@minnowdb/core 0.0.1 → 0.1.0
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 +21 -0
- package/README.md +27 -1
- package/dist/block-format/block.d.ts +46 -0
- package/dist/block-format/block.d.ts.map +1 -0
- package/dist/block-format/block.js +244 -0
- package/dist/block-format/block.js.map +1 -0
- package/dist/block-format/checksum.d.ts +7 -0
- package/dist/block-format/checksum.d.ts.map +1 -0
- package/dist/block-format/checksum.js +56 -0
- package/dist/block-format/checksum.js.map +1 -0
- package/dist/block-format/codecs.d.ts +24 -0
- package/dist/block-format/codecs.d.ts.map +1 -0
- package/dist/block-format/codecs.js +102 -0
- package/dist/block-format/codecs.js.map +1 -0
- package/dist/block-format/column.d.ts +8 -0
- package/dist/block-format/column.d.ts.map +1 -0
- package/dist/block-format/column.js +166 -0
- package/dist/block-format/column.js.map +1 -0
- package/dist/block-format/index.d.ts +7 -0
- package/dist/block-format/index.d.ts.map +1 -0
- package/dist/block-format/index.js +7 -0
- package/dist/block-format/index.js.map +1 -0
- package/dist/block-format/physical.d.ts +20 -0
- package/dist/block-format/physical.d.ts.map +1 -0
- package/dist/block-format/physical.js +439 -0
- package/dist/block-format/physical.js.map +1 -0
- package/dist/block-format/types.d.ts +93 -0
- package/dist/block-format/types.d.ts.map +1 -0
- package/dist/block-format/types.js +2 -0
- package/dist/block-format/types.js.map +1 -0
- package/dist/engine/artifact-cache.d.ts +22 -0
- package/dist/engine/artifact-cache.d.ts.map +1 -0
- package/dist/engine/artifact-cache.js +68 -0
- package/dist/engine/artifact-cache.js.map +1 -0
- package/dist/engine/batch.d.ts +28 -0
- package/dist/engine/batch.d.ts.map +1 -0
- package/dist/engine/batch.js +38 -0
- package/dist/engine/batch.js.map +1 -0
- package/dist/engine/buffered-writer.d.ts +43 -0
- package/dist/engine/buffered-writer.d.ts.map +1 -0
- package/dist/engine/buffered-writer.js +158 -0
- package/dist/engine/buffered-writer.js.map +1 -0
- package/dist/engine/catalog.d.ts +82 -0
- package/dist/engine/catalog.d.ts.map +1 -0
- package/dist/engine/catalog.js +47 -0
- package/dist/engine/catalog.js.map +1 -0
- package/dist/engine/client.d.ts +211 -0
- package/dist/engine/client.d.ts.map +1 -0
- package/dist/engine/client.js +538 -0
- package/dist/engine/client.js.map +1 -0
- package/dist/engine/coordinator.d.ts +17 -0
- package/dist/engine/coordinator.d.ts.map +1 -0
- package/dist/engine/coordinator.js +60 -0
- package/dist/engine/coordinator.js.map +1 -0
- package/dist/engine/database.d.ts +661 -0
- package/dist/engine/database.d.ts.map +1 -0
- package/dist/engine/database.js +10313 -0
- package/dist/engine/database.js.map +1 -0
- package/dist/engine/defaults.d.ts +33 -0
- package/dist/engine/defaults.d.ts.map +1 -0
- package/dist/engine/defaults.js +87 -0
- package/dist/engine/defaults.js.map +1 -0
- package/dist/engine/dsl/db.d.ts +137 -0
- package/dist/engine/dsl/db.d.ts.map +1 -0
- package/dist/engine/dsl/db.js +161 -0
- package/dist/engine/dsl/db.js.map +1 -0
- package/dist/engine/dsl/expression.d.ts +172 -0
- package/dist/engine/dsl/expression.d.ts.map +1 -0
- package/dist/engine/dsl/expression.js +397 -0
- package/dist/engine/dsl/expression.js.map +1 -0
- package/dist/engine/dsl/index.d.ts +8 -0
- package/dist/engine/dsl/index.d.ts.map +1 -0
- package/dist/engine/dsl/index.js +7 -0
- package/dist/engine/dsl/index.js.map +1 -0
- package/dist/engine/dsl/live-query.d.ts +45 -0
- package/dist/engine/dsl/live-query.d.ts.map +1 -0
- package/dist/engine/dsl/live-query.js +116 -0
- package/dist/engine/dsl/live-query.js.map +1 -0
- package/dist/engine/dsl/mutations.d.ts +123 -0
- package/dist/engine/dsl/mutations.d.ts.map +1 -0
- package/dist/engine/dsl/mutations.js +241 -0
- package/dist/engine/dsl/mutations.js.map +1 -0
- package/dist/engine/dsl/select-query-builder.d.ts +148 -0
- package/dist/engine/dsl/select-query-builder.d.ts.map +1 -0
- package/dist/engine/dsl/select-query-builder.js +377 -0
- package/dist/engine/dsl/select-query-builder.js.map +1 -0
- package/dist/engine/dsl/sql-tag.d.ts +46 -0
- package/dist/engine/dsl/sql-tag.d.ts.map +1 -0
- package/dist/engine/dsl/sql-tag.js +85 -0
- package/dist/engine/dsl/sql-tag.js.map +1 -0
- package/dist/engine/dsl/types.d.ts +133 -0
- package/dist/engine/dsl/types.d.ts.map +1 -0
- package/dist/engine/dsl/types.js +9 -0
- package/dist/engine/dsl/types.js.map +1 -0
- package/dist/engine/errors.d.ts +55 -0
- package/dist/engine/errors.d.ts.map +1 -0
- package/dist/engine/errors.js +81 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/fts.d.ts +93 -0
- package/dist/engine/fts.d.ts.map +1 -0
- package/dist/engine/fts.js +273 -0
- package/dist/engine/fts.js.map +1 -0
- package/dist/engine/group-index.d.ts +32 -0
- package/dist/engine/group-index.d.ts.map +1 -0
- package/dist/engine/group-index.js +366 -0
- package/dist/engine/group-index.js.map +1 -0
- package/dist/engine/index.d.ts +13 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +12 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/join-index.d.ts +12 -0
- package/dist/engine/join-index.d.ts.map +1 -0
- package/dist/engine/join-index.js +217 -0
- package/dist/engine/join-index.js.map +1 -0
- package/dist/engine/live.d.ts +86 -0
- package/dist/engine/live.d.ts.map +1 -0
- package/dist/engine/live.js +289 -0
- package/dist/engine/live.js.map +1 -0
- package/dist/engine/memory.d.ts +37 -0
- package/dist/engine/memory.d.ts.map +1 -0
- package/dist/engine/memory.js +119 -0
- package/dist/engine/memory.js.map +1 -0
- package/dist/engine/optimizer.d.ts +20 -0
- package/dist/engine/optimizer.d.ts.map +1 -0
- package/dist/engine/optimizer.js +1170 -0
- package/dist/engine/optimizer.js.map +1 -0
- package/dist/engine/query-cache.d.ts +10 -0
- package/dist/engine/query-cache.d.ts.map +1 -0
- package/dist/engine/query-cache.js +58 -0
- package/dist/engine/query-cache.js.map +1 -0
- package/dist/engine/query.d.ts +844 -0
- package/dist/engine/query.d.ts.map +1 -0
- package/dist/engine/query.js +7450 -0
- package/dist/engine/query.js.map +1 -0
- package/dist/engine/schema-wire.d.ts +92 -0
- package/dist/engine/schema-wire.d.ts.map +1 -0
- package/dist/engine/schema-wire.js +115 -0
- package/dist/engine/schema-wire.js.map +1 -0
- package/dist/engine/schema.d.ts +394 -0
- package/dist/engine/schema.d.ts.map +1 -0
- package/dist/engine/schema.js +709 -0
- package/dist/engine/schema.js.map +1 -0
- package/dist/engine/sort-keys.d.ts +36 -0
- package/dist/engine/sort-keys.d.ts.map +1 -0
- package/dist/engine/sort-keys.js +60 -0
- package/dist/engine/sort-keys.js.map +1 -0
- package/dist/engine/sql-json.d.ts +30 -0
- package/dist/engine/sql-json.d.ts.map +1 -0
- package/dist/engine/sql-json.js +120 -0
- package/dist/engine/sql-json.js.map +1 -0
- package/dist/engine/sql-semantics.d.ts +31 -0
- package/dist/engine/sql-semantics.d.ts.map +1 -0
- package/dist/engine/sql-semantics.js +121 -0
- package/dist/engine/sql-semantics.js.map +1 -0
- package/dist/engine/vector.d.ts +87 -0
- package/dist/engine/vector.d.ts.map +1 -0
- package/dist/engine/vector.js +4227 -0
- package/dist/engine/vector.js.map +1 -0
- package/dist/engine/worker-host.d.ts +48 -0
- package/dist/engine/worker-host.d.ts.map +1 -0
- package/dist/engine/worker-host.js +501 -0
- package/dist/engine/worker-host.js.map +1 -0
- package/dist/engine/worker.d.ts +2 -0
- package/dist/engine/worker.d.ts.map +1 -0
- package/dist/engine/worker.js +14 -0
- package/dist/engine/worker.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/plan/index.d.ts +17 -0
- package/dist/plan/index.d.ts.map +1 -0
- package/dist/plan/index.js +17 -0
- package/dist/plan/index.js.map +1 -0
- package/dist/storage/fixture-shape.d.ts +42 -0
- package/dist/storage/fixture-shape.d.ts.map +1 -0
- package/dist/storage/fixture-shape.js +146 -0
- package/dist/storage/fixture-shape.js.map +1 -0
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/indexeddb.d.ts +139 -0
- package/dist/storage/indexeddb.d.ts.map +1 -0
- package/dist/storage/indexeddb.js +3161 -0
- package/dist/storage/indexeddb.js.map +1 -0
- package/dist/storage/memory.d.ts +121 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +1455 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/storage/snapshot.d.ts +108 -0
- package/dist/storage/snapshot.d.ts.map +1 -0
- package/dist/storage/snapshot.js +276 -0
- package/dist/storage/snapshot.js.map +1 -0
- package/dist/storage/types.d.ts +895 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +1549 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/testing/index.d.ts +76 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +233 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/seeds.d.ts +11 -0
- package/dist/testing/seeds.d.ts.map +1 -0
- package/dist/testing/seeds.js +50 -0
- package/dist/testing/seeds.js.map +1 -0
- package/dist/transactions/index.d.ts +148 -0
- package/dist/transactions/index.d.ts.map +1 -0
- package/dist/transactions/index.js +662 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/worker-protocol/index.d.ts +84 -0
- package/dist/worker-protocol/index.d.ts.map +1 -0
- package/dist/worker-protocol/index.js +117 -0
- package/dist/worker-protocol/index.js.map +1 -0
- package/package.json +66 -16
- package/sql-feature-matrix.json +1275 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
export declare const storeNames: readonly ["catalog", "manifests", "segments", "blocks", "transactions", "leases", "statistics", "temp", "gc"];
|
|
2
|
+
/** The manifest fields every commit publishes; `Manifest` adds the resolved block list. */
|
|
3
|
+
export interface ManifestSummary {
|
|
4
|
+
version: number;
|
|
5
|
+
previousVersion: number | null;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
/**
|
|
8
|
+
* Table IDs whose logical content this commit changed; empty means a logical no-change such as
|
|
9
|
+
* compaction. Absent on manifests written before change tracking, which readers treat as
|
|
10
|
+
* potentially changing every table.
|
|
11
|
+
*/
|
|
12
|
+
changedTableIds?: string[];
|
|
13
|
+
/** A pruned descriptor remains readable for commit reconciliation but cannot be pinned. */
|
|
14
|
+
prunedAt?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Manifest extends ManifestSummary {
|
|
17
|
+
blockIds: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The stored manifest shape: a checkpoint carries the complete sorted block list; a delta
|
|
21
|
+
* carries only this commit's added and removed ids plus its distance from the checkpoint below
|
|
22
|
+
* it. Reads resolve a version by walking back to the nearest checkpoint and applying deltas
|
|
23
|
+
* forward, so publishing a commit writes O(changed blocks) instead of rewriting every live
|
|
24
|
+
* block id. Records are never physically deleted (pruning tombstones them via `prunedAt`), so a
|
|
25
|
+
* chain below any readable version always resolves.
|
|
26
|
+
*/
|
|
27
|
+
export interface StoredManifestRecord extends ManifestSummary {
|
|
28
|
+
blockIds?: string[];
|
|
29
|
+
addedBlockIds?: string[];
|
|
30
|
+
removedBlockIds?: string[];
|
|
31
|
+
/** Deltas since the checkpoint below; 0 on checkpoints. */
|
|
32
|
+
deltaDepth?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Every this-many commits the store writes a full checkpoint instead of a delta. */
|
|
35
|
+
export declare const MANIFEST_CHECKPOINT_INTERVAL = 32;
|
|
36
|
+
/** Applies one stored record to a running block set (checkpoint replaces, delta mutates). */
|
|
37
|
+
export declare function applyManifestRecord(blockIds: Set<string>, record: StoredManifestRecord): void;
|
|
38
|
+
export interface PublishManifestInput {
|
|
39
|
+
changedTableIds?: readonly string[];
|
|
40
|
+
expectedVersion: number | null;
|
|
41
|
+
blockIds: readonly string[];
|
|
42
|
+
createdAt?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare const simpleDataTypes: readonly ["boolean", "number", "string", "datetime"];
|
|
45
|
+
export type SimpleDataType = (typeof simpleDataTypes)[number];
|
|
46
|
+
/**
|
|
47
|
+
* Declarative write-time default. Plain structured-clone-safe data: the spec crosses the
|
|
48
|
+
* worker postMessage boundary and persists in the catalog, so function defaults are
|
|
49
|
+
* unrepresentable by design — the schema DSL carries those separately (`ColumnBuilder.defaultFn`)
|
|
50
|
+
* and the typed facade fills them before a batch reaches the engine.
|
|
51
|
+
*/
|
|
52
|
+
export type ColumnDefault = {
|
|
53
|
+
kind: "now";
|
|
54
|
+
} | {
|
|
55
|
+
kind: "literal";
|
|
56
|
+
value: boolean | number | string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "autoincrement";
|
|
59
|
+
};
|
|
60
|
+
export interface TableColumnRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
type: SimpleDataType;
|
|
64
|
+
nullable: boolean;
|
|
65
|
+
/** Fills null-or-absent slots at insert time; never applied at read time. */
|
|
66
|
+
defaultValue?: ColumnDefault;
|
|
67
|
+
/**
|
|
68
|
+
* What rows written before this column existed read as, instead of NULL.
|
|
69
|
+
*
|
|
70
|
+
* A column added by a migration has no blocks in older segments. Those rows would otherwise
|
|
71
|
+
* read NULL forever, which is why adding a non-nullable column was impossible. Substituting
|
|
72
|
+
* this value at read time makes the addition meaningful without rewriting a single stored
|
|
73
|
+
* byte — the segments are untouched, and compaction folds the value in whenever it next
|
|
74
|
+
* rewrites them. It is frozen when the column is added: a generator runs once, at migration
|
|
75
|
+
* time, so every reader of a given row agrees.
|
|
76
|
+
*
|
|
77
|
+
* Spelled out rather than imported: storage sits below the engine, and NULL is the absence
|
|
78
|
+
* this replaces, so it is not one of the options.
|
|
79
|
+
*/
|
|
80
|
+
backfill?: boolean | number | string | Date;
|
|
81
|
+
/**
|
|
82
|
+
* String columns only: the closed set of values writes must draw from. Physically the column
|
|
83
|
+
* stays a plain string column; the set is write-time validation metadata, so widening it (or
|
|
84
|
+
* dropping it) is catalog-only while narrowing it is rejected by migration planning.
|
|
85
|
+
*/
|
|
86
|
+
enumValues?: string[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The single authority on which enum declarations are legal, shared by the schema DSL's
|
|
90
|
+
* `column.enum()` and the engine's `createTable`: at least one value, every value a non-empty
|
|
91
|
+
* string, no duplicates. Returns a defensive copy.
|
|
92
|
+
*/
|
|
93
|
+
export declare function validateEnumValues(values: readonly string[], context: string): string[];
|
|
94
|
+
/**
|
|
95
|
+
* The single authority on which default declarations are legal, shared by the schema DSL's
|
|
96
|
+
* `table()` and the engine's `createTable` so the two entry points (and the wire path between
|
|
97
|
+
* them) can never drift: defaults require non-nullable columns, "now" is datetime-only,
|
|
98
|
+
* auto-increment is the number unique key, and the unique key never defaults to a constant.
|
|
99
|
+
*/
|
|
100
|
+
export declare function validateColumnDefault(column: {
|
|
101
|
+
name: string;
|
|
102
|
+
type: SimpleDataType;
|
|
103
|
+
nullable: boolean;
|
|
104
|
+
isUniqueKey: boolean;
|
|
105
|
+
enumValues?: readonly string[];
|
|
106
|
+
}, defaultValue: ColumnDefault): void;
|
|
107
|
+
export type FtsColumnIndexState = "building" | "ready" | "invalid";
|
|
108
|
+
/**
|
|
109
|
+
* One column's persisted full-text index declaration. The index is a pruning accelerator, never
|
|
110
|
+
* ground truth: readers use it only in state "ready" with a matching tokenizer version, and the
|
|
111
|
+
* scan re-verifies every candidate, so a stale or missing index costs speed, not correctness.
|
|
112
|
+
*/
|
|
113
|
+
export interface FtsColumnIndexRecord {
|
|
114
|
+
storage: "fts-chunks-v1";
|
|
115
|
+
tokenizerVersion: number;
|
|
116
|
+
state: FtsColumnIndexState;
|
|
117
|
+
/** Manifest version the base build covers; commit deltas above it merge at read time. */
|
|
118
|
+
buildFromVersion: number;
|
|
119
|
+
}
|
|
120
|
+
export interface TableRecord {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
columns: TableColumnRecord[];
|
|
124
|
+
uniqueKeyColumnId?: string;
|
|
125
|
+
uniqueKeyLookupReady?: boolean;
|
|
126
|
+
uniqueKeyStorage?: "chunks-v1" | "chunks-v2";
|
|
127
|
+
/** Full-text index state per column ID. Writers that see this emit commit deltas. */
|
|
128
|
+
ftsColumns?: Record<string, FtsColumnIndexRecord>;
|
|
129
|
+
/** AFTER triggers on this table, fired by the committing writer inside its transaction. */
|
|
130
|
+
triggers?: TriggerRecord[];
|
|
131
|
+
/**
|
|
132
|
+
* Single-column FOREIGN KEY constraints (E141-04). The referenced column is the parent's
|
|
133
|
+
* unique key, which is what the engine can probe for existence and what its keyed write paths
|
|
134
|
+
* address rows by; a parent key never changes, so only ON DELETE has an action to take.
|
|
135
|
+
*/
|
|
136
|
+
foreignKeys?: Array<{
|
|
137
|
+
name: string;
|
|
138
|
+
column: string;
|
|
139
|
+
parentTable: string;
|
|
140
|
+
parentColumn: string;
|
|
141
|
+
onDelete: "restrict" | "cascade" | "set null";
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Row-level CHECK constraints (E141-06), each the text of a boolean expression over this
|
|
145
|
+
* table's own columns. Text rather than a compiled form because the record crosses the worker
|
|
146
|
+
* boundary and IndexedDB; the writer compiles it and evaluates it against every row it writes.
|
|
147
|
+
*/
|
|
148
|
+
checks?: Array<{
|
|
149
|
+
name: string;
|
|
150
|
+
sql: string;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* True when `migrate()` created this table from a schema declaration, which makes the schema
|
|
154
|
+
* authoritative over it: dropping the declaration may drop the table. A table created with
|
|
155
|
+
* `CREATE TABLE`, or one written before this field existed, is absent-or-false and no
|
|
156
|
+
* migration removes it — the same rule views follow, and it matters more here because a
|
|
157
|
+
* table holds rows.
|
|
158
|
+
*/
|
|
159
|
+
managed?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* A view rather than a table: the query text it stands for, and no segments of its own. The
|
|
162
|
+
* `columns` are the query's inferred output schema, so a view answers the same catalog
|
|
163
|
+
* questions a table does — what a reader can select, and of what type.
|
|
164
|
+
*/
|
|
165
|
+
view?: {
|
|
166
|
+
sql: string;
|
|
167
|
+
/**
|
|
168
|
+
* True when `migrate()` created this view from a schema declaration, which makes the schema
|
|
169
|
+
* authoritative over it: dropping the declaration drops the view. A view created with
|
|
170
|
+
* `CREATE VIEW`, or one written before this field existed, is absent-or-false and no
|
|
171
|
+
* migration will remove it.
|
|
172
|
+
*/
|
|
173
|
+
managed?: boolean;
|
|
174
|
+
};
|
|
175
|
+
createdAt: string;
|
|
176
|
+
/** Compare-and-swap revision for catalog evolution; records written before it read as 0. */
|
|
177
|
+
revision?: number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* One AFTER trigger: catalog-persisted on its table record so the catalog epoch makes it
|
|
181
|
+
* visible to every tab immediately, and executed by the committing writer inside the same
|
|
182
|
+
* transaction as the triggering write — the write and its derivations publish atomically.
|
|
183
|
+
*/
|
|
184
|
+
export interface TriggerRecord {
|
|
185
|
+
name: string;
|
|
186
|
+
event: "insert" | "update" | "delete";
|
|
187
|
+
/**
|
|
188
|
+
* BEFORE and AFTER differ only in body staging order here: both fire in the committing
|
|
189
|
+
* writer inside the triggering commit, so the pair exists for SQL portability, with
|
|
190
|
+
* identical atomicity.
|
|
191
|
+
*/
|
|
192
|
+
timing: "before" | "after";
|
|
193
|
+
/** Body statements in order; each fires once per affected row. */
|
|
194
|
+
statements: TriggerStatementRecord[];
|
|
195
|
+
createdAt: string;
|
|
196
|
+
}
|
|
197
|
+
export interface TriggerStatementRecord {
|
|
198
|
+
/** The body statement with every NEW.col / OLD.col reference rewritten to a placeholder. */
|
|
199
|
+
sql: string;
|
|
200
|
+
/** Placeholder bindings in order: which pseudo-row and column fills each parameter. */
|
|
201
|
+
bindings: Array<{
|
|
202
|
+
source: "new" | "old";
|
|
203
|
+
column: string;
|
|
204
|
+
}>;
|
|
205
|
+
}
|
|
206
|
+
export declare class TableRecordConflictError extends Error {
|
|
207
|
+
readonly tableId: string;
|
|
208
|
+
readonly expectedRevision: number;
|
|
209
|
+
readonly actualRevision: number | null;
|
|
210
|
+
readonly name = "TableRecordConflictError";
|
|
211
|
+
constructor(tableId: string, expectedRevision: number, actualRevision: number | null);
|
|
212
|
+
}
|
|
213
|
+
export type SegmentKind = "insert" | "upsert" | "update" | "delete" | "base";
|
|
214
|
+
/** Maps a contiguous segment-row run to its immutable hidden row IDs. */
|
|
215
|
+
export interface RowIdSpan {
|
|
216
|
+
readonly rowStart: number;
|
|
217
|
+
readonly rowCount: number;
|
|
218
|
+
readonly rowIdStart: bigint;
|
|
219
|
+
}
|
|
220
|
+
export interface SegmentRecord {
|
|
221
|
+
id: string;
|
|
222
|
+
tableId: string;
|
|
223
|
+
transactionId: string;
|
|
224
|
+
rowCount: number;
|
|
225
|
+
rowIdStart: bigint;
|
|
226
|
+
rowIdEndExclusive: bigint;
|
|
227
|
+
columnBlockIds: Record<string, string[]>;
|
|
228
|
+
kind?: SegmentKind;
|
|
229
|
+
keyColumnId?: string;
|
|
230
|
+
/** Missing on legacy records, which are interpreted as level zero. */
|
|
231
|
+
level?: number;
|
|
232
|
+
/** Missing on legacy records, where commit order supplies the logical order. */
|
|
233
|
+
logicalOrder?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Staging position inside the owning transaction. Orders segments of one commit relative
|
|
236
|
+
* to each other (an in-scope update must fold after the in-scope insert it patches);
|
|
237
|
+
* missing on legacy records, which never shared a key within one commit.
|
|
238
|
+
*/
|
|
239
|
+
commitOrdinal?: number;
|
|
240
|
+
/** Missing on legacy insert/upsert records, which imply one contiguous row-ID span. */
|
|
241
|
+
rowIdSpans?: readonly RowIdSpan[];
|
|
242
|
+
/** Monotone policy ordinal for an immutable append-row-range level-two partition. */
|
|
243
|
+
readonly partitionOrdinal?: number;
|
|
244
|
+
createdAt: string;
|
|
245
|
+
}
|
|
246
|
+
export interface RowIdRange {
|
|
247
|
+
start: bigint;
|
|
248
|
+
endExclusive: bigint;
|
|
249
|
+
}
|
|
250
|
+
export type LeaseKind = "reader" | "backup";
|
|
251
|
+
export interface LeaseRecord {
|
|
252
|
+
id: string;
|
|
253
|
+
kind: LeaseKind;
|
|
254
|
+
manifestVersion: number | null;
|
|
255
|
+
ownerId: string;
|
|
256
|
+
expiresAt: string;
|
|
257
|
+
revision: number;
|
|
258
|
+
}
|
|
259
|
+
export declare const compactionJobStates: readonly ["planned", "running", "ready", "published", "cancelled", "aborted"];
|
|
260
|
+
export type CompactionJobState = (typeof compactionJobStates)[number];
|
|
261
|
+
export interface CompactionJobCursor {
|
|
262
|
+
sourceSegmentIndex: number;
|
|
263
|
+
sourceBlockIndex: number;
|
|
264
|
+
}
|
|
265
|
+
export declare const compactionRewritePlanKinds: readonly ["copy-v1", "rechunk-v1", "merge-v1"];
|
|
266
|
+
export type CompactionRewritePlanKind = (typeof compactionRewritePlanKinds)[number];
|
|
267
|
+
export interface CopyCompactionRewritePlan {
|
|
268
|
+
readonly kind: "copy-v1";
|
|
269
|
+
}
|
|
270
|
+
export interface RechunkCompactionSourceBlock {
|
|
271
|
+
readonly blockId: string;
|
|
272
|
+
readonly rowStart: number;
|
|
273
|
+
readonly rowCount: number;
|
|
274
|
+
/** Full persisted block byteLength, including the envelope and stored payload. */
|
|
275
|
+
readonly storedBytes: number;
|
|
276
|
+
/** Uncompressed encoded payload length from the immutable block header. */
|
|
277
|
+
readonly encodedBytes: number;
|
|
278
|
+
readonly checksum: number;
|
|
279
|
+
}
|
|
280
|
+
export interface RechunkCompactionSourceColumn {
|
|
281
|
+
readonly columnId: string;
|
|
282
|
+
readonly type: SimpleDataType;
|
|
283
|
+
readonly sourceBlocks: readonly RechunkCompactionSourceBlock[];
|
|
284
|
+
}
|
|
285
|
+
export interface RechunkCompactionOutputWindow {
|
|
286
|
+
readonly rowStart: number;
|
|
287
|
+
readonly rowCount: number;
|
|
288
|
+
}
|
|
289
|
+
export declare const compactionOutputCompressions: readonly ["raw", "gzip"];
|
|
290
|
+
export type CompactionOutputCompression = (typeof compactionOutputCompressions)[number];
|
|
291
|
+
export interface RechunkCompactionRewritePlan {
|
|
292
|
+
readonly kind: "rechunk-v1";
|
|
293
|
+
readonly targetBlockBytes: number;
|
|
294
|
+
readonly outputCompression: CompactionOutputCompression;
|
|
295
|
+
readonly totalRows: number;
|
|
296
|
+
readonly rowIdStart: bigint;
|
|
297
|
+
readonly rowIdEndExclusive: bigint;
|
|
298
|
+
readonly logicalOrder: number;
|
|
299
|
+
readonly columns: readonly RechunkCompactionSourceColumn[];
|
|
300
|
+
/** Shared row windows, emitted in output-window-major then column order. */
|
|
301
|
+
readonly outputs: readonly RechunkCompactionOutputWindow[];
|
|
302
|
+
}
|
|
303
|
+
export interface MergeCompactionSourceBlock {
|
|
304
|
+
readonly blockId: string;
|
|
305
|
+
/** Row offset within the source segment column. */
|
|
306
|
+
readonly rowStart: number;
|
|
307
|
+
readonly rowCount: number;
|
|
308
|
+
readonly storedBytes: number;
|
|
309
|
+
readonly encodedBytes: number;
|
|
310
|
+
readonly checksum: number;
|
|
311
|
+
}
|
|
312
|
+
export interface MergeCompactionSourceColumn {
|
|
313
|
+
readonly columnId: string;
|
|
314
|
+
readonly type: SimpleDataType;
|
|
315
|
+
readonly sourceBlocks: readonly MergeCompactionSourceBlock[];
|
|
316
|
+
}
|
|
317
|
+
export interface MergeCompactionSourceSegment {
|
|
318
|
+
readonly segmentId: string;
|
|
319
|
+
readonly transactionId: string;
|
|
320
|
+
readonly committedVersion: number;
|
|
321
|
+
readonly kind: SegmentKind;
|
|
322
|
+
readonly keyColumnId: string | null;
|
|
323
|
+
readonly level: number;
|
|
324
|
+
readonly logicalOrder: number;
|
|
325
|
+
readonly rowCount: number;
|
|
326
|
+
readonly rowIdStart: bigint;
|
|
327
|
+
readonly rowIdEndExclusive: bigint;
|
|
328
|
+
readonly rowIdSpans: readonly RowIdSpan[];
|
|
329
|
+
readonly columns: readonly MergeCompactionSourceColumn[];
|
|
330
|
+
}
|
|
331
|
+
export interface MergeCompactionOutputSourceRange {
|
|
332
|
+
/** Row offset within the canonical merged output. */
|
|
333
|
+
readonly outputRowStart: number;
|
|
334
|
+
readonly sourceBlockId: string;
|
|
335
|
+
/** Row offset within sourceBlockId. */
|
|
336
|
+
readonly sourceRowStart: number;
|
|
337
|
+
readonly rowCount: number;
|
|
338
|
+
}
|
|
339
|
+
export interface MergeCompactionOutputColumn {
|
|
340
|
+
readonly columnId: string;
|
|
341
|
+
readonly type: SimpleDataType;
|
|
342
|
+
readonly sourceRanges: readonly MergeCompactionOutputSourceRange[];
|
|
343
|
+
}
|
|
344
|
+
/** An immutable logical replay result followed by a physical, output-driven rewrite. */
|
|
345
|
+
export interface MergeCompactionRewritePlan {
|
|
346
|
+
readonly kind: "merge-v1";
|
|
347
|
+
readonly targetBlockBytes: number;
|
|
348
|
+
readonly outputCompression: CompactionOutputCompression;
|
|
349
|
+
readonly keyColumnId: string;
|
|
350
|
+
readonly totalRows: number;
|
|
351
|
+
/** Bounding row-ID envelope; spans preserve gaps and output order. */
|
|
352
|
+
readonly rowIdStart: bigint;
|
|
353
|
+
readonly rowIdEndExclusive: bigint;
|
|
354
|
+
readonly rowIdSpans: readonly RowIdSpan[];
|
|
355
|
+
readonly logicalOrder: number;
|
|
356
|
+
readonly sourceSegments: readonly MergeCompactionSourceSegment[];
|
|
357
|
+
readonly columns: readonly MergeCompactionOutputColumn[];
|
|
358
|
+
readonly outputs: readonly RechunkCompactionOutputWindow[];
|
|
359
|
+
}
|
|
360
|
+
export type CompactionRewritePlan = CopyCompactionRewritePlan | RechunkCompactionRewritePlan | MergeCompactionRewritePlan;
|
|
361
|
+
/**
|
|
362
|
+
* The next rechunk output to emit, ordered by output window and then column. A completed cursor
|
|
363
|
+
* has outputIndex === outputs.length, columnIndex zero, and rowStart === totalRows.
|
|
364
|
+
*/
|
|
365
|
+
export interface CompactionOutputCursor {
|
|
366
|
+
outputIndex: number;
|
|
367
|
+
columnIndex: number;
|
|
368
|
+
rowStart: number;
|
|
369
|
+
}
|
|
370
|
+
export interface CompactionJobRecord {
|
|
371
|
+
id: string;
|
|
372
|
+
tableId: string;
|
|
373
|
+
sourceManifestVersion: number;
|
|
374
|
+
sourceSegmentIds: string[];
|
|
375
|
+
sourceBlockIds: string[];
|
|
376
|
+
outputBlockIds: string[];
|
|
377
|
+
cursor: CompactionJobCursor;
|
|
378
|
+
processedRows: number;
|
|
379
|
+
sourceStoredBytes: number;
|
|
380
|
+
outputStoredBytes: number;
|
|
381
|
+
logicalBytes: number;
|
|
382
|
+
/** Missing on Phase 6A records, which normalize to copy-v1. */
|
|
383
|
+
readonly rewritePlan?: CompactionRewritePlan;
|
|
384
|
+
/** Null for copy-v1; points at the next output for rechunk-v1. */
|
|
385
|
+
outputCursor?: CompactionOutputCursor | null;
|
|
386
|
+
/** Immutable execution budget. Zero for copy-v1 jobs. */
|
|
387
|
+
readonly memoryBudgetBytes?: number;
|
|
388
|
+
/** Immutable planner estimate. Zero for copy-v1 jobs. */
|
|
389
|
+
readonly minimumMemoryBytes?: number;
|
|
390
|
+
/** Immutable stored bytes from newly promoted level-zero sources. Missing on legacy jobs. */
|
|
391
|
+
readonly level0SourceStoredBytes?: number;
|
|
392
|
+
/** Immutable stored bytes from the retained level-one anchor. Missing on legacy jobs. */
|
|
393
|
+
readonly anchorSourceStoredBytes?: number;
|
|
394
|
+
/** Output partition assigned by the append-row-range L2 policy. Missing on legacy jobs. */
|
|
395
|
+
readonly outputPartitionOrdinal?: number;
|
|
396
|
+
/** Immutable maximum compaction output bytes per newly promoted L0 byte. */
|
|
397
|
+
readonly maxWriteAmplification?: number;
|
|
398
|
+
/** Immutable exact ceiling for all stored output blocks produced by this job. */
|
|
399
|
+
readonly maximumOutputStoredBytes?: number;
|
|
400
|
+
/** Immutable conservative full-block upper bound for the planned output. */
|
|
401
|
+
readonly plannedOutputStoredBytesUpperBound?: number;
|
|
402
|
+
/**
|
|
403
|
+
* Immutable stored bytes already written by cancelled or aborted attempts at these same
|
|
404
|
+
* sources. The persisted ceiling is reduced by this amount, so attempts share one lifetime
|
|
405
|
+
* write-amplification budget.
|
|
406
|
+
*/
|
|
407
|
+
readonly priorAttemptOutputStoredBytes?: number;
|
|
408
|
+
peakWorkingBytes?: number;
|
|
409
|
+
outputLogicalBytes?: number;
|
|
410
|
+
targetLevel: number;
|
|
411
|
+
state: CompactionJobState;
|
|
412
|
+
transactionId: string | null;
|
|
413
|
+
outputSegmentId: string | null;
|
|
414
|
+
publishedVersion: number | null;
|
|
415
|
+
revision: number;
|
|
416
|
+
createdAt: string;
|
|
417
|
+
updatedAt: string;
|
|
418
|
+
error?: string;
|
|
419
|
+
}
|
|
420
|
+
export interface CompactionJobRecordUpdate {
|
|
421
|
+
outputBlockIds?: readonly string[];
|
|
422
|
+
cursor?: CompactionJobCursor;
|
|
423
|
+
processedRows?: number;
|
|
424
|
+
sourceStoredBytes?: number;
|
|
425
|
+
outputStoredBytes?: number;
|
|
426
|
+
logicalBytes?: number;
|
|
427
|
+
outputCursor?: CompactionOutputCursor | null;
|
|
428
|
+
peakWorkingBytes?: number;
|
|
429
|
+
outputLogicalBytes?: number;
|
|
430
|
+
state?: CompactionJobState;
|
|
431
|
+
transactionId?: string | null;
|
|
432
|
+
outputSegmentId?: string | null;
|
|
433
|
+
publishedVersion?: number | null;
|
|
434
|
+
updatedAt: string;
|
|
435
|
+
error?: string | null;
|
|
436
|
+
}
|
|
437
|
+
export declare class CompactionJobConflictError extends Error {
|
|
438
|
+
readonly jobId: string;
|
|
439
|
+
readonly expectedRevision: number;
|
|
440
|
+
readonly actualRevision: number | null;
|
|
441
|
+
readonly name = "CompactionJobConflictError";
|
|
442
|
+
constructor(jobId: string, expectedRevision: number, actualRevision: number | null);
|
|
443
|
+
}
|
|
444
|
+
export declare const garbageCollectionJobStates: readonly ["planned", "running", "completed"];
|
|
445
|
+
export type GarbageCollectionJobState = (typeof garbageCollectionJobStates)[number];
|
|
446
|
+
export interface GarbageCollectionCursor {
|
|
447
|
+
manifestIndex: number;
|
|
448
|
+
segmentIndex: number;
|
|
449
|
+
blockIndex: number;
|
|
450
|
+
}
|
|
451
|
+
export interface CreateGarbageCollectionJobInput {
|
|
452
|
+
id: string;
|
|
453
|
+
candidateManifestVersions: readonly number[];
|
|
454
|
+
candidateSegmentIds: readonly string[];
|
|
455
|
+
candidateBlockIds: readonly string[];
|
|
456
|
+
/** Fixed cutoff used to decide which persisted leases protect a manifest for this job. */
|
|
457
|
+
leaseCutoff: string;
|
|
458
|
+
createdAt: string;
|
|
459
|
+
}
|
|
460
|
+
export interface GarbageCollectionJobRecord {
|
|
461
|
+
id: string;
|
|
462
|
+
candidateManifestVersions: number[];
|
|
463
|
+
candidateSegmentIds: string[];
|
|
464
|
+
candidateBlockIds: string[];
|
|
465
|
+
cursor: GarbageCollectionCursor;
|
|
466
|
+
prunedManifestCount: number;
|
|
467
|
+
alreadyPrunedManifestCount: number;
|
|
468
|
+
retainedManifestCount: number;
|
|
469
|
+
missingManifestCount: number;
|
|
470
|
+
reclaimedSegmentCount: number;
|
|
471
|
+
retainedSegmentCount: number;
|
|
472
|
+
missingSegmentCount: number;
|
|
473
|
+
reclaimedBlockCount: number;
|
|
474
|
+
retainedBlockCount: number;
|
|
475
|
+
missingBlockCount: number;
|
|
476
|
+
reclaimedBlockBytes: number;
|
|
477
|
+
state: GarbageCollectionJobState;
|
|
478
|
+
revision: number;
|
|
479
|
+
leaseCutoff: string;
|
|
480
|
+
createdAt: string;
|
|
481
|
+
updatedAt: string;
|
|
482
|
+
}
|
|
483
|
+
export interface RunGarbageCollectionStepInput {
|
|
484
|
+
jobId: string;
|
|
485
|
+
expectedRevision: number;
|
|
486
|
+
maxItems: number;
|
|
487
|
+
updatedAt: string;
|
|
488
|
+
}
|
|
489
|
+
export interface GarbageCollectionStepResult {
|
|
490
|
+
job: GarbageCollectionJobRecord;
|
|
491
|
+
prunedManifestVersions: number[];
|
|
492
|
+
alreadyPrunedManifestVersions: number[];
|
|
493
|
+
retainedManifestVersions: number[];
|
|
494
|
+
missingManifestVersions: number[];
|
|
495
|
+
reclaimedSegmentIds: string[];
|
|
496
|
+
retainedSegmentIds: string[];
|
|
497
|
+
missingSegmentIds: string[];
|
|
498
|
+
reclaimedBlockIds: string[];
|
|
499
|
+
retainedBlockIds: string[];
|
|
500
|
+
missingBlockIds: string[];
|
|
501
|
+
reclaimedBlockBytes: number;
|
|
502
|
+
}
|
|
503
|
+
export interface StoragePage<T, Cursor> {
|
|
504
|
+
records: T[];
|
|
505
|
+
nextCursor: Cursor | null;
|
|
506
|
+
}
|
|
507
|
+
export declare class GarbageCollectionJobConflictError extends Error {
|
|
508
|
+
readonly jobId: string;
|
|
509
|
+
readonly expectedRevision: number;
|
|
510
|
+
readonly actualRevision: number | null;
|
|
511
|
+
readonly name = "GarbageCollectionJobConflictError";
|
|
512
|
+
constructor(jobId: string, expectedRevision: number, actualRevision: number | null);
|
|
513
|
+
}
|
|
514
|
+
export declare class SnapshotManifestMissingError extends Error {
|
|
515
|
+
readonly version: number;
|
|
516
|
+
readonly name = "SnapshotManifestMissingError";
|
|
517
|
+
constructor(version: number);
|
|
518
|
+
}
|
|
519
|
+
export interface GarbageCollectionStepAccounting {
|
|
520
|
+
examinedManifestCount: number;
|
|
521
|
+
prunedManifestCount: number;
|
|
522
|
+
alreadyPrunedManifestCount: number;
|
|
523
|
+
retainedManifestCount: number;
|
|
524
|
+
missingManifestCount: number;
|
|
525
|
+
examinedSegmentCount: number;
|
|
526
|
+
reclaimedSegmentCount: number;
|
|
527
|
+
retainedSegmentCount: number;
|
|
528
|
+
missingSegmentCount: number;
|
|
529
|
+
examinedBlockCount: number;
|
|
530
|
+
reclaimedBlockCount: number;
|
|
531
|
+
retainedBlockCount: number;
|
|
532
|
+
missingBlockCount: number;
|
|
533
|
+
reclaimedBlockBytes: number;
|
|
534
|
+
updatedAt: string;
|
|
535
|
+
}
|
|
536
|
+
export declare class LeaseConflictError extends Error {
|
|
537
|
+
readonly leaseId: string;
|
|
538
|
+
readonly expectedRevision: number;
|
|
539
|
+
readonly actualRevision: number | null;
|
|
540
|
+
readonly name = "LeaseConflictError";
|
|
541
|
+
constructor(leaseId: string, expectedRevision: number, actualRevision: number | null);
|
|
542
|
+
}
|
|
543
|
+
export type TransactionStatus = "active" | "committed" | "aborted";
|
|
544
|
+
export interface TransactionRecord {
|
|
545
|
+
id: string;
|
|
546
|
+
snapshotVersion: number | null;
|
|
547
|
+
pendingBlockIds: string[];
|
|
548
|
+
pendingSegmentIds: string[];
|
|
549
|
+
status: TransactionStatus;
|
|
550
|
+
revision: number;
|
|
551
|
+
startedAt: string;
|
|
552
|
+
updatedAt: string;
|
|
553
|
+
committedVersion: number | null;
|
|
554
|
+
}
|
|
555
|
+
export interface TransactionRecordUpdate {
|
|
556
|
+
snapshotVersion?: number | null;
|
|
557
|
+
pendingBlockIds?: readonly string[];
|
|
558
|
+
pendingSegmentIds?: readonly string[];
|
|
559
|
+
status?: TransactionStatus;
|
|
560
|
+
updatedAt: string;
|
|
561
|
+
committedVersion?: number | null;
|
|
562
|
+
}
|
|
563
|
+
export interface BeginTransactionInput {
|
|
564
|
+
/** Record to create; the store stamps `snapshotVersion` with the current manifest version. */
|
|
565
|
+
record: Omit<TransactionRecord, "snapshotVersion">;
|
|
566
|
+
/** Reserve this many row ids for the table in the same atomic step. */
|
|
567
|
+
reserveRowIds?: {
|
|
568
|
+
tableId: string;
|
|
569
|
+
count: number;
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Reserve auto-increment values for the column in the same atomic step, first bumping the
|
|
573
|
+
* counter to at least `atLeast`. `count` may be 0 for a pure bump past explicit values.
|
|
574
|
+
*/
|
|
575
|
+
reserveAutoIncrement?: {
|
|
576
|
+
tableId: string;
|
|
577
|
+
columnId: string;
|
|
578
|
+
count: number;
|
|
579
|
+
atLeast?: bigint;
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
export interface BeginTransactionResult {
|
|
583
|
+
record: TransactionRecord;
|
|
584
|
+
rowIds?: RowIdRange;
|
|
585
|
+
autoIncrementValues?: RowIdRange;
|
|
586
|
+
}
|
|
587
|
+
export interface StageTransactionArtifactsInput {
|
|
588
|
+
transactionId: string;
|
|
589
|
+
expectedRevision: number;
|
|
590
|
+
blocks: readonly BlockWrite[];
|
|
591
|
+
segments: readonly SegmentRecord[];
|
|
592
|
+
updatedAt: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* The commit input carries only the change: added blocks are the transaction's journaled pending
|
|
596
|
+
* blocks, removals are the superseded ids. The store derives the published manifest from its
|
|
597
|
+
* stored base, so commit cost scales with the delta rather than the database's total block count.
|
|
598
|
+
*/
|
|
599
|
+
export interface CommitTransactionInput {
|
|
600
|
+
transactionId: string;
|
|
601
|
+
changedTableIds?: readonly string[];
|
|
602
|
+
expectedTransactionRevision: number;
|
|
603
|
+
expectedManifestVersion: number | null;
|
|
604
|
+
removedBlockIds?: readonly string[];
|
|
605
|
+
/**
|
|
606
|
+
* Per-table unique-key changes, in operation order. Multi-entry commits come from atomic
|
|
607
|
+
* write scopes; entries for the same table apply sequentially, so in-scope conflicts
|
|
608
|
+
* (inserting one key twice) fail exactly like cross-commit conflicts.
|
|
609
|
+
*/
|
|
610
|
+
uniqueKeyChanges?: readonly UniqueKeyChanges[];
|
|
611
|
+
/** Per-table full-text deltas; at most one entry per table. */
|
|
612
|
+
ftsChanges?: readonly FtsChanges[];
|
|
613
|
+
committedAt: string;
|
|
614
|
+
}
|
|
615
|
+
export interface UniqueKeyChanges {
|
|
616
|
+
tableId: string;
|
|
617
|
+
keyTokens: readonly string[];
|
|
618
|
+
requireAbsent: boolean;
|
|
619
|
+
remove?: boolean;
|
|
620
|
+
storageMode?: "chunks-v1" | "chunks-v2";
|
|
621
|
+
}
|
|
622
|
+
/** One term's postings within a commit delta or base chunk: parallel rowId/tf arrays. */
|
|
623
|
+
export interface FtsPosting {
|
|
624
|
+
term: string;
|
|
625
|
+
rowIds: bigint[];
|
|
626
|
+
tf: number[];
|
|
627
|
+
}
|
|
628
|
+
/** One indexed column's contribution from one commit: postings for the commit's new rows. */
|
|
629
|
+
export interface FtsColumnDelta {
|
|
630
|
+
columnId: string;
|
|
631
|
+
/** Term-sorted postings; rowIds ascending within each term. */
|
|
632
|
+
postings: FtsPosting[];
|
|
633
|
+
/** Total tokens the commit's rows contribute to this column — feeds exact BM25 statistics. */
|
|
634
|
+
totalTokens: number;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* A commit's full-text index deltas, applied atomically with the manifest publish. The store
|
|
638
|
+
* also closes the stale-writer race here: a commit that adds segments to a table whose record
|
|
639
|
+
* indexes a column in state "building" or "ready" without carrying that column's delta flips
|
|
640
|
+
* the column to "invalid" (self-healing rebuild) rather than rejecting the data commit.
|
|
641
|
+
*/
|
|
642
|
+
export interface FtsChanges {
|
|
643
|
+
tableId: string;
|
|
644
|
+
columns: readonly FtsColumnDelta[];
|
|
645
|
+
}
|
|
646
|
+
/** The per-term candidate row IDs a full-text index lookup returns, aligned with the query. */
|
|
647
|
+
export interface FtsCandidates {
|
|
648
|
+
/** Per requested term: ascending unique row IDs whose indexed column contained the term. */
|
|
649
|
+
rowIdsByTerm: bigint[][];
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Shared candidate-merge core for both stores: fetching chunks is store-specific, but the
|
|
653
|
+
* term-match rule (exact, or prefix as a term range) and the sorted-unique row-id shape must
|
|
654
|
+
* never drift between backends — pruning would silently differ per store.
|
|
655
|
+
*/
|
|
656
|
+
export declare function collectFtsCandidates(chunkLists: Iterable<readonly FtsPosting[]>, terms: ReadonlyArray<{
|
|
657
|
+
term: string;
|
|
658
|
+
prefix: boolean;
|
|
659
|
+
}>): FtsCandidates;
|
|
660
|
+
/**
|
|
661
|
+
* Shared stale-writer policy for both stores' commit steps: a commit that adds segments to a
|
|
662
|
+
* table with active full-text columns but no covering delta flips the uncovered columns to
|
|
663
|
+
* "invalid" (the index self-heals through a rebuild; the data commit itself always proceeds).
|
|
664
|
+
* Returns the updated record, or undefined when nothing changes.
|
|
665
|
+
*/
|
|
666
|
+
export declare function invalidateUncoveredFtsColumns(record: TableRecord, coveredColumnIds: ReadonlySet<string>): TableRecord | undefined;
|
|
667
|
+
export declare class UniqueKeyConflictError extends Error {
|
|
668
|
+
readonly tableId: string;
|
|
669
|
+
readonly keyToken: string;
|
|
670
|
+
readonly name = "UniqueKeyConflictError";
|
|
671
|
+
constructor(tableId: string, keyToken: string);
|
|
672
|
+
}
|
|
673
|
+
export declare class WriteConflictError extends Error {
|
|
674
|
+
readonly expectedVersion: number | null;
|
|
675
|
+
readonly actualVersion: number | null;
|
|
676
|
+
readonly name = "WriteConflictError";
|
|
677
|
+
constructor(expectedVersion: number | null, actualVersion: number | null);
|
|
678
|
+
}
|
|
679
|
+
export declare class TransactionRecordConflictError extends Error {
|
|
680
|
+
readonly transactionId: string;
|
|
681
|
+
readonly expectedRevision: number;
|
|
682
|
+
readonly actualRevision: number | null;
|
|
683
|
+
readonly name = "TransactionRecordConflictError";
|
|
684
|
+
constructor(transactionId: string, expectedRevision: number, actualRevision: number | null);
|
|
685
|
+
}
|
|
686
|
+
export interface BlockWrite {
|
|
687
|
+
id: string;
|
|
688
|
+
bytes: Uint8Array;
|
|
689
|
+
}
|
|
690
|
+
export interface TempRunPage {
|
|
691
|
+
ownerId: string;
|
|
692
|
+
runId: string;
|
|
693
|
+
pageIndex: number;
|
|
694
|
+
bytes: Uint8Array;
|
|
695
|
+
}
|
|
696
|
+
export interface TempOwnerRecord {
|
|
697
|
+
ownerId: string;
|
|
698
|
+
expiresAt: string;
|
|
699
|
+
revision: number;
|
|
700
|
+
}
|
|
701
|
+
export declare class TempOwnerConflictError extends Error {
|
|
702
|
+
readonly ownerId: string;
|
|
703
|
+
readonly expectedRevision: number;
|
|
704
|
+
readonly actualRevision: number | null;
|
|
705
|
+
readonly name = "TempOwnerConflictError";
|
|
706
|
+
constructor(ownerId: string, expectedRevision: number, actualRevision: number | null);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* One coherent read of everything query preparation needs before touching blocks: the
|
|
710
|
+
* current manifest version, the named table records, every segment of the found tables,
|
|
711
|
+
* and the transaction records those segments reference. Stores that can produce this in
|
|
712
|
+
* one atomic read collapse the sequential per-record round trips a prepare would
|
|
713
|
+
* otherwise issue.
|
|
714
|
+
*/
|
|
715
|
+
export interface QueryCatalogState {
|
|
716
|
+
manifestVersion: number | null;
|
|
717
|
+
/** Positional per requested name; undefined where the table does not exist. */
|
|
718
|
+
tables: Array<TableRecord | undefined>;
|
|
719
|
+
/** Segments of the found tables, sorted by id like listSegments. */
|
|
720
|
+
segments: SegmentRecord[];
|
|
721
|
+
/** Records for the segments' transaction ids; missing records are omitted. */
|
|
722
|
+
transactions: TransactionRecord[];
|
|
723
|
+
/**
|
|
724
|
+
* The catalog epoch this state was read at, read in the same atomic storage transaction.
|
|
725
|
+
* Present when the store maintains an epoch (see `getCatalogProbe`); callers may cache the
|
|
726
|
+
* state and reuse it while a probe returns the same epoch.
|
|
727
|
+
*/
|
|
728
|
+
catalogEpoch?: number;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* The two change counters a reader needs to know whether anything it may have cached is
|
|
732
|
+
* still current, read together in one atomic storage transaction. `manifestVersion` moves on
|
|
733
|
+
* every data commit. `catalogEpoch` moves on every catalog mutation — table creation, table
|
|
734
|
+
* record updates (schema migration, full-text index stamps), and every manifest publish —
|
|
735
|
+
* so an unchanged epoch proves cached catalog state is byte-identical to a fresh read.
|
|
736
|
+
* Physical garbage collection does not move the epoch: it only deletes records that are
|
|
737
|
+
* already invisible at every leased version, so cached state stays result-equivalent.
|
|
738
|
+
*/
|
|
739
|
+
export interface CatalogProbe {
|
|
740
|
+
manifestVersion: number | null;
|
|
741
|
+
catalogEpoch: number;
|
|
742
|
+
}
|
|
743
|
+
export interface BlockStore {
|
|
744
|
+
addBlock(id: string, bytes: Uint8Array): Promise<void>;
|
|
745
|
+
addBlocks(blocks: readonly BlockWrite[]): Promise<void>;
|
|
746
|
+
getBlock(id: string): Promise<Uint8Array | undefined>;
|
|
747
|
+
getBlocks(ids: readonly string[]): Promise<Array<Uint8Array | undefined>>;
|
|
748
|
+
removeBlock(id: string): Promise<void>;
|
|
749
|
+
listBlockIds(): Promise<string[]>;
|
|
750
|
+
addTable(record: TableRecord): Promise<void>;
|
|
751
|
+
getTable(id: string): Promise<TableRecord | undefined>;
|
|
752
|
+
getTableByName(name: string): Promise<TableRecord | undefined>;
|
|
753
|
+
listTables(): Promise<TableRecord[]>;
|
|
754
|
+
updateTable(id: string, expectedRevision: number, update: {
|
|
755
|
+
columns?: TableColumnRecord[];
|
|
756
|
+
/** Replaces the full-text index state map; null clears it. */
|
|
757
|
+
ftsColumns?: Record<string, FtsColumnIndexRecord> | null;
|
|
758
|
+
/** Replaces the trigger list; null clears it. */
|
|
759
|
+
triggers?: TriggerRecord[] | null;
|
|
760
|
+
}): Promise<TableRecord>;
|
|
761
|
+
/**
|
|
762
|
+
* Removes a table's catalog record together with everything else keyed to it: its segments,
|
|
763
|
+
* its full-text base chunks and commit deltas, its unique-key membership, and its row-id and
|
|
764
|
+
* autoincrement counters. One step, so a crash cannot leave a segment pointing at a table
|
|
765
|
+
* that no longer exists. Advances the catalog epoch, and fails with a
|
|
766
|
+
* `TableRecordConflictError` on a revision mismatch, like `updateTable`.
|
|
767
|
+
*
|
|
768
|
+
* The table's blocks are the caller's business: they are retired by superseding them in a
|
|
769
|
+
* commit, which leaves the bytes for the lease-aware collector rather than deleting data a
|
|
770
|
+
* pinned reader may still be reading.
|
|
771
|
+
*/
|
|
772
|
+
removeTable(id: string, expectedRevision: number): Promise<void>;
|
|
773
|
+
/**
|
|
774
|
+
* Replaces one column's full-text base chunks (term-range partitioned, term-sorted within
|
|
775
|
+
* each chunk) and deletes commit deltas the new base covers. The caller flips the catalog
|
|
776
|
+
* state separately via updateTable; orphaned chunks from a lost race are overwritten by the
|
|
777
|
+
* next build.
|
|
778
|
+
*/
|
|
779
|
+
writeFtsBase(tableId: string, columnId: string, input: {
|
|
780
|
+
coversVersion: number;
|
|
781
|
+
chunks: FtsPosting[][];
|
|
782
|
+
totalTokens: number;
|
|
783
|
+
}): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Per-term candidate row IDs from the base chunks plus every commit delta at or below
|
|
786
|
+
* `upToVersion`, with the column's merged token total for exact BM25 statistics. Prefix
|
|
787
|
+
* terms match the term range [term, term + ""). Reports the merged delta-chunk count so
|
|
788
|
+
* callers can schedule a rebuild when the tail grows, and the base's covered version —
|
|
789
|
+
* a concurrent rebuild can publish a base ahead of a reader's snapshot, and a caller
|
|
790
|
+
* needing snapshot-exact statistics must detect `coversVersion > upToVersion` and fall
|
|
791
|
+
* back (candidates stay a safe superset either way).
|
|
792
|
+
*/
|
|
793
|
+
readFtsCandidates(tableId: string, columnId: string, terms: ReadonlyArray<{
|
|
794
|
+
term: string;
|
|
795
|
+
prefix: boolean;
|
|
796
|
+
}>, upToVersion: number): Promise<FtsCandidates & {
|
|
797
|
+
deltaChunkCount: number;
|
|
798
|
+
totalTokens: number;
|
|
799
|
+
coversVersion: number;
|
|
800
|
+
}>;
|
|
801
|
+
addSegment(record: SegmentRecord): Promise<void>;
|
|
802
|
+
getSegment(id: string): Promise<SegmentRecord | undefined>;
|
|
803
|
+
listSegments(tableId?: string): Promise<SegmentRecord[]>;
|
|
804
|
+
removeSegment(id: string): Promise<void>;
|
|
805
|
+
reserveRowIds(tableId: string, count: number): Promise<RowIdRange>;
|
|
806
|
+
/**
|
|
807
|
+
* Atomically reserves `count` auto-increment values for the column, first bumping the
|
|
808
|
+
* counter to at least `atLeast`. `count` may be 0 for a pure bump past explicit values.
|
|
809
|
+
* Reservations are never returned; aborted transactions leave gaps.
|
|
810
|
+
*/
|
|
811
|
+
reserveAutoIncrement(tableId: string, columnId: string, count: number, atLeast?: bigint): Promise<RowIdRange>;
|
|
812
|
+
getExistingUniqueKeys(tableId: string, keyTokens: readonly string[]): Promise<string[]>;
|
|
813
|
+
getCurrentManifest(): Promise<Manifest | undefined>;
|
|
814
|
+
/** The current version alone, without materializing the manifest's block list. */
|
|
815
|
+
getCurrentManifestVersion(): Promise<number | null>;
|
|
816
|
+
/**
|
|
817
|
+
* Optional: the current manifest version and catalog epoch in one atomic read. This is the
|
|
818
|
+
* freshness probe: an unchanged pair proves any cached catalog state is still exactly what
|
|
819
|
+
* a fresh read would return. Callers that find this absent must not cache catalog state.
|
|
820
|
+
*/
|
|
821
|
+
getCatalogProbe?(): Promise<CatalogProbe>;
|
|
822
|
+
/**
|
|
823
|
+
* Optional: one atomic catalog read for query preparation. Implementations must return
|
|
824
|
+
* the same records the individual getTableByName/listSegments/getTransactions calls
|
|
825
|
+
* would; callers fall back to those calls when this is absent.
|
|
826
|
+
*/
|
|
827
|
+
getQueryCatalogState?(tableNames: readonly string[]): Promise<QueryCatalogState>;
|
|
828
|
+
getManifest(version: number): Promise<Manifest | undefined>;
|
|
829
|
+
listManifests(): Promise<Manifest[]>;
|
|
830
|
+
listManifestPage(afterVersion: number | null, limit: number): Promise<StoragePage<Manifest, number>>;
|
|
831
|
+
publishManifest(input: PublishManifestInput): Promise<Manifest>;
|
|
832
|
+
createTransaction(record: TransactionRecord): Promise<void>;
|
|
833
|
+
/**
|
|
834
|
+
* Optional: reads the current manifest version, creates the transaction record pinned to it,
|
|
835
|
+
* and optionally reserves row ids, all in one atomic storage transaction — one round trip
|
|
836
|
+
* instead of three. Callers fall back to the individual calls when this is absent.
|
|
837
|
+
*/
|
|
838
|
+
beginTransaction?(input: BeginTransactionInput): Promise<BeginTransactionResult>;
|
|
839
|
+
getTransaction(id: string): Promise<TransactionRecord | undefined>;
|
|
840
|
+
getTransactions(ids: readonly string[]): Promise<Array<TransactionRecord | undefined>>;
|
|
841
|
+
listTransactions(): Promise<TransactionRecord[]>;
|
|
842
|
+
listTransactionPage(afterId: string | null, limit: number): Promise<StoragePage<TransactionRecord, string>>;
|
|
843
|
+
updateTransaction(id: string, expectedRevision: number, update: TransactionRecordUpdate): Promise<TransactionRecord>;
|
|
844
|
+
/**
|
|
845
|
+
* Optional: stages blocks and segments and journals them on the transaction record in one
|
|
846
|
+
* atomic storage transaction. Must be equivalent to addBlocks + addSegment(s) + one
|
|
847
|
+
* updateTransaction appending the new ids, with no intermediate state observable after a
|
|
848
|
+
* crash. Callers fall back to those calls when this is absent.
|
|
849
|
+
*/
|
|
850
|
+
stageTransactionArtifacts?(input: StageTransactionArtifactsInput): Promise<TransactionRecord>;
|
|
851
|
+
/** Publishes the next version; the summary omits the block list, which commits never need. */
|
|
852
|
+
commitTransaction(input: CommitTransactionInput): Promise<ManifestSummary>;
|
|
853
|
+
createLease(record: LeaseRecord): Promise<void>;
|
|
854
|
+
getLease(id: string): Promise<LeaseRecord | undefined>;
|
|
855
|
+
listLeases(): Promise<LeaseRecord[]>;
|
|
856
|
+
renewLease(id: string, expectedRevision: number, expiresAt: string): Promise<LeaseRecord>;
|
|
857
|
+
removeLeaseIfExpired(id: string, expectedRevision: number, expiresAtCutoff: string): Promise<boolean>;
|
|
858
|
+
removeLease(id: string): Promise<void>;
|
|
859
|
+
createCompactionJob(record: CompactionJobRecord): Promise<void>;
|
|
860
|
+
getCompactionJob(id: string): Promise<CompactionJobRecord | undefined>;
|
|
861
|
+
listCompactionJobs(tableId?: string): Promise<CompactionJobRecord[]>;
|
|
862
|
+
listCompactionJobPage(afterId: string | null, limit: number): Promise<StoragePage<CompactionJobRecord, string>>;
|
|
863
|
+
updateCompactionJob(id: string, expectedRevision: number, update: CompactionJobRecordUpdate): Promise<CompactionJobRecord>;
|
|
864
|
+
cancelCompactionJob(id: string, expectedRevision: number, cancelledAt: string): Promise<CompactionJobRecord>;
|
|
865
|
+
removeCompactionJob(id: string): Promise<void>;
|
|
866
|
+
createGarbageCollectionJob(input: CreateGarbageCollectionJobInput): Promise<GarbageCollectionJobRecord>;
|
|
867
|
+
getGarbageCollectionJob(id: string): Promise<GarbageCollectionJobRecord | undefined>;
|
|
868
|
+
listGarbageCollectionJobs(): Promise<GarbageCollectionJobRecord[]>;
|
|
869
|
+
runGarbageCollectionStep(input: RunGarbageCollectionStepInput): Promise<GarbageCollectionStepResult>;
|
|
870
|
+
removeGarbageCollectionJob(id: string): Promise<void>;
|
|
871
|
+
putTempRunPage(page: TempRunPage): Promise<void>;
|
|
872
|
+
getTempRunPage(ownerId: string, runId: string, pageIndex: number): Promise<Uint8Array | undefined>;
|
|
873
|
+
removeTempRun(ownerId: string, runId: string): Promise<void>;
|
|
874
|
+
removeTempOwner(ownerId: string): Promise<void>;
|
|
875
|
+
createTempOwner(record: TempOwnerRecord): Promise<void>;
|
|
876
|
+
getTempOwner(ownerId: string): Promise<TempOwnerRecord | undefined>;
|
|
877
|
+
renewTempOwner(ownerId: string, expectedRevision: number, expiresAt: string): Promise<TempOwnerRecord>;
|
|
878
|
+
removeTempOwnerIfExpired(ownerId: string, expiresAtCutoff: string): Promise<boolean>;
|
|
879
|
+
listTempOwnerIdsPage(afterOwnerId: string | null, limit: number): Promise<StoragePage<string, string>>;
|
|
880
|
+
close(): void;
|
|
881
|
+
}
|
|
882
|
+
export declare function createManifest(input: PublishManifestInput): Manifest;
|
|
883
|
+
/**
|
|
884
|
+
* Normalizes the additive L2 partition metadata while preserving legacy segment records verbatim.
|
|
885
|
+
*/
|
|
886
|
+
export declare function normalizeSegmentRecord(record: SegmentRecord): SegmentRecord;
|
|
887
|
+
export declare function updateTransactionRecord(record: TransactionRecord, update: TransactionRecordUpdate): TransactionRecord;
|
|
888
|
+
export declare function createGarbageCollectionJobRecord(input: CreateGarbageCollectionJobInput): GarbageCollectionJobRecord;
|
|
889
|
+
export declare function normalizeGarbageCollectionJobRecord(record: GarbageCollectionJobRecord): GarbageCollectionJobRecord;
|
|
890
|
+
export declare function advanceGarbageCollectionJobRecord(record: GarbageCollectionJobRecord, accounting: GarbageCollectionStepAccounting): GarbageCollectionJobRecord;
|
|
891
|
+
export declare function normalizeCompactionJobRecord(record: CompactionJobRecord): CompactionJobRecord;
|
|
892
|
+
export declare function updateCompactionJobRecord(record: CompactionJobRecord, update: CompactionJobRecordUpdate): CompactionJobRecord;
|
|
893
|
+
/** Floors an integer-times-double product without rounding the binary double upward. */
|
|
894
|
+
export declare function floorWholeNumberProduct(left: number, right: number, label: string): number;
|
|
895
|
+
//# sourceMappingURL=types.d.ts.map
|