@terreno/syncdb 56.0.0-beta.0
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/README.md +419 -0
- package/dist/auth/betterAuthAdapter.d.ts +22 -0
- package/dist/auth/betterAuthAdapter.d.ts.map +1 -0
- package/dist/auth/betterAuthAdapter.js +181 -0
- package/dist/auth/betterAuthAdapter.js.map +1 -0
- package/dist/auth/betterAuthAdapter.test.d.ts +2 -0
- package/dist/auth/betterAuthAdapter.test.d.ts.map +1 -0
- package/dist/auth/betterAuthAdapter.test.js +350 -0
- package/dist/auth/betterAuthAdapter.test.js.map +1 -0
- package/dist/auth/types.d.ts +42 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +9 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client.d.ts +246 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1415 -0
- package/dist/client.js.map +1 -0
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/client.test.js +2310 -0
- package/dist/client.test.js.map +1 -0
- package/dist/crypto/aesGcmCodec.d.ts +33 -0
- package/dist/crypto/aesGcmCodec.d.ts.map +1 -0
- package/dist/crypto/aesGcmCodec.js +80 -0
- package/dist/crypto/aesGcmCodec.js.map +1 -0
- package/dist/crypto/aesGcmCodec.test.d.ts +2 -0
- package/dist/crypto/aesGcmCodec.test.d.ts.map +1 -0
- package/dist/crypto/aesGcmCodec.test.js +83 -0
- package/dist/crypto/aesGcmCodec.test.js.map +1 -0
- package/dist/crypto/identityCodec.d.ts +7 -0
- package/dist/crypto/identityCodec.d.ts.map +1 -0
- package/dist/crypto/identityCodec.js +9 -0
- package/dist/crypto/identityCodec.js.map +1 -0
- package/dist/crypto/keyProviders.d.ts +34 -0
- package/dist/crypto/keyProviders.d.ts.map +1 -0
- package/dist/crypto/keyProviders.js +102 -0
- package/dist/crypto/keyProviders.js.map +1 -0
- package/dist/crypto/keyProviders.test.d.ts +2 -0
- package/dist/crypto/keyProviders.test.d.ts.map +1 -0
- package/dist/crypto/keyProviders.test.js +189 -0
- package/dist/crypto/keyProviders.test.js.map +1 -0
- package/dist/crypto/types.d.ts +24 -0
- package/dist/crypto/types.d.ts.map +1 -0
- package/dist/crypto/types.js +8 -0
- package/dist/crypto/types.js.map +1 -0
- package/dist/debug/debugChannel.d.ts +52 -0
- package/dist/debug/debugChannel.d.ts.map +1 -0
- package/dist/debug/debugChannel.js +73 -0
- package/dist/debug/debugChannel.js.map +1 -0
- package/dist/debug/debugChannel.test.d.ts +2 -0
- package/dist/debug/debugChannel.test.d.ts.map +1 -0
- package/dist/debug/debugChannel.test.js +105 -0
- package/dist/debug/debugChannel.test.js.map +1 -0
- package/dist/debug/debugLog.d.ts +111 -0
- package/dist/debug/debugLog.d.ts.map +1 -0
- package/dist/debug/debugLog.js +150 -0
- package/dist/debug/debugLog.js.map +1 -0
- package/dist/debug/debugLog.test.d.ts +2 -0
- package/dist/debug/debugLog.test.d.ts.map +1 -0
- package/dist/debug/debugLog.test.js +121 -0
- package/dist/debug/debugLog.test.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/isolated/defaultPersisterFactoryNative.isolated.d.ts +2 -0
- package/dist/isolated/defaultPersisterFactoryNative.isolated.d.ts.map +1 -0
- package/dist/isolated/defaultPersisterFactoryNative.isolated.js +38 -0
- package/dist/isolated/defaultPersisterFactoryNative.isolated.js.map +1 -0
- package/dist/mutations/conflicts.d.ts +31 -0
- package/dist/mutations/conflicts.d.ts.map +1 -0
- package/dist/mutations/conflicts.js +73 -0
- package/dist/mutations/conflicts.js.map +1 -0
- package/dist/mutations/outbox.d.ts +174 -0
- package/dist/mutations/outbox.d.ts.map +1 -0
- package/dist/mutations/outbox.js +385 -0
- package/dist/mutations/outbox.js.map +1 -0
- package/dist/mutations/outbox.test.d.ts +2 -0
- package/dist/mutations/outbox.test.d.ts.map +1 -0
- package/dist/mutations/outbox.test.js +643 -0
- package/dist/mutations/outbox.test.js.map +1 -0
- package/dist/mutations/resolveConflict.d.ts +32 -0
- package/dist/mutations/resolveConflict.d.ts.map +1 -0
- package/dist/mutations/resolveConflict.js +101 -0
- package/dist/mutations/resolveConflict.js.map +1 -0
- package/dist/mutations/resolveConflict.test.d.ts +2 -0
- package/dist/mutations/resolveConflict.test.d.ts.map +1 -0
- package/dist/mutations/resolveConflict.test.js +282 -0
- package/dist/mutations/resolveConflict.test.js.map +1 -0
- package/dist/persisters/defaultPersisterFactory.d.ts +9 -0
- package/dist/persisters/defaultPersisterFactory.d.ts.map +1 -0
- package/dist/persisters/defaultPersisterFactory.js +9 -0
- package/dist/persisters/defaultPersisterFactory.js.map +1 -0
- package/dist/persisters/defaultPersisterFactory.native.d.ts +10 -0
- package/dist/persisters/defaultPersisterFactory.native.d.ts.map +1 -0
- package/dist/persisters/defaultPersisterFactory.native.js +44 -0
- package/dist/persisters/defaultPersisterFactory.native.js.map +1 -0
- package/dist/persisters/defaultPersisterFactory.test.d.ts +2 -0
- package/dist/persisters/defaultPersisterFactory.test.d.ts.map +1 -0
- package/dist/persisters/defaultPersisterFactory.test.js +177 -0
- package/dist/persisters/defaultPersisterFactory.test.js.map +1 -0
- package/dist/persisters/defaultPersisterFactory.web.d.ts +17 -0
- package/dist/persisters/defaultPersisterFactory.web.d.ts.map +1 -0
- package/dist/persisters/defaultPersisterFactory.web.js +65 -0
- package/dist/persisters/defaultPersisterFactory.web.js.map +1 -0
- package/dist/persisters/encryptedIndexedDbPersister.d.ts +46 -0
- package/dist/persisters/encryptedIndexedDbPersister.d.ts.map +1 -0
- package/dist/persisters/encryptedIndexedDbPersister.js +171 -0
- package/dist/persisters/encryptedIndexedDbPersister.js.map +1 -0
- package/dist/persisters/encryptedIndexedDbPersister.test.d.ts +2 -0
- package/dist/persisters/encryptedIndexedDbPersister.test.d.ts.map +1 -0
- package/dist/persisters/encryptedIndexedDbPersister.test.js +352 -0
- package/dist/persisters/encryptedIndexedDbPersister.test.js.map +1 -0
- package/dist/persisters/memoryPersister.d.ts +19 -0
- package/dist/persisters/memoryPersister.d.ts.map +1 -0
- package/dist/persisters/memoryPersister.js +31 -0
- package/dist/persisters/memoryPersister.js.map +1 -0
- package/dist/persisters/memoryPersister.test.d.ts +2 -0
- package/dist/persisters/memoryPersister.test.d.ts.map +1 -0
- package/dist/persisters/memoryPersister.test.js +113 -0
- package/dist/persisters/memoryPersister.test.js.map +1 -0
- package/dist/persisters/types.d.ts +65 -0
- package/dist/persisters/types.d.ts.map +1 -0
- package/dist/persisters/types.js +2 -0
- package/dist/persisters/types.js.map +1 -0
- package/dist/react/hooks.d.ts +132 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +269 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/hooks.test.d.ts +2 -0
- package/dist/react/hooks.test.d.ts.map +1 -0
- package/dist/react/hooks.test.js +645 -0
- package/dist/react/hooks.test.js.map +1 -0
- package/dist/react/index.d.ts +11 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +11 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/provider.d.ts +11 -0
- package/dist/react/provider.d.ts.map +1 -0
- package/dist/react/provider.js +17 -0
- package/dist/react/provider.js.map +1 -0
- package/dist/storage/idb.d.ts +27 -0
- package/dist/storage/idb.d.ts.map +1 -0
- package/dist/storage/idb.js +72 -0
- package/dist/storage/idb.js.map +1 -0
- package/dist/storage/idb.test.d.ts +2 -0
- package/dist/storage/idb.test.d.ts.map +1 -0
- package/dist/storage/idb.test.js +100 -0
- package/dist/storage/idb.test.js.map +1 -0
- package/dist/storage/purgeUnknownStream.test.d.ts +2 -0
- package/dist/storage/purgeUnknownStream.test.d.ts.map +1 -0
- package/dist/storage/purgeUnknownStream.test.js +64 -0
- package/dist/storage/purgeUnknownStream.test.js.map +1 -0
- package/dist/storage/schema.d.ts +33 -0
- package/dist/storage/schema.d.ts.map +1 -0
- package/dist/storage/schema.js +92 -0
- package/dist/storage/schema.js.map +1 -0
- package/dist/storage/store.d.ts +136 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +275 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/storage/store.test.d.ts +2 -0
- package/dist/storage/store.test.d.ts.map +1 -0
- package/dist/storage/store.test.js +357 -0
- package/dist/storage/store.test.js.map +1 -0
- package/dist/storage/types.d.ts +146 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +32 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/storage/wipe.d.ts +22 -0
- package/dist/storage/wipe.d.ts.map +1 -0
- package/dist/storage/wipe.js +43 -0
- package/dist/storage/wipe.js.map +1 -0
- package/dist/storage/wipe.test.d.ts +2 -0
- package/dist/storage/wipe.test.d.ts.map +1 -0
- package/dist/storage/wipe.test.js +95 -0
- package/dist/storage/wipe.test.js.map +1 -0
- package/dist/sync/bootstrap.d.ts +64 -0
- package/dist/sync/bootstrap.d.ts.map +1 -0
- package/dist/sync/bootstrap.js +160 -0
- package/dist/sync/bootstrap.js.map +1 -0
- package/dist/sync/bootstrap.test.d.ts +2 -0
- package/dist/sync/bootstrap.test.d.ts.map +1 -0
- package/dist/sync/bootstrap.test.js +447 -0
- package/dist/sync/bootstrap.test.js.map +1 -0
- package/dist/sync/cursor.d.ts +67 -0
- package/dist/sync/cursor.d.ts.map +1 -0
- package/dist/sync/cursor.js +74 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/cursor.test.d.ts +2 -0
- package/dist/sync/cursor.test.d.ts.map +1 -0
- package/dist/sync/cursor.test.js +73 -0
- package/dist/sync/cursor.test.js.map +1 -0
- package/dist/sync/deltaApplier.d.ts +30 -0
- package/dist/sync/deltaApplier.d.ts.map +1 -0
- package/dist/sync/deltaApplier.js +61 -0
- package/dist/sync/deltaApplier.js.map +1 -0
- package/dist/sync/deltaApplier.test.d.ts +2 -0
- package/dist/sync/deltaApplier.test.d.ts.map +1 -0
- package/dist/sync/deltaApplier.test.js +212 -0
- package/dist/sync/deltaApplier.test.js.map +1 -0
- package/dist/sync/entityRepair.d.ts +45 -0
- package/dist/sync/entityRepair.d.ts.map +1 -0
- package/dist/sync/entityRepair.js +91 -0
- package/dist/sync/entityRepair.js.map +1 -0
- package/dist/sync/entityRepair.test.d.ts +2 -0
- package/dist/sync/entityRepair.test.d.ts.map +1 -0
- package/dist/sync/entityRepair.test.js +146 -0
- package/dist/sync/entityRepair.test.js.map +1 -0
- package/dist/sync/httpChannel.d.ts +74 -0
- package/dist/sync/httpChannel.d.ts.map +1 -0
- package/dist/sync/httpChannel.js +123 -0
- package/dist/sync/httpChannel.js.map +1 -0
- package/dist/sync/httpChannel.test.d.ts +2 -0
- package/dist/sync/httpChannel.test.d.ts.map +1 -0
- package/dist/sync/httpChannel.test.js +215 -0
- package/dist/sync/httpChannel.test.js.map +1 -0
- package/dist/sync/replayCoordinator.d.ts +212 -0
- package/dist/sync/replayCoordinator.d.ts.map +1 -0
- package/dist/sync/replayCoordinator.js +1110 -0
- package/dist/sync/replayCoordinator.js.map +1 -0
- package/dist/sync/replayCoordinator.test.d.ts +2 -0
- package/dist/sync/replayCoordinator.test.d.ts.map +1 -0
- package/dist/sync/replayCoordinator.test.js +1496 -0
- package/dist/sync/replayCoordinator.test.js.map +1 -0
- package/dist/sync/socketTransport.d.ts +56 -0
- package/dist/sync/socketTransport.d.ts.map +1 -0
- package/dist/sync/socketTransport.js +292 -0
- package/dist/sync/socketTransport.js.map +1 -0
- package/dist/sync/socketTransport.test.d.ts +2 -0
- package/dist/sync/socketTransport.test.d.ts.map +1 -0
- package/dist/sync/socketTransport.test.js +346 -0
- package/dist/sync/socketTransport.test.js.map +1 -0
- package/dist/sync/transport.d.ts +80 -0
- package/dist/sync/transport.d.ts.map +1 -0
- package/dist/sync/transport.js +5 -0
- package/dist/sync/transport.js.map +1 -0
- package/dist/testing/fakeTransport.d.ts +55 -0
- package/dist/testing/fakeTransport.d.ts.map +1 -0
- package/dist/testing/fakeTransport.js +139 -0
- package/dist/testing/fakeTransport.js.map +1 -0
- package/dist/testing/fakeTransport.test.d.ts +2 -0
- package/dist/testing/fakeTransport.test.d.ts.map +1 -0
- package/dist/testing/fakeTransport.test.js +112 -0
- package/dist/testing/fakeTransport.test.js.map +1 -0
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +13 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types.d.ts +271 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -0
- package/src/auth/betterAuthAdapter.test.ts +455 -0
- package/src/auth/betterAuthAdapter.ts +214 -0
- package/src/auth/types.ts +49 -0
- package/src/client.test.ts +2670 -0
- package/src/client.ts +1748 -0
- package/src/crypto/aesGcmCodec.test.ts +103 -0
- package/src/crypto/aesGcmCodec.ts +98 -0
- package/src/crypto/identityCodec.ts +10 -0
- package/src/crypto/keyProviders.test.ts +228 -0
- package/src/crypto/keyProviders.ts +153 -0
- package/src/crypto/types.ts +23 -0
- package/src/debug/debugChannel.test.ts +121 -0
- package/src/debug/debugChannel.ts +112 -0
- package/src/debug/debugLog.test.ts +139 -0
- package/src/debug/debugLog.ts +272 -0
- package/src/index.ts +157 -0
- package/src/isolated/defaultPersisterFactoryNative.isolated.ts +45 -0
- package/src/mutations/conflicts.ts +108 -0
- package/src/mutations/outbox.test.ts +754 -0
- package/src/mutations/outbox.ts +585 -0
- package/src/mutations/resolveConflict.test.ts +338 -0
- package/src/mutations/resolveConflict.ts +115 -0
- package/src/persisters/defaultPersisterFactory.native.ts +53 -0
- package/src/persisters/defaultPersisterFactory.test.ts +207 -0
- package/src/persisters/defaultPersisterFactory.ts +12 -0
- package/src/persisters/defaultPersisterFactory.web.ts +78 -0
- package/src/persisters/encryptedIndexedDbPersister.test.ts +381 -0
- package/src/persisters/encryptedIndexedDbPersister.ts +218 -0
- package/src/persisters/memoryPersister.test.ts +136 -0
- package/src/persisters/memoryPersister.ts +52 -0
- package/src/persisters/types.ts +71 -0
- package/src/react/hooks.test.tsx +761 -0
- package/src/react/hooks.ts +409 -0
- package/src/react/index.ts +11 -0
- package/src/react/provider.tsx +27 -0
- package/src/storage/idb.test.ts +116 -0
- package/src/storage/idb.ts +112 -0
- package/src/storage/purgeUnknownStream.test.ts +74 -0
- package/src/storage/schema.ts +103 -0
- package/src/storage/store.test.ts +424 -0
- package/src/storage/store.ts +461 -0
- package/src/storage/types.ts +159 -0
- package/src/storage/wipe.test.ts +111 -0
- package/src/storage/wipe.ts +58 -0
- package/src/sync/bootstrap.test.ts +486 -0
- package/src/sync/bootstrap.ts +217 -0
- package/src/sync/cursor.test.ts +84 -0
- package/src/sync/cursor.ts +113 -0
- package/src/sync/deltaApplier.test.ts +237 -0
- package/src/sync/deltaApplier.ts +84 -0
- package/src/sync/entityRepair.test.ts +161 -0
- package/src/sync/entityRepair.ts +124 -0
- package/src/sync/httpChannel.test.ts +265 -0
- package/src/sync/httpChannel.ts +220 -0
- package/src/sync/replayCoordinator.test.ts +1709 -0
- package/src/sync/replayCoordinator.ts +1370 -0
- package/src/sync/socketTransport.test.ts +413 -0
- package/src/sync/socketTransport.ts +379 -0
- package/src/sync/transport.ts +76 -0
- package/src/testing/fakeTransport.test.ts +125 -0
- package/src/testing/fakeTransport.ts +206 -0
- package/src/testing/index.ts +18 -0
- package/src/types.ts +284 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { createOutbox } from "../mutations/outbox";
|
|
3
|
+
import { createMemoryPersister } from "../persisters/memoryPersister";
|
|
4
|
+
import { SYNC_SCHEMA_VERSION } from "./schema";
|
|
5
|
+
import { createSyncStore } from "./store";
|
|
6
|
+
import { CONFLICTS_TABLE, CURSORS_TABLE, OUTBOX_TABLE } from "./types";
|
|
7
|
+
const makeStore = () => createSyncStore({ collections: ["todos", "notes"] });
|
|
8
|
+
describe("createSyncStore", () => {
|
|
9
|
+
it("throws when a collection name starts with the reserved prefix", () => {
|
|
10
|
+
expect(() => createSyncStore({ collections: ["_outbox"] })).toThrow(/must not start with "_"/);
|
|
11
|
+
expect(() => createSyncStore({ collections: ["todos", "_shadow"] })).toThrow(/_shadow/);
|
|
12
|
+
});
|
|
13
|
+
it("throws on duplicate collection names", () => {
|
|
14
|
+
expect(() => createSyncStore({ collections: ["todos", "todos"] })).toThrow(/Duplicate/);
|
|
15
|
+
});
|
|
16
|
+
it("exposes the configured collections and a raw MergeableStore", () => {
|
|
17
|
+
const store = makeStore();
|
|
18
|
+
expect(store.collections).toEqual(["todos", "notes"]);
|
|
19
|
+
expect(typeof store.raw.getMergeableContent).toBe("function");
|
|
20
|
+
});
|
|
21
|
+
it("initializes schemaVersion and an empty lastUserId", () => {
|
|
22
|
+
const store = makeStore();
|
|
23
|
+
expect(store.getSchemaVersion()).toBe(SYNC_SCHEMA_VERSION);
|
|
24
|
+
expect(store.getLastUserId()).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
it("round-trips lastUserId", () => {
|
|
27
|
+
const store = makeStore();
|
|
28
|
+
store.setLastUserId({ userId: "user-1" });
|
|
29
|
+
expect(store.getLastUserId()).toBe("user-1");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("upsertEntity / getEntity", () => {
|
|
33
|
+
it("round-trips entity data through the JSON data cell", () => {
|
|
34
|
+
const store = makeStore();
|
|
35
|
+
store.upsertEntity({
|
|
36
|
+
collection: "todos",
|
|
37
|
+
data: { completed: false, title: "Buy milk" },
|
|
38
|
+
id: "t1",
|
|
39
|
+
seq: 3,
|
|
40
|
+
});
|
|
41
|
+
const entity = store.getEntity({ collection: "todos", id: "t1" });
|
|
42
|
+
expect(entity).toEqual({
|
|
43
|
+
data: { completed: false, title: "Buy milk" },
|
|
44
|
+
deleted: false,
|
|
45
|
+
id: "t1",
|
|
46
|
+
pendingMutationId: undefined,
|
|
47
|
+
seq: 3,
|
|
48
|
+
stream: undefined,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it("returns undefined for a missing entity", () => {
|
|
52
|
+
const store = makeStore();
|
|
53
|
+
expect(store.getEntity({ collection: "todos", id: "nope" })).toBeUndefined();
|
|
54
|
+
});
|
|
55
|
+
it("defaults seq to 0 and deleted to false for new local entities", () => {
|
|
56
|
+
const store = makeStore();
|
|
57
|
+
const entity = store.upsertEntity({ collection: "todos", data: { title: "Local" }, id: "t1" });
|
|
58
|
+
expect(entity.seq).toBe(0);
|
|
59
|
+
expect(entity.deleted).toBe(false);
|
|
60
|
+
expect(entity.pendingMutationId).toBeUndefined();
|
|
61
|
+
});
|
|
62
|
+
it("preserves existing seq, deleted, and pendingMutationId when omitted", () => {
|
|
63
|
+
const store = makeStore();
|
|
64
|
+
store.upsertEntity({
|
|
65
|
+
collection: "todos",
|
|
66
|
+
data: { title: "v1" },
|
|
67
|
+
deleted: true,
|
|
68
|
+
id: "t1",
|
|
69
|
+
pendingMutationId: "m1",
|
|
70
|
+
seq: 7,
|
|
71
|
+
});
|
|
72
|
+
const updated = store.upsertEntity({ collection: "todos", data: { title: "v2" }, id: "t1" });
|
|
73
|
+
expect(updated.seq).toBe(7);
|
|
74
|
+
expect(updated.deleted).toBe(true);
|
|
75
|
+
expect(updated.pendingMutationId).toBe("m1");
|
|
76
|
+
});
|
|
77
|
+
it("clears pendingMutationId when explicitly set to empty", () => {
|
|
78
|
+
const store = makeStore();
|
|
79
|
+
store.upsertEntity({
|
|
80
|
+
collection: "todos",
|
|
81
|
+
data: { title: "v1" },
|
|
82
|
+
id: "t1",
|
|
83
|
+
pendingMutationId: "m1",
|
|
84
|
+
});
|
|
85
|
+
store.upsertEntity({ collection: "todos", data: { title: "v2" }, id: "t1", pendingMutationId: "" });
|
|
86
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.pendingMutationId).toBeUndefined();
|
|
87
|
+
});
|
|
88
|
+
it("stores null data payloads", () => {
|
|
89
|
+
const store = makeStore();
|
|
90
|
+
store.upsertEntity({ collection: "todos", data: null, id: "t1" });
|
|
91
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.data).toBeNull();
|
|
92
|
+
});
|
|
93
|
+
it("returns null data for a corrupt (non-JSON) data cell instead of throwing", () => {
|
|
94
|
+
const store = makeStore();
|
|
95
|
+
store.upsertEntity({ collection: "todos", data: { title: "ok" }, id: "t1" });
|
|
96
|
+
store.raw.setCell("todos", "t1", "data", "{not json");
|
|
97
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.data).toBeNull();
|
|
98
|
+
});
|
|
99
|
+
it("throws for an unknown collection", () => {
|
|
100
|
+
const store = makeStore();
|
|
101
|
+
expect(() => store.upsertEntity({ collection: "nope", data: {}, id: "x" })).toThrow(/Unknown collection "nope"/);
|
|
102
|
+
expect(() => store.getEntity({ collection: "nope", id: "x" })).toThrow(/Unknown collection/);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe("listEntities", () => {
|
|
106
|
+
it("lists entities in a collection", () => {
|
|
107
|
+
const store = makeStore();
|
|
108
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, id: "t1" });
|
|
109
|
+
store.upsertEntity({ collection: "todos", data: { title: "b" }, id: "t2" });
|
|
110
|
+
const entities = store.listEntities({ collection: "todos" });
|
|
111
|
+
expect(entities.map((entity) => entity.id).sort()).toEqual(["t1", "t2"]);
|
|
112
|
+
});
|
|
113
|
+
it("excludes tombstones by default and includes them on request", () => {
|
|
114
|
+
const store = makeStore();
|
|
115
|
+
store.upsertEntity({ collection: "todos", data: { title: "live" }, id: "t1" });
|
|
116
|
+
store.upsertEntity({ collection: "todos", data: { title: "dead" }, deleted: true, id: "t2" });
|
|
117
|
+
expect(store.listEntities({ collection: "todos" }).map((entity) => entity.id)).toEqual(["t1"]);
|
|
118
|
+
expect(store
|
|
119
|
+
.listEntities({ collection: "todos", includeDeleted: true })
|
|
120
|
+
.map((entity) => entity.id)
|
|
121
|
+
.sort()).toEqual(["t1", "t2"]);
|
|
122
|
+
});
|
|
123
|
+
it("isolates collections from each other, even with the same entity id", () => {
|
|
124
|
+
const store = makeStore();
|
|
125
|
+
store.upsertEntity({ collection: "todos", data: { title: "todo" }, id: "shared" });
|
|
126
|
+
store.upsertEntity({ collection: "notes", data: { body: "note" }, id: "shared" });
|
|
127
|
+
expect(store.listEntities({ collection: "todos" })).toHaveLength(1);
|
|
128
|
+
expect(store.getEntity({ collection: "todos", id: "shared" })?.data).toEqual({ title: "todo" });
|
|
129
|
+
expect(store.getEntity({ collection: "notes", id: "shared" })?.data).toEqual({ body: "note" });
|
|
130
|
+
});
|
|
131
|
+
it("throws for an unknown collection", () => {
|
|
132
|
+
const store = makeStore();
|
|
133
|
+
expect(() => store.listEntities({ collection: "nope" })).toThrow(/Unknown collection/);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe("softDeleteEntity", () => {
|
|
137
|
+
it("marks the entity deleted while keeping its data and seq", () => {
|
|
138
|
+
const store = makeStore();
|
|
139
|
+
store.upsertEntity({ collection: "todos", data: { title: "keep me" }, id: "t1", seq: 4 });
|
|
140
|
+
store.softDeleteEntity({ collection: "todos", id: "t1" });
|
|
141
|
+
const entity = store.getEntity({ collection: "todos", id: "t1" });
|
|
142
|
+
expect(entity?.deleted).toBe(true);
|
|
143
|
+
expect(entity?.data).toEqual({ title: "keep me" });
|
|
144
|
+
expect(entity?.seq).toBe(4);
|
|
145
|
+
});
|
|
146
|
+
it("is a no-op for a missing entity", () => {
|
|
147
|
+
const store = makeStore();
|
|
148
|
+
store.softDeleteEntity({ collection: "todos", id: "nope" });
|
|
149
|
+
expect(store.getEntity({ collection: "todos", id: "nope" })).toBeUndefined();
|
|
150
|
+
});
|
|
151
|
+
it("throws for an unknown collection", () => {
|
|
152
|
+
const store = makeStore();
|
|
153
|
+
expect(() => store.softDeleteEntity({ collection: "nope", id: "x" })).toThrow(/Unknown collection/);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe("clearCollection", () => {
|
|
157
|
+
it("removes every entity in the collection but leaves other tables alone", () => {
|
|
158
|
+
const store = makeStore();
|
|
159
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, id: "t1" });
|
|
160
|
+
store.upsertEntity({ collection: "notes", data: { body: "b" }, id: "n1" });
|
|
161
|
+
store.clearCollection({ collection: "todos" });
|
|
162
|
+
expect(store.listEntities({ collection: "todos", includeDeleted: true })).toHaveLength(0);
|
|
163
|
+
expect(store.listEntities({ collection: "notes" })).toHaveLength(1);
|
|
164
|
+
});
|
|
165
|
+
it("throws for an unknown collection", () => {
|
|
166
|
+
const store = makeStore();
|
|
167
|
+
expect(() => store.clearCollection({ collection: "nope" })).toThrow(/Unknown collection/);
|
|
168
|
+
});
|
|
169
|
+
it("cannot be used to clear reserved tables", () => {
|
|
170
|
+
const store = makeStore();
|
|
171
|
+
expect(() => store.clearCollection({ collection: OUTBOX_TABLE })).toThrow(/Unknown collection/);
|
|
172
|
+
expect(() => store.clearCollection({ collection: CURSORS_TABLE })).toThrow(/Unknown collection/);
|
|
173
|
+
expect(() => store.clearCollection({ collection: CONFLICTS_TABLE })).toThrow(/Unknown collection/);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe("deleted rows stay deleted across a persister reload", () => {
|
|
177
|
+
/**
|
|
178
|
+
* A MergeableStore keeps a CRDT tombstone for every deleted row. Loading that
|
|
179
|
+
* tombstone re-applies the tables schema, so any cell carrying a `default`
|
|
180
|
+
* used to be re-created — resurrecting the row as a husk of its defaults. For
|
|
181
|
+
* `_conflicts` that meant an already-resolved conflict reappeared with
|
|
182
|
+
* `collection: ""` and threw `Unknown collection ""` when resolved again.
|
|
183
|
+
*/
|
|
184
|
+
const reloadAfterDelete = async ({ table, rowId, seed, }) => {
|
|
185
|
+
const databaseName = `resurrection-${table}-${Date.now()}-${Math.random()}`;
|
|
186
|
+
const store = seed();
|
|
187
|
+
const persister = createMemoryPersister({ databaseName, store: store.raw });
|
|
188
|
+
await persister.save();
|
|
189
|
+
store.raw.delRow(table, rowId);
|
|
190
|
+
await persister.save();
|
|
191
|
+
const reloaded = createSyncStore({ collections: ["todos", "notes"] });
|
|
192
|
+
const reloadPersister = createMemoryPersister({ databaseName, store: reloaded.raw });
|
|
193
|
+
await reloadPersister.load();
|
|
194
|
+
return reloaded.raw.getTable(table);
|
|
195
|
+
};
|
|
196
|
+
it("does not resurrect a deleted conflict row", async () => {
|
|
197
|
+
const table = await reloadAfterDelete({
|
|
198
|
+
rowId: "m1",
|
|
199
|
+
seed: () => {
|
|
200
|
+
const store = makeStore();
|
|
201
|
+
store.raw.setRow(CONFLICTS_TABLE, "m1", {
|
|
202
|
+
collection: "todos",
|
|
203
|
+
dismissed: false,
|
|
204
|
+
entityId: "t1",
|
|
205
|
+
localData: "{}",
|
|
206
|
+
serverData: "{}",
|
|
207
|
+
serverSeq: 9,
|
|
208
|
+
});
|
|
209
|
+
return store;
|
|
210
|
+
},
|
|
211
|
+
table: CONFLICTS_TABLE,
|
|
212
|
+
});
|
|
213
|
+
expect(table).toEqual({});
|
|
214
|
+
});
|
|
215
|
+
it("does not resurrect a deleted outbox row", async () => {
|
|
216
|
+
const table = await reloadAfterDelete({
|
|
217
|
+
rowId: "m1",
|
|
218
|
+
seed: () => {
|
|
219
|
+
const store = makeStore();
|
|
220
|
+
createOutbox({ store }).enqueue({
|
|
221
|
+
args: { title: "a" },
|
|
222
|
+
collection: "todos",
|
|
223
|
+
entityId: "t1",
|
|
224
|
+
mutationId: "m1",
|
|
225
|
+
operation: "update",
|
|
226
|
+
userId: "u1",
|
|
227
|
+
});
|
|
228
|
+
return store;
|
|
229
|
+
},
|
|
230
|
+
table: OUTBOX_TABLE,
|
|
231
|
+
});
|
|
232
|
+
expect(table).toEqual({});
|
|
233
|
+
});
|
|
234
|
+
it("does not resurrect a compacted entity tombstone", async () => {
|
|
235
|
+
const table = await reloadAfterDelete({
|
|
236
|
+
rowId: "t1",
|
|
237
|
+
seed: () => {
|
|
238
|
+
const store = makeStore();
|
|
239
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, id: "t1" });
|
|
240
|
+
return store;
|
|
241
|
+
},
|
|
242
|
+
table: "todos",
|
|
243
|
+
});
|
|
244
|
+
expect(table).toEqual({});
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
describe("deletedAt stamping (E5)", () => {
|
|
248
|
+
it("upsertEntity stamps deletedAt on the transition into a tombstone, and only then", () => {
|
|
249
|
+
const store = makeStore();
|
|
250
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, id: "t1" });
|
|
251
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.deletedAt).toBeUndefined();
|
|
252
|
+
store.softDeleteEntity({ collection: "todos", id: "t1" });
|
|
253
|
+
const firstStampedAt = store.getEntity({ collection: "todos", id: "t1" })?.deletedAt;
|
|
254
|
+
expect(firstStampedAt).toBeTruthy();
|
|
255
|
+
// A second upsert that keeps deleted: true must NOT re-stamp deletedAt.
|
|
256
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, deleted: true, id: "t1" });
|
|
257
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.deletedAt).toBe(firstStampedAt);
|
|
258
|
+
});
|
|
259
|
+
it("clears deletedAt on a resurrection (upsert back to deleted: false)", () => {
|
|
260
|
+
const store = makeStore();
|
|
261
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, id: "t1" });
|
|
262
|
+
store.softDeleteEntity({ collection: "todos", id: "t1" });
|
|
263
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.deletedAt).toBeTruthy();
|
|
264
|
+
store.upsertEntity({ collection: "todos", data: { title: "a" }, deleted: false, id: "t1" });
|
|
265
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.deletedAt).toBeUndefined();
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
describe("compactTombstones (E5)", () => {
|
|
269
|
+
it("removes tombstones older than the retention window, across all collections", () => {
|
|
270
|
+
const clock = { value: 1000000 };
|
|
271
|
+
const store = createSyncStore({
|
|
272
|
+
collections: ["todos", "notes"],
|
|
273
|
+
now: () => new Date(clock.value).toISOString(),
|
|
274
|
+
});
|
|
275
|
+
store.upsertEntity({ collection: "todos", data: { title: "old" }, id: "t1" });
|
|
276
|
+
store.upsertEntity({ collection: "todos", data: { title: "recent" }, id: "t2" });
|
|
277
|
+
store.upsertEntity({ collection: "notes", data: { body: "old note" }, id: "n1" });
|
|
278
|
+
store.upsertEntity({ collection: "todos", data: { title: "kept, not deleted" }, id: "t3" });
|
|
279
|
+
// t1/n1 tombstoned "long ago"; t2 tombstoned "recently", relative to the
|
|
280
|
+
// clock the compaction call itself uses below.
|
|
281
|
+
store.upsertEntity({ collection: "todos", data: null, deleted: true, id: "t1" });
|
|
282
|
+
store.upsertEntity({ collection: "notes", data: null, deleted: true, id: "n1" });
|
|
283
|
+
clock.value += 100 * 24 * 60 * 60 * 1000; // +100 days
|
|
284
|
+
store.upsertEntity({ collection: "todos", data: null, deleted: true, id: "t2" });
|
|
285
|
+
// Advance the clock another 10 days: t1/n1 are now ~110 days old, t2 is
|
|
286
|
+
// ~10 days old. A 90-day retention window compacts t1/n1 but keeps t2.
|
|
287
|
+
clock.value += 10 * 24 * 60 * 60 * 1000;
|
|
288
|
+
const result = store.compactTombstones({ olderThanMs: 90 * 24 * 60 * 60 * 1000 });
|
|
289
|
+
expect(result.removed).toBe(2);
|
|
290
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })).toBeUndefined();
|
|
291
|
+
expect(store.getEntity({ collection: "notes", id: "n1" })).toBeUndefined();
|
|
292
|
+
expect(store.getEntity({ collection: "todos", id: "t2" })?.deleted).toBe(true);
|
|
293
|
+
expect(store.getEntity({ collection: "todos", id: "t3" })?.deleted).toBe(false);
|
|
294
|
+
});
|
|
295
|
+
it("leaves tombstones with no deletedAt (pre-E5 rows) untouched", () => {
|
|
296
|
+
const store = makeStore();
|
|
297
|
+
store.upsertEntity({ collection: "todos", data: { title: "legacy" }, id: "t1" });
|
|
298
|
+
// Simulate a tombstone written before deletedAt existed: set the cell
|
|
299
|
+
// directly, bypassing the stamping logic in upsertEntity/softDeleteEntity.
|
|
300
|
+
store.raw.setCell("todos", "t1", "deleted", true);
|
|
301
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })?.deletedAt).toBeUndefined();
|
|
302
|
+
const result = store.compactTombstones({ olderThanMs: 0 });
|
|
303
|
+
expect(result.removed).toBe(0);
|
|
304
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })).toBeDefined();
|
|
305
|
+
});
|
|
306
|
+
it("never removes non-tombstone rows regardless of age", () => {
|
|
307
|
+
const store = makeStore();
|
|
308
|
+
const clock = { value: 1000000 };
|
|
309
|
+
store.upsertEntity({ collection: "todos", data: { title: "alive" }, id: "t1" });
|
|
310
|
+
const result = store.compactTombstones({
|
|
311
|
+
now: () => new Date(clock.value + 1000 * 60 * 60 * 24 * 365).toISOString(),
|
|
312
|
+
olderThanMs: 0,
|
|
313
|
+
});
|
|
314
|
+
expect(result.removed).toBe(0);
|
|
315
|
+
expect(store.getEntity({ collection: "todos", id: "t1" })).toBeDefined();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
describe("known streams + purgeStream (C2)", () => {
|
|
319
|
+
it("round-trips known streams (add / get / remove)", () => {
|
|
320
|
+
const store = makeStore();
|
|
321
|
+
expect(store.getKnownStreams()).toEqual([]);
|
|
322
|
+
store.addKnownStream({ collection: "todos", stream: "todos|owner:u1" });
|
|
323
|
+
store.addKnownStream({ collection: "todos", stream: "todos|tenant:org1" });
|
|
324
|
+
expect(store.getKnownStreams().sort()).toEqual(["todos|owner:u1", "todos|tenant:org1"]);
|
|
325
|
+
store.removeKnownStream({ stream: "todos|owner:u1" });
|
|
326
|
+
expect(store.getKnownStreams()).toEqual(["todos|tenant:org1"]);
|
|
327
|
+
});
|
|
328
|
+
it("purgeStream deletes only the matching stream's entities, its cursor, and its known-stream row", () => {
|
|
329
|
+
const store = makeStore();
|
|
330
|
+
const leaving = "todos|tenant:org1";
|
|
331
|
+
const staying = "todos|owner:u1";
|
|
332
|
+
// Two entities on the leaving stream (one in each collection), one on the staying stream.
|
|
333
|
+
store.upsertEntity({ collection: "todos", data: { t: 1 }, id: "a", seq: 3, stream: leaving });
|
|
334
|
+
store.upsertEntity({ collection: "notes", data: { n: 1 }, id: "b", seq: 4, stream: leaving });
|
|
335
|
+
store.upsertEntity({ collection: "todos", data: { t: 2 }, id: "c", seq: 5, stream: staying });
|
|
336
|
+
store.addKnownStream({ collection: "todos", stream: leaving });
|
|
337
|
+
store.addKnownStream({ collection: "todos", stream: staying });
|
|
338
|
+
store.raw.setRow(CURSORS_TABLE, leaving, { seq: 3, updatedAt: "x" });
|
|
339
|
+
store.raw.setRow(CURSORS_TABLE, staying, { seq: 5, updatedAt: "y" });
|
|
340
|
+
const purged = store.purgeStream({ stream: leaving });
|
|
341
|
+
expect(purged).toBe(2);
|
|
342
|
+
expect(store.getEntity({ collection: "todos", id: "a" })).toBeUndefined();
|
|
343
|
+
expect(store.getEntity({ collection: "notes", id: "b" })).toBeUndefined();
|
|
344
|
+
// The staying stream's entity and cursor and known-stream row are untouched.
|
|
345
|
+
expect(store.getEntity({ collection: "todos", id: "c" })?.data).toEqual({ t: 2 });
|
|
346
|
+
expect(store.raw.getCell(CURSORS_TABLE, staying, "seq")).toBe(5);
|
|
347
|
+
expect(store.raw.hasRow(CURSORS_TABLE, leaving)).toBe(false);
|
|
348
|
+
expect(store.getKnownStreams()).toEqual([staying]);
|
|
349
|
+
});
|
|
350
|
+
it("purgeStream returns 0 and is a no-op for a stream with no entities", () => {
|
|
351
|
+
const store = makeStore();
|
|
352
|
+
store.addKnownStream({ collection: "todos", stream: "todos|owner:ghost" });
|
|
353
|
+
expect(store.purgeStream({ stream: "todos|owner:ghost" })).toBe(0);
|
|
354
|
+
expect(store.getKnownStreams()).toEqual([]);
|
|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AAG,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7D,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;QAC1B,KAAK,CAAC,cAAc,CAAC,EAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAC,CAAC,CAAC;QACzE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAC,MAAM,EAAE,mBAAmB,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal TinyBase table layout for the local-first store.
|
|
3
|
+
*
|
|
4
|
+
* Entity tables are named after their collection (e.g. "todos"); reserved
|
|
5
|
+
* infrastructure tables are prefixed with "_" so they can never collide with a
|
|
6
|
+
* collection name (collection names starting with "_" are rejected at store
|
|
7
|
+
* creation). TinyBase cells only hold primitives (string | number | boolean),
|
|
8
|
+
* so rich payloads are JSON-encoded into `data`/`args` cells; the `*Row`
|
|
9
|
+
* interfaces below describe those primitive shapes, while the decoded,
|
|
10
|
+
* application-facing shapes live in `../types`.
|
|
11
|
+
*/
|
|
12
|
+
import type { OutboxStatus, SyncMutationOperation } from "../types";
|
|
13
|
+
/** Reserved table holding durable outbox mutations; rowId = mutationId. */
|
|
14
|
+
export declare const OUTBOX_TABLE = "_outbox";
|
|
15
|
+
/** Reserved table holding per-stream sync cursors; rowId = stream key. */
|
|
16
|
+
export declare const CURSORS_TABLE = "_cursors";
|
|
17
|
+
/** Reserved table holding unresolved conflicts; rowId = mutationId. */
|
|
18
|
+
export declare const CONFLICTS_TABLE = "_conflicts";
|
|
19
|
+
/**
|
|
20
|
+
* C2: reserved table recording the streams the client has bootstrapped (membership set);
|
|
21
|
+
* rowId = stream key. Diffed against `GET /sync/streams` to detect joins (backfill) and
|
|
22
|
+
* leaves (purge), the latter only on a confirmed HTTP-200 membership change (INV-2).
|
|
23
|
+
*/
|
|
24
|
+
export declare const KNOWN_STREAMS_TABLE = "_knownStreams";
|
|
25
|
+
/**
|
|
26
|
+
* Entities whose server deltas were skipped while a pending outbox mutation
|
|
27
|
+
* protected optimistic state. The cursor advanced past the missed seq, so the
|
|
28
|
+
* entity must be re-fetched once the pending mutation resolves without a server ack.
|
|
29
|
+
*/
|
|
30
|
+
export declare const NEEDS_REPAIR_TABLE = "_needsRepair";
|
|
31
|
+
/** Prefix marking reserved (non-collection) tables. */
|
|
32
|
+
export declare const RESERVED_TABLE_PREFIX = "_";
|
|
33
|
+
/** Primitive row shape for a `{collection}` entity table; rowId = entity id. */
|
|
34
|
+
export interface EntityRow {
|
|
35
|
+
/** JSON-encoded entity payload. */
|
|
36
|
+
data: string;
|
|
37
|
+
/** Soft-delete tombstone flag. */
|
|
38
|
+
deleted: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* ISO-8601 timestamp stamped the moment a tombstone (`deleted: true`) is
|
|
41
|
+
* first applied locally (empty string when not a tombstone, or for
|
|
42
|
+
* tombstones applied before this cell existed). E5's client-side
|
|
43
|
+
* compaction ages tombstones out from this timestamp, not `updated`/
|
|
44
|
+
* `created`, since a tombstone's local arrival time is what determines when
|
|
45
|
+
* it is safe to drop (it must survive at least as long as the server's own
|
|
46
|
+
* retention window, C7).
|
|
47
|
+
*/
|
|
48
|
+
deletedAt: string;
|
|
49
|
+
/** Outbox mutation currently protecting this entity's optimistic state ("" = none). */
|
|
50
|
+
pendingMutationId: string;
|
|
51
|
+
/** Highest server seq applied to this entity (0 = local-only, never synced). */
|
|
52
|
+
seq: number;
|
|
53
|
+
/**
|
|
54
|
+
* C2: the stream key this entity was last written under (delta/snapshot). Recorded at
|
|
55
|
+
* apply time so leave-purge can drop a stream's entities in O(stream) without
|
|
56
|
+
* recomputing scope. "" for local-only entities never synced from the server.
|
|
57
|
+
*/
|
|
58
|
+
stream: string;
|
|
59
|
+
}
|
|
60
|
+
/** Primitive row shape for the `_knownStreams` table; rowId = stream key. */
|
|
61
|
+
export interface KnownStreamRow {
|
|
62
|
+
/** The collection tag the stream belongs to. */
|
|
63
|
+
collection: string;
|
|
64
|
+
/** When the stream was first bootstrapped. */
|
|
65
|
+
addedAt: string;
|
|
66
|
+
}
|
|
67
|
+
/** Primitive row shape for the `_outbox` table; rowId = mutationId. */
|
|
68
|
+
export interface OutboxRow {
|
|
69
|
+
/** JSON-encoded mutation args. */
|
|
70
|
+
args: string;
|
|
71
|
+
/** Diagnostic total attempt count across every send (transport + error-nack). */
|
|
72
|
+
attemptCount: number;
|
|
73
|
+
/**
|
|
74
|
+
* Retry budget counter incremented ONLY on server error-nacks; transport
|
|
75
|
+
* failures never touch this cell (they get unlimited retries). Terminality
|
|
76
|
+
* (`MAX_ERROR_NACK_ATTEMPTS`) is checked against this, not `attemptCount`.
|
|
77
|
+
*/
|
|
78
|
+
errorNackCount: number;
|
|
79
|
+
/** Absent when the mutation carries no base version (e.g. creates). */
|
|
80
|
+
baseVersion?: number;
|
|
81
|
+
collection: string;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
/** Monotonic insertion counter; FIFO tiebreaker when createdAt collides. */
|
|
84
|
+
enqueueOrder: number;
|
|
85
|
+
entityId: string;
|
|
86
|
+
operation: SyncMutationOperation;
|
|
87
|
+
status: OutboxStatus;
|
|
88
|
+
userId: string;
|
|
89
|
+
}
|
|
90
|
+
/** Primitive row shape for the `_cursors` table; rowId = stream key. */
|
|
91
|
+
export interface CursorRow {
|
|
92
|
+
/** Highest seq applied for the stream (advanced by both deltas and snapshot pages). */
|
|
93
|
+
seq: number;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
/**
|
|
96
|
+
* Highest seq paged through the snapshot endpoint — bootstrap's own resume
|
|
97
|
+
* point, deliberately separate from `seq`. A live delta advances `seq` to the
|
|
98
|
+
* stream head regardless of how far bootstrap has got, so `seq` cannot be used
|
|
99
|
+
* to resume an interrupted bootstrap without permanently skipping every seq in
|
|
100
|
+
* between (see `sync/cursor.ts`). Absent on streams that predate this cell.
|
|
101
|
+
*/
|
|
102
|
+
snapshotSeq?: number;
|
|
103
|
+
/** True once a snapshot pass reached the stream head (`hasMore: false`). */
|
|
104
|
+
bootstrapped?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** Primitive row shape for the `_needsRepair` table; rowId = `${collection}:${entityId}`. */
|
|
107
|
+
export interface NeedsRepairRow {
|
|
108
|
+
collection: string;
|
|
109
|
+
entityId: string;
|
|
110
|
+
/** Highest server seq skipped while the entity was pending-protected. */
|
|
111
|
+
missedSeq: number;
|
|
112
|
+
/** Stream the skipped delta arrived on (used when applying the repair). */
|
|
113
|
+
stream: string;
|
|
114
|
+
markedAt: string;
|
|
115
|
+
}
|
|
116
|
+
/** Primitive row shape for the `_conflicts` table; rowId = mutationId. */
|
|
117
|
+
export interface ConflictRow {
|
|
118
|
+
collection: string;
|
|
119
|
+
dismissed: boolean;
|
|
120
|
+
entityId: string;
|
|
121
|
+
/** JSON-encoded local (optimistic) entity data. */
|
|
122
|
+
localData: string;
|
|
123
|
+
/** JSON-encoded canonical server entity data. */
|
|
124
|
+
serverData: string;
|
|
125
|
+
serverSeq: number;
|
|
126
|
+
/** True when the server side of the conflict is a tombstone (Task 9.12). */
|
|
127
|
+
serverDeleted?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/** Decoded, application-facing entity record returned by store accessors. */
|
|
130
|
+
export interface SyncEntity<TData = unknown> {
|
|
131
|
+
/** Decoded entity payload. */
|
|
132
|
+
data: TData;
|
|
133
|
+
/** Soft-delete tombstone flag. */
|
|
134
|
+
deleted: boolean;
|
|
135
|
+
/** ISO-8601 timestamp the tombstone was first applied; undefined when not a tombstone. */
|
|
136
|
+
deletedAt?: string;
|
|
137
|
+
/** Entity id (the TinyBase row id). */
|
|
138
|
+
id: string;
|
|
139
|
+
/** Outbox mutation currently protecting this entity, if any. */
|
|
140
|
+
pendingMutationId?: string;
|
|
141
|
+
/** Highest server seq applied to this entity (0 = local-only). */
|
|
142
|
+
seq: number;
|
|
143
|
+
/** C2: the stream key this entity was last written under ("" for local-only). */
|
|
144
|
+
stream?: string;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAElE,2EAA2E;AAC3E,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,0EAA0E;AAC1E,eAAO,MAAM,aAAa,aAAa,CAAC;AAExC,uEAAuE;AACvE,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,uDAAuD;AACvD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,SAAS,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AW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,6EAA6E;AAC7E,MAAM,WAAW,UAAU,CAAC,KAAK,GAAG,OAAO;IACzC,8BAA8B;IAC9B,IAAI,EAAE,KAAK,CAAC;IACZ,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal TinyBase table layout for the local-first store.
|
|
3
|
+
*
|
|
4
|
+
* Entity tables are named after their collection (e.g. "todos"); reserved
|
|
5
|
+
* infrastructure tables are prefixed with "_" so they can never collide with a
|
|
6
|
+
* collection name (collection names starting with "_" are rejected at store
|
|
7
|
+
* creation). TinyBase cells only hold primitives (string | number | boolean),
|
|
8
|
+
* so rich payloads are JSON-encoded into `data`/`args` cells; the `*Row`
|
|
9
|
+
* interfaces below describe those primitive shapes, while the decoded,
|
|
10
|
+
* application-facing shapes live in `../types`.
|
|
11
|
+
*/
|
|
12
|
+
/** Reserved table holding durable outbox mutations; rowId = mutationId. */
|
|
13
|
+
export const OUTBOX_TABLE = "_outbox";
|
|
14
|
+
/** Reserved table holding per-stream sync cursors; rowId = stream key. */
|
|
15
|
+
export const CURSORS_TABLE = "_cursors";
|
|
16
|
+
/** Reserved table holding unresolved conflicts; rowId = mutationId. */
|
|
17
|
+
export const CONFLICTS_TABLE = "_conflicts";
|
|
18
|
+
/**
|
|
19
|
+
* C2: reserved table recording the streams the client has bootstrapped (membership set);
|
|
20
|
+
* rowId = stream key. Diffed against `GET /sync/streams` to detect joins (backfill) and
|
|
21
|
+
* leaves (purge), the latter only on a confirmed HTTP-200 membership change (INV-2).
|
|
22
|
+
*/
|
|
23
|
+
export const KNOWN_STREAMS_TABLE = "_knownStreams";
|
|
24
|
+
/**
|
|
25
|
+
* Entities whose server deltas were skipped while a pending outbox mutation
|
|
26
|
+
* protected optimistic state. The cursor advanced past the missed seq, so the
|
|
27
|
+
* entity must be re-fetched once the pending mutation resolves without a server ack.
|
|
28
|
+
*/
|
|
29
|
+
export const NEEDS_REPAIR_TABLE = "_needsRepair";
|
|
30
|
+
/** Prefix marking reserved (non-collection) tables. */
|
|
31
|
+
export const RESERVED_TABLE_PREFIX = "_";
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAEtC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAExC,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEjD,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyPersister } from "tinybase/persisters";
|
|
2
|
+
import type { SyncStore } from "./store";
|
|
3
|
+
/**
|
|
4
|
+
* Wipe all local sync data for a device/user: clear every store table and
|
|
5
|
+
* value, overwrite the persisted snapshot with the now-empty content, release
|
|
6
|
+
* the persister, and delete the named IndexedDB databases (persisted data and
|
|
7
|
+
* cached encryption keys). Used on logout, on schema-version mismatch, and on
|
|
8
|
+
* decrypt failure before re-bootstrapping.
|
|
9
|
+
*
|
|
10
|
+
* A MergeableStore keeps CRDT tombstones for cleared rows, so persisting the
|
|
11
|
+
* emptied content still leaks row ids at rest — pass `databaseNames` so the
|
|
12
|
+
* underlying databases are deleted outright.
|
|
13
|
+
*/
|
|
14
|
+
export declare const wipeLocalData: ({ store, persister, databaseNames, keyCacheDbNames, }: {
|
|
15
|
+
store: SyncStore;
|
|
16
|
+
persister?: AnyPersister;
|
|
17
|
+
/** databaseNames the store was persisted under; deleted entirely. */
|
|
18
|
+
databaseNames?: string[];
|
|
19
|
+
/** IndexedDB databases holding cached CryptoKeys; deleted entirely. */
|
|
20
|
+
keyCacheDbNames?: string[];
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
//# sourceMappingURL=wipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wipe.d.ts","sourceRoot":"","sources":["../../src/storage/wipe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAItD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAU,uDAKjC;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,KAAG,OAAO,CAAC,IAAI,CA2Bf,CAAC"}
|