@blueshed/joined 0.1.20 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/joined/SKILL.md +1 -1
- package/.claude/skills/joined/reference.md +96 -17
- package/docs/design.md +31 -8
- package/examples/cafe/kitchen.ts +2 -2
- package/examples/desk/card.ts +43 -0
- package/examples/desk/desk.css +17 -0
- package/examples/desk/desk.json +41 -0
- package/examples/desk/generated/elements.ts +69 -0
- package/examples/desk/generated/queries.ts +33 -0
- package/examples/desk/generated/rules.ts +94 -0
- package/examples/desk/index.html +34 -0
- package/examples/desk/lanes.css +126 -0
- package/examples/desk/lanes.ts +133 -0
- package/examples/desk/migrations/001-desk.ts +8 -0
- package/examples/desk/page.ts +29 -0
- package/examples/desk/pulse.ts +20 -0
- package/examples/desk/routes.ts +9 -0
- package/examples/desk/steps.ts +32 -0
- package/examples/desk/stories.jsonl +18 -0
- package/examples/desk/tally.css +62 -0
- package/examples/desk/tally.ts +76 -0
- package/examples/desk/thumbs.ts +45 -0
- package/examples/desk/trust.ts +24 -0
- package/examples/desk/words.ts +17 -0
- package/examples/trip/bar.ts +1 -1
- package/examples/trip/calendar-map.css +2 -0
- package/examples/trip/drags.ts +3 -3
- package/examples/trip/drawer.ts +5 -5
- package/examples/trip/event-form.ts +8 -7
- package/examples/trip/holding.ts +1 -1
- package/examples/trip/ics.ts +22 -112
- package/examples/trip/line-stops.ts +1 -1
- package/examples/trip/line-words.ts +1 -1
- package/examples/trip/line.ts +1 -1
- package/examples/trip/map.ts +1 -1
- package/examples/trip/month.ts +1 -1
- package/examples/trip/other-weeks.ts +1 -1
- package/examples/trip/page.ts +2 -2
- package/examples/trip/peek.ts +1 -1
- package/examples/trip/routes.ts +3 -3
- package/examples/trip/shell.ts +3 -3
- package/examples/trip/stays.ts +1 -1
- package/examples/trip/week.ts +1 -1
- package/examples/trip/writes.ts +1 -1
- package/examples/trips/card.ts +1 -1
- package/examples/trips/map.ts +1 -1
- package/examples/weeks/derive.ts +1 -1
- package/package.json +7 -1
- package/src/attachment.ts +7 -2
- package/src/demo.css +29 -26
- package/src/demo.ts +2 -2
- package/src/draft.ts +23 -8
- package/src/files.ts +24 -8
- package/{examples/trip/mercator.ts → src/geo.ts} +13 -3
- package/src/icon-names.ts +4 -0
- package/src/ics.ts +130 -0
- package/src/members/panel.css +208 -201
- package/src/members/panel.ts +17 -8
- package/src/outbox.ts +70 -0
- package/src/page.css +76 -70
- package/src/page.ts +79 -14
- package/src/parts.css +575 -428
- package/src/parts.ts +18 -5
- package/{examples/trip → src}/place-search.ts +5 -5
- package/{examples/trip → src}/places.ts +9 -7
- package/src/rank.ts +20 -0
- package/src/scrim.ts +81 -0
- package/src/server.ts +28 -1
- package/{examples/trip → src}/time.ts +37 -5
- package/src/tokens.css +5 -0
- package/src/tokens.json +35 -0
|
@@ -14,4 +14,4 @@ A new app goes stories → compile → folder → look → links → tests: §2,
|
|
|
14
14
|
`node_modules/joined/` (`src/`, `examples/`, `docs/`); joined's `tests/` isn't shipped, and an app's tests
|
|
15
15
|
are its own (`tests/`, its stories told). Copy from joined's examples, smallest first.
|
|
16
16
|
|
|
17
|
-
The rules, and the gate, are CLAUDE.md's. Traps already met are §13; the store, its migrations, and running elsewhere, §14 (and §3).
|
|
17
|
+
The rules, and the gate, are CLAUDE.md's. Traps already met are §13; the store, its migrations, and running elsewhere, §14 (and §3); views to copy, §16.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
| 2 | [Stories, the source](#2-stories-the-source) | `examples/people/stories.jsonl` (the smallest with members), `examples/trip/stories.jsonl`, `tests/compile.test.ts` |
|
|
7
7
|
| 3 | [What the compiler writes](#3-what-the-compiler-writes) | `examples/trip/generated/` |
|
|
8
8
|
| 4 | [A view: an item element given a look](#4-a-view-an-item-element-given-a-look) | `examples/trip/stays.ts` (the smallest), `examples/hello/page.ts` (a Draft), `examples/cafe/menu.ts` (a drawer) |
|
|
9
|
-
| 5 | [A display: a collection drawn in a shadow](#5-a-display-a-collection-drawn-in-a-shadow) | `examples/cafe/kitchen.ts` (the smallest), `examples/cafe/rail-drag.ts` (a drag), `examples/trip/calendar-map.ts` (grown, a part a file) |
|
|
9
|
+
| 5 | [A display: a collection drawn in a shadow](#5-a-display-a-collection-drawn-in-a-shadow) | `examples/cafe/kitchen.ts` (the smallest), `examples/desk/tally.ts` (one that holds nothing), `examples/cafe/rail-drag.ts` (a drag), `examples/trip/calendar-map.ts` (grown, a part a file) |
|
|
10
10
|
| 6 | [Links between documents](#6-links-between-documents) | an event's `people`; `examples/people/links.ts` |
|
|
11
11
|
| 7 | [Several documents on a page](#7-several-documents-on-a-page) | `examples/cafe/index.html`, `examples/trip/index.html` |
|
|
12
12
|
| 8 | [Routes: pages and edges](#8-routes-pages-and-edges) | `examples/hello/routes.ts`, `examples/cafe/routes.ts`, `examples/trip/routes.ts` |
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
| 13 | [Traps](#13-traps) | met while building |
|
|
18
18
|
| 14 | [Seeds, the store, and running it elsewhere](#14-seeds-the-store-and-running-it-elsewhere) | `examples/trip/trip.json`, `src/store.ts`, `src/migrate.ts` |
|
|
19
19
|
| 15 | [What stories can't show: definitions, an app's own rules, a kind](#15-what-stories-cant-show-definitions-an-apps-own-rules-a-kind) | `examples/cafe/stories.jsonl`, `src/definitions.ts` |
|
|
20
|
+
| 16 | [Recipes: views to copy](#16-recipes-views-to-copy) | `examples/desk/` (lanes, moves, thumbs, a tally, a glow, a rank), and the rest by where they're shown |
|
|
20
21
|
|
|
21
22
|
## 1. Start an app
|
|
22
23
|
|
|
@@ -55,8 +56,9 @@ element is the document); with the group and a collection, `examples/trips/`.
|
|
|
55
56
|
**An app imports joined by its name, never by a path into `src/`,** as a project that takes joined as
|
|
56
57
|
a dependency would; `tests/package.test.ts` refuses `../src/` under `examples/`. The names are
|
|
57
58
|
`package.json`'s `exports`: `joined/page` (`Answer`, `ask`), `joined/keep` (`keep`, `Row`), `joined/draft`,
|
|
58
|
-
`joined/parts` (`PARTS`, `face`, `said`, `askFirst`, `showsOpen`, `inHash`, `typeahead`), `joined/follow` (`follow`,
|
|
59
|
-
`held`), `joined/
|
|
59
|
+
`joined/parts` (`adopt`, `PARTS`, `face`, `said`, `askFirst`, `showsOpen`, `inHash`, `typeahead`), `joined/follow` (`follow`,
|
|
60
|
+
`held`), `joined/time`, `joined/ics`, `joined/geo`, `joined/places`, `joined/place-search`, `joined/rank` (time, places and order: §16's
|
|
61
|
+
"Shared, not copied"), `joined/icons`, `joined/hues` (`hueOf`), `joined/panel` (`members`, `signedIn`, `group`: §11), `joined/toast`, `joined/client` (`open`),
|
|
60
62
|
`joined/stories` (`tell`), `joined/migrate`, `joined/server` (the type `Read`), `joined/compile`; and in a page's HTML
|
|
61
63
|
`joined/tokens.css`, `joined/page.css`, `joined/icon.png` (`joined/parts.css` and `joined/tokens.json` are there for
|
|
62
64
|
a design system). The compiler writes `joined/page` and `joined/migrate` too.
|
|
@@ -229,9 +231,13 @@ is opened or closed, and `again()`, called as the items change, to open one name
|
|
|
229
231
|
The draft is `Draft` from `joined/draft`, given the form (Save named `go`, Never mind `never`) and
|
|
230
232
|
its note. `fill(saved, afresh)` sets the controls as the document has the item: afresh, all of
|
|
231
233
|
them; on a change from elsewhere (call it from the `MutationObserver`), only those not being
|
|
232
|
-
changed here. `edits()` is what's changed, by control name; `show("kept" | "changed" | "new")` says
|
|
233
|
-
so and turns Save and Never mind on or off
|
|
234
|
-
|
|
234
|
+
changed here. `edits()` is what's changed, by control name; `show("kept" | "changed" | "new", ready?)` says
|
|
235
|
+
so and turns Save and Never mind on or off, Save off too while it isn't `ready` (a new event's title not given);
|
|
236
|
+
`refuse(why)` says a refusal until `refuse("")`. `inside(drawer, close, never)` makes its drawer's × (named
|
|
237
|
+
`close`, at the end of its head) where the form has none, and has the ×, Escape and, on a phone, a tap on the dimmed
|
|
238
|
+
page close it. Every drawer that changes something is one, whether or not it holds its fields against the document
|
|
239
|
+
(a drawer that adds says its state by `show()` alone). What the changes are as ops (a time made a duration, an
|
|
240
|
+
emptied field cleared) stays the page's own.
|
|
235
241
|
|
|
236
242
|
Working, smallest first:
|
|
237
243
|
- `examples/trip/stays.ts`: a view of an item (its name changed in place, a way to cancel it), and a form that adds.
|
|
@@ -244,7 +250,7 @@ Working, smallest first:
|
|
|
244
250
|
- `examples/people/view.ts` (a person's row), `links.ts` (what links to them, kept as links come and go), `order.ts`
|
|
245
251
|
(dragged by a grip), `adding.ts` (the page's form).
|
|
246
252
|
- `examples/trip/event-form.ts` with `drawer.ts` and `writes.ts`: a `Draft` grown, in a drawer, its fields derived (a
|
|
247
|
-
time made a duration), its parts a file each (`zones.ts`, `
|
|
253
|
+
time made a duration), its parts a file each (`zones.ts`, `people-chips.ts`, `answer-rows.ts`; its place search is `joined/place-search`).
|
|
248
254
|
|
|
249
255
|
A file field (a post's photo, a PDF) is `attachment(doc, put, take?)` from `joined/attachment`: `el` to append, and
|
|
250
256
|
`draw(value, { put, take })` called from the view's `draw()` with the item's value and its `may`
|
|
@@ -283,6 +289,11 @@ It never shows it, and draws its items in its shadow DOM:
|
|
|
283
289
|
`iconify(this.#root)` (§10).
|
|
284
290
|
- **Another display's request** comes as an event on the item: `pick`, bubbling, is how the
|
|
285
291
|
people's links pick an event on the calendar.
|
|
292
|
+
- **Who changed it, and by what:** each change put on the page fires `changed` on every element it left changed (an
|
|
293
|
+
item, or a document's own), bubbling, once it's in: `detail.by` the member who made it (null: nobody's, a
|
|
294
|
+
stranger's page or the server's own) and `detail.via` the label of the agent's link it came through (`"claude"`;
|
|
295
|
+
null: a page's). An item removed has none left to say it. A display listening on itself hears its items', so a
|
|
296
|
+
row an agent changed can say so for a moment. Working: `tests/pages.test.ts` ("a change says who made it").
|
|
286
297
|
|
|
287
298
|
Working: `examples/cafe/kitchen.ts`, the smallest (about 130 lines: tickets kept by `keep` in columns, a ticket made
|
|
288
299
|
again only as its order changes, the waits each minute), and `examples/cafe/rail-drag.ts`, the smallest drag (30
|
|
@@ -326,9 +337,14 @@ and so is one put back while another of its document's collections kept it held
|
|
|
326
337
|
The server logs each write a page sends as one line: `write trip by member 1: done, version 12`, or
|
|
327
338
|
`refused, <why>` (quiet under `bun test`; `start({ log })` takes another).
|
|
328
339
|
|
|
329
|
-
When the socket drops (a phone asleep, a redeploy), the page is away (`body[data-away]`,
|
|
330
|
-
`away` event; `back` when it returns; the group's button says "· back soon")
|
|
331
|
-
|
|
340
|
+
When the socket drops (a phone asleep, a redeploy, a train with no signal), the page is away (`body[data-away]`,
|
|
341
|
+
and the `away` event; `back` when it returns; the group's button says "· back soon"). A write that only adds (every
|
|
342
|
+
op `add` at a collection's end: a cost, a person) is kept on the device (`src/outbox.ts`, under who wrote it), its
|
|
343
|
+
sender answered at once, and the page told what's waiting (`body[data-waiting]`, the `waiting` event, the group's
|
|
344
|
+
bar: "2 waiting for signal"); it's sent by itself once the page is back and holds its documents again, oldest first,
|
|
345
|
+
and one refused then is said in the toast and let go. Anything else it sends is refused at once (an edit made away
|
|
346
|
+
could overwrite what changed meanwhile: a Draft keeps it to save again), and it comes back by itself, each document
|
|
347
|
+
put in place by key. Only
|
|
332
348
|
the server closing it on purpose, or the door refusing it, signs it out. A write refused, draw again,
|
|
333
349
|
and a display shows nothing as saved that wasn't. A socket can die with no close (the browser still calls it
|
|
334
350
|
open): woken, or its network back, the page asks it (`{ subscribe, id: 0 }`, answered `{ done: 0 }`), and one
|
|
@@ -399,10 +415,11 @@ Working: `examples/hello/routes.ts`, the smallest; `examples/cafe/routes.ts` (an
|
|
|
399
415
|
for them, as them (their grants, the app's trust), once; then the act is gone. The people's `person`: the person
|
|
400
416
|
they were invited as is them.
|
|
401
417
|
|
|
402
|
-
- **A file a document names** is joined's own route, never an app's: `POST /files?doc=<doc>` (the bytes the body)
|
|
418
|
+
- **A file a document names** is joined's own route, never an app's: `POST /files?doc=<doc>&name=<its file's name>` (the bytes the body)
|
|
403
419
|
by whoever may put a file in that document (an add to a collection with a file field, or its replace: a member by
|
|
404
420
|
their link, a guest by its code), from this site alone (another site's is refused); a photo made a WebP (1600px, no
|
|
405
|
-
EXIF), an SVG and a PDF as they are (an SVG served sandboxed: opened by its path, nothing in it runs),
|
|
421
|
+
EXIF), an SVG and a PDF as they are (an SVG served sandboxed: opened by its path, nothing in it runs), a Markdown
|
|
422
|
+
file as it is where its name says so (`.md`, `.markdown`) and it's text (served as text/markdown), under 20 MB
|
|
406
423
|
and 50 megapixels, else refused in words; answered `{ file }`. Kept by its
|
|
407
424
|
content's hash in `files/` beside the store, or where `JOINED_FILES` says: another folder, or a bucket,
|
|
408
425
|
`s3://<bucket>/<prefix>` (Bun's S3 client, its keys, endpoint and region from `S3_*` or `AWS_*` in the
|
|
@@ -417,10 +434,22 @@ Working: `examples/hello/routes.ts`, the smallest; `examples/cafe/routes.ts` (an
|
|
|
417
434
|
- **Every page's layout,** `src/page.css` (`joined/page.css`), linked after the tokens: the body, `h1`, `h2`,
|
|
418
435
|
`.note`, `.bar`, `#said`, and `main` hidden signed out and dimmed away. A page's own look comes after it.
|
|
419
436
|
- **The parts,** `src/parts.css`, once: buttons, fields, labels, the drawer (`.drawer`), the modal
|
|
420
|
-
(`dialog`)
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
field's look in a display's own sheet:
|
|
437
|
+
(`dialog`), the sheet (`.sheet`, a popover with a title and its ×) and a fixed foot (`.j-foot`). Adopted by the
|
|
438
|
+
page and every shadow (`src/parts.ts`; a display's: `adopt(this.#root, SHEET)`, which also has its modals, sheets
|
|
439
|
+
and drawers dim the page by its one scrim). A button with words is `.act` (`.ink`, `.danger`, `.quiet`), one with
|
|
440
|
+
its icon alone `.icon-only`; a field needs no class. Never a button's or a field's look in a display's own sheet:
|
|
441
|
+
only how it sits (`flex: 1`).
|
|
442
|
+
- **An app's rule wins over joined's:** the parts, the page's layout and the group's look are a layer, `joined`,
|
|
443
|
+
beneath anything of the app's own, whatever its specificity: never `.link.link`, nor adopting a sheet after
|
|
444
|
+
joined's to win. So an app's reset (`button { font: inherit; color: inherit }`) would win over a part too, and a
|
|
445
|
+
filled Save's words would take the page's ink: put it in `@layer reset { … }`, which joined's sheets name beneath
|
|
446
|
+
theirs (`@layer reset, joined;`), wherever it's written. The group is reached by its
|
|
447
|
+
parts: `members-panel::part(sheet)` (`bar`, `who`, `notice`, `sheet`, `menu`, `ask`, `waiting`).
|
|
448
|
+
- **How it moves,** `src/tokens.json`'s motion (`--rise`, `--fall`, `--ask`, `--ask-out`, `--drop`): a drawer or a
|
|
449
|
+
sheet rises (from the foot on a phone, a drawer from the right where it docks), a modal settles, a menu drops; on
|
|
450
|
+
a phone a drawer and a sheet are a phone's sheet (rounded at the top, a grabber), the page dimmed behind by one
|
|
451
|
+
scrim (`src/scrim.ts`) that fades in every browser, a tap on it closing the drawer on top. Never a surface's
|
|
452
|
+
motion or scrim of an app's own.
|
|
424
453
|
- **Type** is nine styles, each a font in `src/tokens.css`: `font: var(--font-row)` (`body`,
|
|
425
454
|
`heading`, `title`, `row`, `label`, `tool`, `small`, `tiny`, `field`). Never a size by hand.
|
|
426
455
|
- **The colours,** `src/tokens.css` (`--paper`, `--card`, `--ink`, `--muted`, `--line`, `--edge`, `--add`,
|
|
@@ -441,9 +470,10 @@ Working: `examples/hello/routes.ts`, the smallest; `examples/cafe/routes.ts` (an
|
|
|
441
470
|
- **A display's,** imported as text and adopted in its shadow:
|
|
442
471
|
|
|
443
472
|
```ts
|
|
473
|
+
import { adopt } from "joined/parts";
|
|
444
474
|
import STYLE from "./calendar-map.css" with { type: "text" };
|
|
445
475
|
const SHEET = new CSSStyleSheet(); SHEET.replaceSync(STYLE);
|
|
446
|
-
this.#root
|
|
476
|
+
adopt(this.#root, SHEET); // joined's parts, then its own
|
|
447
477
|
```
|
|
448
478
|
|
|
449
479
|
Sizes the code draws with are custom properties set on the host (`--hour`), so the numbers live
|
|
@@ -766,3 +796,52 @@ Working: `src/members/`; `tests/sign-in.test.ts`; `tests/mcp.test.ts` (the door)
|
|
|
766
796
|
(`tests/definitions.test.ts`), fills and timed on a tally (`tests/writes.test.ts`); a Padlet (`tests/padlet`, `tests/padlet.test.ts`): item roles in
|
|
767
797
|
a kind, `"me"`, moves from a premise and an add's first step, `gone: "with"`, and a board's secret link, and its settings, frozen and waits (`tests/settings`), and visitor levels (`tests/visitors`); a write across documents (`tests/together`); a post's file
|
|
768
798
|
(`tests/attachments`).
|
|
799
|
+
|
|
800
|
+
## 16. Recipes: views to copy
|
|
801
|
+
|
|
802
|
+
A view or a display an app keeps building, each a file to copy whole and rename. Each says, at its head, what it is,
|
|
803
|
+
what it reads (an item's `data` and its `may`), and the one write it sends. Find the one nearest what you need, copy
|
|
804
|
+
it beside your page, and change its names to your collection's; the rules of §4 and §5 hold in each.
|
|
805
|
+
|
|
806
|
+
The desk (`examples/desk/`, `/desk`) is tasks an agent works through and a person steers, and each part of its page is
|
|
807
|
+
one:
|
|
808
|
+
|
|
809
|
+
| Recipe | File | What it is | Its kind elsewhere |
|
|
810
|
+
|---|---|---|---|
|
|
811
|
+
| Lanes, dragged | `lanes.ts` | A display: a collection in lanes by a field, each in the collection's order, kept by `keep`; a card let go in another lane makes the step its `may` offers, and lands between the cards it's let go between, one write for both. | the kitchen's rail (fixed steps), cardlet's columns, idea-cards' stacks |
|
|
812
|
+
| The moves `may` offers | `steps.ts` | A button for each step of a `moves` field this person may make from where the item is (`replace:status>review`), its words the page's by from and to ("Send back"): the stories say which there are and whose. | a post held for approval, an order's next move |
|
|
813
|
+
| Thumbs | `thumbs.ts`, `trust.ts` | Up or down as two lists of ids (`ups`, `downs`, links to members): yours pressed, the other taken back in the same write (`write()` of the compiled elements); `trust.ts` holds a thumb to its giver, one an item. | idea-cards' thumbs, cardlet's votes |
|
|
814
|
+
| A summary strip (V6) | `tally.ts` | A display that holds nothing: it reads the page's live list and watches the collection for what it shows alone (`attributeFilter`: status, points), sums once a moment (`queueMicrotask`), and moves only a part's width and its words. Counts by a field, done of all, a sum; its parts tones of ink, never hues (a hue is a person's). | bluecount's totals and where it went, the cafe's books |
|
|
815
|
+
| What just changed | `pulse.ts` | A row `keep` makes again for a change glows a moment, not on the first drawing, nor when it's drawn for someone else; the display's own row glows (a class in its shadow), never the document's element. | an agent's work seen as it lands |
|
|
816
|
+
| A rank between | `joined/rank` | Where a thing let go lands among others: its place, and a rank halfway between its neighbours (one less than the first, one more than the last), so one write moves it. | the people's order, cardlet's columns |
|
|
817
|
+
|
|
818
|
+
Who added an item is a field the server fills (`{"fills":{"tasks":{"by":"me"}}}`), drawn as their face. Who made the
|
|
819
|
+
last change isn't told to a view yet (the ledger's #89, `docs/view-plan.md`'s step 3). The plan's V4 (a queue to
|
|
820
|
+
approve) and V5 (filter by a link, a link matrix) are recipes still to add here (its step 8).
|
|
821
|
+
|
|
822
|
+
Elsewhere, by what it does:
|
|
823
|
+
|
|
824
|
+
- A row changed in place and taken away: `examples/trip/stays.ts`. A drawer with a draft: `examples/cafe/menu.ts`.
|
|
825
|
+
- A form on the page that adds, its refusal said under it: `examples/people/adding.ts`, the desk's `page.ts`.
|
|
826
|
+
- What links to an item, kept as links come and go: `examples/people/links.ts`.
|
|
827
|
+
- Dragged in order by a grip, or the arrow keys: `examples/people/order.ts`.
|
|
828
|
+
- A list of people as chips, a typeahead past six: `examples/trip/people-chips.ts`.
|
|
829
|
+
- Each person's answer to an item, a list of ids each: `examples/trip/answer-rows.ts`, `answers.ts`.
|
|
830
|
+
- A file on an item: `attachment()` (§4), `tests/attachments/board/page.ts`.
|
|
831
|
+
- When and where by a hand (a calendar, a map): `examples/trip/calendar-map.ts` and its parts.
|
|
832
|
+
|
|
833
|
+
**Shared, not copied.** What three apps repeated is joined's, imported by name, never copied (each told in
|
|
834
|
+
`tests/`, the place search by the trip's page):
|
|
835
|
+
|
|
836
|
+
- `joined/time`: a start a wall clock kept as if UTC (`wall`, `local`, `hhmm`, `now`), a day a count (`dayOf`,
|
|
837
|
+
`mondayOf`, `weekOf`, `firstOf`, `gridOf`, `dated`), a length ISO 8601 (`seconds`, `iso`, `ends`), said and typed as
|
|
838
|
+
people do (`lasts`: PT2H30M is "2h 30m"; `lengthOf`: "1.5h" is PT1H30M), a drag's quarter hour (`snap`, `SNAP`),
|
|
839
|
+
`hours`, `stayed`, `on`. A time is never `new Date(start)`: that reads a wall clock in the browser's zone.
|
|
840
|
+
- `joined/geo`: a `geo:` value read (`geo`) and made (`geoOf`), Open in Maps (`mapsLink`), and Web Mercator over
|
|
841
|
+
OpenStreetMap's tiles (`world`, `placeAt`, `bounds`, `tileAt`, `TILE`).
|
|
842
|
+
- `joined/places`: Photon's `find(q, near?)` and `nameOf(point)`; `joined/place-search`'s `PlaceSearch` offers what's
|
|
843
|
+
found beneath a field.
|
|
844
|
+
- `joined/rank`: `between(before?, after?)` and `landing(rows, ranks, y)`.
|
|
845
|
+
- `joined/ics`: `toIcs(events, name)`, each event a `uid` (the same each time: a feed's calendar changes it, not adds
|
|
846
|
+
it again), its `zone`, `location`, `coordinates`, `description`, `url` and `attendees` where it has them; and
|
|
847
|
+
`fromIcs(text)`. Served as `text/calendar`, it's a download or a feed (`webcal://`); the trip's `routes.ts`.
|
package/docs/design.md
CHANGED
|
@@ -18,14 +18,18 @@ and offers nothing they can't.
|
|
|
18
18
|
|
|
19
19
|
- **The page** shows what is here: a document's collection, in its readings.
|
|
20
20
|
- **A drawer** (Drawer) is editing: one thing's own fields, its deeds at its foot. Docked at the
|
|
21
|
-
right, `panel` wide; on a phone, a sheet
|
|
22
|
-
Its changes wait in it until Save.
|
|
21
|
+
right, `panel` wide, the page beside it as it was; on a phone, a sheet risen from the foot, the page dimmed
|
|
22
|
+
above it. Its changes wait in it until Save.
|
|
23
23
|
- **A modal** (Modal, New event) is new or delete: one question, one answer, gone. It never edits.
|
|
24
24
|
Removing, or anything that can't be taken back, is always asked first in the app's own modal,
|
|
25
25
|
never the browser's `confirm()`.
|
|
26
26
|
- **A sheet** (Sheet, The group) shows a list beside the page. It has a title and its ×, and closes
|
|
27
27
|
when you tap away. A form in it is laid out as a drawer's: its fields one under another, its deeds at
|
|
28
28
|
its foot, removing apart.
|
|
29
|
+
- **On a phone, a drawer and a sheet are a phone's sheet:** the width of the screen, risen from the foot,
|
|
30
|
+
rounded at the top (`radius-sheet`), a grabber on its head, the page dimmed behind by its one scrim; a tap on
|
|
31
|
+
the dimmed page closes a drawer, as its × does, and takes a sheet away. A modal dims the page by the same
|
|
32
|
+
scrim anywhere, over the drawer it asks over.
|
|
29
33
|
- **Each keeps its head and its foot in view.** A drawer, a modal and a sheet always show what it is
|
|
30
34
|
(its title, its ×) and what you may do (its deeds, a sheet's add field); only what's between them
|
|
31
35
|
scrolls, however tall it grows, under a band of its card (8px) below the head and above the foot, so
|
|
@@ -43,7 +47,8 @@ place with a picture is drawn as it (a trip is its week and its map), never as a
|
|
|
43
47
|
### What a tap does
|
|
44
48
|
|
|
45
49
|
- A tap on something named is that thing, in one tap.
|
|
46
|
-
- Nothing opens by itself, and closing changes nothing. One thing open at a time; Escape closes it
|
|
50
|
+
- Nothing opens by itself, and closing changes nothing. One thing open at a time; Escape closes it, wherever
|
|
51
|
+
you are.
|
|
47
52
|
Back closes it too, what's open being in the URL's hash (`#event=2`), so a link opens it again.
|
|
48
53
|
- Offer only what this person may do: each element's `may` says it, from the grants and their roles
|
|
49
54
|
(`add` on a collection; `remove`, `replace:price`, a move `replace:status>ready` on an item), and a
|
|
@@ -52,7 +57,10 @@ place with a picture is drawn as it (a trip is its week and its map), never as a
|
|
|
52
57
|
- Every write says what it did, where the person is: done, the change shows, on every page alike;
|
|
53
58
|
refused, and why, beside the control that sent it (Said), to that person alone. Nothing typed is
|
|
54
59
|
lost to a refusal.
|
|
55
|
-
- Away, what's shown dims, as it may be behind, and the group's button says it's coming back (Away).
|
|
60
|
+
- Away, what's shown dims, as it may be behind, and the group's button says it's coming back (Away). What's
|
|
61
|
+
added meanwhile (a cost, a person: a write that only adds) is kept on the device and the group's bar says how
|
|
62
|
+
many wait for signal; it's sent once the page is back, and one refused then is said. Anything else is refused
|
|
63
|
+
at once, so an edit made before it can't overwrite what changed meanwhile, and the drawer keeps it to save again.
|
|
56
64
|
|
|
57
65
|
### What a drag does
|
|
58
66
|
|
|
@@ -129,8 +137,19 @@ Icons assets).
|
|
|
129
137
|
that runs to the screen's edges bleeds by the gutter's name, `calc(-1 * var(--gutter))`, never its number.
|
|
130
138
|
- **Every space is a token** (`space-4` … `space-64`), on one scale, never a number of rem or px by hand.
|
|
131
139
|
- **Under a finger, 44px:** a button (`touch`), an icon button (`control`) and a field.
|
|
132
|
-
- **4px corners everywhere** (`radius`), a card's too; 3px inside a 4px box; a tag is a pill; a dot and a face are
|
|
133
|
-
|
|
140
|
+
- **4px corners everywhere** (`radius`), a card's too; 3px inside a 4px box; a tag is a pill; a dot and a face are
|
|
141
|
+
round; on a phone, a drawer's and a sheet's top corners are 14px (`radius-sheet`), as a phone's sheet.
|
|
142
|
+
- **No shadows.** A drawer, a modal and a sheet are set apart by a 1px `edge`; on a phone, a drawer and a sheet by
|
|
143
|
+
the scrim behind them alone.
|
|
144
|
+
- **A foot fixed at the screen's foot** (a quick add, a balance) is `.j-foot`: it runs on past the screen's foot
|
|
145
|
+
by 40vh, its words lifted by as much, so nothing of the page shows under it where an iPhone's address bar floats
|
|
146
|
+
and comes and goes.
|
|
147
|
+
- **An app's rule wins over a part:** the parts (and joined's page, the group's and the demo's sheets) are a
|
|
148
|
+
layer, `joined`, beneath anything of the app's own, whatever its specificity; an app's reset
|
|
149
|
+
(`button { font: inherit }`) goes in `@layer reset`, which joined names beneath its own. A display gives its shadow the
|
|
150
|
+
parts by `adopt(root, …its own sheets)`, so its modals, sheets and drawers dim the page as the page's do; the
|
|
151
|
+
group takes an app's touch by its parts, `members-panel::part(sheet)` (bar, who, notice, sheet, menu, ask,
|
|
152
|
+
waiting).
|
|
134
153
|
|
|
135
154
|
## Words
|
|
136
155
|
|
|
@@ -144,5 +163,9 @@ Icons assets).
|
|
|
144
163
|
|
|
145
164
|
## Motion
|
|
146
165
|
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
Things come and go as an iPhone's do (`src/tokens.json`, motion): a drawer or a sheet rises into place in
|
|
167
|
+
`rise` (420ms, quick then a long soft settle) and goes back the way it came in `fall` (280ms), from the foot on
|
|
168
|
+
a phone, a drawer from the right where it docks, a sheet a little from below; the scrim fades with them. A
|
|
169
|
+
modal settles in from a little larger in `ask` and fades as it shrinks a little in `ask-out`; a menu drops a
|
|
170
|
+
few pixels from its button in `drop`; the Toast fades. Nothing else moves, and under
|
|
171
|
+
`prefers-reduced-motion` nothing does (`src/parts.css`).
|
package/examples/cafe/kitchen.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import "joined/panel";
|
|
11
11
|
import "joined/toast";
|
|
12
12
|
import { keep, type Row } from "joined/keep";
|
|
13
|
-
import {
|
|
13
|
+
import { adopt, said } from "joined/parts";
|
|
14
14
|
import * as kitchen from "./generated/kitchen.rules.ts";
|
|
15
15
|
import { JLine, JOrder } from "./generated/kitchen.elements.ts";
|
|
16
16
|
import { dragged } from "./rail-drag.ts";
|
|
@@ -48,7 +48,7 @@ class KitchenRail extends HTMLElement {
|
|
|
48
48
|
#ticking?: ReturnType<typeof setInterval>;
|
|
49
49
|
// on the page, it watches what it holds and the clock; off it, neither
|
|
50
50
|
connectedCallback() {
|
|
51
|
-
if (!this.#rail.parentNode) ((this.#root
|
|
51
|
+
if (!this.#rail.parentNode) (adopt(this.#root, SHEET), this.#root.append(this.#rail));
|
|
52
52
|
this.#watching.observe(this, { subtree: true, childList: true, attributes: true });
|
|
53
53
|
this.#ticking = setInterval(() => this.#draw(), 60_000);
|
|
54
54
|
this.#draw();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// A task's card, as the lanes draw it (a row kept by key, made again only as what it shows changes): its title, who
|
|
2
|
+
// put it on the desk (their face and name: the server filled it, "me") and its points, its thumbs (./thumbs.ts), and
|
|
3
|
+
// the moves its person may make from where it is (./steps.ts), a refusal said under them.
|
|
4
|
+
|
|
5
|
+
import type { Row } from "joined/keep";
|
|
6
|
+
import { members } from "joined/panel";
|
|
7
|
+
import { face } from "joined/parts";
|
|
8
|
+
import type { JTask } from "./generated/elements.ts";
|
|
9
|
+
import { steps } from "./steps.ts";
|
|
10
|
+
import { thumbs } from "./thumbs.ts";
|
|
11
|
+
import { MOVES } from "./words.ts";
|
|
12
|
+
|
|
13
|
+
/** A member's name, as the group on the page has it: none, once they've left. */
|
|
14
|
+
export const nameOf = (id?: number) =>
|
|
15
|
+
id === undefined ? "" : ([...members].find((m) => m.key === id)?.data.name ?? "");
|
|
16
|
+
|
|
17
|
+
/** A task's card, for `me` (none: signed in as nobody). */
|
|
18
|
+
export function card(task: JTask, me: number | undefined): Row {
|
|
19
|
+
const { title, points, by, status = "queued" } = task.data,
|
|
20
|
+
who = nameOf(by);
|
|
21
|
+
return {
|
|
22
|
+
key: String(task.key),
|
|
23
|
+
shows: JSON.stringify([task.data, task.getAttribute("may"), me, who]),
|
|
24
|
+
make: () => {
|
|
25
|
+
const li = Object.assign(document.createElement("li"), { className: "card" }),
|
|
26
|
+
line = Object.assign(document.createElement("p"), { className: "said", role: "status" }),
|
|
27
|
+
meta = Object.assign(document.createElement("p"), { className: "meta" }),
|
|
28
|
+
acts = Object.assign(document.createElement("p"), { className: "acts" });
|
|
29
|
+
li.dataset.key = String(task.key);
|
|
30
|
+
if (who) meta.append(face(by!, who), who, " · ");
|
|
31
|
+
meta.append(`${points} point${points === 1 ? "" : "s"}`);
|
|
32
|
+
acts.append(...steps(task, "status", status, MOVES, line));
|
|
33
|
+
li.append(
|
|
34
|
+
Object.assign(document.createElement("b"), { textContent: title }),
|
|
35
|
+
meta,
|
|
36
|
+
thumbs(task, me, line),
|
|
37
|
+
acts,
|
|
38
|
+
line,
|
|
39
|
+
);
|
|
40
|
+
return li;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* The desk's page: the tally in a card over the lanes, and the form to add a task under them. */
|
|
2
|
+
main.desk {
|
|
3
|
+
display: grid;
|
|
4
|
+
gap: var(--space-24);
|
|
5
|
+
}
|
|
6
|
+
.card.tally {
|
|
7
|
+
padding: var(--space-16);
|
|
8
|
+
border: 1px solid var(--edge);
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
background: var(--card);
|
|
11
|
+
}
|
|
12
|
+
form.add input[type="number"] {
|
|
13
|
+
flex: 0 0 6rem;
|
|
14
|
+
}
|
|
15
|
+
form.add input[name="title"] {
|
|
16
|
+
flex-basis: 12rem;
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"title": "Write the welcome",
|
|
7
|
+
"status": "queued",
|
|
8
|
+
"points": 2,
|
|
9
|
+
"rank": 1,
|
|
10
|
+
"by": 1,
|
|
11
|
+
"added": "2026-11-10T09:00:00Z"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": 2,
|
|
15
|
+
"title": "Draw up the rota",
|
|
16
|
+
"status": "working",
|
|
17
|
+
"points": 3,
|
|
18
|
+
"rank": 2,
|
|
19
|
+
"by": 1,
|
|
20
|
+
"added": "2026-11-10T09:05:00Z"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": 3,
|
|
24
|
+
"title": "Book the hall",
|
|
25
|
+
"status": "review",
|
|
26
|
+
"points": 1,
|
|
27
|
+
"rank": 3,
|
|
28
|
+
"by": 2,
|
|
29
|
+
"added": "2026-11-10T09:10:00Z"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": 4,
|
|
33
|
+
"title": "Send the invitations",
|
|
34
|
+
"status": "done",
|
|
35
|
+
"points": 2,
|
|
36
|
+
"rank": 4,
|
|
37
|
+
"by": 3,
|
|
38
|
+
"added": "2026-11-10T09:15:00Z"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/desk/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
// Each collection is an element, defined here: on a page, it holds the document, and its items
|
|
4
|
+
// are put inside it. Each item is an element, defined by the page: as it is, or by a view that
|
|
5
|
+
// extends it. A field is an attribute (a list of ids as IDREFS: "1 3"), and an item's key the
|
|
6
|
+
// document's id for it. How an item looks is the app's: its view, or a display holding the
|
|
7
|
+
// collection draws it. Ops go up as an "ops" event, for the page to send to desk, with why they
|
|
8
|
+
// were made if it's said; only the ops the stories allow can be sent. Each returns its write's answer.
|
|
9
|
+
|
|
10
|
+
import { hold, letGo, type Answer } from "joined/page";
|
|
11
|
+
|
|
12
|
+
// the document an element is of: its collection's doc attribute (an instance of a kind, shelf:1), or desk
|
|
13
|
+
const docOf = (el: Element) => el.closest("[doc]")?.getAttribute("doc") ?? "desk";
|
|
14
|
+
// an element's ops go up as an "ops" event; what it returns is the write's answer, done or refused
|
|
15
|
+
const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>((answer) => from.dispatchEvent(new CustomEvent("ops", { bubbles: true, composed: true, detail: { doc: docOf(from), ops, why, answer } })));
|
|
16
|
+
|
|
17
|
+
/** A task's fields, as the stories give them. */
|
|
18
|
+
export type JTaskData = { "title": string; "points": number; "rank": number; "status"?: string; "ups"?: number[]; "downs"?: number[]; "by"?: number; "added"?: string };
|
|
19
|
+
/** An add of a task, as it's sent: its fields as the stories write them. */
|
|
20
|
+
export type JTaskValue = { "title": string; "points": number; "rank": number; "status"?: string; "ups"?: number[]; "downs"?: number[]; "by"?: number | `$${number}`; "added"?: string };
|
|
21
|
+
|
|
22
|
+
/** <j-task key>: title (string), points (integer), rank (decimal), status (string), ups (ids in members), downs (ids in members), by (an id in members), added (instant), each an attribute. */
|
|
23
|
+
export class JTask extends HTMLElement {
|
|
24
|
+
static observedAttributes = ["title","points","rank","status","ups","downs","by","added","may"];
|
|
25
|
+
#data?: JTaskData & Required<Pick<JTaskData, "ups" | "downs">>;
|
|
26
|
+
/** Its id in the document. */
|
|
27
|
+
get key() { return Number(this.getAttribute("key")); }
|
|
28
|
+
get path() { return `/tasks/${this.key}`; }
|
|
29
|
+
/** Its fields, read from its attributes once and again when one changes: frozen, since they're shared. */
|
|
30
|
+
get data(): JTaskData & Required<Pick<JTaskData, "ups" | "downs">> {
|
|
31
|
+
return (this.#data ??= Object.freeze({ "title": this.getAttribute("title") ?? "", "points": Number(this.getAttribute("points")), "rank": Number(this.getAttribute("rank")), "status": this.getAttribute("status") ?? undefined, "ups": Object.freeze((this.getAttribute("ups") ?? "").split(" ").filter(Boolean).map(Number)), "downs": Object.freeze((this.getAttribute("downs") ?? "").split(" ").filter(Boolean).map(Number)), "by": this.hasAttribute("by") ? Number(this.getAttribute("by")) : undefined, "added": this.getAttribute("added") ?? undefined }) as JTaskData & Required<Pick<JTaskData, "ups" | "downs">>);
|
|
32
|
+
}
|
|
33
|
+
/** How a view shows it, drawn again whenever an attribute changes (what its person may do, its may, too). */
|
|
34
|
+
draw?(): void;
|
|
35
|
+
attributeChangedCallback() { this.#data = undefined; this.draw?.(); }
|
|
36
|
+
/** Replace some of its fields (status, rank): one write for all of them. */
|
|
37
|
+
replace(fields: Partial<Pick<JTaskData, "status" | "rank">>, why?: string) {
|
|
38
|
+
return send(this, Object.entries(fields).filter(([, value]) => value !== undefined).map(([field, value]) => ({ op: "replace", path: `${this.path}/${field.replace(".", "/")}`, value })), why);
|
|
39
|
+
}
|
|
40
|
+
/** Link it to one more id in a list (ups, downs): the ids there already are left as they are. */
|
|
41
|
+
link(field: "ups" | "downs", id: number, why?: string) { return send(this, [{ op: "add", path: `${this.path}/${field}/-`, value: id }], why); }
|
|
42
|
+
/** Take one id from a list (ups, downs). */
|
|
43
|
+
unlink(field: "ups" | "downs", id: number, why?: string) { return send(this, [{ op: "remove", path: `${this.path}/${field}/${id}` }], why); }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** <j-tasks>: the document's tasks, each a <j-task> inside it. */
|
|
47
|
+
export class JTasks extends HTMLElement {
|
|
48
|
+
connectedCallback() { hold(this, docOf(this), "tasks", "j-task", {"title":"string","points":"integer","rank":"decimal","status":"string","ups":"ids","downs":"ids","by":"integer","added":"instant"}, false, "rank"); }
|
|
49
|
+
disconnectedCallback() { letGo(this); }
|
|
50
|
+
/** Its tasks, as the document has them. */
|
|
51
|
+
get items() { return [...this.children].filter((el): el is JTask => el.localName === "j-task"); }
|
|
52
|
+
/** Add tasks: one write for all of them. */
|
|
53
|
+
add(...values: JTaskValue[]) { return send(this, values.map((value) => ({ op: "add", path: "/tasks/-", value }))); }
|
|
54
|
+
}
|
|
55
|
+
customElements.define("j-tasks", JTasks);
|
|
56
|
+
|
|
57
|
+
/** An op on desk the stories allow, in any of its collections. */
|
|
58
|
+
export type DeskOp =
|
|
59
|
+
| { op: "add"; path: "/tasks/-"; value: JTaskValue }
|
|
60
|
+
| { op: "replace"; path: `/tasks/${number}/status`; value: string }
|
|
61
|
+
| { op: "replace"; path: `/tasks/${number}/rank`; value: number }
|
|
62
|
+
| { op: "add"; path: `/tasks/${number}/ups/-`; value: number }
|
|
63
|
+
| { op: "add"; path: `/tasks/${number}/downs/-`; value: number }
|
|
64
|
+
| { op: "remove"; path: `/tasks/${number}/ups/${number}` }
|
|
65
|
+
| { op: "remove"; path: `/tasks/${number}/downs/${number}` };
|
|
66
|
+
|
|
67
|
+
/** One write to desk across its collections (a move with its legs): sent from an element of it, checked
|
|
68
|
+
* whole by its rules, and made whole or not at all. */
|
|
69
|
+
export function write(from: Element, ops: DeskOp[], why?: string) { return send(from, ops, why); }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/desk/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
/** Each collection's item, as one row of its table (`t`) is it: what the query gathers, and what the store keeps of a
|
|
4
|
+
* row a write changes, before and after, to tell each document holding it. */
|
|
5
|
+
export const items: Record<string, string> = {
|
|
6
|
+
"tasks": "json_patch('{}', json_object('id', t.id,\n 'title', t.\"title\",\n 'points', t.\"points\",\n 'rank', t.\"rank\",\n 'status', t.\"status\",\n 'ups', json(NULLIF((SELECT json_group_array(p.\"ups\" ORDER BY p.id) FROM \"tasks_ups\" p WHERE p.\"tasks\" = t.id), '[]')),\n 'downs', json(NULLIF((SELECT json_group_array(p.\"downs\" ORDER BY p.id) FROM \"tasks_downs\" p WHERE p.\"tasks\" = t.id), '[]')),\n 'by', t.\"by\",\n 'added', t.\"added\"))"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** desk, whole, as one statement over its tables (SQLite): its parameters $doc. */
|
|
10
|
+
export const query = `SELECT json_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),
|
|
11
|
+
'tasks', json((SELECT json_group_array(json_patch('{}', json_object('id', t.id,
|
|
12
|
+
'title', t."title",
|
|
13
|
+
'points', t."points",
|
|
14
|
+
'rank', t."rank",
|
|
15
|
+
'status', t."status",
|
|
16
|
+
'ups', json(NULLIF((SELECT json_group_array(p."ups" ORDER BY p.id) FROM "tasks_ups" p WHERE p."tasks" = t.id), '[]')),
|
|
17
|
+
'downs', json(NULLIF((SELECT json_group_array(p."downs" ORDER BY p.id) FROM "tasks_downs" p WHERE p."tasks" = t.id), '[]')),
|
|
18
|
+
'by', t."by",
|
|
19
|
+
'added', t."added")) ORDER BY COALESCE(t."rank", t.id), t.id)
|
|
20
|
+
FROM "tasks" t))) AS doc`;
|
|
21
|
+
|
|
22
|
+
/** Its rules over values (definitions' takes, gives and totals), as triggers the store makes in its database: run in
|
|
23
|
+
* each write's transaction, and told as any change is. */
|
|
24
|
+
export const triggers: string[] = [];
|
|
25
|
+
|
|
26
|
+
/** Its items, its query and its triggers, as Postgres says them. */
|
|
27
|
+
export const postgres = {
|
|
28
|
+
"items": {
|
|
29
|
+
"tasks": "json_strip_nulls(json_build_object('id', t.id,\n 'title', t.\"title\",\n 'points', t.\"points\",\n 'rank', t.\"rank\",\n 'status', t.\"status\",\n 'ups', (SELECT json_agg(p.\"ups\" ORDER BY p.id) FROM \"tasks_ups\" p WHERE p.\"tasks\" = t.id),\n 'downs', (SELECT json_agg(p.\"downs\" ORDER BY p.id) FROM \"tasks_downs\" p WHERE p.\"tasks\" = t.id),\n 'by', t.\"by\",\n 'added', t.\"added\"))"
|
|
30
|
+
},
|
|
31
|
+
"query": "SELECT json_build_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),\n 'tasks', (SELECT COALESCE(json_agg(json_strip_nulls(json_build_object('id', t.id,\n 'title', t.\"title\",\n 'points', t.\"points\",\n 'rank', t.\"rank\",\n 'status', t.\"status\",\n 'ups', (SELECT json_agg(p.\"ups\" ORDER BY p.id) FROM \"tasks_ups\" p WHERE p.\"tasks\" = t.id),\n 'downs', (SELECT json_agg(p.\"downs\" ORDER BY p.id) FROM \"tasks_downs\" p WHERE p.\"tasks\" = t.id),\n 'by', t.\"by\",\n 'added', t.\"added\")) ORDER BY COALESCE(t.\"rank\", t.id), t.id), '[]')\n FROM \"tasks\" t)) AS doc",
|
|
32
|
+
"triggers": []
|
|
33
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Written by src/compile.ts from examples/desk/stories.jsonl: change the stories, not this.
|
|
2
|
+
|
|
3
|
+
export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
|
|
4
|
+
|
|
5
|
+
/** The document, and each collection: its element, the element its items are, their fields, those an add needs, and
|
|
6
|
+
* what each link is to. */
|
|
7
|
+
export const doc = "desk";
|
|
8
|
+
export const collections = {
|
|
9
|
+
"tasks": {
|
|
10
|
+
"place": "j-tasks",
|
|
11
|
+
"tag": "j-task",
|
|
12
|
+
"fields": {
|
|
13
|
+
"title": "string",
|
|
14
|
+
"points": "integer",
|
|
15
|
+
"rank": "decimal",
|
|
16
|
+
"status": "string",
|
|
17
|
+
"ups": "ids",
|
|
18
|
+
"downs": "ids",
|
|
19
|
+
"by": "integer",
|
|
20
|
+
"added": "instant"
|
|
21
|
+
},
|
|
22
|
+
"needs": [
|
|
23
|
+
"title",
|
|
24
|
+
"points",
|
|
25
|
+
"rank"
|
|
26
|
+
],
|
|
27
|
+
"links": {
|
|
28
|
+
"ups": "members",
|
|
29
|
+
"downs": "members",
|
|
30
|
+
"by": "members"
|
|
31
|
+
},
|
|
32
|
+
"order": "rank",
|
|
33
|
+
"fills": {
|
|
34
|
+
"status": "queued",
|
|
35
|
+
"by": "me",
|
|
36
|
+
"added": "now"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} as const;
|
|
40
|
+
/** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
|
|
41
|
+
export const anonymous = false;
|
|
42
|
+
/** What kind of document desk is, by the flows it uses: static, changed only with a release (a page reads it, and
|
|
43
|
+
* never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
|
|
44
|
+
export const type = "shared";
|
|
45
|
+
/** The parts of desk a page may hold alone, by its query's parameters (its definitions' window): null, none. */
|
|
46
|
+
export const window = null;
|
|
47
|
+
/** Each field whose value moves only as the stories move it, each step by its roles (its definitions' moves). */
|
|
48
|
+
export const moves = {"tasks":"status"};
|
|
49
|
+
/** The document as one statement over its tables (generated/queries.ts). */
|
|
50
|
+
export { query, postgres, items, triggers } from "./queries.ts";
|
|
51
|
+
|
|
52
|
+
/** desk is one document. */
|
|
53
|
+
export const kind = null;
|
|
54
|
+
|
|
55
|
+
/** Each grant, read off the stories: the roles whose stories do it (a member: anyone). An op no story
|
|
56
|
+
* does isn't one. */
|
|
57
|
+
export const grants: Record<string, string[]> = {
|
|
58
|
+
"add tasks": [
|
|
59
|
+
"member"
|
|
60
|
+
],
|
|
61
|
+
"add tasks.downs[]": [
|
|
62
|
+
"member"
|
|
63
|
+
],
|
|
64
|
+
"add tasks.ups[]": [
|
|
65
|
+
"member"
|
|
66
|
+
],
|
|
67
|
+
"remove tasks.downs[]": [
|
|
68
|
+
"member"
|
|
69
|
+
],
|
|
70
|
+
"remove tasks.ups[]": [
|
|
71
|
+
"member"
|
|
72
|
+
],
|
|
73
|
+
"replace tasks.rank": [
|
|
74
|
+
"member"
|
|
75
|
+
],
|
|
76
|
+
"replace tasks.status:queued>working": [
|
|
77
|
+
"member"
|
|
78
|
+
],
|
|
79
|
+
"replace tasks.status:review>done": [
|
|
80
|
+
"member"
|
|
81
|
+
],
|
|
82
|
+
"replace tasks.status:review>working": [
|
|
83
|
+
"member"
|
|
84
|
+
],
|
|
85
|
+
"replace tasks.status:working>review": [
|
|
86
|
+
"member"
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** Who someone is to desk: a member, as it names no roles. */
|
|
91
|
+
export const rolesOf = (_m: number, _read: (doc: string) => any, _doc: string, _at?: any): string[] => [];
|
|
92
|
+
|
|
93
|
+
/** What someone sees: all of desk, as it has no owns. */
|
|
94
|
+
export const sees = null;
|