@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,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SyncDebugLog — an opt-in, in-memory event recorder for @terreno/syncdb.
|
|
3
|
+
*
|
|
4
|
+
* It captures the semantic sync events the client produces (local mutations,
|
|
5
|
+
* inbound server deltas/patches, outbox send/ack/nack/retry/failure, conflicts,
|
|
6
|
+
* reconcile/replay phases, connectivity) into a fixed-capacity circular buffer.
|
|
7
|
+
* This is the data source behind the "sync debugger" UI (a Redux-DevTools-style
|
|
8
|
+
* live stream) and is deliberately shaped as a plain, JSON-serializable snapshot
|
|
9
|
+
* so the same surface can be exposed over MCP in the future without change:
|
|
10
|
+
*
|
|
11
|
+
* const snapshot = client.debug?.snapshot(); // -> return straight from an MCP tool
|
|
12
|
+
*
|
|
13
|
+
* Design notes:
|
|
14
|
+
* - Zero overhead when disabled: the client never constructs event objects unless
|
|
15
|
+
* a log exists (call sites guard with `emit?.(...)`, which short-circuits arg
|
|
16
|
+
* evaluation).
|
|
17
|
+
* - Circular buffer (no array shifts) so recording stays O(1) under bursts.
|
|
18
|
+
* - `subscribe` delivers each new event individually so consumers can append
|
|
19
|
+
* without re-reading the whole buffer; `getRevision` powers `useSyncExternalStore`.
|
|
20
|
+
*/
|
|
21
|
+
import type { SyncMutationOperation } from "../types";
|
|
22
|
+
/** Coarse category for an event, mirroring the sync protocol vocabulary. */
|
|
23
|
+
export type SyncDebugEventType = "mutate" | "delta" | "send" | "ack" | "nack" | "retry" | "failed" | "conflict" | "resolve" | "reconcile" | "replay" | "connect" | "disconnect";
|
|
24
|
+
/** Which way the event flows relative to the device. */
|
|
25
|
+
export type SyncDebugDirection = "local" | "inbound" | "outbound" | "system";
|
|
26
|
+
/** A single recorded sync event. All fields are JSON-serializable. */
|
|
27
|
+
export interface SyncDebugEvent {
|
|
28
|
+
/** Monotonic local id (assigned by the log; stable ordering key). */
|
|
29
|
+
id: number;
|
|
30
|
+
/** ISO-8601 capture time. */
|
|
31
|
+
timestamp: string;
|
|
32
|
+
type: SyncDebugEventType;
|
|
33
|
+
direction: SyncDebugDirection;
|
|
34
|
+
/** Short human-readable summary, e.g. "update todos/abc @4". */
|
|
35
|
+
label: string;
|
|
36
|
+
collection?: string;
|
|
37
|
+
entityId?: string;
|
|
38
|
+
stream?: string;
|
|
39
|
+
mutationId?: string;
|
|
40
|
+
operation?: SyncMutationOperation;
|
|
41
|
+
/** Server seq (deltas, acks) where applicable. */
|
|
42
|
+
seq?: number;
|
|
43
|
+
/** For long-running events (reconcile/replay) split into start/end. */
|
|
44
|
+
phase?: "start" | "end";
|
|
45
|
+
/** Outcome flag: true for ack, false for nack/failed. */
|
|
46
|
+
ok?: boolean;
|
|
47
|
+
/** Wall-clock duration for a phase:"end" event. */
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
/** Extra serializable context (delta data, mutation args, nack code, counts). */
|
|
50
|
+
detail?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/** Input to `record`; the log fills in `id` and `timestamp`. */
|
|
53
|
+
export type SyncDebugRecordInput = Omit<SyncDebugEvent, "id" | "timestamp"> & {
|
|
54
|
+
timestamp?: string;
|
|
55
|
+
};
|
|
56
|
+
export interface SyncDebugStats {
|
|
57
|
+
/** Events recorded since creation/last clear (including evicted ones). */
|
|
58
|
+
total: number;
|
|
59
|
+
/** Live count of events currently retained in the buffer. */
|
|
60
|
+
retained: number;
|
|
61
|
+
/** Events dropped from the tail because the buffer was full. */
|
|
62
|
+
dropped: number;
|
|
63
|
+
byType: Record<SyncDebugEventType, number>;
|
|
64
|
+
firstEventAt?: string;
|
|
65
|
+
lastEventAt?: string;
|
|
66
|
+
}
|
|
67
|
+
/** A plain, serializable point-in-time view — the MCP-facing shape. */
|
|
68
|
+
export interface SyncDebugSnapshot {
|
|
69
|
+
capacity: number;
|
|
70
|
+
events: SyncDebugEvent[];
|
|
71
|
+
stats: SyncDebugStats;
|
|
72
|
+
}
|
|
73
|
+
export interface SyncDebugLog {
|
|
74
|
+
/** Max events retained before the oldest are evicted. */
|
|
75
|
+
readonly capacity: number;
|
|
76
|
+
/** Record an event; returns the stored event (with id + timestamp). */
|
|
77
|
+
record: (input: SyncDebugRecordInput) => SyncDebugEvent;
|
|
78
|
+
/** Events in chronological (oldest → newest) order. */
|
|
79
|
+
getEvents: () => SyncDebugEvent[];
|
|
80
|
+
/** Subscribe to each newly recorded event. Returns an unsubscribe fn. */
|
|
81
|
+
subscribe: (listener: (event: SyncDebugEvent) => void) => () => void;
|
|
82
|
+
/** Monotonic revision, bumped on every record and clear (for external stores). */
|
|
83
|
+
getRevision: () => number;
|
|
84
|
+
/** Aggregate counters. */
|
|
85
|
+
getStats: () => SyncDebugStats;
|
|
86
|
+
/** Serializable snapshot (events + stats) — safe to return over MCP. */
|
|
87
|
+
snapshot: () => SyncDebugSnapshot;
|
|
88
|
+
/**
|
|
89
|
+
* Drop all retained events AND reset every derived stat (`total`,
|
|
90
|
+
* `dropped`, `byType`, `firstEventAt`, `lastEventAt`) to match the
|
|
91
|
+
* now-empty buffer — `getStats()` immediately after `clear()` always
|
|
92
|
+
* describes exactly what the log currently holds (nothing), never a
|
|
93
|
+
* lifetime total left over from before the clear. The event id sequence
|
|
94
|
+
* (`nextId`) is the only thing that survives a clear, so ids stay
|
|
95
|
+
* monotonic across it.
|
|
96
|
+
*/
|
|
97
|
+
clear: () => void;
|
|
98
|
+
}
|
|
99
|
+
export interface SyncDebugLogOptions {
|
|
100
|
+
/** Max retained events (default 500). */
|
|
101
|
+
capacity?: number;
|
|
102
|
+
/** ISO clock, injectable for deterministic tests. */
|
|
103
|
+
clock?: () => string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create an in-memory debug log backed by a circular buffer.
|
|
107
|
+
*/
|
|
108
|
+
export declare const createSyncDebugLog: (options?: SyncDebugLogOptions) => SyncDebugLog;
|
|
109
|
+
/** Resolve a `debug` config value (boolean | options) into a log or undefined. */
|
|
110
|
+
export declare const resolveDebugLog: (debug: boolean | SyncDebugLogOptions | undefined) => SyncDebugLog | undefined;
|
|
111
|
+
//# sourceMappingURL=debugLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugLog.d.ts","sourceRoot":"","sources":["../../src/debug/debugLog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAEpD,4EAA4E;AAC5E,MAAM,MAAM,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}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SyncDebugLog — an opt-in, in-memory event recorder for @terreno/syncdb.
|
|
3
|
+
*
|
|
4
|
+
* It captures the semantic sync events the client produces (local mutations,
|
|
5
|
+
* inbound server deltas/patches, outbox send/ack/nack/retry/failure, conflicts,
|
|
6
|
+
* reconcile/replay phases, connectivity) into a fixed-capacity circular buffer.
|
|
7
|
+
* This is the data source behind the "sync debugger" UI (a Redux-DevTools-style
|
|
8
|
+
* live stream) and is deliberately shaped as a plain, JSON-serializable snapshot
|
|
9
|
+
* so the same surface can be exposed over MCP in the future without change:
|
|
10
|
+
*
|
|
11
|
+
* const snapshot = client.debug?.snapshot(); // -> return straight from an MCP tool
|
|
12
|
+
*
|
|
13
|
+
* Design notes:
|
|
14
|
+
* - Zero overhead when disabled: the client never constructs event objects unless
|
|
15
|
+
* a log exists (call sites guard with `emit?.(...)`, which short-circuits arg
|
|
16
|
+
* evaluation).
|
|
17
|
+
* - Circular buffer (no array shifts) so recording stays O(1) under bursts.
|
|
18
|
+
* - `subscribe` delivers each new event individually so consumers can append
|
|
19
|
+
* without re-reading the whole buffer; `getRevision` powers `useSyncExternalStore`.
|
|
20
|
+
*/
|
|
21
|
+
import { DateTime } from "luxon";
|
|
22
|
+
const DEFAULT_CAPACITY = 500;
|
|
23
|
+
const emptyByType = () => ({
|
|
24
|
+
ack: 0,
|
|
25
|
+
conflict: 0,
|
|
26
|
+
connect: 0,
|
|
27
|
+
delta: 0,
|
|
28
|
+
disconnect: 0,
|
|
29
|
+
failed: 0,
|
|
30
|
+
mutate: 0,
|
|
31
|
+
nack: 0,
|
|
32
|
+
reconcile: 0,
|
|
33
|
+
replay: 0,
|
|
34
|
+
resolve: 0,
|
|
35
|
+
retry: 0,
|
|
36
|
+
send: 0,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Create an in-memory debug log backed by a circular buffer.
|
|
40
|
+
*/
|
|
41
|
+
export const createSyncDebugLog = (options = {}) => {
|
|
42
|
+
const capacity = Math.max(1, options.capacity ?? DEFAULT_CAPACITY);
|
|
43
|
+
const clock = options.clock ?? (() => DateTime.now().toISO() ?? new Date().toISOString());
|
|
44
|
+
const buffer = new Array(capacity);
|
|
45
|
+
let writeIndex = 0;
|
|
46
|
+
let retained = 0;
|
|
47
|
+
let nextId = 1;
|
|
48
|
+
let total = 0;
|
|
49
|
+
let dropped = 0;
|
|
50
|
+
let revision = 0;
|
|
51
|
+
const byType = emptyByType();
|
|
52
|
+
let firstEventAt;
|
|
53
|
+
let lastEventAt;
|
|
54
|
+
const listeners = new Set();
|
|
55
|
+
const record = (input) => {
|
|
56
|
+
const event = {
|
|
57
|
+
...input,
|
|
58
|
+
id: nextId++,
|
|
59
|
+
timestamp: input.timestamp ?? clock(),
|
|
60
|
+
};
|
|
61
|
+
// Evict the slot we are about to overwrite once the buffer is saturated.
|
|
62
|
+
if (retained === capacity) {
|
|
63
|
+
dropped++;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
retained++;
|
|
67
|
+
}
|
|
68
|
+
buffer[writeIndex] = event;
|
|
69
|
+
writeIndex = (writeIndex + 1) % capacity;
|
|
70
|
+
total++;
|
|
71
|
+
byType[event.type]++;
|
|
72
|
+
if (!firstEventAt) {
|
|
73
|
+
firstEventAt = event.timestamp;
|
|
74
|
+
}
|
|
75
|
+
lastEventAt = event.timestamp;
|
|
76
|
+
revision++;
|
|
77
|
+
for (const listener of listeners) {
|
|
78
|
+
listener(event);
|
|
79
|
+
}
|
|
80
|
+
return event;
|
|
81
|
+
};
|
|
82
|
+
const getEvents = () => {
|
|
83
|
+
const events = [];
|
|
84
|
+
const start = (writeIndex - retained + capacity) % capacity;
|
|
85
|
+
for (let i = 0; i < retained; i++) {
|
|
86
|
+
const event = buffer[(start + i) % capacity];
|
|
87
|
+
if (event) {
|
|
88
|
+
events.push(event);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return events;
|
|
92
|
+
};
|
|
93
|
+
const getStats = () => ({
|
|
94
|
+
byType: { ...byType },
|
|
95
|
+
dropped,
|
|
96
|
+
firstEventAt,
|
|
97
|
+
lastEventAt,
|
|
98
|
+
retained,
|
|
99
|
+
total,
|
|
100
|
+
});
|
|
101
|
+
const snapshot = () => ({
|
|
102
|
+
capacity,
|
|
103
|
+
events: getEvents(),
|
|
104
|
+
stats: getStats(),
|
|
105
|
+
});
|
|
106
|
+
const subscribe = (listener) => {
|
|
107
|
+
listeners.add(listener);
|
|
108
|
+
return () => {
|
|
109
|
+
listeners.delete(listener);
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const clear = () => {
|
|
113
|
+
buffer.fill(undefined);
|
|
114
|
+
writeIndex = 0;
|
|
115
|
+
retained = 0;
|
|
116
|
+
// E6: reset every derived stat to match the now-empty buffer, not just
|
|
117
|
+
// `retained` — leaving `total`/`dropped`/`byType`/`firstEventAt`/
|
|
118
|
+
// `lastEventAt` at their pre-clear values produced an incoherent
|
|
119
|
+
// snapshot (e.g. `retained: 0` alongside `byType.mutate: 5` and a
|
|
120
|
+
// `total` that no longer describes anything the log still holds).
|
|
121
|
+
// `nextId` is NOT reset: ids stay monotonic across a clear so a listener
|
|
122
|
+
// that cached an event by id never collides with a later one.
|
|
123
|
+
total = 0;
|
|
124
|
+
dropped = 0;
|
|
125
|
+
for (const type of Object.keys(byType)) {
|
|
126
|
+
byType[type] = 0;
|
|
127
|
+
}
|
|
128
|
+
firstEventAt = undefined;
|
|
129
|
+
lastEventAt = undefined;
|
|
130
|
+
revision++;
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
capacity,
|
|
134
|
+
clear,
|
|
135
|
+
getEvents,
|
|
136
|
+
getRevision: () => revision,
|
|
137
|
+
getStats,
|
|
138
|
+
record,
|
|
139
|
+
snapshot,
|
|
140
|
+
subscribe,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/** Resolve a `debug` config value (boolean | options) into a log or undefined. */
|
|
144
|
+
export const resolveDebugLog = (debug) => {
|
|
145
|
+
if (!debug) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
return createSyncDebugLog(debug === true ? {} : debug);
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=debugLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugLog.js","sourceRoot":"","sources":["../../src/debug/debugLog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AA4G/B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,WAAW,GAAG,GAAuC,EAAE,CAAC,CAAC;IAC7D,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAC;IACb,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;CACR,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAA+B,EAAE,EAAgB,EAAE;IACpF,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI,gBAAgB,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,GAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAElG,MAAM,MAAM,GAAmC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnE,IAAI,UAAU,GAAG,CAAC,CAAC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QACZ,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAyB,EAAE,CAAC;YAC/D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,YAAY,GAAG,SAAS,CAAC;QACzB,WAAW,GAAG,SAAS,CAAC;QACxB,QAAQ,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,KAAK;QACL,SAAS;QACT,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ;QAC3B,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAgD,EACtB,EAAE;IAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,kBAAkB,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugLog.test.d.ts","sourceRoot":"","sources":["../../src/debug/debugLog.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { createSyncDebugLog, resolveDebugLog } from "./debugLog";
|
|
3
|
+
describe("createSyncDebugLog", () => {
|
|
4
|
+
it("assigns monotonic ids and timestamps and preserves order", () => {
|
|
5
|
+
let tick = 0;
|
|
6
|
+
const log = createSyncDebugLog({ clock: () => `2026-01-01T00:00:0${tick++}.000Z` });
|
|
7
|
+
log.record({ direction: "local", label: "one", type: "mutate" });
|
|
8
|
+
log.record({ direction: "inbound", label: "two", type: "delta" });
|
|
9
|
+
const events = log.getEvents();
|
|
10
|
+
expect(events.map((e) => e.id)).toEqual([1, 2]);
|
|
11
|
+
expect(events.map((e) => e.label)).toEqual(["one", "two"]);
|
|
12
|
+
expect(events[0].timestamp).toBe("2026-01-01T00:00:00.000Z");
|
|
13
|
+
expect(events[1].timestamp).toBe("2026-01-01T00:00:01.000Z");
|
|
14
|
+
});
|
|
15
|
+
it("evicts oldest events beyond capacity (circular buffer)", () => {
|
|
16
|
+
const log = createSyncDebugLog({ capacity: 3 });
|
|
17
|
+
for (let i = 1; i <= 5; i++) {
|
|
18
|
+
log.record({ direction: "local", label: `e${i}`, type: "mutate" });
|
|
19
|
+
}
|
|
20
|
+
const events = log.getEvents();
|
|
21
|
+
expect(events).toHaveLength(3);
|
|
22
|
+
expect(events.map((e) => e.label)).toEqual(["e3", "e4", "e5"]);
|
|
23
|
+
expect(events.map((e) => e.id)).toEqual([3, 4, 5]);
|
|
24
|
+
const stats = log.getStats();
|
|
25
|
+
expect(stats.total).toBe(5);
|
|
26
|
+
expect(stats.retained).toBe(3);
|
|
27
|
+
expect(stats.dropped).toBe(2);
|
|
28
|
+
expect(stats.byType.mutate).toBe(5);
|
|
29
|
+
});
|
|
30
|
+
it("notifies subscribers with each new event and supports unsubscribe", () => {
|
|
31
|
+
const log = createSyncDebugLog();
|
|
32
|
+
const received = [];
|
|
33
|
+
const unsubscribe = log.subscribe((event) => received.push(event.label));
|
|
34
|
+
log.record({ direction: "local", label: "a", type: "mutate" });
|
|
35
|
+
unsubscribe();
|
|
36
|
+
log.record({ direction: "local", label: "b", type: "mutate" });
|
|
37
|
+
expect(received).toEqual(["a"]);
|
|
38
|
+
});
|
|
39
|
+
it("bumps revision on record and clear", () => {
|
|
40
|
+
const log = createSyncDebugLog();
|
|
41
|
+
expect(log.getRevision()).toBe(0);
|
|
42
|
+
log.record({ direction: "local", label: "a", type: "mutate" });
|
|
43
|
+
expect(log.getRevision()).toBe(1);
|
|
44
|
+
log.clear();
|
|
45
|
+
expect(log.getRevision()).toBe(2);
|
|
46
|
+
expect(log.getEvents()).toHaveLength(0);
|
|
47
|
+
// E6: clear() resets every derived stat coherently — total (and
|
|
48
|
+
// everything else getStats() reports) describes only what happened
|
|
49
|
+
// since the last clear, not a lifetime count that would otherwise be
|
|
50
|
+
// inconsistent with retained: 0.
|
|
51
|
+
expect(log.getStats().total).toBe(0);
|
|
52
|
+
});
|
|
53
|
+
it("clear() resets total/dropped/byType/firstEventAt/lastEventAt, not just retained (E6)", () => {
|
|
54
|
+
const log = createSyncDebugLog({ capacity: 2 });
|
|
55
|
+
log.record({ direction: "local", label: "a", type: "mutate" });
|
|
56
|
+
log.record({ direction: "inbound", label: "b", type: "delta" });
|
|
57
|
+
// Overflow past capacity to also populate `dropped`.
|
|
58
|
+
log.record({ direction: "inbound", label: "c", type: "ack" });
|
|
59
|
+
const beforeClear = log.getStats();
|
|
60
|
+
expect(beforeClear.total).toBe(3);
|
|
61
|
+
expect(beforeClear.dropped).toBe(1);
|
|
62
|
+
expect(beforeClear.byType.mutate).toBe(1);
|
|
63
|
+
expect(beforeClear.firstEventAt).toBeDefined();
|
|
64
|
+
expect(beforeClear.lastEventAt).toBeDefined();
|
|
65
|
+
log.clear();
|
|
66
|
+
const afterClear = log.getStats();
|
|
67
|
+
expect(afterClear).toEqual({
|
|
68
|
+
byType: {
|
|
69
|
+
ack: 0,
|
|
70
|
+
conflict: 0,
|
|
71
|
+
connect: 0,
|
|
72
|
+
delta: 0,
|
|
73
|
+
disconnect: 0,
|
|
74
|
+
failed: 0,
|
|
75
|
+
mutate: 0,
|
|
76
|
+
nack: 0,
|
|
77
|
+
reconcile: 0,
|
|
78
|
+
replay: 0,
|
|
79
|
+
resolve: 0,
|
|
80
|
+
retry: 0,
|
|
81
|
+
send: 0,
|
|
82
|
+
},
|
|
83
|
+
dropped: 0,
|
|
84
|
+
firstEventAt: undefined,
|
|
85
|
+
lastEventAt: undefined,
|
|
86
|
+
retained: 0,
|
|
87
|
+
total: 0,
|
|
88
|
+
});
|
|
89
|
+
// A fresh record after clear reports as if the log were brand new, and
|
|
90
|
+
// ids stay monotonic (not reset) across the clear.
|
|
91
|
+
const next = log.record({ direction: "local", label: "d", type: "mutate" });
|
|
92
|
+
expect(next.id).toBe(4);
|
|
93
|
+
expect(log.getStats()).toMatchObject({
|
|
94
|
+
byType: { mutate: 1 },
|
|
95
|
+
dropped: 0,
|
|
96
|
+
retained: 1,
|
|
97
|
+
total: 1,
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
it("snapshot returns a serializable events + stats view", () => {
|
|
101
|
+
const log = createSyncDebugLog({ capacity: 10 });
|
|
102
|
+
log.record({ collection: "todos", direction: "local", label: "create", type: "mutate" });
|
|
103
|
+
const snapshot = log.snapshot();
|
|
104
|
+
expect(snapshot.capacity).toBe(10);
|
|
105
|
+
expect(snapshot.events).toHaveLength(1);
|
|
106
|
+
expect(snapshot.stats.total).toBe(1);
|
|
107
|
+
// Must round-trip through JSON unchanged (MCP-facing contract).
|
|
108
|
+
expect(JSON.parse(JSON.stringify(snapshot))).toEqual(snapshot);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe("resolveDebugLog", () => {
|
|
112
|
+
it("returns undefined when disabled", () => {
|
|
113
|
+
expect(resolveDebugLog(undefined)).toBeUndefined();
|
|
114
|
+
expect(resolveDebugLog(false)).toBeUndefined();
|
|
115
|
+
});
|
|
116
|
+
it("creates a log for true or options", () => {
|
|
117
|
+
expect(resolveDebugLog(true)?.capacity).toBe(500);
|
|
118
|
+
expect(resolveDebugLog({ capacity: 25 })?.capacity).toBe(25);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=debugLog.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugLog.test.js","sourceRoot":"","sources":["../../src/debug/debugLog.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAC,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;A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AAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrC,gEAAgE;QAChE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACnD,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,MAAM,CAAC,eAAe,CAAC,EAAC,QAAQ,EAAE,EAAE,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @terreno/syncdb — local-first data layer for Terreno apps.
|
|
3
|
+
*
|
|
4
|
+
* The on-device store (TinyBase MergeableStore) is the UI's source of truth:
|
|
5
|
+
* reads come from the local store, writes apply optimistically to local state and a
|
|
6
|
+
* durable outbox, and the server is asynchronous reconciliation over a websocket
|
|
7
|
+
* delta protocol with HTTP snapshot catch-up. Supersedes @terreno/rtk for
|
|
8
|
+
* data-synchronization concerns. See docs/implementationPlans/syncdb-local-first.md.
|
|
9
|
+
*
|
|
10
|
+
* This module is the package's public API: everything re-exported here is
|
|
11
|
+
* semver-protected, and everything else under `src/` is an internal detail that may
|
|
12
|
+
* change in a patch release. Deliberately absent are the pieces that let a host app
|
|
13
|
+
* corrupt the store's invariants behind the client's back — cell-level cursor
|
|
14
|
+
* mutators, outbox/conflict writers, raw row shapes, the IndexedDB helpers, and the
|
|
15
|
+
* debug broadcast bridge. Reach for `client.store`/`client.outbox` (or the React
|
|
16
|
+
* hooks) instead, and open an issue if something genuinely needs promoting.
|
|
17
|
+
*
|
|
18
|
+
* Two other entry points exist:
|
|
19
|
+
* - `@terreno/syncdb/react` (src/react/index.ts) — React bindings. They live on
|
|
20
|
+
* their own subpath because react is an optional peer dependency and this entry
|
|
21
|
+
* must stay importable without it.
|
|
22
|
+
* - `@terreno/syncdb/testing` (src/testing/index.ts) — test doubles such as
|
|
23
|
+
* `createFakeTransport`, kept out of production bundles.
|
|
24
|
+
*/
|
|
25
|
+
export { createSyncDb, DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_SEQ_JUMP_RECONCILE_MIN_INTERVAL_MS, DEFAULT_START_AUTH_RETRY_ATTEMPTS, DEFAULT_START_AUTH_RETRY_DELAY_MS, DEFAULT_TOMBSTONE_RETENTION_MS, type ForceResyncResult, type ForceResyncSkipReason, type MutateArgs, type SyncDb, type SyncDbConfig, } from "./client";
|
|
26
|
+
export type { AuthProvider, ConflictResolutionStrategy, OutboxMutation, OutboxStatus, SyncAck, SyncCollectionStatus, SyncConflict, SyncDelta, SyncEntitiesResponse, SyncMutateBatchRequest, SyncMutateBatchResponse, SyncMutateBatchResult, SyncMutateRequest, SyncMutationOperation, SyncNack, SyncNackCode, SyncSnapshotEntity, SyncSnapshotResponse, SyncStatus, SyncStreamInfo, } from "./types";
|
|
27
|
+
export { listConflicts } from "./mutations/conflicts";
|
|
28
|
+
export { generateMutationId, type Outbox } from "./mutations/outbox";
|
|
29
|
+
export type { SyncStore } from "./storage/store";
|
|
30
|
+
export { OUTBOX_TABLE, type SyncEntity } from "./storage/types";
|
|
31
|
+
export { wipeLocalData } from "./storage/wipe";
|
|
32
|
+
export { type BetterAuthAdapterOptions, betterAuthAdapter, DEFAULT_AUTH_POLL_INTERVAL_MS, } from "./auth/betterAuthAdapter";
|
|
33
|
+
export type { BetterAuthClientLike, BetterAuthGetSessionResult, BetterAuthSessionAtomLike, BetterAuthSessionDataLike, BetterAuthSessionLike, BetterAuthUserLike, } from "./auth/types";
|
|
34
|
+
export { AES_GCM_ENVELOPE_VERSION, createAesGcmCodec, PayloadIntegrityError, UnknownEnvelopeVersionError, } from "./crypto/aesGcmCodec";
|
|
35
|
+
export { identityCodec } from "./crypto/identityCodec";
|
|
36
|
+
export { createKeyProviderCodec, createLocalKeyProvider, createServerKeyProvider, DEFAULT_KEY_CACHE_DB_NAME, } from "./crypto/keyProviders";
|
|
37
|
+
export type { KeyProvider, PayloadCodec } from "./crypto/types";
|
|
38
|
+
export { createDefaultPersisterFactory } from "./persisters/defaultPersisterFactory";
|
|
39
|
+
export { createEncryptedIndexedDbPersister } from "./persisters/encryptedIndexedDbPersister";
|
|
40
|
+
export { clearMemoryPersisterData, createMemoryPersister, memoryPersisterFactory, } from "./persisters/memoryPersister";
|
|
41
|
+
export type { DefaultPersisterFactoryConfig, PersisterFactory } from "./persisters/types";
|
|
42
|
+
export { AuthRequiredError, createHttpChannel, type FetchLike, type FetchSnapshotPageArgs, type HttpChannel, type HttpChannelConfig, } from "./sync/httpChannel";
|
|
43
|
+
export { createSocketTransport, type SocketTransportConfig } from "./sync/socketTransport";
|
|
44
|
+
export { DEFAULT_BATCH_SIZE, DEFAULT_MUTATION_TIMEOUT_MS, type SendMutationBatchResult, type SendMutationResult, type SyncTransport, type TransportStatus, } from "./sync/transport";
|
|
45
|
+
export type { SyncDebugDirection, SyncDebugEvent, SyncDebugEventType, SyncDebugLog, SyncDebugLogOptions, SyncDebugRecordInput, SyncDebugSnapshot, SyncDebugStats, } from "./debug/debugLog";
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EACL,YAAY,EACZ,6BAA6B,EAC7B,0CAA0C,EAC1C,iCAAiC,EACjC,iCAAiC,EACjC,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAIlB,YAAY,EACV,YAAY,EACZ,0BAA0B,EAC1B,cAAc,EACd,YAAY,EACZ,OAAO,EACP,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,cAAc,GACf,MAAM,SAAS,CAAC;AASjB,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,kBAAkB,EAAE,KAAK,MAAM,EAAC,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAE,KAAK,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EACL,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,yBA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ps.
|
|
3
|
+
*
|
|
4
|
+
* The on-device store (TinyBase MergeableStore) is the UI's source of truth:
|
|
5
|
+
* reads come from the local store, writes apply optimistically to local state and a
|
|
6
|
+
* durable outbox, and the server is asynchronous reconciliation over a websocket
|
|
7
|
+
* delta protocol with HTTP snapshot catch-up. Supersedes @terreno/rtk for
|
|
8
|
+
* data-synchronization concerns. See docs/implementationPlans/syncdb-local-first.md.
|
|
9
|
+
*
|
|
10
|
+
* This module is the package's public API: everything re-exported here is
|
|
11
|
+
* semver-protected, and everything else under `src/` is an internal detail that may
|
|
12
|
+
* change in a patch release. Deliberately absent are the pieces that let a host app
|
|
13
|
+
* corrupt the store's invariants behind the client's back — cell-level cursor
|
|
14
|
+
* mutators, outbox/conflict writers, raw row shapes, the IndexedDB helpers, and the
|
|
15
|
+
* debug broadcast bridge. Reach for `client.store`/`client.outbox` (or the React
|
|
16
|
+
* hooks) instead, and open an issue if something genuinely needs promoting.
|
|
17
|
+
*
|
|
18
|
+
* Two other entry points exist:
|
|
19
|
+
* - `@terreno/syncdb/react` (src/react/index.ts) — React bindings. They live on
|
|
20
|
+
* their own subpath because react is an optional peer dependency and this entry
|
|
21
|
+
* must stay importable without it.
|
|
22
|
+
* - `@terreno/syncdb/testing` (src/testing/index.ts) — test doubles such as
|
|
23
|
+
* `createFakeTransport`, kept out of production bundles.
|
|
24
|
+
*/
|
|
25
|
+
// --- Client ---------------------------------------------------------------
|
|
26
|
+
export { createSyncDb, DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_SEQ_JUMP_RECONCILE_MIN_INTERVAL_MS, DEFAULT_START_AUTH_RETRY_ATTEMPTS, DEFAULT_START_AUTH_RETRY_DELAY_MS, DEFAULT_TOMBSTONE_RETENTION_MS, } from "./client";
|
|
27
|
+
// --- Local store and outbox (read surface) -------------------------------
|
|
28
|
+
// `client.store` is typed as SyncStore and `client.outbox` as Outbox;
|
|
29
|
+
// OUTBOX_TABLE names the table to pass to `client.store.raw.getTable(...)` when
|
|
30
|
+
// inspecting queued mutations directly (what the example app's sync health UI
|
|
31
|
+
// does). Reading conflicts outside React goes through `listConflicts`; writing to
|
|
32
|
+
// any reserved table is the client's job alone.
|
|
33
|
+
export { listConflicts } from "./mutations/conflicts";
|
|
34
|
+
export { generateMutationId } from "./mutations/outbox";
|
|
35
|
+
export { OUTBOX_TABLE } from "./storage/types";
|
|
36
|
+
export { wipeLocalData } from "./storage/wipe";
|
|
37
|
+
// --- Auth -----------------------------------------------------------------
|
|
38
|
+
export { betterAuthAdapter, DEFAULT_AUTH_POLL_INTERVAL_MS, } from "./auth/betterAuthAdapter";
|
|
39
|
+
// --- Encryption (web persistence) ----------------------------------------
|
|
40
|
+
export { AES_GCM_ENVELOPE_VERSION, createAesGcmCodec, PayloadIntegrityError, UnknownEnvelopeVersionError, } from "./crypto/aesGcmCodec";
|
|
41
|
+
export { identityCodec } from "./crypto/identityCodec";
|
|
42
|
+
export { createKeyProviderCodec, createLocalKeyProvider, createServerKeyProvider, DEFAULT_KEY_CACHE_DB_NAME, } from "./crypto/keyProviders";
|
|
43
|
+
// --- Persisters -----------------------------------------------------------
|
|
44
|
+
export { createDefaultPersisterFactory } from "./persisters/defaultPersisterFactory";
|
|
45
|
+
export { createEncryptedIndexedDbPersister } from "./persisters/encryptedIndexedDbPersister";
|
|
46
|
+
export { clearMemoryPersisterData, createMemoryPersister, memoryPersisterFactory, } from "./persisters/memoryPersister";
|
|
47
|
+
// --- Transports (only needed to override the defaults) -------------------
|
|
48
|
+
export { AuthRequiredError, createHttpChannel, } from "./sync/httpChannel";
|
|
49
|
+
export { createSocketTransport } from "./sync/socketTransport";
|
|
50
|
+
export { DEFAULT_BATCH_SIZE, DEFAULT_MUTATION_TIMEOUT_MS, } from "./sync/transport";
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultPersisterFactoryNative.isolated.d.ts","sourceRoot":"","sources":["../../src/isolated/defaultPersisterFactoryNative.isolated.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolated test (own `bun test` invocation via scripts/check-coverage.ts):
|
|
3
|
+
* `mock.module` replaces the expo-sqlite native module and TinyBase's
|
|
4
|
+
* expo-sqlite persister module globally for the process (the latter imports
|
|
5
|
+
* expo-sqlite at its top level, which cannot load outside React Native), so
|
|
6
|
+
* this must not share a test pass with the rest of the suite.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
9
|
+
const fakeDb = { fake: true };
|
|
10
|
+
const fakePersister = { marker: "fake-persister" };
|
|
11
|
+
const openDatabaseSync = mock((_databaseName) => fakeDb);
|
|
12
|
+
const createExpoSqlitePersister = mock((_store, _db, _tableName) => fakePersister);
|
|
13
|
+
mock.module("expo-sqlite", () => ({ openDatabaseSync }));
|
|
14
|
+
mock.module("tinybase/persisters/persister-expo-sqlite", () => ({ createExpoSqlitePersister }));
|
|
15
|
+
import { createDefaultPersisterFactory } from "../persisters/defaultPersisterFactory.native";
|
|
16
|
+
import { createSyncStore } from "../storage/store";
|
|
17
|
+
describe("createDefaultPersisterFactory (native)", () => {
|
|
18
|
+
it("opens the expo-sqlite database lazily and wires the JSON-mode persister", () => {
|
|
19
|
+
const factory = createDefaultPersisterFactory();
|
|
20
|
+
// Nothing touches expo-sqlite until a persister is actually created.
|
|
21
|
+
expect(openDatabaseSync).not.toHaveBeenCalled();
|
|
22
|
+
const store = createSyncStore({ collections: ["todos"] });
|
|
23
|
+
const persister = factory({ databaseName: "terreno-syncdb.db", store: store.raw });
|
|
24
|
+
expect(openDatabaseSync).toHaveBeenCalledWith("terreno-syncdb.db");
|
|
25
|
+
// JSON serialization mode: the third argument is a string table name
|
|
26
|
+
// (tabular config objects cannot persist MergeableStore CRDT metadata).
|
|
27
|
+
expect(createExpoSqlitePersister).toHaveBeenCalledWith(store.raw, fakeDb, "terreno_syncdb");
|
|
28
|
+
expect(persister).toBe(fakePersister);
|
|
29
|
+
});
|
|
30
|
+
it("honors a custom storeTableName", () => {
|
|
31
|
+
const factory = createDefaultPersisterFactory({ storeTableName: "custom_table" });
|
|
32
|
+
const store = createSyncStore({ collections: ["todos"] });
|
|
33
|
+
factory({ databaseName: "custom.db", store: store.raw });
|
|
34
|
+
expect(openDatabaseSync).toHaveBeenCalledWith("custom.db");
|
|
35
|
+
expect(createExpoSqlitePersister).toHaveBeenCalledWith(store.raw, fakeDb, "custom_table");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=defaultPersisterFactoryNative.isolated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultPersisterFactoryNative.isolated.js","sourceRoot":"","sources":["../../src/isolated/defaultPersisterFactoryNative.isolated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAC,MAAM,UAAU,CAAC;AAEpD,MAAM,MAAM,GAAG,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;AAC5B,MAAM,aAAa,GAAG,EAAC,MAAM,EAAE,gBAAgB,EAAC,CAAC;AACjD,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,aAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;AACjE,MAAM,yBAAyB,GAAG,IAAI,CACpC,CAAC,MAAe,EAAE,GAAY,EAAE,UAAkB,EAAE,EAAE,CAAC,aAAa,CACrE,CAAC;AAEF,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,EAAC,gBAAgB,EAAC,CAAC,CAAC,CAAC;AACvD,IAAI,CAAC,MAAM,CAAC,2CAA2C,EAAE,GAAG,EAAE,CAAC,CAAC,EAAC,yBAA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WAAW,CAAC,CAAC;QAC3D,MAAM,CAAC,yBAAyB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SyncStore } from "../storage/store";
|
|
2
|
+
import type { SyncConflict } from "../types";
|
|
3
|
+
/** Record an unresolved conflict in the `_conflicts` table (rowId = mutationId). */
|
|
4
|
+
export declare const writeConflict: ({ store, conflict, }: {
|
|
5
|
+
store: SyncStore;
|
|
6
|
+
conflict: SyncConflict;
|
|
7
|
+
}) => void;
|
|
8
|
+
/** Read one conflict by its mutationId, or undefined when absent (or a husk row). */
|
|
9
|
+
export declare const getConflict: ({ store, mutationId, }: {
|
|
10
|
+
store: SyncStore;
|
|
11
|
+
mutationId: string;
|
|
12
|
+
}) => SyncConflict | undefined;
|
|
13
|
+
/** Remove a conflict row (after resolution). */
|
|
14
|
+
export declare const deleteConflict: ({ store, mutationId, }: {
|
|
15
|
+
store: SyncStore;
|
|
16
|
+
mutationId: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
/** All unresolved conflicts (dismissed rows excluded unless requested). */
|
|
19
|
+
export declare const listConflicts: ({ store, includeDismissed, }: {
|
|
20
|
+
store: SyncStore;
|
|
21
|
+
includeDismissed?: boolean;
|
|
22
|
+
}) => SyncConflict[];
|
|
23
|
+
/**
|
|
24
|
+
* Delete husk `_conflicts` rows (see {@link isActionable}) so they stop
|
|
25
|
+
* inflating conflict counts in a store that persisted them. Returns the
|
|
26
|
+
* mutationIds removed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const pruneGhostConflicts: ({ store }: {
|
|
29
|
+
store: SyncStore;
|
|
30
|
+
}) => string[];
|
|
31
|
+
//# sourceMappingURL=conflicts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflicts.d.ts","sourceRoot":"","sources":["../../src/mutations/conflicts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAuB3C,oFAAoF;AACpF,eAAO,MAAM,aAAa,GAAI,sBAG3B;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;CACxB,KAAG,IAIH,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,WAAW,GAAI,wBAGzB;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,YAAY,GAAG,SASlB,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,cAAc,GAAI,wBAG5B;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,IAEH,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,aAAa,GAAI,8BAG3B;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,KAAG,YAAY,EAcf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAS;IAAC,KAAK,EAAE,SAAS,CAAA;CAAC,KAAG,MAAM,EAUvE,CAAC"}
|