@pgxsinkit/client 0.1.31 → 0.1.36

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 (85) hide show
  1. package/README.md +11 -0
  2. package/dist/convergence.d.ts +76 -0
  3. package/dist/convergence.d.ts.map +1 -0
  4. package/dist/debug.d.ts +34 -0
  5. package/dist/debug.d.ts.map +1 -0
  6. package/dist/index.d.ts +421 -7
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7214 -2234
  9. package/dist/index.js.map +74 -44
  10. package/dist/lazy-guard.d.ts +58 -0
  11. package/dist/lazy-guard.d.ts.map +1 -0
  12. package/dist/local-store.d.ts +56 -0
  13. package/dist/local-store.d.ts.map +1 -0
  14. package/dist/local-tables.d.ts +707 -0
  15. package/dist/local-tables.d.ts.map +1 -0
  16. package/dist/mutation-state.d.ts +62 -0
  17. package/dist/mutation-state.d.ts.map +1 -0
  18. package/dist/mutation.d.ts +117 -4
  19. package/dist/mutation.d.ts.map +1 -1
  20. package/dist/schema.d.ts +49 -0
  21. package/dist/schema.d.ts.map +1 -1
  22. package/dist/shape-sync.d.ts +180 -0
  23. package/dist/shape-sync.d.ts.map +1 -0
  24. package/dist/sync/apply.d.ts +51 -0
  25. package/dist/sync/apply.d.ts.map +1 -0
  26. package/dist/sync/copy.d.ts +43 -0
  27. package/dist/sync/copy.d.ts.map +1 -0
  28. package/dist/sync/drizzle-executor.d.ts +5 -0
  29. package/dist/sync/drizzle-executor.d.ts.map +1 -0
  30. package/dist/sync/index.d.ts +32 -0
  31. package/dist/sync/index.d.ts.map +1 -0
  32. package/dist/sync/metadata-tables.d.ts +131 -0
  33. package/dist/sync/metadata-tables.d.ts.map +1 -0
  34. package/dist/sync/nudge.d.ts +49 -0
  35. package/dist/sync/nudge.d.ts.map +1 -0
  36. package/dist/sync/shape-inbox.d.ts +215 -0
  37. package/dist/sync/shape-inbox.d.ts.map +1 -0
  38. package/dist/sync/subscription-state.d.ts +39 -0
  39. package/dist/sync/subscription-state.d.ts.map +1 -0
  40. package/dist/sync/tags.d.ts +130 -0
  41. package/dist/sync/tags.d.ts.map +1 -0
  42. package/dist/sync/types.d.ts +118 -0
  43. package/dist/sync/types.d.ts.map +1 -0
  44. package/dist/sync-auth.d.ts +53 -0
  45. package/dist/sync-auth.d.ts.map +1 -0
  46. package/dist/worker/attach-sync-client.d.ts +75 -0
  47. package/dist/worker/attach-sync-client.d.ts.map +1 -0
  48. package/dist/worker/define-sync-worker.d.ts +75 -0
  49. package/dist/worker/define-sync-worker.d.ts.map +1 -0
  50. package/dist/worker/live-diff.d.ts +44 -0
  51. package/dist/worker/live-diff.d.ts.map +1 -0
  52. package/dist/worker/protocol.d.ts +260 -0
  53. package/dist/worker/protocol.d.ts.map +1 -0
  54. package/dist/worker/token-cache.d.ts +26 -0
  55. package/dist/worker/token-cache.d.ts.map +1 -0
  56. package/oxlint-plugin.js +143 -0
  57. package/package.json +19 -7
  58. package/skills/core/SKILL.md +197 -0
  59. package/skills/operating/SKILL.md +243 -0
  60. package/src/convergence.ts +197 -0
  61. package/src/debug.ts +151 -0
  62. package/src/index.ts +1104 -44
  63. package/src/lazy-guard.ts +121 -0
  64. package/src/local-store.ts +193 -0
  65. package/src/local-tables.ts +546 -0
  66. package/src/mutation-state.ts +90 -0
  67. package/src/mutation.ts +1868 -562
  68. package/src/schema.ts +352 -27
  69. package/src/shape-sync.ts +477 -0
  70. package/src/sync/apply.ts +530 -0
  71. package/src/sync/copy.ts +206 -0
  72. package/src/sync/drizzle-executor.ts +48 -0
  73. package/src/sync/index.ts +1076 -0
  74. package/src/sync/metadata-tables.ts +67 -0
  75. package/src/sync/nudge.ts +110 -0
  76. package/src/sync/shape-inbox.ts +566 -0
  77. package/src/sync/subscription-state.ts +135 -0
  78. package/src/sync/tags.ts +365 -0
  79. package/src/sync/types.ts +132 -0
  80. package/src/sync-auth.ts +117 -0
  81. package/src/worker/attach-sync-client.ts +558 -0
  82. package/src/worker/define-sync-worker.ts +596 -0
  83. package/src/worker/live-diff.ts +140 -0
  84. package/src/worker/protocol.ts +325 -0
  85. package/src/worker/token-cache.ts +84 -0
@@ -0,0 +1,118 @@
1
+ import type { ChangeMessage, FetchError, Row, ShapeStreamInterface, ShapeStreamOptions } from "@electric-sql/client";
2
+ import type { PgliteDatabase } from "drizzle-orm/pglite";
3
+ import type { SyncTableRegistry } from "@pgxsinkit/contracts";
4
+ export type { Row, ShapeStreamOptions } from "@electric-sql/client";
5
+ export type { MultiShapeMessages } from "@electric-sql/experimental";
6
+ export type Lsn = bigint;
7
+ export type SubscriptionKey = string;
8
+ export type InitialInsertMethod = "insert" | "copy" | "json";
9
+ /** Default hard cap on commit-transaction attempts before the engine goes degraded (ADR-0009). */
10
+ export declare const DEFAULT_MAX_COMMIT_RETRIES = 5;
11
+ /**
12
+ * Per-shape options for the group form (ADR-0029 D1). Every table-scoped fact — local table identity,
13
+ * projection, primary keys, apply strategy, column types — is derived by the engine from the
14
+ * group-level `registry` and this shape's `tableKey`; none is passed here. Only the Electric shape
15
+ * stream, an optional per-shape backfill override, and the must-refetch hook remain.
16
+ */
17
+ export interface ShapeToTableOptions {
18
+ shape: ShapeStreamOptions<Row<unknown>>;
19
+ /** The registry table key this shape applies into — the engine's sole per-table spec (ADR-0029 D1). */
20
+ tableKey: string;
21
+ /**
22
+ * Must-refetch override: replaces the default `TRUNCATE` cache wipe (ADR-0029 D4). Receives a Drizzle
23
+ * handle bound to the commit transaction (`drizzleOverPg(tx)`), so a scoped clear authors tier-①
24
+ * (`db.delete(table).where(…)`).
25
+ */
26
+ onMustRefetch?: ((db: PgliteDatabase) => Promise<void>) | undefined;
27
+ /**
28
+ * Per-shape initial-backfill apply strategy override (ADR-0009 decisions 2 + 3). In a consistency
29
+ * group each shape resolves its own apply path, so one shape's backfill never forces the rest onto
30
+ * plain `INSERT`. When set it wins over the registry-classified strategy; otherwise the strategy is
31
+ * derived from the entry and mapped, else the group-level default applies.
32
+ */
33
+ initialInsertMethod?: InitialInsertMethod | undefined;
34
+ }
35
+ export interface SyncShapesToTablesOptions {
36
+ key: string | null;
37
+ /** The engine's per-table spec source (ADR-0029 D1): every shape's `tableKey` resolves against it. */
38
+ registry: SyncTableRegistry;
39
+ shapes: Record<string, ShapeToTableOptions>;
40
+ initialInsertMethod?: InitialInsertMethod | undefined;
41
+ onInitialSync?: (() => void) | undefined;
42
+ /**
43
+ * Fresh-store prefetch overlap (ADR-0032 S4 / backlog-0003). When present, the group is on a
44
+ * PROVABLY-FRESH store (a claimed schemaless spare — the caller's `freshStore` hint), so the engine
45
+ * starts the shape streams and BUFFERS their catch-up into the memory inbox immediately — WITHOUT the
46
+ * two DB touches the sequential path takes first (`initMetadataTables`, `getSubscriptionState`) — and
47
+ * gates every commit (the first write to PGlite) until this promise resolves. The owner resolves it
48
+ * once the local store is ready (schema exec + journal recovery + store-version reconcile complete), so
49
+ * the network catch-up overlaps those local phases instead of running strictly after them. Absent → the
50
+ * exact sequential path (warm stores, and every non-overlap caller). Because a fresh store has no prior
51
+ * subscription state, the overlap treats the group as a new subscription (`subState === null`), which the
52
+ * `freshStore` gate guarantees.
53
+ */
54
+ dbReady?: Promise<void> | undefined;
55
+ /** Stream-level (network / fetch) error from Electric, forwarded to `MultiShapeStream.subscribe`. */
56
+ onError?: ((error: FetchError | Error) => void) | undefined;
57
+ /**
58
+ * Commit-level error surfacing (ADR-0009 decision 5). Fired when a sync commit transaction
59
+ * still fails after `maxCommitRetries` jittered-backoff attempts. The engine then holds its
60
+ * buffer and committed frontier (never advancing `isUpToDate` on an unapplied commit) so the
61
+ * read cache cannot silently diverge; recovery is a later commit or a restart/refetch.
62
+ */
63
+ onSyncError?: ((error: Error) => void) | undefined;
64
+ /**
65
+ * Fired whenever the stream delivers a batch — i.e. a fetch just succeeded (ADR-0013 Phase 3).
66
+ * The runtime uses this as the read path's "alive again" signal to clear an `auth-needed` status
67
+ * once sync resumes after re-authentication.
68
+ */
69
+ onSyncActivity?: (() => void) | undefined;
70
+ /** Hard cap on commit-transaction attempts before going degraded. Defaults to {@link DEFAULT_MAX_COMMIT_RETRIES}. */
71
+ maxCommitRetries?: number | undefined;
72
+ /**
73
+ * Backoff before re-attempting a failed commit, as a function of the attempt number. Defaults to
74
+ * the runtime's jittered backoff (`computeRetryDelayMs`). A test seam — pass `() => 0` for an
75
+ * immediate retry instead of sleeping the real backoff.
76
+ */
77
+ commitRetryDelayMs?: ((attempt: number) => number) | undefined;
78
+ }
79
+ export interface SyncShapesToTablesResult {
80
+ unsubscribe: () => void;
81
+ readonly isUpToDate: boolean;
82
+ streams: Record<string, ShapeStreamInterface<Row<unknown>>>;
83
+ }
84
+ /**
85
+ * Single-shape options (ADR-0029 D6): thin sugar over the group form, taking the same entry-based
86
+ * fields plus a `shapeKey`. Every table-scoped fact is derived from `(registry, tableKey)`.
87
+ */
88
+ export interface SyncShapeToTableOptions {
89
+ shape: ShapeStreamOptions<Row<unknown>>;
90
+ registry: SyncTableRegistry;
91
+ tableKey: string;
92
+ shapeKey: string | null;
93
+ initialInsertMethod?: InitialInsertMethod | undefined;
94
+ onInitialSync?: (() => void) | undefined;
95
+ onError?: ((error: FetchError | Error) => void) | undefined;
96
+ /** Commit-level error surfacing (ADR-0009 decision 5); see {@link SyncShapesToTablesOptions.onSyncError}. */
97
+ onSyncError?: ((error: Error) => void) | undefined;
98
+ /** Hard cap on commit-transaction attempts before going degraded. Defaults to {@link DEFAULT_MAX_COMMIT_RETRIES}. */
99
+ maxCommitRetries?: number | undefined;
100
+ /** Backoff before re-attempting a failed commit; see {@link SyncShapesToTablesOptions.commitRetryDelayMs}. */
101
+ commitRetryDelayMs?: ((attempt: number) => number) | undefined;
102
+ onMustRefetch?: ((db: PgliteDatabase) => Promise<void>) | undefined;
103
+ }
104
+ export interface SyncShapeToTableResult {
105
+ unsubscribe: () => void;
106
+ readonly isUpToDate: boolean;
107
+ stream: ShapeStreamInterface<Row<unknown>>;
108
+ }
109
+ export interface ElectricSyncOptions {
110
+ debug?: boolean;
111
+ metadataSchema?: string;
112
+ }
113
+ export type InsertChangeMessage = ChangeMessage<Row<unknown>> & {
114
+ headers: {
115
+ operation: "insert";
116
+ };
117
+ };
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK9D,YAAY,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7D,kGAAkG;AAClG,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACxC,uGAAuG;IACvG,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACpE;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACvD;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,sGAAsG;IACtG,QAAQ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,mBAAmB,GAAG,SAAS,CAAC;IACtD,aAAa,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D,6GAA6G;IAC7G,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACnD,qHAAqH;IACrH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,8GAA8G;IAC9G,kBAAkB,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;IAC/D,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CACrE;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG;IAC9D,OAAO,EAAE;QAAE,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;CAClC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { ExternalHeadersRecord, ShapeStreamOptions } from "@electric-sql/client";
2
+ /** The per-shape error handler shape Electric expects (`ShapeStreamOptions.onError`). */
3
+ type ShapeStreamErrorHandler = NonNullable<ShapeStreamOptions["onError"]>;
4
+ /**
5
+ * Read-path identity (ADR-0013). The two ingress points must share **one** token lifecycle: the
6
+ * write path already calls `getAuthToken` fresh on every flush, so the read path must too — never
7
+ * freezing a JWT at boot, which wedges a long-lived offline-first session the instant the token
8
+ * expires.
9
+ *
10
+ * `buildAuthShapeHeaders` returns the read-path `Authorization` header as an **async function**.
11
+ * Electric resolves header-value functions on every request *and every retry*
12
+ * (`ExternalHeadersRecord` allows `string | (() => string | Promise<string>)`), so each shape fetch
13
+ * presents a fresh token. This is the client mirror of ADR-0003's server-side one-identity decision.
14
+ *
15
+ * The provider contract (documented in `docs/architecture.md`): `getAuthToken` is now called per
16
+ * request by both paths and **must be refresh-deduping** — return the cached valid token and refresh
17
+ * single-flight, so an N-shape consistency group does not trigger N refreshes.
18
+ */
19
+ /**
20
+ * Build the read-path shape headers: the optional async `Authorization` (per ADR-0013) **plus** any
21
+ * caller-supplied static `requestHeaders`. The static headers are spread first so the toolkit-owned
22
+ * `Authorization` always wins; they exist for deployment-gateway credentials the toolkit is otherwise
23
+ * agnostic about — e.g. a Supabase `apikey` header the platform function gateway expects. Emitted
24
+ * whenever *either* a token provider or static headers are present, so a credential-only consumer
25
+ * (no per-request token) still sends its headers.
26
+ */
27
+ export declare function buildShapeHeaders(input: {
28
+ getAuthToken?: () => Promise<string | undefined>;
29
+ requestHeaders?: Record<string, string>;
30
+ }): ExternalHeadersRecord;
31
+ /** Token-only convenience over {@link buildShapeHeaders}; retained for callers that pass a provider. */
32
+ export declare function buildAuthShapeHeaders(getAuthToken: () => Promise<string | undefined>, requestHeaders?: Record<string, string>): ExternalHeadersRecord;
33
+ /**
34
+ * The per-shape `ShapeStreamOptions.onError` handler for the read path. It is the only place that can
35
+ * request a retry (the `MultiShapeStream.subscribe` `onError` is notification-only), so it owns BOTH
36
+ * read-path identity (ADR-0013) and read-stream error surfacing (#4):
37
+ *
38
+ * - **auth (401/403)** → `onAuthError` + return `{}` (retry): Electric re-issues the request,
39
+ * re-resolving the async Authorization header ({@link buildAuthShapeHeaders}) for a *fresh* token.
40
+ * Never return `void` here — that stops the stream permanently, wrong for offline-first: a dead
41
+ * session must keep retrying (jittered backoff bounds the cost) so sync resumes the instant re-auth
42
+ * makes the token valid again. The optional `onAuthError` surfaces a distinct "re-login" status.
43
+ * - **any other error** → `onReadStreamError` (so the runtime can move to a `degraded` status instead
44
+ * of silently believing the read path is live), then retry transient faults ({@link
45
+ * isRetryableStreamError}: 5xx/429/network → `{}`) or stop a structural 4xx (return `undefined`). A
46
+ * later successful fetch (`onSyncActivity`) clears the degraded status back to live.
47
+ */
48
+ export declare function createShapeErrorHandler(options?: {
49
+ onAuthError?: () => void;
50
+ onReadStreamError?: (error: Error) => void;
51
+ }): ShapeStreamErrorHandler;
52
+ export {};
53
+ //# sourceMappingURL=sync-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-auth.d.ts","sourceRoot":"","sources":["../src/sync-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,yFAAyF;AACzF,KAAK,uBAAuB,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AACH;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GAAG,qBAAqB,CAYxB;AAED,wGAAwG;AACxG,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EAC/C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,qBAAqB,CAEvB;AAuCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CAAO,GACrF,uBAAuB,CASzB"}
@@ -0,0 +1,75 @@
1
+ import type { SyncRuntimeStatus, SyncTableRegistry } from "@pgxsinkit/contracts";
2
+ import { type MutationDetail, type SyncClient } from "../index";
3
+ import type { LocalStoreVersionEvent } from "../local-store";
4
+ import { type AuthTokenSnapshot, type BridgeCodec, type BridgePort, type BridgeTransferable } from "./protocol";
5
+ /** A `Worker`/`SharedWorker`-shaped handle: a dedicated `Worker` IS the port; a `SharedWorker` carries `.port`. */
6
+ interface WorkerLike {
7
+ port?: BridgePort;
8
+ postMessage?: (message: unknown, transfer?: BridgeTransferable[]) => void;
9
+ addEventListener?: (type: "message", listener: (event: {
10
+ data: unknown;
11
+ }) => void) => void;
12
+ removeEventListener?: (type: "message", listener: (event: {
13
+ data: unknown;
14
+ }) => void) => void;
15
+ }
16
+ export interface AttachSyncClientOptions<TRegistry extends SyncTableRegistry> {
17
+ registry: TRegistry;
18
+ /** A native `Worker` or `SharedWorker` (or anything port-shaped). Provide this OR {@link port}. */
19
+ worker?: WorkerLike;
20
+ /** A raw transport port (a `MessageChannel` port in tests, a `SharedWorker.port` in a browser). */
21
+ port?: BridgePort;
22
+ /**
23
+ * The tab's token provider (ADR-0032 decision 3). Richer than `createSyncClient`'s string form: the
24
+ * worker needs the EXPIRY to apply its pull margin, so this yields `{accessToken, expiresAt}` (or null
25
+ * when unauthenticated). Pushed at attach and answered on every worker pull-request.
26
+ */
27
+ getToken?: () => Promise<AuthTokenSnapshot | null>;
28
+ /** The bound store id (resolved tab-side before attach — SharedWorker naming, ADR-0032 decision 5). */
29
+ storeId?: string;
30
+ dataDir?: string;
31
+ syncEnabled?: boolean;
32
+ /**
33
+ * Which baked registry the worker boots (ADR-0032 S3) — forwarded in the attach `config.role`. A worker
34
+ * file that bakes multiple role variants (the board's admin/member) picks by this; single-registry
35
+ * workers ignore it.
36
+ */
37
+ role?: string;
38
+ /**
39
+ * Fresh-store prefetch-overlap hint (ADR-0032 S4), forwarded in the attach `config.freshStore`. Set true
40
+ * ONLY when the tab knows the store is a claimed schemaless spare (never for a mapped/returning store);
41
+ * the worker's `createSyncClient` then overlaps the shape catch-up with its local boot phases.
42
+ */
43
+ freshStore?: boolean;
44
+ codec?: BridgeCodec;
45
+ onStatusChange?: (status: SyncRuntimeStatus) => void;
46
+ onConflict?: (details: MutationDetail[]) => void;
47
+ onQuarantine?: (details: MutationDetail[]) => void;
48
+ onReject?: (details: MutationDetail[]) => void;
49
+ onSchemaChange?: (event: LocalStoreVersionEvent) => void;
50
+ onSyncError?: (error: Error) => void;
51
+ }
52
+ /**
53
+ * The worker-attached client: `SyncClient`'s shape, worker-proxied, plus `notifyAuthChanged` (re-push the
54
+ * token after an app auth-state change, ADR-0032 decision 3). The unsupported one-shot-read members throw.
55
+ */
56
+ export type AttachedSyncClient<TRegistry extends SyncTableRegistry> = SyncClient<TRegistry> & {
57
+ notifyAuthChanged: () => void;
58
+ /**
59
+ * Forward the app's Offline toggle to the worker (ADR-0032 S3). The worker owns convergence, so the
60
+ * tab cannot gate a local trigger; this sends `set-online`, which suppresses/resumes the worker's flush
61
+ * passes (resuming fires one immediate pass). The in-process client gates its own `autoSync` instead.
62
+ */
63
+ setOnline: (online: boolean) => void;
64
+ };
65
+ export declare function attachSyncClient<const TRegistry extends SyncTableRegistry>(options: AttachSyncClientOptions<TRegistry>): Promise<AttachedSyncClient<TRegistry>>;
66
+ /**
67
+ * Pre-spawn a worker's store WITHOUT attaching (ADR-0032 decision 5). Sent at the board's login screen
68
+ * against a freshly-named spare `SharedWorker`: the worker runs PGlite `create`/initdb only and holds the
69
+ * raw store idle until the real {@link attachSyncClient} claim adopts it. Resolves when the worker acks the
70
+ * provision (its initdb settled); rejects only if the worker reports the create failed — the caller treats
71
+ * either outcome as best-effort, since attach falls back to a fresh create regardless.
72
+ */
73
+ export declare function provisionSyncWorker<TRegistry extends SyncTableRegistry>(options: Pick<AttachSyncClientOptions<TRegistry>, "worker" | "port" | "storeId" | "dataDir" | "codec">): Promise<void>;
74
+ export {};
75
+ //# sourceMappingURL=attach-sync-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-sync-client.d.ts","sourceRoot":"","sources":["../../src/worker/attach-sync-client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,UAAU,EAGhB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,kBAAkB,EAUxB,MAAM,YAAY,CAAC;AAEpB,mHAAmH;AACnH,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IAC1E,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAC3F,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;CAC/F;AAED,MAAM,WAAW,uBAAuB,CAAC,SAAS,SAAS,iBAAiB;IAC1E,QAAQ,EAAE,SAAS,CAAC;IACpB,mGAAmG;IACnG,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,mGAAmG;IACnG,I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mBAAmB,CAAC,SAAS,SAAS,iBAAiB,EACrE,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,GACrG,OAAO,CAAC,IAAI,CAAC,CAmBf"}
@@ -0,0 +1,75 @@
1
+ import type { SyncTableRegistry } from "@pgxsinkit/contracts";
2
+ import { type ClientPGlite, type CreateSyncClientOptions, type SyncClient } from "../index";
3
+ import { type BridgeCodec, type BridgePort } from "./protocol";
4
+ export interface DefineSyncWorkerOptions<TRegistry extends SyncTableRegistry> {
5
+ /**
6
+ * The sync registry — imported as CODE by the worker file, never cloned into it (ADR-0032 decision 4).
7
+ * When {@link resolveRegistry} is also given this is the DEFAULT (used when the attach carries no role
8
+ * or an unknown one).
9
+ */
10
+ registry: TRegistry;
11
+ /**
12
+ * Resolve the registry to boot from the attach's `config.role` (ADR-0032 S3). A single worker file can
13
+ * bake BOTH role variants (e.g. the board's admin/member registries — same TS shape, different write
14
+ * capability) and pick per-attach, which the spare flow needs: the spare is provisioned role-agnostic
15
+ * (before the user is known) and the role is only settled at claim/attach. Returns `undefined` to fall
16
+ * back to {@link registry}.
17
+ */
18
+ resolveRegistry?: (role: string | undefined) => TRegistry | undefined;
19
+ /**
20
+ * How the worker creates its raw PGlite store (provision + fresh-attach paths). Defaults to
21
+ * {@link createClientPGlite}, which loads PGlite's own boot assets — in a browser worker those hit the
22
+ * same-origin HTTP cache the tab's login-screen warm already primed (ADR-0032 S3). Injected in tests.
23
+ */
24
+ createPglite?: (dataDir: string) => Promise<ClientPGlite>;
25
+ electricUrl: string;
26
+ writeUrl: string;
27
+ /** Static headers on every read + write request (e.g. a gateway `apikey`). See `createSyncClient`. */
28
+ requestHeaders?: Record<string, string>;
29
+ /** Write-only headers merged over {@link requestHeaders} (e.g. region/DB-affinity). See `createSyncClient`. */
30
+ writeRequestHeaders?: Record<string, string>;
31
+ /** Default PGlite store id if the first attach carries none (`memory://…` in tests, `idb://…` in a browser). */
32
+ dataDir?: string;
33
+ maxMutationAttempts?: number;
34
+ syncEnabled?: boolean;
35
+ /**
36
+ * How close to expiry (ms) a cached token may be before a read/write that needs it triggers a pull
37
+ * broadcast (ADR-0032 decision 3). Default 30s — comfortably ahead of a long-poll cycle.
38
+ */
39
+ tokenExpiryMarginMs?: number;
40
+ /**
41
+ * The worker's own convergence cadence (ms) — the interval trigger FALLBACK only. Local writes
42
+ * flush immediately via the event-driven `requestPass` seam and tab `wake` signals, so this
43
+ * interval exists purely for retry/recovery sweeps; each idle pass still costs real worker CPU
44
+ * (`flush` + `reconcile` queries). Default 15000.
45
+ */
46
+ convergenceIntervalMs?: number;
47
+ /** Injected transport binder. Defaults to auto-detecting the SharedWorker/dedicated-worker global scope. */
48
+ installGlobal?: boolean;
49
+ /** Injected codec (ADR-0032 S2 §1). Defaults to the v1 identity codec. */
50
+ codec?: BridgeCodec;
51
+ /**
52
+ * A raw PGlite the worker uses instead of creating its own (forwarded to `createSyncClient`'s
53
+ * {@link CreateSyncClientOptions.precreatedPglite}) — the client still applies schema/reconcile. In a
54
+ * browser worker the store is minted internally (`dataDir`); this is the seam for a prepopulated store in
55
+ * tests, and the future spare-worker claim (ADR-0032 decision 5).
56
+ */
57
+ precreatedPglite?: CreateSyncClientOptions<TRegistry>["precreatedPglite"];
58
+ /** A fully-provisioned PGlite (forwarded to {@link CreateSyncClientOptions.pgliteInstance}; caller owns schema). */
59
+ pgliteInstance?: CreateSyncClientOptions<TRegistry>["pgliteInstance"];
60
+ }
61
+ /** The worker-side host: attach ports, await the boot, and (for tests) tear down. */
62
+ export interface SyncWorkerHost<TRegistry extends SyncTableRegistry> {
63
+ /** Bind a transport port (a SharedWorker connection, the dedicated-worker `self`, or a test channel port). */
64
+ connect: (port: BridgePort) => void;
65
+ /** Resolves with the booted in-process engine once the first attach's `createSyncClient` completes. */
66
+ whenBooted: () => Promise<SyncClient<TRegistry>>;
67
+ /** Detach every port and stop the underlying client — for tests and dedicated-worker teardown. */
68
+ close: () => Promise<void>;
69
+ }
70
+ /**
71
+ * Build a worker host over the given engine config. In a real worker file the consumer calls this at module
72
+ * top level and it auto-binds the global scope; a test constructs it and drives {@link SyncWorkerHost.connect}.
73
+ */
74
+ export declare function defineSyncWorker<const TRegistry extends SyncTableRegistry>(options: DefineSyncWorkerOptions<TRegistry>): SyncWorkerHost<TRegistry>;
75
+ //# sourceMappingURL=define-sync-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-sync-worker.d.ts","sourceRoot":"","sources":["../../src/worker/define-sync-worker.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoC,iBAAiB,EAAa,MAAM,sBAAsB,CAAC;AAI3G,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,uBAAuB,EAI5B,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAEL,KAAK,WAAW,EAGhB,KAAK,UAAU,EAUhB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,uBAAuB,CAAC,SAAS,SAAS,iBAAiB;IAC1E;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC;IACtE;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,+GAA+G;IAC/G,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,gHAAgH;IAChH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4GAA4G;IAC5G,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;IAC1E,oHAAoH;IACpH,cAAc,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC;CACvE;AAED,qFAAqF;AACrF,MAAM,WAAW,cAAc,CAAC,SAAS,SAAS,iBAAiB;IACjE,8GAA8G;IAC9G,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACpC,uGAAuG;IACvG,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,kGAAkG;IAClG,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAOD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,SAAS,SAAS,iBAAiB,EACxE,OAAO,EAAE,uBAAuB,CAAC,SAAS,CAAC,GAC1C,cAAc,CAAC,SAAS,CAAC,CAya3B"}
@@ -0,0 +1,44 @@
1
+ import type { LiveDiffPayload } from "./protocol";
2
+ /**
3
+ * The stable key for a result row (§4). With `pkColumns`, join their values (composite-safe) — this is the
4
+ * diff-keying identity, so a row whose PK is unchanged is the SAME logical row even if other columns moved.
5
+ * Without `pkColumns` (a keyless query) fall back to the whole-row JSON value: still diff-shaped (never a
6
+ * full resend), but an update surfaces as remove+add rather than a `changed` — the documented keyless
7
+ * fallback. Duplicate identical keyless rows collapse under this scheme (accepted for the fallback).
8
+ */
9
+ export declare function rowKey(row: Record<string, unknown>, pkColumns: readonly string[] | undefined): string;
10
+ /** The worker's per-subscription memory: the last delivered rows keyed by {@link rowKey}, in delivered order. */
11
+ export interface LiveDiffState {
12
+ pkColumns?: readonly string[];
13
+ /** key → the exact row body last sent, so the next diff can detect `changed` and skip unchanged rows. */
14
+ previous: Map<string, Record<string, unknown>>;
15
+ }
16
+ /** Seed the diff state from the initial snapshot (which the worker sends verbatim, not as a diff). */
17
+ export declare function seedLiveDiffState(rows: readonly Record<string, unknown>[], pkColumns: readonly string[] | undefined): LiveDiffState;
18
+ /**
19
+ * Diff a fresh ordered result set against the state's previous set, MUTATING the state to the new set and
20
+ * returning the wire diff (§4). `order` is every key in the new ORDER BY order (keys only — cheap); `added`/
21
+ * `changed` carry the delta row BODIES; `removed` carries dropped keys. Never emits the full result set: a
22
+ * single-row change yields one `changed` and the (key-only) `order`.
23
+ */
24
+ export declare function computeLiveDiff(state: LiveDiffState, nextRows: readonly Record<string, unknown>[]): Omit<LiveDiffPayload, "queryId">;
25
+ /**
26
+ * The tab-side fold of live diffs into an ordered row array with STABLE object identity (§4). The initial
27
+ * snapshot seeds the cache; each diff rebuilds the array from `diff.order`, reusing the cached object for
28
+ * any key not in `added`/`changed` (so an unchanged row keeps `===` and a memoized React row skips its
29
+ * re-render), and installing a fresh object for added/changed keys. Order is exactly `diff.order` — the
30
+ * query's ORDER BY as delivered by the worker.
31
+ */
32
+ export declare class LiveRowsMaterializer<TRow extends Record<string, unknown> = Record<string, unknown>> {
33
+ private byKey;
34
+ private rows;
35
+ private readonly pkColumns;
36
+ constructor(pkColumns: readonly string[] | undefined);
37
+ /** Seed from the initial snapshot; returns the initial ordered rows (each a distinct cached object). */
38
+ seed(initialRows: readonly TRow[]): TRow[];
39
+ /** Apply a diff; returns the new ordered array (a fresh array, but unchanged rows keep their object identity). */
40
+ apply(diff: Omit<LiveDiffPayload, "queryId">): TRow[];
41
+ /** The current ordered rows (identity-stable across `apply` calls for unchanged rows). */
42
+ current(): TRow[];
43
+ }
44
+ //# sourceMappingURL=live-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-diff.d.ts","sourceRoot":"","sources":["../../src/worker/live-diff.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAKrG;AAaD,iHAAiH;AACjH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,yGAAyG;IACzG,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAChD;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACxC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACvC,aAAa,CAIf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAC3C,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CA+BlC;AAED;;;;;;GAMG;AACH,qBAAa,oBAAoB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9F,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAE1D,YAAY,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAEnD;IAED,wGA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