@yaks/journal 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.
Files changed (84) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +522 -2
  3. package/_dist/backed.d.ts +9 -0
  4. package/_dist/backed.d.ts.map +1 -0
  5. package/_dist/batch.d.ts +45 -0
  6. package/_dist/batch.d.ts.map +1 -0
  7. package/_dist/feed.d.ts +108 -0
  8. package/_dist/feed.d.ts.map +1 -0
  9. package/_dist/graph.d.ts +104 -0
  10. package/_dist/graph.d.ts.map +1 -0
  11. package/_dist/kept.d.ts +63 -0
  12. package/_dist/kept.d.ts.map +1 -0
  13. package/_dist/log.d.ts +142 -0
  14. package/_dist/log.d.ts.map +1 -0
  15. package/_dist/merge.d.ts +41 -0
  16. package/_dist/merge.d.ts.map +1 -0
  17. package/_dist/mod.d.ts +101 -0
  18. package/_dist/mod.d.ts.map +1 -0
  19. package/_dist/service.d.ts +68 -0
  20. package/_dist/service.d.ts.map +1 -0
  21. package/_dist/tools.d.ts +5 -0
  22. package/_dist/tools.d.ts.map +1 -0
  23. package/_dist/undo.d.ts +48 -0
  24. package/_dist/undo.d.ts.map +1 -0
  25. package/_dist/value.d.ts +6 -0
  26. package/_dist/value.d.ts.map +1 -0
  27. package/_dist/views.d.ts +25 -0
  28. package/_dist/views.d.ts.map +1 -0
  29. package/_dist/vocab.d.ts +7 -0
  30. package/_dist/vocab.d.ts.map +1 -0
  31. package/backed.js +225 -0
  32. package/backed.js.map +1 -0
  33. package/backed.ts +274 -0
  34. package/batch.js +12 -0
  35. package/batch.js.map +1 -0
  36. package/batch.ts +84 -0
  37. package/deno.json +1 -0
  38. package/feed.js +295 -0
  39. package/feed.js.map +1 -0
  40. package/feed.ts +368 -0
  41. package/graph.js +224 -0
  42. package/graph.js.map +1 -0
  43. package/graph.ts +329 -0
  44. package/held.js +25 -0
  45. package/held.js.map +1 -0
  46. package/held.ts +24 -0
  47. package/kept.js +61 -0
  48. package/kept.js.map +1 -0
  49. package/kept.ts +100 -0
  50. package/log.js +1161 -0
  51. package/log.js.map +1 -0
  52. package/log.ts +1299 -0
  53. package/merge.js +158 -0
  54. package/merge.js.map +1 -0
  55. package/merge.ts +185 -0
  56. package/mod.js +101 -0
  57. package/mod.js.map +1 -0
  58. package/mod.ts +102 -0
  59. package/names.js +206 -0
  60. package/names.js.map +1 -0
  61. package/names.ts +230 -0
  62. package/package.json +52 -4
  63. package/page.js +160 -0
  64. package/page.js.map +1 -0
  65. package/page.ts +233 -0
  66. package/service.js +118 -0
  67. package/service.js.map +1 -0
  68. package/service.ts +148 -0
  69. package/tools.js +110 -0
  70. package/tools.js.map +1 -0
  71. package/tools.ts +113 -0
  72. package/undo.js +187 -0
  73. package/undo.js.map +1 -0
  74. package/undo.ts +190 -0
  75. package/value.js +26 -0
  76. package/value.js.map +1 -0
  77. package/value.ts +35 -0
  78. package/views.js +85 -0
  79. package/views.js.map +1 -0
  80. package/views.ts +91 -0
  81. package/vocab.js +20 -0
  82. package/vocab.js.map +1 -0
  83. package/vocab.json +308 -0
  84. package/vocab.ts +22 -0
package/names.js ADDED
@@ -0,0 +1,206 @@
1
+ // What the journal's rows call each word. A change records its component by
2
+ // the component's identity, the `$id` its vocabulary gives it (@yaks/vocab),
3
+ // which is the eid of the `_comp` row describing it, and each value by its
4
+ // property's identity, so a renamed word keeps its history. A word without an
5
+ // identity is recorded by its label.
6
+ //
7
+ // Rows written before identities name every word by its label. Both shapes
8
+ // are read alike, each to the label the vocabulary reads it by now, until
9
+ // every store's journal has been rewritten to identities (D-338's migration).
10
+ //
11
+ // A statement reads a label from `journal_word`, the store's rows for the
12
+ // names its vocabulary gives (`words`), which the journal's schema writes
13
+ // whenever the vocabulary changes (./log.ts `ddl`). The vocabulary is never
14
+ // written into a statement: the platform's is tens of kilobytes, and workerd
15
+ // refuses a statement past 100,000 bytes (@yaks/sql `LENGTH`).
16
+ //
17
+ // Labels are read back in the reader's namespace: `names(vocab.in(ns))` gives
18
+ // each component the label that namespace reads it by (@yaks/vocab, "Reading
19
+ // in a namespace"). `journal_word` holds the store's own labels, so a reading
20
+ // writes into its statements only the components it labels otherwise: none
21
+ // for the store's own reading, and few for any other, since only a label two
22
+ // namespaces share reads differently. A property's label is the same in every
23
+ // reading.
24
+ import { derivedEid } from "@yaks/graph/identity";
25
+ import { among, col, eq, fn, lit, select, sub, table, unionAll, when } from "@yaks/sql/core";
26
+ import { rowsOf } from "@yaks/vocab";
27
+ let unique = (names)=>[
28
+ ...new Set(names.filter((n)=>!!n))
29
+ ];
30
+ /** The table naming each word a journal's rows may record: `recorded`, what
31
+ * a row holds for it, its `label`, and for a component the eid of its `_comp`
32
+ * row. */ export let WORDS = 'journal_word';
33
+ let text = (name, notNull = false)=>({
34
+ name,
35
+ type: 'text',
36
+ notNull
37
+ });
38
+ /** {@link WORDS}, keyed by what a row recorded. */ export let wordTable = {
39
+ t: 'create table',
40
+ name: WORDS,
41
+ ifNot: true,
42
+ cols: [
43
+ {
44
+ ...text('recorded', true),
45
+ pk: true
46
+ },
47
+ text('label', true),
48
+ text('row')
49
+ ],
50
+ withoutRowid: true
51
+ };
52
+ // The rows of one insert: three literals each, so a statement stays well
53
+ // short of workerd's length, and its text, the print a store installs by,
54
+ // changes when a word does.
55
+ let BATCH = 200;
56
+ /** The statements writing `vocab`'s words into {@link WORDS}, after what
57
+ * stood there: each component by its identity and by its label, each
58
+ * property by its identity. A property's label is what a row recorded where
59
+ * it has none, which reads as itself. The labels are the store's own, however
60
+ * `reading` reads them. */ export let words = (reading)=>{
61
+ let vocab = reading.in();
62
+ let at = rowsOf(vocab, derivedEid);
63
+ let rows = [];
64
+ for (let comp of vocab.all){
65
+ let id = vocab.comp(comp)?.id, row = at.comp(comp);
66
+ rows.push([
67
+ comp,
68
+ comp,
69
+ row
70
+ ]);
71
+ if (id && id != comp) rows.push([
72
+ id,
73
+ comp,
74
+ row
75
+ ]);
76
+ for (let prop of vocab.props(comp)){
77
+ let p = vocab.prop(comp, prop)?.id;
78
+ if (p && p != prop) rows.push([
79
+ p,
80
+ prop,
81
+ null
82
+ ]);
83
+ }
84
+ }
85
+ let once = [
86
+ ...new Map(rows.map((r)=>[
87
+ r[0],
88
+ r
89
+ ])).values()
90
+ ];
91
+ return [
92
+ {
93
+ t: 'delete',
94
+ from: WORDS
95
+ },
96
+ ...Array.from({
97
+ length: Math.ceil(once.length / BATCH)
98
+ }, (_, i)=>({
99
+ t: 'insert',
100
+ into: WORDS,
101
+ cols: [
102
+ 'recorded',
103
+ 'label',
104
+ 'row'
105
+ ],
106
+ rows: once.slice(i * BATCH, (i + 1) * BATCH).map((r)=>r.map(lit))
107
+ }))
108
+ ];
109
+ };
110
+ // A word's `column` in WORDS, by what a row recorded; what it does not hold
111
+ // reads as itself.
112
+ let looked = (column)=>(key)=>fn('coalesce', sub(select({
113
+ cols: [
114
+ col(column, '__w')
115
+ ],
116
+ from: table(WORDS, '__w'),
117
+ where: eq(col('recorded', '__w'), key)
118
+ })), key);
119
+ let labelOf = looked('label'), rowOf = looked('row');
120
+ let recordedAt = (row)=>unionAll(select({
121
+ cols: [
122
+ col('recorded', '__r')
123
+ ],
124
+ from: table(WORDS, '__r'),
125
+ where: eq(col('row', '__r'), row)
126
+ }), select({
127
+ cols: [
128
+ row
129
+ ]
130
+ }));
131
+ let labeledIn = (turned)=>(labels)=>unionAll(select({
132
+ cols: [
133
+ col('recorded', '__l')
134
+ ],
135
+ from: table(WORDS, '__l'),
136
+ where: among(col('label', '__l'), labels)
137
+ }), ...[
138
+ ...labels,
139
+ ...turned.map((k)=>lit(k))
140
+ ].map((n)=>select({
141
+ cols: [
142
+ n
143
+ ]
144
+ })));
145
+ let made = new WeakMap();
146
+ /** The names `vocab`'s words are recorded by, and read back from, in the
147
+ * labels `vocab` reads them by. */ export let names = (vocab)=>{
148
+ let got = made.get(vocab);
149
+ if (got) return got;
150
+ let own = vocab.in();
151
+ // The label each recorded name reads as: each identity, and each of the
152
+ // store's labels this reading gives another (`turned`, which `heldAs` maps
153
+ // back, since a row recorded by label holds the store's).
154
+ let comps = {};
155
+ let props = {};
156
+ let turned = [];
157
+ let heldAs = {};
158
+ for (let comp of own.all){
159
+ let id = own.comp(comp)?.id, word = id ? vocab.word(id) : undefined;
160
+ let as = word && 'comp' in word ? word.comp : comp;
161
+ if (id) comps[id] = as;
162
+ if (id && as != comp) {
163
+ comps[comp] = as;
164
+ heldAs[as] = comp;
165
+ turned.push([
166
+ id,
167
+ as
168
+ ], [
169
+ comp,
170
+ as
171
+ ]);
172
+ }
173
+ for (let prop of own.props(comp)){
174
+ let p = own.prop(comp, prop)?.id;
175
+ if (p) props[p] = prop;
176
+ }
177
+ }
178
+ let compLabelOf = turned.length ? (key)=>when(turned.map(([k, as])=>[
179
+ eq(key, lit(k)),
180
+ lit(as)
181
+ ]), labelOf(key)) : labelOf;
182
+ let idOf = (label)=>vocab.comp(label)?.id;
183
+ got = {
184
+ comp: (label)=>idOf(label) ?? label,
185
+ prop: (comp, label)=>vocab.prop(comp, label)?.id ?? label,
186
+ comps: (label)=>unique([
187
+ idOf(label),
188
+ label,
189
+ heldAs[label]
190
+ ]),
191
+ props: (comp, label)=>unique([
192
+ vocab.prop(comp, label)?.id,
193
+ label
194
+ ]),
195
+ compLabel: (recorded)=>comps[recorded] ?? recorded,
196
+ propLabel: (recorded)=>props[recorded] ?? recorded,
197
+ compLabelOf,
198
+ propLabelOf: labelOf,
199
+ rowOf,
200
+ recordedAt,
201
+ labeled: labeledIn(turned.map(([k])=>k))
202
+ };
203
+ made.set(vocab, got);
204
+ return got;
205
+ };
206
+ //# sourceMappingURL=names.js.map
package/names.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.js","sources":["./names.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,qCAAqC;AACrC,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1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CAAC,QAAQ;EACjD,MAAM;IACJ,MAAM,CAAC,QAAU,KAAK,UAAU;IAChC,MAAM,CAAC,MAAM,QAAU,MAAM,IAAI,CAAC,MAAM,QAAQ,MAAM;IACtD,OAAO,CAAC,QAAU,OAAO;QAAC,KAAK;QAAQ;QAAO,MAAM,CAAC,MAAM;OAAC;IAC5D,OAAO,CAAC,MAAM,QAAU,OAAO;QAAC,MAAM,IAAI,CAAC,MAAM,QAAQ;QAAI;OAAM;IACnE,WAAW,CAAC,WAAa,KAAK,CAAC,SAAS,IAAI;IAC5C,WAAW,CAAC,WAAa,KAAK,CAAC,SAAS,IAAI;IAC5C;IACA,aAAa;IACb;IACA;IACA,SAAS,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,GAAK;EACzC;EACA,KAAK,GAAG,CAAC,OAAO;EAChB,OAAO;AACT,EAAC"}
package/names.ts ADDED
@@ -0,0 +1,230 @@
1
+ // What the journal's rows call each word. A change records its component by
2
+ // the component's identity, the `$id` its vocabulary gives it (@yaks/vocab),
3
+ // which is the eid of the `_comp` row describing it, and each value by its
4
+ // property's identity, so a renamed word keeps its history. A word without an
5
+ // identity is recorded by its label.
6
+ //
7
+ // Rows written before identities name every word by its label. Both shapes
8
+ // are read alike, each to the label the vocabulary reads it by now, until
9
+ // every store's journal has been rewritten to identities (D-338's migration).
10
+ //
11
+ // A statement reads a label from `journal_word`, the store's rows for the
12
+ // names its vocabulary gives (`words`), which the journal's schema writes
13
+ // whenever the vocabulary changes (./log.ts `ddl`). The vocabulary is never
14
+ // written into a statement: the platform's is tens of kilobytes, and workerd
15
+ // refuses a statement past 100,000 bytes (@yaks/sql `LENGTH`).
16
+ //
17
+ // Labels are read back in the reader's namespace: `names(vocab.in(ns))` gives
18
+ // each component the label that namespace reads it by (@yaks/vocab, "Reading
19
+ // in a namespace"). `journal_word` holds the store's own labels, so a reading
20
+ // writes into its statements only the components it labels otherwise: none
21
+ // for the store's own reading, and few for any other, since only a label two
22
+ // namespaces share reads differently. A property's label is the same in every
23
+ // reading.
24
+
25
+ import { derivedEid } from '@yaks/graph/identity'
26
+ import {
27
+ among,
28
+ col,
29
+ type Column,
30
+ eq,
31
+ type Expr,
32
+ fn,
33
+ lit,
34
+ type Query,
35
+ select,
36
+ type Stmt,
37
+ sub,
38
+ table,
39
+ unionAll,
40
+ when,
41
+ } from '@yaks/sql/core'
42
+ import { rowsOf, type Vocab } from '@yaks/vocab'
43
+
44
+ /** How the journal's rows name the words of one vocabulary. */
45
+ export type Names = {
46
+ /** what a row records for a component, by its label */
47
+ comp: (label: string) => string
48
+ /** what a row records for a property, by its component's label and its */
49
+ prop: (comp: string, label: string) => string
50
+ /** every name a row may hold for a component: its identity and its labels */
51
+ comps: (label: string) => string[]
52
+ /** every name a row may hold for a property: its identity and its label */
53
+ props: (comp: string, label: string) => string[]
54
+ /** the label a component a row recorded reads as */
55
+ compLabel: (recorded: string) => string
56
+ /** the label a property a row recorded reads as */
57
+ propLabel: (recorded: string) => string
58
+ /** {@link Names.compLabel} in SQL, over a column holding what a row
59
+ * recorded */
60
+ compLabelOf: (recorded: Expr) => Expr
61
+ /** {@link Names.propLabel} in SQL */
62
+ propLabelOf: (recorded: Expr) => Expr
63
+ /** the eid of the `_comp` row describing a component, in SQL, from what a
64
+ * row recorded for it: its identity, or where its label derives where it
65
+ * has none (@yaks/vocab `rowsOf`) */
66
+ rowOf: (recorded: Expr) => Expr
67
+ /** every name a row may hold for the component the `_comp` row whose eid
68
+ * is `row` describes, in SQL: the inverse of {@link Names.rowOf}, as a set
69
+ * an index on what rows recorded can seek */
70
+ recordedAt: (row: Expr) => Query
71
+ /** names a row may hold for a component that reads as one of `labels`, in
72
+ * SQL: each label, what {@link WORDS} gives it, and what this reading
73
+ * labels otherwise, a few more besides, as a set an index on what rows
74
+ * recorded can seek. Which of them read as `labels` is
75
+ * {@link Names.compLabelOf}'s to say. */
76
+ labeled: (labels: Expr[]) => Query
77
+ }
78
+
79
+ let unique = (
80
+ names: (string | undefined)[],
81
+ ) => [...new Set(names.filter((n): n is string => !!n))]
82
+
83
+ /** The table naming each word a journal's rows may record: `recorded`, what
84
+ * a row holds for it, its `label`, and for a component the eid of its `_comp`
85
+ * row. */
86
+ export let WORDS = 'journal_word'
87
+
88
+ let text = (name: string, notNull = false): Column => ({
89
+ name,
90
+ type: 'text',
91
+ notNull,
92
+ })
93
+
94
+ /** {@link WORDS}, keyed by what a row recorded. */
95
+ export let wordTable: Stmt = {
96
+ t: 'create table',
97
+ name: WORDS,
98
+ ifNot: true,
99
+ cols: [
100
+ { ...text('recorded', true), pk: true },
101
+ text('label', true),
102
+ text('row'),
103
+ ],
104
+ withoutRowid: true,
105
+ }
106
+
107
+ // The rows of one insert: three literals each, so a statement stays well
108
+ // short of workerd's length, and its text, the print a store installs by,
109
+ // changes when a word does.
110
+ let BATCH = 200
111
+
112
+ /** The statements writing `vocab`'s words into {@link WORDS}, after what
113
+ * stood there: each component by its identity and by its label, each
114
+ * property by its identity. A property's label is what a row recorded where
115
+ * it has none, which reads as itself. The labels are the store's own, however
116
+ * `reading` reads them. */
117
+ export let words = (reading: Vocab): Stmt[] => {
118
+ let vocab = reading.in()
119
+ let at = rowsOf(vocab, derivedEid)
120
+ let rows: [string, string, string | null][] = []
121
+ for (let comp of vocab.all) {
122
+ let id = vocab.comp(comp)?.id, row = at.comp(comp)
123
+ rows.push([comp, comp, row])
124
+ if (id && id != comp) rows.push([id, comp, row])
125
+ for (let prop of vocab.props(comp)) {
126
+ let p = vocab.prop(comp, prop)?.id
127
+ if (p && p != prop) rows.push([p, prop, null])
128
+ }
129
+ }
130
+ let once = [...new Map(rows.map((r) => [r[0], r])).values()]
131
+ return [
132
+ { t: 'delete', from: WORDS },
133
+ ...Array.from(
134
+ { length: Math.ceil(once.length / BATCH) },
135
+ (_, i): Stmt => ({
136
+ t: 'insert',
137
+ into: WORDS,
138
+ cols: ['recorded', 'label', 'row'],
139
+ rows: once.slice(i * BATCH, (i + 1) * BATCH).map((r) => r.map(lit)),
140
+ }),
141
+ ),
142
+ ]
143
+ }
144
+
145
+ // A word's `column` in WORDS, by what a row recorded; what it does not hold
146
+ // reads as itself.
147
+ let looked = (column: string) => (key: Expr): Expr =>
148
+ fn(
149
+ 'coalesce',
150
+ sub(select({
151
+ cols: [col(column, '__w')],
152
+ from: table(WORDS, '__w'),
153
+ where: eq(col('recorded', '__w'), key),
154
+ })),
155
+ key,
156
+ )
157
+ let labelOf = looked('label'), rowOf = looked('row')
158
+
159
+ let recordedAt = (row: Expr): Query =>
160
+ unionAll(
161
+ select({
162
+ cols: [col('recorded', '__r')],
163
+ from: table(WORDS, '__r'),
164
+ where: eq(col('row', '__r'), row),
165
+ }),
166
+ select({ cols: [row] }),
167
+ )
168
+
169
+ let labeledIn = (turned: string[]) => (labels: Expr[]): Query =>
170
+ unionAll(
171
+ select({
172
+ cols: [col('recorded', '__l')],
173
+ from: table(WORDS, '__l'),
174
+ where: among(col('label', '__l'), labels),
175
+ }),
176
+ ...[...labels, ...turned.map((k) => lit(k))].map((n) =>
177
+ select({ cols: [n] })
178
+ ),
179
+ )
180
+
181
+ let made = new WeakMap<Vocab, Names>()
182
+
183
+ /** The names `vocab`'s words are recorded by, and read back from, in the
184
+ * labels `vocab` reads them by. */
185
+ export let names = (vocab: Vocab): Names => {
186
+ let got = made.get(vocab)
187
+ if (got) return got
188
+ let own = vocab.in()
189
+ // The label each recorded name reads as: each identity, and each of the
190
+ // store's labels this reading gives another (`turned`, which `heldAs` maps
191
+ // back, since a row recorded by label holds the store's).
192
+ let comps: Record<string, string> = {}
193
+ let props: Record<string, string> = {}
194
+ let turned: [string, string][] = []
195
+ let heldAs: Record<string, string> = {}
196
+ for (let comp of own.all) {
197
+ let id = own.comp(comp)?.id, word = id ? vocab.word(id) : undefined
198
+ let as = word && 'comp' in word ? word.comp : comp
199
+ if (id) comps[id] = as
200
+ if (id && as != comp) {
201
+ comps[comp] = as
202
+ heldAs[as] = comp
203
+ turned.push([id, as], [comp, as])
204
+ }
205
+ for (let prop of own.props(comp)) {
206
+ let p = own.prop(comp, prop)?.id
207
+ if (p) props[p] = prop
208
+ }
209
+ }
210
+ let compLabelOf = turned.length
211
+ ? (key: Expr) =>
212
+ when(turned.map(([k, as]) => [eq(key, lit(k)), lit(as)]), labelOf(key))
213
+ : labelOf
214
+ let idOf = (label: string) => vocab.comp(label)?.id
215
+ got = {
216
+ comp: (label) => idOf(label) ?? label,
217
+ prop: (comp, label) => vocab.prop(comp, label)?.id ?? label,
218
+ comps: (label) => unique([idOf(label), label, heldAs[label]]),
219
+ props: (comp, label) => unique([vocab.prop(comp, label)?.id, label]),
220
+ compLabel: (recorded) => comps[recorded] ?? recorded,
221
+ propLabel: (recorded) => props[recorded] ?? recorded,
222
+ compLabelOf,
223
+ propLabelOf: labelOf,
224
+ rowOf,
225
+ recordedAt,
226
+ labeled: labeledIn(turned.map(([k]) => k)),
227
+ }
228
+ made.set(vocab, got)
229
+ return got
230
+ }
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@yaks/journal",
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/journal",
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
+ "./graph": {
16
+ "types": "./_dist/graph.d.ts",
17
+ "default": "./graph.js"
18
+ },
19
+ "./tools": {
20
+ "types": "./_dist/tools.d.ts",
21
+ "default": "./tools.js"
22
+ },
23
+ "./service": {
24
+ "types": "./_dist/service.d.ts",
25
+ "default": "./service.js"
26
+ },
27
+ "./views": {
28
+ "types": "./_dist/views.d.ts",
29
+ "default": "./views.js"
30
+ },
31
+ "./kept": {
32
+ "types": "./_dist/kept.d.ts",
33
+ "default": "./kept.js"
34
+ }
35
+ },
36
+ "license": "Apache-2.0",
37
+ "dependencies": {
38
+ "@yaks/file": "0.2.36",
39
+ "@yaks/fp": "0.2.36",
40
+ "@yaks/graph": "0.2.36",
41
+ "@yaks/inspect": "0.2.36",
42
+ "@yaks/query": "0.2.36",
43
+ "@yaks/render": "0.2.36",
44
+ "@yaks/sql": "0.2.36",
45
+ "@yaks/tools": "0.2.36",
46
+ "@yaks/ui": "0.2.36",
47
+ "@yaks/vocab": "0.2.36",
48
+ "@types/react": "19.3.0",
49
+ "lucide": "1.31.0",
50
+ "react": "19.3.0"
51
+ },
52
+ "description": "Records every committed graph transaction, and who wrote it, inside that same transaction: entity history and undo, and a short-lived feed that carries every commit to the other processes on the store.",
53
+ "repository": "https://github.com/yak-sh/yak.git"
54
+ }
package/page.js ADDED
@@ -0,0 +1,160 @@
1
+ /**
2
+ * What history keeps, as the browsing app draws it: its share of the file
3
+ * and what it kept per change and per day, day by day; the changes the
4
+ * journal holds for each component, beside what that component keeps in its
5
+ * own table and its versions; and every table in the file, largest first.
6
+ * Everything comes from the `kept` rows the duty writes once a day
7
+ * (./service.ts), the changes per component among them, so opening the page
8
+ * reads a month of rows and counts nothing. A component is drawn by name and
9
+ * opens its page, where its recent writes are.
10
+ *
11
+ * @module
12
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment } from "react";
13
+ import { compEid, mention, useNamed } from "@yaks/inspect";
14
+ import { Head, Loading, Meter, Section, Table } from "@yaks/ui";
15
+ import { size } from "@yaks/file";
16
+ import { changes, historic, history, keptOf, perChange, perDay, versioned } from "./kept.js";
17
+ let { Body, Cell, Heading, Row } = Table;
18
+ let COMPONENTS = 30;
19
+ let TABLES = 40;
20
+ let count = (n)=>Math.round(n).toLocaleString('en-US');
21
+ let share = (part, whole)=>whole ? `${Math.round(part / whole * 100)}%` : '';
22
+ let waiting = (got, what)=>got?.error ? /*#__PURE__*/ h(Section.Sub, {
23
+ role: 'alert'
24
+ }, got.error) : !got?.ready ? /*#__PURE__*/ h(Loading, {}, `Loading ${what}…`) : null;
25
+ // A table of rows under headings: the first column a name, the second a bar.
26
+ let Ranked = ({ title, sub, heads, rows })=>/*#__PURE__*/ h(Section, {}, /*#__PURE__*/ h(Section.Title, {}, title, ' ', /*#__PURE__*/ h(Section.Count, {}, String(rows.length))), /*#__PURE__*/ h(Section.Sub, {}, sub), /*#__PURE__*/ h(Table, {
27
+ cols: [
28
+ null,
29
+ null,
30
+ ...heads.map(()=>'num')
31
+ ]
32
+ }, /*#__PURE__*/ h(Table.Head, {}, /*#__PURE__*/ h(Row, {}, /*#__PURE__*/ h(Heading, {}, ''), /*#__PURE__*/ h(Heading, {}, ''), ...heads.map((k)=>/*#__PURE__*/ h(Heading, {
33
+ key: k,
34
+ mod: 'num'
35
+ }, k)))), /*#__PURE__*/ h(Body, {}, rows.map((r)=>/*#__PURE__*/ h(Row, {
36
+ key: r.key
37
+ }, /*#__PURE__*/ h(Cell, {}, r.name), /*#__PURE__*/ h(Cell, {}, /*#__PURE__*/ h(Meter, {
38
+ value: r.bar,
39
+ width: 10
40
+ })), ...r.cells.map((s, i)=>/*#__PURE__*/ h(Cell, {
41
+ key: i,
42
+ mod: 'num'
43
+ }, s)))))));
44
+ // Each day, newest first, beside the day before it.
45
+ let Days = ({ days })=>/*#__PURE__*/ h(Ranked, {
46
+ title: 'Day by day',
47
+ sub: 'The file and what history kept in it each day, the changes the journal held, and what history kept per change written since the day before.',
48
+ heads: [
49
+ 'file',
50
+ 'history',
51
+ 'changes',
52
+ 'per change'
53
+ ],
54
+ rows: days.map((k, i)=>{
55
+ let before = days[i + 1];
56
+ let each = before && perChange(before, k);
57
+ return {
58
+ key: k.day,
59
+ name: k.day,
60
+ bar: k.bytes ? history(k) / k.bytes : 0,
61
+ cells: [
62
+ size(k.bytes),
63
+ `${size(history(k))} (${share(history(k), k.bytes)})`,
64
+ count(changes(k)),
65
+ each == null ? '' : size(each)
66
+ ]
67
+ };
68
+ })
69
+ });
70
+ // The changes the journal held for each component, beside what the
71
+ // component keeps in its table and its versions.
72
+ let Components = ({ io, k })=>{
73
+ let rows = io.vocab.all.map((c)=>({
74
+ c,
75
+ eid: compEid(io.vocab, c),
76
+ n: k.changes?.[c] ?? 0
77
+ })).filter((r)=>r.n || k.tables[`${r.c}$versions`]).toSorted((a, b)=>b.n - a.n).slice(0, COMPONENTS);
78
+ useNamed(io, rows.map((r)=>r.eid));
79
+ let most = rows[0]?.n || 1;
80
+ return /*#__PURE__*/ h(Ranked, {
81
+ title: 'By component',
82
+ sub: 'The changes the journal held for each component, and what the component keeps in its own table and in its versions. A component marked as keeping no history has none.',
83
+ heads: [
84
+ 'changes',
85
+ 'table',
86
+ 'versions'
87
+ ],
88
+ rows: rows.map(({ c, eid, n })=>({
89
+ key: c,
90
+ name: mention(io, eid),
91
+ bar: n / most,
92
+ cells: [
93
+ count(n),
94
+ size(k.tables[c]?.[0]),
95
+ k.tables[`${c}$versions`] ? size(k.tables[`${c}$versions`][0]) : ''
96
+ ]
97
+ }))
98
+ });
99
+ };
100
+ // Every table, largest first, with its growth a day.
101
+ let Tables = ({ k, before })=>{
102
+ let rows = Object.entries(k.tables).toSorted(([, a], [, b])=>b[0] - a[0]).slice(0, TABLES);
103
+ let most = rows[0]?.[1][0] || 1;
104
+ let grew = (t)=>{
105
+ let d = before && perDay(before, k, (m)=>m.tables[t]?.[0] ?? 0);
106
+ return d == null ? '' : `${d > 0 ? '+' : ''}${size(d)}`;
107
+ };
108
+ return /*#__PURE__*/ h(Ranked, {
109
+ title: 'Tables',
110
+ sub: 'Every table in the file with its indexes, largest first. History’s are the journal’s and each component’s versions.',
111
+ heads: [
112
+ 'bytes',
113
+ 'rows',
114
+ 'a day',
115
+ ''
116
+ ],
117
+ rows: rows.map(([t, [bytes, n]])=>({
118
+ key: t,
119
+ name: versioned(t) ? `${versioned(t)} versions` : t,
120
+ bar: bytes / most,
121
+ cells: [
122
+ size(bytes),
123
+ count(n),
124
+ grew(t),
125
+ historic(t) ? 'history' : ''
126
+ ]
127
+ }))
128
+ });
129
+ };
130
+ /** The page: history's share of the file, day by day, by component and by
131
+ * table. */ export let Page = ({ io, got })=>{
132
+ let days = (got.days?.rows ?? []).map(keptOf).filter((k)=>!!k);
133
+ let [k, before] = days;
134
+ let each = before && perChange(before, k);
135
+ let daily = before && perDay(before, k, history);
136
+ return /*#__PURE__*/ h('article', {}, /*#__PURE__*/ h(Head, {}, /*#__PURE__*/ h(Head.Title, {}, 'What history keeps'), /*#__PURE__*/ h(Head.Sub, {}, 'The journal records who wrote what and the values each write left; versions keep every version of a row. Measured once a day from the file’s pages, each table with its indexes.'), k ? /*#__PURE__*/ h(Head.Facts, {}, `${size(history(k))} of the file’s ${size(k.bytes)} (${share(history(k), k.bytes)})`, ...daily == null ? [] : [
137
+ `${size(daily)} more a day`
138
+ ], ...each == null ? [] : [
139
+ `${size(each)} kept per change`
140
+ ], `${count(changes(k))} changes held`, `measured ${io.when(k.at)}`) : null), waiting(got.days, 'the measurements') ?? (!k ? /*#__PURE__*/ h(Section.Sub, {}, 'Not measured yet: the duty measures the file once a day.') : /*#__PURE__*/ h(Fragment, {}, /*#__PURE__*/ h(Days, {
141
+ days: days.slice(0, 14)
142
+ }), /*#__PURE__*/ h(Components, {
143
+ io,
144
+ k
145
+ }), /*#__PURE__*/ h(Tables, {
146
+ k,
147
+ before
148
+ }))));
149
+ };
150
+ /** The views this package draws in the browsing app. */ export let inspectViews = [
151
+ {
152
+ view: 'History.Page',
153
+ match: true,
154
+ asks: ()=>({
155
+ days: '.kept * .order=-kept.day .limit=31'
156
+ }),
157
+ Render: Page
158
+ }
159
+ ];
160
+ //# sourceMappingURL=page.js.map
package/page.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","sources":["./page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;CAWC,GACD,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,QAAQ,gBAAoD;AACnI,SACE,OAAO,EACP,OAA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