@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/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,2EAA2E;AAC3E,wEAAwE;AACxE,+EAA+E;AAE/E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,mDAAmD,GACnD,OAAO,IAAI,YAAsB,IAAG;AAEpC;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAU,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:7db60ead-fba7-419e-b1cc-4e1e5e56feda",
|
|
3
|
+
"$vocabulary": {
|
|
4
|
+
"https://yak.sh/vocab/core": true
|
|
5
|
+
},
|
|
6
|
+
"title": "sqlite",
|
|
7
|
+
"$defs": {
|
|
8
|
+
"storage_check": {
|
|
9
|
+
"tool": true,
|
|
10
|
+
"noun": "storage",
|
|
11
|
+
"verb": "check",
|
|
12
|
+
"title": "Check the database file",
|
|
13
|
+
"description": "Check that the SQLite file holds no component row without its parent record (entity) and no reference to a nonexistent entity. These can be missed by ordinary entity queries, so this asks the connection directly: whether foreign keys are enforced, which rows violate one, and what SQLite’s own integrity_check reports. Takes no arguments. Returns a report in content.body, with warning or failure findings when present; it does not repair the records or configuration.",
|
|
14
|
+
"input": {},
|
|
15
|
+
"readOnly": true
|
|
16
|
+
},
|
|
17
|
+
"archetype_check": {
|
|
18
|
+
"tool": true,
|
|
19
|
+
"noun": "archetype",
|
|
20
|
+
"verb": "check",
|
|
21
|
+
"title": "Check entity component sets",
|
|
22
|
+
"description": "Check that each entity’s archetype pointer matches the components it actually has. An entity is a stored record; its components are named groups of fields, and its archetype pointer identifies the set of component types present. Direct database writes that bypass the graph can leave these pointers stale, causing reads and query planning to use the wrong component set. Takes no arguments. Returns a report in content.body, with warning or failure findings when present; it does not repair the records or configuration.",
|
|
23
|
+
"input": {},
|
|
24
|
+
"readOnly": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The component and tool declarations, and only those: the module exported as
|
|
2
|
+
// `@yaks/sqlite/vocab`. This package declares no component — a store is not a
|
|
3
|
+
// domain, and nothing here is sent to a client. What it declares is two tools,
|
|
4
|
+
// the checks in ./tools.ts, because a tool is declared in a vocabulary and
|
|
5
|
+
// listed by the application the same way a component is: the file's own
|
|
6
|
+
// invariants are checked through the same mechanism every other package's are.
|
|
7
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
8
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
9
|
+
import manifest from './package.json' with { type: 'json' }
|
|
10
|
+
|
|
11
|
+
/** The tool declarations this plugin contributes. */
|
|
12
|
+
export let sqliteDoc: VocabDoc = doc
|
|
13
|
+
|
|
14
|
+
/** What this package is: its manifest's description, the one place it is
|
|
15
|
+
* written, which a host stamps on each document here. */
|
|
16
|
+
export let description: string = manifest.description
|
|
17
|
+
|
|
18
|
+
/** Every document this plugin declares. */
|
|
19
|
+
export let docs: VocabDoc[] = [sqliteDoc]
|
package/watch.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Rows other connections add, heard as they land. The driver hears its file
|
|
2
|
+
// change (@yaks/sql `Driver.watch`); the component's table then answers its
|
|
3
|
+
// newest row from the end of its key, one seek, and one newer than the last
|
|
4
|
+
// it answered is a row added since. An entity's id is never reused, so a
|
|
5
|
+
// newer row has a higher one. A driver that owns its database alone hears
|
|
6
|
+
// nothing: what it adds, its own writer already knows.
|
|
7
|
+
import { as, col, fn, select, table } from "@yaks/sql";
|
|
8
|
+
import { tables } from "./layout.js";
|
|
9
|
+
/** The newest row of `comp`'s table, one seek: a higher one is a row added
|
|
10
|
+
* since. 0 where nothing has written the table yet, or it names no table. */ export let newest = (driver, vocab, comp)=>// A table nothing has written yet stands once a write first names it
|
|
11
|
+
// (./raise.ts); until then it has no newest row.
|
|
12
|
+
tables(vocab).includes(comp) && driver.query({
|
|
13
|
+
t: 'pragma',
|
|
14
|
+
name: 'table_info',
|
|
15
|
+
arg: comp
|
|
16
|
+
}).length ? Number(driver.query(select({
|
|
17
|
+
cols: [
|
|
18
|
+
as(fn('max', col('entity')), 'newest')
|
|
19
|
+
],
|
|
20
|
+
from: table(comp)
|
|
21
|
+
}))[0]?.newest ?? 0) : 0;
|
|
22
|
+
/** Call `heard` soon after another connection commits a new row of
|
|
23
|
+
* `comp`. */ export let watch = (driver, vocab, comp, heard)=>{
|
|
24
|
+
if (!driver.watch || !tables(vocab).includes(comp)) return ()=>{};
|
|
25
|
+
let last = newest(driver, vocab, comp);
|
|
26
|
+
return driver.watch(()=>{
|
|
27
|
+
let now = newest(driver, vocab, comp);
|
|
28
|
+
let more = now > last;
|
|
29
|
+
last = now;
|
|
30
|
+
if (more) heard();
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=watch.js.map
|
package/watch.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["./watch.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,uDAAuD;AACvD,SAAS,EAAE,EAAE,GAAG,EAAe,EAAE,EAAE,MAAM,EAAE,KAAK,yBAA8B;AAE9E,SAAS,MAAM,sBAAqB;AAEpC;2EAC2E,GAC3E,OAAO,IAAI,SAAS,CAAC,QAAgB,OAAc,OACjD,qEAAqE;EACrE,iDAAiD;EACjD,OAAO,OAAO,QAAQ,CAAC,SACrB,OAAO,KAAK,CAAC;IAAE,GAAG;IAAU,MAAM;IAAc,KAAK;EAAK,GAAG,MAAM,GACjE,OACA,OAAO,KAAK,CAAC,OAAO;IAClB,MAAM;MAAC,GAAG,GAAG,OAAO,IAAI,YAAY;KAAU;IAC9C,MAAM,MAAM;EACd,GAAG,CAAC,EAAE,EAAE,UAAU,KAElB,EAAC;AAEP;WACW,GACX,OAAO,IAAI,QAAQ,CACjB,QACA,OACA,MACA;EAEA,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,OAAO,QAAQ,CAAC,OAAO,OAAO,KAAO;EAClE,IAAI,OAAO,OAAO,QAAQ,OAAO;EACjC,OAAO,OAAO,KAAK,CAAC;IAClB,IAAI,MAAM,OAAO,QAAQ,OAAO;IAChC,IAAI,OAAO,MAAM;IACjB,OAAO;IACP,IAAI,MAAM;EACZ;AACF,EAAC"}
|
package/watch.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Rows other connections add, heard as they land. The driver hears its file
|
|
2
|
+
// change (@yaks/sql `Driver.watch`); the component's table then answers its
|
|
3
|
+
// newest row from the end of its key, one seek, and one newer than the last
|
|
4
|
+
// it answered is a row added since. An entity's id is never reused, so a
|
|
5
|
+
// newer row has a higher one. A driver that owns its database alone hears
|
|
6
|
+
// nothing: what it adds, its own writer already knows.
|
|
7
|
+
import { as, col, type Driver, fn, select, table } from '@yaks/sql'
|
|
8
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
9
|
+
import { tables } from './layout.js'
|
|
10
|
+
|
|
11
|
+
/** The newest row of `comp`'s table, one seek: a higher one is a row added
|
|
12
|
+
* since. 0 where nothing has written the table yet, or it names no table. */
|
|
13
|
+
export let newest = (driver: Driver, vocab: Vocab, comp: string): number =>
|
|
14
|
+
// A table nothing has written yet stands once a write first names it
|
|
15
|
+
// (./raise.ts); until then it has no newest row.
|
|
16
|
+
tables(vocab).includes(comp) &&
|
|
17
|
+
driver.query({ t: 'pragma', name: 'table_info', arg: comp }).length
|
|
18
|
+
? Number(
|
|
19
|
+
driver.query(select({
|
|
20
|
+
cols: [as(fn('max', col('entity')), 'newest')],
|
|
21
|
+
from: table(comp),
|
|
22
|
+
}))[0]?.newest ?? 0,
|
|
23
|
+
)
|
|
24
|
+
: 0
|
|
25
|
+
|
|
26
|
+
/** Call `heard` soon after another connection commits a new row of
|
|
27
|
+
* `comp`. */
|
|
28
|
+
export let watch = (
|
|
29
|
+
driver: Driver,
|
|
30
|
+
vocab: Vocab,
|
|
31
|
+
comp: string,
|
|
32
|
+
heard: () => void,
|
|
33
|
+
): () => void => {
|
|
34
|
+
if (!driver.watch || !tables(vocab).includes(comp)) return () => {}
|
|
35
|
+
let last = newest(driver, vocab, comp)
|
|
36
|
+
return driver.watch(() => {
|
|
37
|
+
let now = newest(driver, vocab, comp)
|
|
38
|
+
let more = now > last
|
|
39
|
+
last = now
|
|
40
|
+
if (more) heard()
|
|
41
|
+
})
|
|
42
|
+
}
|