@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.
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/persisted.cjs +7 -7
- package/dist/cjs/persisted.cjs.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/persisted.js +8 -8
- package/dist/esm/persisted.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/persisted.ts +12 -8
package/dist/esm/persisted.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compileSingleRowExpression, toBooleanPredicate } from "@tanstack/db";
|
|
1
|
+
import { safeRandomUUID, compileSingleRowExpression, toBooleanPredicate } from "@tanstack/db";
|
|
2
2
|
import { InvalidPersistedCollectionCoordinatorError, InvalidPersistedCollectionConfigError, InvalidSyncConfigError, InvalidPersistedStorageKeyError, InvalidPersistedStorageKeyEncodingError, InvalidPersistenceAdapterError } from "./errors.js";
|
|
3
3
|
const REQUIRED_COORDINATOR_METHODS = [
|
|
4
4
|
`getNodeId`,
|
|
@@ -13,7 +13,7 @@ const TARGETED_INVALIDATION_KEY_LIMIT = 128;
|
|
|
13
13
|
const DEFAULT_DB_NAME = `tanstack-db`;
|
|
14
14
|
const REMOTE_ENSURE_RETRY_DELAY_MS = 50;
|
|
15
15
|
class SingleProcessCoordinator {
|
|
16
|
-
constructor(nodeId =
|
|
16
|
+
constructor(nodeId = safeRandomUUID()) {
|
|
17
17
|
this.nodeId = nodeId;
|
|
18
18
|
}
|
|
19
19
|
getNodeId() {
|
|
@@ -37,7 +37,7 @@ class SingleProcessCoordinator {
|
|
|
37
37
|
pullSince() {
|
|
38
38
|
return Promise.resolve({
|
|
39
39
|
type: `rpc:pullSince:res`,
|
|
40
|
-
rpcId:
|
|
40
|
+
rpcId: safeRandomUUID(),
|
|
41
41
|
ok: true,
|
|
42
42
|
latestTerm: 1,
|
|
43
43
|
latestSeq: 0,
|
|
@@ -642,7 +642,7 @@ class PersistedCollectionRuntime {
|
|
|
642
642
|
this.createTxCommittedPayload({
|
|
643
643
|
term: streamPosition.term,
|
|
644
644
|
seq: streamPosition.seq,
|
|
645
|
-
txId:
|
|
645
|
+
txId: safeRandomUUID(),
|
|
646
646
|
latestRowVersion: streamPosition.rowVersion,
|
|
647
647
|
changedRows: [],
|
|
648
648
|
deletedKeys: [],
|
|
@@ -672,7 +672,7 @@ class PersistedCollectionRuntime {
|
|
|
672
672
|
}
|
|
673
673
|
createPersistedTxFromOperations(transaction, streamPosition) {
|
|
674
674
|
return {
|
|
675
|
-
txId:
|
|
675
|
+
txId: safeRandomUUID(),
|
|
676
676
|
term: streamPosition.term,
|
|
677
677
|
seq: streamPosition.seq,
|
|
678
678
|
rowVersion: streamPosition.rowVersion,
|
|
@@ -706,7 +706,7 @@ class PersistedCollectionRuntime {
|
|
|
706
706
|
}
|
|
707
707
|
createPersistedTxFromMutations(mutations, streamPosition) {
|
|
708
708
|
return {
|
|
709
|
-
txId:
|
|
709
|
+
txId: safeRandomUUID(),
|
|
710
710
|
term: streamPosition.term,
|
|
711
711
|
seq: streamPosition.seq,
|
|
712
712
|
rowVersion: streamPosition.rowVersion,
|
|
@@ -1557,7 +1557,7 @@ function persistedCollectionOptions(options) {
|
|
|
1557
1557
|
);
|
|
1558
1558
|
}
|
|
1559
1559
|
const { schemaVersion: schemaVersion2, ...syncOptions } = options;
|
|
1560
|
-
const collectionId2 = syncOptions.id ?? `persisted-collection:${
|
|
1560
|
+
const collectionId2 = syncOptions.id ?? `persisted-collection:${safeRandomUUID()}`;
|
|
1561
1561
|
const persistence2 = resolvePersistenceForCollection(
|
|
1562
1562
|
syncOptions.persistence,
|
|
1563
1563
|
{
|
|
@@ -1581,7 +1581,7 @@ function persistedCollectionOptions(options) {
|
|
|
1581
1581
|
};
|
|
1582
1582
|
}
|
|
1583
1583
|
const { schemaVersion, ...localOnlyOptions } = options;
|
|
1584
|
-
const collectionId = localOnlyOptions.id ?? `persisted-collection:${
|
|
1584
|
+
const collectionId = localOnlyOptions.id ?? `persisted-collection:${safeRandomUUID()}`;
|
|
1585
1585
|
const persistence = resolvePersistenceForCollection(
|
|
1586
1586
|
localOnlyOptions.persistence,
|
|
1587
1587
|
{
|