@minnowdb/core 0.7.0 → 0.7.2

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.
Files changed (96) hide show
  1. package/dist/block-format/block.js +254 -325
  2. package/dist/block-format/checksum.js +30 -52
  3. package/dist/block-format/codecs.js +112 -125
  4. package/dist/block-format/column.js +187 -205
  5. package/dist/block-format/index.js +5 -1
  6. package/dist/block-format/physical.js +371 -387
  7. package/dist/block-format/types.js +4 -1
  8. package/dist/block-format/unicode.js +30 -39
  9. package/dist/date-value.js +67 -78
  10. package/dist/engine/artifact-cache.js +106 -116
  11. package/dist/engine/batch.js +36 -44
  12. package/dist/engine/buffered-writer.js +156 -158
  13. package/dist/engine/byte-estimates.js +20 -22
  14. package/dist/engine/cache-limits.js +24 -25
  15. package/dist/engine/cancellation.js +5 -3
  16. package/dist/engine/catalog.js +64 -73
  17. package/dist/engine/client.js +715 -780
  18. package/dist/engine/database.js +15942 -19313
  19. package/dist/engine/defaults.js +104 -111
  20. package/dist/engine/errors.js +113 -128
  21. package/dist/engine/fts.js +233 -280
  22. package/dist/engine/group-index.js +287 -321
  23. package/dist/engine/index.js +23 -12
  24. package/dist/engine/join-index.js +177 -186
  25. package/dist/engine/keyed-live.js +168 -173
  26. package/dist/engine/live-api.js +0 -1
  27. package/dist/engine/live-equal.js +32 -37
  28. package/dist/engine/live.js +603 -647
  29. package/dist/engine/memory.js +109 -111
  30. package/dist/engine/optimizer.d.ts +19 -1
  31. package/dist/engine/optimizer.js +2691 -2933
  32. package/dist/engine/point-read.js +122 -182
  33. package/dist/engine/query-api.js +12 -3
  34. package/dist/engine/query-cache.js +61 -69
  35. package/dist/engine/query.d.ts +6 -0
  36. package/dist/engine/query.js +8511 -9980
  37. package/dist/engine/result-wire.js +221 -252
  38. package/dist/engine/schema-wire.js +97 -112
  39. package/dist/engine/schema.js +1099 -1254
  40. package/dist/engine/sort-keys.js +315 -389
  41. package/dist/engine/sql-domains.js +646 -769
  42. package/dist/engine/sql-driver.js +0 -1
  43. package/dist/engine/sql-functions.js +1031 -1125
  44. package/dist/engine/sql-json.js +199 -218
  45. package/dist/engine/sql-semantics.js +572 -639
  46. package/dist/engine/typed-live.js +271 -293
  47. package/dist/engine/vector.js +4484 -5145
  48. package/dist/engine/worker-host.d.ts +8 -63
  49. package/dist/engine/worker-host.js +28 -1130
  50. package/dist/engine/worker-indexeddb.d.ts +1 -0
  51. package/dist/engine/worker-indexeddb.js +3 -0
  52. package/dist/engine/worker-memory.d.ts +1 -0
  53. package/dist/engine/worker-memory.js +3 -0
  54. package/dist/engine/worker-opfs.d.ts +1 -0
  55. package/dist/engine/worker-opfs.js +3 -0
  56. package/dist/engine/worker-server.d.ts +93 -0
  57. package/dist/engine/worker-server.js +999 -0
  58. package/dist/engine/worker-store-indexeddb.d.ts +2 -0
  59. package/dist/engine/worker-store-indexeddb.js +11 -0
  60. package/dist/engine/worker-store-memory.d.ts +2 -0
  61. package/dist/engine/worker-store-memory.js +6 -0
  62. package/dist/engine/worker-store-opfs.d.ts +2 -0
  63. package/dist/engine/worker-store-opfs.js +9 -0
  64. package/dist/engine/worker.js +0 -12
  65. package/dist/engine/write-block-planner.js +93 -100
  66. package/dist/plan/index.js +15 -16
  67. package/dist/plan/model.d.ts +6 -0
  68. package/dist/plan/model.js +20 -27
  69. package/dist/storage/index.js +0 -12
  70. package/dist/storage/indexeddb.js +11784 -13171
  71. package/dist/storage/memory.js +1198 -1241
  72. package/dist/storage/opfs/files.js +238 -295
  73. package/dist/storage/opfs/index.js +9 -3
  74. package/dist/storage/opfs/leader.js +4386 -4856
  75. package/dist/storage/opfs/rpc.js +223 -259
  76. package/dist/storage/opfs/snapshot-ledger.js +219 -260
  77. package/dist/storage/opfs/store.js +884 -1003
  78. package/dist/storage/persistence.js +59 -74
  79. package/dist/storage/snapshot-stream.js +788 -826
  80. package/dist/storage/snapshot.js +36 -37
  81. package/dist/storage/toolkit/extents.js +444 -520
  82. package/dist/storage/toolkit/index.js +28 -29
  83. package/dist/storage/toolkit/record-core.js +5804 -6377
  84. package/dist/storage/toolkit/sync-file.js +34 -42
  85. package/dist/storage/toolkit/wal.js +92 -127
  86. package/dist/storage/toolkit/wire.js +232 -256
  87. package/dist/storage/types.js +2948 -3250
  88. package/dist/testing/block-store-conformance.js +1556 -1629
  89. package/dist/testing/index.js +310 -291
  90. package/dist/testing/opfs-shim.js +280 -312
  91. package/dist/testing/simulator.js +496 -534
  92. package/dist/testing/sqllogictest.js +425 -365
  93. package/dist/transactions/index.js +1464 -1712
  94. package/dist/worker-protocol/index.js +70 -69
  95. package/package.json +20 -2
  96. package/sql-feature-matrix.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { attachWorkerHost } from "./worker-server.js";
2
+ import { indexedDbWorkerStore } from "./worker-store-indexeddb.js";
3
+ attachWorkerHost(self, indexedDbWorkerStore);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { attachWorkerHost } from "./worker-server.js";
2
+ import { memoryWorkerStore } from "./worker-store-memory.js";
3
+ attachWorkerHost(self, memoryWorkerStore);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { attachWorkerHost } from "./worker-server.js";
2
+ import { opfsWorkerStore } from "./worker-store-opfs.js";
3
+ attachWorkerHost(self, opfsWorkerStore);
@@ -0,0 +1,93 @@
1
+ import type { BlockStore } from "../storage/types.js";
2
+ import { MinnowDatabase, type MinnowDatabaseOptions } from "./database.js";
3
+ /**
4
+ * Worker-side host for the main-thread client. exposeDatabase() answers the client's RPC frames
5
+ * against a database you construct yourself; attachWorkerHost() additionally owns construction,
6
+ * building the store from the cloneable descriptor in the client's init frame through the store
7
+ * factory it is given. The per-store worker entries (`@minnowdb/core/worker/{indexeddb,opfs,
8
+ * memory}`) call it with a factory that imports one adapter statically. The public
9
+ * `@minnowdb/core/worker-host` facade adds attachDatabaseWorker(), whose default factory names
10
+ * every adapter — which is why it lives in that module and not here: an entry importing this
11
+ * module carries only the adapter it names itself.
12
+ *
13
+ * Dispatch is a whitelist per target: the root database and each issued handle accept only the
14
+ * methods listed here, so arbitrary property access never crosses the channel.
15
+ */
16
+ export type StoreDescriptor = {
17
+ kind: "memory";
18
+ } | {
19
+ kind: "indexeddb";
20
+ name: string;
21
+ durability?: IDBTransactionDurability;
22
+ uniqueKeyCacheBytes?: number;
23
+ } | {
24
+ kind: "opfs";
25
+ name: string;
26
+ durability?: "relaxed" | "strict";
27
+ };
28
+ /** The cloneable subset of MinnowDatabaseOptions; function-valued seams stay worker-side. */
29
+ export type WireDatabaseOptions = Pick<MinnowDatabaseOptions, "compression" | "targetBlockBytes" | "rowsPerBlock" | "maxCommitRetries" | "spillOwnerLeaseMs" | "transactionOwnerLeaseMs" | "transactionIdleTimeoutMs" | "bufferPoolBytes" | "executionMemoryBudgetBytes" | "autoCollectDebtLimitCommits" | "autoCollect" | "autoCompact">;
30
+ export interface DatabaseInitPayload {
31
+ store: StoreDescriptor;
32
+ options?: WireDatabaseOptions;
33
+ }
34
+ /** The slice of DedicatedWorkerGlobalScope (or MessagePort) the host needs. */
35
+ export interface RpcScope {
36
+ addEventListener(type: "message", listener: (event: MessageEvent<unknown>) => void): void;
37
+ /**
38
+ * Query results arrive with their typed-array buffers listed for transfer; a scope that
39
+ * ignores the second argument still works, it just clones them.
40
+ */
41
+ postMessage(message: unknown, options?: {
42
+ transfer: ArrayBuffer[];
43
+ }): void;
44
+ }
45
+ export interface ExposeDatabaseOptions {
46
+ /** Called when the client sends its dispose frame, after every handle has been closed. */
47
+ onDispose?: () => void | Promise<void>;
48
+ /**
49
+ * Rolls back a worker write handle after this long without a handle RPC. Match the constructed
50
+ * database's `transactionIdleTimeoutMs` when it is customized. Defaults to 30 seconds.
51
+ */
52
+ writeHandleIdleTimeoutMs?: number;
53
+ /**
54
+ * Called when the main thread reports its page visibility. The stock entry forwards this to
55
+ * the store's `setForeground` when it has one — the OPFS store uses it to keep leadership
56
+ * on the tab the user is looking at.
57
+ */
58
+ onVisibility?: (visible: boolean) => void;
59
+ }
60
+ /** What a worker store factory may need beyond the descriptor itself. */
61
+ export interface WorkerStoreOptions {
62
+ /** Test seam for environments without a global IndexedDB (e.g. fake-indexeddb). */
63
+ indexedDB?: IDBFactory;
64
+ }
65
+ /**
66
+ * Builds the block store named by a client's init frame. The stock entry's factory loads the
67
+ * adapter for any of the three kinds on demand; a per-store entry supplies one that imports a
68
+ * single adapter statically and refuses the rest.
69
+ */
70
+ export type WorkerStoreFactory = (descriptor: StoreDescriptor, options: WorkerStoreOptions) => BlockStore | Promise<BlockStore>;
71
+ /** Hard per-connection ceiling for resident worker resources abandoned by a client. */
72
+ export declare const MAX_WORKER_HANDLES_PER_CONNECTION = 256;
73
+ /**
74
+ * Answers client RPC frames against a database you constructed yourself. Use this in a custom
75
+ * worker entry when you need non-cloneable construction options (a custom store, `now`,
76
+ * `createId`) — the client's init frame is acknowledged without reconstructing anything.
77
+ */
78
+ export declare function exposeDatabase(database: MinnowDatabase, scope: RpcScope, options?: ExposeDatabaseOptions): void;
79
+ /**
80
+ * Full worker-side wiring: waits for the client's init frame, builds the store it describes with
81
+ * `createStore`, constructs the database, and exposes it. The store is closed when the client
82
+ * disposes. A factory failure — including a refused store kind — fails the init call and leaves
83
+ * the worker ready for a retry.
84
+ */
85
+ export declare function attachWorkerHost(scope: RpcScope, createStore: WorkerStoreFactory, options?: WorkerStoreOptions): void;
86
+ /**
87
+ * A store factory that opens one kind of store and refuses every other init frame with an error
88
+ * naming the entry that does support it. The per-store worker entries are built from this; a
89
+ * custom entry may pass one to `attachDatabaseWorker()` when it must own the open call.
90
+ */
91
+ export declare function singleStoreFactory<Kind extends StoreDescriptor["kind"]>(kind: Kind, open: (descriptor: Extract<StoreDescriptor, {
92
+ kind: Kind;
93
+ }>, options: WorkerStoreOptions) => BlockStore | Promise<BlockStore>): WorkerStoreFactory;