@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import { type Driver } from "@yaks/sql";
|
|
3
|
+
import { type Ledger } from "./ledger.js";
|
|
4
|
+
export { type Ledger, ledger } from "./ledger.js";
|
|
5
|
+
export { componentTables } from "./physical.js";
|
|
6
|
+
/** Counts from a boot: existing assignments stay untouched on a repeated run. */ export type Backfill = {
|
|
7
|
+
entities: number;
|
|
8
|
+
archetypes: number;
|
|
9
|
+
retired: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Every entity classified again from the tables it holds rows in, not only the
|
|
13
|
+
* unclassified ones: what a pass that wrote component tables directly, outside
|
|
14
|
+
* the graph, leaves to do. Atomic, like {@link backfill}.
|
|
15
|
+
*/ export declare let reclassifyAll: (driver: Driver) => Backfill;
|
|
16
|
+
/**
|
|
17
|
+
* Idempotent, atomic boot maintenance, after additive DDL has installed the
|
|
18
|
+
* column and archetype vocabulary. Reads presence from the physical file, not
|
|
19
|
+
* vocab. Retires forever a descriptor naming a table that is missing or no
|
|
20
|
+
* longer a component table (a key renamed away from `entity`); reclassifies
|
|
21
|
+
* their owners, plus null assignments, in table-sized scans. No per-owner
|
|
22
|
+
* component census.
|
|
23
|
+
*/ export declare function backfill(driver: Driver, assignments?: boolean): Backfill;
|
|
24
|
+
/** An audit's tally: owners read, pointers that disagree, and a few names. */ export type Drift = {
|
|
25
|
+
checked: number;
|
|
26
|
+
drifted: number;
|
|
27
|
+
sample: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The audit half of `reclassify`, and it writes nothing. A row written past
|
|
31
|
+
* the graph must name its owners; a writer that forgets leaves a pointer that
|
|
32
|
+
* no longer describes its entity, and both the read path and the query planner
|
|
33
|
+
* trust that pointer — nothing else notices. So this reads presence for every
|
|
34
|
+
* owner, by the same rule and the same component list classification uses, and
|
|
35
|
+
* reports where the two disagree. Descriptors are their own fixed point and
|
|
36
|
+
* are left out, exactly as `reclassify` leaves them out.
|
|
37
|
+
*/ export declare function drift(driver: Driver, sample?: number): Drift;
|
|
38
|
+
/**
|
|
39
|
+
* Every owner the audit finds out of step ({@link drift}) classified again
|
|
40
|
+
* from the rows it holds, a few thousand to a unit, so a large file never
|
|
41
|
+
* holds the write lock for the whole pass: the repair for pointers a writer
|
|
42
|
+
* past every door left behind. Returns how many moved.
|
|
43
|
+
*/ export declare let mend: (driver: Driver) => number;
|
|
44
|
+
/**
|
|
45
|
+
* The tables these entities hold rows in, as their removal clears them: each
|
|
46
|
+
* one's stored archetype, as the connection's ledger amends it for what the
|
|
47
|
+
* open transaction wrote since ({@link Ledger} `held`), among the component
|
|
48
|
+
* tables the file holds. One statement reads the pointers, so a removal costs
|
|
49
|
+
* the tables its entities wear rather than every table in the file.
|
|
50
|
+
*
|
|
51
|
+
* The pointer is exact wherever no unit is open: every door classifies what it
|
|
52
|
+
* wrote before its unit closes, and a raw writer calls {@link reclassify}
|
|
53
|
+
* (what {@link drift} audits). An entity with no pointer that the transaction
|
|
54
|
+
* did not mint is a failure: `lost` repairs those, as {@link reclassify} does
|
|
55
|
+
* before their tables are read again; without one, the failure is thrown.
|
|
56
|
+
*/ export declare function heldBy(driver: Driver, eids: string[], book?: Ledger, lost?: (eids: string[]) => void): string[];
|
|
57
|
+
/**
|
|
58
|
+
* Point these entities, just removed, at the tombstone set, minting its
|
|
59
|
+
* descriptor the first time a store needs one. A removal clears every table
|
|
60
|
+
* its entities hold rows in ({@link heldBy}), so what each one holds afterwards
|
|
61
|
+
* is its tombstone and nothing else, known without reading a table. A unit
|
|
62
|
+
* calls this for the dead its ledger still owes a pointer ({@link Ledger}
|
|
63
|
+
* `buried`) as it closes, so the dead leave their archetype whichever door
|
|
64
|
+
* removed them, and a presence lookup passes them by. Answers whether it
|
|
65
|
+
* minted a descriptor.
|
|
66
|
+
*/ export declare function entomb(driver: Driver, eids: string[]): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Classify the named entities from their physical presence, now, inside the
|
|
69
|
+
* caller's transaction. For rows an application wrote past the graph (raw SQL
|
|
70
|
+
* into a component table), and the repair of an entity met with no archetype:
|
|
71
|
+
* no queue, no triggers, the same presence rule as boot. Returns the pointers
|
|
72
|
+
* that moved and any descriptor minted, as bundles an application can
|
|
73
|
+
* broadcast. Descriptors and unknown eids are left alone.
|
|
74
|
+
*/ export declare function reclassify(driver: Driver, eids: string[]): Bundle[];
|
|
75
|
+
//# sourceMappingURL=archetype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archetype.d.ts","sources":["../archetype.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,2BAAgC;AAQpD,SAKE,KAAK,MAAM,yBAgBgB;AAS7B,SAAS,KAAK,MAAM,sBAA6B;AACjD,SAAS,KAAK,MAAM,EAAE,MAAM,sBAAqB;AAEjD,SAAS,eAAe,wBAAuB;AA8B/C,+EAA+E,GAC/E,YAAY;EACV,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,SAAS,MAAM;;AA+JjB;;;;CAIC,GACD,OAAO,YAAI,gBAAiB,QAAQ,WAAS,SAQzC;AAEJ;;;;;;;CAOC,GACD,OAAO,iBAAS,SACd,QAAQ,MAAM,EACd,qBAAkB,GACjB;AA+MH,4EAA4E,GAC5E,YAAY;EAAU,SAAS,MAAM;EAAE,SAAS,MAAM;EAAE,QAAQ,MAAM;;AAOtE;;;;;;;;CAQC,GACD,OAAO,iBAAS,MAAM,QAAQ,MAAM,EAAE,eAAW,GAAG;AAoDpD;;;;;CAKC,GACD,OAAO,YAAI,OAAQ,QAAQ,WAAS,MAAM,CAQzC;AAoBD;;;;;;;;;;;;CAYC,GACD,OAAO,iBAAS,OACd,QAAQ,MAAM,EACd,MAAM,MAAM,EAAE,EACd,OAAO,MAAM,EACb,QAAQ,MAAM,MAAM,OAAO,IAAI,GAC9B,MAAM;AAqBT;;;;;;;;;CASC,GACD,OAAO,iBAAS,OACd,QAAQ,MAAM,EACd,MAAM,MAAM,EAAE,GACb,OAAO;AAqBV;;;;;;;CAOC,GACD,OAAO,iBAAS,WACd,QAAQ,MAAM,EACd,MAAM,MAAM,EAAE,GACb"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Driver } from "@yaks/sql";
|
|
2
|
+
import type { BindOpts } from "@yaks/sql/query";
|
|
3
|
+
import type { Vocab } from "@yaks/vocab";
|
|
4
|
+
import type { Branches } from "@yaks/graph/storage";
|
|
5
|
+
import { type History, type Mode } from "./history.js";
|
|
6
|
+
import { Refused } from "@yaks/graph/errors";
|
|
7
|
+
/** Whether the store over `driver` is still taking its live rows as their
|
|
8
|
+
* first versions (`Opts.paced`): what maintain() owes it. */ export declare let seeding: (driver: Driver) => boolean;
|
|
9
|
+
/** A store still taking its live rows as their first versions (`Opts.paced`)
|
|
10
|
+
* makes no branch yet: one would read main as of a fork that misses every
|
|
11
|
+
* row not taken. Asked again once maintain() has taken the last page. */ export declare class Unseeded extends Refused {
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
/** Make a branch of main at its newest transaction: one row, nothing copied.
|
|
15
|
+
* Answers its id and the transaction it forked at. */ export declare let branch: (driver: Driver, history: History) => {
|
|
16
|
+
branch: number;
|
|
17
|
+
fork: number;
|
|
18
|
+
};
|
|
19
|
+
/** The branch `id`, as a mode: where it forked. Undefined for none. */ export declare let branchOf: (driver: Driver, id: number) => Mode | undefined;
|
|
20
|
+
/** The branches of the store with history over `driver`, its changes read
|
|
21
|
+
* with `opts` as its reads are. Making one makes sure main has the archetype
|
|
22
|
+
* of an entity holding nothing, which an entity the branch makes is on main. */ export declare let branching: (driver: Driver, vocab: Vocab, history: History, opts?: () => BindOpts) => Branches;
|
|
23
|
+
//# sourceMappingURL=branches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branches.d.ts","sources":["../branches.ts"],"names":[],"mappings":"AAWA,SAIE,KAAK,MAAM,yBAcgB;AAC7B,cAAc,QAAQ,+BAAoC;AAC1D,cAAc,KAAK,2BAAgC;AAEnD,cAAsB,QAAQ,mCAAgD;AAC9E,SAOE,KAAK,OAAO,EAEZ,KAAK,IAAI,uBAGU;AAKrB,SAAS,OAAO,kCAAuC;AAEvD;2DAC2D,GAC3D,OAAO,YAAI,UAAW,QAAQ,WAAS,OAAO,CACX;AAEnC;;uEAEuE,GACvE,OAAO,cAAM,iBAAiB;EAC5B;AAOF;AAyBA;oDACoD,GACpD,OAAO,YAAI,SACT,QAAQ,QACR,SAAS;EACN,QAAQ,MAAM;EAAE,MAAM,MAAM;EAUhC;AAED,qEAAqE,GACrE,OAAO,YAAI,WAAY,QAAQ,QAAQ,IAAI,MAAM,KAAG,OAAO,SAAS,CAGnE;AA+ED;;8EAE8E,GAC9E,OAAO,YAAI,YACT,QAAQ,QACR,OAAO,OACP,SAAS,SACT,aAAY,aACX,SAmCD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Row } from "@yaks/sql";
|
|
2
|
+
import type { Query } from "./read.js";
|
|
3
|
+
/** The most one read may answer: rows decoded, and their size. */ export type Limits = {
|
|
4
|
+
rows: number;
|
|
5
|
+
bytes: number;
|
|
6
|
+
};
|
|
7
|
+
/** A read's limits: a million rows or 256 MiB. Measured on the box's graph:
|
|
8
|
+
* its pages and tools spend at most 35,000 rows and 5 MiB a read,
|
|
9
|
+
* a million narrow rows meter about 120 MiB, and a read cut at 256 MiB peaks
|
|
10
|
+
* near 480 MiB of a V8 heap's 4 GB while it decodes. */ export declare let LIMITS: Limits;
|
|
11
|
+
/** What a row costs beside its text and blobs: the object and its keys. */ export declare let ROW: number;
|
|
12
|
+
/** What each value costs beside its own bytes. */ export declare let VALUE: number;
|
|
13
|
+
/** Run `read`, refusing it once the rows it decodes pass `limits`, the
|
|
14
|
+
* refusal naming the read as `what` says, so its caller and any report of it
|
|
15
|
+
* can tell which read it was. A read inside another counts against the outer
|
|
16
|
+
* one.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { meter, metered } from './budget.ts'
|
|
20
|
+
* import { equal, throws } from '@yaks/testing'
|
|
21
|
+
*
|
|
22
|
+
* let scan = (n: number) => () => {
|
|
23
|
+
* for (let i = 0; i < n; i++) meter({ x: 'x' })
|
|
24
|
+
* return n
|
|
25
|
+
* }
|
|
26
|
+
* let limits = { rows: 2, bytes: 1_000 }
|
|
27
|
+
* equal(metered(scan(2), { limits }), 2)
|
|
28
|
+
* let refused = await throws(() => metered(scan(3), { limits }))
|
|
29
|
+
* equal((refused as Error).name, 'Refused')
|
|
30
|
+
* let what = () => '.task'
|
|
31
|
+
* await throws(() => metered(scan(3), { what, limits }), /^\.task answers/)
|
|
32
|
+
* let narrow = { rows: 9, bytes: 100 }
|
|
33
|
+
* await throws(() => metered(scan(2), { limits: narrow }), /MiB/)
|
|
34
|
+
* meter({ x: 'outside any read, nothing is counted' })
|
|
35
|
+
* ```
|
|
36
|
+
*/ export declare let metered: <R>(read: () => R, _dts_1: never) => R;
|
|
37
|
+
/** A query read, named as a trace keeps it: every value masked, bounded, and
|
|
38
|
+
* said to be masked where it was, so a search for one word reads as a query
|
|
39
|
+
* whose word is hidden, not as a message with a blank left in it.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { named } from './budget.ts'
|
|
43
|
+
* import { equal } from '@yaks/testing'
|
|
44
|
+
*
|
|
45
|
+
* equal(named('mossvale')(), 'the query `?` (its values masked)')
|
|
46
|
+
* equal(named('.task')(), 'the query `.task`')
|
|
47
|
+
* ```
|
|
48
|
+
*/ export declare let named: (query: Query) => any;
|
|
49
|
+
/** A get, named by how many entities it asked for. */ export declare let gotten: (eids: unknown[]) => any;
|
|
50
|
+
/** Count one decoded row against the read running, if one is; throws a
|
|
51
|
+
* refusal once the read passes its limits. */ export declare let meter: (row: Row) => void;
|
|
52
|
+
//# sourceMappingURL=budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.ts","sources":["../budget.ts"],"names":[],"mappings":"AASA,cAAc,GAAG,yBAA8B;AAE/C,cAAc,KAAK,oBAAmB;AAEtC,gEAAgE,GAChE,YAAY;EAAW,MAAM,MAAM;EAAE,OAAO,MAAM;;AAElD;;;sDAGsD,GACtD,OAAO,YAAI,QAAQ,OAAsD;AAEzE,yEAAyE,GACzE,OAAO,YAAI,YAAQ;AACnB,gDAAgD,GAChD,OAAO,YAAI,cAAU;AAOrB;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,YAAI,UAAW,GACpB,YAAY,GACZ,kBACC,EAQF;AAED;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,QAAS,OAAO,cAK1B;AAED,oDAAoD,GACpD,OAAO,YAAI,SAAU,MAAM,OAAO,WACE;AAEpC;4CAC4C,GAC5C,OAAO,YAAI,QAAS,KAAK,QAAM,IAAI,CAsBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sources":["../bundle.ts"],"names":[],"mappings":"AAqBA,cAAc,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,2BAAgC"}
|
package/_dist/cache.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Driver } from "@yaks/sql";
|
|
2
|
+
/** A rebuildable database's byte budget and its tables' file-URL columns.
|
|
3
|
+
* Tables not named here, such as cache version metadata, are kept. */ export type Cache = {
|
|
4
|
+
most: number;
|
|
5
|
+
tables: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
/** The bytes a cache and its SQLite WAL occupy, without the shared-memory
|
|
8
|
+
* index, whose size is unrelated to the bytes stored. */ export declare let held: (path: string) => Promise<number>;
|
|
9
|
+
/** Remove entries for missing local files through a cache's declared columns.
|
|
10
|
+
* Remote specifiers and unreadable local files stay cached. */ export declare let prune: (db: Driver, tables: Cache['tables'], gone?: (specifier: string) => boolean) => number;
|
|
11
|
+
/** Trim a cache over budget in place. Missing sources go first; if its live
|
|
12
|
+
* entries still exceed the budget, clear its rebuildable tables. The database
|
|
13
|
+
* and its WAL are never unlinked while it is readable, including while another
|
|
14
|
+
* connection uses it; a malformed one is removed for its owner to rebuild. A
|
|
15
|
+
* cache another connection holds busy waits for the next pass. Returns bytes
|
|
16
|
+
* reclaimed. A cache that does not exist is left absent. Its file checks and
|
|
17
|
+
* vacuum block the calling thread; {@link threaded} runs it on its own. */ export declare let trim: (path: string, cache: Cache) => Promise<number>;
|
|
18
|
+
/** What the trim thread answers. */ export type Trimmed = {
|
|
19
|
+
value: number;
|
|
20
|
+
} | {
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
/** {@link trim} on a thread of its own, so no disk stall holds the caller's. */ export declare let threaded: (path: string, cache: Cache) => Promise<number>;
|
|
24
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sources":["../cache.ts"],"names":[],"mappings":"AAQA,SAAc,KAAK,MAAM,yBAAoD;AAK7E;oEACoE,GACpE,YAAY;EAAU,MAAM,MAAM;EAAE,QAAQ,OAAO,MAAM,EAAE,MAAM;;AAEjE;uDACuD,GACvD,OAAO,YAAI,OAAc,MAAM,MAAM,KAAG,QAAQ,MAAM,EAUrD;AAaD;6DAC6D,GAC7D,OAAO,YAAI,QACT,IAAI,QACJ,QAAQ,MAAM,WACd,QAAO,WAAW,MAAM,KAAK,OAAO,KACnC,MAAM,CA0BR;AAyCD;;;;;;yEAMyE,GACzE,OAAO,YAAI,OAAc,MAAM,MAAM,EAAE,OAAO,UAAQ,QAAQ,MAAM,EAUnE;AAED,kCAAkC,GAClC,YAAY;EAAY,OAAO,MAAM;;EAAO,OAAO,MAAM;;AAEzD,8EAA8E,GAC9E,OAAO,YAAI,WAAY,MAAM,MAAM,EAAE,OAAO,UAAQ,QAAQ,MAAM,EAe9D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ArchetypeSet, type Driver } from "@yaks/sql/core";
|
|
2
|
+
/**
|
|
3
|
+
* A lazy, single-plan catalog snapshot. Value-only queries do not need it;
|
|
4
|
+
* the first component-presence or kind predicate loads it and all others share
|
|
5
|
+
* that snapshot.
|
|
6
|
+
* Create one per compile, not once per connection. Compile and execute inside
|
|
7
|
+
* the same transaction, so another writer cannot change the catalog between.
|
|
8
|
+
*/ export declare function catalog(driver: Driver, pending?: ReadonlyMap<number, readonly string[]> | (() => ReadonlyMap<number, readonly string[]>)): ArchetypeSet;
|
|
9
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sources":["../catalog.ts"],"names":[],"mappings":"AAUA,SAEE,KAAK,YAAY,EAGjB,KAAK,MAAM,8BAMqB;AA+IlC;;;;;;CAMC,GACD,OAAO,iBAAS,QACd,QAAQ,MAAM,EACd,UACI,YAAY,MAAM,WAAW,MAAM,aAC5B,YAAY,MAAM,WAAW,MAAM,IAAI,GACjD"}
|
package/_dist/check.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sources":["../check.ts"],"names":[],"mappings":"AA6BA,cAAc,OAAO,2BAAgC;AAErD,cAAc,MAAM,yBAA8B;AAQlD,4DAA4D,GAC5D,OAAO,YAAI,SAAU,QAAQ,eAmD3B"}
|
package/_dist/db.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Driver } from "@yaks/sql";
|
|
2
|
+
/** A database this process opened: its {@link Driver}, and the way to close
|
|
3
|
+
* it. */ export type Opened = Driver & {
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Open (or create) the database at `path` — a file, whose directory is made
|
|
8
|
+
* when missing, or `:memory:` — as a {@link Driver} to bind `storage()` to.
|
|
9
|
+
* This is the one place a connection's settings are made. `readOnly: true`
|
|
10
|
+
* requires an existing file and changes no journal settings. Extensions can
|
|
11
|
+
* read installed indexes; the read-only handle refuses metadata writes. A
|
|
12
|
+
* library that cannot load them (macOS's own) opens with no `extension`.
|
|
13
|
+
*
|
|
14
|
+
* Every connection runs with foreign keys on. A file is one other processes
|
|
15
|
+
* may have open too, so it also runs in WAL mode, with WAL's crash-safe pairing
|
|
16
|
+
* `synchronous = normal`, a 64 MiB WAL checkpointed on a thread of its own
|
|
17
|
+
* once it fills and cut back as it starts over (`wal` sets the size, for a test; `wal: false` keeps a
|
|
18
|
+
* rollback journal instead, for one file to copy elsewhere), a 64 MiB page cache, no
|
|
19
|
+
* checkpoint on close or commit, and a one-minute busy timeout, and a new file starts in incremental
|
|
20
|
+
* auto-vacuum mode, so the pages a delete frees can be given back (./owe.ts `reclaim`); a database in memory
|
|
21
|
+
* belongs to this process alone and needs none of that. A graph batch may be large, so contention gives
|
|
22
|
+
* the one writer that bounded minute to finish. A writer held longer is a
|
|
23
|
+
* performance failure, not a reason for every other process to wait forever.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { open } from '@yaks/sqlite/db'
|
|
27
|
+
*
|
|
28
|
+
* let sql = open(':memory:')
|
|
29
|
+
* sql.query({ t: 'create table', name: 't', cols: [{ name: 'x' }] })
|
|
30
|
+
* sql.close()
|
|
31
|
+
* ```
|
|
32
|
+
*/ export declare let open: (path: string, opts?: {
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
wal?: number | false;
|
|
35
|
+
}) => Opened;
|
|
36
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sources":["../db.ts"],"names":[],"mappings":"AAYA,SAAS,KAAK,MAAM,yBAAsC;AAM1D;OACO,GACP,YAAY,SAAS;EAAW,aAAa,IAAI;;AASjD;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,YAAI,OACT,MAAM,MAAM,EACZ;EAAQ,WAAW,OAAO;EAAE,MAAM,MAAM,GAAG,KAAK;MAC/C,OA6DF"}
|
package/_dist/ddl.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type Vocab } from "@yaks/vocab";
|
|
2
|
+
import { type CreateIndex, type CreateTable, type Derived, type Driver, type Stmt } from "@yaks/sql";
|
|
3
|
+
import { type Stood } from "./physical.js";
|
|
4
|
+
import type { Statistics } from "./meta.js";
|
|
5
|
+
export { META } from "./layout.js";
|
|
6
|
+
export declare let schema: (vocab: Vocab, derived?: Derived, file?: boolean) => Stmt[];
|
|
7
|
+
export declare let tabled: (vocab: Vocab, derived?: Derived, file?: boolean) => Stmt[];
|
|
8
|
+
/** {@link tabled} for a file that may already hold them: the doc view is
|
|
9
|
+
* dropped and made again only where the file's says something else. Making an
|
|
10
|
+
* identical view again still changes the schema, and every other connection
|
|
11
|
+
* to the file reads a changed schema as another install to answer. */ export declare let retabled: (driver: Driver, vocab: Vocab, derived?: Derived) => readonly Stmt[];
|
|
12
|
+
export declare let indexed: (vocab: Vocab, storage?: boolean) => readonly CreateIndex[];
|
|
13
|
+
/** The storage indexes an install builds over a file: every one of
|
|
14
|
+
* {@link indexed} but a {@link needless} one. An index owed before it became
|
|
15
|
+
* needless is forgotten where it is worked off (./owe.ts, ./maintenance.ts),
|
|
16
|
+
* since an install whose schema stands as it was never looks again. */ export declare let built: (driver: Driver, vocab: Vocab) => readonly CreateIndex[];
|
|
17
|
+
/** Retire vocabulary indexes whose declaration disappeared or changed. An
|
|
18
|
+
* index whose kept SQL is the one its declaration makes is as declared, and
|
|
19
|
+
* the engine is asked nothing about it. */ export declare let retired: (driver: Driver, vocab: Vocab) => Stmt[];
|
|
20
|
+
/**
|
|
21
|
+
* Which revision of fitting ({@link grown}, {@link refit}) brings a standing
|
|
22
|
+
* file to its vocabulary. What fitting changes it reads off the file, not off
|
|
23
|
+
* the vocabulary, so a fingerprint of the statements alone calls a file
|
|
24
|
+
* current that an older fitting left behind. This is part of every install's
|
|
25
|
+
* fingerprint instead, and moving it fits every store once more: move it when
|
|
26
|
+
* fitting learns to see something it did not.
|
|
27
|
+
*/ export declare let FIT: number;
|
|
28
|
+
/**
|
|
29
|
+
* What fitting reads off a file before an install creates anything: each
|
|
30
|
+
* table the vocabulary names that stood, and the spine. Only those can be
|
|
31
|
+
* behind the vocabulary, since a table the install creates is already the
|
|
32
|
+
* shape it says, so a fresh file is asked nothing.
|
|
33
|
+
*/ export type Standing = Record<string, Stood>;
|
|
34
|
+
/** Whether fitting asks a file about the table `name`. */ export declare let fitting: (vocab: Vocab) => any;
|
|
35
|
+
/** The {@link Standing} a file holds now, read through a driver that answers
|
|
36
|
+
* at once. */ export declare let standing: (driver: Driver, vocab: Vocab) => Standing;
|
|
37
|
+
/** Values that cannot resolve through the entity spine, one check per
|
|
38
|
+
* converted column, each answering an {@link Orphan} where one stands. A
|
|
39
|
+
* failed conversion must leave its old column untouched rather than turn a
|
|
40
|
+
* missing id into null. */ export declare let unresolved: (vocab: Vocab, was: Standing) => Record<string, Stmt[]>;
|
|
41
|
+
/** A row an {@link unresolved} check found: the property, the row's eid and
|
|
42
|
+
* the value in it that names no entity. */ export type Orphan = {
|
|
43
|
+
prop: string;
|
|
44
|
+
row: string | null;
|
|
45
|
+
value: unknown;
|
|
46
|
+
};
|
|
47
|
+
/** What a store says of a component whose reference column it could not
|
|
48
|
+
* convert ({@link unresolved}): the table is as it stood, and the refusal
|
|
49
|
+
* names the property, a row and the value, and the ways out. */ export declare let orphaned: (comp: string, {}: Orphan) => Error;
|
|
50
|
+
/**
|
|
51
|
+
* What rebuilding one table takes ({@link refit}): the table as its vocabulary
|
|
52
|
+
* says it, the columns it has, the ones carried over, and the reference
|
|
53
|
+
* columns whose stored form changes (an eid becoming the entity's integer id,
|
|
54
|
+
* or back), each read through the entity spine.
|
|
55
|
+
*/ export type Refitting = {
|
|
56
|
+
fresh: CreateTable;
|
|
57
|
+
old: string[];
|
|
58
|
+
cols: string[];
|
|
59
|
+
changed: Record<string, {
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The statements rebuilding each table {@link refitting} names, in one unit:
|
|
66
|
+
* its rows set aside as they are, the table made again as the vocabulary
|
|
67
|
+
* says, and the rows brought back. It is made under its own name rather than
|
|
68
|
+
* renamed into it, because a rename checks every view and trigger that names
|
|
69
|
+
* the table while it is gone (`doc_value` names `doc`). The table's triggers
|
|
70
|
+
* and undeclared indexes go with it, for whoever raised them to raise again at
|
|
71
|
+
* boot (@yaks/fts `adopt`); the declared indexes are {@link indexed}'s, which
|
|
72
|
+
* runs after. A table too big to rebuild in one unit is owed instead, and
|
|
73
|
+
* rebuilt beside itself in windows (./owe.ts).
|
|
74
|
+
*/ export declare let refit: (vocab: Vocab, was: Standing) => Record<string, Stmt[]>;
|
|
75
|
+
export declare let grown: (vocab: Vocab, was: Standing) => Stmt[];
|
|
76
|
+
/**
|
|
77
|
+
* The spine moved off a number unique on its own (./physical.ts `sole`), as
|
|
78
|
+
* every spine made before series had letters keeps it: there T-5 and M-5
|
|
79
|
+
* cannot both stand, so a store that numbers by series moves it as it
|
|
80
|
+
* installs. SQLite drops a column's `unique` only with its table, and
|
|
81
|
+
* dropping the spine with foreign keys on, as a Durable Object keeps them,
|
|
82
|
+
* deletes each row and checks every table naming it, and putting the rows
|
|
83
|
+
* back checks each again: a store's entities times the hundreds of
|
|
84
|
+
* references to them. So no row moves. The column holding the old constraint
|
|
85
|
+
* is renamed {@link RETIRED_NUM} and emptied, and a new `num` takes its
|
|
86
|
+
* numbers; an update of columns no reference names checks none. The spine's
|
|
87
|
+
* indexes and triggers name its number, so they are dropped first and its
|
|
88
|
+
* triggers raised again after. Its indexes are the install's to raise.
|
|
89
|
+
*/ export declare let respined: (driver: Driver) => Stmt[];
|
|
90
|
+
/** The spine rebuilt where it keeps a number unique on its own
|
|
91
|
+
* ({@link respined}), in a unit of its own: one the engine refused is left as
|
|
92
|
+
* it stood, and returned with the engine's reason. */ export declare let respine: (driver: Driver) => Error[];
|
|
93
|
+
/**
|
|
94
|
+
* Bring the tables that stood to the vocabulary, through a driver that answers
|
|
95
|
+
* at once: the columns they lack ({@link grown}), then a rebuild of each whose
|
|
96
|
+
* constraints moved ({@link refit}), in one unit. A table whose rows do not fit
|
|
97
|
+
* the shape the vocabulary now says (a value its enum no longer lists) is left
|
|
98
|
+
* exactly as it stood, and returned with the engine's reason: those rows need a
|
|
99
|
+
* migration that prepares them. Until one runs, the old constraint admits them,
|
|
100
|
+
* and admission holds every new write to the vocabulary. A table `owe` takes
|
|
101
|
+
* on is left for it to rebuild later.
|
|
102
|
+
*/ export declare let fit: (driver: Driver, vocab: Vocab, owe?: (comp: string, r: Refitting) => boolean) => Error[];
|
|
103
|
+
/** Where a store tells what it outlived when its caller names nowhere else:
|
|
104
|
+
* one line on the console. It is the state of the data, not a defect in the
|
|
105
|
+
* code, so a stack says nothing, and it repeats on every open until fixed. */ export declare let logged: (e: Error) => void;
|
|
106
|
+
/** What is reported of a table whose rebuild ({@link refit}) the engine
|
|
107
|
+
* refused, `e` being its refusal: the table is as it stood. */ export declare let unfit: (comp: string, e: unknown) => Error;
|
|
108
|
+
/**
|
|
109
|
+
* Keep the statistics the query planner reads this schema with.
|
|
110
|
+
*
|
|
111
|
+
* Every component table is keyed `entity integer primary key` and carries no
|
|
112
|
+
* secondary index, so without `sqlite_stat1` SQLite has nothing to size one by
|
|
113
|
+
* and falls back to its built-in guess of about a million rows for all of them.
|
|
114
|
+
* A query for "the entities that carry `call`" is then planned as a walk of
|
|
115
|
+
* the whole spine probing `call` per row, instead of a scan of the fifty
|
|
116
|
+
* thousand `call` rows — which is how opening an imported graph came to read
|
|
117
|
+
* the archive end to end six times before answering (T-37734).
|
|
118
|
+
*
|
|
119
|
+
* Installation analyzes nothing: it answers the receipt of which tables are
|
|
120
|
+
* owed an analysis ({@link owing}), and {@link analyzing} works them off a
|
|
121
|
+
* table at a time, away from the install that owed them (./owe.ts `work` on a
|
|
122
|
+
* file, a Durable Object's alarm), since one `ANALYZE` holds the write lock
|
|
123
|
+
* while it reads its table. A file's analysis is sampled ({@link SAMPLE}),
|
|
124
|
+
* and a table of its with no index is counted a window at a time in a
|
|
125
|
+
* snapshot, holding no lock ({@link counted});
|
|
126
|
+
* a full-analysis engine (a Durable Object's, which refuses `analysis_limit`)
|
|
127
|
+
* provides its stored bytes without scanning rows. An unchanged store below
|
|
128
|
+
* tenfold byte growth bills no rows for statistics, including after a
|
|
129
|
+
* connection restart. A table empty at its last analysis that holds rows now
|
|
130
|
+
* is owed, and so, after a schema change, is a populated table or index
|
|
131
|
+
* without statistics. Existing complete statistics are adopted once by
|
|
132
|
+
* installations predating receipts. A table holding at most one row is never
|
|
133
|
+
* analyzed: it is remembered as empty and checked with a count of two rows at
|
|
134
|
+
* most. Each whose statistics say it holds fewer than {@link SMALL} rows is
|
|
135
|
+
* checked for twice as many ({@link small}).
|
|
136
|
+
*
|
|
137
|
+
* Optimize decides none of it: empty tables get no stat1 row, so it names
|
|
138
|
+
* them on every run, and it names as often a table whose row count it guesses
|
|
139
|
+
* wrong from one page, such as one of variable-sized rows, which `ANALYZE`
|
|
140
|
+
* then counts end to end under the write lock. Only a database in memory,
|
|
141
|
+
* which nobody else writes, still optimizes at once.
|
|
142
|
+
*/ export declare let analyzed: (driver: Driver, previous?: Statistics, unchanged?: boolean) => Statistics | undefined;
|
|
143
|
+
//# sourceMappingURL=ddl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl.d.ts","sources":["../ddl.ts"],"names":[],"mappings":"AA6CA,SAA2C,KAAK,KAAK,2BAAgC;AAErF,SAOE,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,OAAO,EACZ,KAAK,MAAM,EAgBX,KAAK,IAAI,yBAIkB;AAC7B,SAME,KAAK,KAAK,wBAEU;AAYtB,cAAwB,UAAU,oBAAmB;AAErD,SAAS,IAAI,sBAA6B;AA+O1C,OAAO,YAAI,SACT,OAAO,OACP,UAAS,SACT,mBACC,OAIF;AAID,OAAO,YAAI,SACT,OAAO,OACP,UAAS,SACT,mBACC,OAKF;AAuDD;;;oEAGoE,GACpE,OAAO,YAAI,WACT,QAAQ,QACR,OAAO,OACP,UAAS,qBACC,OAsBX;AAQD,OAAO,YAAI,UACT,OAAO,OACP,+BACU,cAUX;AAsCD;;;qEAGqE,GACrE,OAAO,YAAI,QAAS,QAAQ,QAAQ,OAAO,mBAAiB,cACF;AAqD1D;;yCAEyC,GACzC,OAAO,YAAI,UAAW,QAAQ,QAAQ,OAAO,UAAQ,OAsBpD;AAED;;;;;;;CAOC,GACD,OAAO,YAAI,YAAQ;AAEnB;;;;;CAKC,GACD,YAAY,WAAW,OAAO,MAAM,EAAE;AAEtC,wDAAwD,GACxD,OAAO,YAAI,UAAW,OAAO,cACqB;AAElD;YACY,GACZ,OAAO,YAAI,WAAY,QAAQ,QAAQ,OAAO,UAAQ,SACvB;AA0H/B;;;yBAGyB,GACzB,OAAO,YAAI,aACT,OAAO,OACP,KAAK,aACJ,OAAO,MAAM,EAAE,QAiCf;AAEH;yCACyC,GACzC,YAAY;EAAW,MAAM,MAAM;EAAE,KAAK,MAAM,GAAG,IAAI;EAAE,OAAO,OAAO;;AAGvE;;8DAE8D,GAC9D,OAAO,YAAI,WAAY,MAAM,MAAM,EAAE,IAAsB,MAAM,KAAG,MASjE;AAEH;;;;;CAKC,GACD,YAAY;EACV,OAAO;EACP,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,SAAS,OAAO,MAAM;IAAI,MAAM,MAAM;IAAE,IAAI,MAAM;;;AAwDpD;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QACT,OAAO,OACP,KAAK,aACJ,OAAO,MAAM,EAAE,QAmCf;AAaH,OAAO,YAAI,QAAS,OAAO,OAAO,KAAK,aAAW,OAgBjD;AA0CD;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,WAAY,QAAQ,WAAS,OA+BvC;AAED;;oDAEoD,GACpD,OAAO,YAAI,UAAW,QAAQ,WAAS,QAStC;AAED;;;;;;;;;CASC,GACD,OAAO,YAAI,MACT,QAAQ,QACR,OAAO,OACP,OAAM,MAAM,MAAM,EAAE,GAAG,cAAc,OAAO,KAC3C,QAsBC;AAEJ;;4EAE4E,GAC5E,OAAO,YAAI,SAAU,GAAG,UAAQ,IAAI,CACS;AAE7C;6DAC6D,GAC7D,OAAO,YAAI,QAAS,MAAM,MAAM,EAAE,GAAG,OAAO,KAAG,MAK5C;AAcH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GACD,OAAO,YAAI,WACT,QAAQ,QACR,WAAW,YACX,wBACC,aAAa,SAAS,CAQxB"}
|
package/_dist/doom.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Vocab } from "@yaks/vocab";
|
|
2
|
+
import type { Doom } from "@yaks/graph";
|
|
3
|
+
import { type Driver, type Lacks } from "@yaks/sql";
|
|
4
|
+
/**
|
|
5
|
+
* The whole death cascade, computed by one statement rather than walked:
|
|
6
|
+
* everything that dies with these entities, and every soft reference that has
|
|
7
|
+
* to let go of them (@yaks/sql's `doomSql`/`looseSql`). @yaks/graph would
|
|
8
|
+
* otherwise read once per rung of the chain — free here, a round trip each over
|
|
9
|
+
* a network — and that walk is what an adapter unable to compile this still
|
|
10
|
+
* gets.
|
|
11
|
+
*
|
|
12
|
+
* Each statement fits the engine's compound SELECT and CTE cursor limits.
|
|
13
|
+
* A vocabulary too wide for one statement (@yaks/sql `narrow`) is
|
|
14
|
+
* queried in rounds: each statement is transitive within its own tables, so
|
|
15
|
+
* the result is complete when a round turns up nothing the last one had not.
|
|
16
|
+
*
|
|
17
|
+
* Asked inside the transaction, after the batch's patches have gone in, which
|
|
18
|
+
* is what makes the result the one the cascade wants: who points at the dying
|
|
19
|
+
* as the batch leaves the graph. `lacks` is what the file does not hold yet of
|
|
20
|
+
* the vocabulary's schema (./survey.ts), which the statements do not name.
|
|
21
|
+
*/ export declare let doom: (driver: Driver, vocab: Vocab, eids: string[], lacks?: Lacks) => Doom;
|
|
22
|
+
//# sourceMappingURL=doom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doom.d.ts","sources":["../doom.ts"],"names":[],"mappings":"AACA,cAAc,KAAK,2BAAgC;AACnD,cAAc,IAAI,2BAAsC;AACxD,SAIE,KAAK,MAAM,EACX,KAAK,KAAK,yBAKiB;AAE7B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,OACT,QAAQ,QACR,OAAO,OACP,MAAM,MAAM,IACZ,QAAO,UACN,KAoCF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type Driver, type SchemaObject, type Stmt } from "@yaks/sql/core";
|
|
2
|
+
import { type Derived } from "@yaks/sql";
|
|
3
|
+
import type { Vocab } from "@yaks/vocab";
|
|
4
|
+
/** The print of a composed schema: a store's own print (`Store.print`) and
|
|
5
|
+
* every further statement the file needs, rendered. */ export declare let printOf: (store: string, stmts: Stmt[]) => string;
|
|
6
|
+
/** What `Store.print` says, known from the vocabulary alone: for a host that
|
|
7
|
+
* composes its print before it binds the store it will open with it, the way
|
|
8
|
+
* a yaks.app store keeps one print per vocabulary it has seen. */ export declare let printFor: (vocab: Vocab, derived?: Derived, file?: boolean) => string;
|
|
9
|
+
/** {@link printFor}, digested by the platform: a host that can wait before it
|
|
10
|
+
* binds the store it opens asks this first, and the store finds its print
|
|
11
|
+
* made rather than digesting a hundred kilobytes of statements in script. */ export declare let printing: (vocab: Vocab, derived?: Derived, file?: boolean) => Promise<string>;
|
|
12
|
+
/** The `add column` statements the tables `stmts` create are missing where
|
|
13
|
+
* they already stand: `create table if not exists` does nothing to a table
|
|
14
|
+
* that is there, so a column a table gained after it was made arrives here.
|
|
15
|
+
* `held` is the schema as it stood before `stmts` ran (`catalogue`): a table
|
|
16
|
+
* it lacks was made whole by the first statement naming it, and one it holds
|
|
17
|
+
* as a statement declares it has every column, so neither is asked about. */ export declare let grow: (driver: Driver, stmts: Stmt[], held?: readonly SchemaObject[]) => Stmt[];
|
|
18
|
+
/** Run `stmts`, each of which only adds what is missing, then the columns
|
|
19
|
+
* their standing tables lack, in one unit under the write lock. An index over
|
|
20
|
+
* a populated table is owed rather than built, and a unique index the rows
|
|
21
|
+
* already there break is left unbuilt and returned for the caller to report
|
|
22
|
+
* (./owe.ts). */ export declare let add: (driver: Driver, stmts: Stmt[]) => Error[];
|
|
23
|
+
/** What a composed schema names, for {@link follow} to shed what a file holds
|
|
24
|
+
* beyond it: the tables and columns the store of `vocab` makes, and the tables
|
|
25
|
+
* `beside` makes. */ export type Named = {
|
|
26
|
+
vocab: Vocab;
|
|
27
|
+
beside?: readonly Stmt[];
|
|
28
|
+
};
|
|
29
|
+
/** A component's table, or a table and one of its columns. */ export type Seat = readonly [table: string, column?: string];
|
|
30
|
+
/** Drop each of `seats` the file holds, a component's table or a column,
|
|
31
|
+
* whatever it holds, in one unit: for a host contracting what its words
|
|
32
|
+
* decided to let go of. Each view and trigger naming a table goes with it,
|
|
33
|
+
* and each index, trigger and view naming a column, which SQLite refuses the
|
|
34
|
+
* drop for while they stand; the next pass (`install`) makes again what the
|
|
35
|
+
* schema still wants of those. */ export declare let unseat: (driver: Driver, seats: readonly Seat[]) => void;
|
|
36
|
+
/** The drops of what a file holds that `named` stopped naming ({@link
|
|
37
|
+
* unseat}): a component table (./physical.ts `componentTables`) no statement
|
|
38
|
+
* makes and no word names, once it holds no rows, and a column the statement
|
|
39
|
+
* making its table lacks, once no row holds a value in it. A table that holds
|
|
40
|
+
* a row, a column that holds a value, and a column its table's own definition
|
|
41
|
+
* holds in place (./physical.ts `pinned`) stay as they stand. */ export declare let shed: (driver: Driver, {}: Named) => Seat[];
|
|
42
|
+
/** Bring a file to the composed schema `print` names: nothing, where the file
|
|
43
|
+
* has recorded it; otherwise `pass`, which adds what is missing, and then the
|
|
44
|
+
* record. A pass that left something it could not do (a table it could not
|
|
45
|
+
* fit) answers false, and the print stays unrecorded so the next opener tries
|
|
46
|
+
* again. True when the pass ran.
|
|
47
|
+
*
|
|
48
|
+
* Given what the schema names, the pass first sheds what the file holds
|
|
49
|
+
* beyond it ({@link shed}), which the pass makes again where the schema still
|
|
50
|
+
* wants it (a view or a trigger that named a column shed with it). What SQLite
|
|
51
|
+
* refuses to drop stands, and the pass runs over it. A file
|
|
52
|
+
* that shed something no longer stands at any other print it recorded, so
|
|
53
|
+
* those are forgotten: an opener of the vocabulary that named it runs its pass
|
|
54
|
+
* again. A host whose vocabulary may shrink for a while and grow back (an
|
|
55
|
+
* application's older release, a rollback away) gives nothing, and the file
|
|
56
|
+
* keeps all it holds. */ export declare let follow: (driver: Driver, print: string, pass: () => boolean | void, named?: Named) => boolean;
|
|
57
|
+
/** Forget that a file stands at `print`, so its next opener runs the pass
|
|
58
|
+
* again: for a host whose file something that keeps no print may have changed,
|
|
59
|
+
* the way a yaks.app store's older release, still a rollback away, installs
|
|
60
|
+
* over whatever a print stands for. The store's own install receipt is
|
|
61
|
+
* forgotten with it, so that install looks at the file again too. */ export declare let forget: (driver: Driver, print: string) => void;
|
|
62
|
+
/**
|
|
63
|
+
* What a reader binds over a file no writer has brought to its vocabulary yet:
|
|
64
|
+
* each stored property whose column the file's table lacks, read as null, the
|
|
65
|
+
* way an entity reads a property it was never given, and each component whose
|
|
66
|
+
* table the file lacks, read as a table no entity wears (@yaks/sql
|
|
67
|
+
* `absent`). A reader never changes the schema, so it reads what the file
|
|
68
|
+
* holds. Nothing, where the store's tables are as this vocabulary makes them,
|
|
69
|
+
* which costs the store's print and one read of `server_meta`.
|
|
70
|
+
*/ export declare let lacking: (driver: Driver, vocab: Vocab, derived?: Derived, physical?: boolean) => {
|
|
71
|
+
derived: Derived;
|
|
72
|
+
absent: string[];
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=follow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.d.ts","sources":["../follow.ts"],"names":[],"mappings":"AAgBA,SAGE,KAAK,MAAM,EAEX,KAAK,YAAY,EACjB,KAAK,IAAI,8BAEuB;AAClC,SAEE,KAAK,OAAO,yBAMe;AAC7B,cAAc,KAAK,2BAAgC;AA0BnD;qDACqD,GACrD,OAAO,YAAI,UAAW,OAAO,MAAM,EAAE,OAAO,WAAS,MAAM,CACM;AAEjE;;gEAEgE,GAChE,OAAO,YAAI,WACT,OAAO,OACP,UAAS,SACT,mBACC,MAAM,CAAoC;AAE7C;;2EAE2E,GAC3E,OAAO,YAAI,WACT,OAAO,OACP,UAAS,SACT,mBACC,QAAQ,MAAM,EAAuD;AAiBxE;;;;;2EAK2E,GAC3E,OAAO,YAAI,OACT,QAAQ,QACR,OAAO,QACP,gBAAe,mBACd,OAqBF;AAED;;;;eAIe,GACf,OAAO,YAAI,MAAO,QAAQ,QAAQ,OAAO,WAAS,QAM9C;AAEJ;;mBAEmB,GACnB,YAAY;EAAU,OAAO;EAAO,kBAAkB;;AAatD,4DAA4D,GAC5D,YAAY,iBAAiB,OAAO,MAAM,EAAE,SAAS,MAAM;AAiF3D;;;;;gCAKgC,GAChC,OAAO,YAAI,SAAU,QAAQ,QAAQ,gBAAgB,WAAS,IAAI,CAUjE;AAED;;;;;+DAK+D,GAC/D,OAAO,YAAI,OAAQ,QAAQ,QAAQ,IAAwB,KAAK,KAAG,OA0BlE;AAcD;;;;;;;;;;;;;;uBAcuB,GACvB,OAAO,YAAI,SACT,QAAQ,QACR,OAAO,MAAM,EACb,YAAY,OAAO,GAAG,IAAI,EAC1B,QAAQ,UACP,OAAO,CAeT;AAED;;;;mEAImE,GACnE,OAAO,YAAI,SAAU,QAAQ,QAAQ,OAAO,MAAM,KAAG,IAAI,CAMxD;AAED;;;;;;;;CAQC,GACD,OAAO,YAAI,UACT,QAAQ,QACR,OAAO,OACP,UAAS,SACT;EACG,SAAS;EAAS,QAAQ,MAAM;EA8BpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-shapes.d.ts","sources":["../history-shapes.ts"],"names":[],"mappings":"AAiCA,OAAO,YAAI,cAAgB,YAAY,eAAwC;AAC/E,OAAO,YAAI,SAAU,MAAM,MAAM,KAAG,MAAM,CAAsB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Driver, type Stmt } from "@yaks/sql";
|
|
2
|
+
import type { Vocab } from "@yaks/vocab";
|
|
3
|
+
export { beside, BRANCH, FROM, TO } from "./history-shapes.js";
|
|
4
|
+
export type { History } from "@yaks/sql";
|
|
5
|
+
export type { Mode } from "@yaks/sql";
|
|
6
|
+
/** The table of branches. */ export declare let BRANCHES: string;
|
|
7
|
+
/** Whether main keeps a component's versions: every component table but those
|
|
8
|
+
* declared `journal: false`. */ export declare let keeps: (vocab: Vocab, comp: string) => boolean;
|
|
9
|
+
/** A column's declared type as its live table holds it, where it stands. */ export type Typed = (comp: string, column: string) => string | undefined;
|
|
10
|
+
/** Everything a store with history needs beside its own schema: the tables of
|
|
11
|
+
* versions, typed as `typed` says the live ones stand, and the branch table.
|
|
12
|
+
* The live tables are not restated: history changes none of them. */ export declare let historySchema: (vocab: Vocab, typed?: Typed) => Stmt[];
|
|
13
|
+
/** The key of what a store whose history began paced (`Opts.paced`) still
|
|
14
|
+
* owes, in `server_meta`: the components whose live rows are not yet their
|
|
15
|
+
* first versions, oldest first, and the last entity taken of the first. */ export declare let SEEDING: string;
|
|
16
|
+
/** The id this driver's innermost unit's versions name, where it has taken
|
|
17
|
+
* one: what the history plugin writes its transaction row as. */ export declare let ticked: (driver: Driver) => number | undefined;
|
|
18
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sources":["../history.ts"],"names":[],"mappings":"AAiCA,SAOE,KAAK,MAAM,EAkBX,KAAK,IAAI,yBAKkB;AAC7B,cAAc,KAAK,2BAAgC;AAgBnD,SAAiB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,8BAA6B;AAEtE,cAAc,OAAO,yBAA8B;AAEnD,cAAc,IAAI,yBAA8B;AAEhD,2BAA2B,GAC3B,OAAO,YAAI,iBAAoB;AAK/B;8BAC8B,GAC9B,OAAO,YAAI,QAAS,OAAO,OAAO,MAAM,MAAM,KAAG,OAAO,CACE;AA4B1D,0EAA0E,GAC1E,YAAY,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,GAAG,SAAS;AA6ExE;;mEAEmE,GACnE,OAAO,YAAI,gBAAiB,OAAO,OAAO,QAAQ,UAAQ,OAazD;AA6BD;;yEAEyE,GACzE,OAAO,YAAI,gBAA2B;AA8KtC;+DAC+D,GAC/D,OAAO,YAAI,SAAU,QAAQ,WAAS,MAAM,GAAG,SAAS,CACjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Driver } from "@yaks/sql";
|
|
2
|
+
export type DeletionWindow = {
|
|
3
|
+
since: string;
|
|
4
|
+
until: string;
|
|
5
|
+
after?: number;
|
|
6
|
+
/** name each grave in the window, its eid and when it was laid */ eids?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type Deletions = {
|
|
9
|
+
scanned: number;
|
|
10
|
+
count: number;
|
|
11
|
+
minutes: Record<string, number>;
|
|
12
|
+
next: number | null;
|
|
13
|
+
graves?: {
|
|
14
|
+
eid: string;
|
|
15
|
+
at: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
/** Count deletions in [since, until), reading at most 1,000 graves from the
|
|
19
|
+
* primary key. Continue with `next` until null; timestamps need no new index.
|
|
20
|
+
* With `eids`, each grave in the window is named too. */ export declare let deletions: (db: Driver, window: DeletionWindow) => Deletions;
|
|
21
|
+
export type TableSize = {
|
|
22
|
+
name: string;
|
|
23
|
+
/** Exact live owners for components, unknown for physical infrastructure. */ rows: number | null;
|
|
24
|
+
indexCount: number;
|
|
25
|
+
indexes: string[];
|
|
26
|
+
};
|
|
27
|
+
export type StoreSize = {
|
|
28
|
+
tables: number;
|
|
29
|
+
shown: TableSize[];
|
|
30
|
+
omitted: number;
|
|
31
|
+
};
|
|
32
|
+
/** The ordinary tables and indexes the file holds, including tables no
|
|
33
|
+
* longer named by the current vocabulary. Counting is capped so a diagnostic
|
|
34
|
+
* remains bounded even after a store has seen many schemas. */ export declare let inspect: (db: Driver, limit?: number, preferred?: readonly string[]) => StoreSize;
|
|
35
|
+
export type Identity = {
|
|
36
|
+
eid: string;
|
|
37
|
+
exists: boolean;
|
|
38
|
+
tombstoned: boolean;
|
|
39
|
+
tables: string[];
|
|
40
|
+
omitted: number;
|
|
41
|
+
};
|
|
42
|
+
/** Identity and its archetype table set, never component values. */ export declare let identity: (db: Driver, eid: string) => Identity;
|
|
43
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sources":["../inspect.ts"],"names":[],"mappings":"AAOA,SAGE,KAAK,MAAM,yBAOgB;AAE7B,YAAY;EACV,OAAO,MAAM;EACb,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,gEAAgE,GAChE,OAAO,OAAO;;AAEhB,YAAY;EACV,SAAS,MAAM;EACf,OAAO,MAAM;EACb,SAAS,OAAO,MAAM,EAAE,MAAM;EAC9B,MAAM,MAAM,GAAG,IAAI;EACnB;IAAW,KAAK,MAAM;IAAE,IAAI,MAAM;;;AAGpC;;uDAEuD,GACvD,OAAO,YAAI,YAAa,IAAI,QAAQ,QAAQ,mBAAiB,UA+C5D;AAED,YAAY;EACV,MAAM,MAAM;EACZ,2EAA2E,GAC3E,MAAM,MAAM,GAAG,IAAI;EACnB,YAAY,MAAM;EAClB,SAAS,MAAM;;AAGjB,YAAY;EACV,QAAQ,MAAM;EACd,OAAO;EACP,SAAS,MAAM;;AAGjB;;6DAE6D,GAC7D,OAAO,YAAI,UACT,IAAI,QACJ,gBACA,qBAAoB,MAAM,OACzB,UA0BF;AAED,YAAY;EACV,KAAK,MAAM;EACX,QAAQ,OAAO;EACf,YAAY,OAAO;EACnB,QAAQ,MAAM;EACd,SAAS,MAAM;;AAGjB,kEAAkE,GAClE,OAAO,YAAI,WAAY,IAAI,QAAQ,KAAK,MAAM,KAAG,SAmBhD"}
|
package/_dist/jsonb.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { And } from "@yaks/query";
|
|
2
|
+
import type { Vocab } from "@yaks/vocab";
|
|
3
|
+
import { type Expr, type Param } from "@yaks/sql/core";
|
|
4
|
+
/** Whether `comp.prop` holds a JSON value. */ export declare let isJsonb: (v: Vocab, comp: string, prop: string) => boolean;
|
|
5
|
+
/** A JSON value as the parameter `jsonb(?)` binds; null clears the column. */ export declare let jsonIn: (value: unknown) => Param;
|
|
6
|
+
/** A stored JSON value read back as its JSON text. */ export declare let jsonOut: (e: Expr) => Expr;
|
|
7
|
+
/** A component row as read: absent SQL columns are omitted, each JSON column
|
|
8
|
+
* is parsed back into its value, and booleans read as `true`/`false`. A null
|
|
9
|
+
* patch clears a property; it is not a stored property value. */ export declare let decoded: <R extends Record<string, unknown>>(v: Vocab, comp: string, row: R) => R;
|
|
10
|
+
/** A row of a query's raw answer, each `.fields` projection read as
|
|
11
|
+
* {@link decoded} reads it in a component. A projected column is named by its
|
|
12
|
+
* path (`comp.prop`, or one through references, `review.book.book.price`),
|
|
13
|
+
* and read as the property it ends on. A `.distinct` or `.tally` row's `value`
|
|
14
|
+
* is read as the property the query counts (`counted`, a boolean as
|
|
15
|
+
* `true`/`false`); the rest of the row (`eid`, `n`) is left as the statement
|
|
16
|
+
* returned it. */ export declare let projected: <R extends Record<string, unknown>>(v: Vocab, row: R, counted?: And) => R;
|
|
17
|
+
//# sourceMappingURL=jsonb.d.ts.map
|