@yaks/notify 0.0.0-stage → 0.2.36

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/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,SAAS,SAAS,qBAAoB;AAEtC,yEAAyE,GACzE,OAAO,IAAI,WAAW,CACpB,GACA,KACA,MACA,OAAoB,IAAI,KAAa;EAErC,IAAI,QAAQ,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;EAC9B,IAAI,SAAS,MAAM,IAAI,UAAU,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG;IACjD,KAAK,GAAG,CAAC,EAAE,GAAG;IACd,OAAO,SAAS,KAAK,GAAG,CAAC,QAAS,KAAK,MAAM;EAC/C;EACA,IAAI,SAAS,EAAE,KAAK,CAAC,IAAI,IAAI,OACzB;IAAC,IAAI,KAAK;IAAE,IAAI,OAAO;IAAE,IAAI,KAAK;GAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,KACpE,KACA,OACA,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,UACvC,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU;EAE/B,8DAA8D;EAC9D,0EAA0E;EAC1E,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,UAAU,EAAE,GAAG;EAC5C,OAAO,UAAU,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,WAC7D,EAAE,GAAG;AACT,EAAC;AAID,IAAI,MAAM,CAAC,IAAuB,OAAO,KAAK;AAE9C,sEAAsE,GACtE,OAAO,IAAI,YAAY,CAAC,KAAa,OAAgC;IACnE;MAAE,QAAQ;QAAE;MAAI;MAAG,CAAC,KAAK,EAAE;IAAK;IAChC;MAAE,QAAQ;QAAE;MAAI;MAAG,CAAC,KAAK,EAAE,CAAC;IAAE;GAC/B,CAAA"}
package/mod.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Being notified. A `knock` is a nudge aimed at an entity, with the message
3
+ * that came with it; a `notification` tells someone what happened, a thread
4
+ * of its own; a `subscription` records whether somebody watches or mutes
5
+ * that entity, with their archived/opened attention marks on the same row;
6
+ * and a `chat` is an open conversation between an actor and an
7
+ * entity.
8
+ *
9
+ * Pure thread subjects and the notification vocabulary. Graph writes live
10
+ * behind the ./attention boundary.
11
+ */
12
+
13
+ export { notifyDoc } from './vocab.js'
14
+
15
+ /** A thread's subject, following mail reply ancestry before its target. */
16
+ export let threadOf = (
17
+ r: ThreadRow,
18
+ who?: ThreadReader,
19
+ byId?: Map<string, ThreadRow>,
20
+ seen: Set<string> = new Set<string>(),
21
+ ): string => {
22
+ let reply = str(r.comps.mail?.reply_to)
23
+ if (reply && byId?.has(reply) && !seen.has(r.eid)) {
24
+ seen.add(r.eid)
25
+ return threadOf(byId.get(reply)!, who, byId, seen)
26
+ }
27
+ let target = r.comps.mail && who &&
28
+ [who.actor, who.session, who.scope].includes(str(r.comps.mail.target))
29
+ ? ''
30
+ : String(
31
+ r.comps.comment?.target ?? r.comps.mail?.target ??
32
+ r.comps.knock?.target ?? '',
33
+ )
34
+ // A question is a thread of its own, even said as a line of a
35
+ // conversation: it waits on whom it asks, apart from what was said there.
36
+ if (r.comps.decision) return target || r.eid
37
+ return target || str(r.comps.entry?.session ?? r.comps.commit?.target) ||
38
+ r.eid
39
+ }
40
+
41
+ type ThreadRow = { eid: string; comps: Record<string, Record<string, unknown>> }
42
+ type ThreadReader = { actor?: string; session?: string; scope?: string }
43
+ let str = (v: unknown): string => String(v ?? '')
44
+
45
+ /** Atomic replacement gives repeated marks a fresh server timestamp. */
46
+ export let attention = (eid: string, mark: 'archived' | 'opened') => [
47
+ { entity: { eid }, [mark]: null },
48
+ { entity: { eid }, [mark]: {} },
49
+ ]
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@yaks/notify",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.36",
4
+ "homepage": "https://jsr.io/@yaks/notify",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./_dist/mod.d.ts",
9
+ "default": "./mod.js"
10
+ },
11
+ "./vocab": {
12
+ "types": "./_dist/vocab.d.ts",
13
+ "default": "./vocab.js"
14
+ },
15
+ "./attention": {
16
+ "types": "./_dist/attention.d.ts",
17
+ "default": "./attention.js"
18
+ },
19
+ "./whereabouts": {
20
+ "types": "./_dist/whereabouts.d.ts",
21
+ "default": "./whereabouts.js"
22
+ },
23
+ "./tab": {
24
+ "types": "./_dist/tab.d.ts",
25
+ "default": "./tab.js"
26
+ }
27
+ },
28
+ "license": "Apache-2.0",
29
+ "dependencies": {
30
+ "@yaks/fp": "0.2.36",
31
+ "@yaks/graph": "0.2.36",
32
+ "@yaks/query": "0.2.36",
33
+ "@yaks/vocab": "0.2.36"
34
+ },
35
+ "description": "How somebody is notified: a knock aimed at an entity, what they watch or mute, an open conversation, and where they are available right now.",
36
+ "repository": "https://github.com/yak-sh/yak.git"
37
+ }
package/tab.js ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Where a page's person is: whether its tab is visible, focused, and has
3
+ * recent input. The page's half of whereabouts, which
4
+ * @yaks/client and the yaks.app app pages' client both say through.
5
+ *
6
+ * ```ts ignore
7
+ * import { browserPage, sayTab } from '@yaks/notify/tab'
8
+ *
9
+ * let page = browserPage()
10
+ * if (page) sayTab(page, (tab) => socket.send(JSON.stringify({ tab })))
11
+ * ```
12
+ */ import { system } from "@yaks/fp";
13
+ import { BEAT } from "./whereabouts.js";
14
+ /** How long input counts toward a tab's presence. */ export let IDLE = 5 * 60_000;
15
+ let INPUT = [
16
+ 'pointerdown',
17
+ 'pointermove',
18
+ 'keydown',
19
+ 'wheel',
20
+ 'touchmove',
21
+ 'input'
22
+ ];
23
+ /** The browser's page, none on any other runtime. */ export let browserPage = ()=>{
24
+ let g = globalThis;
25
+ return typeof g.document?.hasFocus == 'function' && g.addEventListener ? g : undefined;
26
+ };
27
+ /** Say the tab's changes and renew the legacy whereabouts timestamp every
28
+ * `BEAT`. The returned function stops both. */ export let sayTab = (page, say, clock = system)=>{
29
+ let { document } = page;
30
+ let last = -Infinity;
31
+ let stopIdle;
32
+ let left = ()=>last + IDLE - clock.now();
33
+ let report = ()=>say({
34
+ visible: document.visibilityState == 'visible',
35
+ focused: document.hasFocus(),
36
+ idle: left() <= 0
37
+ });
38
+ let expire = ()=>{
39
+ let remaining = left();
40
+ stopIdle = remaining > 0 ? clock.after(remaining, expire) : undefined;
41
+ if (!stopIdle) report();
42
+ };
43
+ let input = ()=>{
44
+ let idle = left() <= 0;
45
+ last = clock.now();
46
+ stopIdle ??= clock.after(IDLE, expire);
47
+ if (idle) report();
48
+ };
49
+ document.addEventListener('visibilitychange', report);
50
+ page.addEventListener('focus', report);
51
+ page.addEventListener('blur', report);
52
+ for (let event of INPUT)document.addEventListener(event, input, true);
53
+ let beat = page.setInterval(report, BEAT);
54
+ report();
55
+ return ()=>{
56
+ document.removeEventListener('visibilitychange', report);
57
+ page.removeEventListener('focus', report);
58
+ page.removeEventListener('blur', report);
59
+ for (let event of INPUT)document.removeEventListener(event, input, true);
60
+ page.clearInterval(beat);
61
+ stopIdle?.();
62
+ };
63
+ };
64
+ //# sourceMappingURL=tab.js.map
package/tab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab.js","sources":["./tab.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAAqB,MAAM,wBAA6B;AACxD,SAAS,IAAI,2BAAoC;AAEjD,mDAAmD,GACnD,OAAO,IAAI,OAAO,IAAI,OAAM;AAE5B,IAAI,QAAQ;EACV;EACA;EACA;EACA;EACA;EACA;CACD;AAoBD,mDAAmD,GACnD,OAAO,IAAI,cAAc;EACvB,IAAI,IAAI;EACR,OAAO,OAAO,EAAE,QAAQ,EAAE,YAAY,cAAc,EAAE,gBAAgB,GAClE,IACA;AACN,EAAC;AAED;6CAC6C,GAC7C,OAAO,IAAI,SAAS,CAClB,MACA,KACA,QAAe,MAAM;EAErB,IAAI,EAAE,QAAQ,EAAE,GAAG;EACnB,IAAI,OAAO,CAAC;EACZ,IAAI;EACJ,IAAI,OAAO,IAAM,OAAO,OAAO,MAAM,GAAG;EACxC,IAAI,SAAS,IACX,IAAI;MACF,SAAS,SAAS,eAAe,IAAI;MACrC,SAAS,SAAS,QAAQ;MAC1B,MAAM,UAAU;IAClB;EACF,IAAI,SAAS;IACX,IAAI,YAAY;IAChB,WAAW,YAAY,IAAI,MAAM,KAAK,CAAC,WAAW,UAAU;IAC5D,IAAI,CAAC,UAAU;EACjB;EACA,IAAI,QAAQ;IACV,IAAI,OAAO,UAAU;IACrB,OAAO,MAAM,GAAG;IAChB,aAAa,MAAM,KAAK,CAAC,MAAM;IAC/B,IAAI,MAAM;EACZ;EACA,SAAS,gBAAgB,CAAC,oBAAoB;EAC9C,KAAK,gBAAgB,CAAC,SAAS;EAC/B,KAAK,gBAAgB,CAAC,QAAQ;EAC9B,KAAK,IAAI,SAAS,MAAO,SAAS,gBAAgB,CAAC,OAAO,OAAO;EACjE,IAAI,OAAO,KAAK,WAAW,CAAC,QAAQ;EACpC;EACA,OAAO;IACL,SAAS,mBAAmB,CAAC,oBAAoB;IACjD,KAAK,mBAAmB,CAAC,SAAS;IAClC,KAAK,mBAAmB,CAAC,QAAQ;IACjC,KAAK,IAAI,SAAS,MAAO,SAAS,mBAAmB,CAAC,OAAO,OAAO;IACpE,KAAK,aAAa,CAAC;IACnB;EACF;AACF,EAAC"}
package/tab.ts ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Where a page's person is: whether its tab is visible, focused, and has
3
+ * recent input. The page's half of whereabouts, which
4
+ * @yaks/client and the yaks.app app pages' client both say through.
5
+ *
6
+ * ```ts ignore
7
+ * import { browserPage, sayTab } from '@yaks/notify/tab'
8
+ *
9
+ * let page = browserPage()
10
+ * if (page) sayTab(page, (tab) => socket.send(JSON.stringify({ tab })))
11
+ * ```
12
+ */
13
+
14
+ import { type Clock, system } from '@yaks/fp'
15
+ import { BEAT, type Tab } from './whereabouts.js'
16
+
17
+ /** How long input counts toward a tab's presence. */
18
+ export let IDLE = 5 * 60_000
19
+
20
+ let INPUT = [
21
+ 'pointerdown',
22
+ 'pointermove',
23
+ 'keydown',
24
+ 'wheel',
25
+ 'touchmove',
26
+ 'input',
27
+ ]
28
+
29
+ /** The page a client says its tab from: a browser's `window`, by default. */
30
+ export type Page = {
31
+ document: {
32
+ visibilityState: string
33
+ hasFocus: () => boolean
34
+ addEventListener: (type: string, fn: () => void, capture?: boolean) => void
35
+ removeEventListener: (
36
+ type: string,
37
+ fn: () => void,
38
+ capture?: boolean,
39
+ ) => void
40
+ }
41
+ addEventListener: (type: string, fn: () => void) => void
42
+ removeEventListener: (type: string, fn: () => void) => void
43
+ setInterval: (fn: () => void, ms: number) => unknown
44
+ clearInterval: (id: unknown) => void
45
+ }
46
+
47
+ /** The browser's page, none on any other runtime. */
48
+ export let browserPage = (): Page | undefined => {
49
+ let g = globalThis as unknown as Partial<Page>
50
+ return typeof g.document?.hasFocus == 'function' && g.addEventListener
51
+ ? g as Page
52
+ : undefined
53
+ }
54
+
55
+ /** Say the tab's changes and renew the legacy whereabouts timestamp every
56
+ * `BEAT`. The returned function stops both. */
57
+ export let sayTab = (
58
+ page: Page,
59
+ say: (tab: Tab) => void,
60
+ clock: Clock = system,
61
+ ): () => void => {
62
+ let { document } = page
63
+ let last = -Infinity
64
+ let stopIdle: (() => void) | undefined
65
+ let left = () => last + IDLE - clock.now()
66
+ let report = () =>
67
+ say({
68
+ visible: document.visibilityState == 'visible',
69
+ focused: document.hasFocus(),
70
+ idle: left() <= 0,
71
+ })
72
+ let expire = () => {
73
+ let remaining = left()
74
+ stopIdle = remaining > 0 ? clock.after(remaining, expire) : undefined
75
+ if (!stopIdle) report()
76
+ }
77
+ let input = () => {
78
+ let idle = left() <= 0
79
+ last = clock.now()
80
+ stopIdle ??= clock.after(IDLE, expire)
81
+ if (idle) report()
82
+ }
83
+ document.addEventListener('visibilitychange', report)
84
+ page.addEventListener('focus', report)
85
+ page.addEventListener('blur', report)
86
+ for (let event of INPUT) document.addEventListener(event, input, true)
87
+ let beat = page.setInterval(report, BEAT)
88
+ report()
89
+ return () => {
90
+ document.removeEventListener('visibilitychange', report)
91
+ page.removeEventListener('focus', report)
92
+ page.removeEventListener('blur', report)
93
+ for (let event of INPUT) document.removeEventListener(event, input, true)
94
+ page.clearInterval(beat)
95
+ stopIdle?.()
96
+ }
97
+ }
package/vocab.js ADDED
@@ -0,0 +1,16 @@
1
+ // The component declarations, and nothing else: the module a server or a
2
+ // browser page imports at `@yaks/notify/vocab`. It reaches no storage, no SQL
3
+ // and no runtime, so a browser tab loading this vocabulary loads nothing else.
4
+ import doc from './vocab.json' with {
5
+ type: 'json'
6
+ };
7
+ import manifest from './package.json' with {
8
+ type: 'json'
9
+ };
10
+ /** The notify vocabulary, in the form `loadVocab` accepts. */ export let notifyDoc = doc;
11
+ /** What this package is: its manifest's description, the one place it is
12
+ * written, which a host stamps on each document here. */ export let description = manifest.description;
13
+ /** Every document this plugin declares. */ export let docs = [
14
+ notifyDoc
15
+ ];
16
+ //# sourceMappingURL=vocab.js.map
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,+EAA+E;AAG/E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,4DAA4D,GAC5D,OAAO,IAAI,YAAsB,IAAe;AAEhD;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAU,CAAA"}
package/vocab.json ADDED
@@ -0,0 +1,250 @@
1
+ {
2
+ "$id": "urn:uuid:9633882a-0d6a-4d95-a205-6049603458de",
3
+ "$vocabulary": {
4
+ "https://yak.sh/vocab/core": true,
5
+ "https://yak.sh/vocab/fence": true,
6
+ "https://yak.sh/vocab/id": true
7
+ },
8
+ "title": "notify",
9
+ "$defs": {
10
+ "chat": {
11
+ "$id": "urn:uuid:60f17b09-8281-4ade-9b7f-b7cf835ac7b4",
12
+ "component": true,
13
+ "type": "object",
14
+ "unique": [
15
+ [
16
+ "actor",
17
+ "target"
18
+ ]
19
+ ],
20
+ "properties": {
21
+ "actor": {
22
+ "$id": "urn:uuid:4cda218b-a39e-4ee6-a30f-441557b5fb9a",
23
+ "type": "string",
24
+ "ref": "entity",
25
+ "death": "detach"
26
+ },
27
+ "target": {
28
+ "$id": "urn:uuid:d7d12f44-c428-4979-9e0c-816c64d14080",
29
+ "type": "string",
30
+ "ref": "entity",
31
+ "death": "detach"
32
+ }
33
+ },
34
+ "description": "an open conversation between an actor and an entity — one per actor/entity pair"
35
+ },
36
+ "knock": {
37
+ "$id": "urn:uuid:f92b85b4-cb65-44d3-a700-0d61690a35bb",
38
+ "component": true,
39
+ "type": "object",
40
+ "notice": true,
41
+ "index": [
42
+ { "props": ["target", "at"], "present": ["at"] },
43
+ { "props": ["from", "at"], "present": ["at"] }
44
+ ],
45
+ "properties": {
46
+ "target": {
47
+ "$id": "urn:uuid:b6db3189-88c6-4904-a132-f83436322fa1",
48
+ "type": "string",
49
+ "ref": "entity",
50
+ "death": "cascade"
51
+ },
52
+ "from": {
53
+ "$id": "urn:uuid:b58f0785-17c1-4955-b9e7-7f8cf843aa4a",
54
+ "type": "string",
55
+ "ref": "entity",
56
+ "death": "keep",
57
+ "description": "whose act or words it tells, where it tells someone's: the actor who finished a task or commented on it, the person who sent a text"
58
+ },
59
+ "about": {
60
+ "$id": "urn:uuid:a259ac68-6ad7-4301-b954-ff6ab766a6d5",
61
+ "type": "string",
62
+ "ref": "entity",
63
+ "death": "keep",
64
+ "description": "what it tells of, where that is one entity: the task a mark or an assignment moved, or the comment on it"
65
+ },
66
+ "at": {
67
+ "$id": "urn:uuid:6e054484-9191-47ab-9826-d2049b5225d5",
68
+ "type": "string",
69
+ "format": "date-time",
70
+ "description": "when it was sent, where its target's or its sender's newest are read in order: a message between friends on yaks.app"
71
+ },
72
+ "outcome": {
73
+ "$id": "urn:uuid:f0ec9e19-4f25-4021-b14a-c5615a6d5746",
74
+ "type": "string",
75
+ "enum": ["settled", "failed", "stopped", "open"],
76
+ "description": "How the work this report concerns ended, when the sender knows."
77
+ }
78
+ },
79
+ "description": "a nudge aimed at an entity, with the message that came with it"
80
+ },
81
+ "notification": {
82
+ "$id": "urn:uuid:b05a4c79-b446-4ebd-ab09-230f2768f3f9",
83
+ "component": true,
84
+ "type": "object",
85
+ "notice": true,
86
+ "properties": {
87
+ "to": {
88
+ "$id": "urn:uuid:6b131f34-34d3-43e7-a10c-9b39812e5f30",
89
+ "type": "string",
90
+ "ref": "entity",
91
+ "death": "keep",
92
+ "description": "whom it tells: a person, or a space or project for everyone standing in it; it may live in another graph"
93
+ },
94
+ "about": {
95
+ "$id": "urn:uuid:eb443781-86dc-41e1-9e2d-02232e322cc2",
96
+ "type": "string",
97
+ "ref": "entity",
98
+ "death": "keep",
99
+ "description": "what it tells of, which may live in another graph"
100
+ },
101
+ "from": {
102
+ "$id": "urn:uuid:a28892b9-ae86-49d4-8ded-48545804cfdb",
103
+ "type": "string",
104
+ "ref": "entity",
105
+ "death": "keep",
106
+ "description": "the entry it was written from, where its reader opens the conversation it came from"
107
+ },
108
+ "quiet": {
109
+ "$id": "urn:uuid:02ac15d2-bbd7-45d8-8a1e-6dd48a85a61c",
110
+ "type": "boolean",
111
+ "description": "whether this stays in the inbox without an alert through another channel"
112
+ }
113
+ },
114
+ "description": "words emitted, not said, telling whoever its `to` names (a person, or a space or project for everyone standing in it) what happened; doc{body} holds them, and it is a thread of its own"
115
+ },
116
+ "reply": {
117
+ "$id": "urn:uuid:76f98866-e79f-4474-9e4c-0746343ccc00",
118
+ "component": true,
119
+ "type": "object",
120
+ "properties": {
121
+ "to": {
122
+ "$id": "urn:uuid:a984c972-0614-4fbe-ada1-cb0d632f7cfd",
123
+ "type": "string",
124
+ "ref": "entity",
125
+ "death": "keep",
126
+ "description": "the words it answers: an entry, a comment or a letter, which may live in another graph"
127
+ }
128
+ },
129
+ "description": "these words answer words somebody said: a notification telling them the answer to what they wrote is a reply, shown as its own words"
130
+ },
131
+ "subscription": {
132
+ "$id": "urn:uuid:c3ce17be-a170-49da-9fe1-25797a0abce5",
133
+ "component": true,
134
+ "type": "object",
135
+ "unique": [
136
+ [
137
+ "actor",
138
+ "target"
139
+ ]
140
+ ],
141
+ "properties": {
142
+ "actor": {
143
+ "$id": "urn:uuid:78edcef1-5b27-4784-9b17-6c5b7f1de22c",
144
+ "type": "string",
145
+ "ref": "entity",
146
+ "death": "cascade"
147
+ },
148
+ "target": {
149
+ "$id": "urn:uuid:5288e00f-1b59-48a0-9b2d-c9f526463446",
150
+ "type": "string",
151
+ "ref": "entity",
152
+ "death": "cascade"
153
+ },
154
+ "mode": {
155
+ "$id": "urn:uuid:97213217-0198-4594-9ea8-6704912ddaab",
156
+ "type": "string",
157
+ "enum": [
158
+ "watch",
159
+ "mute"
160
+ ],
161
+ "description": "watch: notify this actor. mute: do not"
162
+ }
163
+ },
164
+ "description": "one actor’s attention to one entity; mode watches or mutes it, and archived/opened marks on this row record putting away or reading its thread"
165
+ },
166
+ "whereabouts": {
167
+ "$id": "urn:uuid:c1ecca6a-595b-4b85-9117-bded2b8b0f23",
168
+ "component": true,
169
+ "fence": "own",
170
+ "type": "object",
171
+ "description": "where a person is available on one channel, as it last changed: one row per person, channel and place, its eid derived from the three (@yaks/notify/whereabouts `whereaboutsEid`). A row is written when its state changes, or again while it holds once it is old enough to fade; a row older than its channel's fade says nothing.",
172
+ "properties": {
173
+ "person": {
174
+ "$id": "urn:uuid:1896b71e-2f02-4c47-bd1c-2ef35a08078a",
175
+ "type": "string",
176
+ "ref": "entity",
177
+ "death": "cascade",
178
+ "description": "whose whereabouts it is"
179
+ },
180
+ "channel": {
181
+ "$id": "urn:uuid:2c7edb35-3c2f-4299-a30b-e72c523cef7d",
182
+ "type": "string",
183
+ "enum": [
184
+ "operator",
185
+ "apps",
186
+ "discord",
187
+ "text",
188
+ "email"
189
+ ],
190
+ "description": "where: the Operator's page, a yaks.app app's page, Discord, a text, an email"
191
+ },
192
+ "place": {
193
+ "$id": "urn:uuid:9f8e2baf-8f9b-49fb-925f-5c25482bffbe",
194
+ "type": "string",
195
+ "description": "which one of the channel, where there are several: the space whose Operator page, the app whose page; none for a channel the person is on once"
196
+ },
197
+ "state": {
198
+ "$id": "urn:uuid:94a9fc59-214b-4460-8951-c6dd3997264d",
199
+ "type": "string",
200
+ "enum": [
201
+ "here",
202
+ "background",
203
+ "away",
204
+ "open",
205
+ "online",
206
+ "idle",
207
+ "dnd",
208
+ "offline",
209
+ "used"
210
+ ],
211
+ "description": "what the channel last said: an Operator page focused (here), open but hidden or unfocused (background), or closed (away); an app page open or closed (away); Discord's status; a text or email used"
212
+ },
213
+ "at": {
214
+ "$id": "urn:uuid:58fbbadb-0a93-45c6-8ec9-5e2eea766410",
215
+ "type": "string",
216
+ "format": "date-time",
217
+ "description": "when the state was last said, which it fades from"
218
+ }
219
+ }
220
+ }
221
+ },
222
+ "kinds": {
223
+ "knock": {
224
+ "$id": "urn:uuid:f92b85b4-cb65-44d3-a700-0d61690a35bb",
225
+ "description": "a nudge aimed at an entity, with the message that came with it",
226
+ "prefix": "K",
227
+ "examples": [
228
+ {
229
+ "knock": {
230
+ "target": "7c1e1f0a-3b5d-4c2e-9a41-2f6d8b0e5a13"
231
+ },
232
+ "doc": {
233
+ "body": "Your review is waiting"
234
+ }
235
+ }
236
+ ]
237
+ },
238
+ "notification": {
239
+ "$id": "urn:uuid:b05a4c79-b446-4ebd-ab09-230f2768f3f9",
240
+ "description": "words emitted, not said, telling whoever its `to` names (a person, or a space or project for everyone standing in it) what happened; doc{body} holds them, and it is a thread of its own",
241
+ "with": {
242
+ "doc": true
243
+ }
244
+ },
245
+ "subscription": {
246
+ "$id": "urn:uuid:c3ce17be-a170-49da-9fe1-25797a0abce5",
247
+ "description": "one actor’s attention to one entity; mode watches or mutes it, and archived/opened marks on this row record putting away or reading its thread"
248
+ }
249
+ }
250
+ }
package/vocab.ts ADDED
@@ -0,0 +1,17 @@
1
+ // The component declarations, and nothing else: the module a server or a
2
+ // browser page imports at `@yaks/notify/vocab`. It reaches no storage, no SQL
3
+ // and no runtime, so a browser tab loading this vocabulary loads nothing else.
4
+
5
+ import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
6
+ import doc from './vocab.json' with { type: 'json' }
7
+ import manifest from './package.json' with { type: 'json' }
8
+
9
+ /** The notify vocabulary, in the form `loadVocab` accepts. */
10
+ export let notifyDoc: VocabDoc = doc as VocabDoc
11
+
12
+ /** What this package is: its manifest's description, the one place it is
13
+ * written, which a host stamps on each document here. */
14
+ export let description: string = manifest.description
15
+
16
+ /** Every document this plugin declares. */
17
+ export let docs: VocabDoc[] = [notifyDoc]