@pgxsinkit/contracts 0.2.7 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/apply-strategy.d.ts +13 -1
- package/dist/apply-strategy.d.ts.map +1 -1
- package/dist/config.d.ts +256 -87
- package/dist/config.d.ts.map +1 -1
- package/dist/convergence-model.d.ts +2 -2
- package/dist/convergence-model.d.ts.map +1 -1
- package/dist/event-stream.d.ts +1 -1
- package/dist/fingerprint.d.ts +31 -11
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +480 -202
- package/dist/index.js.map +16 -14
- package/dist/predicate.d.ts +162 -0
- package/dist/predicate.d.ts.map +1 -0
- package/dist/projection.d.ts +2 -2
- package/dist/projection.d.ts.map +1 -1
- package/dist/registry-diff.d.ts.map +1 -1
- package/dist/registry-invariant.d.ts +26 -14
- package/dist/registry-invariant.d.ts.map +1 -1
- package/dist/registry.d.ts +74 -48
- package/dist/registry.d.ts.map +1 -1
- package/dist/sql-role-guard.d.ts +1 -1
- package/dist/stream-envelope.d.ts +84 -0
- package/dist/stream-envelope.d.ts.map +1 -0
- package/dist/supabase-rls.d.ts +32 -36
- package/dist/supabase-rls.d.ts.map +1 -1
- package/package.json +3 -2
- package/skills/registry-authoring/SKILL.md +185 -185
- package/skills/registry-authoring/references/storage-engine-and-build.md +29 -0
- package/src/apply-strategy.ts +23 -4
- package/src/config.ts +340 -116
- package/src/convergence-model.ts +2 -2
- package/src/event-stream.ts +1 -1
- package/src/fingerprint.ts +76 -14
- package/src/index.ts +2 -0
- package/src/predicate.ts +274 -0
- package/src/projection.ts +6 -2
- package/src/registry-diff.ts +15 -4
- package/src/registry-invariant.ts +34 -19
- package/src/registry.ts +324 -78
- package/src/sql-role-guard.ts +1 -1
- package/src/stream-envelope.ts +91 -0
- package/src/supabase-rls.ts +76 -74
package/dist/fingerprint.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import type { SyncTableEntry, SyncTableRegistry } from "./registry";
|
|
|
5
5
|
*
|
|
6
6
|
* This is the single source of "has the shape changed" — consumed as the local-DB
|
|
7
7
|
* version key and as the basis of the registry-diff gate (ADR-0006). Function *bodies*
|
|
8
|
-
* (`rowTransform`, `
|
|
8
|
+
* (`rowTransform`, `customPredicate`) cannot be fingerprinted and are excluded — but their
|
|
9
9
|
* *presence* and the surrounding **static** filter structure (the projected columns)
|
|
10
10
|
* participate. For the invisible *logic* itself, a consumer-bumped `rowFilter.revision` is
|
|
11
|
-
* folded in: changing it is how a `
|
|
11
|
+
* folded in: changing it is how a `customPredicate` authorization change is forced to shift the
|
|
12
12
|
* fingerprint (and so rebuild the cache + reset the subscription).
|
|
13
13
|
*/
|
|
14
14
|
export interface CanonicalColumn {
|
|
@@ -33,8 +33,18 @@ export interface CanonicalTable {
|
|
|
33
33
|
shape: {
|
|
34
34
|
tableName: string;
|
|
35
35
|
shapeKey: string;
|
|
36
|
-
|
|
36
|
+
physicalTable: string | null;
|
|
37
37
|
rowFilter: CanonicalRowFilter | null;
|
|
38
|
+
/** Shared-tier scope columns, in declaration order — the order parameterizes the family. */
|
|
39
|
+
scope: string[] | null;
|
|
40
|
+
/**
|
|
41
|
+
* The native static predicate, canonicalized in full.
|
|
42
|
+
*
|
|
43
|
+
* Unlike `customPredicate`, this one is *visible*: an AST can be hashed, where a closure could only
|
|
44
|
+
* ever be fingerprinted by its presence. So the `revision` footgun does not apply here — editing
|
|
45
|
+
* a native `where` shifts the fingerprint by itself, and a consumer cannot forget to say so.
|
|
46
|
+
*/
|
|
47
|
+
where: string | null;
|
|
38
48
|
} | null;
|
|
39
49
|
managedFields: Array<{
|
|
40
50
|
field: string;
|
|
@@ -58,16 +68,16 @@ export interface CanonicalTable {
|
|
|
58
68
|
}
|
|
59
69
|
/**
|
|
60
70
|
* The static, fingerprint-able structure of a row filter. A changed projection shifts the
|
|
61
|
-
* fingerprint, so the local store rebuilds and the diff gate flags it. `
|
|
62
|
-
* invisible — only its presence (`
|
|
71
|
+
* fingerprint, so the local store rebuilds and the diff gate flags it. `customPredicate`'s body is
|
|
72
|
+
* invisible — only its presence (`hasCustomPredicate`) is recorded — so a `customPredicate` *logic* change
|
|
63
73
|
* is surfaced only by bumping `revision`.
|
|
64
74
|
*/
|
|
65
75
|
export interface CanonicalRowFilter {
|
|
66
|
-
|
|
76
|
+
hasCustomPredicate: boolean;
|
|
67
77
|
columns: string[] | null;
|
|
68
78
|
/**
|
|
69
|
-
* The consumer-supplied version tag for the non-fingerprintable filter logic (the `
|
|
70
|
-
* body). Changing it shifts the fingerprint, which is the only way a `
|
|
79
|
+
* The consumer-supplied version tag for the non-fingerprintable filter logic (the `customPredicate`
|
|
80
|
+
* body). Changing it shifts the fingerprint, which is the only way a `customPredicate` *logic* change
|
|
71
81
|
* forces a cache + subscription reset.
|
|
72
82
|
*/
|
|
73
83
|
revision: string | null;
|
|
@@ -89,7 +99,7 @@ export declare function fingerprintRegistry(registry: SyncTableRegistry): string
|
|
|
89
99
|
/**
|
|
90
100
|
* The **read contract** of a single sync table: the subset of its canonical shape that decides what
|
|
91
101
|
* data streams down and how a row is identified and filtered — synced-table name, columns, primary key
|
|
92
|
-
* (and any local-PK override), column omission, and the shape (
|
|
102
|
+
* (and any local-PK override), column omission, and the shape (physical table + row filter). It is the
|
|
93
103
|
* stable identity a writable entry shares with its {@link asReadonly} projection.
|
|
94
104
|
*
|
|
95
105
|
* Deliberately EXCLUDES the two axes a per-client projection may legitimately differ on:
|
|
@@ -100,7 +110,7 @@ export declare function fingerprintRegistry(registry: SyncTableRegistry): string
|
|
|
100
110
|
*
|
|
101
111
|
* What it pins is the data itself: two registries that present "the same" logical table to different
|
|
102
112
|
* clients must agree here, or those clients are silently seeing different rows/columns. As with the
|
|
103
|
-
* full registry fingerprint, the `
|
|
113
|
+
* full registry fingerprint, the `customPredicate` *body* is invisible — only its presence and the
|
|
104
114
|
* consumer-bumped {@link RowFilterSpec.revision} participate, so bump `revision` to force a divergence
|
|
105
115
|
* a logic-only change would otherwise hide.
|
|
106
116
|
*/
|
|
@@ -113,8 +123,18 @@ export interface CanonicalReadContract {
|
|
|
113
123
|
shape: {
|
|
114
124
|
tableName: string;
|
|
115
125
|
shapeKey: string;
|
|
116
|
-
|
|
126
|
+
physicalTable: string | null;
|
|
117
127
|
rowFilter: CanonicalRowFilter | null;
|
|
128
|
+
/** Shared-tier scope columns, in declaration order — the order parameterizes the family. */
|
|
129
|
+
scope: string[] | null;
|
|
130
|
+
/**
|
|
131
|
+
* The native static predicate, canonicalized in full.
|
|
132
|
+
*
|
|
133
|
+
* Unlike `customPredicate`, this one is *visible*: an AST can be hashed, where a closure could only
|
|
134
|
+
* ever be fingerprinted by its presence. So the `revision` footgun does not apply here — editing
|
|
135
|
+
* a native `where` shifts the fingerprint by itself, and a consumer cannot forget to say so.
|
|
136
|
+
*/
|
|
137
|
+
where: string | null;
|
|
118
138
|
} | null;
|
|
119
139
|
}
|
|
120
140
|
/** The canonical {@link CanonicalReadContract} of a sync table entry (see the interface for what it omits). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM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AE,iBAAiB,GAAG,MAAM,CAE3E;AAcD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAMvE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;QACrC,4FAA4F;QAC5F,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACvB;;;;;;WAMG;QACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,GAAG,IAAI,CAAC;CACV;AAED,+GAA+G;AAC/G,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,cAAc,GAAG,qBAAqB,CAsBrF;AAED,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBhD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ export * from "./registry";
|
|
|
9
9
|
export * from "./registry-diff";
|
|
10
10
|
export * from "./registry-invariant";
|
|
11
11
|
export * from "./mutation";
|
|
12
|
+
export * from "./predicate";
|
|
12
13
|
export * from "./projection";
|
|
13
14
|
export * from "./runtime";
|
|
14
15
|
export * from "./sql-defaults";
|
|
16
|
+
export * from "./stream-envelope";
|
|
15
17
|
export * from "./sql-identifier";
|
|
16
18
|
export * from "./sql-role-guard";
|
|
17
19
|
export * from "./supabase-rls";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|