@tanstack/db-sqlite-persistence-core 0.2.0 → 0.2.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.
- 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/src/persisted.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
compileSingleRowExpression,
|
|
3
|
+
safeRandomUUID,
|
|
4
|
+
toBooleanPredicate,
|
|
5
|
+
} from '@tanstack/db'
|
|
2
6
|
import {
|
|
3
7
|
InvalidPersistedCollectionConfigError,
|
|
4
8
|
InvalidPersistedCollectionCoordinatorError,
|
|
@@ -440,7 +444,7 @@ type SyncControlFns<T extends object, TKey extends string | number> = {
|
|
|
440
444
|
export class SingleProcessCoordinator implements PersistedCollectionCoordinator {
|
|
441
445
|
private readonly nodeId: string
|
|
442
446
|
|
|
443
|
-
constructor(nodeId: string =
|
|
447
|
+
constructor(nodeId: string = safeRandomUUID()) {
|
|
444
448
|
this.nodeId = nodeId
|
|
445
449
|
}
|
|
446
450
|
|
|
@@ -467,7 +471,7 @@ export class SingleProcessCoordinator implements PersistedCollectionCoordinator
|
|
|
467
471
|
public pullSince(): Promise<PullSinceResponse> {
|
|
468
472
|
return Promise.resolve({
|
|
469
473
|
type: `rpc:pullSince:res`,
|
|
470
|
-
rpcId:
|
|
474
|
+
rpcId: safeRandomUUID(),
|
|
471
475
|
ok: true,
|
|
472
476
|
latestTerm: 1,
|
|
473
477
|
latestSeq: 0,
|
|
@@ -1387,7 +1391,7 @@ class PersistedCollectionRuntime<
|
|
|
1387
1391
|
this.createTxCommittedPayload({
|
|
1388
1392
|
term: streamPosition.term,
|
|
1389
1393
|
seq: streamPosition.seq,
|
|
1390
|
-
txId:
|
|
1394
|
+
txId: safeRandomUUID(),
|
|
1391
1395
|
latestRowVersion: streamPosition.rowVersion,
|
|
1392
1396
|
changedRows: [],
|
|
1393
1397
|
deletedKeys: [],
|
|
@@ -1427,7 +1431,7 @@ class PersistedCollectionRuntime<
|
|
|
1427
1431
|
streamPosition: { term: number; seq: number; rowVersion: number },
|
|
1428
1432
|
): PersistedTx {
|
|
1429
1433
|
return {
|
|
1430
|
-
txId:
|
|
1434
|
+
txId: safeRandomUUID(),
|
|
1431
1435
|
term: streamPosition.term,
|
|
1432
1436
|
seq: streamPosition.seq,
|
|
1433
1437
|
rowVersion: streamPosition.rowVersion,
|
|
@@ -1471,7 +1475,7 @@ class PersistedCollectionRuntime<
|
|
|
1471
1475
|
streamPosition: { term: number; seq: number; rowVersion: number },
|
|
1472
1476
|
): PersistedTx {
|
|
1473
1477
|
return {
|
|
1474
|
-
txId:
|
|
1478
|
+
txId: safeRandomUUID(),
|
|
1475
1479
|
term: streamPosition.term,
|
|
1476
1480
|
seq: streamPosition.seq,
|
|
1477
1481
|
rowVersion: streamPosition.rowVersion,
|
|
@@ -2607,7 +2611,7 @@ export function persistedCollectionOptions<
|
|
|
2607
2611
|
|
|
2608
2612
|
const { schemaVersion, ...syncOptions } = options
|
|
2609
2613
|
const collectionId =
|
|
2610
|
-
syncOptions.id ?? `persisted-collection:${
|
|
2614
|
+
syncOptions.id ?? `persisted-collection:${safeRandomUUID()}`
|
|
2611
2615
|
const persistence = resolvePersistenceForCollection(
|
|
2612
2616
|
syncOptions.persistence,
|
|
2613
2617
|
{
|
|
@@ -2635,7 +2639,7 @@ export function persistedCollectionOptions<
|
|
|
2635
2639
|
|
|
2636
2640
|
const { schemaVersion, ...localOnlyOptions } = options
|
|
2637
2641
|
const collectionId =
|
|
2638
|
-
localOnlyOptions.id ?? `persisted-collection:${
|
|
2642
|
+
localOnlyOptions.id ?? `persisted-collection:${safeRandomUUID()}`
|
|
2639
2643
|
const persistence = resolvePersistenceForCollection(
|
|
2640
2644
|
localOnlyOptions.persistence,
|
|
2641
2645
|
{
|