@tanstack/db-sqlite-persistence-core 0.2.0 → 0.2.1

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const persisted = require("./persisted.cjs");
4
4
  const errors = require("./errors.cjs");
5
5
  const sqliteCoreAdapter = require("./sqlite-core-adapter.cjs");
6
+ const db = require("@tanstack/db");
6
7
  exports.SingleProcessCoordinator = persisted.SingleProcessCoordinator;
7
8
  exports.createPersistedTableName = persisted.createPersistedTableName;
8
9
  exports.decodePersistedStorageKey = persisted.decodePersistedStorageKey;
@@ -21,4 +22,8 @@ exports.DEFAULT_APPLIED_TX_PRUNE_MAX_AGE_SECONDS = sqliteCoreAdapter.DEFAULT_APP
21
22
  exports.DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS = sqliteCoreAdapter.DEFAULT_APPLIED_TX_PRUNE_MAX_ROWS;
22
23
  exports.SQLiteCorePersistenceAdapter = sqliteCoreAdapter.SQLiteCorePersistenceAdapter;
23
24
  exports.createSQLiteCorePersistenceAdapter = sqliteCoreAdapter.createSQLiteCorePersistenceAdapter;
25
+ Object.defineProperty(exports, "safeRandomUUID", {
26
+ enumerable: true,
27
+ get: () => db.safeRandomUUID
28
+ });
24
29
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,4 @@
1
1
  export * from './persisted.cjs';
2
2
  export * from './errors.cjs';
3
3
  export * from './sqlite-core-adapter.cjs';
4
+ export { safeRandomUUID } from '@tanstack/db';
@@ -15,7 +15,7 @@ const TARGETED_INVALIDATION_KEY_LIMIT = 128;
15
15
  const DEFAULT_DB_NAME = `tanstack-db`;
16
16
  const REMOTE_ENSURE_RETRY_DELAY_MS = 50;
17
17
  class SingleProcessCoordinator {
18
- constructor(nodeId = crypto.randomUUID()) {
18
+ constructor(nodeId = db.safeRandomUUID()) {
19
19
  this.nodeId = nodeId;
20
20
  }
21
21
  getNodeId() {
@@ -39,7 +39,7 @@ class SingleProcessCoordinator {
39
39
  pullSince() {
40
40
  return Promise.resolve({
41
41
  type: `rpc:pullSince:res`,
42
- rpcId: crypto.randomUUID(),
42
+ rpcId: db.safeRandomUUID(),
43
43
  ok: true,
44
44
  latestTerm: 1,
45
45
  latestSeq: 0,
@@ -644,7 +644,7 @@ class PersistedCollectionRuntime {
644
644
  this.createTxCommittedPayload({
645
645
  term: streamPosition.term,
646
646
  seq: streamPosition.seq,
647
- txId: crypto.randomUUID(),
647
+ txId: db.safeRandomUUID(),
648
648
  latestRowVersion: streamPosition.rowVersion,
649
649
  changedRows: [],
650
650
  deletedKeys: [],
@@ -674,7 +674,7 @@ class PersistedCollectionRuntime {
674
674
  }
675
675
  createPersistedTxFromOperations(transaction, streamPosition) {
676
676
  return {
677
- txId: crypto.randomUUID(),
677
+ txId: db.safeRandomUUID(),
678
678
  term: streamPosition.term,
679
679
  seq: streamPosition.seq,
680
680
  rowVersion: streamPosition.rowVersion,
@@ -708,7 +708,7 @@ class PersistedCollectionRuntime {
708
708
  }
709
709
  createPersistedTxFromMutations(mutations, streamPosition) {
710
710
  return {
711
- txId: crypto.randomUUID(),
711
+ txId: db.safeRandomUUID(),
712
712
  term: streamPosition.term,
713
713
  seq: streamPosition.seq,
714
714
  rowVersion: streamPosition.rowVersion,
@@ -1559,7 +1559,7 @@ function persistedCollectionOptions(options) {
1559
1559
  );
1560
1560
  }
1561
1561
  const { schemaVersion: schemaVersion2, ...syncOptions } = options;
1562
- const collectionId2 = syncOptions.id ?? `persisted-collection:${crypto.randomUUID()}`;
1562
+ const collectionId2 = syncOptions.id ?? `persisted-collection:${db.safeRandomUUID()}`;
1563
1563
  const persistence2 = resolvePersistenceForCollection(
1564
1564
  syncOptions.persistence,
1565
1565
  {
@@ -1583,7 +1583,7 @@ function persistedCollectionOptions(options) {
1583
1583
  };
1584
1584
  }
1585
1585
  const { schemaVersion, ...localOnlyOptions } = options;
1586
- const collectionId = localOnlyOptions.id ?? `persisted-collection:${crypto.randomUUID()}`;
1586
+ const collectionId = localOnlyOptions.id ?? `persisted-collection:${db.safeRandomUUID()}`;
1587
1587
  const persistence = resolvePersistenceForCollection(
1588
1588
  localOnlyOptions.persistence,
1589
1589
  {