Skip to content

Commit

Permalink
Update package pages and user guides with new features.
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Jun 14, 2024
1 parent 66cf113 commit ac4afb4
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 90 deletions.
4 changes: 2 additions & 2 deletions src/routes/packages/client-node/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</header>

<p>
The Nymph Node Client let's you do everything the Nymph Client does, but
from Node.JS instead of the browser.
The Nymph Node Client lets you do everything the Nymph Client does, but from
Node.JS instead of the browser.
</p>

<header class="major">
Expand Down
4 changes: 2 additions & 2 deletions src/routes/packages/client/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let subscription = pubsub.subscribeEntities(
{
type: '&',
'!tag': 'archived',
}
},
)(
(update) => {
// The first time this is called, \`update\` will be an array of Todo
Expand All @@ -95,7 +95,7 @@ let subscription = pubsub.subscribeEntities(
// If you provide this callback, the server will send updates of how many
// clients are subscribed to this query.
userCount = count;
}
},
);
// ...
Expand Down
2 changes: 0 additions & 2 deletions src/routes/packages/guid/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ const customId = customAlphabet('abc', 20)();`}
import bash from 'svelte-highlight/languages/bash';
import typescript from 'svelte-highlight/languages/typescript';
import github from 'svelte-highlight/styles/github';
import { base } from '$app/paths';
</script>
17 changes: 5 additions & 12 deletions src/routes/packages/nymph/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
To use Nymph, you need a database driver. Nymph.js provides a <a
href="{base}/packages/driver-mysql">MySQL driver</a
>, <a href="{base}/packages/driver-postgresql">PostgreSQL driver</a>, and a
<a href="{base}/packages/driver-sqlite3">SQLite3 driver</a>.
<a href="{base}/packages/driver-sqlite3">SQLite3 driver</a>. They all
provide the exact same functionality.
</p>

<header class="major">
Expand Down Expand Up @@ -65,15 +66,15 @@ async function run() {
const otherPendingTodos = await nymph.getEntities(
{ class: Todo },
{ type: '&', '!guid': myEntity.guid, equal: ['done', false] }
{ type: '&', '!guid': myEntity.guid, equal: ['done', false] },
);
const total = otherPendingTodos.length;
const single = total === 1;
console.log(
\`Besides the one I just created, there \${
single ? 'is' : 'are'
} \${total} pending todo\${single ? '' : 's'} in the database.\`
} \${total} pending todo\${single ? '' : 's'} in the database.\`,
);
}`}
/>
Expand All @@ -92,14 +93,6 @@ export default class Todo extends Entity<TodoData> {
static ETYPE = 'todo'; // This is used for the table name(s) in the DB.
static class = 'Todo'; // This is used to map references to their class.
static async factory(guid?: string): Promise<Todo & TodoData> {
return (await super.factory(guid)) as Todo & TodoData;
}
static factorySync(): Todo & TodoData {
return super.factorySync() as Todo & TodoData;
}
constructor() {
super();
Expand All @@ -115,7 +108,7 @@ export default class Todo extends Entity<TodoData> {
// instance of Nymph, so it could be a transactional instance.
const otherTodos = await this.$nymph.getEntities(
{ class: Todo },
{ type: '!&', guid: this.guid }
{ type: '!&', guid: this.guid },
);
return otherTodos;
}
Expand Down
8 changes: 4 additions & 4 deletions src/routes/packages/pubsub/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const nymph = new Nymph(
{},
new SQLite3Driver({
filename: ':memory:', // Put the correct driver/config here.
})
}),
);
PubSub.initPublisher(pubSubConfig, nymph);`}
/>
Expand Down Expand Up @@ -74,7 +74,7 @@ const nymph = new Nymph(
{},
new SQLite3Driver({
filename: ':memory:', // Put the correct driver/config here.
})
}),
);
// Don't forget to do this; even here!
PubSub.initPublisher(pubSubConfig, nymph);
Expand Down Expand Up @@ -108,7 +108,7 @@ const nymph = new Nymph(
{},
new SQLite3Driver({
filename: ':memory:', // Put the correct driver/config here.
})
}),
);
// Don't forget to do this; even here!
PubSub.initPublisher(pubSubConfig, nymph);
Expand All @@ -122,7 +122,7 @@ const server = http.createServer((_request, response) => {
const listener = server.listen(port, () => {
console.log(
new Date().toISOString(),
\`Nymph-PubSub server started listening on port \${port}.\`
\`Nymph-PubSub server started listening on port \${port}.\`,
);
});
const wsServer = new WebSocketServer({
Expand Down
36 changes: 18 additions & 18 deletions src/routes/packages/query-parser/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function doQuery() {
/>

<header class="major">
<h2>Usage</h2>
<h2>Options</h2>
</header>

<p>You can set limit, offset, sort, and reverse like this.</p>
Expand Down Expand Up @@ -172,7 +172,7 @@ async function doQuery() {
<p>Check for a tag.</p>

<ul>
<li><code>&lt;tag&gt;</code> or <code>&lt;!tag&gt;</code></li>
<li><code>{'<name>'}</code> or <code>{'<!name>'}</code></li>
</ul>

<header>
Expand Down Expand Up @@ -206,7 +206,7 @@ async function doQuery() {
<code>{'name<{refclassname inner query}>'}</code> or
<code>{'name!<{refclassname inner query}>'}</code>
<ul>
<li>(Esacpe curly brackets with a leading backslash.)</li>
<li>(Escape curly brackets with a leading backslash.)</li>
<li>
(Requires a map of refclassname to their actual class and default
fields.)
Expand Down Expand Up @@ -306,9 +306,9 @@ async function doQuery() {
<p>Check a prop's value is greater than a given value.</p>

<ul>
<li><code>name&gt;number</code></li>
<li><code>{'name>number'}</code></li>
<li>
<code>name&gt;relative</code>
<code>{'name>relative'}</code>
<ul>
<li>
(A single relative time value like <code>now</code> or
Expand All @@ -317,7 +317,7 @@ async function doQuery() {
</ul>
</li>
<li>
<code>name&gt;"relative time value"</code>
<code>{'name>"relative time value"'}</code>
<ul>
<li>
(Use this for a time value with a space like <code
Expand All @@ -337,9 +337,9 @@ async function doQuery() {
<p>Check a prop's value is greater than or equal to a given value.</p>

<ul>
<li><code>name&gt;=number</code></li>
<li><code>{'name>=number'}</code></li>
<li>
<code>name&gt;=relative</code>
<code>{'name>=relative'}</code>
<ul>
<li>
(A single relative time value like <code>now</code> or
Expand All @@ -348,7 +348,7 @@ async function doQuery() {
</ul>
</li>
<li>
<code>name&gt;="relative time value"</code>
<code>{'name>="relative time value"'}</code>
<ul>
<li>
(Use this for a time value with a space like <code
Expand All @@ -368,9 +368,9 @@ async function doQuery() {
<p>Check a prop's value is less than a given value.</p>

<ul>
<li><code>name&lt;number</code></li>
<li><code>{'name<number'}</code></li>
<li>
<code>name&lt;relative</code>
<code>{'name<relative'}</code>
<ul>
<li>
(A single relative time value like <code>now</code> or
Expand All @@ -379,7 +379,7 @@ async function doQuery() {
</ul>
</li>
<li>
<code>name&lt;"relative time value"</code>
<code>{'name<"relative time value"'}</code>
<ul>
<li>
(Use this for a time value with a space like <code
Expand All @@ -399,9 +399,9 @@ async function doQuery() {
<p>Check a prop's value is less than or equal to a given value.</p>

<ul>
<li><code>name&lt;=number</code></li>
<li><code>{'name<=number'}</code></li>
<li>
<code>name&lt;=relative</code>
<code>{'name<=relative'}</code>
<ul>
<li>
(A single relative time value like <code>now</code> or
Expand All @@ -410,7 +410,7 @@ async function doQuery() {
</ul>
</li>
<li>
<code>name&lt;="relative time value"</code>
<code>{'name<="relative time value"'}</code>
<ul>
<li>
(Use this for a time value with a space like <code
Expand All @@ -435,14 +435,14 @@ async function doQuery() {

<p>Here are some examples of nested selectors.</p>

<pre>Either enabled is truthy and abilities contains "subscriber", or abilities contains "lifelong-subscriber".
<pre>{`Either enabled is truthy and abilities contains "subscriber", or abilities contains "lifelong-subscriber".
(| ([enabled] abilities&lt;"subscriber"&gt;) abilities&lt;"lifeline-subscriber"&gt;)
(| ([enabled] abilities<"subscriber">) abilities<"lifeline-subscriber">)
Published is not truthy and cdate is not greater than 6 months ago.
(! [published] cdate&gt;"6 months ago")</pre>
(! [published] cdate>"6 months ago")`}</pre>

<header class="major">
<h2>Default Fields</h2>
Expand Down
12 changes: 6 additions & 6 deletions src/routes/packages/server/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const nymph = new Nymph(
{},
new SQLite3Driver({
filename: ':memory:',
})
}),
);
const MyEntity = nymph.addEntityClass(MyEntityClass);
Expand All @@ -68,8 +68,8 @@ app.listen(80);`}
</p>

<p>
Now you can configure your <strong>client</strong> using your server's address
(and the optional path, if set).
Now you can configure your <strong>client</strong>, using your server's
address (and the optional path, if set).
</p>

<Highlight
Expand Down Expand Up @@ -117,7 +117,7 @@ const nymph = new Nymph(
new SQLite3Driver({
filename: ':memory:',
}),
tilmeld
tilmeld,
);
const MyEntity = nymph.addEntityClass(MyEntityClass);
Expand Down Expand Up @@ -153,8 +153,8 @@ app.user(
{
restUrl: 'https://mydomain.tld/rest',
},
nymph
)
nymph,
),
);
// Do anything else you need to do...
Expand Down
4 changes: 2 additions & 2 deletions src/routes/packages/tilmeld-client/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<p>
The Tilmeld client contains the client versions of the <code>User</code> and
<code>Group</code>
entities. It also contains helpers, <code>getClientConfig</code>,
<code>login</code>, <code>register</code>, and <code>checkUsername</code>.
entities. It also contains helpers, <code>login</code>,
<code>register</code>, and <code>checkUsername</code>.
</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/packages/tilmeld-components/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<p>
The Tilmeld Components are front end registration/login, account recovery,
account details, and password change components build with <a
account details, and password change components built with <a
href="https://svelte.dev/"
target="_blank">Svelte</a
>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/packages/tilmeld-setup/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const nymph = new Nymph(
verifyChangeRedirect: 'http://localhost',
cancelChangeRedirect: 'http://localhost',
jwtSecret: 'shhhhh',
})
}),
);
// Create your Express app.
Expand All @@ -86,8 +86,8 @@ app.use(
{
restUrl: 'http://localhost/rest',
},
nymph
)
nymph,
),
);
// Do anything else you need to do...
Expand Down
5 changes: 3 additions & 2 deletions src/routes/packages/tilmeld/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const nymph = new Nymph(
new SQLite3Driver({
filename: ':memory:',
}),
tilmeld
tilmeld,
);
// These are the classes specific to this instance of Tilmeld.
Expand All @@ -84,7 +84,8 @@ const { User, Group } = tilmeld;`}

<ul>
<li>
<code>system/admin</code> - A user with this ability has **all** abilities.
<code>system/admin</code> - A user with this ability has
<strong>all</strong> abilities.
</li>
<li>
<code>tilmeld/admin</code> - Allow the user to manage and edit other user's
Expand Down
Loading

0 comments on commit ac4afb4

Please sign in to comment.