@minnowdb/core 0.10.0 → 0.10.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 (37) hide show
  1. package/dist/engine/auto-store.d.ts +15 -3
  2. package/dist/engine/auto-store.js +48 -6
  3. package/dist/engine/client.js +23 -7
  4. package/dist/engine/database.js +347 -862
  5. package/dist/engine/index-terms.js +627 -0
  6. package/dist/engine/index.d.ts +1 -1
  7. package/dist/engine/index.js +2 -1
  8. package/dist/engine/live-maintenance.js +220 -0
  9. package/dist/engine/schema.js +2 -1
  10. package/dist/engine/sql-functions.js +3 -2
  11. package/dist/engine/sql-quote.js +6 -0
  12. package/dist/engine/vector.js +1 -3
  13. package/dist/engine/worker-host.js +2 -0
  14. package/dist/engine/worker-server.js +4 -5
  15. package/dist/engine/worker-store-auto.js +2 -2
  16. package/dist/engine/write-coordinator.js +21 -1
  17. package/dist/storage/indexeddb.d.ts +18 -0
  18. package/dist/storage/indexeddb.js +293 -211
  19. package/dist/storage/opfs/coordination-helpers.js +54 -0
  20. package/dist/storage/opfs/index.d.ts +1 -1
  21. package/dist/storage/opfs/index.js +3 -2
  22. package/dist/storage/opfs/leader.js +44 -5
  23. package/dist/storage/opfs/rpc.js +3 -1
  24. package/dist/storage/opfs/store.d.ts +12 -0
  25. package/dist/storage/opfs/store.js +59 -12
  26. package/dist/storage/toolkit/wal.js +16 -0
  27. package/dist/storage/toolkit/wire.js +3 -3
  28. package/dist/storage/types.d.ts +35 -4
  29. package/dist/storage/types.js +17 -4
  30. package/dist/testing/block-store-conformance.js +40 -1
  31. package/dist/testing/index.d.ts +1 -0
  32. package/dist/testing/index.js +9 -0
  33. package/dist/testing/interaction-simulator.d.ts +319 -0
  34. package/dist/testing/interaction-simulator.js +1631 -0
  35. package/dist/transactions/index.d.ts +7 -0
  36. package/dist/transactions/index.js +17 -3
  37. package/package.json +4 -1
@@ -145,6 +145,13 @@ export declare class DatabaseTransaction {
145
145
  get compactionSourceBlockIds(): string[];
146
146
  /** Extends durable ownership; scope owners call this while user code is legitimately waiting. */
147
147
  renew(): Promise<void>;
148
+ /**
149
+ * Renews the lease and record only when a third of their lifetime has gone: an O(1) deadline
150
+ * check otherwise. A scope that buffers statement after statement stages nothing, so nothing
151
+ * renews inline, and a loop that never yields to the event loop never lets the heartbeat
152
+ * timer fire either — the buffered path calls this per statement instead.
153
+ */
154
+ renewIfDue(): Promise<void>;
148
155
  /**
149
156
  * Counts every registration this transaction carries: staged blocks and segments, unique-key
150
157
  * entries, full-text entries, and supersessions. A caller that fails part-way through a
@@ -1,5 +1,5 @@
1
1
  import { dateIsoString, dateMilliseconds } from "../date-value.js";
2
- import { assertTransactionArtifactBatchLimits, GarbageCollectionJobConflictError, LeaseConflictError, LeaseExpiredError, MAX_LEVEL_ZERO_SEGMENTS, MAX_MANIFEST_BLOCK_PRESENCE_IDS, MAX_LEASE_TTL_MS, MAX_TRANSACTION_STAGE_BLOCKS, MAX_TRANSACTION_STAGE_BYTES, MAX_TRANSACTION_STAGE_SEGMENTS, MAX_TRANSACTION_COMMIT_DELTA_BYTES, MAX_TRANSACTION_COMMIT_DELTA_ENTRIES, transactionCommitDeltaRetainedBytes, SnapshotManifestMissingError, TransactionRecordConflictError, WriteConflictError } from "../storage/types.js";
2
+ import { assertTransactionArtifactBatchLimits, GarbageCollectionJobConflictError, LeaseConflictError, LeaseExpiredError, MAX_LEVEL_ZERO_SEGMENTS, MAX_MANIFEST_BLOCK_PRESENCE_IDS, MAX_LEASE_TTL_MS, MAX_TRANSACTION_STAGE_BLOCKS, MAX_TRANSACTION_STAGE_BYTES, MAX_TRANSACTION_STAGE_SEGMENTS, MAX_TRANSACTION_COMMIT_DELTA_BYTES, MAX_TRANSACTION_COMMIT_DELTA_ENTRIES, transactionCommitDeltaRetainedBytes, SnapshotManifestMissingError, TransactionRecordConflictError, UnknownOutcomeError, WriteConflictError } from "../storage/types.js";
3
3
  const DEFAULT_TRANSACTION_TTL_MS = 3e4;
4
4
  class TransactionClosedError extends Error {
5
5
  transactionId;
@@ -233,6 +233,11 @@ class DatabaseTransaction {
233
233
  this.#assertActive();
234
234
  await this.#renewOwnership(true);
235
235
  }
236
+ async renewIfDue() {
237
+ if (this.#record.status !== "active")
238
+ return;
239
+ await this.#renewOwnership(false);
240
+ }
236
241
  get stagedWorkCount() {
237
242
  return this.pendingBlockCount + this.pendingSegmentCount + this.#uniqueKeyChanges.length + this.#ftsChanges.size + this.#compactionSourceBlockIds.size;
238
243
  }
@@ -406,7 +411,7 @@ class DatabaseTransaction {
406
411
  updatedAt: dateIsoString(this.now())
407
412
  });
408
413
  } catch (error) {
409
- await this.#recoverStagedAcknowledgement(error, blocks, segments);
414
+ this.#record = await this.#recoverStagedAcknowledgement(error, blocks, segments);
410
415
  }
411
416
  this.#journalAppended(previous, blocks.map((block) => block.id));
412
417
  }
@@ -912,7 +917,14 @@ class DatabaseTransaction {
912
917
  if (error instanceof SnapshotManifestMissingError) {
913
918
  throw new WriteConflictError(this.#record.snapshotVersion, await this.store.getCurrentManifestVersion());
914
919
  }
915
- throw error;
920
+ const persisted = await this.store.getTransaction(this.id).catch(() => void 0);
921
+ if (persisted?.status !== "active" || persisted.ownerId !== this.#record.ownerId || persisted.revision !== this.#record.revision || persisted.snapshotVersion !== this.#record.snapshotVersion || persisted.pendingBlockIds.length !== 0 || persisted.pendingSegmentIds.length !== 0) {
922
+ throw error;
923
+ }
924
+ this.#record = persisted;
925
+ this.#persisted = true;
926
+ if (!(error instanceof UnknownOutcomeError))
927
+ throw error;
916
928
  }
917
929
  this.#persisted = true;
918
930
  void this.#releaseSnapshotLease().catch(() => void 0);
@@ -1070,6 +1082,8 @@ class DatabaseTransaction {
1070
1082
  })) {
1071
1083
  this.#record = persisted;
1072
1084
  this.#persisted = true;
1085
+ if (error instanceof UnknownOutcomeError)
1086
+ return persisted;
1073
1087
  }
1074
1088
  }
1075
1089
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnowdb/core",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "A columnar SQL database for the browser: PostgreSQL-style SQL over durable IndexedDB or OPFS data, with no server or WebAssembly module.",
5
5
  "license": "MIT",
6
6
  "author": "Eric Wilhite",
@@ -149,6 +149,9 @@
149
149
  "!dist/engine/storage-test-helpers.*",
150
150
  "!dist/testing/seeds.*",
151
151
  "!dist/testing/oracle.*",
152
+ "!dist/engine/client-audit-harness.*",
153
+ "!dist/storage/indexeddb-audit-helpers.*",
154
+ "!dist/storage/opfs/power-loss-model.*",
152
155
  "!dist/*.tsbuildinfo",
153
156
  "sql-feature-matrix.json",
154
157
  "postgres-feature-profile.json"