@tanstack/db-sqlite-persistence-core 0.2.12 → 0.2.13
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/persisted.cjs +19 -2
- package/dist/cjs/persisted.cjs.map +1 -1
- package/dist/esm/persisted.js +20 -3
- package/dist/esm/persisted.js.map +1 -1
- package/package.json +2 -2
- package/src/persisted.ts +24 -2
package/dist/esm/persisted.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safeRandomUUID, compileSingleRowExpression, toBooleanPredicate } from "@tanstack/db";
|
|
1
|
+
import { safeRandomUUID, withCollectionConfigFactory, 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`,
|
|
@@ -539,6 +539,9 @@ class PersistedCollectionRuntime {
|
|
|
539
539
|
this.withInternalApply(() => {
|
|
540
540
|
this.syncControls.begin?.({ immediate: true });
|
|
541
541
|
for (const row of rows) {
|
|
542
|
+
if (this.collection?._hasHydratedKey(row.key)) {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
542
545
|
this.syncControls.write?.({
|
|
543
546
|
type: `update`,
|
|
544
547
|
value: row.value,
|
|
@@ -1580,12 +1583,19 @@ function persistedCollectionOptions(options) {
|
|
|
1580
1583
|
syncOptions.syncMode ?? `eager`,
|
|
1581
1584
|
collectionId2
|
|
1582
1585
|
);
|
|
1583
|
-
|
|
1586
|
+
const result2 = {
|
|
1584
1587
|
...syncOptions,
|
|
1585
1588
|
id: collectionId2,
|
|
1586
1589
|
sync: createWrappedSyncConfig(syncOptions.sync, runtime2),
|
|
1587
1590
|
persistence: persistence2
|
|
1588
1591
|
};
|
|
1592
|
+
return withCollectionConfigFactory(
|
|
1593
|
+
result2,
|
|
1594
|
+
() => persistedCollectionOptions({
|
|
1595
|
+
...options,
|
|
1596
|
+
id: collectionId2
|
|
1597
|
+
})
|
|
1598
|
+
);
|
|
1589
1599
|
}
|
|
1590
1600
|
const { schemaVersion, ...localOnlyOptions } = options;
|
|
1591
1601
|
const collectionId = localOnlyOptions.id ?? `persisted-collection:${safeRandomUUID()}`;
|
|
@@ -1643,7 +1653,7 @@ function persistedCollectionOptions(options) {
|
|
|
1643
1653
|
...localOnlyOptions.utils ?? {},
|
|
1644
1654
|
...persistedUtils
|
|
1645
1655
|
};
|
|
1646
|
-
|
|
1656
|
+
const result = {
|
|
1647
1657
|
...localOnlyOptions,
|
|
1648
1658
|
id: collectionId,
|
|
1649
1659
|
persistence,
|
|
@@ -1655,6 +1665,13 @@ function persistedCollectionOptions(options) {
|
|
|
1655
1665
|
startSync: true,
|
|
1656
1666
|
gcTime: localOnlyOptions.gcTime ?? 0
|
|
1657
1667
|
};
|
|
1668
|
+
return withCollectionConfigFactory(
|
|
1669
|
+
result,
|
|
1670
|
+
() => persistedCollectionOptions({
|
|
1671
|
+
...options,
|
|
1672
|
+
id: collectionId
|
|
1673
|
+
})
|
|
1674
|
+
);
|
|
1658
1675
|
}
|
|
1659
1676
|
function encodePersistedStorageKey(key) {
|
|
1660
1677
|
if (typeof key === `number`) {
|