@pgxsinkit/client 0.1.48 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boot-report.d.ts +76 -0
- package/dist/boot-report.d.ts.map +1 -1
- package/dist/index.d.ts +84 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1549 -333
- package/dist/index.js.map +15 -12
- package/dist/local-store.d.ts +58 -0
- package/dist/local-store.d.ts.map +1 -1
- package/dist/local-tables.d.ts +340 -0
- package/dist/local-tables.d.ts.map +1 -1
- package/dist/mutation.d.ts +36 -0
- package/dist/mutation.d.ts.map +1 -1
- package/dist/mutations-api.d.ts +82 -0
- package/dist/mutations-api.d.ts.map +1 -0
- package/dist/schema.d.ts +62 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts +17 -0
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/live-query-fingerprint.d.ts +14 -0
- package/dist/worker/live-query-fingerprint.d.ts.map +1 -0
- package/dist/worker/live-query-manager.d.ts +130 -0
- package/dist/worker/live-query-manager.d.ts.map +1 -0
- package/dist/worker/protocol.d.ts +53 -2
- package/dist/worker/protocol.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/core/SKILL.md +1 -1
- package/skills/operating/SKILL.md +29 -1
- package/src/boot-report.ts +108 -0
- package/src/index.ts +648 -152
- package/src/local-store.ts +150 -3
- package/src/local-tables.ts +49 -1
- package/src/mutation.ts +256 -15
- package/src/mutations-api.ts +310 -0
- package/src/schema.ts +406 -193
- package/src/worker/attach-sync-client.ts +193 -15
- package/src/worker/define-sync-worker.ts +267 -53
- package/src/worker/live-query-fingerprint.ts +128 -0
- package/src/worker/live-query-manager.ts +591 -0
- package/src/worker/protocol.ts +49 -1
package/dist/schema.d.ts
CHANGED
|
@@ -7,7 +7,69 @@ import { type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const LOCAL_META_TABLE = "pgxsinkit_local_meta";
|
|
9
9
|
export declare const REGISTRY_FINGERPRINT_KEY = "registry_fingerprint";
|
|
10
|
+
/**
|
|
11
|
+
* The `pgxsinkit_local_meta` key holding the DURABLE-schema fingerprint the local store was last
|
|
12
|
+
* provisioned under (warm-persisted-store-startup slice 3 / proposal §3). Its value is
|
|
13
|
+
* `lsf1:<hash(durable SQL)>` (see {@link computeLocalSchemaFingerprint}); a boot compares it against the
|
|
14
|
+
* freshly-generated durable SQL's hash to SKIP the durable replay when they match.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LOCAL_SCHEMA_FINGERPRINT_KEY = "local_schema_fingerprint";
|
|
17
|
+
/** The versioned value prefix for {@link LOCAL_SCHEMA_FINGERPRINT_KEY} (bump only if the encoding changes). */
|
|
18
|
+
export declare const LOCAL_SCHEMA_FINGERPRINT_PREFIX = "lsf1:";
|
|
19
|
+
/**
|
|
20
|
+
* The registry-wide cross-journal mutation view (warm-persisted-store-startup slice 4 / proposal §5,
|
|
21
|
+
* option 1). A `TEMP` view UNION-ALL-ing every writable table's journal down to the shared fixed columns
|
|
22
|
+
* (plus a `table_key` literal per branch), so a consumer can render one global mutation summary/detail
|
|
23
|
+
* subscription instead of one live query per writable journal. It MUST be `TEMP`: an ephemeral entry's
|
|
24
|
+
* journal is a `pg_temp` relation (ADR-0021 §3), which a durable view cannot reference — and it is
|
|
25
|
+
* recreated on every engine boot (a TEMP view dies with the old engine), so it lives in the always-applied
|
|
26
|
+
* ephemeral schema portion, NOT the durable (fingerprint-gated) portion. See {@link getAllMutationsView}
|
|
27
|
+
* for the query-authoring Drizzle object over it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ALL_MUTATIONS_VIEW = "pgxsinkit_all_mutations";
|
|
30
|
+
/**
|
|
31
|
+
* The shared fixed journal columns the {@link ALL_MUTATIONS_VIEW} branches project (in journal-DDL order),
|
|
32
|
+
* mirroring `buildJournalFixedColumns` (local-tables.ts) MINUS `payload_json` (detail rows stay
|
|
33
|
+
* payload-free by default — entity identity comes from `entity_key_json`) and the per-table PRIMARY KEY
|
|
34
|
+
* columns (they differ per branch, so they cannot appear in a UNION ALL). `mutation_seq` is retained: it is
|
|
35
|
+
* a shared fixed column and {@link import("./mutation").MutationDetail} carries it — but it is per-journal,
|
|
36
|
+
* NOT globally ordered, so the detail API orders by `enqueued_at_us`, never this.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ALL_MUTATIONS_JOURNAL_COLUMNS: readonly ["mutation_id", "entity_key_json", "mutation_seq", "mutation_kind", "status", "registry_version", "base_server_version", "write_unit", "write_mode", "attempt_count", "last_error", "last_http_status", "conflict_reason", "server_updated_at_us", "enqueued_at_us", "next_retry_at_us", "sent_at_us", "acked_at_us", "updated_at_us"];
|
|
39
|
+
/**
|
|
40
|
+
* The minimal durable bootstrap (schema + meta table) as an executable script (slice 3). Run as the first,
|
|
41
|
+
* tiny crossing on every client-owned boot so the `local_schema_fingerprint` read/write has its table before
|
|
42
|
+
* the fingerprint fast path decides whether to replay the rest of the durable schema. Depends on the
|
|
43
|
+
* registry only for its local schema name, so it is a function rather than a bare constant.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildLocalMetaBootstrapSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
46
|
+
/** The DURABLE local schema as an executable script (slice 3) — the fingerprint's basis. See {@link durableSchemaStatements}. */
|
|
47
|
+
export declare function generateDurableLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
48
|
+
/**
|
|
49
|
+
* The EPHEMERAL (always-applied) local schema as an executable script (slice 3), or `""` when the registry
|
|
50
|
+
* has no ephemeral entry (so the boot skips the crossing). See {@link ephemeralSchemaStatements}.
|
|
51
|
+
*/
|
|
52
|
+
export declare function generateEphemeralLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
53
|
+
/**
|
|
54
|
+
* The complete local schema — durable statements then ephemeral statements — the single script the
|
|
55
|
+
* wipe/rebuild paths and every external caller keep using. For an all-persistent registry the durable stream
|
|
56
|
+
* IS the historical stream in registry order, now followed by the always-applied ephemeral portion — which
|
|
57
|
+
* for any registry with a writable table carries the `pgxsinkit_all_mutations` TEMP VIEW (slice 4), so the
|
|
58
|
+
* full script is no longer byte-identical to the pre-slice-4 output (it gains the trailing view). For a MIXED
|
|
59
|
+
* registry it is also idempotent-equivalent, NOT byte-identical to a single-pass interleave: the persistent
|
|
60
|
+
* clusters precede the ephemeral ones and the ephemeral portion re-emits idempotent enum guards — a
|
|
61
|
+
* reordering of independent `IF NOT EXISTS` DDL that executes to the same schema. Equals `durable + ephemeral`
|
|
62
|
+
* by construction (test-covered).
|
|
63
|
+
*/
|
|
10
64
|
export declare function generateLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
65
|
+
/**
|
|
66
|
+
* The durable-schema fingerprint value (slice 3 / proposal §3): `lsf1:<FNV-1a hash of the durable SQL>`. The
|
|
67
|
+
* hash is over the generated durable DDL body itself (no composed inputs, no hand-maintained format-version
|
|
68
|
+
* constant), so it auto-invalidates on ANY generator change, registry change, or projection rename — the
|
|
69
|
+
* ADR-0018 apply-function-fingerprint precedent applied to the local schema. Stamped into
|
|
70
|
+
* {@link LOCAL_SCHEMA_FINGERPRINT_KEY} only after a successful durable exec.
|
|
71
|
+
*/
|
|
72
|
+
export declare function computeLocalSchemaFingerprint<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
11
73
|
/**
|
|
12
74
|
* Render `CREATE TABLE IF NOT EXISTS` (plus a `CREATE INDEX IF NOT EXISTS` per declared index) for a
|
|
13
75
|
* Drizzle `pgTable` / `pgSchema.table`, through the SAME column/PK/type machinery
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,SAAS,iBAAiB,EACrE,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,GACvG,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
|
@@ -58,6 +58,23 @@ export interface DefineSyncWorkerOptions<TRegistry extends SyncTableRegistry> {
|
|
|
58
58
|
precreatedPglite?: CreateSyncClientOptions<TRegistry>["precreatedPglite"];
|
|
59
59
|
/** A fully-provisioned PGlite (forwarded to {@link CreateSyncClientOptions.pgliteInstance}; caller owns schema). */
|
|
60
60
|
pgliteInstance?: CreateSyncClientOptions<TRegistry>["pgliteInstance"];
|
|
61
|
+
/**
|
|
62
|
+
* Bounded zero-subscriber keep-alive for the live-query manager (ADR-0040 decision 4). When an entry's last
|
|
63
|
+
* subscriber leaves, a nonzero effective keep-alive retains its PGlite registration + diff state for a grace
|
|
64
|
+
* period so a matching resubscribe (e.g. a re-mounted route across tabs) reuses it verbatim — no ~400 ms
|
|
65
|
+
* re-materialization. Bounded by explicit budgets; DEFAULTS OFF (`defaultKeepAliveMs: 0` → tear a query
|
|
66
|
+
* down the instant its last consumer leaves, byte-identical to the pre-keep-alive behaviour). Standing
|
|
67
|
+
* argument for the 0 default: a retained entry STILL pays a full SQL rerun + diff on every dependent write —
|
|
68
|
+
* PGlite live queries cannot be paused — so retention only pays off for a genuinely hot, re-mounted query.
|
|
69
|
+
*/
|
|
70
|
+
liveQueries?: {
|
|
71
|
+
/** Baseline retention (ms) for a zero-subscriber entry; floored by each subscriber's own hint. Default 0. */
|
|
72
|
+
defaultKeepAliveMs?: number;
|
|
73
|
+
/** Max simultaneously-retained (zero-subscriber) entries — LRU-evicted past this. Default 16. */
|
|
74
|
+
maxRetainedQueries?: number;
|
|
75
|
+
/** Max total rows across all retained entries — LRU-evicted past this. Default 50_000. */
|
|
76
|
+
maxRetainedRows?: number;
|
|
77
|
+
};
|
|
61
78
|
}
|
|
62
79
|
/** The worker-side host: attach ports, await the boot, and (for tests) tear down. */
|
|
63
80
|
export interface SyncWorkerHost<TRegistry extends SyncTableRegistry> {
|
|
@@ -1 +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,EAO5B,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;
|
|
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,EAO5B,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAUlB,OAAO,EAGL,KAAK,WAAW,EAGhB,KAAK,UAAU,EAWhB,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;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACxF,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/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C,GAC1C,cAAc,CAAC,SAAS,CAAC,CA0yB3B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The map key (full canonical string — the dedup identity) plus a short digest for diagnostics (Slice 5). */
|
|
2
|
+
export interface LiveQueryFingerprint {
|
|
3
|
+
/** The exact dedup key: two subscriptions share a registration iff their `key` is identical. */
|
|
4
|
+
key: string;
|
|
5
|
+
/** A short, opaque hash of `key` — for diagnostics/observability only, NEVER used for dedup. */
|
|
6
|
+
digest: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fingerprint a live query. `materialSql` is the POST-WRAP SQL (the manager's registration input); `params`
|
|
10
|
+
* are the decoded bound params; `pkColumns` selects the key mode. Returns the full canonical `key` (the dedup
|
|
11
|
+
* identity) and a short `digest` for diagnostics.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fingerprintLiveQuery(materialSql: string, params: readonly unknown[], pkColumns?: readonly string[]): LiveQueryFingerprint;
|
|
14
|
+
//# sourceMappingURL=live-query-fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-query-fingerprint.d.ts","sourceRoot":"","sources":["../../src/worker/live-query-fingerprint.ts"],"names":[],"mappings":"AAYA,8GAA8G;AAC9G,MAAM,WAAW,oBAAoB;IACnC,gGAAgG;IAChG,GAAG,EAAE,MAAM,CAAC;IACZ,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;CAChB;AAqFD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAC5B,oBAAoB,CAetB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { LiveNamespace } from "@electric-sql/pglite/live";
|
|
2
|
+
import type { LiveDiffPayload } from "./protocol";
|
|
3
|
+
type Row = Record<string, unknown>;
|
|
4
|
+
/** The wire diff a subscriber receives — exactly `computeLiveDiff`'s output, minus the caller's `queryId`. */
|
|
5
|
+
export type LiveDiffWire = Omit<LiveDiffPayload, "queryId">;
|
|
6
|
+
/** The two delivery callbacks a subscriber supplies; the caller wires these to its bridge posting. */
|
|
7
|
+
export interface LiveSubscriber {
|
|
8
|
+
/** The verbatim initial snapshot (NOT a diff), delivered ONCE before any diff (rows-before-diff ordering). */
|
|
9
|
+
deliverInitial(rows: readonly Row[]): void;
|
|
10
|
+
/** A subsequent change, already diffed against the last delivered set. */
|
|
11
|
+
deliverDiff(diff: LiveDiffWire): void;
|
|
12
|
+
}
|
|
13
|
+
/** Post-wrap SQL + bound params + optional single-column PK (selects `incrementalQuery` vs `query`). */
|
|
14
|
+
export interface LiveQuerySpec {
|
|
15
|
+
materialSql: string;
|
|
16
|
+
params: unknown[];
|
|
17
|
+
pkColumns?: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/** Per-subscription options (ADR-0040). */
|
|
20
|
+
export interface LiveSubscribeOptions {
|
|
21
|
+
/**
|
|
22
|
+
* How long (ms) THIS subscriber asks the entry to be retained after IT (and any siblings) leave. The
|
|
23
|
+
* entry's effective keep-alive is `max(policy default, the max hint of the current active generation)`
|
|
24
|
+
* (see the generation rule on `subscribe`); the worker count/row budgets stay authoritative over any hint.
|
|
25
|
+
* Absent / 0 → no retention from this subscriber. Must be a finite number ≥ 0.
|
|
26
|
+
*/
|
|
27
|
+
keepAliveMs?: number;
|
|
28
|
+
/**
|
|
29
|
+
* An opaque grouping key for diagnostics only (ADR-0040 decision 5) — never part of the fingerprint, so it
|
|
30
|
+
* NEVER affects dedup or registration. The worker passes one stable scope per bridge port, so a snapshot's
|
|
31
|
+
* `scopeCount` reads as the distinct-tab count; the in-process client passes none.
|
|
32
|
+
*/
|
|
33
|
+
scope?: string;
|
|
34
|
+
}
|
|
35
|
+
/** A live registration's handle: awaited/tracked teardown and a coalesced refresh. */
|
|
36
|
+
export interface LiveSubscription {
|
|
37
|
+
/** Non-blocking for the caller; the promise is retained internally so `dispose()` awaits it (decision 1). */
|
|
38
|
+
unsubscribe(): Promise<void>;
|
|
39
|
+
/** Force one recompute; concurrent calls SHARE one underlying `live.refresh()` (never N stacked reruns). */
|
|
40
|
+
refresh(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/** The manager's bounded keep-alive policy (ADR-0040 decision 4). All fields default; the block is opt-in. */
|
|
43
|
+
export interface LiveQueryPolicy {
|
|
44
|
+
/**
|
|
45
|
+
* Default retention (ms) for a zero-subscriber entry, floored by each subscriber's own `keepAliveMs` hint.
|
|
46
|
+
* Default 0 — the current route-scoped behaviour (tear a query down the moment its last consumer leaves).
|
|
47
|
+
* The standing argument for 0: a retained zero-subscriber entry STILL pays a full SQL rerun + diff on every
|
|
48
|
+
* dependent-table write — PGlite live queries cannot be paused, only torn down — so retention trades that
|
|
49
|
+
* standing cost for avoiding re-materialization, and is only worth it for a genuinely hot, re-mounted query.
|
|
50
|
+
*/
|
|
51
|
+
defaultKeepAliveMs?: number;
|
|
52
|
+
/** Max simultaneously-retained (zero-subscriber) entries; LRU-evicted past this. Active entries never count. */
|
|
53
|
+
maxRetainedQueries?: number;
|
|
54
|
+
/** Max total rows held across ALL retained entries; LRU-evicted past this. Active entries never count. */
|
|
55
|
+
maxRetainedRows?: number;
|
|
56
|
+
}
|
|
57
|
+
type TimerHandle = unknown;
|
|
58
|
+
export interface LiveQueryManagerDeps {
|
|
59
|
+
/** The engine's `live` namespace — only the two registration entry points are used. */
|
|
60
|
+
live: Pick<LiveNamespace, "query" | "incrementalQuery">;
|
|
61
|
+
/** Bounded keep-alive policy (ADR-0040 decision 4); omitted → all defaults (retention off). */
|
|
62
|
+
policy?: LiveQueryPolicy;
|
|
63
|
+
/** Monotonic clock for keep-alive LRU accounting. Default `performance.now()` (Date.now fallback). */
|
|
64
|
+
now?: () => number;
|
|
65
|
+
/** Injectable eviction timer (tests drive it deterministically). Default `setTimeout`. */
|
|
66
|
+
setTimer?: (callback: () => void, ms: number) => TimerHandle;
|
|
67
|
+
/** Injectable timer cancel. Default `clearTimeout`. */
|
|
68
|
+
clearTimer?: (handle: TimerHandle) => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A structured-clone-safe, per-entry diagnostics record (ADR-0040 decision 5). It carries ONLY opaque
|
|
72
|
+
* fingerprint digests and counts/timings — NEVER SQL text, bound param values, or result-row values (those
|
|
73
|
+
* live only in the fingerprint's private `key`, which is deliberately absent here). Safe to cross the bridge
|
|
74
|
+
* and surface in support tooling.
|
|
75
|
+
*/
|
|
76
|
+
export interface LiveQueryDiagnostics {
|
|
77
|
+
/** The opaque fingerprint digest (a short hash — see live-query-fingerprint.ts). NEVER the full key. */
|
|
78
|
+
digest: string;
|
|
79
|
+
/** Current subscriber count (0 while retained). */
|
|
80
|
+
subscriberCount: number;
|
|
81
|
+
/**
|
|
82
|
+
* Distinct subscription scopes on this entry. The worker passes one scope per bridge port, so in WORKER
|
|
83
|
+
* mode this is the number of distinct tabs on the query; the in-process client passes none, so it stays 1
|
|
84
|
+
* while any subscriber is attached (0 while retained).
|
|
85
|
+
*/
|
|
86
|
+
scopeCount: number;
|
|
87
|
+
/** Rows currently held in the shared diff state. */
|
|
88
|
+
rowCount: number;
|
|
89
|
+
/** Whether this is a zero-subscriber entry currently kept alive (ADR-0040 decision 4). */
|
|
90
|
+
retained: boolean;
|
|
91
|
+
/** How many subscribes JOINED this entry rather than creating it (active-joins + retained rejoins). */
|
|
92
|
+
dedupHits: number;
|
|
93
|
+
/** Monotonic stamp (ms) when the entry was created. */
|
|
94
|
+
createdAt: number;
|
|
95
|
+
/** Time (ms) the registration setup took, or `null` until setup completes. */
|
|
96
|
+
setupMs: number | null;
|
|
97
|
+
/** Refresh timings for the shared registration (the hydration-chain / force refreshes). */
|
|
98
|
+
refresh: {
|
|
99
|
+
count: number;
|
|
100
|
+
lastMs: number | null;
|
|
101
|
+
totalMs: number;
|
|
102
|
+
maxMs: number;
|
|
103
|
+
};
|
|
104
|
+
/** Monotonic stamp (ms) of the last transition to zero subscribers, or `null` if never retained. */
|
|
105
|
+
lastUsedAt: number | null;
|
|
106
|
+
/** How long (ms) the entry has been retained (now − lastUsedAt), or `null` when not retained. */
|
|
107
|
+
retainedSinceMs: number | null;
|
|
108
|
+
/** A teardown is in flight (the entry is unsubscribing from PGlite). */
|
|
109
|
+
teardownPending: boolean;
|
|
110
|
+
}
|
|
111
|
+
export interface LiveQueryManager {
|
|
112
|
+
subscribe(spec: LiveQuerySpec, subscriber: LiveSubscriber, opts?: LiveSubscribeOptions): Promise<LiveSubscription>;
|
|
113
|
+
/** Tear down every live registration and await ALL teardowns (the Slice-1 close-vs-unsubscribe guard). */
|
|
114
|
+
dispose(): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* A point-in-time diagnostics snapshot (ADR-0040 decision 5): one plain-object record per live entry,
|
|
117
|
+
* carrying digests + counts/timings only — NO SQL, params, or rows. For the `liveQueryDiagnostics` RPC and
|
|
118
|
+
* support tooling.
|
|
119
|
+
*/
|
|
120
|
+
snapshot(): LiveQueryDiagnostics[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Validate a keep-alive policy at the public boundary (ADR-0040 decision 4 — bounded, no permanent retention).
|
|
124
|
+
* Every provided field must be a finite number ≥ 0; the two budgets must additionally be integers. Throws a
|
|
125
|
+
* `TypeError` naming the offending field so a misconfiguration fails at construction, not at first subscribe.
|
|
126
|
+
*/
|
|
127
|
+
export declare function validateLiveQueryPolicy(policy: LiveQueryPolicy | undefined): void;
|
|
128
|
+
export declare function createLiveQueryManager(deps: LiveQueryManagerDeps): LiveQueryManager;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=live-query-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-query-manager.d.ts","sourceRoot":"","sources":["../../src/worker/live-query-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,2BAA2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O,CAAC,gBAAgB,CAAC,CAAC;IACnH,0GAA0G;IAC1G,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;;;OAIG;IACH,QAAQ,IAAI,oBAAoB,EAAE,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAsBjF;AAyCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,gBAAgB,CA8WnF"}
|
|
@@ -144,6 +144,14 @@ export interface AttachPayload {
|
|
|
144
144
|
export interface SetOnlinePayload {
|
|
145
145
|
online: boolean;
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* The two background boot stages the worker announces over the bridge as one-shot milestones (ADR-0041
|
|
149
|
+
* stage 2). `localReadReady` is NOT in this set: under the Option B contract the `attach-ack` fires AT the
|
|
150
|
+
* engine's `localReadReady`, so a tab resolves that stage from the ack itself (early OR late attach) — it
|
|
151
|
+
* needs no separate milestone. `writeReady` and `bootSettled` cross in the background write/sync tail, after
|
|
152
|
+
* the ack, so they DO ride milestone messages (and the late-attach ack fold).
|
|
153
|
+
*/
|
|
154
|
+
export type BootMilestone = "writeReady" | "bootSettled";
|
|
147
155
|
/** worker → tab: attach acknowledged. `alreadyBooted` is false for the attach that booted the engine. */
|
|
148
156
|
export interface AttachAckPayload {
|
|
149
157
|
alreadyBooted: boolean;
|
|
@@ -154,9 +162,34 @@ export interface AttachAckPayload {
|
|
|
154
162
|
* the ack, rather than wait for a phase-"ready" status that may never come again.
|
|
155
163
|
*/
|
|
156
164
|
engineReady?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Late-attach milestone fold (ADR-0041 stage 2): true when the engine had ALREADY crossed `writeReady` /
|
|
167
|
+
* `bootSettled` by the time this attach was acked, so a tab attaching after the stage fired resolves it
|
|
168
|
+
* straight from the ack rather than waiting for a `milestone` broadcast it missed. The ack fires AT
|
|
169
|
+
* `localReadReady`, so that stage is always implied by a non-error ack and carries no boolean.
|
|
170
|
+
*/
|
|
171
|
+
writeReady?: boolean;
|
|
172
|
+
bootSettled?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Late-attach failure fold (ADR-0041 stage 2): present when the engine's background write/sync tail had
|
|
175
|
+
* already REJECTED a downstream stage before this attach was acked. The tab rejects the matching stage
|
|
176
|
+
* promise (so a gated write / `bootSettled` awaiter fails loudly rather than hangs) — but the attach
|
|
177
|
+
* itself still RESOLVES (the engine reached `localReadReady`; only the tail failed). A live milestone
|
|
178
|
+
* failure after attach rides the `milestone-error` broadcast instead.
|
|
179
|
+
*/
|
|
180
|
+
writeReadyError?: {
|
|
181
|
+
message: string;
|
|
182
|
+
detail?: unknown;
|
|
183
|
+
};
|
|
184
|
+
bootSettledError?: {
|
|
185
|
+
message: string;
|
|
186
|
+
detail?: unknown;
|
|
187
|
+
};
|
|
157
188
|
/**
|
|
158
189
|
* Present when the engine boot REJECTED for this attach: the tab rejects `attachSyncClient` with this
|
|
159
|
-
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot.
|
|
190
|
+
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot. This
|
|
191
|
+
* is a LOCAL-READ-CORE failure (the engine never reached `localReadReady`); a tail failure after
|
|
192
|
+
* `localReadReady` uses the stage-error fields above and does NOT reject the attach.
|
|
160
193
|
*/
|
|
161
194
|
error?: {
|
|
162
195
|
message: string;
|
|
@@ -176,7 +209,7 @@ export interface TokenResponsePayload {
|
|
|
176
209
|
* The RPC ops the attach facade proxies to the worker's booted client — the write API (mirrors
|
|
177
210
|
* `client.mutate`/flush), mutation-state reads, and the one-shot raw inspection reads (`rawQuery`/`rawExec`).
|
|
178
211
|
*/
|
|
179
|
-
export type RpcOp = "create" | "update" | "delete" | "batch" | "transaction" | "flush" | "reconcile" | "retryFailed" | "recoverSending" | "discardConflict" | "discardQuarantined" | "desync" | "discardEphemeral" | "readMutationDetails" | "diagnostics" | "rawQuery" | "rawExec" | "bootReport" | "exportStore" | "exportDiagnostics" | "exportData";
|
|
212
|
+
export type RpcOp = "create" | "update" | "delete" | "batch" | "transaction" | "flush" | "reconcile" | "retryFailed" | "recoverSending" | "discardConflict" | "discardQuarantined" | "desync" | "discardEphemeral" | "readMutationDetails" | "diagnostics" | "rawQuery" | "rawExec" | "bootReport" | "liveQueryDiagnostics" | "exportStore" | "exportDiagnostics" | "exportData";
|
|
180
213
|
/** tab → worker: a write/read-of-mutation-state RPC. `id` correlates the matching {@link RpcResultPayload}. */
|
|
181
214
|
export interface RpcPayload {
|
|
182
215
|
op: RpcOp;
|
|
@@ -234,6 +267,14 @@ export interface SubscribePayload {
|
|
|
234
267
|
pkColumns?: string[];
|
|
235
268
|
/** Lazy relations to activate before the query runs (ADR-0021), forwarded to the worker's `prepareQuery`. */
|
|
236
269
|
use?: string[];
|
|
270
|
+
/**
|
|
271
|
+
* Per-subscription keep-alive hint (ms) for the worker's live-query manager (ADR-0040 decision 4): how long
|
|
272
|
+
* the shared registration should be retained after this subscription's last consumer leaves, so a matching
|
|
273
|
+
* resubscribe reuses it verbatim. ADDITIVE and backward-compatible both directions — an older tab omits it
|
|
274
|
+
* (the worker falls back to its `liveQueries.defaultKeepAliveMs`), and an older worker ignores it. Absent
|
|
275
|
+
* means "no hint".
|
|
276
|
+
*/
|
|
277
|
+
keepAliveMs?: number;
|
|
237
278
|
}
|
|
238
279
|
/** worker → tab: the initial ordered snapshot for a subscription. `id` correlates the `subscribe` request. */
|
|
239
280
|
export interface LiveInitialPayload {
|
|
@@ -292,6 +333,16 @@ export type BridgeEvent = {
|
|
|
292
333
|
} | {
|
|
293
334
|
kind: "groupReady";
|
|
294
335
|
groupKey: string;
|
|
336
|
+
} | {
|
|
337
|
+
kind: "milestone";
|
|
338
|
+
stage: BootMilestone;
|
|
339
|
+
} | {
|
|
340
|
+
kind: "milestone-error";
|
|
341
|
+
stage: BootMilestone;
|
|
342
|
+
error: {
|
|
343
|
+
message: string;
|
|
344
|
+
detail?: unknown;
|
|
345
|
+
};
|
|
295
346
|
} | {
|
|
296
347
|
kind: "conflict";
|
|
297
348
|
details: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/worker/protocol.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,cAAc,EAAG,kBAA2B,CAAC;AAC1D,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IACzE,gBAAgB,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAC1F,mBAAmB,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAC7F,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,cAAc,CAAC;IAC1B,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,iHAAiH;IACjH,EAAE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W,WAAW;IAC1B,2GAA2G;IAC3G,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAA;KAAE,CAAC;IACpF,oFAAoF;IACpF,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CACvC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAG3B,CAAC;AAIF,8GAA8G;AAC9G,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM,GACV;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAU/D;AAED,mHAAmH;AACnH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,CAOtE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,kBAAkB,EAAE,GAC9B,IAAI,CAQN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgxsinkit/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@electric-sql/client": "^1.5.24",
|
|
37
37
|
"@electric-sql/experimental": "^6.0.24",
|
|
38
38
|
"@electric-sql/pglite-tools": "0.4.4",
|
|
39
|
-
"@pgxsinkit/contracts": "0.1.
|
|
39
|
+
"@pgxsinkit/contracts": "0.1.50"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@electric-sql/pglite": "0.5.4",
|
package/skills/core/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: task
|
|
15
15
|
library: "@pgxsinkit/client"
|
|
16
|
-
library_version: "0.1.
|
|
16
|
+
library_version: "0.1.50"
|
|
17
17
|
source: https://pgxsinkit.github.io/start/operating-in-production/
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -153,6 +153,34 @@ shows nothing" is worker mode working as designed, not an absence of requests. I
|
|
|
153
153
|
rejections surface only there). Full model:
|
|
154
154
|
<https://pgxsinkit.github.io/concepts/worker-mode/>.
|
|
155
155
|
|
|
156
|
+
## Live-query manager: dedup + keep-alive (ADR-0040)
|
|
157
|
+
|
|
158
|
+
Every reactive read (`useLiveDrizzleRows`/`useLiveQueryRaw`/`subscribeLiveRows`) is a **local SQL live
|
|
159
|
+
query**: PGlite materialises it once, then re-runs + diffs it on every write to its tables. That registration
|
|
160
|
+
is a real cost — ~a few hundred ms to materialise a heavy aggregate — and is **automatically deduplicated**:
|
|
161
|
+
identical queries (keyed on executed SQL + bound params, NOT `use`) share ONE registration and ONE re-run +
|
|
162
|
+
diff per write, fanned to every subscriber. So N components — or N tabs on the shared worker — on the same
|
|
163
|
+
query cost one materialisation, not N. You do nothing to get this.
|
|
164
|
+
|
|
165
|
+
Default lifetime is route-scoped: a live query is torn down the instant its last consumer unmounts, so a
|
|
166
|
+
navigate-away-and-back RE-materialises it. Opt a genuinely hot query into a grace period with a per-hook hint
|
|
167
|
+
`useLiveDrizzleRows(build, deps, { keepAliveMs: 30_000 })` (or the raw-hook / `subscribeLiveRows` field), or
|
|
168
|
+
set a worker/client-wide policy `defineSyncWorker({ …, liveQueries: { defaultKeepAliveMs, maxRetainedQueries,
|
|
169
|
+
maxRetainedRows } })` (defaults `0` / `16` / `50_000`; same block on `createSyncClient`). The effective
|
|
170
|
+
keep-alive is `max(default, subscribers' hints)`; the count/row budgets are authoritative over any hint and
|
|
171
|
+
LRU-evict zero-subscriber entries past them; active (still-subscribed) entries are never evicted.
|
|
172
|
+
|
|
173
|
+
**Keep the default 0 unless you have a specific hot query.** A retained zero-subscriber query is NOT paused —
|
|
174
|
+
PGlite live queries can't be — so it still pays a full re-run + diff on every write to its tables for as long
|
|
175
|
+
as it's held. Retention wins only for a frequently-re-mounted, write-COLD query; for a write-hot one it costs
|
|
176
|
+
more idle than the one re-materialisation it saves. For a fixed hot set, the endorsed "permanent" pattern is a
|
|
177
|
+
**mounted subscriber** (a root-provider hook that never unmounts) — one live registration for the app's life,
|
|
178
|
+
every route dedups onto it — not a retention setting; there is deliberately no retain-forever knob.
|
|
179
|
+
|
|
180
|
+
`client.liveQueryDiagnostics()` returns a per-entry snapshot — fingerprint DIGEST (never SQL/params/rows),
|
|
181
|
+
subscriber + row counts, setup/refresh timings, retention state — safe to log. The manager also emits
|
|
182
|
+
`live-query register|dedup-hit|retained|evicted|teardown-complete` lines on the debug rail (digests only).
|
|
183
|
+
|
|
156
184
|
## Store naming, backups, and restore (ADR-0035/0036)
|
|
157
185
|
|
|
158
186
|
**Stores are named by a plain `storePath`, never a storage URL.** The backend is derived (browser/worker →
|