@pgxsinkit/client 0.1.50 → 0.1.51
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/index.js +72 -28
- package/dist/index.js.map +9 -9
- package/dist/schema.d.ts +18 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/shape-sync.d.ts +6 -0
- package/dist/shape-sync.d.ts.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/metadata-tables.d.ts +16 -0
- package/dist/sync/metadata-tables.d.ts.map +1 -1
- package/dist/sync/subscription-state.d.ts +10 -2
- package/dist/sync/subscription-state.d.ts.map +1 -1
- package/dist/sync/tags.d.ts +16 -4
- package/dist/sync/tags.d.ts.map +1 -1
- package/dist/sync/types.d.ts +12 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/core/SKILL.md +1 -1
- package/skills/operating/SKILL.md +1 -1
- package/src/schema.ts +22 -4
- package/src/shape-sync.ts +11 -0
- package/src/sync/index.ts +14 -1
- package/src/sync/metadata-tables.ts +41 -0
- package/src/sync/subscription-state.ts +29 -4
- package/src/sync/tags.ts +34 -9
- package/src/sync/types.ts +12 -0
package/dist/schema.d.ts
CHANGED
|
@@ -83,8 +83,25 @@ export declare function computeLocalSchemaFingerprint<TRegistry extends SyncTabl
|
|
|
83
83
|
* ADR-0029 D3: the metadata-store DDL renders from its `metadata-tables.ts` pgTables through this,
|
|
84
84
|
* making the pgTable the single source. The OUTPUT is tier-③-by-nature runtime DDL (schema/table
|
|
85
85
|
* identifiers assembled at construction), but it is GENERATED from the model, never hand-maintained.
|
|
86
|
+
*
|
|
87
|
+
* ADR-0042: `{ temp: true }` renders the SESSION variant — `CREATE TEMP TABLE IF NOT EXISTS <bare name>`
|
|
88
|
+
* (+ each index `ON <bare name>`), IGNORING the pgTable's declared schema for the RELATION name. TEMP DDL
|
|
89
|
+
* takes the UNqualified relation name (the TEMP keyword places it in `pg_temp`; a `CREATE TEMP TABLE
|
|
90
|
+
* pg_temp.x` target is not portable). Same relation/index NAMES as the durable form: an index name lives
|
|
91
|
+
* per schema, so the durable (metadata-schema) and session (`pg_temp`) indexes coexist without collision
|
|
92
|
+
* (probed on real PGlite).
|
|
93
|
+
*
|
|
94
|
+
* CAVEAT — the `temp` flag only bares the RELATION name; `buildTableColumnSql` below still receives
|
|
95
|
+
* `schemaName` and would qualify any ENUM column type into THAT schema. That is correct only because the
|
|
96
|
+
* metadata pgTables (the sole callers of `{ temp: true }`) carry no enum columns. A future enum-bearing TEMP
|
|
97
|
+
* render would emit `<metadataSchema>.<enum>` for the column type — which is exactly what we want (enums are
|
|
98
|
+
* persistent DB objects living in the durable schema even for TEMP tables, ADR-0021 §3), NOT a `pg_temp`
|
|
99
|
+
* qualification. If this path ever renders a TEMP relation with an enum, keep the enum durable-qualified;
|
|
100
|
+
* do not fold the `temp` flag into the column-type schema.
|
|
86
101
|
*/
|
|
87
|
-
export declare function renderCreateTableSql(table: AnyPgTable
|
|
102
|
+
export declare function renderCreateTableSql(table: AnyPgTable, options?: {
|
|
103
|
+
temp?: boolean;
|
|
104
|
+
}): string[];
|
|
88
105
|
/**
|
|
89
106
|
* The `-t` allowlist for a Data export (ADR-0035 decision 1): the schema-qualified PHYSICAL synced table
|
|
90
107
|
* name for every registry entry that owns one, resolved through the SAME `getClientProjection` the local
|
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,EAAiC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAWL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAyB9B;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAC/D;;;;;GAKG;AACH,eAAO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,GAAG,MAAM,EAAE,CAiBlG;AAmLD;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,EAAE,CAapH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAgB/G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAyB7G;AAgHD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAkBtG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CA8BvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,SAAS,iBAAiB,EACrE,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CAkCR"}
|
package/dist/shape-sync.d.ts
CHANGED
|
@@ -163,6 +163,12 @@ interface StartGroupSyncOptions {
|
|
|
163
163
|
groupKey: string;
|
|
164
164
|
specs: ConfiguredShapeSyncSpec[];
|
|
165
165
|
registry: SyncTableRegistry;
|
|
166
|
+
/**
|
|
167
|
+
* ADR-0042: the group's retention is `ephemeral`, so its sync bookkeeping (cursor + tags) is session-
|
|
168
|
+
* scoped — the engine stores it in `pg_temp` relations that die with the engine. Forwarded straight to
|
|
169
|
+
* the engine's `syncShapesToTables`; absent/`false` for a persistent group (byte-identical storage).
|
|
170
|
+
*/
|
|
171
|
+
sessionScoped?: boolean;
|
|
166
172
|
headers?: ExternalHeadersRecord;
|
|
167
173
|
/** Fresh-store prefetch overlap gate (ADR-0032 S4) — forwarded to the engine's `syncShapesToTables`. */
|
|
168
174
|
dbReady?: Promise<void>;
|
package/dist/shape-sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape-sync.d.ts","sourceRoot":"","sources":["../src/shape-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG/C,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,eAAe,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,CAAC,EAAE,CAAC,QAAQ,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AChC,OAAO,CAAC,yBAAyB,CAAC,CA+LpC;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,uGAAuG;IACvG,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,qBAAqB,sDAwCtF;AAgCD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,uBAAuB,EAAE,kBAAkB,GAAG,UAAU,CAAC,GAAG,MAAM,CAEjH"}
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from "./types";
|
|
|
13
13
|
export declare function createSyncEngine(pg: PGliteInterface, options?: ElectricSyncOptions): Promise<{
|
|
14
14
|
namespace: {
|
|
15
15
|
initMetadataTables: () => Promise<void>;
|
|
16
|
-
syncShapesToTables: ({ key, registry, shapes, initialInsertMethod, onInitialSync, onError, onSyncError, onSyncActivity, dbReady, bootStamp, maxCommitRetries, commitRetryDelayMs, }: SyncShapesToTablesOptions) => Promise<SyncShapesToTablesResult>;
|
|
16
|
+
syncShapesToTables: ({ key, registry, shapes, sessionScoped, initialInsertMethod, onInitialSync, onError, onSyncError, onSyncActivity, dbReady, bootStamp, maxCommitRetries, commitRetryDelayMs, }: SyncShapesToTablesOptions) => Promise<SyncShapesToTablesResult>;
|
|
17
17
|
syncShapeToTable: (options: SyncShapeToTableOptions) => Promise<SyncShapeToTableResult>;
|
|
18
18
|
deleteSubscription: (key: string) => Promise<void>;
|
|
19
19
|
};
|
package/dist/sync/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0C5D,OAAO,EAEL,KAAK,mBAAmB,EAIxB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAgDxB;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,mBAAmB;;kCA+BxD,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0C5D,OAAO,EAEL,KAAK,mBAAmB,EAIxB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC;AAgDxB;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,mBAAmB;;kCA+BxD,OAAO,CAAC,IAAI,CAAC;4MA2BzC,yBAAyB,KAAG,OAAO,CAAC,wBAAwB,CAAC;oCA00BvB,uBAAuB,KAAG,OAAO,CAAC,sBAAsB,CAAC;kCAsC3D,MAAM;;;GAgC9C;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAEvD,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C,IAAI,EAAE,gBAAgB,CAAC;CACxB,CAAC"}
|
|
@@ -127,5 +127,21 @@ declare function buildShapeRowTags(schema: ReturnType<typeof pgSchema>): import(
|
|
|
127
127
|
}>;
|
|
128
128
|
/** The (memoized) metadata-store `pgTable`s for a given metadata schema name. */
|
|
129
129
|
export declare function getMetadataTables(metadataSchema: string): MetadataTables;
|
|
130
|
+
/**
|
|
131
|
+
* The (memoized) SESSION metadata-store `pgTable`s (ADR-0042) — the same relation names as the durable
|
|
132
|
+
* variants, built from the SAME column builders (ADR-0029 D3 single-source), but schema-qualified into
|
|
133
|
+
* `pg_temp` so the DML lands in the engine's session-scoped TEMP relations. No schema parameter: `pg_temp`
|
|
134
|
+
* is per-engine by construction, so a single memoized singleton serves every engine. The DDL that
|
|
135
|
+
* PROVISIONS these tables uses the unqualified `CREATE TEMP TABLE` form (the TEMP keyword places the
|
|
136
|
+
* relation in the session schema; a `pg_temp.x` DDL target is not portable), rendered from these SAME
|
|
137
|
+
* definitions via `renderCreateTableSql({ temp: true })`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function getSessionMetadataTables(): MetadataTables;
|
|
140
|
+
/**
|
|
141
|
+
* Select the durable or SESSION metadata tables (ADR-0042). `sessionScoped` groups (ephemeral retention)
|
|
142
|
+
* route their cursor + tag DML to the `pg_temp` variants; every other group keeps the durable tables. The
|
|
143
|
+
* engine learns one storage-scope bit, not the retention model.
|
|
144
|
+
*/
|
|
145
|
+
export declare function pickMetadataTables(metadataSchema: string, sessionScoped: boolean): MetadataTables;
|
|
130
146
|
export {};
|
|
131
147
|
//# sourceMappingURL=metadata-tables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-tables.d.ts","sourceRoot":"","sources":["../../src/sync/metadata-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAoB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;IAC9E,mFAAmF;IACnF,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAC7D;
|
|
1
|
+
{"version":3,"file":"metadata-tables.d.ts","sourceRoot":"","sources":["../../src/sync/metadata-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAoB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;IAC9E,mFAAmF;IACnF,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CAC7D;AAYD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQtE;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAa7D;AAID,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc,CAWxE;AAID;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CASzD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,cAAc,CAEjG"}
|
|
@@ -14,8 +14,14 @@ export interface GetSubscriptionStateOptions {
|
|
|
14
14
|
readonly pg: PGliteInterface | Transaction;
|
|
15
15
|
readonly metadataSchema: string;
|
|
16
16
|
readonly subscriptionKey: SubscriptionKey;
|
|
17
|
+
/**
|
|
18
|
+
* ADR-0042: read the SESSION (`pg_temp`) cursor instead of the durable one for an ephemeral group. On
|
|
19
|
+
* every engine boot the session table is empty, so a returning ephemeral group correctly reads `null`
|
|
20
|
+
* (a brand-new subscription) and re-streams its whole shape from scratch over the recreated TEMP cluster.
|
|
21
|
+
*/
|
|
22
|
+
readonly sessionScoped?: boolean;
|
|
17
23
|
}
|
|
18
|
-
export declare function getSubscriptionState({ pg, metadataSchema, subscriptionKey, }: GetSubscriptionStateOptions): Promise<SubscriptionState | null>;
|
|
24
|
+
export declare function getSubscriptionState({ pg, metadataSchema, subscriptionKey, sessionScoped, }: GetSubscriptionStateOptions): Promise<SubscriptionState | null>;
|
|
19
25
|
export interface UpdateSubscriptionStateOptions {
|
|
20
26
|
pg: PGliteInterface | Transaction;
|
|
21
27
|
metadataSchema: string;
|
|
@@ -23,8 +29,10 @@ export interface UpdateSubscriptionStateOptions {
|
|
|
23
29
|
shapeMetadata: Record<string, ShapeSubscriptionState>;
|
|
24
30
|
lastLsn: Lsn;
|
|
25
31
|
debug?: boolean;
|
|
32
|
+
/** ADR-0042: persist the cursor to the SESSION (`pg_temp`) table for an ephemeral group. */
|
|
33
|
+
sessionScoped?: boolean;
|
|
26
34
|
}
|
|
27
|
-
export declare function updateSubscriptionState({ pg, metadataSchema, subscriptionKey, shapeMetadata, lastLsn, debug, }: UpdateSubscriptionStateOptions): Promise<void>;
|
|
35
|
+
export declare function updateSubscriptionState({ pg, metadataSchema, subscriptionKey, shapeMetadata, lastLsn, debug, sessionScoped, }: UpdateSubscriptionStateOptions): Promise<void>;
|
|
28
36
|
export interface DeleteSubscriptionStateOptions {
|
|
29
37
|
pg: PGliteInterface | Transaction;
|
|
30
38
|
metadataSchema: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-state.d.ts","sourceRoot":"","sources":["../../src/sync/subscription-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQzE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,eAAe,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACvD,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,EAAE,EAAE,eAAe,GAAG,WAAW,CAAC;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription-state.d.ts","sourceRoot":"","sources":["../../src/sync/subscription-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQzE,OAAO,EAAE,KAAK,GAA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eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,8BAA8B,iBAUpH;AAED,MAAM,WAAW,wCAAwC;IACvD,EAAE,EAAE,eAAe,GAAG,WAAW,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,iCAAiC,CAAC,EACtD,EAAE,EACF,cAAc,GACf,EAAE,wCAAwC,iBAsB1C"}
|
package/dist/sync/tags.d.ts
CHANGED
|
@@ -43,6 +43,12 @@ export declare function assertValidMetadataSchema(metadataSchema: string): void;
|
|
|
43
43
|
* `migrateSubscriptionMetadataTables`, which renders that same pgTable.
|
|
44
44
|
*/
|
|
45
45
|
export declare function shapeRowTagsTableName(metadataSchema: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* The SESSION (`pg_temp`) tag store's qualified identifier (ADR-0042), derived from the session
|
|
48
|
+
* `shape_row_tags` pgTable config — the same relation name, in `pg_temp`. Used by the scope-blind
|
|
49
|
+
* {@link buildClearShapeTagsSql} so a desync/discard clears an ephemeral shape's tags wherever they live.
|
|
50
|
+
*/
|
|
51
|
+
export declare function shapeRowTagsSessionTableName(): string;
|
|
46
52
|
/** The `shape_table` key for the tag store: the synced table, schema-qualified (defaults `public`). */
|
|
47
53
|
export declare function shapeTableId(schema: string | undefined, table: string): string;
|
|
48
54
|
/**
|
|
@@ -84,6 +90,8 @@ interface TagSyncOptions {
|
|
|
84
90
|
shapeTable: string;
|
|
85
91
|
messages: ChangeMessage<Row<unknown>>[];
|
|
86
92
|
primaryKey: string[];
|
|
93
|
+
/** ADR-0042: route the tag DML to the SESSION (`pg_temp`) store for an ephemeral group. */
|
|
94
|
+
sessionScoped?: boolean;
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
89
97
|
* Maintain the tag-set for a shape from its drained change batch (ADR-0023). For a subquery shape every
|
|
@@ -92,7 +100,7 @@ interface TagSyncOptions {
|
|
|
92
100
|
* shape carries no `tags`, so this is a no-op for it. Runs before the data apply and the move-out
|
|
93
101
|
* eviction in the same commit, so an add-then-remove within one batch resolves correctly.
|
|
94
102
|
*/
|
|
95
|
-
export declare function applyShapeTagSync({ pg, metadataSchema, shapeTable, messages, primaryKey, }: TagSyncOptions): Promise<void>;
|
|
103
|
+
export declare function applyShapeTagSync({ pg, metadataSchema, shapeTable, messages, primaryKey, sessionScoped, }: TagSyncOptions): Promise<void>;
|
|
96
104
|
/**
|
|
97
105
|
* Record (union) a **move-in** row's tags without clearing the tags the row already carries (ADR-0024).
|
|
98
106
|
* A move-in ADDS a reason a row is in the shape, so — unlike a regular change, whose `tags` is the
|
|
@@ -102,7 +110,7 @@ export declare function applyShapeTagSync({ pg, metadataSchema, shapeTable, mess
|
|
|
102
110
|
* eviction afterwards stays correct under multi-grant without depending on the move-in's tag cardinality.
|
|
103
111
|
* A row with no `tags` (a non-subquery shape) is a no-op.
|
|
104
112
|
*/
|
|
105
|
-
export declare function addShapeRowTags({ pg, metadataSchema, shapeTable, messages, primaryKey, }: TagSyncOptions): Promise<void>;
|
|
113
|
+
export declare function addShapeRowTags({ pg, metadataSchema, shapeTable, messages, primaryKey, sessionScoped, }: TagSyncOptions): Promise<void>;
|
|
106
114
|
interface MoveOutOptions {
|
|
107
115
|
pg: PGliteInterface | Transaction;
|
|
108
116
|
metadataSchema: string;
|
|
@@ -112,6 +120,8 @@ interface MoveOutOptions {
|
|
|
112
120
|
/** One entry per buffered `move-out` event, each its own pattern set. */
|
|
113
121
|
patternSets: MovePattern[][];
|
|
114
122
|
debug: boolean;
|
|
123
|
+
/** ADR-0042: route the tag reads/evictions to the SESSION (`pg_temp`) store for an ephemeral group. */
|
|
124
|
+
sessionScoped?: boolean;
|
|
115
125
|
}
|
|
116
126
|
/**
|
|
117
127
|
* Apply buffered `move-out` events for a shape (ADR-0023): withdraw the matched tag from every row that
|
|
@@ -119,12 +129,14 @@ interface MoveOutOptions {
|
|
|
119
129
|
* survives losing one. Eviction goes through the tested bulk-delete path, so it fires the reconcile
|
|
120
130
|
* trigger and the read-model/overlay stays consistent. Returns the number of rows evicted.
|
|
121
131
|
*/
|
|
122
|
-
export declare function applyShapeMoveOut({ pg, metadataSchema, shapeTable, target, patternSets, debug, }: MoveOutOptions): Promise<number>;
|
|
132
|
+
export declare function applyShapeMoveOut({ pg, metadataSchema, shapeTable, target, patternSets, debug, sessionScoped, }: MoveOutOptions): Promise<number>;
|
|
123
133
|
/** Drop a shape's entire tag-set — for a `must-refetch`/read-cache rebuild, before the re-snapshot (ADR-0023 Slice 2). */
|
|
124
|
-
export declare function clearShapeTags({ pg, metadataSchema, shapeTable, }: {
|
|
134
|
+
export declare function clearShapeTags({ pg, metadataSchema, shapeTable, sessionScoped, }: {
|
|
125
135
|
pg: PGliteInterface | Transaction;
|
|
126
136
|
metadataSchema: string;
|
|
127
137
|
shapeTable: string;
|
|
138
|
+
/** ADR-0042: clear the SESSION (`pg_temp`) tag store for an ephemeral group's must-refetch rebuild. */
|
|
139
|
+
sessionScoped?: boolean;
|
|
128
140
|
}): Promise<void>;
|
|
129
141
|
export {};
|
|
130
142
|
//# sourceMappingURL=tags.d.ts.map
|
package/dist/sync/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/sync/tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAQnD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,IAA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AAU,EACV,MAAM,EACN,WAAW,EACX,KAAK,EACL,aAAqB,GACtB,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ElC;AAED,0HAA0H;AAC1H,wBAAsB,cAAc,CAAC,EACnC,EAAE,EACF,cAAc,EACd,UAAU,EACV,aAAqB,GACtB,EAAE;IACD,EAAE,EAAE,eAAe,GAAG,WAAW,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,uGAAuG;IACvG,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhB"}
|
package/dist/sync/types.d.ts
CHANGED
|
@@ -38,6 +38,16 @@ export interface SyncShapesToTablesOptions {
|
|
|
38
38
|
/** The engine's per-table spec source (ADR-0029 D1): every shape's `tableKey` resolves against it. */
|
|
39
39
|
registry: SyncTableRegistry;
|
|
40
40
|
shapes: Record<string, ShapeToTableOptions>;
|
|
41
|
+
/**
|
|
42
|
+
* ADR-0042: this group's sync bookkeeping (subscription cursor + tagged-subquery reason sets) is
|
|
43
|
+
* SESSION-scoped — stored in the engine's `pg_temp` metadata relations that die with the engine, not the
|
|
44
|
+
* durable ones. Set for an `ephemeral`-retention group, whose whole cluster is already TEMP: the cursor
|
|
45
|
+
* and tags then die with the rows they index, so a returning engine re-streams the shape from scratch
|
|
46
|
+
* instead of resuming a stale durable cursor over a recreated-empty TEMP cluster. Default `false` — every
|
|
47
|
+
* persistent group's storage is byte-identical to before. One storage-scope bit; the engine never learns
|
|
48
|
+
* the retention model.
|
|
49
|
+
*/
|
|
50
|
+
sessionScoped?: boolean | undefined;
|
|
41
51
|
initialInsertMethod?: InitialInsertMethod | undefined;
|
|
42
52
|
onInitialSync?: (() => void) | undefined;
|
|
43
53
|
/**
|
|
@@ -98,6 +108,8 @@ export interface SyncShapeToTableOptions {
|
|
|
98
108
|
registry: SyncTableRegistry;
|
|
99
109
|
tableKey: string;
|
|
100
110
|
shapeKey: string | null;
|
|
111
|
+
/** ADR-0042: SESSION-scope this shape's cursor + tags (ephemeral retention); see {@link SyncShapesToTablesOptions.sessionScoped}. */
|
|
112
|
+
sessionScoped?: boolean | undefined;
|
|
101
113
|
initialInsertMethod?: InitialInsertMethod | undefined;
|
|
102
114
|
onInitialSync?: (() => void) | undefined;
|
|
103
115
|
onError?: ((error: FetchError | Error) => void) | undefined;
|
package/dist/sync/types.d.ts.map
CHANGED
|
@@ -1 +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;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD,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,CA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-1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgxsinkit/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
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.51"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@electric-sql/pglite": "0.5.4",
|
package/skills/core/SKILL.md
CHANGED
package/src/schema.ts
CHANGED
|
@@ -545,18 +545,36 @@ function buildTableColumnSql(columns: TableColumn[], primaryKeyColumns: string[]
|
|
|
545
545
|
* ADR-0029 D3: the metadata-store DDL renders from its `metadata-tables.ts` pgTables through this,
|
|
546
546
|
* making the pgTable the single source. The OUTPUT is tier-③-by-nature runtime DDL (schema/table
|
|
547
547
|
* identifiers assembled at construction), but it is GENERATED from the model, never hand-maintained.
|
|
548
|
+
*
|
|
549
|
+
* ADR-0042: `{ temp: true }` renders the SESSION variant — `CREATE TEMP TABLE IF NOT EXISTS <bare name>`
|
|
550
|
+
* (+ each index `ON <bare name>`), IGNORING the pgTable's declared schema for the RELATION name. TEMP DDL
|
|
551
|
+
* takes the UNqualified relation name (the TEMP keyword places it in `pg_temp`; a `CREATE TEMP TABLE
|
|
552
|
+
* pg_temp.x` target is not portable). Same relation/index NAMES as the durable form: an index name lives
|
|
553
|
+
* per schema, so the durable (metadata-schema) and session (`pg_temp`) indexes coexist without collision
|
|
554
|
+
* (probed on real PGlite).
|
|
555
|
+
*
|
|
556
|
+
* CAVEAT — the `temp` flag only bares the RELATION name; `buildTableColumnSql` below still receives
|
|
557
|
+
* `schemaName` and would qualify any ENUM column type into THAT schema. That is correct only because the
|
|
558
|
+
* metadata pgTables (the sole callers of `{ temp: true }`) carry no enum columns. A future enum-bearing TEMP
|
|
559
|
+
* render would emit `<metadataSchema>.<enum>` for the column type — which is exactly what we want (enums are
|
|
560
|
+
* persistent DB objects living in the durable schema even for TEMP tables, ADR-0021 §3), NOT a `pg_temp`
|
|
561
|
+
* qualification. If this path ever renders a TEMP relation with an enum, keep the enum durable-qualified;
|
|
562
|
+
* do not fold the `temp` flag into the column-type schema.
|
|
548
563
|
*/
|
|
549
|
-
export function renderCreateTableSql(table: AnyPgTable): string[] {
|
|
564
|
+
export function renderCreateTableSql(table: AnyPgTable, options: { temp?: boolean } = {}): string[] {
|
|
550
565
|
const config = getTableConfig(table);
|
|
566
|
+
const temp = options.temp === true;
|
|
551
567
|
const schemaName = config.schema ?? "public";
|
|
552
|
-
|
|
568
|
+
// The DML paths qualify the session tables into `pg_temp`; the DDL must NOT — see the doc comment.
|
|
569
|
+
const tableRef = temp ? maybeQuoteIdentifier(config.name) : qualifyIdentifier(schemaName, config.name);
|
|
553
570
|
const primaryKeyColumns = collectPgTablePrimaryKeyColumns(config);
|
|
554
571
|
const columnSql = buildTableColumnSql(config.columns as unknown as TableColumn[], primaryKeyColumns, schemaName);
|
|
555
572
|
|
|
556
|
-
const
|
|
573
|
+
const createKeyword = temp ? "CREATE TEMP TABLE" : "CREATE TABLE";
|
|
574
|
+
const statements = [`${createKeyword} IF NOT EXISTS ${tableRef} (\n ${columnSql}\n);`];
|
|
557
575
|
|
|
558
576
|
for (const index of config.indexes) {
|
|
559
|
-
statements.push(renderCreateIndexSql(
|
|
577
|
+
statements.push(renderCreateIndexSql(tableRef, index));
|
|
560
578
|
}
|
|
561
579
|
|
|
562
580
|
return statements;
|
package/src/shape-sync.ts
CHANGED
|
@@ -296,6 +296,10 @@ export async function startConfiguredSync(
|
|
|
296
296
|
groupKey: group.groupKey,
|
|
297
297
|
specs: group.specs,
|
|
298
298
|
registry: input.registry,
|
|
299
|
+
// ADR-0042: an ephemeral group's cursor + tags are session-scoped (stored in `pg_temp`), so a warm
|
|
300
|
+
// engine restart re-streams the shape from scratch rather than resuming a stale durable cursor over
|
|
301
|
+
// the recreated-empty TEMP cluster. The engine learns only this one storage-scope bit.
|
|
302
|
+
...(group.retention === "ephemeral" ? { sessionScoped: true } : {}),
|
|
299
303
|
...(bootStamp ? { bootStamp } : {}),
|
|
300
304
|
// The prefetch overlap (ADR-0032 S4) applies ONLY to the eager BOOT starts: a fresh store's eager
|
|
301
305
|
// groups are genuinely new, so buffering their catch-up behind the commit gate is safe. An on-demand
|
|
@@ -400,6 +404,12 @@ interface StartGroupSyncOptions {
|
|
|
400
404
|
groupKey: string;
|
|
401
405
|
specs: ConfiguredShapeSyncSpec[];
|
|
402
406
|
registry: SyncTableRegistry;
|
|
407
|
+
/**
|
|
408
|
+
* ADR-0042: the group's retention is `ephemeral`, so its sync bookkeeping (cursor + tags) is session-
|
|
409
|
+
* scoped — the engine stores it in `pg_temp` relations that die with the engine. Forwarded straight to
|
|
410
|
+
* the engine's `syncShapesToTables`; absent/`false` for a persistent group (byte-identical storage).
|
|
411
|
+
*/
|
|
412
|
+
sessionScoped?: boolean;
|
|
403
413
|
headers?: ExternalHeadersRecord;
|
|
404
414
|
/** Fresh-store prefetch overlap gate (ADR-0032 S4) — forwarded to the engine's `syncShapesToTables`. */
|
|
405
415
|
dbReady?: Promise<void>;
|
|
@@ -450,6 +460,7 @@ export async function startGroupSync(pg: SyncEnginePGlite, input: StartGroupSync
|
|
|
450
460
|
key: input.groupKey,
|
|
451
461
|
registry: input.registry,
|
|
452
462
|
shapes,
|
|
463
|
+
...(input.sessionScoped ? { sessionScoped: input.sessionScoped } : {}),
|
|
453
464
|
...(input.dbReady ? { dbReady: input.dbReady } : {}),
|
|
454
465
|
...(input.bootStamp ? { bootStamp: input.bootStamp } : {}),
|
|
455
466
|
...(input.onGroupInitialSync ? { onInitialSync: input.onGroupInitialSync } : {}),
|
package/src/sync/index.ts
CHANGED
|
@@ -163,6 +163,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
163
163
|
key,
|
|
164
164
|
registry,
|
|
165
165
|
shapes,
|
|
166
|
+
sessionScoped = false,
|
|
166
167
|
initialInsertMethod,
|
|
167
168
|
onInitialSync,
|
|
168
169
|
onError,
|
|
@@ -224,6 +225,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
224
225
|
pg,
|
|
225
226
|
metadataSchema,
|
|
226
227
|
subscriptionKey: key,
|
|
228
|
+
sessionScoped,
|
|
227
229
|
});
|
|
228
230
|
if (debug && subState) {
|
|
229
231
|
console.log("resuming from subscription state", subState);
|
|
@@ -436,7 +438,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
436
438
|
}
|
|
437
439
|
// The re-snapshot rebuilds tags from scratch, so drop this shape's stale tag-set too
|
|
438
440
|
// (ADR-0023 Slice 2: a must-refetch/rebuild must not leave orphan tags).
|
|
439
|
-
await clearShapeTags({ pg: tx, metadataSchema, shapeTable });
|
|
441
|
+
await clearShapeTags({ pg: tx, metadataSchema, shapeTable, sessionScoped });
|
|
440
442
|
}
|
|
441
443
|
|
|
442
444
|
// ADR-0024: this shape's buffered move-in snapshot rows (a row ENTERING the shape). Their
|
|
@@ -451,6 +453,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
451
453
|
shapeTable,
|
|
452
454
|
messages: moveInMessages,
|
|
453
455
|
primaryKey: target.primaryKey,
|
|
456
|
+
sessionScoped,
|
|
454
457
|
});
|
|
455
458
|
}
|
|
456
459
|
|
|
@@ -463,6 +466,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
463
466
|
shapeTable,
|
|
464
467
|
messages: initialMessages,
|
|
465
468
|
primaryKey: target.primaryKey,
|
|
469
|
+
sessionScoped,
|
|
466
470
|
});
|
|
467
471
|
|
|
468
472
|
// ADR-0024: apply the move-in rows idempotently BEFORE the change fold, so a same-commit
|
|
@@ -567,6 +571,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
567
571
|
target,
|
|
568
572
|
patternSets,
|
|
569
573
|
debug,
|
|
574
|
+
sessionScoped,
|
|
570
575
|
});
|
|
571
576
|
}
|
|
572
577
|
}
|
|
@@ -576,6 +581,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
576
581
|
pg: tx,
|
|
577
582
|
metadataSchema,
|
|
578
583
|
subscriptionKey: key,
|
|
584
|
+
sessionScoped,
|
|
579
585
|
shapeMetadata: Object.fromEntries(
|
|
580
586
|
Object.keys(shapes).map((shapeName) => {
|
|
581
587
|
const stream = getShapeStream(shapeName);
|
|
@@ -1024,6 +1030,7 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
1024
1030
|
},
|
|
1025
1031
|
},
|
|
1026
1032
|
key: options.shapeKey,
|
|
1033
|
+
...(options.sessionScoped ? { sessionScoped: options.sessionScoped } : {}),
|
|
1027
1034
|
onInitialSync: options.onInitialSync,
|
|
1028
1035
|
onError: options.onError,
|
|
1029
1036
|
onSyncError: options.onSyncError,
|
|
@@ -1047,6 +1054,12 @@ export async function createSyncEngine(pg: PGliteInterface, options?: ElectricSy
|
|
|
1047
1054
|
};
|
|
1048
1055
|
|
|
1049
1056
|
const deleteSubscription = async (key: string) => {
|
|
1057
|
+
// ADR-0042: the scope-blind delete now also touches `pg_temp.subscriptions_metadata`, which does NOT
|
|
1058
|
+
// exist until the (per-engine, memoized) metadata migration has run — so a warm-store reset that fires
|
|
1059
|
+
// before any group started (nothing else triggered `initMetadataTables` yet) would hit 42P01. Ensure the
|
|
1060
|
+
// provisioning first; the promise is memoized/idempotent, so on the normal path (a group already
|
|
1061
|
+
// started) this is a no-op await on the resolved init promise.
|
|
1062
|
+
await initMetadataTables();
|
|
1050
1063
|
await deleteSubscriptionState({
|
|
1051
1064
|
pg,
|
|
1052
1065
|
metadataSchema,
|
|
@@ -25,6 +25,16 @@ export interface MetadataTables {
|
|
|
25
25
|
readonly shapeRowTags: ReturnType<typeof buildShapeRowTags>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The `pg_temp` schema name the SESSION metadata variants are built under (ADR-0042). An ephemeral
|
|
30
|
+
* group's sync bookkeeping (cursor + tags) is scoped to the engine session by placing it in `pg_temp`
|
|
31
|
+
* relations that die with the engine — the cursor's lifetime is mechanically tied to the TEMP cluster
|
|
32
|
+
* whose rows it indexes. `pg_temp` is a per-session alias Postgres accepts in DML qualification (probed
|
|
33
|
+
* on real PGlite), so the DML paths select these objects unchanged. Same relation NAMES as the durable
|
|
34
|
+
* variants, distinguished by schema alone (maintainer ruling).
|
|
35
|
+
*/
|
|
36
|
+
const SESSION_METADATA_SCHEMA = "pg_temp";
|
|
37
|
+
|
|
28
38
|
function buildSubscriptionsMetadata(schema: ReturnType<typeof pgSchema>) {
|
|
29
39
|
return schema.table("subscriptions_metadata", {
|
|
30
40
|
key: text("key").primaryKey(),
|
|
@@ -65,3 +75,34 @@ export function getMetadataTables(metadataSchema: string): MetadataTables {
|
|
|
65
75
|
}
|
|
66
76
|
return tables;
|
|
67
77
|
}
|
|
78
|
+
|
|
79
|
+
let sessionCache: MetadataTables | undefined;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The (memoized) SESSION metadata-store `pgTable`s (ADR-0042) — the same relation names as the durable
|
|
83
|
+
* variants, built from the SAME column builders (ADR-0029 D3 single-source), but schema-qualified into
|
|
84
|
+
* `pg_temp` so the DML lands in the engine's session-scoped TEMP relations. No schema parameter: `pg_temp`
|
|
85
|
+
* is per-engine by construction, so a single memoized singleton serves every engine. The DDL that
|
|
86
|
+
* PROVISIONS these tables uses the unqualified `CREATE TEMP TABLE` form (the TEMP keyword places the
|
|
87
|
+
* relation in the session schema; a `pg_temp.x` DDL target is not portable), rendered from these SAME
|
|
88
|
+
* definitions via `renderCreateTableSql({ temp: true })`.
|
|
89
|
+
*/
|
|
90
|
+
export function getSessionMetadataTables(): MetadataTables {
|
|
91
|
+
if (!sessionCache) {
|
|
92
|
+
const schema = pgSchema(SESSION_METADATA_SCHEMA);
|
|
93
|
+
sessionCache = {
|
|
94
|
+
subscriptionsMetadata: buildSubscriptionsMetadata(schema),
|
|
95
|
+
shapeRowTags: buildShapeRowTags(schema),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return sessionCache;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Select the durable or SESSION metadata tables (ADR-0042). `sessionScoped` groups (ephemeral retention)
|
|
103
|
+
* route their cursor + tag DML to the `pg_temp` variants; every other group keeps the durable tables. The
|
|
104
|
+
* engine learns one storage-scope bit, not the retention model.
|
|
105
|
+
*/
|
|
106
|
+
export function pickMetadataTables(metadataSchema: string, sessionScoped: boolean): MetadataTables {
|
|
107
|
+
return sessionScoped ? getSessionMetadataTables() : getMetadataTables(metadataSchema);
|
|
108
|
+
}
|
|
@@ -8,7 +8,7 @@ import { quoteIdentifier } from "@pgxsinkit/contracts";
|
|
|
8
8
|
|
|
9
9
|
import { renderCreateTableSql } from "../schema";
|
|
10
10
|
import { drizzleOverPg } from "./drizzle-executor";
|
|
11
|
-
import { getMetadataTables } from "./metadata-tables";
|
|
11
|
+
import { getMetadataTables, getSessionMetadataTables, pickMetadataTables } from "./metadata-tables";
|
|
12
12
|
import { type Lsn, type SubscriptionKey } from "./types";
|
|
13
13
|
|
|
14
14
|
export interface SubscriptionState {
|
|
@@ -26,14 +26,21 @@ export interface GetSubscriptionStateOptions {
|
|
|
26
26
|
readonly pg: PGliteInterface | Transaction;
|
|
27
27
|
readonly metadataSchema: string;
|
|
28
28
|
readonly subscriptionKey: SubscriptionKey;
|
|
29
|
+
/**
|
|
30
|
+
* ADR-0042: read the SESSION (`pg_temp`) cursor instead of the durable one for an ephemeral group. On
|
|
31
|
+
* every engine boot the session table is empty, so a returning ephemeral group correctly reads `null`
|
|
32
|
+
* (a brand-new subscription) and re-streams its whole shape from scratch over the recreated TEMP cluster.
|
|
33
|
+
*/
|
|
34
|
+
readonly sessionScoped?: boolean;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export async function getSubscriptionState({
|
|
32
38
|
pg,
|
|
33
39
|
metadataSchema,
|
|
34
40
|
subscriptionKey,
|
|
41
|
+
sessionScoped = false,
|
|
35
42
|
}: GetSubscriptionStateOptions): Promise<SubscriptionState | null> {
|
|
36
|
-
const { subscriptionsMetadata } =
|
|
43
|
+
const { subscriptionsMetadata } = pickMetadataTables(metadataSchema, sessionScoped);
|
|
37
44
|
const rows = await drizzleOverPg(pg)
|
|
38
45
|
.select()
|
|
39
46
|
.from(subscriptionsMetadata)
|
|
@@ -74,6 +81,8 @@ export interface UpdateSubscriptionStateOptions {
|
|
|
74
81
|
shapeMetadata: Record<string, ShapeSubscriptionState>;
|
|
75
82
|
lastLsn: Lsn;
|
|
76
83
|
debug?: boolean;
|
|
84
|
+
/** ADR-0042: persist the cursor to the SESSION (`pg_temp`) table for an ephemeral group. */
|
|
85
|
+
sessionScoped?: boolean;
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
export async function updateSubscriptionState({
|
|
@@ -83,12 +92,13 @@ export async function updateSubscriptionState({
|
|
|
83
92
|
shapeMetadata,
|
|
84
93
|
lastLsn,
|
|
85
94
|
debug,
|
|
95
|
+
sessionScoped = false,
|
|
86
96
|
}: UpdateSubscriptionStateOptions) {
|
|
87
97
|
if (debug) {
|
|
88
98
|
console.log("updating subscription state", subscriptionKey, shapeMetadata, lastLsn);
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
const { subscriptionsMetadata } =
|
|
101
|
+
const { subscriptionsMetadata } = pickMetadataTables(metadataSchema, sessionScoped);
|
|
92
102
|
const lastLsnText = lastLsn.toString();
|
|
93
103
|
await drizzleOverPg(pg)
|
|
94
104
|
.insert(subscriptionsMetadata)
|
|
@@ -106,8 +116,15 @@ export interface DeleteSubscriptionStateOptions {
|
|
|
106
116
|
}
|
|
107
117
|
|
|
108
118
|
export async function deleteSubscriptionState({ pg, metadataSchema, subscriptionKey }: DeleteSubscriptionStateOptions) {
|
|
119
|
+
// ADR-0042: SCOPE-BLIND delete — remove the key from BOTH the durable and the session (`pg_temp`) cursor
|
|
120
|
+
// tables. Idempotent (a `WHERE key = …` no-op on the table that never held it), so every existing caller —
|
|
121
|
+
// `desync`, `discardEphemeral`, the `"rebuilt"` all-keys reset — clears both with zero caller changes, and
|
|
122
|
+
// a persistent→ephemeral flip leaves no orphaned durable cursor row behind.
|
|
123
|
+
const db = drizzleOverPg(pg);
|
|
109
124
|
const { subscriptionsMetadata } = getMetadataTables(metadataSchema);
|
|
110
|
-
|
|
125
|
+
const session = getSessionMetadataTables();
|
|
126
|
+
await db.delete(subscriptionsMetadata).where(eq(subscriptionsMetadata.key, subscriptionKey));
|
|
127
|
+
await db.delete(session.subscriptionsMetadata).where(eq(session.subscriptionsMetadata.key, subscriptionKey));
|
|
111
128
|
}
|
|
112
129
|
|
|
113
130
|
export interface MigrateSubscriptionMetadataTablesOptions {
|
|
@@ -125,11 +142,19 @@ export async function migrateSubscriptionMetadataTables({
|
|
|
125
142
|
// (schema identifier assembled at construction; the GUC has no tier-①/② form). Executed together as
|
|
126
143
|
// one batch, exactly as before — same relations, same IF NOT EXISTS idempotence, same GUC default.
|
|
127
144
|
const { subscriptionsMetadata, shapeRowTags } = getMetadataTables(metadataSchema);
|
|
145
|
+
// ADR-0042: alongside the durable relations, provision the SESSION (`pg_temp`) cursor + tag tables in the
|
|
146
|
+
// SAME migrate step (once per engine, memoized by the caller). Their DDL is the unqualified `CREATE TEMP
|
|
147
|
+
// TABLE` form rendered from the same session pgTables (single-source, ADR-0029 D3) — the TEMP keyword
|
|
148
|
+
// places them in `pg_temp` where the DML (schema-qualified `pg_temp.*`) reads/writes them. They die with
|
|
149
|
+
// the engine, so an ephemeral group's cursor lifetime is mechanically tied to the TEMP cluster it indexes.
|
|
150
|
+
const session = getSessionMetadataTables();
|
|
128
151
|
const statements = [
|
|
129
152
|
`SET ${metadataSchema}.syncing = false;`,
|
|
130
153
|
`CREATE SCHEMA IF NOT EXISTS ${quoteIdentifier(metadataSchema)};`,
|
|
131
154
|
...renderCreateTableSql(subscriptionsMetadata),
|
|
132
155
|
...renderCreateTableSql(shapeRowTags),
|
|
156
|
+
...renderCreateTableSql(session.subscriptionsMetadata, { temp: true }),
|
|
157
|
+
...renderCreateTableSql(session.shapeRowTags, { temp: true }),
|
|
133
158
|
];
|
|
134
159
|
await pg.exec(statements.join("\n"));
|
|
135
160
|
}
|