@doync/client 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -17
  2. package/dist/adapter.cjs +1 -1
  3. package/dist/adapter.d.cts +1 -1
  4. package/dist/adapter.d.ts +1 -1
  5. package/dist/adapter.js +1 -1
  6. package/dist/adapter.js.map +1 -1
  7. package/dist/client-Bv6QMenB.cjs +15 -0
  8. package/dist/client-Db0Jfwuy.js +16 -0
  9. package/dist/client-Db0Jfwuy.js.map +1 -0
  10. package/dist/{client-CNyLMCw0.d.ts → client-OAVaC3pt.d.ts} +79 -91
  11. package/dist/client-OAVaC3pt.d.ts.map +1 -0
  12. package/dist/{client-DHXO0dbf.d.cts → client-OPt8Axyp.d.cts} +79 -91
  13. package/dist/client-OPt8Axyp.d.cts.map +1 -0
  14. package/dist/index.d.cts +3 -2
  15. package/dist/index.d.ts +3 -2
  16. package/dist/internal.cjs +1 -1
  17. package/dist/internal.d.cts +3 -12
  18. package/dist/internal.d.cts.map +1 -1
  19. package/dist/internal.d.ts +3 -12
  20. package/dist/internal.d.ts.map +1 -1
  21. package/dist/internal.js +1 -1
  22. package/package.json +3 -3
  23. package/src/client.ts +82 -32
  24. package/src/engine.ts +188 -134
  25. package/src/index.ts +1 -6
  26. package/src/internal.ts +4 -4
  27. package/src/migrate.ts +1 -1
  28. package/src/replica/db/0002_prefs_table.sql +9 -0
  29. package/src/replica/db/meta/0002_snapshot.json +191 -0
  30. package/src/replica/db/meta/_journal.json +7 -0
  31. package/src/replica/db/schema.ts +12 -3
  32. package/src/replica/index.ts +5 -4
  33. package/src/replica/meta.ts +23 -0
  34. package/src/replica/track.ts +20 -39
  35. package/src/socket-reconnect.ts +29 -5
  36. package/dist/client-C6jAdhbe.cjs +0 -15
  37. package/dist/client-CNyLMCw0.d.ts.map +0 -1
  38. package/dist/client-ClV8ce6X.js +0 -16
  39. package/dist/client-ClV8ce6X.js.map +0 -1
  40. package/dist/client-DHXO0dbf.d.cts.map +0 -1
  41. package/src/client-mutation-registry.ts +0 -31
  42. package/src/mutations.ts +0 -96
@@ -1,5 +1,5 @@
1
1
  import { ClientMessage, ServerMessage } from "@doync/core/internal";
2
- import { BoundQuery, DoyncSchema, MutationDefinition, MutationTree, SqlValue } from "@doync/core";
2
+ import { AuthContext, AuthData, BoundQuery, DoyncSchema, MutationDefinition, MutationTree, SqlValue } from "@doync/core";
3
3
 
4
4
  //#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
5
5
  /** The Standard Typed interface. This is a base type extended by other specs. */
@@ -126,48 +126,6 @@ interface LocalDb {
126
126
  */
127
127
  declare function extractWriteTable(sql: string): string | null;
128
128
  //#endregion
129
- //#region src/mutations.d.ts
130
- /**
131
- * Write surface a client mutation body runs against: one parameterized
132
- * statement at a time inside the mutation's savepoint, returning its rows. Same
133
- * shape the Origin uses, so a shared body runs identically on device and
134
- * server.
135
- */
136
- interface ClientMutationTx {
137
- exec<T extends LocalRow = LocalRow>(query: string, ...params: SqlValue[]): T[];
138
- }
139
- /**
140
- * Client mutation body `(args, ctx, sql)`. Must be deterministic and DB-only
141
- * (may still be async for local work). Generate ids on the client and pass them
142
- * in `args` — the body is replayed on rebase. External I/O belongs in a server
143
- * override, not the client bundle.
144
- */
145
- type ClientMutationHandler = (args: unknown, ctx: Record<string, unknown>, sql: ClientMutationTx) => void | Promise<void>;
146
- /**
147
- * A registered client mutation: body plus optional standard-schema args
148
- * validator applied at `mutate()` time. A bare handler is also accepted.
149
- */
150
- interface ClientMutation {
151
- readonly args?: StandardSchemaV1;
152
- readonly handler: ClientMutationHandler;
153
- }
154
- /**
155
- * Name-keyed client mutation registry. Keys match the server's dotted names so
156
- * a push reaches the matching authoritative body.
157
- */
158
- type ClientMutationRegistry = Readonly<Record<string, ClientMutation | ClientMutationHandler>>;
159
- /**
160
- * Normalize a registry entry (bare handler or `{args, handler}`) to the object
161
- * form.
162
- */
163
- declare function asClientMutation(entry: ClientMutation | ClientMutationHandler): ClientMutation;
164
- /**
165
- * Validate `args` through a standard-schema synchronously (mirrors
166
- * `@doync/core` query-args). Async validators refuse loudly — the body is
167
- * deterministic on both ends. Returns validated value or throws.
168
- */
169
- declare function validateMutationArgs(schema: StandardSchemaV1, args: unknown): unknown;
170
- //#endregion
171
129
  //#region src/socket.d.ts
172
130
  /**
173
131
  * Minimal transport the client engine uses to talk to its Mirror. Platform
@@ -217,6 +175,13 @@ interface SyncSocketHandlers {
217
175
  declare function readMeta(db: LocalDb, key: string): string | null;
218
176
  /** Upsert one `__doync_meta` value. Columns are `k`/`v` (ADR-0024). */
219
177
  declare function writeMeta(db: LocalDb, key: string, value: string): void;
178
+ /**
179
+ * Read one `__doync_prefs` value, or `null` if unset. Columns are `k`/`v`
180
+ * (ADR-0024).
181
+ */
182
+ declare function readPref(db: LocalDb, key: string): string | null;
183
+ /** Upsert one `__doync_prefs` value. Columns are `k`/`v` (ADR-0024). */
184
+ declare function writePref(db: LocalDb, key: string, value: string): void;
220
185
  //#endregion
221
186
  //#region src/replica/stamps.d.ts
222
187
  /**
@@ -275,8 +240,9 @@ declare function applyBundledMigrations(db: LocalDb, schema: DoyncSchema, fromVe
275
240
  * Drop every consumer (synced) table (ADR-0020's wipe fallback): the first step
276
241
  * of wipe-replica-and-resync, run with foreign keys already off so no cascade
277
242
  * fires and drop order is irrelevant (ADR-0009). `__doync_`-prefixed engine
278
- * tables the pending queue, clientId, and `__doync_engine` ledger that
279
- * SURVIVE the wipe are left untouched.
243
+ * tables are left alone here; the caller drops pending / sync meta and mints a
244
+ * fresh clientId (ADR-0037). The `__doync_engine` ledger and `__doync_prefs`
245
+ * survive.
280
246
  */
281
247
  declare function dropConsumerTables(db: LocalDb, schema: DoyncSchema): void;
282
248
  //#endregion
@@ -299,12 +265,12 @@ interface MutationResult {
299
265
  */
300
266
  type LogoutBehavior = "keep" | "forget";
301
267
  /**
302
- * The `__doync_meta` key the durable {@link LogoutBehavior} lives under
268
+ * The `__doync_prefs` key the durable {@link LogoutBehavior} lives under
303
269
  * (closeio/doync#135) — shared by the direct engine's
304
270
  * {@link ClientEngine.setLogoutBehavior} / `createClient` write and the web DB
305
271
  * worker's per-identity write + boot read, so the ends can never drift.
306
272
  */
307
- declare const __LOGOUT_BEHAVIOR_META_KEY = "logout_behavior";
273
+ declare const __LOGOUT_BEHAVIOR_PREF_KEY = "logout_behavior";
308
274
  /**
309
275
  * The `__doync_meta` key the Client's durable connected-time counter lives
310
276
  * under (ADR-0014 client-half addendum / closeio/doync#223). Blob-typed
@@ -319,12 +285,17 @@ declare const __CONNECTED_CLOCK_META_KEY = "connected_clock";
319
285
  * after deploying a matching client. Terminal until reload.
320
286
  * - `server-behind` — client is ahead of a mid-deploy Mirror; the client backs
321
287
  * off and re-handshakes automatically.
322
- * - `resync` — local replica/memberships wiped and rebuilding; pending writes and
323
- * clientId survive. Transient; clears when sync resumes.
288
+ * - `resync` — local sync state wiped and rebuilding as a fresh Client under the
289
+ * same identity (pending writes dropped, new clientId). Transient; clears
290
+ * when sync resumes.
291
+ * - `reaped` — same fresh-client rebuild as `resync`, but the Origin forgot this
292
+ * Client (gone past the client-state lifetime). Transient; clears when sync
293
+ * resumes. Distinct so the app can say "you were away too long" rather than
294
+ * "data refreshed".
324
295
  * - `forget` — local store erased (including identity); boots as a fresh client.
325
296
  * Transient; clears when sync resumes.
326
297
  */
327
- type SchemaEventKind = "reload" | "server-behind" | "resync" | "forget";
298
+ type SchemaEventKind = "reload" | "server-behind" | "resync" | "reaped" | "forget";
328
299
  /**
329
300
  * One schema-status transition: `kind` plus a human-readable `message` for
330
301
  * diagnostics (not a control signal). `null` on the client means nominal.
@@ -461,17 +432,18 @@ interface DoyncClient {
461
432
  */
462
433
  onSchemaChange(listener: () => void): () => void;
463
434
  /**
464
- * Wipe the replica and resubscribe while keeping clientId and pending writes.
465
- * Safe "my local data looks wrong" refresh. Optional on the interface —
435
+ * Rebuild sync state as a fresh Client under the same identity: drop pending
436
+ * writes, mint a new clientId, wipe the replica, and rebootstrap. Destructive
437
+ * to unsent work — not a harmless refresh. Optional on the interface —
466
438
  * platform clients implement it.
467
439
  */
468
- resync?(): void;
440
+ resync(): void;
469
441
  /**
470
442
  * Erase this identity's local data (replica, pendings, identity). Privacy /
471
443
  * logout-forget path. Optional on the interface — platform clients implement
472
444
  * it.
473
445
  */
474
- forget?(): void;
446
+ forget(identity?: string): void;
475
447
  /**
476
448
  * Durably set {@link LogoutBehavior} at runtime (e.g. a "remember me"
477
449
  * checkbox). Survives restart. Optional — platform clients implement it.
@@ -542,15 +514,15 @@ interface ClientEngineConfig {
542
514
  * Named mutation bodies resolved on `push` — deterministic, DB-only
543
515
  * (ADR-0017/0021).
544
516
  */
545
- readonly mutations: ClientMutationRegistry;
517
+ readonly mutations: Record<string, MutationDefinition>;
546
518
  /** The Mirror socket seam (ADR-0016). */
547
519
  readonly socket: SyncSocket;
548
520
  /**
549
521
  * The asserted projected auth context (ADR-0018 addendum / closeio/doync#167)
550
522
  * queries and mutation bodies read. Consumer-owned; the library ships no
551
- * decode. Anonymous `{}`.
523
+ * decode. `null` when anonymous.
552
524
  */
553
- readonly ctx?: Record<string, unknown>;
525
+ readonly ctx?: AuthContext;
554
526
  /**
555
527
  * Transport credential PRESENTED as `connect{jwt}` (ADR-0016/0018) — the
556
528
  * Mirror resolves token-first. Auth must ride the HANDSHAKE, not only the
@@ -639,17 +611,17 @@ declare class ClientEngine implements DoyncClient {
639
611
  get schemaStatus(): SchemaEvent | null;
640
612
  mutate<Args = unknown>(mutation: MutationDefinition<Args>, args: Args, options?: MutationOptions): MutationResult;
641
613
  /**
642
- * Adopt a refreshed SAME-USER identity triple (#167). When connected with a
643
- * bearer, send in-band `updateAuth` (ADR-0018 / #85) so the Mirror extends
644
- * auth without reconnect when userId matches and `issuedAt` is newer.
645
- * Identity CHANGE (different `userId`, incl. anon↔user) is topology-level
646
- * replica swap — SharedWorker routes only same-user refreshes here.
614
+ * Adopt a refreshed SAME-USER identity (#167). When connected with a bearer,
615
+ * send in-band `updateAuth` (ADR-0018 / #85) so the Mirror extends auth
616
+ * without reconnect when userId matches and `issuedAt` is newer. Identity
617
+ * CHANGE (different `userId`, incl. anon↔user) is topology-level replica swap
618
+ * — SharedWorker routes only same-user refreshes here.
647
619
  *
648
620
  * Token is stored for the next reconnect (#92: surviving SharedWorker must
649
621
  * not reuse a stale token). `ctx`/`userId` asserted, never derived. Halted
650
- * engines never emit.
622
+ * engines never emit. Pass `ctx: null` for anonymous.
651
623
  */
652
- updateAuth(token: string | null | undefined, ctx?: Record<string, unknown>, userId?: string | null): void;
624
+ updateAuth(token: string | null | undefined, ctx?: AuthContext, userId?: string | null): void;
653
625
  /**
654
626
  * Subscribe to a registered query (ADR-0021): resolve under args+ctx,
655
627
  * register upstream, return a reactive {@link View}. Local snapshots run
@@ -682,23 +654,25 @@ declare class ClientEngine implements DoyncClient {
682
654
  */
683
655
  local<Row extends Record<string, unknown> = Record<string, SqlValue>>(sql: string, ...params: SqlValue[]): View<Row>;
684
656
  /**
685
- * Rebuild sync state (ADR-0022 resync): wipe replica/memberships/cookie, KEEP
686
- * clientId + pending, rebootstrap. Same core as failed-migration and
687
- * cookie-above-head heals ({@link #wipeAndResync}). Exclusive chain; offline
688
- * rebootstrap rides next reconnect.
657
+ * Rebuild sync state as a fresh Client under the same identity (ADR-0022 /
658
+ * ADR-0037 resync): drop pending writes, mint a new clientId, wipe replica /
659
+ * memberships / cookie, rebootstrap. Same core as failed-migration,
660
+ * cookie-above-head, and heldAt-ahead heals ({@link #wipeAndResync}).
661
+ * Exclusive chain; offline rebootstrap rides next reconnect. Preferences
662
+ * survive (`__doync_prefs`).
689
663
  */
690
664
  resync(): void;
691
665
  /**
692
666
  * Erase this identity's local data (ADR-0022 forget): wipe replica,
693
- * memberships, pending, and all meta (clientId), then fresh first-sight under
694
- * a new clientId. Erases WHO, not just WHAT. Awaiters of forgotten writes are
695
- * rejected. Topology can swap OPFS on active forget (#134); this resets the
696
- * current store. Exclusive chain.
667
+ * memberships, pending, meta, and preferences, then fresh first-sight under a
668
+ * new clientId. Erases WHO, not just WHAT. Awaiters of forgotten writes are
669
+ * rejected. Topology can erase the identity's database file on active forget
670
+ * (#134); this resets the current store. Exclusive chain.
697
671
  */
698
672
  forget(): void;
699
673
  /**
700
674
  * Durably set {@link LogoutBehavior} at runtime ({@link
701
- * DoyncClient.setLogoutBehavior}). Via {@link #sideWriteMeta} so it commits
675
+ * DoyncClient.setLogoutBehavior}). Via {@link #sideWritePref} so it commits
702
676
  * outside the optimistic overlay (#135 / ADR-0019). Direct engine stores for
703
677
  * RN; web DB worker reports to hub.
704
678
  */
@@ -756,7 +730,7 @@ declare function settledRejection(error: unknown): MutationResult;
756
730
  * Options for {@link createClient}. Platform adapters (`@doync/web`,
757
731
  * `@doync/mobile`) fill these; app code rarely calls `createClient` directly.
758
732
  */
759
- interface CreateClientOptions<TAuthData = unknown> {
733
+ interface CreateClientOptions<TAuthContext extends AuthContext = AuthContext> {
760
734
  /** Synchronous local SQLite port (wa-sqlite / node:sqlite / op-sqlite). */
761
735
  readonly db: LocalDb;
762
736
  /** Synced schema shared with Origin and Mirror. */
@@ -769,22 +743,16 @@ interface CreateClientOptions<TAuthData = unknown> {
769
743
  /** Transport to the Mirror. */
770
744
  readonly socket: SyncSocket;
771
745
  /**
772
- * Bearer credential for the handshake. Does not drive `userId` or `ctx`. Omit
773
- * for cookie-session auth.
774
- */
775
- readonly token?: string;
776
- /**
777
- * Projected auth context for optimistic query/mutation resolution (mirror
778
- * your server `toContext`). Defaults to `{}`.
746
+ * Whole client identity, or `null` for anonymous. `token` is optional inside
747
+ * {@link AuthData} (cookie auth); `ctx` is required when authenticated.
779
748
  */
780
- readonly ctx?: TAuthData;
749
+ readonly authData: AuthData<TAuthContext> | null;
781
750
  /**
782
- * Authenticated identity, or `null`/omit for anonymous. Never derived from
783
- * `token`.
751
+ * Standard Schema for `authData.ctx`. When present, construction validates
752
+ * synchronously and throws on failure. Platform adapters pass the consumer's
753
+ * shared `ctxValidationSchema`.
784
754
  */
785
- readonly userId?: string | null;
786
- /** Pin a durable client id across restarts. */
787
- readonly clientId?: string;
755
+ readonly ctxValidationSchema: StandardSchemaV1<unknown, TAuthContext>;
788
756
  /** Observe schema/recovery transitions. */
789
757
  readonly onSchemaEvent?: (event: SchemaEvent) => void;
790
758
  /**
@@ -799,14 +767,34 @@ interface CreateClientOptions<TAuthData = unknown> {
799
767
  * Mirror socket. App code normally goes through `@doync/web` / `@doync/mobile`
800
768
  * instead.
801
769
  */
802
- declare function createClient<TAuthData = unknown>(options: CreateClientOptions<TAuthData>): DoyncClient;
770
+ declare function createClient<TAuthContext extends AuthContext = AuthContext>(options: CreateClientOptions<TAuthContext>): DoyncClient;
771
+ /**
772
+ * {@link CreateClientOptions} for trusted internal construction: the web DB
773
+ * worker receives tab-validated identity over the wire and cannot hold the
774
+ * consumer's schema (a validator is a function), so the schema is optional here
775
+ * — absent means the caller already validated.
776
+ */
777
+ type CreateClientEngineOptions<TAuthContext extends AuthContext = AuthContext> = Omit<CreateClientOptions<TAuthContext>, "ctxValidationSchema"> & {
778
+ readonly ctxValidationSchema?: StandardSchemaV1<unknown, TAuthContext>; /** Pin a durable client id (monorepo test/bench lanes only). */
779
+ readonly clientId?: string;
780
+ };
803
781
  /**
804
782
  * Concrete-engine factory (ADR-0033 / closeio/doync#241). Same construction as
805
783
  * {@link createClient}, but typed as {@link ClientEngine} so platform adapters
806
784
  * (web DB-worker, mobile wrapper) can reach engine-only fields like `clientId`
807
785
  * without an unchecked downcast. Exported on `@doync/client/internal` only.
808
786
  */
809
- declare function createClientEngine<TAuthData = unknown>(options: CreateClientOptions<TAuthData>): ClientEngine;
787
+ declare function createClientEngine<TAuthContext extends AuthContext = AuthContext>(options: CreateClientEngineOptions<TAuthContext>): ClientEngine;
788
+ /**
789
+ * Validate and flatten `authData` for engine slots. When a schema is present
790
+ * and identity is non-null, `ctx` is validated synchronously (throws at the
791
+ * call site). Anonymous (`null`) yields `userId: null`, `ctx: null`, no token.
792
+ */
793
+ declare function resolveClientAuthData<TAuthContext extends AuthContext>(authData: AuthData<TAuthContext> | null, ctxValidationSchema?: StandardSchemaV1<unknown, TAuthContext>): {
794
+ userId: string | null;
795
+ token: string | undefined;
796
+ ctx: AuthContext;
797
+ };
810
798
  //#endregion
811
- export { readMeta as A, validateMutationArgs as B, isFalsyQuery as C, createEngineTables as D, applyBundledMigrations as E, ClientMutation as F, LocalRow as H, ClientMutationHandler as I, ClientMutationRegistry as L, SeamStatus as M, SyncSocket as N, dropConsumerTables as O, SyncSocketHandlers as P, ClientMutationTx as R, __LOGOUT_BEHAVIOR_META_KEY as S, settledRejection as T, extractWriteTable as U, LocalDb as V, SchemaEventKind as _, ClientEngineConfig as a, ViewStatus as b, FalsyQuery as c, MutationResult as d, OnceView as f, SchemaEvent as g, QueryStatus as h, ClientEngine as i, writeMeta as j, replayMigrations as k, LogoutBehavior as l, PreloadOptions as m, createClient as n, ConnectionStatus as o, PreloadHandle as p, createClientEngine as r, DoyncClient as s, CreateClientOptions as t, MutationOptions as u, SubscribeOptions as v, normalizeQuerySurface as w, __CONNECTED_CLOCK_META_KEY as x, View as y, asClientMutation as z };
812
- //# sourceMappingURL=client-CNyLMCw0.d.ts.map
799
+ export { replayMigrations as A, extractWriteTable as B, __LOGOUT_BEHAVIOR_PREF_KEY as C, applyBundledMigrations as D, settledRejection as E, SeamStatus as F, SyncSocket as I, SyncSocketHandlers as L, readPref as M, writeMeta as N, createEngineTables as O, writePref as P, LocalDb as R, __CONNECTED_CLOCK_META_KEY as S, normalizeQuerySurface as T, SchemaEvent as _, ClientEngine as a, View as b, DoyncClient as c, MutationOptions as d, MutationResult as f, QueryStatus as g, PreloadOptions as h, resolveClientAuthData as i, readMeta as j, dropConsumerTables as k, FalsyQuery as l, PreloadHandle as m, createClient as n, ClientEngineConfig as o, OnceView as p, createClientEngine as r, ConnectionStatus as s, CreateClientOptions as t, LogoutBehavior as u, SchemaEventKind as v, isFalsyQuery as w, ViewStatus as x, SubscribeOptions as y, LocalRow as z };
800
+ //# sourceMappingURL=client-OAVaC3pt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-OAVaC3pt.d.ts","names":["Input","Output","StandardTypedV1","Props","version","vendor","types","Types","input","output","InferInput","Schema","NonNullable","InferOutput","StandardSchemaV1","validate","value","Options","options","Result","Promise","SuccessResult","FailureResult","issues","libraryOptions","Record","ReadonlyArray","Issue","message","path","PropertyKey","PathSegment","key","StandardJSONSchemaV1","jsonSchema","Converter","Target","target"],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/port.ts","../src/socket.ts","../src/replica/meta.ts","../src/replica/stamps.ts","../src/replica/index.ts","../src/engine.ts","../src/client.ts"],"x_google_ignoreList":[0],"mappings":";;;;;UACU,eAAA,2BAA0C,KAAA;;WAEvC,WAAA,EAAa,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;AAAA;AAAA,kBAErC,eAAA;EAJO;EAAA,UAMXG,KAAAA,2BAAgC,KAAA;IAJE;IAAA,SAM/BC,OAAAA;IANS;IAAA,SAQTC,MAAAA;IAR8B;IAAA,SAU9BC,KAAAA,GAAQ,KAAA,CAAM,KAAA,EAAO,MAAA;EAAA;EAZcN;EAAAA,UAetCO,KAAAA,2BAAgC,KAAA;IAbpBL;IAAAA,SAeTM,KAAAA,EAAO,KAAA;IAfwBR;IAAAA,SAiB/BS,MAAAA,EAAQ,MAAA;EAAA;EAjBoC;EAAA,KAoBpDC,UAAAA,gBAA0B,eAAA,IAAmB,WAAA,CAAY,MAAA;EAlBjC;EAAA,KAoBxBG,WAAAA,gBAA2B,eAAA,IAAmB,WAAA,CAAY,MAAA;AAAA;;UAGzD,gBAAA,2BAA2C,KAAA;EAf5B;EAAA,SAiBZ,WAAA,EAAa,gBAAA,CAAiB,KAAA,CAAM,KAAA,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{ BoundQuery, DoyncSchema, MutationDefinition, MutationTree, SqlValue } from "@doync/core";
1
+ import { AuthContext, AuthData, BoundQuery, DoyncSchema, MutationDefinition, MutationTree, SqlValue } from "@doync/core";
2
2
  import { ClientMessage, ServerMessage } from "@doync/core/internal";
3
3
 
4
4
  //#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
@@ -126,48 +126,6 @@ interface LocalDb {
126
126
  */
127
127
  declare function extractWriteTable(sql: string): string | null;
128
128
  //#endregion
129
- //#region src/mutations.d.ts
130
- /**
131
- * Write surface a client mutation body runs against: one parameterized
132
- * statement at a time inside the mutation's savepoint, returning its rows. Same
133
- * shape the Origin uses, so a shared body runs identically on device and
134
- * server.
135
- */
136
- interface ClientMutationTx {
137
- exec<T extends LocalRow = LocalRow>(query: string, ...params: SqlValue[]): T[];
138
- }
139
- /**
140
- * Client mutation body `(args, ctx, sql)`. Must be deterministic and DB-only
141
- * (may still be async for local work). Generate ids on the client and pass them
142
- * in `args` — the body is replayed on rebase. External I/O belongs in a server
143
- * override, not the client bundle.
144
- */
145
- type ClientMutationHandler = (args: unknown, ctx: Record<string, unknown>, sql: ClientMutationTx) => void | Promise<void>;
146
- /**
147
- * A registered client mutation: body plus optional standard-schema args
148
- * validator applied at `mutate()` time. A bare handler is also accepted.
149
- */
150
- interface ClientMutation {
151
- readonly args?: StandardSchemaV1;
152
- readonly handler: ClientMutationHandler;
153
- }
154
- /**
155
- * Name-keyed client mutation registry. Keys match the server's dotted names so
156
- * a push reaches the matching authoritative body.
157
- */
158
- type ClientMutationRegistry = Readonly<Record<string, ClientMutation | ClientMutationHandler>>;
159
- /**
160
- * Normalize a registry entry (bare handler or `{args, handler}`) to the object
161
- * form.
162
- */
163
- declare function asClientMutation(entry: ClientMutation | ClientMutationHandler): ClientMutation;
164
- /**
165
- * Validate `args` through a standard-schema synchronously (mirrors
166
- * `@doync/core` query-args). Async validators refuse loudly — the body is
167
- * deterministic on both ends. Returns validated value or throws.
168
- */
169
- declare function validateMutationArgs(schema: StandardSchemaV1, args: unknown): unknown;
170
- //#endregion
171
129
  //#region src/socket.d.ts
172
130
  /**
173
131
  * Minimal transport the client engine uses to talk to its Mirror. Platform
@@ -217,6 +175,13 @@ interface SyncSocketHandlers {
217
175
  declare function readMeta(db: LocalDb, key: string): string | null;
218
176
  /** Upsert one `__doync_meta` value. Columns are `k`/`v` (ADR-0024). */
219
177
  declare function writeMeta(db: LocalDb, key: string, value: string): void;
178
+ /**
179
+ * Read one `__doync_prefs` value, or `null` if unset. Columns are `k`/`v`
180
+ * (ADR-0024).
181
+ */
182
+ declare function readPref(db: LocalDb, key: string): string | null;
183
+ /** Upsert one `__doync_prefs` value. Columns are `k`/`v` (ADR-0024). */
184
+ declare function writePref(db: LocalDb, key: string, value: string): void;
220
185
  //#endregion
221
186
  //#region src/replica/stamps.d.ts
222
187
  /**
@@ -275,8 +240,9 @@ declare function applyBundledMigrations(db: LocalDb, schema: DoyncSchema, fromVe
275
240
  * Drop every consumer (synced) table (ADR-0020's wipe fallback): the first step
276
241
  * of wipe-replica-and-resync, run with foreign keys already off so no cascade
277
242
  * fires and drop order is irrelevant (ADR-0009). `__doync_`-prefixed engine
278
- * tables the pending queue, clientId, and `__doync_engine` ledger that
279
- * SURVIVE the wipe are left untouched.
243
+ * tables are left alone here; the caller drops pending / sync meta and mints a
244
+ * fresh clientId (ADR-0037). The `__doync_engine` ledger and `__doync_prefs`
245
+ * survive.
280
246
  */
281
247
  declare function dropConsumerTables(db: LocalDb, schema: DoyncSchema): void;
282
248
  //#endregion
@@ -299,12 +265,12 @@ interface MutationResult {
299
265
  */
300
266
  type LogoutBehavior = "keep" | "forget";
301
267
  /**
302
- * The `__doync_meta` key the durable {@link LogoutBehavior} lives under
268
+ * The `__doync_prefs` key the durable {@link LogoutBehavior} lives under
303
269
  * (closeio/doync#135) — shared by the direct engine's
304
270
  * {@link ClientEngine.setLogoutBehavior} / `createClient` write and the web DB
305
271
  * worker's per-identity write + boot read, so the ends can never drift.
306
272
  */
307
- declare const __LOGOUT_BEHAVIOR_META_KEY = "logout_behavior";
273
+ declare const __LOGOUT_BEHAVIOR_PREF_KEY = "logout_behavior";
308
274
  /**
309
275
  * The `__doync_meta` key the Client's durable connected-time counter lives
310
276
  * under (ADR-0014 client-half addendum / closeio/doync#223). Blob-typed
@@ -319,12 +285,17 @@ declare const __CONNECTED_CLOCK_META_KEY = "connected_clock";
319
285
  * after deploying a matching client. Terminal until reload.
320
286
  * - `server-behind` — client is ahead of a mid-deploy Mirror; the client backs
321
287
  * off and re-handshakes automatically.
322
- * - `resync` — local replica/memberships wiped and rebuilding; pending writes and
323
- * clientId survive. Transient; clears when sync resumes.
288
+ * - `resync` — local sync state wiped and rebuilding as a fresh Client under the
289
+ * same identity (pending writes dropped, new clientId). Transient; clears
290
+ * when sync resumes.
291
+ * - `reaped` — same fresh-client rebuild as `resync`, but the Origin forgot this
292
+ * Client (gone past the client-state lifetime). Transient; clears when sync
293
+ * resumes. Distinct so the app can say "you were away too long" rather than
294
+ * "data refreshed".
324
295
  * - `forget` — local store erased (including identity); boots as a fresh client.
325
296
  * Transient; clears when sync resumes.
326
297
  */
327
- type SchemaEventKind = "reload" | "server-behind" | "resync" | "forget";
298
+ type SchemaEventKind = "reload" | "server-behind" | "resync" | "reaped" | "forget";
328
299
  /**
329
300
  * One schema-status transition: `kind` plus a human-readable `message` for
330
301
  * diagnostics (not a control signal). `null` on the client means nominal.
@@ -461,17 +432,18 @@ interface DoyncClient {
461
432
  */
462
433
  onSchemaChange(listener: () => void): () => void;
463
434
  /**
464
- * Wipe the replica and resubscribe while keeping clientId and pending writes.
465
- * Safe "my local data looks wrong" refresh. Optional on the interface —
435
+ * Rebuild sync state as a fresh Client under the same identity: drop pending
436
+ * writes, mint a new clientId, wipe the replica, and rebootstrap. Destructive
437
+ * to unsent work — not a harmless refresh. Optional on the interface —
466
438
  * platform clients implement it.
467
439
  */
468
- resync?(): void;
440
+ resync(): void;
469
441
  /**
470
442
  * Erase this identity's local data (replica, pendings, identity). Privacy /
471
443
  * logout-forget path. Optional on the interface — platform clients implement
472
444
  * it.
473
445
  */
474
- forget?(): void;
446
+ forget(identity?: string): void;
475
447
  /**
476
448
  * Durably set {@link LogoutBehavior} at runtime (e.g. a "remember me"
477
449
  * checkbox). Survives restart. Optional — platform clients implement it.
@@ -542,15 +514,15 @@ interface ClientEngineConfig {
542
514
  * Named mutation bodies resolved on `push` — deterministic, DB-only
543
515
  * (ADR-0017/0021).
544
516
  */
545
- readonly mutations: ClientMutationRegistry;
517
+ readonly mutations: Record<string, MutationDefinition>;
546
518
  /** The Mirror socket seam (ADR-0016). */
547
519
  readonly socket: SyncSocket;
548
520
  /**
549
521
  * The asserted projected auth context (ADR-0018 addendum / closeio/doync#167)
550
522
  * queries and mutation bodies read. Consumer-owned; the library ships no
551
- * decode. Anonymous `{}`.
523
+ * decode. `null` when anonymous.
552
524
  */
553
- readonly ctx?: Record<string, unknown>;
525
+ readonly ctx?: AuthContext;
554
526
  /**
555
527
  * Transport credential PRESENTED as `connect{jwt}` (ADR-0016/0018) — the
556
528
  * Mirror resolves token-first. Auth must ride the HANDSHAKE, not only the
@@ -639,17 +611,17 @@ declare class ClientEngine implements DoyncClient {
639
611
  get schemaStatus(): SchemaEvent | null;
640
612
  mutate<Args = unknown>(mutation: MutationDefinition<Args>, args: Args, options?: MutationOptions): MutationResult;
641
613
  /**
642
- * Adopt a refreshed SAME-USER identity triple (#167). When connected with a
643
- * bearer, send in-band `updateAuth` (ADR-0018 / #85) so the Mirror extends
644
- * auth without reconnect when userId matches and `issuedAt` is newer.
645
- * Identity CHANGE (different `userId`, incl. anon↔user) is topology-level
646
- * replica swap — SharedWorker routes only same-user refreshes here.
614
+ * Adopt a refreshed SAME-USER identity (#167). When connected with a bearer,
615
+ * send in-band `updateAuth` (ADR-0018 / #85) so the Mirror extends auth
616
+ * without reconnect when userId matches and `issuedAt` is newer. Identity
617
+ * CHANGE (different `userId`, incl. anon↔user) is topology-level replica swap
618
+ * — SharedWorker routes only same-user refreshes here.
647
619
  *
648
620
  * Token is stored for the next reconnect (#92: surviving SharedWorker must
649
621
  * not reuse a stale token). `ctx`/`userId` asserted, never derived. Halted
650
- * engines never emit.
622
+ * engines never emit. Pass `ctx: null` for anonymous.
651
623
  */
652
- updateAuth(token: string | null | undefined, ctx?: Record<string, unknown>, userId?: string | null): void;
624
+ updateAuth(token: string | null | undefined, ctx?: AuthContext, userId?: string | null): void;
653
625
  /**
654
626
  * Subscribe to a registered query (ADR-0021): resolve under args+ctx,
655
627
  * register upstream, return a reactive {@link View}. Local snapshots run
@@ -682,23 +654,25 @@ declare class ClientEngine implements DoyncClient {
682
654
  */
683
655
  local<Row extends Record<string, unknown> = Record<string, SqlValue>>(sql: string, ...params: SqlValue[]): View<Row>;
684
656
  /**
685
- * Rebuild sync state (ADR-0022 resync): wipe replica/memberships/cookie, KEEP
686
- * clientId + pending, rebootstrap. Same core as failed-migration and
687
- * cookie-above-head heals ({@link #wipeAndResync}). Exclusive chain; offline
688
- * rebootstrap rides next reconnect.
657
+ * Rebuild sync state as a fresh Client under the same identity (ADR-0022 /
658
+ * ADR-0037 resync): drop pending writes, mint a new clientId, wipe replica /
659
+ * memberships / cookie, rebootstrap. Same core as failed-migration,
660
+ * cookie-above-head, and heldAt-ahead heals ({@link #wipeAndResync}).
661
+ * Exclusive chain; offline rebootstrap rides next reconnect. Preferences
662
+ * survive (`__doync_prefs`).
689
663
  */
690
664
  resync(): void;
691
665
  /**
692
666
  * Erase this identity's local data (ADR-0022 forget): wipe replica,
693
- * memberships, pending, and all meta (clientId), then fresh first-sight under
694
- * a new clientId. Erases WHO, not just WHAT. Awaiters of forgotten writes are
695
- * rejected. Topology can swap OPFS on active forget (#134); this resets the
696
- * current store. Exclusive chain.
667
+ * memberships, pending, meta, and preferences, then fresh first-sight under a
668
+ * new clientId. Erases WHO, not just WHAT. Awaiters of forgotten writes are
669
+ * rejected. Topology can erase the identity's database file on active forget
670
+ * (#134); this resets the current store. Exclusive chain.
697
671
  */
698
672
  forget(): void;
699
673
  /**
700
674
  * Durably set {@link LogoutBehavior} at runtime ({@link
701
- * DoyncClient.setLogoutBehavior}). Via {@link #sideWriteMeta} so it commits
675
+ * DoyncClient.setLogoutBehavior}). Via {@link #sideWritePref} so it commits
702
676
  * outside the optimistic overlay (#135 / ADR-0019). Direct engine stores for
703
677
  * RN; web DB worker reports to hub.
704
678
  */
@@ -756,7 +730,7 @@ declare function settledRejection(error: unknown): MutationResult;
756
730
  * Options for {@link createClient}. Platform adapters (`@doync/web`,
757
731
  * `@doync/mobile`) fill these; app code rarely calls `createClient` directly.
758
732
  */
759
- interface CreateClientOptions<TAuthData = unknown> {
733
+ interface CreateClientOptions<TAuthContext extends AuthContext = AuthContext> {
760
734
  /** Synchronous local SQLite port (wa-sqlite / node:sqlite / op-sqlite). */
761
735
  readonly db: LocalDb;
762
736
  /** Synced schema shared with Origin and Mirror. */
@@ -769,22 +743,16 @@ interface CreateClientOptions<TAuthData = unknown> {
769
743
  /** Transport to the Mirror. */
770
744
  readonly socket: SyncSocket;
771
745
  /**
772
- * Bearer credential for the handshake. Does not drive `userId` or `ctx`. Omit
773
- * for cookie-session auth.
774
- */
775
- readonly token?: string;
776
- /**
777
- * Projected auth context for optimistic query/mutation resolution (mirror
778
- * your server `toContext`). Defaults to `{}`.
746
+ * Whole client identity, or `null` for anonymous. `token` is optional inside
747
+ * {@link AuthData} (cookie auth); `ctx` is required when authenticated.
779
748
  */
780
- readonly ctx?: TAuthData;
749
+ readonly authData: AuthData<TAuthContext> | null;
781
750
  /**
782
- * Authenticated identity, or `null`/omit for anonymous. Never derived from
783
- * `token`.
751
+ * Standard Schema for `authData.ctx`. When present, construction validates
752
+ * synchronously and throws on failure. Platform adapters pass the consumer's
753
+ * shared `ctxValidationSchema`.
784
754
  */
785
- readonly userId?: string | null;
786
- /** Pin a durable client id across restarts. */
787
- readonly clientId?: string;
755
+ readonly ctxValidationSchema: StandardSchemaV1<unknown, TAuthContext>;
788
756
  /** Observe schema/recovery transitions. */
789
757
  readonly onSchemaEvent?: (event: SchemaEvent) => void;
790
758
  /**
@@ -799,14 +767,34 @@ interface CreateClientOptions<TAuthData = unknown> {
799
767
  * Mirror socket. App code normally goes through `@doync/web` / `@doync/mobile`
800
768
  * instead.
801
769
  */
802
- declare function createClient<TAuthData = unknown>(options: CreateClientOptions<TAuthData>): DoyncClient;
770
+ declare function createClient<TAuthContext extends AuthContext = AuthContext>(options: CreateClientOptions<TAuthContext>): DoyncClient;
771
+ /**
772
+ * {@link CreateClientOptions} for trusted internal construction: the web DB
773
+ * worker receives tab-validated identity over the wire and cannot hold the
774
+ * consumer's schema (a validator is a function), so the schema is optional here
775
+ * — absent means the caller already validated.
776
+ */
777
+ type CreateClientEngineOptions<TAuthContext extends AuthContext = AuthContext> = Omit<CreateClientOptions<TAuthContext>, "ctxValidationSchema"> & {
778
+ readonly ctxValidationSchema?: StandardSchemaV1<unknown, TAuthContext>; /** Pin a durable client id (monorepo test/bench lanes only). */
779
+ readonly clientId?: string;
780
+ };
803
781
  /**
804
782
  * Concrete-engine factory (ADR-0033 / closeio/doync#241). Same construction as
805
783
  * {@link createClient}, but typed as {@link ClientEngine} so platform adapters
806
784
  * (web DB-worker, mobile wrapper) can reach engine-only fields like `clientId`
807
785
  * without an unchecked downcast. Exported on `@doync/client/internal` only.
808
786
  */
809
- declare function createClientEngine<TAuthData = unknown>(options: CreateClientOptions<TAuthData>): ClientEngine;
787
+ declare function createClientEngine<TAuthContext extends AuthContext = AuthContext>(options: CreateClientEngineOptions<TAuthContext>): ClientEngine;
788
+ /**
789
+ * Validate and flatten `authData` for engine slots. When a schema is present
790
+ * and identity is non-null, `ctx` is validated synchronously (throws at the
791
+ * call site). Anonymous (`null`) yields `userId: null`, `ctx: null`, no token.
792
+ */
793
+ declare function resolveClientAuthData<TAuthContext extends AuthContext>(authData: AuthData<TAuthContext> | null, ctxValidationSchema?: StandardSchemaV1<unknown, TAuthContext>): {
794
+ userId: string | null;
795
+ token: string | undefined;
796
+ ctx: AuthContext;
797
+ };
810
798
  //#endregion
811
- export { readMeta as A, validateMutationArgs as B, isFalsyQuery as C, createEngineTables as D, applyBundledMigrations as E, ClientMutation as F, LocalRow as H, ClientMutationHandler as I, ClientMutationRegistry as L, SeamStatus as M, SyncSocket as N, dropConsumerTables as O, SyncSocketHandlers as P, ClientMutationTx as R, __LOGOUT_BEHAVIOR_META_KEY as S, settledRejection as T, extractWriteTable as U, LocalDb as V, SchemaEventKind as _, ClientEngineConfig as a, ViewStatus as b, FalsyQuery as c, MutationResult as d, OnceView as f, SchemaEvent as g, QueryStatus as h, ClientEngine as i, writeMeta as j, replayMigrations as k, LogoutBehavior as l, PreloadOptions as m, createClient as n, ConnectionStatus as o, PreloadHandle as p, createClientEngine as r, DoyncClient as s, CreateClientOptions as t, MutationOptions as u, SubscribeOptions as v, normalizeQuerySurface as w, __CONNECTED_CLOCK_META_KEY as x, View as y, asClientMutation as z };
812
- //# sourceMappingURL=client-DHXO0dbf.d.cts.map
799
+ export { replayMigrations as A, extractWriteTable as B, __LOGOUT_BEHAVIOR_PREF_KEY as C, applyBundledMigrations as D, settledRejection as E, SeamStatus as F, SyncSocket as I, SyncSocketHandlers as L, readPref as M, writeMeta as N, createEngineTables as O, writePref as P, LocalDb as R, __CONNECTED_CLOCK_META_KEY as S, normalizeQuerySurface as T, SchemaEvent as _, ClientEngine as a, View as b, DoyncClient as c, MutationOptions as d, MutationResult as f, QueryStatus as g, PreloadOptions as h, resolveClientAuthData as i, readMeta as j, dropConsumerTables as k, FalsyQuery as l, PreloadHandle as m, createClient as n, ClientEngineConfig as o, OnceView as p, createClientEngine as r, ConnectionStatus as s, CreateClientOptions as t, LogoutBehavior as u, SchemaEventKind as v, isFalsyQuery as w, ViewStatus as x, SubscribeOptions as y, LocalRow as z };
800
+ //# sourceMappingURL=client-OPt8Axyp.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-OPt8Axyp.d.cts","names":["Input","Output","StandardTypedV1","Props","version","vendor","types","Types","input","output","InferInput","Schema","NonNullable","InferOutput","StandardSchemaV1","validate","value","Options","options","Result","Promise","SuccessResult","FailureResult","issues","libraryOptions","Record","ReadonlyArray","Issue","message","path","PropertyKey","PathSegment","key","StandardJSONSchemaV1","jsonSchema","Converter","Target","target"],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../src/port.ts","../src/socket.ts","../src/replica/meta.ts","../src/replica/stamps.ts","../src/replica/index.ts","../src/engine.ts","../src/client.ts"],"x_google_ignoreList":[0],"mappings":";;;;;UACU,eAAA,2BAA0C,KAAA;;WAEvC,WAAA,EAAa,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;AAAA;AAAA,kBAErC,eAAA;EAJO;EAAA,UAMXG,KAAAA,2BAAgC,KAAA;IAJE;IAAA,SAM/BC,OAAAA;IANS;IAAA,SAQTC,MAAAA;IAR8B;IAAA,SAU9BC,KAAAA,GAAQ,KAAA,CAAM,KAAA,EAAO,MAAA;EAAA;EAZcN;EAAAA,UAetCO,KAAAA,2BAAgC,KAAA;IAbpBL;IAAAA,SAeTM,KAAAA,EAAO,KAAA;IAfwBR;IAAAA,SAiB/BS,MAAAA,EAAQ,MAAA;EAAA;EAjBoC;EAAA,KAoBpDC,UAAAA,gBAA0B,eAAA,IAAmB,WAAA,CAAY,MAAA;EAlBjC;EAAA,KAoBxBG,WAAAA,gBAA2B,eAAA,IAAmB,WAAA,CAAY,MAAA;AAAA;;UAGzD,gBAAA,2BAA2C,KAAA;EAf5B;EAAA,SAiBZ,WAAA,EAAa,gBAAA,CAAiB,KAAA,CAAM,KAAA,EAAO,MAAA;AAAA;AAAA,kBAEtC,gBAAA;EATiB;EAAA,UAWrBV,KAAAA,2BAAgC,KAAA,UAAe,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,MAAA;IAXpC;IAAA,SAarCY,QAAAA,GA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