@minnowdb/core 0.2.1 → 0.4.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/README.md +23 -32
- package/dist/block-format/block.d.ts +32 -13
- package/dist/block-format/block.js +179 -55
- package/dist/block-format/checksum.d.ts +2 -1
- package/dist/block-format/checksum.js +5 -2
- package/dist/block-format/codecs.d.ts +7 -2
- package/dist/block-format/codecs.js +53 -12
- package/dist/block-format/column.d.ts +3 -2
- package/dist/block-format/column.js +96 -30
- package/dist/block-format/index.d.ts +2 -2
- package/dist/block-format/index.js +2 -2
- package/dist/block-format/physical.d.ts +8 -2
- package/dist/block-format/physical.js +14 -6
- package/dist/block-format/types.d.ts +7 -3
- package/dist/block-format/types.js +0 -1
- package/dist/block-format/unicode.d.ts +11 -0
- package/dist/block-format/unicode.js +46 -0
- package/dist/date-value.d.ts +15 -0
- package/dist/date-value.js +64 -0
- package/dist/engine/artifact-cache.d.ts +2 -1
- package/dist/engine/artifact-cache.js +5 -1
- package/dist/engine/batch.d.ts +11 -3
- package/dist/engine/batch.js +17 -7
- package/dist/engine/buffered-writer.d.ts +2 -1
- package/dist/engine/buffered-writer.js +34 -9
- package/dist/engine/cache-limits.d.ts +25 -0
- package/dist/engine/cache-limits.js +25 -0
- package/dist/engine/catalog.d.ts +24 -5
- package/dist/engine/catalog.js +34 -7
- package/dist/engine/client.d.ts +29 -7
- package/dist/engine/client.js +216 -40
- package/dist/engine/database.d.ts +224 -39
- package/dist/engine/database.js +7475 -1539
- package/dist/engine/defaults.d.ts +4 -8
- package/dist/engine/defaults.js +46 -22
- package/dist/engine/errors.d.ts +19 -1
- package/dist/engine/errors.js +32 -2
- package/dist/engine/fts.d.ts +0 -6
- package/dist/engine/fts.js +41 -14
- package/dist/engine/group-index.d.ts +0 -1
- package/dist/engine/group-index.js +6 -11
- package/dist/engine/index.d.ts +16 -10
- package/dist/engine/index.js +12 -9
- package/dist/engine/join-index.d.ts +0 -1
- package/dist/engine/join-index.js +2 -2
- package/dist/engine/keyed-live.d.ts +57 -0
- package/dist/engine/keyed-live.js +226 -0
- package/dist/engine/live-api.d.ts +4 -0
- package/dist/engine/live-api.js +4 -0
- package/dist/engine/live.d.ts +43 -26
- package/dist/engine/live.js +504 -126
- package/dist/engine/memory.d.ts +2 -1
- package/dist/engine/memory.js +3 -2
- package/dist/engine/optimizer.d.ts +0 -1
- package/dist/engine/optimizer.js +262 -27
- package/dist/engine/query-api.d.ts +3 -0
- package/dist/engine/query-api.js +3 -0
- package/dist/engine/query-cache.d.ts +1 -2
- package/dist/engine/query-cache.js +7 -5
- package/dist/engine/query.d.ts +134 -29
- package/dist/engine/query.js +1668 -372
- package/dist/engine/result-wire.d.ts +0 -1
- package/dist/engine/result-wire.js +2 -2
- package/dist/engine/schema-wire.d.ts +6 -3
- package/dist/engine/schema-wire.js +40 -34
- package/dist/engine/schema.d.ts +156 -80
- package/dist/engine/schema.js +570 -108
- package/dist/engine/sort-keys.d.ts +4 -4
- package/dist/engine/sort-keys.js +44 -29
- package/dist/engine/sql-domains.d.ts +31 -0
- package/dist/engine/sql-domains.js +585 -0
- package/dist/engine/sql-driver.d.ts +19 -0
- package/dist/engine/sql-driver.js +1 -0
- package/dist/engine/sql-json.d.ts +7 -9
- package/dist/engine/sql-json.js +75 -15
- package/dist/engine/sql-semantics.d.ts +8 -3
- package/dist/engine/sql-semantics.js +458 -30
- package/dist/engine/typed-live.d.ts +67 -0
- package/dist/engine/typed-live.js +349 -0
- package/dist/engine/vector.d.ts +12 -2
- package/dist/engine/vector.js +635 -119
- package/dist/engine/worker-host.d.ts +9 -2
- package/dist/engine/worker-host.js +620 -152
- package/dist/engine/worker.d.ts +0 -1
- package/dist/engine/worker.js +3 -3
- package/dist/engine/write-block-planner.d.ts +18 -0
- package/dist/engine/write-block-planner.js +112 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/plan/index.d.ts +3 -4
- package/dist/plan/index.js +3 -4
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/indexeddb.d.ts +99 -51
- package/dist/storage/indexeddb.js +13448 -2660
- package/dist/storage/memory.d.ts +64 -57
- package/dist/storage/memory.js +1042 -128
- package/dist/storage/opfs/files.d.ts +18 -7
- package/dist/storage/opfs/files.js +115 -28
- package/dist/storage/opfs/index.d.ts +1 -1
- package/dist/storage/opfs/index.js +1 -1
- package/dist/storage/opfs/leader.d.ts +409 -75
- package/dist/storage/opfs/leader.js +4621 -650
- package/dist/storage/opfs/rpc.d.ts +15 -3
- package/dist/storage/opfs/rpc.js +224 -2
- package/dist/storage/opfs/snapshot-ledger.d.ts +40 -0
- package/dist/storage/opfs/snapshot-ledger.js +281 -0
- package/dist/storage/opfs/store.d.ts +33 -99
- package/dist/storage/opfs/store.js +453 -364
- package/dist/storage/persistence.d.ts +37 -0
- package/dist/storage/persistence.js +78 -0
- package/dist/storage/snapshot-stream.d.ts +24 -0
- package/dist/storage/snapshot-stream.js +897 -0
- package/dist/storage/snapshot.d.ts +9 -85
- package/dist/storage/snapshot.js +33 -265
- package/dist/storage/toolkit/extents.d.ts +41 -7
- package/dist/storage/toolkit/extents.js +402 -39
- package/dist/storage/toolkit/index.d.ts +4 -5
- package/dist/storage/toolkit/index.js +28 -4
- package/dist/storage/toolkit/record-core.d.ts +182 -55
- package/dist/storage/toolkit/record-core.js +6158 -1331
- package/dist/storage/toolkit/sync-file.d.ts +10 -1
- package/dist/storage/toolkit/sync-file.js +50 -2
- package/dist/storage/toolkit/wal.d.ts +23 -5
- package/dist/storage/toolkit/wal.js +89 -27
- package/dist/storage/toolkit/wire.d.ts +15 -2
- package/dist/storage/toolkit/wire.js +199 -10
- package/dist/storage/types.d.ts +1439 -204
- package/dist/storage/types.js +1745 -141
- package/dist/testing/block-store-conformance.d.ts +0 -1
- package/dist/testing/block-store-conformance.js +1009 -119
- package/dist/testing/index.d.ts +46 -26
- package/dist/testing/index.js +112 -57
- package/dist/testing/opfs-shim.d.ts +13 -3
- package/dist/testing/opfs-shim.js +40 -6
- package/dist/testing/simulator.d.ts +97 -0
- package/dist/testing/simulator.js +591 -0
- package/dist/testing/sqllogictest.d.ts +89 -0
- package/dist/testing/sqllogictest.js +434 -0
- package/dist/transactions/index.d.ts +92 -16
- package/dist/transactions/index.js +1074 -236
- package/dist/worker-protocol/index.d.ts +3 -2
- package/dist/worker-protocol/index.js +2 -5
- package/package.json +53 -3
- package/postgres-feature-profile.json +223 -0
- package/sql-feature-matrix.json +172 -252
- package/dist/block-format/block.d.ts.map +0 -1
- package/dist/block-format/block.js.map +0 -1
- package/dist/block-format/checksum.d.ts.map +0 -1
- package/dist/block-format/checksum.js.map +0 -1
- package/dist/block-format/codecs.d.ts.map +0 -1
- package/dist/block-format/codecs.js.map +0 -1
- package/dist/block-format/column.d.ts.map +0 -1
- package/dist/block-format/column.js.map +0 -1
- package/dist/block-format/index.d.ts.map +0 -1
- package/dist/block-format/index.js.map +0 -1
- package/dist/block-format/physical.d.ts.map +0 -1
- package/dist/block-format/physical.js.map +0 -1
- package/dist/block-format/types.d.ts.map +0 -1
- package/dist/block-format/types.js.map +0 -1
- package/dist/engine/artifact-cache.d.ts.map +0 -1
- package/dist/engine/artifact-cache.js.map +0 -1
- package/dist/engine/batch.d.ts.map +0 -1
- package/dist/engine/batch.js.map +0 -1
- package/dist/engine/buffered-writer.d.ts.map +0 -1
- package/dist/engine/buffered-writer.js.map +0 -1
- package/dist/engine/catalog.d.ts.map +0 -1
- package/dist/engine/catalog.js.map +0 -1
- package/dist/engine/client.d.ts.map +0 -1
- package/dist/engine/client.js.map +0 -1
- package/dist/engine/coordinator.d.ts +0 -17
- package/dist/engine/coordinator.d.ts.map +0 -1
- package/dist/engine/coordinator.js +0 -60
- package/dist/engine/coordinator.js.map +0 -1
- package/dist/engine/database.d.ts.map +0 -1
- package/dist/engine/database.js.map +0 -1
- package/dist/engine/defaults.d.ts.map +0 -1
- package/dist/engine/defaults.js.map +0 -1
- package/dist/engine/errors.d.ts.map +0 -1
- package/dist/engine/errors.js.map +0 -1
- package/dist/engine/fts.d.ts.map +0 -1
- package/dist/engine/fts.js.map +0 -1
- package/dist/engine/group-index.d.ts.map +0 -1
- package/dist/engine/group-index.js.map +0 -1
- package/dist/engine/index.d.ts.map +0 -1
- package/dist/engine/index.js.map +0 -1
- package/dist/engine/join-index.d.ts.map +0 -1
- package/dist/engine/join-index.js.map +0 -1
- package/dist/engine/live.d.ts.map +0 -1
- package/dist/engine/live.js.map +0 -1
- package/dist/engine/memory.d.ts.map +0 -1
- package/dist/engine/memory.js.map +0 -1
- package/dist/engine/optimizer.d.ts.map +0 -1
- package/dist/engine/optimizer.js.map +0 -1
- package/dist/engine/query-cache.d.ts.map +0 -1
- package/dist/engine/query-cache.js.map +0 -1
- package/dist/engine/query.d.ts.map +0 -1
- package/dist/engine/query.js.map +0 -1
- package/dist/engine/result-wire.d.ts.map +0 -1
- package/dist/engine/result-wire.js.map +0 -1
- package/dist/engine/schema-wire.d.ts.map +0 -1
- package/dist/engine/schema-wire.js.map +0 -1
- package/dist/engine/schema.d.ts.map +0 -1
- package/dist/engine/schema.js.map +0 -1
- package/dist/engine/sort-keys.d.ts.map +0 -1
- package/dist/engine/sort-keys.js.map +0 -1
- package/dist/engine/sql-json.d.ts.map +0 -1
- package/dist/engine/sql-json.js.map +0 -1
- package/dist/engine/sql-semantics.d.ts.map +0 -1
- package/dist/engine/sql-semantics.js.map +0 -1
- package/dist/engine/vector.d.ts.map +0 -1
- package/dist/engine/vector.js.map +0 -1
- package/dist/engine/worker-host.d.ts.map +0 -1
- package/dist/engine/worker-host.js.map +0 -1
- package/dist/engine/worker.d.ts.map +0 -1
- package/dist/engine/worker.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plan/index.d.ts.map +0 -1
- package/dist/plan/index.js.map +0 -1
- package/dist/storage/fixture-shape.d.ts +0 -42
- package/dist/storage/fixture-shape.d.ts.map +0 -1
- package/dist/storage/fixture-shape.js +0 -146
- package/dist/storage/fixture-shape.js.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/indexeddb.d.ts.map +0 -1
- package/dist/storage/indexeddb.js.map +0 -1
- package/dist/storage/memory.d.ts.map +0 -1
- package/dist/storage/memory.js.map +0 -1
- package/dist/storage/opfs/files.d.ts.map +0 -1
- package/dist/storage/opfs/files.js.map +0 -1
- package/dist/storage/opfs/index.d.ts.map +0 -1
- package/dist/storage/opfs/index.js.map +0 -1
- package/dist/storage/opfs/leader.d.ts.map +0 -1
- package/dist/storage/opfs/leader.js.map +0 -1
- package/dist/storage/opfs/rpc.d.ts.map +0 -1
- package/dist/storage/opfs/rpc.js.map +0 -1
- package/dist/storage/opfs/store.d.ts.map +0 -1
- package/dist/storage/opfs/store.js.map +0 -1
- package/dist/storage/snapshot.d.ts.map +0 -1
- package/dist/storage/snapshot.js.map +0 -1
- package/dist/storage/toolkit/extents.d.ts.map +0 -1
- package/dist/storage/toolkit/extents.js.map +0 -1
- package/dist/storage/toolkit/index.d.ts.map +0 -1
- package/dist/storage/toolkit/index.js.map +0 -1
- package/dist/storage/toolkit/record-core.d.ts.map +0 -1
- package/dist/storage/toolkit/record-core.js.map +0 -1
- package/dist/storage/toolkit/sync-file.d.ts.map +0 -1
- package/dist/storage/toolkit/sync-file.js.map +0 -1
- package/dist/storage/toolkit/wal.d.ts.map +0 -1
- package/dist/storage/toolkit/wal.js.map +0 -1
- package/dist/storage/toolkit/wire.d.ts.map +0 -1
- package/dist/storage/toolkit/wire.js.map +0 -1
- package/dist/storage/types.d.ts.map +0 -1
- package/dist/storage/types.js.map +0 -1
- package/dist/testing/block-store-conformance.d.ts.map +0 -1
- package/dist/testing/block-store-conformance.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/opfs-shim.d.ts.map +0 -1
- package/dist/testing/opfs-shim.js.map +0 -1
- package/dist/testing/seeds.d.ts +0 -11
- package/dist/testing/seeds.d.ts.map +0 -1
- package/dist/testing/seeds.js +0 -50
- package/dist/testing/seeds.js.map +0 -1
- package/dist/transactions/index.d.ts.map +0 -1
- package/dist/transactions/index.js.map +0 -1
- package/dist/worker-protocol/index.d.ts.map +0 -1
- package/dist/worker-protocol/index.js.map +0 -1
package/dist/engine/worker.d.ts
CHANGED
package/dist/engine/worker.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* module worker at it and connect a MinnowDatabaseClient — the client's init frame carries the
|
|
5
5
|
* store descriptor and options, so this entry needs no configuration of its own:
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* // db-worker.ts: import "@minnowdb/core/worker";
|
|
8
|
+
* new Worker(new URL("./db-worker.ts", import.meta.url), { type: "module" })
|
|
8
9
|
*
|
|
9
10
|
* For non-cloneable construction options (custom store, `now`, `createId`), write your own entry
|
|
10
|
-
* and
|
|
11
|
+
* and import `exposeDatabase()` from `@minnowdb/core/worker-host` instead.
|
|
11
12
|
*/
|
|
12
13
|
import { attachDatabaseWorker } from "./worker-host.js";
|
|
13
14
|
attachDatabaseWorker(self);
|
|
14
|
-
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type LogicalType } from "../block-format/index.js";
|
|
2
|
+
export interface WriteColumnValues {
|
|
3
|
+
readonly type: LogicalType;
|
|
4
|
+
readonly values: readonly unknown[];
|
|
5
|
+
readonly stringByteLengths?: readonly number[];
|
|
6
|
+
}
|
|
7
|
+
export interface WriteBlockRange {
|
|
8
|
+
readonly start: number;
|
|
9
|
+
readonly end: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Plans aligned row groups for every column in one segment. The row-wise accumulator visits each
|
|
13
|
+
* string value once, plus at most one overflow recheck at a block boundary, so a late wide column
|
|
14
|
+
* cannot make its siblings rescan the rest of the batch for every output block.
|
|
15
|
+
*/
|
|
16
|
+
export declare function planAlignedWriteBlockRanges(columns: readonly WriteColumnValues[], rowCount: number, maximumRows: number, targetBytes: number, measureString?: (value: string) => number): WriteBlockRange[];
|
|
17
|
+
/** Conservative first estimate used by both physical compaction planners. */
|
|
18
|
+
export declare function estimateCompactionRowsPerOutput(targetBlockBytes: number, maximumEncodedBytesPerRow: number): number;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { MAX_BLOCK_ROW_COUNT, physicalColumnByteLength, wellFormedUtf8ByteLength, } from "../block-format/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Plans aligned row groups for every column in one segment. The row-wise accumulator visits each
|
|
4
|
+
* string value once, plus at most one overflow recheck at a block boundary, so a late wide column
|
|
5
|
+
* cannot make its siblings rescan the rest of the batch for every output block.
|
|
6
|
+
*/
|
|
7
|
+
export function planAlignedWriteBlockRanges(columns, rowCount, maximumRows, targetBytes, measureString = wellFormedUtf8ByteLength) {
|
|
8
|
+
if (rowCount === 0)
|
|
9
|
+
return [];
|
|
10
|
+
if (!Number.isSafeInteger(maximumRows) || maximumRows <= 0 || maximumRows > MAX_BLOCK_ROW_COUNT) {
|
|
11
|
+
throw new RangeError("Maximum rows per write block exceeds the format limit");
|
|
12
|
+
}
|
|
13
|
+
for (const column of columns) {
|
|
14
|
+
if (column.values.length !== rowCount) {
|
|
15
|
+
throw new RangeError("Column lengths must match while planning write blocks");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let maximumRowsPerRange = maximumRows;
|
|
19
|
+
const stringColumns = [];
|
|
20
|
+
for (const column of columns) {
|
|
21
|
+
if (column.type === "string")
|
|
22
|
+
stringColumns.push(column);
|
|
23
|
+
else {
|
|
24
|
+
maximumRowsPerRange = Math.min(maximumRowsPerRange, maximumFixedWidthRows(column.type, maximumRows, targetBytes));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ranges = [];
|
|
28
|
+
if (stringColumns.length === 0) {
|
|
29
|
+
// Fixed-width sizes depend only on row count. Do not add a value-reading pass to numeric and
|
|
30
|
+
// boolean writes: calculate the cap once and emit the arithmetic ranges directly.
|
|
31
|
+
for (let start = 0; start < rowCount; start += maximumRowsPerRange) {
|
|
32
|
+
ranges.push({ start, end: Math.min(rowCount, start + maximumRowsPerRange) });
|
|
33
|
+
}
|
|
34
|
+
return ranges;
|
|
35
|
+
}
|
|
36
|
+
for (let start = 0; start < rowCount;) {
|
|
37
|
+
const rowLimit = Math.min(rowCount, start + maximumRowsPerRange);
|
|
38
|
+
const stringContentBytes = new Array(stringColumns.length).fill(0);
|
|
39
|
+
let end = start;
|
|
40
|
+
for (let row = start; row < rowLimit; row += 1) {
|
|
41
|
+
const count = row - start + 1;
|
|
42
|
+
let fitsTarget = true;
|
|
43
|
+
for (let columnIndex = 0; columnIndex < stringColumns.length; columnIndex += 1) {
|
|
44
|
+
const column = stringColumns[columnIndex];
|
|
45
|
+
if (column === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
let contentBytes = stringContentBytes[columnIndex] ?? 0;
|
|
48
|
+
const value = column.values[row];
|
|
49
|
+
if (value !== null) {
|
|
50
|
+
if (typeof value !== "string") {
|
|
51
|
+
throw new TypeError("String column contains a non-string");
|
|
52
|
+
}
|
|
53
|
+
contentBytes += column.stringByteLengths?.[row] ?? measureString(value);
|
|
54
|
+
stringContentBytes[columnIndex] = contentBytes;
|
|
55
|
+
}
|
|
56
|
+
if (physicalColumnBytesUnchecked("string", count, contentBytes) > targetBytes) {
|
|
57
|
+
fitsTarget = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!fitsTarget && count > 1)
|
|
61
|
+
break;
|
|
62
|
+
if (!fitsTarget) {
|
|
63
|
+
// The target is soft for one wide row, but the format ceiling is always hard. Validate
|
|
64
|
+
// every string column's exact one-row size before allowing that row to make progress.
|
|
65
|
+
for (let columnIndex = 0; columnIndex < stringColumns.length; columnIndex += 1) {
|
|
66
|
+
physicalColumnByteLength("string", 1, stringContentBytes[columnIndex] ?? 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
end = row + 1;
|
|
70
|
+
if (!fitsTarget)
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (end <= start)
|
|
74
|
+
throw new Error("Write block planner made no progress");
|
|
75
|
+
ranges.push({ start, end });
|
|
76
|
+
start = end;
|
|
77
|
+
}
|
|
78
|
+
return ranges;
|
|
79
|
+
}
|
|
80
|
+
function maximumFixedWidthRows(type, maximumRows, targetBytes) {
|
|
81
|
+
if (physicalColumnBytesUnchecked(type, maximumRows, 0) <= targetBytes)
|
|
82
|
+
return maximumRows;
|
|
83
|
+
if (physicalColumnBytesUnchecked(type, 1, 0) > targetBytes)
|
|
84
|
+
return 1;
|
|
85
|
+
let low = 1;
|
|
86
|
+
let high = maximumRows;
|
|
87
|
+
while (low < high) {
|
|
88
|
+
const middle = Math.ceil((low + high) / 2);
|
|
89
|
+
if (physicalColumnBytesUnchecked(type, middle, 0) <= targetBytes)
|
|
90
|
+
low = middle;
|
|
91
|
+
else
|
|
92
|
+
high = middle - 1;
|
|
93
|
+
}
|
|
94
|
+
return low;
|
|
95
|
+
}
|
|
96
|
+
/** Conservative first estimate used by both physical compaction planners. */
|
|
97
|
+
export function estimateCompactionRowsPerOutput(targetBlockBytes, maximumEncodedBytesPerRow) {
|
|
98
|
+
return Math.max(1, Math.min(MAX_BLOCK_ROW_COUNT, Math.floor(targetBlockBytes / maximumEncodedBytesPerRow)));
|
|
99
|
+
}
|
|
100
|
+
/** Exact physical size without applying the 64 MiB hard limit during range search. */
|
|
101
|
+
function physicalColumnBytesUnchecked(type, rowCount, stringContentBytes) {
|
|
102
|
+
const validityBytes = Math.ceil(rowCount / 8);
|
|
103
|
+
switch (type) {
|
|
104
|
+
case "boolean":
|
|
105
|
+
return validityBytes * 2;
|
|
106
|
+
case "number":
|
|
107
|
+
case "datetime":
|
|
108
|
+
return validityBytes + rowCount * 8;
|
|
109
|
+
case "string":
|
|
110
|
+
return validityBytes + (rowCount + 1) * 4 + stringContentBytes;
|
|
111
|
+
}
|
|
112
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/plan/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The plan-construction primitives, published so a typed
|
|
2
|
+
* The plan-construction primitives, published so a typed query layer can be built externally.
|
|
3
3
|
*
|
|
4
4
|
* A query builder's whole job is to assemble the same logical plan the SQL parser assembles, and
|
|
5
5
|
* then hand it to the engine. That requires the plan's types, the block-assembly functions the
|
|
6
6
|
* parser itself ends in, and the validators that keep a hand-built plan as strict as a parsed one.
|
|
7
|
-
* Exposing them here
|
|
8
|
-
*
|
|
7
|
+
* Exposing them here lets an external builder produce plans the engine treats as indistinguishable
|
|
8
|
+
* from parsed SQL.
|
|
9
9
|
*
|
|
10
10
|
* This module re-exports rather than owns: the plan types still live beside the parser that
|
|
11
11
|
* produces them. Splitting them into a leaf module of their own is the next step, and it will not
|
|
@@ -14,4 +14,3 @@
|
|
|
14
14
|
export { assembleSelectBlock, compoundSelectBlock, derivedTableSource, hasAggregate, splitCondition, validateLimit, validateOffset, type AggregateName, type CompiledQuery, type CompiledStatement, type Expression, type JoinPlan, type Predicate, type PredicateOperator, type QueryResult, type QueryRow, type QueryValue, type SelectItem, type SetOperator, type TableSource, type WindowFunctionName, } from "../engine/query.js";
|
|
15
15
|
export { optimizePlan, renderPlan } from "../engine/optimizer.js";
|
|
16
16
|
export { validateFtsQuery } from "../engine/fts.js";
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/plan/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The plan-construction primitives, published so a typed
|
|
2
|
+
* The plan-construction primitives, published so a typed query layer can be built externally.
|
|
3
3
|
*
|
|
4
4
|
* A query builder's whole job is to assemble the same logical plan the SQL parser assembles, and
|
|
5
5
|
* then hand it to the engine. That requires the plan's types, the block-assembly functions the
|
|
6
6
|
* parser itself ends in, and the validators that keep a hand-built plan as strict as a parsed one.
|
|
7
|
-
* Exposing them here
|
|
8
|
-
*
|
|
7
|
+
* Exposing them here lets an external builder produce plans the engine treats as indistinguishable
|
|
8
|
+
* from parsed SQL.
|
|
9
9
|
*
|
|
10
10
|
* This module re-exports rather than owns: the plan types still live beside the parser that
|
|
11
11
|
* produces them. Splitting them into a leaf module of their own is the next step, and it will not
|
|
@@ -14,4 +14,3 @@
|
|
|
14
14
|
export { assembleSelectBlock, compoundSelectBlock, derivedTableSource, hasAggregate, splitCondition, validateLimit, validateOffset, } from "../engine/query.js";
|
|
15
15
|
export { optimizePlan, renderPlan } from "../engine/optimizer.js";
|
|
16
16
|
export { validateFtsQuery } from "../engine/fts.js";
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/dist/storage/index.d.ts
CHANGED
package/dist/storage/index.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { type BeginTransactionInput, type BeginTransactionResult, type CommitTransactionInput, type CompactionJobRecord, type CompactionJobRecordUpdate, type CreateGarbageCollectionJobInput, type BlockStore, type
|
|
2
|
-
import { type DatabaseSnapshot, type SnapshotLoadProgress } from "./snapshot.js";
|
|
1
|
+
import { type AbortTransactionIfExpiredInput, type AdoptAbortedSegmentInput, type BeginTransactionInput, type BeginTransactionResult, type BeginSnapshotFrameExportInput, type BeginSnapshotFrameImportInput, type BeginPostingBuildInput, type RenewPostingBuildInput, type AppendPostingBuildChunkInput, type FinishPostingBuildInput, type AbortPostingBuildInput, type ReadSnapshotExportFrameInput, type SnapshotFrameExportSession, type SnapshotFrameImportSession, type RenewSnapshotFrameImportInput, type AppendSnapshotImportFramesInput, type FinishSnapshotFrameImportInput, type SnapshotFrame, type CloseSnapshotExportInput, type CancelSnapshotImportInput, type CommitTransactionInput, type DropTableColumnInput, type DropTableInput, type CompactionJobRecord, type CompactionJobRecordUpdate, type CreateGarbageCollectionJobInput, type BlockStore, type CatalogProbe, type CatalogMutationOptions, type UniqueKeyBuildRecord, type BeginUniqueKeyBuildInput, type AppendUniqueKeyBuildChunkInput, type FinishUniqueKeyBuildInput, type RenewUniqueKeyBuildInput, type AbortUniqueKeyBuildInput, type FtsCandidates, type FtsPostingQuery, type FtsPosting, type GarbageCollectionJobRecord, type GarbageCollectionStepResult, type LeaseRecord, type Manifest, type ListManifestBlockPageInput, type ListRetiredManifestBlockPageInput, type ManifestBlockPage, type ManifestSummary, type RenewTransactionInput, type RenewLeaseInput, type MoveLeaseInput, type RowIdRange, type RollbackTransactionArtifactsInput, type InterruptedSnapshotImport, type InterruptedSnapshotImportAbortResult, type StorageIntegrityReport, type StorageStats, type RunGarbageCollectionStepInput, type UpdateGarbageCollectionPlanningInput, type SegmentRecord, type QueryCatalogState, type StageTransactionArtifactsInput, type StoragePage, type TableRecord, type TableRecordUpdate, type TempOwnerRecord, type RenewTempOwnerInput, type TempRunPage, type TransactionRecord, type TransactionRecordUpdate, type WriteTransactionInput } from "./types.js";
|
|
3
2
|
export interface IndexedDbBlockStoreOptions {
|
|
4
3
|
name: string;
|
|
5
4
|
durability?: IDBTransactionDurability;
|
|
6
5
|
indexedDB?: IDBFactory;
|
|
6
|
+
/**
|
|
7
|
+
* Modeled bytes allowed for the optional complete unique-key membership cache. The cache
|
|
8
|
+
* accelerates bulk loads but is never required for correctness; `0` disables it. Defaults to
|
|
9
|
+
* 8 MiB so a table's row count cannot silently become an unbounded resident-memory cost.
|
|
10
|
+
*/
|
|
11
|
+
uniqueKeyCacheBytes?: number;
|
|
7
12
|
}
|
|
8
13
|
export declare class IndexedDbBlockStore implements BlockStore {
|
|
9
14
|
#private;
|
|
15
|
+
readonly liveQueryChannelName: string;
|
|
10
16
|
private constructor();
|
|
11
17
|
static open(options: IndexedDbBlockStoreOptions): Promise<IndexedDbBlockStore>;
|
|
12
|
-
addBlock(id: string, bytes: Uint8Array): Promise<void>;
|
|
13
|
-
addBlocks(blocks: readonly BlockWrite[]): Promise<void>;
|
|
14
18
|
getBlock(id: string): Promise<Uint8Array | undefined>;
|
|
15
19
|
getBlocks(ids: readonly string[]): Promise<Array<Uint8Array | undefined>>;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
readManifestBlock(version: number | null, id: string): Promise<Uint8Array | undefined>;
|
|
21
|
+
hasManifestBlocks(version: number | null, ids: readonly string[]): Promise<boolean[]>;
|
|
22
|
+
listManifestBlockPage(input: ListManifestBlockPageInput): Promise<ManifestBlockPage>;
|
|
23
|
+
listRetiredManifestBlockPage(input: ListRetiredManifestBlockPageInput): Promise<ManifestBlockPage>;
|
|
18
24
|
putTempRunPage(page: TempRunPage): Promise<void>;
|
|
19
25
|
putTempRunPages(pages: readonly TempRunPage[]): Promise<void>;
|
|
20
26
|
getTempRunPage(ownerId: string, runId: string, pageIndex: number): Promise<Uint8Array | undefined>;
|
|
@@ -22,29 +28,45 @@ export declare class IndexedDbBlockStore implements BlockStore {
|
|
|
22
28
|
removeTempOwner(ownerId: string): Promise<void>;
|
|
23
29
|
createTempOwner(record: TempOwnerRecord): Promise<void>;
|
|
24
30
|
getTempOwner(ownerId: string): Promise<TempOwnerRecord | undefined>;
|
|
25
|
-
renewTempOwner(
|
|
31
|
+
renewTempOwner(input: RenewTempOwnerInput): Promise<TempOwnerRecord>;
|
|
26
32
|
removeTempOwnerIfExpired(ownerId: string, expiresAtCutoff: string): Promise<boolean>;
|
|
27
33
|
listTempOwnerIdsPage(afterOwnerId: string | null, limit: number): Promise<StoragePage<string, string>>;
|
|
28
|
-
|
|
34
|
+
listExpiredTempOwnerPage(expiresAtCutoff: string, afterCursor: string | null, limit: number): Promise<StoragePage<string, string>>;
|
|
35
|
+
addTable(record: TableRecord, options?: CatalogMutationOptions): Promise<void>;
|
|
29
36
|
getTable(id: string): Promise<TableRecord | undefined>;
|
|
30
|
-
updateTable(id: string, expectedRevision: number, update:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
updateTable(id: string, expectedRevision: number, update: TableRecordUpdate): Promise<TableRecord>;
|
|
38
|
+
beginUniqueKeyBuild(input: BeginUniqueKeyBuildInput): Promise<UniqueKeyBuildRecord>;
|
|
39
|
+
getUniqueKeyBuild(buildId: string): Promise<UniqueKeyBuildRecord | undefined>;
|
|
40
|
+
renewUniqueKeyBuild(input: RenewUniqueKeyBuildInput): Promise<UniqueKeyBuildRecord>;
|
|
41
|
+
appendUniqueKeyBuildChunk(input: AppendUniqueKeyBuildChunkInput): Promise<UniqueKeyBuildRecord>;
|
|
42
|
+
finishUniqueKeyBuild(input: FinishUniqueKeyBuildInput): Promise<TableRecord>;
|
|
43
|
+
abortUniqueKeyBuild(input: AbortUniqueKeyBuildInput): Promise<boolean>;
|
|
44
|
+
removeTable(id: string, expectedRevision: number, options?: CatalogMutationOptions): Promise<void>;
|
|
45
|
+
dropTable(input: DropTableInput): Promise<ManifestSummary>;
|
|
46
|
+
dropTableColumn(input: DropTableColumnInput): Promise<ManifestSummary>;
|
|
36
47
|
writeFtsBase(tableId: string, columnId: string, input: {
|
|
37
48
|
coversVersion: number;
|
|
38
49
|
chunks: FtsPosting[][];
|
|
39
50
|
totalTokens: number;
|
|
40
51
|
}): Promise<void>;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
beginFtsBaseBuild(input: BeginPostingBuildInput): Promise<void>;
|
|
53
|
+
renewFtsBaseBuild(input: RenewPostingBuildInput): Promise<void>;
|
|
54
|
+
writeFtsBaseBuildChunk(input: AppendPostingBuildChunkInput): Promise<void>;
|
|
55
|
+
finishFtsBaseBuild(input: FinishPostingBuildInput): Promise<void>;
|
|
56
|
+
abortFtsBaseBuild(input: AbortPostingBuildInput): Promise<void>;
|
|
57
|
+
removeFtsColumn(tableId: string, columnId: string): Promise<void>;
|
|
58
|
+
readFtsCandidates(tableId: string, columnId: string, terms: readonly FtsPostingQuery[], upToVersion: number, maxRowIds?: number): Promise<FtsCandidates & {
|
|
45
59
|
deltaChunkCount: number;
|
|
46
60
|
totalTokens: number;
|
|
47
61
|
coversVersion: number;
|
|
62
|
+
hasBase: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
readFtsPostings(tableId: string, columnId: string, upToVersion: number, maxRowIds?: number, maxRetainedBytes?: number): Promise<{
|
|
65
|
+
postings: FtsPosting[];
|
|
66
|
+
overflow: boolean;
|
|
67
|
+
deltaChunkCount: number;
|
|
68
|
+
coversVersion: number;
|
|
69
|
+
hasBase: boolean;
|
|
48
70
|
}>;
|
|
49
71
|
/**
|
|
50
72
|
* Resolving a name means two reads — name to id, then id to record — and the second cannot
|
|
@@ -56,10 +78,17 @@ export declare class IndexedDbBlockStore implements BlockStore {
|
|
|
56
78
|
*/
|
|
57
79
|
getTableByName(name: string): Promise<TableRecord | undefined>;
|
|
58
80
|
listTables(): Promise<TableRecord[]>;
|
|
59
|
-
addSegment(record: SegmentRecord): Promise<void>;
|
|
60
81
|
getSegment(id: string): Promise<SegmentRecord | undefined>;
|
|
61
|
-
|
|
62
|
-
|
|
82
|
+
listSegmentPage(afterId: string | null, limit: number): Promise<{
|
|
83
|
+
records: SegmentRecord[];
|
|
84
|
+
nextCursor: string | null;
|
|
85
|
+
}>;
|
|
86
|
+
listTableSegmentPage(tableId: string, afterId: string | null, limit: number): Promise<{
|
|
87
|
+
records: SegmentRecord[];
|
|
88
|
+
nextCursor: string | null;
|
|
89
|
+
}>;
|
|
90
|
+
removeAbortedSegment(segmentId: string, expectedTransactionId: string): Promise<boolean>;
|
|
91
|
+
adoptAbortedSegment(input: AdoptAbortedSegmentInput): Promise<TransactionRecord>;
|
|
63
92
|
reserveRowIds(tableId: string, count: number): Promise<RowIdRange>;
|
|
64
93
|
reserveAutoIncrement(tableId: string, columnId: string, count: number, atLeast?: bigint): Promise<RowIdRange>;
|
|
65
94
|
getExistingUniqueKeys(tableId: string, keyTokens: readonly string[]): Promise<string[]>;
|
|
@@ -73,35 +102,42 @@ export declare class IndexedDbBlockStore implements BlockStore {
|
|
|
73
102
|
* events, so an abort surfaces as a rejection here instead of hanging.
|
|
74
103
|
*/
|
|
75
104
|
getCatalogProbe(): Promise<CatalogProbe>;
|
|
76
|
-
getQueryCatalogState(
|
|
105
|
+
getQueryCatalogState(names: readonly string[]): Promise<QueryCatalogState>;
|
|
77
106
|
getCurrentManifest(): Promise<Manifest | undefined>;
|
|
78
107
|
getManifest(version: number): Promise<Manifest | undefined>;
|
|
79
|
-
listManifests(): Promise<Manifest[]>;
|
|
80
108
|
listManifestPage(afterVersion: number | null, limit: number): Promise<{
|
|
81
|
-
records:
|
|
109
|
+
records: ManifestSummary[];
|
|
82
110
|
nextCursor: number | null;
|
|
83
111
|
}>;
|
|
84
|
-
publishManifest(input: PublishManifestInput): Promise<Manifest>;
|
|
85
112
|
beginTransaction(input: BeginTransactionInput): Promise<BeginTransactionResult>;
|
|
86
113
|
createTransaction(record: TransactionRecord): Promise<void>;
|
|
87
114
|
getTransaction(id: string): Promise<TransactionRecord | undefined>;
|
|
88
115
|
getTransactions(ids: readonly string[]): Promise<Array<TransactionRecord | undefined>>;
|
|
89
|
-
listTransactions(): Promise<TransactionRecord[]>;
|
|
90
116
|
listTransactionPage(afterId: string | null, limit: number): Promise<{
|
|
91
117
|
records: TransactionRecord[];
|
|
92
118
|
nextCursor: string | null;
|
|
93
119
|
}>;
|
|
94
120
|
updateTransaction(id: string, expectedRevision: number, update: TransactionRecordUpdate): Promise<TransactionRecord>;
|
|
121
|
+
renewTransaction(input: RenewTransactionInput): Promise<boolean>;
|
|
122
|
+
abortTransactionIfExpired(input: AbortTransactionIfExpiredInput): Promise<TransactionRecord | undefined>;
|
|
95
123
|
stageTransactionArtifacts(input: StageTransactionArtifactsInput): Promise<TransactionRecord>;
|
|
124
|
+
rollbackTransactionArtifacts(input: RollbackTransactionArtifactsInput): Promise<TransactionRecord>;
|
|
96
125
|
commitTransaction(input: CommitTransactionInput): Promise<ManifestSummary>;
|
|
97
126
|
writeTransaction(input: WriteTransactionInput): Promise<ManifestSummary>;
|
|
98
127
|
createLease(record: LeaseRecord): Promise<void>;
|
|
99
128
|
getLease(id: string): Promise<LeaseRecord | undefined>;
|
|
100
129
|
listLeases(): Promise<LeaseRecord[]>;
|
|
101
|
-
|
|
102
|
-
|
|
130
|
+
listExpiredLeasePage(expiresAtCutoff: string, afterCursor: string | null, limit: number): Promise<{
|
|
131
|
+
records: LeaseRecord[];
|
|
132
|
+
nextCursor: string | null;
|
|
133
|
+
}>;
|
|
134
|
+
renewLease(input: RenewLeaseInput): Promise<LeaseRecord>;
|
|
135
|
+
moveLease(input: MoveLeaseInput): Promise<LeaseRecord>;
|
|
103
136
|
removeLeaseIfExpired(id: string, expectedRevision: number, expiresAtCutoff: string): Promise<boolean>;
|
|
104
|
-
removeLease(
|
|
137
|
+
removeLease(input: {
|
|
138
|
+
id: string;
|
|
139
|
+
ownerId: string;
|
|
140
|
+
}): Promise<boolean>;
|
|
105
141
|
createCompactionJob(record: CompactionJobRecord): Promise<void>;
|
|
106
142
|
getCompactionJob(id: string): Promise<CompactionJobRecord | undefined>;
|
|
107
143
|
listCompactionJobs(tableId?: string): Promise<CompactionJobRecord[]>;
|
|
@@ -111,33 +147,45 @@ export declare class IndexedDbBlockStore implements BlockStore {
|
|
|
111
147
|
}>;
|
|
112
148
|
updateCompactionJob(id: string, expectedRevision: number, update: CompactionJobRecordUpdate): Promise<CompactionJobRecord>;
|
|
113
149
|
cancelCompactionJob(id: string, expectedRevision: number, cancelledAt: string): Promise<CompactionJobRecord>;
|
|
114
|
-
removeCompactionJob(id: string): Promise<
|
|
150
|
+
removeCompactionJob(id: string): Promise<boolean>;
|
|
115
151
|
createGarbageCollectionJob(input: CreateGarbageCollectionJobInput): Promise<GarbageCollectionJobRecord>;
|
|
152
|
+
updateGarbageCollectionPlanning(input: UpdateGarbageCollectionPlanningInput): Promise<GarbageCollectionJobRecord>;
|
|
116
153
|
getGarbageCollectionJob(id: string): Promise<GarbageCollectionJobRecord | undefined>;
|
|
117
154
|
listGarbageCollectionJobs(): Promise<GarbageCollectionJobRecord[]>;
|
|
155
|
+
listGarbageCollectionJobPage(afterId: string | null, limit: number): Promise<{
|
|
156
|
+
records: GarbageCollectionJobRecord[];
|
|
157
|
+
nextCursor: string | null;
|
|
158
|
+
}>;
|
|
118
159
|
runGarbageCollectionStep(input: RunGarbageCollectionStepInput): Promise<GarbageCollectionStepResult>;
|
|
119
|
-
removePrunedManifestRecords(): Promise<number>;
|
|
160
|
+
removePrunedManifestRecords(maxItems: number): Promise<number>;
|
|
120
161
|
removeGarbageCollectionJob(id: string): Promise<void>;
|
|
121
162
|
getLogicalStorageBytes(): Promise<number>;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
onProgress?: (progress: SnapshotLoadProgress) => void;
|
|
140
|
-
}): Promise<void>;
|
|
163
|
+
inspectInterruptedImport(): Promise<InterruptedSnapshotImport | null>;
|
|
164
|
+
abortInterruptedImport(identity: string): Promise<InterruptedSnapshotImportAbortResult>;
|
|
165
|
+
getStorageStats(): Promise<StorageStats>;
|
|
166
|
+
checkIntegrity(options?: {
|
|
167
|
+
mode?: "metadata" | "full";
|
|
168
|
+
maxIssues?: number;
|
|
169
|
+
}): Promise<StorageIntegrityReport>;
|
|
170
|
+
/** Captures one immutable, framed view and its durable GC pin without reading payload bytes. */
|
|
171
|
+
beginSnapshotFrameExport(input: BeginSnapshotFrameExportInput): Promise<SnapshotFrameExportSession>;
|
|
172
|
+
/** Reads one frozen metadata page or one live-at-version payload and renews the pin atomically. */
|
|
173
|
+
readSnapshotExportFrame(input: ReadSnapshotExportFrameInput): Promise<SnapshotFrame | undefined>;
|
|
174
|
+
closeSnapshotFrameExport(input: CloseSnapshotExportInput): Promise<boolean>;
|
|
175
|
+
beginSnapshotFrameImport(input: BeginSnapshotFrameImportInput): Promise<SnapshotFrameImportSession>;
|
|
176
|
+
renewSnapshotFrameImport(input: RenewSnapshotFrameImportInput): Promise<SnapshotFrameImportSession>;
|
|
177
|
+
appendSnapshotImportFrames(input: AppendSnapshotImportFramesInput): Promise<SnapshotFrameImportSession>;
|
|
178
|
+
finishSnapshotFrameImport(input: FinishSnapshotFrameImportInput): Promise<void>;
|
|
179
|
+
cancelSnapshotFrameImport(input: CancelSnapshotImportInput): Promise<InterruptedSnapshotImportAbortResult>;
|
|
141
180
|
close(): void;
|
|
181
|
+
/** Test-only counters that make the adapter's retained-state bounds regression-testable. */
|
|
182
|
+
_residentStateForTests(): {
|
|
183
|
+
tableNameCacheEntries: number;
|
|
184
|
+
uniqueKeyCacheEntries: number;
|
|
185
|
+
uniqueKeyCacheBytes: number;
|
|
186
|
+
uniqueKeyCacheLimitBytes: number;
|
|
187
|
+
manifestCacheBlockIds: number;
|
|
188
|
+
snapshotPeakRetainedItems: number;
|
|
189
|
+
snapshotPeakRetainedBytes: number;
|
|
190
|
+
};
|
|
142
191
|
}
|
|
143
|
-
//# sourceMappingURL=indexeddb.d.ts.map
|