@yaks/sqlite 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/LICENSE +202 -0
- package/README.md +1596 -2
- package/_dist/archetype.d.ts +75 -0
- package/_dist/archetype.d.ts.map +1 -0
- package/_dist/branches.d.ts +23 -0
- package/_dist/branches.d.ts.map +1 -0
- package/_dist/budget.d.ts +52 -0
- package/_dist/budget.d.ts.map +1 -0
- package/_dist/bundle.d.ts +2 -0
- package/_dist/bundle.d.ts.map +1 -0
- package/_dist/cache.d.ts +24 -0
- package/_dist/cache.d.ts.map +1 -0
- package/_dist/catalog.d.ts +9 -0
- package/_dist/catalog.d.ts.map +1 -0
- package/_dist/check.d.ts +4 -0
- package/_dist/check.d.ts.map +1 -0
- package/_dist/db.d.ts +36 -0
- package/_dist/db.d.ts.map +1 -0
- package/_dist/ddl.d.ts +143 -0
- package/_dist/ddl.d.ts.map +1 -0
- package/_dist/doom.d.ts +22 -0
- package/_dist/doom.d.ts.map +1 -0
- package/_dist/follow.d.ts +74 -0
- package/_dist/follow.d.ts.map +1 -0
- package/_dist/history-shapes.d.ts +3 -0
- package/_dist/history-shapes.d.ts.map +1 -0
- package/_dist/history.d.ts +18 -0
- package/_dist/history.d.ts.map +1 -0
- package/_dist/inspect.d.ts +43 -0
- package/_dist/inspect.d.ts.map +1 -0
- package/_dist/jsonb.d.ts +17 -0
- package/_dist/jsonb.d.ts.map +1 -0
- package/_dist/layout.d.ts +7 -0
- package/_dist/layout.d.ts.map +1 -0
- package/_dist/ledger.d.ts +41 -0
- package/_dist/ledger.d.ts.map +1 -0
- package/_dist/meta.d.ts +89 -0
- package/_dist/meta.d.ts.map +1 -0
- package/_dist/migration.d.ts +41 -0
- package/_dist/migration.d.ts.map +1 -0
- package/_dist/mod.d.ts +201 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/mode.d.ts +14 -0
- package/_dist/mode.d.ts.map +1 -0
- package/_dist/overlay.d.ts +30 -0
- package/_dist/overlay.d.ts.map +1 -0
- package/_dist/owe.d.ts +180 -0
- package/_dist/owe.d.ts.map +1 -0
- package/_dist/physical.d.ts +89 -0
- package/_dist/physical.d.ts.map +1 -0
- package/_dist/point.d.ts +10 -0
- package/_dist/point.d.ts.map +1 -0
- package/_dist/raise.d.ts +22 -0
- package/_dist/raise.d.ts.map +1 -0
- package/_dist/read-db.d.ts +9 -0
- package/_dist/read-db.d.ts.map +1 -0
- package/_dist/read-store.d.ts +10 -0
- package/_dist/read-store.d.ts.map +1 -0
- package/_dist/read.d.ts +59 -0
- package/_dist/read.d.ts.map +1 -0
- package/_dist/reader.d.ts +11 -0
- package/_dist/reader.d.ts.map +1 -0
- package/_dist/rules.d.ts +19 -0
- package/_dist/rules.d.ts.map +1 -0
- package/_dist/service.d.ts +12 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/shape.d.ts +12 -0
- package/_dist/shape.d.ts.map +1 -0
- package/_dist/statements.d.ts +4 -0
- package/_dist/statements.d.ts.map +1 -0
- package/_dist/survey.d.ts +31 -0
- package/_dist/survey.d.ts.map +1 -0
- package/_dist/tools.d.ts +15 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/trash.d.ts +18 -0
- package/_dist/trash.d.ts.map +1 -0
- package/_dist/unit.d.ts +11 -0
- package/_dist/unit.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/write.d.ts +169 -0
- package/_dist/write.d.ts.map +1 -0
- package/answer.js +110 -0
- package/answer.js.map +1 -0
- package/answer.ts +122 -0
- package/archetype.js +730 -0
- package/archetype.js.map +1 -0
- package/archetype.ts +790 -0
- package/binary_cases.ts +240 -0
- package/branches.js +195 -0
- package/branches.js.map +1 -0
- package/branches.ts +257 -0
- package/budget.js +89 -0
- package/budget.js.map +1 -0
- package/budget.ts +117 -0
- package/builtin.js +34 -0
- package/builtin.js.map +1 -0
- package/builtin.ts +31 -0
- package/bundle.js +21 -0
- package/bundle.js.map +1 -0
- package/bundle.ts +22 -0
- package/buried.js +95 -0
- package/buried.js.map +1 -0
- package/buried.ts +124 -0
- package/cache.js +153 -0
- package/cache.js.map +1 -0
- package/cache.ts +154 -0
- package/cache_worker.ts +16 -0
- package/catalog.js +173 -0
- package/catalog.js.map +1 -0
- package/catalog.ts +224 -0
- package/check.js +80 -0
- package/check.js.map +1 -0
- package/check.ts +92 -0
- package/checkpoint.js +98 -0
- package/checkpoint.js.map +1 -0
- package/checkpoint.ts +129 -0
- package/checkpoint_worker.ts +37 -0
- package/db.js +170 -0
- package/db.js.map +1 -0
- package/db.ts +173 -0
- package/ddl.js +1441 -0
- package/ddl.js.map +1 -0
- package/ddl.ts +1508 -0
- package/deno.json +1 -0
- package/doom.js +59 -0
- package/doom.js.map +1 -0
- package/doom.ts +75 -0
- package/driver.js +69 -0
- package/driver.js.map +1 -0
- package/driver.ts +101 -0
- package/error.js +30 -0
- package/error.js.map +1 -0
- package/error.ts +46 -0
- package/ffi/LICENSE +202 -0
- package/ffi/blob.js +99 -0
- package/ffi/blob.js.map +1 -0
- package/ffi/blob.ts +156 -0
- package/ffi/constants.js +65 -0
- package/ffi/constants.js.map +1 -0
- package/ffi/constants.ts +67 -0
- package/ffi/database.js +613 -0
- package/ffi/database.js.map +1 -0
- package/ffi/database.ts +931 -0
- package/ffi/ffi.js +535 -0
- package/ffi/ffi.js.map +1 -0
- package/ffi/ffi.ts +604 -0
- package/ffi/mod.js +15 -0
- package/ffi/mod.js.map +1 -0
- package/ffi/mod.ts +28 -0
- package/ffi/statement.js +555 -0
- package/ffi/statement.js.map +1 -0
- package/ffi/statement.ts +788 -0
- package/ffi/util.js +32 -0
- package/ffi/util.js.map +1 -0
- package/ffi/util.ts +48 -0
- package/follow.js +342 -0
- package/follow.js.map +1 -0
- package/follow.ts +401 -0
- package/history-branch.js +166 -0
- package/history-branch.js.map +1 -0
- package/history-branch.ts +140 -0
- package/history-shapes.js +254 -0
- package/history-shapes.js.map +1 -0
- package/history-shapes.ts +268 -0
- package/history.js +620 -0
- package/history.js.map +1 -0
- package/history.ts +674 -0
- package/inspect.js +120 -0
- package/inspect.js.map +1 -0
- package/inspect.ts +164 -0
- package/jsonb.js +73 -0
- package/jsonb.js.map +1 -0
- package/jsonb.ts +108 -0
- package/layout.js +22 -0
- package/layout.js.map +1 -0
- package/layout.ts +26 -0
- package/ledger.js +210 -0
- package/ledger.js.map +1 -0
- package/ledger.ts +210 -0
- package/legacy.js +4 -0
- package/legacy.js.map +1 -0
- package/legacy.ts +3 -0
- package/maintenance.js +148 -0
- package/maintenance.js.map +1 -0
- package/maintenance.ts +154 -0
- package/measure.js +133 -0
- package/measure.js.map +1 -0
- package/measure.ts +167 -0
- package/measure_worker.ts +18 -0
- package/memo.js +1250 -0
- package/memo.js.map +1 -0
- package/memo.ts +1480 -0
- package/meta.js +265 -0
- package/meta.js.map +1 -0
- package/meta.ts +321 -0
- package/migration.js +272 -0
- package/migration.js.map +1 -0
- package/migration.ts +286 -0
- package/mod.js +1103 -0
- package/mod.js.map +1 -0
- package/mod.ts +1762 -0
- package/mode.js +192 -0
- package/mode.js.map +1 -0
- package/mode.ts +207 -0
- package/native.js +544 -0
- package/native.js.map +1 -0
- package/native.ts +544 -0
- package/overlay.js +408 -0
- package/overlay.js.map +1 -0
- package/overlay.ts +485 -0
- package/owe.js +719 -0
- package/owe.js.map +1 -0
- package/owe.ts +873 -0
- package/package.json +99 -4
- package/physical.js +350 -0
- package/physical.js.map +1 -0
- package/physical.ts +434 -0
- package/plan.js +78 -0
- package/plan.js.map +1 -0
- package/plan.ts +104 -0
- package/point.js +81 -0
- package/point.js.map +1 -0
- package/point.ts +52 -0
- package/population.js +639 -0
- package/population.js.map +1 -0
- package/population.ts +630 -0
- package/purge.js +117 -0
- package/purge.js.map +1 -0
- package/purge.ts +127 -0
- package/raise.js +270 -0
- package/raise.js.map +1 -0
- package/raise.ts +316 -0
- package/read-db.js +381 -0
- package/read-db.js.map +1 -0
- package/read-db.ts +282 -0
- package/read-store.js +74 -0
- package/read-store.js.map +1 -0
- package/read-store.ts +86 -0
- package/read.js +1100 -0
- package/read.js.map +1 -0
- package/read.ts +1441 -0
- package/reader.js +141 -0
- package/reader.js.map +1 -0
- package/reader.ts +159 -0
- package/rules.js +88 -0
- package/rules.js.map +1 -0
- package/rules.ts +113 -0
- package/service.js +27 -0
- package/service.js.map +1 -0
- package/service.ts +41 -0
- package/shape.js +76 -0
- package/shape.js.map +1 -0
- package/shape.ts +108 -0
- package/sparse_presence_fixture.ts +45 -0
- package/sqlitepath.js +24 -0
- package/sqlitepath.js.map +1 -0
- package/sqlitepath.ts +29 -0
- package/statements.js +78 -0
- package/statements.js.map +1 -0
- package/statements.ts +96 -0
- package/survey.js +135 -0
- package/survey.js.map +1 -0
- package/survey.ts +196 -0
- package/tools.js +17 -0
- package/tools.js.map +1 -0
- package/tools.ts +50 -0
- package/trash.js +144 -0
- package/trash.js.map +1 -0
- package/trash.ts +187 -0
- package/unit.js +215 -0
- package/unit.js.map +1 -0
- package/unit.ts +211 -0
- package/versions.js +115 -0
- package/versions.js.map +1 -0
- package/versions.ts +110 -0
- package/vocab.js +19 -0
- package/vocab.js.map +1 -0
- package/vocab.json +27 -0
- package/vocab.ts +19 -0
- package/watch.js +33 -0
- package/watch.js.map +1 -0
- package/watch.ts +42 -0
- package/write.js +1164 -0
- package/write.js.map +1 -0
- package/write.ts +1356 -0
- package/written.js +200 -0
- package/written.js.map +1 -0
- package/written.ts +202 -0
package/purge.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Explicit purge belongs to the owner of the retained versions. These writes
|
|
2
|
+
// bypass ordinary entity mutation: deliberately erased history is not trash.
|
|
3
|
+
import { among, array, col, select, table } from "@yaks/sql";
|
|
4
|
+
import { foreign, stood } from "./physical.js";
|
|
5
|
+
import { valuesOf } from "./read.js";
|
|
6
|
+
import { TRASH } from "./trash.js";
|
|
7
|
+
import { erased } from "./mode.js";
|
|
8
|
+
import { tables } from "./physical.js";
|
|
9
|
+
import { WRITTEN } from "./written.js";
|
|
10
|
+
let metadata = new Set([
|
|
11
|
+
'entity',
|
|
12
|
+
'$branch',
|
|
13
|
+
'$from',
|
|
14
|
+
'$to'
|
|
15
|
+
]);
|
|
16
|
+
/** Every version of exactly these identities, including retired columns. */ export let purgeHistory = (driver, vocab, eids, opts)=>{
|
|
17
|
+
let names = new Map(driver.query(select({
|
|
18
|
+
cols: [
|
|
19
|
+
col('id'),
|
|
20
|
+
col('eid')
|
|
21
|
+
],
|
|
22
|
+
from: table('entity'),
|
|
23
|
+
where: among(col('eid'), array(eids))
|
|
24
|
+
})).map((r)=>[
|
|
25
|
+
Number(r.id),
|
|
26
|
+
String(r.eid)
|
|
27
|
+
]));
|
|
28
|
+
let out = [];
|
|
29
|
+
for (let [name, shape] of Object.entries(stood(driver, (name)=>!foreign(name) && name.endsWith('$versions')))){
|
|
30
|
+
let comp = name.slice(0, -'$versions'.length);
|
|
31
|
+
let where = among(col('entity', comp), array([
|
|
32
|
+
...names.keys()
|
|
33
|
+
]));
|
|
34
|
+
if (vocab.comp(comp)) {
|
|
35
|
+
out.push(...valuesOf(driver, vocab, comp, name, where, opts).map(([id, value])=>({
|
|
36
|
+
entity: {
|
|
37
|
+
eid: names.get(id)
|
|
38
|
+
},
|
|
39
|
+
[comp]: value
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
// The current vocabulary cannot decode a retired property. Its stored
|
|
43
|
+
// value still matters to resources retaining content by address.
|
|
44
|
+
let extras = shape.cols.map((c)=>String(c.name)).filter((p)=>!metadata.has(p) && !vocab.prop(comp, p));
|
|
45
|
+
if (extras.length) {
|
|
46
|
+
out.push(...driver.query(select({
|
|
47
|
+
cols: [
|
|
48
|
+
col('entity', comp),
|
|
49
|
+
...extras.map((p)=>col(p, comp))
|
|
50
|
+
],
|
|
51
|
+
from: table(name, comp),
|
|
52
|
+
where
|
|
53
|
+
})).map(({ entity, ...value })=>({
|
|
54
|
+
entity: {
|
|
55
|
+
eid: names.get(Number(entity))
|
|
56
|
+
},
|
|
57
|
+
[comp]: value
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
driver.query({
|
|
61
|
+
t: 'delete',
|
|
62
|
+
from: name,
|
|
63
|
+
where: among(col('entity'), array([
|
|
64
|
+
...names.keys()
|
|
65
|
+
]))
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (tables(driver).includes(WRITTEN)) {
|
|
69
|
+
driver.query({
|
|
70
|
+
t: 'insert',
|
|
71
|
+
into: WRITTEN,
|
|
72
|
+
cols: [
|
|
73
|
+
'entity'
|
|
74
|
+
],
|
|
75
|
+
q: select({
|
|
76
|
+
cols: [
|
|
77
|
+
col('id')
|
|
78
|
+
],
|
|
79
|
+
from: table('entity'),
|
|
80
|
+
where: among(col('eid'), array(eids))
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
erased(driver);
|
|
85
|
+
return out;
|
|
86
|
+
};
|
|
87
|
+
/** Exact candidate strings, including inside JSON, without depending on the
|
|
88
|
+
* current vocabulary to remember retired columns. */ export let retained = (driver, values)=>{
|
|
89
|
+
let candidates = new Set(values), found = new Set();
|
|
90
|
+
let visit = (value)=>{
|
|
91
|
+
if (typeof value == 'string') {
|
|
92
|
+
if (candidates.has(value)) found.add(value);
|
|
93
|
+
if (/^[\[{]/.test(value)) {
|
|
94
|
+
try {
|
|
95
|
+
visit(JSON.parse(value));
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
98
|
+
} else if (value && typeof value == 'object') {
|
|
99
|
+
for (let part of Object.values(value))visit(part);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
let shapes = stood(driver, (name)=>!foreign(name));
|
|
103
|
+
for (let [name, shape] of Object.entries(shapes)){
|
|
104
|
+
if (name != TRASH && !name.endsWith('$versions') && !shape.cols.some((c)=>c.name == 'entity' && Number(c.pk) > 0)) continue;
|
|
105
|
+
let cols = shape.cols.map((c)=>String(c.name)).filter((p)=>!metadata.has(p));
|
|
106
|
+
if (cols.length) {
|
|
107
|
+
for (let row of driver.query(select({
|
|
108
|
+
cols: cols.map((p)=>col(p)),
|
|
109
|
+
from: table(name)
|
|
110
|
+
})))visit(row);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return [
|
|
114
|
+
...found
|
|
115
|
+
];
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=purge.js.map
|
package/purge.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.js","sources":["./purge.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAG7E,SACE,KAAK,EACL,KAAK,EAEL,GAAG,EAEH,MAAM,EACN,KAAK,yBACsB;AAC7B,SAAS,OAAO,EAAE,KAAK,wBAAuB;AAC9C,SAAS,QAAQ,oBAAmB;AACpC,SAAS,KAAK,qBAAoB;AAClC,SAAS,MAAM,oBAAmB;AAClC,SAAS,MAAM,wBAAuB;AACtC,SAAS,OAAO,uBAAsB;AAEtC,IAAI,WAAW,IAAI,IAAI;EAAC;EAAU;EAAW;EAAS;CAAM;AAE5D,0EAA0E,GAC1E,OAAO,IAAI,eAAe,CACxB,QACA,OACA,MACA;EAEA,IAAI,QAAQ,IAAI,IACd,OAAO,KAAK,CAAC,OAAO;IAClB,MAAM;MAAC,IAAI;MAAO,IAAI;KAAO;IAC7B,MAAM,MAAM;IACZ,OAAO,MAAM,IAAI,QAAQ,MAAM;EACjC,IAAI,GAAG,CAAC,CAAC,IAAM;MAAC,OAAO,EAAE,EAAE;MAAG,OAAO,EAAE,GAAG;KAAE;EAE9C,IAAI,MAAgB,EAAE;EACtB,KACE,IAAI,CAAC,MAAM,MAAM,IAAI,OAAO,OAAO,CAAC,MAClC,QACA,CAAC,OAAS,CAAC,QAAQ,SAAS,KAAK,QAAQ,CAAC,eAE5C;IACA,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG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;EACF;EACA,OAAO;EACP,OAAO;AACT,EAAC;AAED;mDACmD,GACnD,OAAO,IAAI,WAAW,CAAC,QAAgB;EACrC,IAAI,aAAa,IAAI,IAAI,SAAS,QAAQ,IAAI;EAC9C,IAAI,QAAQ,CAAC;IACX,IAAI,OAAO,SAAS,UAAU;MAC5B,IAAI,WAAW,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC;MACrC,IAAI,SAAS,IAAI,CAAC,QAAQ;QACxB,IAAI;UACF,MAAM,KAAK,KAAK,CAAC;QACnB,EAAE,OAAM,CAAsB;MAChC;IACF,OAAO,IAAI,SAAS,OAAO,SAAS,UAAU;MAC5C,KAAK,IAAI,QAAQ,OAAO,MAAM,CAAC,OAAQ,MAAM;IAC/C;EACF;EACA,IAAI,SAAS,MAAM,QAAQ,CAAC,OAAS,CAAC,QAAQ;EAC9C,KAAK,IAAI,CAAC,MAAM,MAAM,IAAI,OAAO,OAAO,CAAC,QAAS;IAChD,IACE,QAAQ,SAAS,CAAC,KAAK,QAAQ,CAAC,gBAChC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAM,EAAE,IAAI,IAAI,YAAY,OAAO,EAAE,EAAE,IAAI,IAC7D;IACF,IAAI,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,IAAM,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,IACvD,CAAC,SAAS,GAAG,CAAC;IAEhB,IAAI,KAAK,MAAM,EAAE;MACf,KACE,IAAI,OAAO,OAAO,KAAK,CAAC,OAAO;QAC7B,MAAM,KAAK,GAAG,CAAC,CAAC,IAAM,IAAI;QAC1B,MAAM,MAAM;MACd,IACA,MAAM;IACV;EACF;EACA,OAAO;OAAI;GAAM;AACnB,EAAC"}
|
package/purge.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Explicit purge belongs to the owner of the retained versions. These writes
|
|
2
|
+
// bypass ordinary entity mutation: deliberately erased history is not trash.
|
|
3
|
+
import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
|
|
4
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
5
|
+
import {
|
|
6
|
+
among,
|
|
7
|
+
array,
|
|
8
|
+
type BindOpts,
|
|
9
|
+
col,
|
|
10
|
+
type Driver,
|
|
11
|
+
select,
|
|
12
|
+
table,
|
|
13
|
+
} from '@yaks/sql'
|
|
14
|
+
import { foreign, stood } from './physical.js'
|
|
15
|
+
import { valuesOf } from './read.js'
|
|
16
|
+
import { TRASH } from './trash.js'
|
|
17
|
+
import { erased } from './mode.js'
|
|
18
|
+
import { tables } from './physical.js'
|
|
19
|
+
import { WRITTEN } from './written.js'
|
|
20
|
+
|
|
21
|
+
let metadata = new Set(['entity', '$branch', '$from', '$to'])
|
|
22
|
+
|
|
23
|
+
/** Every version of exactly these identities, including retired columns. */
|
|
24
|
+
export let purgeHistory = (
|
|
25
|
+
driver: Driver,
|
|
26
|
+
vocab: Vocab,
|
|
27
|
+
eids: string[],
|
|
28
|
+
opts: BindOpts,
|
|
29
|
+
): Bundle[] => {
|
|
30
|
+
let names = new Map(
|
|
31
|
+
driver.query(select({
|
|
32
|
+
cols: [col('id'), col('eid')],
|
|
33
|
+
from: table('entity'),
|
|
34
|
+
where: among(col('eid'), array(eids)),
|
|
35
|
+
})).map((r) => [Number(r.id), String(r.eid)]),
|
|
36
|
+
)
|
|
37
|
+
let out: Bundle[] = []
|
|
38
|
+
for (
|
|
39
|
+
let [name, shape] of Object.entries(stood(
|
|
40
|
+
driver,
|
|
41
|
+
(name) => !foreign(name) && name.endsWith('$versions'),
|
|
42
|
+
))
|
|
43
|
+
) {
|
|
44
|
+
let comp = name.slice(0, -'$versions'.length)
|
|
45
|
+
let where = among(col('entity', comp), array([...names.keys()]))
|
|
46
|
+
if (vocab.comp(comp)) {
|
|
47
|
+
out.push(
|
|
48
|
+
...valuesOf(driver, vocab, comp, name, where, opts).map((
|
|
49
|
+
[id, value],
|
|
50
|
+
) => ({ entity: { eid: names.get(id)! }, [comp]: value })),
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
// The current vocabulary cannot decode a retired property. Its stored
|
|
54
|
+
// value still matters to resources retaining content by address.
|
|
55
|
+
let extras = shape.cols.map((c) => String(c.name)).filter((p) =>
|
|
56
|
+
!metadata.has(p) && !vocab.prop(comp, p)
|
|
57
|
+
)
|
|
58
|
+
if (extras.length) {
|
|
59
|
+
out.push(
|
|
60
|
+
...driver.query(select({
|
|
61
|
+
cols: [col('entity', comp), ...extras.map((p) => col(p, comp))],
|
|
62
|
+
from: table(name, comp),
|
|
63
|
+
where,
|
|
64
|
+
})).map(({ entity, ...value }) => ({
|
|
65
|
+
entity: { eid: names.get(Number(entity))! },
|
|
66
|
+
[comp]: value,
|
|
67
|
+
})),
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
driver.query({
|
|
71
|
+
t: 'delete',
|
|
72
|
+
from: name,
|
|
73
|
+
where: among(col('entity'), array([...names.keys()])),
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
if (tables(driver).includes(WRITTEN)) {
|
|
77
|
+
driver.query({
|
|
78
|
+
t: 'insert',
|
|
79
|
+
into: WRITTEN,
|
|
80
|
+
cols: ['entity'],
|
|
81
|
+
q: select({
|
|
82
|
+
cols: [col('id')],
|
|
83
|
+
from: table('entity'),
|
|
84
|
+
where: among(col('eid'), array(eids)),
|
|
85
|
+
}),
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
erased(driver)
|
|
89
|
+
return out
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Exact candidate strings, including inside JSON, without depending on the
|
|
93
|
+
* current vocabulary to remember retired columns. */
|
|
94
|
+
export let retained = (driver: Driver, values: string[]): string[] => {
|
|
95
|
+
let candidates = new Set(values), found = new Set<string>()
|
|
96
|
+
let visit = (value: unknown): void => {
|
|
97
|
+
if (typeof value == 'string') {
|
|
98
|
+
if (candidates.has(value)) found.add(value)
|
|
99
|
+
if (/^[\[{]/.test(value)) {
|
|
100
|
+
try {
|
|
101
|
+
visit(JSON.parse(value))
|
|
102
|
+
} catch { /* ordinary text */ }
|
|
103
|
+
}
|
|
104
|
+
} else if (value && typeof value == 'object') {
|
|
105
|
+
for (let part of Object.values(value)) visit(part)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
let shapes = stood(driver, (name) => !foreign(name))
|
|
109
|
+
for (let [name, shape] of Object.entries(shapes)) {
|
|
110
|
+
if (
|
|
111
|
+
name != TRASH && !name.endsWith('$versions') &&
|
|
112
|
+
!shape.cols.some((c) => c.name == 'entity' && Number(c.pk) > 0)
|
|
113
|
+
) continue
|
|
114
|
+
let cols = shape.cols.map((c) => String(c.name)).filter((p) =>
|
|
115
|
+
!metadata.has(p)
|
|
116
|
+
)
|
|
117
|
+
if (cols.length) {
|
|
118
|
+
for (
|
|
119
|
+
let row of driver.query(select({
|
|
120
|
+
cols: cols.map((p) => col(p)),
|
|
121
|
+
from: table(name),
|
|
122
|
+
}))
|
|
123
|
+
) visit(row)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return [...found]
|
|
127
|
+
}
|
package/raise.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// A component's table is made the first time a write names the component, not
|
|
2
|
+
// when its store installs (D-143541). An empty store holds the spine, the
|
|
3
|
+
// tables a host keeps of its own (blobs, vectors, the journal) and nothing for
|
|
4
|
+
// a word nobody has written; a store holds a table, its indexes and the
|
|
5
|
+
// triggers kept over it only for the words it uses.
|
|
6
|
+
//
|
|
7
|
+
// What belongs to a component is read off the statements themselves, the
|
|
8
|
+
// store's and every one a host keeps beside them, rather than declared twice:
|
|
9
|
+
// a statement **rests on** the component tables it is on, reads or writes,
|
|
10
|
+
// and on whatever the objects it names rest on (a search index on the text
|
|
11
|
+
// view it reads, a trigger on the index it writes). One that rests on no
|
|
12
|
+
// component table is made when the store installs. One that rests on some is
|
|
13
|
+
// made once every table it rests on stands: by the install, over a file that
|
|
14
|
+
// holds them, and otherwise in the transaction of the write that raises the
|
|
15
|
+
// last of them, before that write's rows, so its triggers see them. An object
|
|
16
|
+
// that rests on none but is kept over a component's table (a substring index's
|
|
17
|
+
// list of pieces) is made with the first raised statement that names it,
|
|
18
|
+
// where no install made it.
|
|
19
|
+
//
|
|
20
|
+
// A read of a component with no table answers as one worn by no entity
|
|
21
|
+
// (@yaks/sql `absentDialect`, `absentDerived`).
|
|
22
|
+
import { catalogue, erect, revision } from "@yaks/sql/core";
|
|
23
|
+
import { indexed, tabled } from "./ddl.js";
|
|
24
|
+
import { tables } from "./layout.js";
|
|
25
|
+
import { componentTables } from "./physical.js";
|
|
26
|
+
import { meta, TABLES, tablesAt } from "./meta.js";
|
|
27
|
+
/** The revision of when a component's objects are made: part of every
|
|
28
|
+
* store's print (./plan.ts), so code that made them all at install finds a
|
|
29
|
+
* store this code made as one it never installed, and makes them. */ export let RAISED = 1;
|
|
30
|
+
// The component tables every install makes: the graves, and the archetype
|
|
31
|
+
// descriptors and their retirements, which a catalog reads by name before
|
|
32
|
+
// anything is written (./catalog.ts).
|
|
33
|
+
let EAGER = new Set([
|
|
34
|
+
'tombstone',
|
|
35
|
+
'archetype',
|
|
36
|
+
'retired'
|
|
37
|
+
]);
|
|
38
|
+
/** Whether `comp`'s table waits for the first write that names it. */ export let lazy = (vocab, comp)=>!EAGER.has(comp) && !!vocab.comp(comp) && !vocab.comp(comp).computed && comp != 'entity';
|
|
39
|
+
// Every name a statement is on, reads or writes: a source table, a trigger's
|
|
40
|
+
// or an index's table, a write's target, a virtual table's content.
|
|
41
|
+
let names = (node, into)=>{
|
|
42
|
+
if (Array.isArray(node)) {
|
|
43
|
+
for (let n of node)names(n, into);
|
|
44
|
+
return into;
|
|
45
|
+
}
|
|
46
|
+
if (!node || typeof node != 'object') return into;
|
|
47
|
+
let o = node;
|
|
48
|
+
if (o.t == 'raw' || o.t == 'val' || o.t == 'lit') return into;
|
|
49
|
+
if (o.t == 'table' && !o.args) into.add(String(o.name));
|
|
50
|
+
if (o.t == 'create trigger' || o.t == 'create index') into.add(String(o.on));
|
|
51
|
+
if (o.t == 'insert') into.add(String(o.into));
|
|
52
|
+
if (o.t == 'update') into.add(String(o.table));
|
|
53
|
+
if (o.t == 'delete' && typeof o.from == 'string') into.add(o.from);
|
|
54
|
+
if (o.t == 'drop') into.add(String(o.name));
|
|
55
|
+
if (o.t == 'create virtual table') {
|
|
56
|
+
for (let a of o.args){
|
|
57
|
+
if (Array.isArray(a) && a[0] == 'content') into.add(String(a[1]));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (let v of Object.values(o))names(v, into);
|
|
61
|
+
return into;
|
|
62
|
+
};
|
|
63
|
+
let mentioned = new WeakMap();
|
|
64
|
+
let mentions = (stmt)=>{
|
|
65
|
+
let found = mentioned.get(stmt);
|
|
66
|
+
if (!found) mentioned.set(stmt, found = names(stmt, new Set()));
|
|
67
|
+
return found;
|
|
68
|
+
};
|
|
69
|
+
// A store's own schema and what its host keeps beside it, as one list per
|
|
70
|
+
// vocabulary, read overrides, file and host list: a Vocab is a value nobody
|
|
71
|
+
// mutates once loaded, so a process works out what rests on what once.
|
|
72
|
+
let NONE = {};
|
|
73
|
+
let schemas = new WeakMap();
|
|
74
|
+
let joined = new WeakMap();
|
|
75
|
+
/** Everything a component's first write may make in a store of `vocab`: its
|
|
76
|
+
* own schema (./ddl.ts `tabled`, `indexed`) and `over`, what its host keeps
|
|
77
|
+
* beside it. The same list comes back for the same arguments. */ export let units = (vocab, derived = NONE, file = false, over = [])=>{
|
|
78
|
+
let by = schemas.get(vocab) ?? new WeakMap();
|
|
79
|
+
schemas.set(vocab, by);
|
|
80
|
+
let held = by.get(derived) ?? [];
|
|
81
|
+
by.set(derived, held);
|
|
82
|
+
let own = held[Number(file)] ??= [
|
|
83
|
+
...tabled(vocab, derived, file),
|
|
84
|
+
...indexed(vocab)
|
|
85
|
+
];
|
|
86
|
+
if (!over.length) return own;
|
|
87
|
+
let beside = joined.get(own) ?? new WeakMap();
|
|
88
|
+
joined.set(own, beside);
|
|
89
|
+
let all = beside.get(over);
|
|
90
|
+
if (!all) beside.set(over, all = [
|
|
91
|
+
...own,
|
|
92
|
+
...over
|
|
93
|
+
]);
|
|
94
|
+
return all;
|
|
95
|
+
};
|
|
96
|
+
let rested = new WeakMap();
|
|
97
|
+
/** The component tables each of `stmts` rests on, in order: the ones it
|
|
98
|
+
* names, and the ones every object it names that another of `stmts` makes
|
|
99
|
+
* rests on. */ export let rests = (vocab, stmts)=>{
|
|
100
|
+
let by = rested.get(vocab) ?? new WeakMap();
|
|
101
|
+
rested.set(vocab, by);
|
|
102
|
+
let known = by.get(stmts);
|
|
103
|
+
if (known) return known;
|
|
104
|
+
let makers = new Map();
|
|
105
|
+
stmts.forEach((s, i)=>{
|
|
106
|
+
if (s.t.startsWith('create ') && 'name' in s) makers.set(s.name, i);
|
|
107
|
+
});
|
|
108
|
+
let memo = new Map();
|
|
109
|
+
let of = (i)=>{
|
|
110
|
+
let held = memo.get(i);
|
|
111
|
+
if (held) return held;
|
|
112
|
+
let found = new Set();
|
|
113
|
+
memo.set(i, found);
|
|
114
|
+
let s = stmts[i];
|
|
115
|
+
let made = s.t.startsWith('create ') && 'name' in s ? s.name : null;
|
|
116
|
+
// A component's own table rests on itself.
|
|
117
|
+
if (made != null && lazy(vocab, made)) found.add(made);
|
|
118
|
+
for (let n of mentions(s)){
|
|
119
|
+
if (lazy(vocab, n)) found.add(n);
|
|
120
|
+
let maker = makers.get(n);
|
|
121
|
+
if (n != made && maker != null) {
|
|
122
|
+
for (let c of of(maker))found.add(c);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return found;
|
|
126
|
+
};
|
|
127
|
+
let all = stmts.map((_, i)=>[
|
|
128
|
+
...of(i)
|
|
129
|
+
]);
|
|
130
|
+
by.set(stmts, all);
|
|
131
|
+
return all;
|
|
132
|
+
};
|
|
133
|
+
// What the file's receipt says, per schema revision: a write that raises a
|
|
134
|
+
// table moves the schema and the receipt in one transaction.
|
|
135
|
+
let receipts = new WeakMap();
|
|
136
|
+
/** The component tables the file holds, as its receipt says (./meta.ts
|
|
137
|
+
* `TABLES`), one row; undefined where no install of this code recorded one,
|
|
138
|
+
* a file whose install made every table. */ let held = (driver)=>{
|
|
139
|
+
let at = revision(driver, 'schema');
|
|
140
|
+
let k = receipts.get(driver);
|
|
141
|
+
if (k?.at !== at) {
|
|
142
|
+
let said = tablesAt(driver);
|
|
143
|
+
receipts.set(driver, k = {
|
|
144
|
+
at,
|
|
145
|
+
held: said && new Set(said)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return k.held;
|
|
149
|
+
};
|
|
150
|
+
/** Record the component tables the file holds now, in its receipt: what an
|
|
151
|
+
* install does once its tables stand. */ export let recorded = (driver)=>{
|
|
152
|
+
let found = componentTables(driver);
|
|
153
|
+
meta(driver).set(TABLES, found.join(' '));
|
|
154
|
+
receipts.set(driver, {
|
|
155
|
+
at: revision(driver, 'schema'),
|
|
156
|
+
held: new Set(found)
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
let standings = new WeakMap();
|
|
160
|
+
let standing = (driver, vocab)=>{
|
|
161
|
+
let all = held(driver);
|
|
162
|
+
let at = revision(driver, 'schema');
|
|
163
|
+
let k = standings.get(driver);
|
|
164
|
+
if (k?.at !== at || k.all !== all) {
|
|
165
|
+
standings.set(driver, k = {
|
|
166
|
+
at,
|
|
167
|
+
all,
|
|
168
|
+
by: new WeakMap()
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
let got = k.by.get(vocab);
|
|
172
|
+
if (!got) {
|
|
173
|
+
let names = tables(vocab);
|
|
174
|
+
// Main's receipt can omit a table first raised under a branch's words.
|
|
175
|
+
// A mode also sees the tables already present in the shared schema.
|
|
176
|
+
let present = driver.views && all ? new Set([
|
|
177
|
+
...all,
|
|
178
|
+
...componentTables(driver, [
|
|
179
|
+
...all
|
|
180
|
+
], names)
|
|
181
|
+
]) : all;
|
|
182
|
+
let raised = new Set(names.filter((c)=>lazy(vocab, c) && (!present || present.has(c))));
|
|
183
|
+
got = {
|
|
184
|
+
raised,
|
|
185
|
+
unraised: Object.freeze(names.filter((c)=>lazy(vocab, c) && !raised.has(c))),
|
|
186
|
+
stood: Object.freeze(names.filter((c)=>!lazy(vocab, c) || raised.has(c)))
|
|
187
|
+
};
|
|
188
|
+
k.by.set(vocab, got);
|
|
189
|
+
}
|
|
190
|
+
return got;
|
|
191
|
+
};
|
|
192
|
+
/** The tables of `vocab` raised on a first write that this file holds. */ export let raisedIn = (driver, vocab)=>new Set(standing(driver, vocab).raised);
|
|
193
|
+
/** The components of `vocab` whose table waits for a first write. */ export let unraised = (driver, vocab)=>standing(driver, vocab).unraised;
|
|
194
|
+
/** The tables of `vocab` this file holds. */ export let stood = (driver, vocab)=>standing(driver, vocab).stood;
|
|
195
|
+
/** Those of `stmts` that rest on no table this file lacks, as its schema
|
|
196
|
+
* says: what an install makes, before any receipt is recorded. */ export let holds = (driver, vocab, stmts)=>{
|
|
197
|
+
let on = rests(vocab, stmts);
|
|
198
|
+
if (on.every((r)=>!r.length)) return [
|
|
199
|
+
...stmts
|
|
200
|
+
];
|
|
201
|
+
let stands = new Set(componentTables(driver));
|
|
202
|
+
return stmts.filter((_, i)=>on[i].every((c)=>stands.has(c)));
|
|
203
|
+
};
|
|
204
|
+
// Those of `stmts` that rest on no component table, make an object one of
|
|
205
|
+
// `raised` names, and the file lacks: what a host keeps over a component's
|
|
206
|
+
// table for it alone (a substring index's list of pieces) stands once the
|
|
207
|
+
// component's first write does, as what rests on the component does.
|
|
208
|
+
let unmade = (driver, stmts, on, raised)=>{
|
|
209
|
+
let made = (s)=>s.t.startsWith('create ') && 'name' in s ? s.name : null;
|
|
210
|
+
let alone = stmts.filter((s, i)=>!on[i].length && made(s) != null);
|
|
211
|
+
if (!alone.length) return [];
|
|
212
|
+
let named = new Set();
|
|
213
|
+
for (let stmt of raised){
|
|
214
|
+
for (let name of mentions(stmt))named.add(name);
|
|
215
|
+
}
|
|
216
|
+
let held = new Set(catalogue(driver).map((o)=>o.name));
|
|
217
|
+
return alone.filter((s)=>named.has(made(s)) && !held.has(made(s)));
|
|
218
|
+
};
|
|
219
|
+
// The schema revisions a run of raises on one connection moved through, the
|
|
220
|
+
// first of them where the run began: what moved the schema and nothing else.
|
|
221
|
+
let runs = new WeakMap();
|
|
222
|
+
/** Whether raises alone moved this connection's schema from revision `from`
|
|
223
|
+
* to `to`, so a look at the file taken at `from` stands for all but the
|
|
224
|
+
* tables they made. */ export let raisedOnly = (driver, from, to)=>{
|
|
225
|
+
let run = runs.get(driver);
|
|
226
|
+
return !!run && run.includes(from) && run.at(-1) == to;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Make the tables of `comps` this file lacks, and every one of `stmts` that
|
|
230
|
+
* rests on one of them and on no table still missing, in their order. Answers
|
|
231
|
+
* the components it made a table for. Run it in the transaction of the write
|
|
232
|
+
* that names them, before that write.
|
|
233
|
+
*/ export let raise = (driver, vocab, comps, stmts)=>{
|
|
234
|
+
let stands = raisedIn(driver, vocab);
|
|
235
|
+
let fresh = [
|
|
236
|
+
...new Set(comps)
|
|
237
|
+
].filter((c)=>lazy(vocab, c) && !stands.has(c));
|
|
238
|
+
if (!fresh.length) return [];
|
|
239
|
+
for (let c of fresh)stands.add(c);
|
|
240
|
+
let made = new Set(fresh);
|
|
241
|
+
let from = revision(driver, 'schema');
|
|
242
|
+
let on = rests(vocab, stmts);
|
|
243
|
+
let raised = stmts.filter((_, i)=>on[i].some((c)=>made.has(c)) && on[i].every((c)=>stands.has(c)));
|
|
244
|
+
erect(driver, [
|
|
245
|
+
...unmade(driver, stmts, on, raised),
|
|
246
|
+
...raised
|
|
247
|
+
]);
|
|
248
|
+
let now = new Set([
|
|
249
|
+
...held(driver) ?? componentTables(driver),
|
|
250
|
+
...fresh
|
|
251
|
+
]);
|
|
252
|
+
meta(driver).set(TABLES, [
|
|
253
|
+
...now
|
|
254
|
+
].sort().join(' '));
|
|
255
|
+
let to = revision(driver, 'schema');
|
|
256
|
+
receipts.set(driver, {
|
|
257
|
+
at: to,
|
|
258
|
+
held: now
|
|
259
|
+
});
|
|
260
|
+
let run = runs.get(driver);
|
|
261
|
+
runs.set(driver, run?.at(-1) == from ? [
|
|
262
|
+
...run,
|
|
263
|
+
to
|
|
264
|
+
] : [
|
|
265
|
+
from,
|
|
266
|
+
to
|
|
267
|
+
]);
|
|
268
|
+
return fresh;
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=raise.js.map
|
package/raise.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raise.js","sources":["./raise.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,wEAAwE;AACxE,oDAAoD;AACpD,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,yEAAyE;AACzE,4BAA4B;AAC5B,EAAE;AACF,uEAAuE;AACvE,gDAAgD;AAEhD,SACE,SAAS,EAGT,KAAK,EACL,QAAQ,8BAEwB;AAClC,SAAS,OAAO,EAAE,MAAM,mBAAkB;AAE1C,SAAS,MAAM,sBAAqB;AACpC,SAAS,eAAe,wBAAuB;AAC/C,SAAS,IAAI,EAAE,MAAM,EAAE,QAAQ,oBAAmB;AAElD;;mEAEmE,GACnE,OAAO,IAAI,SAAS,EAAC;AAErB,0EAA0E;AAC1E,0EAA0E;AAC1E,sCAAsC;AACtC,IAAI,QAAQ,IAAI,IAAI;EAAC;EAAa;EAAa;CAAU;AAEzD,oEAAoE,GACpE,OAAO,IAAI,OAAO,CAAC,OAAc,OAC/B,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,C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