@kairos-es/store-postgres 1.0.0-alpha.2 → 1.0.0-alpha.4
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/README.md +13 -5
- package/dist/cjs/ensureSchema.js +6 -1
- package/dist/cjs/ensureSchema.js.map +1 -1
- package/dist/cjs/internal/ddl.js +29 -12
- package/dist/cjs/internal/ddl.js.map +1 -1
- package/dist/cjs/internal/matchSql.js +46 -4
- package/dist/cjs/internal/matchSql.js.map +1 -1
- package/dist/cjs/internal/readPlan.js +8 -4
- package/dist/cjs/internal/readPlan.js.map +1 -1
- package/dist/cjs/internal/transport.js +27 -4
- package/dist/cjs/internal/transport.js.map +1 -1
- package/dist/cjs/store.js.map +1 -1
- package/dist/dts/ensureSchema.d.ts +6 -1
- package/dist/dts/ensureSchema.d.ts.map +1 -1
- package/dist/dts/internal/ddl.d.ts.map +1 -1
- package/dist/dts/internal/matchSql.d.ts +26 -2
- package/dist/dts/internal/matchSql.d.ts.map +1 -1
- package/dist/dts/internal/readPlan.d.ts.map +1 -1
- package/dist/dts/internal/transport.d.ts +17 -7
- package/dist/dts/internal/transport.d.ts.map +1 -1
- package/dist/dts/store.d.ts.map +1 -1
- package/dist/esm/ensureSchema.js +6 -1
- package/dist/esm/ensureSchema.js.map +1 -1
- package/dist/esm/internal/ddl.js +30 -13
- package/dist/esm/internal/ddl.js.map +1 -1
- package/dist/esm/internal/matchSql.js +44 -2
- package/dist/esm/internal/matchSql.js.map +1 -1
- package/dist/esm/internal/readPlan.js +8 -4
- package/dist/esm/internal/readPlan.js.map +1 -1
- package/dist/esm/internal/transport.js +26 -3
- package/dist/esm/internal/transport.js.map +1 -1
- package/dist/esm/store.js.map +1 -1
- package/package.json +2 -2
- package/src/ensureSchema.ts +6 -1
- package/src/internal/ddl.ts +32 -12
- package/src/internal/matchSql.ts +52 -1
- package/src/internal/readPlan.ts +8 -4
- package/src/internal/transport.ts +46 -7
- package/src/store.ts +2 -4
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ per ADR-0003):
|
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
21
|
pnpm add @kairos-es/store-postgres@alpha @kairos-es/core@alpha \
|
|
22
|
-
@effect/sql @effect/sql-pg @effect/platform
|
|
22
|
+
@effect/sql@^0.52.0 @effect/sql-pg@^0.53.0 @effect/platform@^0.97.0 \
|
|
23
|
+
@effect/experimental@^0.61.0 effect@^3.22.0
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
`@effect/platform` and `@effect/experimental` are pulled in because
|
|
@@ -30,10 +31,17 @@ consumers.
|
|
|
30
31
|
## Schema: `ensureSchema` as a migration
|
|
31
32
|
|
|
32
33
|
The package ships **no migrator**. `ensureSchema(config)` is a single idempotent
|
|
33
|
-
`Effect<void, SqlError, SqlClient>` that creates
|
|
34
|
-
|
|
35
|
-
FUNCTION`, so re-running it is
|
|
36
|
-
package only provides the idempotent **payload**.
|
|
34
|
+
`Effect<void, SqlError, SqlClient>` that creates every object the store owns and
|
|
35
|
+
replaces its append functions. Every statement is `CREATE … IF NOT EXISTS` or
|
|
36
|
+
`CREATE OR REPLACE FUNCTION`, so re-running it is safe. Migration
|
|
37
|
+
**orchestration** is yours; the package only provides the idempotent **payload**.
|
|
38
|
+
|
|
39
|
+
**Upgrading.** A re-run replaces the append functions but never alters an existing
|
|
40
|
+
table. So when a release adds a column, its release notes give the `ALTER TABLE`
|
|
41
|
+
statement, and an upgrade is that statement followed by this version's
|
|
42
|
+
`ensureSchema` again, registered as a NEW migration: a migrator never re-runs one
|
|
43
|
+
it has already applied, and an append function left behind silently ignores the
|
|
44
|
+
new column.
|
|
37
45
|
|
|
38
46
|
Drop it straight into an `@effect/sql` migrator as a one-liner:
|
|
39
47
|
|
package/dist/cjs/ensureSchema.js
CHANGED
|
@@ -28,7 +28,12 @@ var _ddl = require("./internal/ddl.js");
|
|
|
28
28
|
* consumer, this package only provides the idempotent PAYLOAD.
|
|
29
29
|
*
|
|
30
30
|
* Idempotence: every statement is `CREATE … IF NOT EXISTS` or `CREATE OR REPLACE
|
|
31
|
-
* FUNCTION`, so re-running
|
|
31
|
+
* FUNCTION`, so re-running it is safe. It is NOT a no-op across versions: a
|
|
32
|
+
* re-run replaces the append functions with this version's, and does NOT alter
|
|
33
|
+
* an existing table, so a column a newer version adds must be added by hand
|
|
34
|
+
* before the re-run (the release notes give the statement). A store whose
|
|
35
|
+
* table gained a column but whose functions were never replaced keeps writing
|
|
36
|
+
* through the old ones, which do not know the column. Names come from
|
|
32
37
|
* `sql(identifier)` (via the pre-quoted builder in `internal/ddl.ts`); the DDL
|
|
33
38
|
* bodies carry no bound values (pure schema), and the append functions keep
|
|
34
39
|
* their runtime VALUES as bound parameters, never interpolated.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureSchema.js","names":["_sql","require","_effect","_config","_ddl","ensureSchema","config","Effect","gen","sql","SqlClient","names","resolveNames","decodePostgresStoreConfig","all","runDdl","discard","exports"],"sources":["../../src/ensureSchema.ts"],"sourcesContent":[null],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"ensureSchema.js","names":["_sql","require","_effect","_config","_ddl","ensureSchema","config","Effect","gen","sql","SqlClient","names","resolveNames","decodePostgresStoreConfig","all","runDdl","discard","exports"],"sources":["../../src/ensureSchema.ts"],"sourcesContent":[null],"mappings":";;;;;;AA8BA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAjCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;AAKO,MAAMI,YAAY,GACvBC,MAA2B,IAE3BC,cAAM,CAACC,GAAG,CAAC,aAAS;EAClB,MAAMC,GAAG,GAAG,OAAOC,cAAS,CAACA,SAAS;EACtC;EACA;EACA,MAAMC,KAAK,GAAG,IAAAC,iBAAY,EAAC,IAAAC,iCAAyB,EAACP,MAAM,CAAC,CAAC;EAC7D;EACA,OAAOC,cAAM,CAACO,GAAG,CAAC,IAAAC,WAAM,EAACN,GAAG,EAAEE,KAAK,CAAC,EAAE;IAAEK,OAAO,EAAE;EAAI,CAAE,CAAC;AAC1D,CAAC,CAAC;AAAAC,OAAA,CAAAZ,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/dist/cjs/internal/ddl.js
CHANGED
|
@@ -129,6 +129,16 @@ const lockClause = names => `LOCK TABLE ${quoteQualified(names.mainTable)} IN EX
|
|
|
129
129
|
* preserves batch order, and `RETURNING id, tags` is captured into a temp
|
|
130
130
|
* result set so the tag fan-out and the head can both read it. `data` arrives as
|
|
131
131
|
* a base64 text field and is `decode(…, 'base64')`-restored to `bytea`.
|
|
132
|
+
*
|
|
133
|
+
* The recordset definition, its projection, the `INSERT INTO (…)` target list and
|
|
134
|
+
* the `SELECT` list are all derived from the one `EVENT_COLUMNS` descriptor in
|
|
135
|
+
* `matchSql.ts`, never written out here. The last two must agree POSITIONALLY and a
|
|
136
|
+
* mismatch is not an error, so deriving both from one walk is what keeps them from
|
|
137
|
+
* falling out of step; a column added without a source is a compile error there.
|
|
138
|
+
* What the compiler does NOT reach is whether the source READS the right field, or
|
|
139
|
+
* whether the column comes back out on the read; the round-trip contract group run
|
|
140
|
+
* against this engine is what proves a new column, and only with a value distinct
|
|
141
|
+
* per column, which is what makes a swap visible.
|
|
132
142
|
*/
|
|
133
143
|
const insertFanoutNotify = (names, options = {}) => {
|
|
134
144
|
const main = quoteQualified(names.mainTable);
|
|
@@ -146,18 +156,18 @@ const insertFanoutNotify = (names, options = {}) => {
|
|
|
146
156
|
IF new_head IS NOT NULL THEN
|
|
147
157
|
PERFORM pg_notify(${channel}, '1');
|
|
148
158
|
END IF;` : '';
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
const ne = _matchSql.RECORDSET_ALIAS;
|
|
160
|
+
return ` WITH ${ne} AS (
|
|
161
|
+
SELECT ${_matchSql.eventColumnList}, ordinality
|
|
151
162
|
FROM ROWS FROM(
|
|
152
163
|
jsonb_to_recordset(new_events) AS (${_matchSql.eventRecordsetColumns})
|
|
153
164
|
) WITH ORDINALITY
|
|
154
165
|
),
|
|
155
166
|
inserted AS (
|
|
156
|
-
INSERT INTO ${main} (
|
|
157
|
-
SELECT
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
ORDER BY ne.ordinality
|
|
167
|
+
INSERT INTO ${main} (${_matchSql.eventColumnList})
|
|
168
|
+
SELECT ${_matchSql.eventInsertSelectList}
|
|
169
|
+
FROM ${ne}
|
|
170
|
+
ORDER BY ${ne}.ordinality
|
|
161
171
|
RETURNING id, tags
|
|
162
172
|
),
|
|
163
173
|
fanned AS (
|
|
@@ -206,9 +216,12 @@ const conditionalAppendBody = (names, options = {}) => {
|
|
|
206
216
|
// its ITEMS — none at all, an item carrying no tags, an item carrying tags —
|
|
207
217
|
// which between them cover every `Query` value the grammar can express, so a new
|
|
208
218
|
// SHAPE changes which SQL the read compiles without changing what this body has
|
|
209
|
-
// to match. The exposure is the GRAMMAR itself: a
|
|
210
|
-
// meaning for an existing one, is something this body ignores rather than
|
|
211
|
-
// on, and no `switch` over the shape union would have caught that either.
|
|
219
|
+
// to match. The exposure is the GRAMMAR itself: a field ADDED to `QueryItem`, or a
|
|
220
|
+
// new meaning for an existing one, is something this body ignores rather than
|
|
221
|
+
// fails on, and no `switch` over the shape union would have caught that either. A
|
|
222
|
+
// key the grammar does NOT define never reaches this body: core's
|
|
223
|
+
// `servableQueryFault` refuses it at the contract boundary, which is what keeps a
|
|
224
|
+
// smuggled predicate from being dropped here in silence.
|
|
212
225
|
const after = 'COALESCE(after_id, 0)';
|
|
213
226
|
return `
|
|
214
227
|
DECLARE
|
|
@@ -378,14 +391,18 @@ const ddlStatements = names => {
|
|
|
378
391
|
// positions — a rolled-back insert permanently consumes its id, which is
|
|
379
392
|
// fine: ordering is by id alone and the store is never made gapless.
|
|
380
393
|
// `data` is NULLABLE (a payload-less event is valid); `occurred_at` is
|
|
381
|
-
// informational domain time, never an ordering key.
|
|
394
|
+
// informational domain time, never an ordering key. `metadata` is the
|
|
395
|
+
// event's cleartext context bag (ADR-0017): `jsonb` only so a containment
|
|
396
|
+
// index stays possible without a rewrite, though nothing queries it and no
|
|
397
|
+
// index is built; `NOT NULL DEFAULT '{}'` gives an empty bag one shape.
|
|
382
398
|
`CREATE TABLE IF NOT EXISTS ${main} (
|
|
383
399
|
id bigserial,
|
|
384
400
|
type text NOT NULL,
|
|
385
401
|
data bytea,
|
|
386
402
|
tags text[] NOT NULL,
|
|
387
403
|
uuid text NOT NULL,
|
|
388
|
-
occurred_at timestamptz NOT NULL
|
|
404
|
+
occurred_at timestamptz NOT NULL,
|
|
405
|
+
metadata jsonb NOT NULL DEFAULT '{}'::jsonb
|
|
389
406
|
) WITH (${AUTOVACUUM_WITH});`,
|
|
390
407
|
// Covering unique index: uniqueness on id plus INCLUDE(type) so the read
|
|
391
408
|
// path's id→type lookups are index-only.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddl.js","names":["_matchSql","require","DEFAULT_SCHEMA","exports","DEFAULT_TABLE_PREFIX","MAX_IDENTIFIER_BYTES","utf8ByteLength","value","TextEncoder","encode","length","derivedAtoms","config","schema","tablePrefix","replace","oversizedIdentifier","label","atom","bytes","undefined","resolveNames","problem","Error","mainTable","tagTable","mainIndex","tagIndex","appendFn","appendUnconditionalFn","channel","quoteQualified","name","split","map","join","quoteAtom","quoteLiteral","AUTOVACUUM_WITH","lockClause","names","insertFanoutNotify","options","main","tag","notify","eventRecordsetColumns","conditionalAppendBody","lock","after","taggedMatchChain","queryItemsExpr","afterExpr","allowedTypesPredicate","qualifiedRows","unconditionalAppendBody","appendFunctionStatement","qualifiedName","argList","body","kind","ddlStatements","runDdl","sql","statement","unsafe"],"sources":["../../../src/internal/ddl.ts"],"sourcesContent":[null],"mappings":";;;;;;AA4BA,IAAAA,SAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"ddl.js","names":["_matchSql","require","DEFAULT_SCHEMA","exports","DEFAULT_TABLE_PREFIX","MAX_IDENTIFIER_BYTES","utf8ByteLength","value","TextEncoder","encode","length","derivedAtoms","config","schema","tablePrefix","replace","oversizedIdentifier","label","atom","bytes","undefined","resolveNames","problem","Error","mainTable","tagTable","mainIndex","tagIndex","appendFn","appendUnconditionalFn","channel","quoteQualified","name","split","map","join","quoteAtom","quoteLiteral","AUTOVACUUM_WITH","lockClause","names","insertFanoutNotify","options","main","tag","notify","ne","RECORDSET_ALIAS","eventColumnList","eventRecordsetColumns","eventInsertSelectList","conditionalAppendBody","lock","after","taggedMatchChain","queryItemsExpr","afterExpr","allowedTypesPredicate","qualifiedRows","unconditionalAppendBody","appendFunctionStatement","qualifiedName","argList","body","kind","ddlStatements","runDdl","sql","statement","unsafe"],"sources":["../../../src/internal/ddl.ts"],"sourcesContent":[null],"mappings":";;;;;;AA4BA,IAAAA,SAAA,GAAAC,OAAA;AA6CA;AACO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,QAAQ;AACtC;AACO,MAAME,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,GAAG,YAAY;AAEhD;;;;;;;AAOA,MAAMC,oBAAoB,GAAG,EAAE;AAE/B;AACA,MAAMC,cAAc,GAAIC,KAAa,IACnC,IAAIC,WAAW,EAAE,CAACC,MAAM,CAACF,KAAK,CAAC,CAACG,MAAM;AAExC;;;;;;AAMA,MAAMC,YAAY,GAAIC,MAGrB,IAA8C;EAC7C,MAAMC,MAAM,GAAGD,MAAM,CAACC,MAAM,IAAIX,cAAc;EAC9C,MAAMY,WAAW,GAAGF,MAAM,CAACE,WAAW,IAAIV,oBAAoB;EAC9D,OAAO,CACL,CAAC,QAAQ,EAAES,MAAM,CAAC,EAClB,CAAC,cAAc,EAAEC,WAAW,CAAC,EAC7B,CAAC,WAAW,EAAE,GAAGA,WAAW,OAAO,CAAC,EACpC,CAAC,YAAY,EAAE,GAA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SAAS,CAACI,KAAK,CAAC3B,MAAM,CAAC;EACtC,MAAMa,SAAS,GAAGU,SAAS,CAACI,KAAK,CAACd,SAAS,CAAC;EAC5C,MAAMC,QAAQ,GAAGS,SAAS,CAACI,KAAK,CAACb,QAAQ,CAAC;EAE1C,OAAO;EACL;EACA;EACA,+BAA+Bd,MAAM,GAAG;EAExC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,8BAA8B8B,IAAI;;;;;;;;eAQvBL,eAAe,IAAI;EAE9B;EACA;EACA,qCAAqCZ,SAAS;YACtCiB,IAAI,uBAAuB;EAEnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,8BAA8BC,GAAG;;mCAEFD,IAAI;eACxBL,eAAe,IAAI;EAE9B;EACA;EACA,8BAA8BX,QAAQ;YAC9BiB,GAAG,kBAAkB;EAE7B;EACAgB,uBAAuB,CAACpB,KAAK,EAAE;IAAEwB,IAAI,EAAE;EAAa,CAAE,CAAC;EAEvD;EACAJ,uBAAuB,CAACpB,KAAK,EAAE;IAAEwB,IAAI,EAAE;EAAe,CAAE,CAAC,CAC1D;AACH,CAAC;AAED;;;;;;AAAA7D,OAAA,CAAA8D,aAAA,GAAAA,aAAA;AAMO,MAAMC,MAAM,GAAGA,CACpBC,GAAwB,EACxB3B,KAAoB,KAEpByB,aAAa,CAACzB,KAAK,CAAC,CAACN,GAAG,CAAEkC,SAAS,IAAKD,GAAG,CAACE,MAAM,CAACD,SAAS,CAAC,CAAC;AAAAjE,OAAA,CAAA+D,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.wildcardReadSql = exports.typeOnlyReadSql = exports.taggedReadSql = exports.taggedMatchChain = exports.readColumns = exports.qualifiedRows = exports.eventRecordsetColumns = exports.allowedTypesPredicate = void 0;
|
|
6
|
+
exports.wildcardReadSql = exports.typeOnlyReadSql = exports.taggedReadSql = exports.taggedMatchChain = exports.readColumns = exports.qualifiedRows = exports.eventRecordsetColumns = exports.eventInsertSelectList = exports.eventColumnList = exports.allowedTypesPredicate = exports.RECORDSET_ALIAS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Single source of truth for the tag-first match SQL.
|
|
9
9
|
*
|
|
@@ -38,10 +38,11 @@ exports.wildcardReadSql = exports.typeOnlyReadSql = exports.taggedReadSql = expo
|
|
|
38
38
|
* that union, so a column rename here is a COMPILE error there, not a silent drift
|
|
39
39
|
* the lax read boundary (ADR-0006) would only surface as corrupt data under test.
|
|
40
40
|
*/
|
|
41
|
-
const EVENT_COLUMNS = [['type', 'text'], ['data', 'text'], ['tags', 'text[]'], ['uuid', 'text'], ['occurred_at', 'timestamptz']];
|
|
41
|
+
const EVENT_COLUMNS = [['type', 'text'], ['data', 'text'], ['tags', 'text[]'], ['uuid', 'text'], ['occurred_at', 'timestamptz'], ['metadata', 'jsonb']];
|
|
42
42
|
/**
|
|
43
43
|
* The `jsonb_to_recordset(new_events) AS (…)` column definitions —
|
|
44
|
-
* `type text, data text, tags text[], uuid text, occurred_at timestamptz
|
|
44
|
+
* `type text, data text, tags text[], uuid text, occurred_at timestamptz,
|
|
45
|
+
* metadata jsonb`. The
|
|
45
46
|
* transport `data` is base64 TEXT (restored to `bytea` by `decode(…, 'base64')`
|
|
46
47
|
* at insert), which is why it is `text` here, not `bytea`.
|
|
47
48
|
*/
|
|
@@ -52,13 +53,54 @@ const eventRecordsetColumns = exports.eventRecordsetColumns = /*#__PURE__*/EVENT
|
|
|
52
53
|
* cannot drift from the recordset.
|
|
53
54
|
*/
|
|
54
55
|
const readColumns = (prefix = '') => [`${prefix}id`, ...EVENT_COLUMNS.map(([name]) => `${prefix}${name}`)].join(', ');
|
|
56
|
+
/**
|
|
57
|
+
* The alias the append body gives the expanded `new_events` recordset — the `ne`
|
|
58
|
+
* CTE in `ddl.ts` — which every expression in `EVENT_COLUMN_SOURCE` reads from.
|
|
59
|
+
* Exported so the CTE is declared under the one name its readers assume.
|
|
60
|
+
*/
|
|
61
|
+
exports.readColumns = readColumns;
|
|
62
|
+
const RECORDSET_ALIAS = exports.RECORDSET_ALIAS = 'ne';
|
|
63
|
+
/**
|
|
64
|
+
* What the append body inserts into each event column, read from the recordset row.
|
|
65
|
+
*
|
|
66
|
+
* Typed as a `Record` over `EventColumnName` so that adding a column to
|
|
67
|
+
* `EVENT_COLUMNS` without saying where its value comes from is a COMPILE error,
|
|
68
|
+
* rather than a column the insert silently leaves at its default. Every column but
|
|
69
|
+
* `data` passes through as the recordset already types it — `text[]` tags,
|
|
70
|
+
* `timestamptz`, `jsonb` metadata — because `jsonb_to_recordset` did the casting;
|
|
71
|
+
* `data` crosses as base64 TEXT and is restored to `bytea` here, its one decode.
|
|
72
|
+
*/
|
|
73
|
+
const EVENT_COLUMN_SOURCE = {
|
|
74
|
+
type: `${RECORDSET_ALIAS}.type`,
|
|
75
|
+
data: `decode(${RECORDSET_ALIAS}.data, 'base64')`,
|
|
76
|
+
tags: `${RECORDSET_ALIAS}.tags`,
|
|
77
|
+
uuid: `${RECORDSET_ALIAS}.uuid`,
|
|
78
|
+
occurred_at: `${RECORDSET_ALIAS}.occurred_at`,
|
|
79
|
+
metadata: `${RECORDSET_ALIAS}.metadata`
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The bare event column names — `type, data, tags, uuid, occurred_at, metadata` —
|
|
83
|
+
* which the append body uses twice: as the recordset CTE's projection and as the
|
|
84
|
+
* `INSERT INTO t (…)` target list.
|
|
85
|
+
*/
|
|
86
|
+
const eventColumnList = exports.eventColumnList = /*#__PURE__*/EVENT_COLUMNS.map(([name]) => name).join(', ');
|
|
87
|
+
/**
|
|
88
|
+
* The append insert's SELECT list: one source expression per column, in the SAME
|
|
89
|
+
* ORDER as `eventColumnList`.
|
|
90
|
+
*
|
|
91
|
+
* The two halves of `INSERT INTO t (a, b) SELECT x, y` agree POSITION BY POSITION
|
|
92
|
+
* and nothing checks that they do: two columns of compatible type swap without an
|
|
93
|
+
* error at any layer and the data lands in the wrong one. Both halves are therefore
|
|
94
|
+
* one walk of the one descriptor, so the append body has no second ordering to keep
|
|
95
|
+
* in step and no hand-written list for a new column to be missing from.
|
|
96
|
+
*/
|
|
97
|
+
const eventInsertSelectList = exports.eventInsertSelectList = /*#__PURE__*/EVENT_COLUMNS.map(([name]) => EVENT_COLUMN_SOURCE[name]).join(', ');
|
|
55
98
|
/**
|
|
56
99
|
* The allowed-types filter for a candidate row aliased `m`: an item with no
|
|
57
100
|
* types matches ANY type; otherwise the event's type must be one of them.
|
|
58
101
|
* `typesCol` is the `text[]` column holding the item's types — `q.allowed_types`
|
|
59
102
|
* for a tagged match, `qi.types` for a tagless one.
|
|
60
103
|
*/
|
|
61
|
-
exports.readColumns = readColumns;
|
|
62
104
|
const allowedTypesPredicate = typesCol => `(array_length(${typesCol}, 1) IS NULL OR array_length(${typesCol}, 1) = 0 OR m.type = ANY(${typesCol}))`;
|
|
63
105
|
/**
|
|
64
106
|
* The tag-first match CTE chain shared by the read and conflict paths: expand
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchSql.js","names":["EVENT_COLUMNS","eventRecordsetColumns","exports","map","name","type","join","readColumns","prefix","allowedTypesPredicate","typesCol","taggedMatchChain","tokens","queryItemsExpr","tag","afterExpr","qualifiedRows","main","wildcardReadSql","typeOnlyReadSql","taggedReadSql"],"sources":["../../../src/internal/matchSql.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAwBA;;;;;;;;;;;AAWA,MAAMA,aAAa,GAAG,CACpB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,aAAa,EAAE,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"matchSql.js","names":["EVENT_COLUMNS","eventRecordsetColumns","exports","map","name","type","join","readColumns","prefix","RECORDSET_ALIAS","EVENT_COLUMN_SOURCE","data","tags","uuid","occurred_at","metadata","eventColumnList","eventInsertSelectList","allowedTypesPredicate","typesCol","taggedMatchChain","tokens","queryItemsExpr","tag","afterExpr","qualifiedRows","main","wildcardReadSql","typeOnlyReadSql","taggedReadSql"],"sources":["../../../src/internal/matchSql.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAwBA;;;;;;;;;;;AAWA,MAAMA,aAAa,GAAG,CACpB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClB,CAAC,MAAM,EAAE,MAAM,CAAC,EAChB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9B,CAAC,UAAU,EAAE,OAAO,CAAC,CAGtB;AAYD;;;;;;;AAOO,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAAWD,aAAa,CAACG,GAAG,CAC5D,CAAC,CAACC,IAAI,EAAEC,IAAI,CAAC,KAAK,GAAGD,IAAI,IAAIC,IAAI,EAAE,CACpC,CAACC,IAAI,CAAC,IAAI,CAAC;AAEZ;;;;;AAKO,MAAMC,WAAW,GAAGA,CAACC,MAAM,GAAG,EAAE,KACrC,CAAC,GAAGA,MAAM,IAAI,EAAE,GAAGR,aAAa,CAACG,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,GAAGI,MAAM,GAAGJ,IAAI,EAAE,CAAC,CAAC,CAACE,IAAI,CACxE,IAAI,CACL;AAEH;;;;;AAAAJ,OAAA,CAAAK,WAAA,GAAAA,WAAA;AAKO,MAAME,eAAe,GAAAP,OAAA,CAAAO,eAAA,GAAG,IAAI;AAEnC;;;;;;;;;;AAUA,MAAMC,mB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AME,eAAe,GAAID,IAAY,IAC1C,UAAUnB,WAAW,EAAE;UACfmB,IAAI;;;YAGF;AAEZ;AAAAxB,OAAA,CAAAyB,eAAA,GAAAA,eAAA;AACO,MAAMC,eAAe,GAAIF,IAAY,IAC1C,UAAUnB,WAAW,EAAE;UACfmB,IAAI;;;YAGF;AAEZ;;;;;;AAAAxB,OAAA,CAAA0B,eAAA,GAAAA,eAAA;AAMO,MAAMC,aAAa,GAAGA,CAACH,IAAY,EAAEH,GAAW,KACrD,QAAQH,gBAAgB,CAAC;EAAEE,cAAc,EAAE,WAAW;EAAEE,SAAS,EAAE,IAAI;EAAEE,IAAI;EAAEH;AAAG,CAAE,CAAC;;;MAGjFE,aAAa,CAAC;EAAEC,IAAI;EAAEF,SAAS,EAAE;AAAI,CAAE,CAAC;;;;WAInCjB,WAAW,CAAC,IAAI,CAAC;SACnBmB,IAAI;;oBAEO;AAAAxB,OAAA,CAAA2B,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -36,10 +36,14 @@ const compileFetchPlan = (tables, query) => {
|
|
|
36
36
|
case 'typeOnly':
|
|
37
37
|
{
|
|
38
38
|
// node-postgres binds a JS array param as a Postgres array literal, so
|
|
39
|
-
// `type = ANY($2)` matches any of the item's types.
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
39
|
+
// `type = ANY($2)` matches any of the item's types. A branded `EventType` IS
|
|
40
|
+
// its string to the driver, so nothing has to be unwrapped — but the list is
|
|
41
|
+
// COPIED here, at compile time. The driver serialises the array afresh on
|
|
42
|
+
// every `bind`, and a subscription re-binds on every poll, so binding the
|
|
43
|
+
// caller's own array would let an edit the caller makes after subscribing
|
|
44
|
+
// reach the next fetch. The tagged arm is immune by construction, since it
|
|
45
|
+
// serialises once below; this copy is what makes the two arms agree.
|
|
46
|
+
const types = [...shape.types];
|
|
43
47
|
return {
|
|
44
48
|
text: (0, _matchSql.typeOnlyReadSql)(tables.main),
|
|
45
49
|
bind: (after, limit) => [after, types, limit]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readPlan.js","names":["_core","require","_matchSql","_transport","compileFetchPlan","tables","query","shape","classifyServableQuery","kind","text","wildcardReadSql","main","bind","after","limit","types","typeOnlyReadSql","itemsJson","jsonbText","toQueryItemsJson","taggedReadSql","tag","exports","runFetch","sql","plan","unsafe","ORIGIN"],"sources":["../../../src/internal/readPlan.ts"],"sourcesContent":[null],"mappings":";;;;;;AAyBA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AA0BA;;;;;;;;;;;;;;;;;;AAkBO,MAAMG,gBAAgB,GAAGA,CAC9BC,MAAkB,EAClBC,KAAY,KACC;EACb,MAAMC,KAAK,GAAG,IAAAC,2BAAqB,EAACF,KAAK,CAAC;EAC1C,QAAQC,KAAK,CAACE,IAAI;IAChB,KAAK,UAAU;MACb,OAAO;QACLC,IAAI,EAAE,IAAAC,yBAAe,EAACN,MAAM,CAACO,IAAI,CAAC;QAClCC,IAAI,EAAEA,CAACC,KAAK,EAAEC,KAAK,KAAK,CAACD,KAAK,EAAEC,KAAK;OACtC;IACH,KAAK,UAAU;MAAE;QACf;QACA;QACA;QACA;QACA,MAAMC,KAAK,GAAGT,KAAK,CAACS,KAAK;
|
|
1
|
+
{"version":3,"file":"readPlan.js","names":["_core","require","_matchSql","_transport","compileFetchPlan","tables","query","shape","classifyServableQuery","kind","text","wildcardReadSql","main","bind","after","limit","types","typeOnlyReadSql","itemsJson","jsonbText","toQueryItemsJson","taggedReadSql","tag","exports","runFetch","sql","plan","unsafe","ORIGIN"],"sources":["../../../src/internal/readPlan.ts"],"sourcesContent":[null],"mappings":";;;;;;AAyBA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AA0BA;;;;;;;;;;;;;;;;;;AAkBO,MAAMG,gBAAgB,GAAG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AAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -34,12 +34,35 @@ const toEventJson = event => ({
|
|
|
34
34
|
data: _effect.Encoding.encodeBase64(event.data),
|
|
35
35
|
tags: [...event.tags],
|
|
36
36
|
uuid: event.uuid,
|
|
37
|
-
occurred_at: _effect.DateTime.formatIso(event.occurredAt)
|
|
37
|
+
occurred_at: _effect.DateTime.formatIso(event.occurredAt),
|
|
38
|
+
metadata: event.metadata
|
|
38
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* The `metadata` column as the event's bag, checked to be a JSON OBJECT.
|
|
42
|
+
*
|
|
43
|
+
* The store only ever writes an object, but `jsonb` admits any JSON value — an
|
|
44
|
+
* array, a string, a number, a boolean, JSON `null` (which `NOT NULL` does not
|
|
45
|
+
* exclude) — so a hand-written row can hold one. Such a row is corrupt, and
|
|
46
|
+
* handing an event whose `metadata` is not a bag to every projection
|
|
47
|
+
* downstream is worse than stopping at the read. This is the CONTAINER check
|
|
48
|
+
* only; the shape rule itself has one home, core's `Metadata` doc. The VALUES
|
|
49
|
+
* are deliberately not re-checked as strings, because a value check on read
|
|
50
|
+
* alone would make an event the store accepted unreadable for ever.
|
|
51
|
+
*/
|
|
52
|
+
exports.toEventJson = toEventJson;
|
|
53
|
+
const metadataFrom = value => {
|
|
54
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
55
|
+
throw new Error(`@kairos-es/store-postgres: the \`metadata\` column did not hold a JSON object (got ${JSON.stringify(value)}).`);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
39
59
|
/**
|
|
40
60
|
* Map a raw main-table row to a core `SequencedEvent`. `data` NULL → empty bytes
|
|
41
61
|
* (a payload-less event round-trips to a zero-length `Uint8Array`); `occurred_at`
|
|
42
|
-
* Date → `DateTime.Utc`; `id` string → branded `Position
|
|
62
|
+
* Date → `DateTime.Utc`; `id` string → branded `Position`; `metadata` through
|
|
63
|
+
* `metadataFrom`. The column is `NOT NULL DEFAULT '{}'`, so there is no absent
|
|
64
|
+
* case to reconcile: an event appended with an empty bag reads back as `{}` on
|
|
65
|
+
* this engine exactly as on the in-memory oracle.
|
|
43
66
|
*
|
|
44
67
|
* The branded scalars (`type`, `tags`, `uuid`, `position`) are minted by trusted
|
|
45
68
|
* `as`-cast, NOT by re-running `EventType.make` / `Tag.make` etc. This is
|
|
@@ -51,14 +74,14 @@ const toEventJson = event => ({
|
|
|
51
74
|
* (`inMemory.ts`). The read boundary is the analogous trusted deserialisation
|
|
52
75
|
* point.
|
|
53
76
|
*/
|
|
54
|
-
exports.toEventJson = toEventJson;
|
|
55
77
|
const rowToSequenced = row => ({
|
|
56
78
|
event: {
|
|
57
79
|
type: row.type,
|
|
58
80
|
data: row.data ?? new Uint8Array(0),
|
|
59
81
|
tags: row.tags,
|
|
60
82
|
uuid: row.uuid,
|
|
61
|
-
occurredAt: _effect.DateTime.unsafeFromDate(row.occurred_at)
|
|
83
|
+
occurredAt: _effect.DateTime.unsafeFromDate(row.occurred_at),
|
|
84
|
+
metadata: metadataFrom(row.metadata)
|
|
62
85
|
},
|
|
63
86
|
position: BigInt(row.id)
|
|
64
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","names":["_effect","require","jsonbText","value","JSON","stringify","exports","toQueryItemsJson","query","items","map","item","types","tags","toEventJson","event","type","data","Encoding","encodeBase64","uuid","occurred_at","DateTime","formatIso","occurredAt","rowToSequenced","row","Uint8Array","unsafeFromDate","position","BigInt","id"],"sources":["../../../src/internal/transport.ts"],"sourcesContent":[null],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"transport.js","names":["_effect","require","jsonbText","value","JSON","stringify","exports","toQueryItemsJson","query","items","map","item","types","tags","toEventJson","event","type","data","Encoding","encodeBase64","uuid","occurred_at","DateTime","formatIso","occurredAt","metadata","metadataFrom","Array","isArray","Error","rowToSequenced","row","Uint8Array","unsafeFromDate","position","BigInt","id"],"sources":["../../../src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O,MAAM2B,cAAc,GAAIC,GAAa,KAAsB;EAChEhB,KAAK,EAAE;IACLC,IAAI,EAAEe,GAAG,CAACf,IAAwB;IAClCC,IAAI,EAAEc,GAAG,CAACd,IAAI,IAAI,IAAIe,UAAU,CAAC,CAAC,CAAC;IACnCnB,IAAI,EAAEkB,GAAG,CAAClB,IAAmC;IAC7CO,IAAI,EAAEW,GAAG,CAACX,IAAwB;IAClCI,UAAU,EAAEF,gBAAQ,CAACW,cAAc,CAACF,GAAG,CAACV,WAAW,CAAC;IACpDI,QAAQ,EAAEC,YAAY,CAACK,GAAG,CAACN,QAAQ;GACpC;EACDS,QAAQ,EAAEC,MAAM,CAACJ,GAAG,CAACK,EAAE;CACxB,CAAC;AAAA9B,OAAA,CAAAwB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/dist/cjs/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","names":["_core","require","_effect","_clients","_config","_ddl","_readPlan","_transport","setLocalLockTimeout","sql","lockTimeout","make","config","names","Effect","gen","pooled","PgClientPooled","direct","PgClientDirect","pollInterval","DEFAULT_POLL_INTERVAL_MILLIS","catchUpPageSize","DEFAULT_CATCH_UP_PAGE_SIZE","tables","main","quoteQualified","mainTable","tag","tagTable","globalHead","pipe","map","rows","max","undefined","ORIGIN","BigInt","readRowsAndHead","query","options","plan","compileFetchPlan","limit","runFetch","after","lastRow","at","head","id","withTransaction","unsafe","read","events","Stream","fromIterable","rowToSequenced","callAppendFn","select","zipRight","append","condition","eventsJson","toEventJson","appendUnconditionalFn","jsonbText","headFromRows","queryItems","toQueryItemsJson","failIfEventsMatch","afterId","appendFn","length","AppendConditionFailed","Error","subscribe","subscribeStream","fetch","from","listen","channel","layer","decoded","decodePostgresStoreConfig","Layer","effect","DcbEventStore","resolveNames","makeContractStore","exports"],"sources":["../../src/store.ts"],"sourcesContent":[null],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"store.js","names":["_core","require","_effect","_clients","_config","_ddl","_readPlan","_transport","setLocalLockTimeout","sql","lockTimeout","make","config","names","Effect","gen","pooled","PgClientPooled","direct","PgClientDirect","pollInterval","DEFAULT_POLL_INTERVAL_MILLIS","catchUpPageSize","DEFAULT_CATCH_UP_PAGE_SIZE","tables","main","quoteQualified","mainTable","tag","tagTable","globalHead","pipe","map","rows","max","undefined","ORIGIN","BigInt","readRowsAndHead","query","options","plan","compileFetchPlan","limit","runFetch","after","lastRow","at","head","id","withTransaction","unsafe","read","events","Stream","fromIterable","rowToSequenced","callAppendFn","select","zipRight","append","condition","eventsJson","toEventJson","appendUnconditionalFn","jsonbText","headFromRows","queryItems","toQueryItemsJson","failIfEventsMatch","afterId","appendFn","length","AppendConditionFailed","Error","subscribe","subscribeStream","fetch","from","listen","channel","layer","decoded","decodePostgresStoreConfig","Layer","effect","DcbEventStore","resolveNames","makeContractStore","exports"],"sources":["../../src/store.ts"],"sourcesContent":[null],"mappings":";;;;;;AAkDA,IAAAA,KAAA,GAAAC,OAAA;AAYA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAKA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAN,OAAA;AAQA;;;;;;;;;AASA,MAAMO,mBAAmB,GAAGA,CAC1BC,GAAwB,EACxBC,WAAmB,KAEnBD,GAAG,qCAAqC,GAAGC,WAAW,GAAG,SAAS;AAEpE;;;;;;AAMA,MAAMC,IAAI,GAAGA,CACXC,MAA2B,EAC3BC,KAAoB,KAMpBC,cAAM,CAACC,GAAG,CAAC,aAAS;EAClB,MAAMC,MAAM,GAAG,OAAOC,uBAAc;EACpC,MAAMC,MAAM,GAAG,OAAOC,uBAAc;EACpC,MAAMT,WAAW,GAAGE,MAAM,CAACF,WAAW,IAAI,CAAC;EAC3C,MAAMU,YAAY,GAAGR,MAAM,CAACQ,YA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CAAC;IAC5C,OAAO,IAAAqC,qBAAe,EACpB;MACEC,KAAK,EAAEA,CAACC,IAAI,EAAEnC,KAAK,KACjB,IAAAC,kBAAQ,EAAC5B,MAAM,EAAEyB,IAAI,EAAEqC,IAAI,EAAEnC,KAAK,CAAC,CAACZ,IAAI,CACtCjB,cAAM,CAACkB,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACD,GAAG,CAACwB,yBAAc,CAAC,CAAC,CAC/C;MACHuB,MAAM,EAAE7D,MAAM,CAAC6D,MAAM,CAAClE,KAAK,CAACmE,OAAO,CAAC;MACpC5D,YAAY;MACZE;KACD,EACDuB,KAAK,CACN;EACH,CAAC;EAED,OAAO;IAAEO,IAAI;IAAEQ,MAAM;IAAEe;EAAS,CAAW;AAC7C,CAAC,CAAC;AAEJ;;;;;;;;;;;AAWO,MAAMM,KAAK,GAAGA,CACnBrE,MAAA,GAA8B,EAAE,KACsC;EACtE;EACA;EACA;EACA,MAAMsE,OAAO,GAAG,IAAAC,iCAAyB,EAACvE,MAAM,CAAC;EACjD,OAAOwE,aAAK,CAACC,MAAM,CACjBC,mBAAa,EACbxE,cAAM,CAACkB,GAAG,CAACrB,IAAI,CAACuE,OAAO,EAAE,IAAAK,iBAAY,EAACL,OAAO,CAAC,CAAC,EAAEM,uBAAiB,CAAC,CACpE;AACH,CAAC;AAAAC,OAAA,CAAAR,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
* consumer, this package only provides the idempotent PAYLOAD.
|
|
19
19
|
*
|
|
20
20
|
* Idempotence: every statement is `CREATE … IF NOT EXISTS` or `CREATE OR REPLACE
|
|
21
|
-
* FUNCTION`, so re-running
|
|
21
|
+
* FUNCTION`, so re-running it is safe. It is NOT a no-op across versions: a
|
|
22
|
+
* re-run replaces the append functions with this version's, and does NOT alter
|
|
23
|
+
* an existing table, so a column a newer version adds must be added by hand
|
|
24
|
+
* before the re-run (the release notes give the statement). A store whose
|
|
25
|
+
* table gained a column but whose functions were never replaced keeps writing
|
|
26
|
+
* through the old ones, which do not know the column. Names come from
|
|
22
27
|
* `sql(identifier)` (via the pre-quoted builder in `internal/ddl.ts`); the DDL
|
|
23
28
|
* bodies carry no bound values (pure schema), and the append functions keep
|
|
24
29
|
* their runtime VALUES as bound parameters, never interpolated.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureSchema.d.ts","sourceRoot":"","sources":["../../src/ensureSchema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ensureSchema.d.ts","sourceRoot":"","sources":["../../src/ensureSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAG9E;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,mBAAmB,KAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAQzD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../src/internal/ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../src/internal/ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAWvD;;;;;GAKG;AACH,MAAM,WAAW,aAA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C1B;AAoOD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAC7B,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GACpE,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAAG,iBAAiB,CAAC,CAAA;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,aAAa,EACpB,SAAS,qBAAqB,KAC7B,MAqBF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,aAAa,KAAG,aAAa,CAAC,MAAM,CAmExE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,SAAS,CAAC,SAAS,EACxB,OAAO,aAAa,KACnB,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CACmB,CAAA"}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* that union, so a column rename here is a COMPILE error there, not a silent drift
|
|
33
33
|
* the lax read boundary (ADR-0006) would only surface as corrupt data under test.
|
|
34
34
|
*/
|
|
35
|
-
declare const EVENT_COLUMNS: readonly [readonly ["type", "text"], readonly ["data", "text"], readonly ["tags", "text[]"], readonly ["uuid", "text"], readonly ["occurred_at", "timestamptz"]];
|
|
35
|
+
declare const EVENT_COLUMNS: readonly [readonly ["type", "text"], readonly ["data", "text"], readonly ["tags", "text[]"], readonly ["uuid", "text"], readonly ["occurred_at", "timestamptz"], readonly ["metadata", "jsonb"]];
|
|
36
36
|
/**
|
|
37
37
|
* The event payload column NAMES as a string-literal union, derived from the ONE
|
|
38
38
|
* `EVENT_COLUMNS` descriptor. `internal/transport.ts` builds its transport shapes
|
|
@@ -44,7 +44,8 @@ declare const EVENT_COLUMNS: readonly [readonly ["type", "text"], readonly ["dat
|
|
|
44
44
|
export type EventColumnName = (typeof EVENT_COLUMNS)[number][0];
|
|
45
45
|
/**
|
|
46
46
|
* The `jsonb_to_recordset(new_events) AS (…)` column definitions —
|
|
47
|
-
* `type text, data text, tags text[], uuid text, occurred_at timestamptz
|
|
47
|
+
* `type text, data text, tags text[], uuid text, occurred_at timestamptz,
|
|
48
|
+
* metadata jsonb`. The
|
|
48
49
|
* transport `data` is base64 TEXT (restored to `bytea` by `decode(…, 'base64')`
|
|
49
50
|
* at insert), which is why it is `text` here, not `bytea`.
|
|
50
51
|
*/
|
|
@@ -55,6 +56,29 @@ export declare const eventRecordsetColumns: string;
|
|
|
55
56
|
* cannot drift from the recordset.
|
|
56
57
|
*/
|
|
57
58
|
export declare const readColumns: (prefix?: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* The alias the append body gives the expanded `new_events` recordset — the `ne`
|
|
61
|
+
* CTE in `ddl.ts` — which every expression in `EVENT_COLUMN_SOURCE` reads from.
|
|
62
|
+
* Exported so the CTE is declared under the one name its readers assume.
|
|
63
|
+
*/
|
|
64
|
+
export declare const RECORDSET_ALIAS = "ne";
|
|
65
|
+
/**
|
|
66
|
+
* The bare event column names — `type, data, tags, uuid, occurred_at, metadata` —
|
|
67
|
+
* which the append body uses twice: as the recordset CTE's projection and as the
|
|
68
|
+
* `INSERT INTO t (…)` target list.
|
|
69
|
+
*/
|
|
70
|
+
export declare const eventColumnList: string;
|
|
71
|
+
/**
|
|
72
|
+
* The append insert's SELECT list: one source expression per column, in the SAME
|
|
73
|
+
* ORDER as `eventColumnList`.
|
|
74
|
+
*
|
|
75
|
+
* The two halves of `INSERT INTO t (a, b) SELECT x, y` agree POSITION BY POSITION
|
|
76
|
+
* and nothing checks that they do: two columns of compatible type swap without an
|
|
77
|
+
* error at any layer and the data lands in the wrong one. Both halves are therefore
|
|
78
|
+
* one walk of the one descriptor, so the append body has no second ordering to keep
|
|
79
|
+
* in step and no hand-written list for a new column to be missing from.
|
|
80
|
+
*/
|
|
81
|
+
export declare const eventInsertSelectList: string;
|
|
58
82
|
/**
|
|
59
83
|
* The allowed-types filter for a candidate row aliased `m`: an item with no
|
|
60
84
|
* types matches ANY type; otherwise the event's type must be one of them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchSql.d.ts","sourceRoot":"","sources":["../../../src/internal/matchSql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,QAAA,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"matchSql.d.ts","sourceRoot":"","sources":["../../../src/internal/matchSql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,QAAA,MAAM,aAAa,kMASlB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAExB,CAAA;AAEZ;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,eAAW,KAAG,MAGvC,CAAA;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,OAAO,CAAA;AAqBnC;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAE7B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAExB,CAAA;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MACkD,CAAA;AAE3G,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,qCAAqC;IACrC,QAAQ,CAAC,G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,MAAM,SAAS,EACf,OAAO,QAAQ,GAAG,SAAS,EAC3B,OAAO,SAAS,GAAG,SAAS,KAC3B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CACiB,CAAA"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* where transport code lives, and the two per-column type maps (`EventJson`,
|
|
9
9
|
* `EventRow`) sit next to each other rather than in two files.
|
|
10
10
|
*
|
|
11
|
-
* The
|
|
11
|
+
* The event column contract stays single-sourced on `EventColumnName`
|
|
12
12
|
* (`internal/matchSql.ts`), the one column-NAME descriptor: both type maps here
|
|
13
13
|
* are mapped types over it, so a column rename in `EVENT_COLUMNS` is a COMPILE
|
|
14
14
|
* error in this module, never a silent transport drift the lax read boundary
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* (`toEventJson`) serialises `data` as base64 text and domain time as an ISO
|
|
20
20
|
* string, both restored in SQL.
|
|
21
21
|
*/
|
|
22
|
-
import type { DcbEvent, Query, SequencedEvent } from '@kairos-es/core';
|
|
22
|
+
import type { DcbEvent, Metadata, Query, SequencedEvent } from '@kairos-es/core';
|
|
23
23
|
import type { EventColumnName } from './matchSql.js';
|
|
24
24
|
/**
|
|
25
25
|
* Serialise a value to a JSON STRING for transport as a `::jsonb`-cast bound
|
|
@@ -45,9 +45,11 @@ export declare const toQueryItemsJson: (query: Query) => ReadonlyArray<QueryItem
|
|
|
45
45
|
/**
|
|
46
46
|
* The per-column TS types of the transport JSON shape — one entry per
|
|
47
47
|
* `EVENT_COLUMNS` name. `data` is base64 TEXT and `occurred_at` an ISO string
|
|
48
|
-
* (both restored in SQL: `decode(…, 'base64')` / `timestamptz`);
|
|
49
|
-
*
|
|
50
|
-
* the
|
|
48
|
+
* (both restored in SQL: `decode(…, 'base64')` / `timestamptz`); `metadata`
|
|
49
|
+
* travels as a nested JSON object, which `jsonb_to_recordset` hands to the
|
|
50
|
+
* insert as `jsonb` untouched; the rest map straight across. Kept as a plain
|
|
51
|
+
* map so `EventJson` below is a mapped type over the ONE column descriptor
|
|
52
|
+
* rather than a hand-restated column list.
|
|
51
53
|
*/
|
|
52
54
|
interface EventJsonColumns {
|
|
53
55
|
readonly type: string;
|
|
@@ -55,6 +57,7 @@ interface EventJsonColumns {
|
|
|
55
57
|
readonly tags: ReadonlyArray<string>;
|
|
56
58
|
readonly uuid: string;
|
|
57
59
|
readonly occurred_at: string;
|
|
60
|
+
readonly metadata: Metadata;
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* The JSON shape of one event as sent to the append functions, as a mapped type
|
|
@@ -73,7 +76,10 @@ export declare const toEventJson: (event: DcbEvent) => EventJson;
|
|
|
73
76
|
/**
|
|
74
77
|
* The per-column TS types of a raw driver row — one entry per `EVENT_COLUMNS`
|
|
75
78
|
* name. These are node-postgres's decoded JS types: `data` a `Buffer` (or null
|
|
76
|
-
* for a payload-less event), `occurred_at` a JS `Date`, `tags` a `string[]
|
|
79
|
+
* for a payload-less event), `occurred_at` a JS `Date`, `tags` a `string[]`,
|
|
80
|
+
* `metadata` whatever node-postgres parses a `jsonb` value into — declared
|
|
81
|
+
* `unknown`, because `jsonb` is the one column here whose SQL type does not
|
|
82
|
+
* fix its JS shape, and `metadataFrom` below is where it is checked. `id`
|
|
77
83
|
* (the `bigserial` position) is NOT here — it is prepended by the read projection
|
|
78
84
|
* and absent from the events recordset, so it sits outside the shared descriptor.
|
|
79
85
|
*/
|
|
@@ -83,6 +89,7 @@ interface EventRowColumns {
|
|
|
83
89
|
readonly tags: ReadonlyArray<string>;
|
|
84
90
|
readonly uuid: string;
|
|
85
91
|
readonly occurred_at: Date;
|
|
92
|
+
readonly metadata: unknown;
|
|
86
93
|
}
|
|
87
94
|
/**
|
|
88
95
|
* A raw row from the main table as node-postgres returns it, as `id` plus a
|
|
@@ -99,7 +106,10 @@ export type EventRow = {
|
|
|
99
106
|
/**
|
|
100
107
|
* Map a raw main-table row to a core `SequencedEvent`. `data` NULL → empty bytes
|
|
101
108
|
* (a payload-less event round-trips to a zero-length `Uint8Array`); `occurred_at`
|
|
102
|
-
* Date → `DateTime.Utc`; `id` string → branded `Position
|
|
109
|
+
* Date → `DateTime.Utc`; `id` string → branded `Position`; `metadata` through
|
|
110
|
+
* `metadataFrom`. The column is `NOT NULL DEFAULT '{}'`, so there is no absent
|
|
111
|
+
* case to reconcile: an event appended with an empty bag reads back as `{}` on
|
|
112
|
+
* this engine exactly as on the in-memory oracle.
|
|
103
113
|
*
|
|
104
114
|
* The branded scalars (`type`, `tags`, `uuid`, `position`) are minted by trusted
|
|
105
115
|
* `as`-cast, NOT by re-running `EventType.make` / `Tag.make` etc. This is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/internal/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/internal/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EAER,KAAK,EACL,cAAc,EACf,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MAA+B,CAAA;AAE1E,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,GAAI,OAAO,KAAK,KAAG,aAAa,CAAC,aAAa,CAItE,CAAA;AAEL;;;;;;;;GAQG;AACH,UAAU,gBAAg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"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAkDA,OAAO,EAGL,aAAa,EAQd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAA6B,KAAK,EAAsB,MAAM,QAAQ,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAoU9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,SAAQ,mBAAwB,KAC/B,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,cAAc,GAAG,cAAc,CASnE,CAAA"}
|
package/dist/esm/ensureSchema.js
CHANGED
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
* consumer, this package only provides the idempotent PAYLOAD.
|
|
19
19
|
*
|
|
20
20
|
* Idempotence: every statement is `CREATE … IF NOT EXISTS` or `CREATE OR REPLACE
|
|
21
|
-
* FUNCTION`, so re-running
|
|
21
|
+
* FUNCTION`, so re-running it is safe. It is NOT a no-op across versions: a
|
|
22
|
+
* re-run replaces the append functions with this version's, and does NOT alter
|
|
23
|
+
* an existing table, so a column a newer version adds must be added by hand
|
|
24
|
+
* before the re-run (the release notes give the statement). A store whose
|
|
25
|
+
* table gained a column but whose functions were never replaced keeps writing
|
|
26
|
+
* through the old ones, which do not know the column. Names come from
|
|
22
27
|
* `sql(identifier)` (via the pre-quoted builder in `internal/ddl.ts`); the DDL
|
|
23
28
|
* bodies carry no bound values (pure schema), and the append functions keep
|
|
24
29
|
* their runtime VALUES as bound parameters, never interpolated.
|