@ddd-ts-kit/kernel 0.110.1 → 0.112.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/README.fr.md +81 -17
- package/README.md +76 -13
- package/dist/application/criteria/filter-operator.d.ts +1 -1
- package/dist/application/criteria/filter-operator.d.ts.map +1 -1
- package/dist/application/criteria/filter-violations.d.ts.map +1 -1
- package/dist/application/criteria/filter-violations.js +4 -3
- package/dist/application/criteria/filter-violations.js.map +1 -1
- package/dist/application/criteria/finds-text.d.ts +4 -0
- package/dist/application/criteria/finds-text.d.ts.map +1 -0
- package/dist/application/criteria/finds-text.js +12 -0
- package/dist/application/criteria/finds-text.js.map +1 -0
- package/dist/application/criteria/fold-case.d.ts +14 -0
- package/dist/application/criteria/fold-case.d.ts.map +1 -0
- package/dist/application/criteria/fold-case.js +16 -0
- package/dist/application/criteria/fold-case.js.map +1 -0
- package/dist/application/criteria/holds.d.ts.map +1 -1
- package/dist/application/criteria/holds.js +5 -4
- package/dist/application/criteria/holds.js.map +1 -1
- package/dist/application/criteria/index.d.ts +3 -0
- package/dist/application/criteria/index.d.ts.map +1 -1
- package/dist/application/criteria/index.js +3 -0
- package/dist/application/criteria/index.js.map +1 -1
- package/dist/application/criteria/is-text-search.d.ts +5 -0
- package/dist/application/criteria/is-text-search.d.ts.map +1 -0
- package/dist/application/criteria/is-text-search.js +11 -0
- package/dist/application/criteria/is-text-search.js.map +1 -0
- package/dist/application/criteria/operand-of.d.ts +2 -1
- package/dist/application/criteria/operand-of.d.ts.map +1 -1
- package/dist/application/criteria/operator-of.d.ts +2 -1
- package/dist/application/criteria/operator-of.d.ts.map +1 -1
- package/dist/application/criteria/operators-of-type.js +1 -1
- package/dist/application/criteria/operators-of-type.js.map +1 -1
- package/dist/application/criteria/text-search.d.ts +3 -0
- package/dist/application/criteria/text-search.d.ts.map +1 -0
- package/dist/application/criteria/text-search.js +2 -0
- package/dist/application/criteria/text-search.js.map +1 -0
- package/dist/application/files/content-expectation.d.ts +6 -0
- package/dist/application/files/content-expectation.d.ts.map +1 -1
- package/dist/application/files/content-matches.d.ts +12 -3
- package/dist/application/files/content-matches.d.ts.map +1 -1
- package/dist/application/files/content-matches.js +23 -28
- package/dist/application/files/content-matches.js.map +1 -1
- package/dist/application/files/content-rule-defects.d.ts +9 -0
- package/dist/application/files/content-rule-defects.d.ts.map +1 -0
- package/dist/application/files/content-rule-defects.js +57 -0
- package/dist/application/files/content-rule-defects.js.map +1 -0
- package/dist/application/files/content-rule-of.d.ts +11 -0
- package/dist/application/files/content-rule-of.d.ts.map +1 -0
- package/dist/application/files/content-rule-of.js +28 -0
- package/dist/application/files/content-rule-of.js.map +1 -0
- package/dist/application/files/content-rule.d.ts +4 -0
- package/dist/application/files/content-rule.d.ts.map +1 -0
- package/dist/application/files/content-rule.js +2 -0
- package/dist/application/files/content-rule.js.map +1 -0
- package/dist/application/files/content-rules.d.ts +4 -0
- package/dist/application/files/content-rules.d.ts.map +1 -0
- package/dist/application/files/content-rules.js +2 -0
- package/dist/application/files/content-rules.js.map +1 -0
- package/dist/application/files/index.d.ts +10 -0
- package/dist/application/files/index.d.ts.map +1 -1
- package/dist/application/files/index.js +10 -0
- package/dist/application/files/index.js.map +1 -1
- package/dist/application/files/is-utf8.d.ts +8 -0
- package/dist/application/files/is-utf8.d.ts.map +1 -0
- package/dist/application/files/is-utf8.js +16 -0
- package/dist/application/files/is-utf8.js.map +1 -0
- package/dist/application/files/looks-like-text.d.ts +8 -0
- package/dist/application/files/looks-like-text.d.ts.map +1 -0
- package/dist/application/files/looks-like-text.js +28 -0
- package/dist/application/files/looks-like-text.js.map +1 -0
- package/dist/application/files/named-only-media-types.d.ts +6 -0
- package/dist/application/files/named-only-media-types.d.ts.map +1 -0
- package/dist/application/files/named-only-media-types.js +12 -0
- package/dist/application/files/named-only-media-types.js.map +1 -0
- package/dist/application/files/signed-media-types.d.ts +3 -0
- package/dist/application/files/signed-media-types.d.ts.map +1 -0
- package/dist/application/files/signed-media-types.js +13 -0
- package/dist/application/files/signed-media-types.js.map +1 -0
- package/dist/application/files/stated-content-rule.d.ts +7 -0
- package/dist/application/files/stated-content-rule.d.ts.map +1 -0
- package/dist/application/files/stated-content-rule.js +2 -0
- package/dist/application/files/stated-content-rule.js.map +1 -0
- package/dist/application/files/text-media-types.d.ts +3 -0
- package/dist/application/files/text-media-types.d.ts.map +1 -0
- package/dist/application/files/text-media-types.js +10 -0
- package/dist/application/files/text-media-types.js.map +1 -0
- package/dist/application/files/text-rule.d.ts +17 -0
- package/dist/application/files/text-rule.d.ts.map +1 -0
- package/dist/application/files/text-rule.js +2 -0
- package/dist/application/files/text-rule.js.map +1 -0
- package/dist/application/files/zip-containers.d.ts +3 -0
- package/dist/application/files/zip-containers.d.ts.map +1 -0
- package/dist/application/files/zip-containers.js +10 -0
- package/dist/application/files/zip-containers.js.map +1 -0
- package/dist/application/persistence/advisory-lock-options.d.ts +10 -0
- package/dist/application/persistence/advisory-lock-options.d.ts.map +1 -0
- package/dist/application/persistence/advisory-lock-options.js +2 -0
- package/dist/application/persistence/advisory-lock-options.js.map +1 -0
- package/dist/application/ports/read-model-rows.d.ts +8 -2
- package/dist/application/ports/read-model-rows.d.ts.map +1 -1
- package/dist/application/ports/read-model-rows.js.map +1 -1
- package/dist/application/ports/read-model-store.d.ts +29 -3
- package/dist/application/ports/read-model-store.d.ts.map +1 -1
- package/dist/application/ports/read-model-store.js +8 -1
- package/dist/application/ports/read-model-store.js.map +1 -1
- package/dist/application/ports/read-model-table.d.ts +7 -0
- package/dist/application/ports/read-model-table.d.ts.map +1 -1
- package/dist/application/ports/read-model-table.js.map +1 -1
- package/dist/application/read-model/event-stamp.d.ts +4 -2
- package/dist/application/read-model/event-stamp.d.ts.map +1 -1
- package/dist/application/read-model/is-newer.d.ts +8 -1
- package/dist/application/read-model/is-newer.d.ts.map +1 -1
- package/dist/application/read-model/is-newer.js +8 -1
- package/dist/application/read-model/is-newer.js.map +1 -1
- package/dist/application/read-model/read-model-table-state.d.ts +53 -0
- package/dist/application/read-model/read-model-table-state.d.ts.map +1 -0
- package/dist/application/read-model/read-model-table-state.js +2 -0
- package/dist/application/read-model/read-model-table-state.js.map +1 -0
- package/dist/application/read-model/read-model-write.d.ts +9 -4
- package/dist/application/read-model/read-model-write.d.ts.map +1 -1
- package/dist/application/read-model/same-stamp.d.ts +8 -0
- package/dist/application/read-model/same-stamp.d.ts.map +1 -0
- package/dist/application/read-model/same-stamp.js +11 -0
- package/dist/application/read-model/same-stamp.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts +2 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts.map +1 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js +2 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js.map +1 -1
- package/dist/infrastructure/files/file-inspection.js +1 -1
- package/dist/infrastructure/files/file-inspection.js.map +1 -1
- package/dist/infrastructure/files/file-staging.d.ts +4 -2
- package/dist/infrastructure/files/file-staging.d.ts.map +1 -1
- package/dist/infrastructure/files/file-staging.js +14 -6
- package/dist/infrastructure/files/file-staging.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-read-model-table.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-read-model-table.js +2 -6
- package/dist/infrastructure/in-memory/in-memory-read-model-table.js.map +1 -1
- package/dist/infrastructure/persistence/advisory-lock-key.d.ts +16 -0
- package/dist/infrastructure/persistence/advisory-lock-key.d.ts.map +1 -0
- package/dist/infrastructure/persistence/advisory-lock-key.js +18 -0
- package/dist/infrastructure/persistence/advisory-lock-key.js.map +1 -0
- package/dist/infrastructure/persistence/advisory-lock-outside-unit-of-work-error.d.ts +9 -0
- package/dist/infrastructure/persistence/advisory-lock-outside-unit-of-work-error.d.ts.map +1 -0
- package/dist/infrastructure/persistence/advisory-lock-outside-unit-of-work-error.js +12 -0
- package/dist/infrastructure/persistence/advisory-lock-outside-unit-of-work-error.js.map +1 -0
- package/dist/infrastructure/read-model/database-failure.d.ts +19 -0
- package/dist/infrastructure/read-model/database-failure.d.ts.map +1 -0
- package/dist/infrastructure/read-model/database-failure.js +71 -0
- package/dist/infrastructure/read-model/database-failure.js.map +1 -0
- package/dist/infrastructure/read-model/live-rows-columns-of.d.ts +7 -0
- package/dist/infrastructure/read-model/live-rows-columns-of.d.ts.map +1 -0
- package/dist/infrastructure/read-model/live-rows-columns-of.js +20 -0
- package/dist/infrastructure/read-model/live-rows-columns-of.js.map +1 -0
- package/dist/infrastructure/read-model/live-rows-constraint-form.d.ts +11 -0
- package/dist/infrastructure/read-model/live-rows-constraint-form.d.ts.map +1 -0
- package/dist/infrastructure/read-model/live-rows-constraint-form.js +13 -0
- package/dist/infrastructure/read-model/live-rows-constraint-form.js.map +1 -0
- package/dist/infrastructure/read-model/live-rows-constraint-of.d.ts +6 -0
- package/dist/infrastructure/read-model/live-rows-constraint-of.d.ts.map +1 -0
- package/dist/infrastructure/read-model/live-rows-constraint-of.js +18 -0
- package/dist/infrastructure/read-model/live-rows-constraint-of.js.map +1 -0
- package/dist/infrastructure/read-model/postgres-trace-columns.d.ts +34 -0
- package/dist/infrastructure/read-model/postgres-trace-columns.d.ts.map +1 -0
- package/dist/infrastructure/read-model/postgres-trace-columns.js +124 -0
- package/dist/infrastructure/read-model/postgres-trace-columns.js.map +1 -0
- package/dist/infrastructure/read-model/projection-rebuild.d.ts +4 -1
- package/dist/infrastructure/read-model/projection-rebuild.d.ts.map +1 -1
- package/dist/infrastructure/read-model/projection-rebuild.js +4 -1
- package/dist/infrastructure/read-model/projection-rebuild.js.map +1 -1
- package/dist/infrastructure/read-model/read-model-key-held-elsewhere-error.d.ts +12 -0
- package/dist/infrastructure/read-model/read-model-key-held-elsewhere-error.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-key-held-elsewhere-error.js +16 -0
- package/dist/infrastructure/read-model/read-model-key-held-elsewhere-error.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-migration.d.ts +31 -0
- package/dist/infrastructure/read-model/read-model-table-migration.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-migration.js +82 -0
- package/dist/infrastructure/read-model/read-model-table-migration.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-not-ready-error.d.ts +28 -0
- package/dist/infrastructure/read-model/read-model-table-not-ready-error.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-not-ready-error.js +132 -0
- package/dist/infrastructure/read-model/read-model-table-not-ready-error.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-notes.d.ts +9 -0
- package/dist/infrastructure/read-model/read-model-table-notes.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-notes.js +36 -0
- package/dist/infrastructure/read-model/read-model-table-notes.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-ready.d.ts +4 -0
- package/dist/infrastructure/read-model/read-model-table-ready.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-table-ready.js +5 -0
- package/dist/infrastructure/read-model/read-model-table-ready.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-tables-not-ready-error.d.ts +24 -0
- package/dist/infrastructure/read-model/read-model-tables-not-ready-error.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-tables-not-ready-error.js +40 -0
- package/dist/infrastructure/read-model/read-model-tables-not-ready-error.js.map +1 -0
- package/dist/infrastructure/read-model/read-model-tables.d.ts +82 -0
- package/dist/infrastructure/read-model/read-model-tables.d.ts.map +1 -0
- package/dist/infrastructure/read-model/read-model-tables.js +161 -0
- package/dist/infrastructure/read-model/read-model-tables.js.map +1 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.d.ts +1 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.d.ts.map +1 -1
- package/dist/infrastructure/read-model/shadow-read-model-store.js +3 -0
- package/dist/infrastructure/read-model/shadow-read-model-store.js.map +1 -1
- package/dist/infrastructure/read-model/table-read-model-store.d.ts +8 -0
- package/dist/infrastructure/read-model/table-read-model-store.d.ts.map +1 -1
- package/dist/infrastructure/read-model/table-read-model-store.js +11 -0
- package/dist/infrastructure/read-model/table-read-model-store.js.map +1 -1
- package/dist/infrastructure/read-model/write-if-newer.d.ts +14 -2
- package/dist/infrastructure/read-model/write-if-newer.d.ts.map +1 -1
- package/dist/infrastructure/read-model/write-if-newer.js +35 -5
- package/dist/infrastructure/read-model/write-if-newer.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { liveRowsColumnsOf } from './live-rows-columns-of.js';
|
|
2
|
+
import { liveRowsConstraintOf } from './live-rows-constraint-of.js';
|
|
3
|
+
import { ReadModelTableNotReadyError } from './read-model-table-not-ready-error.js';
|
|
4
|
+
import { readModelTableReady } from './read-model-table-ready.js';
|
|
5
|
+
/** Every column of the table, as a statement resolves it: what a trace needs to know of each, and what kind of relation holds them. */
|
|
6
|
+
const COLUMNS = `select col.attname as "column", col.attnotnull as "refusing", col.attidentity <> '' as "identity", col.attgenerated <> '' as "generated", exists (select 1 from pg_index as pk where pk.indrelid = col.attrelid and pk.indisprimary and col.attnum = any (pk.indkey)) as "key", exists (select 1 from pg_type as typ where typ.oid = col.atttypid and typ.typtype = 'd' and typ.typnotnull) as "domain", (select rel.relkind::text from pg_class as rel where rel.oid = col.attrelid) as "relation" from pg_attribute as col where col.attrelid = to_regclass($1) and col.attnum > 0 and not col.attisdropped`;
|
|
7
|
+
/** Every check constraint of the table, as PostgreSQL writes it, with the columns it names. */
|
|
8
|
+
const CHECKS = `select con.conname as "name", con.convalidated as "valid", pg_get_constraintdef(con.oid) as "definition", array_to_json(array(select att.attname from pg_attribute as att where att.attrelid = con.conrelid and att.attnum = any (con.conkey)))::text as "columns" from pg_constraint as con where con.conrelid = to_regclass($1) and con.contype = 'c' order by con.conname`;
|
|
9
|
+
const RELATIONS = {
|
|
10
|
+
v: 'view',
|
|
11
|
+
m: 'materialized-view',
|
|
12
|
+
f: 'foreign-table',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Whether the table of a read model on PostgreSQL can hold the trace of a deleted row, read from
|
|
16
|
+
* the database for the columns the store maps and for no other: each accepts NULL, and none is a
|
|
17
|
+
* part of the primary key, an identity or a generated column, nor of a domain that refuses NULL,
|
|
18
|
+
* which nothing can open. The table is read as a statement would resolve it (the search path
|
|
19
|
+
* when no schema is named). `require` is the refusal of a store before its first trace, by name
|
|
20
|
+
* and not by a statement that would abort the transaction of the event; it reads once, and the
|
|
21
|
+
* check constraints only for a table it refuses. `state` is the same reading with the
|
|
22
|
+
* constraints, for the tables an application lists and checks when it starts
|
|
23
|
+
* (`ReadModelTables`): one code, so one verdict. The copy of a rebuild is made like the table.
|
|
24
|
+
* Shared by the ORM adapters, which differ only in how they run a statement.
|
|
25
|
+
*/
|
|
26
|
+
export class PostgresTraceColumns {
|
|
27
|
+
run;
|
|
28
|
+
target;
|
|
29
|
+
ready = false;
|
|
30
|
+
constructor(run, target) {
|
|
31
|
+
this.run = run;
|
|
32
|
+
this.target = target;
|
|
33
|
+
}
|
|
34
|
+
async require() {
|
|
35
|
+
if (this.ready) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const columns = await this.columns();
|
|
39
|
+
if (!readModelTableReady(columns)) {
|
|
40
|
+
throw new ReadModelTableNotReadyError(columns.exists ? await this.withChecks(columns) : columns);
|
|
41
|
+
}
|
|
42
|
+
this.ready = true;
|
|
43
|
+
}
|
|
44
|
+
/** What the table can hold, what its check constraint keeps whole and what else checks its row. */
|
|
45
|
+
async state() {
|
|
46
|
+
const columns = await this.columns();
|
|
47
|
+
return columns.exists ? this.withChecks(columns) : columns;
|
|
48
|
+
}
|
|
49
|
+
async columns() {
|
|
50
|
+
const { schema, table, data, deleted = 'deleted' } = this.target();
|
|
51
|
+
const read = await this.run(COLUMNS, [pathOf(schema, table)]);
|
|
52
|
+
const held = new Map(read.map((row) => [row['column'], row]));
|
|
53
|
+
const kinds = data.map((column) => ({ column, because: kindOf(held.get(column)) }));
|
|
54
|
+
const unfit = kinds.flatMap(({ column, because }) => (because === undefined ? [] : [{ column, because }]));
|
|
55
|
+
const row = data.filter((column) => !unfit.some((left) => left.column === column));
|
|
56
|
+
const relation = RELATIONS[String(read[0]?.['relation'])];
|
|
57
|
+
return {
|
|
58
|
+
table,
|
|
59
|
+
exists: held.size > 0,
|
|
60
|
+
refusing: held.size === 0 ? [] : row.filter((column) => held.get(column)?.['refusing'] === true),
|
|
61
|
+
unfit: held.size === 0 ? [] : unfit,
|
|
62
|
+
row,
|
|
63
|
+
deleted,
|
|
64
|
+
...(schema === undefined ? {} : { schema }),
|
|
65
|
+
...(relation === undefined ? {} : { relation }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async withChecks(columns) {
|
|
69
|
+
const { schema, table } = columns;
|
|
70
|
+
const name = liveRowsConstraintOf(table);
|
|
71
|
+
const checks = await this.run(CHECKS, [pathOf(schema, table)]);
|
|
72
|
+
const others = checks.filter((check) => check['name'] !== name).flatMap((check) => namingTheRow(check, columns));
|
|
73
|
+
return {
|
|
74
|
+
...columns,
|
|
75
|
+
constraint: constraintOf(checks.find((check) => check['name'] === name), columns.deleted),
|
|
76
|
+
...(others.length === 0 ? {} : { checks: others }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** The constraint of the live rows as the table holds it: the kit's form and what it keeps whole, or another check under its name. */
|
|
81
|
+
function constraintOf(held, deleted) {
|
|
82
|
+
if (held === undefined) {
|
|
83
|
+
return { state: 'missing', columns: [] };
|
|
84
|
+
}
|
|
85
|
+
const definition = String(held['definition']);
|
|
86
|
+
const whole = liveRowsColumnsOf(definition, deleted);
|
|
87
|
+
if (whole === undefined) {
|
|
88
|
+
return { state: 'unexpected', columns: [], definition };
|
|
89
|
+
}
|
|
90
|
+
return { state: held['valid'] === true ? 'held' : 'not-valid', columns: whole };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Another check constraint, when it names a column of the row: it may refuse the NULL of a trace
|
|
94
|
+
* there. One that holds for the live rows only, written `deleted or ..` as PostgreSQL prints it,
|
|
95
|
+
* lets every trace in and is not named.
|
|
96
|
+
*/
|
|
97
|
+
function namingTheRow(check, { row, deleted }) {
|
|
98
|
+
const named = JSON.parse(String(check['columns']));
|
|
99
|
+
const definition = String(check['definition']);
|
|
100
|
+
const live = [deleted, quoted(deleted)].some((mark) => definition.startsWith(`CHECK ((${mark} OR `));
|
|
101
|
+
return !live && Array.isArray(named) && named.some((column) => row.includes(String(column)))
|
|
102
|
+
? [{ name: String(check['name']), definition }]
|
|
103
|
+
: [];
|
|
104
|
+
}
|
|
105
|
+
const KINDS = [
|
|
106
|
+
['key', 'primary-key'],
|
|
107
|
+
['identity', 'identity'],
|
|
108
|
+
['generated', 'generated'],
|
|
109
|
+
['domain', 'domain'],
|
|
110
|
+
];
|
|
111
|
+
/** Why a trace can never hold NULL in the column, when it cannot. */
|
|
112
|
+
function kindOf(column) {
|
|
113
|
+
if (column === undefined) {
|
|
114
|
+
return 'absent';
|
|
115
|
+
}
|
|
116
|
+
return KINDS.find(([flag]) => column[flag] === true)?.[1];
|
|
117
|
+
}
|
|
118
|
+
function pathOf(schema, table) {
|
|
119
|
+
return schema === undefined ? quoted(table) : `${quoted(schema)}.${quoted(table)}`;
|
|
120
|
+
}
|
|
121
|
+
function quoted(identifier) {
|
|
122
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=postgres-trace-columns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-trace-columns.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/postgres-trace-columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,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31
|
+
/**
|
|
32
|
+
* The source no longer has the row: the copy takes the trace the table holds of its deletion,
|
|
33
|
+
* if it has one, whether or not the copy held the row yet.
|
|
34
|
+
*/
|
|
32
35
|
private forget;
|
|
33
36
|
}
|
|
34
37
|
//# sourceMappingURL=projection-rebuild.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection-rebuild.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/projection-rebuild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAItF,MAAM,WAAW,sBAAsB,CAAC,GAAG;IACzC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,mGAAmG;IACnG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAE,sBAAsB,CAAC,GAAG,CAAC,EAAI;IAE7D,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAiB5C;YAEa,IAAI;YAmBJ,OAAO;YAkBP,IAAI;YAeJ,SAAS;IAmBvB
|
|
1
|
+
{"version":3,"file":"projection-rebuild.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/projection-rebuild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAItF,MAAM,WAAW,sBAAsB,CAAC,GAAG;IACzC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,mGAAmG;IACnG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAE,sBAAsB,CAAC,GAAG,CAAC,EAAI;IAE7D,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAiB5C;YAEa,IAAI;YAmBJ,OAAO;YAkBP,IAAI;YAeJ,SAAS;IAmBvB;;;OAGG;YACW,MAAM;CAOrB"}
|
|
@@ -77,7 +77,10 @@ export class ProjectionRebuild {
|
|
|
77
77
|
await table.settle(keys);
|
|
78
78
|
return keys.length;
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* The source no longer has the row: the copy takes the trace the table holds of its deletion,
|
|
82
|
+
* if it has one, whether or not the copy held the row yet.
|
|
83
|
+
*/
|
|
81
84
|
async forget(key) {
|
|
82
85
|
const live = await this.parts.table.find(key);
|
|
83
86
|
if (live !== undefined && live.row === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection-rebuild.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/projection-rebuild.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAehD;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IACC,KAAK;IAAlC,YAA6B,KAAkC;qBAAlC,KAAK;IAAgC,CAAC;IAEnE,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzC,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;QAE3B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAErD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;YAE7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACrC,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,MAA0B,CAAC;QAE/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AK,SAAS,EAAE,CAAC;YACjD,MAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConcurrencyError } from '../../domain/errors/concurrency-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* A write found nothing under its key, its insert was refused by a conflict, and the next read
|
|
4
|
+
* still found nothing: the key is held out of the reach of this work, by another tenant. The key
|
|
5
|
+
* of a read model is unique across tenants. A `ConcurrencyError`, so what catches that still does,
|
|
6
|
+
* but one no retry settles.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ReadModelKeyHeldElsewhereError extends ConcurrencyError {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
constructor(key: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=read-model-key-held-elsewhere-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-key-held-elsewhere-error.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-key-held-elsewhere-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,gBAAgB;IACtD,QAAQ,CAAC,GAAG,EAAE,MAAM;IAAhC,YAAqB,GAAG,EAAE,MAAM,EAI/B;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConcurrencyError } from '../../domain/errors/concurrency-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* A write found nothing under its key, its insert was refused by a conflict, and the next read
|
|
4
|
+
* still found nothing: the key is held out of the reach of this work, by another tenant. The key
|
|
5
|
+
* of a read model is unique across tenants. A `ConcurrencyError`, so what catches that still does,
|
|
6
|
+
* but one no retry settles.
|
|
7
|
+
*/
|
|
8
|
+
export class ReadModelKeyHeldElsewhereError extends ConcurrencyError {
|
|
9
|
+
key;
|
|
10
|
+
constructor(key) {
|
|
11
|
+
super(key);
|
|
12
|
+
this.key = key;
|
|
13
|
+
this.message = `The key "${key}" of the read model is held by another tenant: the key of a read model is unique across tenants. When two tenants can use the same key, make the key carry the tenant (acme:${key}) or generate it`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=read-model-key-held-elsewhere-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-key-held-elsewhere-error.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-key-held-elsewhere-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,gBAAgB;IAC7C,GAAG;IAAxB,YAAqB,GAAW;QAC9B,KAAK,CAAC,GAAG,CAAC,CAAC;mBADQ,GAAG;QAGtB,IAAI,CAAC,OAAO,GAAG,YAAY,GAAG,+KAA+K,GAAG,kBAAkB,CAAC;IACrO,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
|
|
2
|
+
/** The migration of a read model table, in the two steps a large table runs apart. */
|
|
3
|
+
interface ReadModelTableMigration {
|
|
4
|
+
/**
|
|
5
|
+
* The change of definition: NOT NULL dropped and the check constraint written, `not valid`, in
|
|
6
|
+
* one statement. Brief, under the lock that stops the readers and the writers of the table.
|
|
7
|
+
*/
|
|
8
|
+
readonly definition: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* The validation of the constraint and the cleaning of the rows deleted before: both read the
|
|
11
|
+
* whole table under a lock that lets readers and writers through, when they run outside the
|
|
12
|
+
* transaction of the first step.
|
|
13
|
+
*/
|
|
14
|
+
readonly validation: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The migration that makes a read model table ready, PostgreSQL statements written from the
|
|
18
|
+
* columns the store maps and from nothing else. NOT NULL is dropped on the columns of the row
|
|
19
|
+
* that refuse it and, in the same statement, the check constraint that keeps the live rows whole
|
|
20
|
+
* is written again when it is missing or does not hold those columns, `not valid`: no row can be
|
|
21
|
+
* written between the two, whatever commits each statement. A constraint of that name that is
|
|
22
|
+
* not written as the kit writes it is never dropped: the statement reads its definition first and
|
|
23
|
+
* fails on it, on the database it runs against. Then the constraint is validated and the rows
|
|
24
|
+
* deleted before are emptied, those that still hold data alone. Run twice, it ends where it ended
|
|
25
|
+
* the first time and fails on nothing. It never names the key, the tenant, the stamp, a column
|
|
26
|
+
* the store does not map, nor one that is unfit. Nothing is written while the definition alone
|
|
27
|
+
* was read.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readModelTableMigration(state: ReadModelTableState): ReadModelTableMigration;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=read-model-table-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-migration.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAE/F,sFAAsF;AACtF,UAAU,uBAAuB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,uBAAuB,CAwB3F"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LIVE_ROWS_CONSTRAINT_FORM } from './live-rows-constraint-form.js';
|
|
2
|
+
import { liveRowsConstraintOf } from './live-rows-constraint-of.js';
|
|
3
|
+
/**
|
|
4
|
+
* The migration that makes a read model table ready, PostgreSQL statements written from the
|
|
5
|
+
* columns the store maps and from nothing else. NOT NULL is dropped on the columns of the row
|
|
6
|
+
* that refuse it and, in the same statement, the check constraint that keeps the live rows whole
|
|
7
|
+
* is written again when it is missing or does not hold those columns, `not valid`: no row can be
|
|
8
|
+
* written between the two, whatever commits each statement. A constraint of that name that is
|
|
9
|
+
* not written as the kit writes it is never dropped: the statement reads its definition first and
|
|
10
|
+
* fails on it, on the database it runs against. Then the constraint is validated and the rows
|
|
11
|
+
* deleted before are emptied, those that still hold data alone. Run twice, it ends where it ended
|
|
12
|
+
* the first time and fails on nothing. It never names the key, the tenant, the stamp, a column
|
|
13
|
+
* the store does not map, nor one that is unfit. Nothing is written while the definition alone
|
|
14
|
+
* was read.
|
|
15
|
+
*/
|
|
16
|
+
export function readModelTableMigration(state) {
|
|
17
|
+
const { refusing, row, constraint } = state;
|
|
18
|
+
if (constraint === undefined || refusing.length === 0) {
|
|
19
|
+
return { definition: [], validation: constraint?.state === 'not-valid' ? [validated(state)] : [] };
|
|
20
|
+
}
|
|
21
|
+
const whole = [...new Set([...constraint.columns, ...refusing])];
|
|
22
|
+
const held = row.map((column) => `${quoted(column)} is not null`).join(' or ');
|
|
23
|
+
const emptied = row.map((column) => `${quoted(column)} = null`).join(', ');
|
|
24
|
+
const cleaned = `update ${pathOf(state)} set ${emptied} where ${quoted(state.deleted)} and (${held});`;
|
|
25
|
+
if (constraint.state === 'unexpected') {
|
|
26
|
+
return { definition: [`alter table ${pathOf(state)} ${opened(state)};`], validation: [cleaned] };
|
|
27
|
+
}
|
|
28
|
+
if (constraint.state !== 'missing' && whole.length === constraint.columns.length) {
|
|
29
|
+
return {
|
|
30
|
+
definition: [`alter table ${pathOf(state)} ${opened(state)};`],
|
|
31
|
+
validation: [...(constraint.state === 'not-valid' ? [validated(state)] : []), cleaned],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return { definition: [rewritten(state, whole)], validation: [validated(state), cleaned] };
|
|
35
|
+
}
|
|
36
|
+
function opened({ refusing }) {
|
|
37
|
+
return refusing.map((column) => `alter column ${quoted(column)} drop not null`).join(', ');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* NOT NULL dropped and the constraint written again in one statement, once the constraint the
|
|
41
|
+
* database holds under that name, if any, is known to be the kit's.
|
|
42
|
+
*/
|
|
43
|
+
function rewritten(state, whole) {
|
|
44
|
+
const path = pathOf(state);
|
|
45
|
+
const name = liveRowsConstraintOf(state.table);
|
|
46
|
+
const checked = whole.map((column) => `${quoted(column)} is not null`).join(' and ');
|
|
47
|
+
const table = state.schema === undefined ? state.table : `${state.schema}.${state.table}`;
|
|
48
|
+
const refused = `The constraint ${name} of ${table} is not written as ddd-ts-kit writes the one that keeps the live rows of a read model whole: it is left as it is, and nothing was changed.`;
|
|
49
|
+
const body = [
|
|
50
|
+
'begin',
|
|
51
|
+
` if exists (select 1 from pg_constraint where conrelid = to_regclass(${literal(path)}) and conname = ${literal(name)} and pg_get_constraintdef(oid) !~ ${literal(LIVE_ROWS_CONSTRAINT_FORM)}) then`,
|
|
52
|
+
` raise exception ${literal(refused.replaceAll('%', '%%'))};`,
|
|
53
|
+
' end if;',
|
|
54
|
+
` alter table ${path} ${opened(state)}, drop constraint if exists ${quoted(name)}, add constraint ${quoted(name)} check (${quoted(state.deleted)} or (${checked})) not valid;`,
|
|
55
|
+
'end',
|
|
56
|
+
].join('\n');
|
|
57
|
+
const tag = dollarTagFor(body);
|
|
58
|
+
return `do ${tag}\n${body}\n${tag};`;
|
|
59
|
+
}
|
|
60
|
+
/** A dollar quote no name of the statement can close: `$kit$`, lengthened while the body holds it. */
|
|
61
|
+
function dollarTagFor(body) {
|
|
62
|
+
let tag = 'kit';
|
|
63
|
+
while (body.includes(`$${tag}$`)) {
|
|
64
|
+
tag += '_';
|
|
65
|
+
}
|
|
66
|
+
return `$${tag}$`;
|
|
67
|
+
}
|
|
68
|
+
function validated(state) {
|
|
69
|
+
return `alter table ${pathOf(state)} validate constraint ${quoted(liveRowsConstraintOf(state.table))};`;
|
|
70
|
+
}
|
|
71
|
+
/** The table as a statement names it: its schema first when it has one. */
|
|
72
|
+
function pathOf({ schema, table }) {
|
|
73
|
+
return schema === undefined ? quoted(table) : `${quoted(schema)}.${quoted(table)}`;
|
|
74
|
+
}
|
|
75
|
+
/** Every identifier is quoted: a reserved word, a capital or a hyphen is then written as the database holds it. */
|
|
76
|
+
function quoted(identifier) {
|
|
77
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
78
|
+
}
|
|
79
|
+
function literal(text) {
|
|
80
|
+
return `'${text.replaceAll("'", "''")}'`;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=read-model-table-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-migration.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAkBjE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA0B;IAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE5C,IAAI,UAAU,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrG,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,QAAQ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QAAQ,OAAO,eAAe;QAC/K,KAAK;KACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,MAAM,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG,CAAC;AACvC,CAAC;AAED,sGAAsG;AACtG,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,GAAG,GAAG,KAAK,CAAC;IAEhB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;QACjC,GAAG,IAAI,GAAG,CAAC;IACb,CAAC;IAED,OAAO,IAAI,GAAG,GAAG,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,KAA0B;IAC3C,OAAO,eAAe,MAAM,CAAC,KAAK,CAAC,wBAAwB,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AAC1G,CAAC;AAED,2EAA2E;AAC3E,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAuB;IACpD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,mHAAmH;AACnH,SAAS,MAAM,CAAC,UAAkB;IAChC,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AACjD,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readModelTableMigration } from './read-model-table-migration.js';
|
|
2
|
+
import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
|
|
3
|
+
/**
|
|
4
|
+
* The table of a read model cannot hold the trace of a deleted row: its key, its tenant and its
|
|
5
|
+
* stamp, NULL in every other column the store maps. An adapter raises it from the definition of
|
|
6
|
+
* the table when the store is built, or from one read of its columns before the first trace,
|
|
7
|
+
* never from a statement the database would refuse, since on PostgreSQL that refusal aborts the
|
|
8
|
+
* transaction of the event. Its message names the table, what keeps it from holding a trace,
|
|
9
|
+
* what is known of the check constraint of the live rows, and the migration to write, which
|
|
10
|
+
* names the columns the store maps and no other.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ReadModelTableNotReadyError extends Error {
|
|
13
|
+
readonly state: ReadModelTableState;
|
|
14
|
+
/** The table as it is said: `scheduling.agenda`. */
|
|
15
|
+
readonly table: string;
|
|
16
|
+
/** The columns of the row that refuse NULL. */
|
|
17
|
+
readonly columns: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* The migration to write, in the two steps a large table runs apart: the change of definition,
|
|
20
|
+
* then the validation of the constraint and the cleaning of the rows deleted before. Both empty
|
|
21
|
+
* when no migration makes the table ready.
|
|
22
|
+
*/
|
|
23
|
+
readonly steps: ReturnType<typeof readModelTableMigration>;
|
|
24
|
+
/** The statements of both steps, in order. */
|
|
25
|
+
readonly statements: readonly string[];
|
|
26
|
+
constructor(state: ReadModelTableState);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=read-model-table-not-ready-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-not-ready-error.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-not-ready-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAE/F;;;;;;;;GAQG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IAiBxC,QAAQ,CAAC,KAAK,EAAE,mBAAmB;IAhB/C,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IAE3D,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,YAAqB,KAAK,EAAE,mBAAmB,EAiB9C;CACF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { liveRowsConstraintOf } from './live-rows-constraint-of.js';
|
|
2
|
+
import { readModelTableMigration } from './read-model-table-migration.js';
|
|
3
|
+
/**
|
|
4
|
+
* The table of a read model cannot hold the trace of a deleted row: its key, its tenant and its
|
|
5
|
+
* stamp, NULL in every other column the store maps. An adapter raises it from the definition of
|
|
6
|
+
* the table when the store is built, or from one read of its columns before the first trace,
|
|
7
|
+
* never from a statement the database would refuse, since on PostgreSQL that refusal aborts the
|
|
8
|
+
* transaction of the event. Its message names the table, what keeps it from holding a trace,
|
|
9
|
+
* what is known of the check constraint of the live rows, and the migration to write, which
|
|
10
|
+
* names the columns the store maps and no other.
|
|
11
|
+
*/
|
|
12
|
+
export class ReadModelTableNotReadyError extends Error {
|
|
13
|
+
state;
|
|
14
|
+
/** The table as it is said: `scheduling.agenda`. */
|
|
15
|
+
table;
|
|
16
|
+
/** The columns of the row that refuse NULL. */
|
|
17
|
+
columns;
|
|
18
|
+
/**
|
|
19
|
+
* The migration to write, in the two steps a large table runs apart: the change of definition,
|
|
20
|
+
* then the validation of the constraint and the cleaning of the rows deleted before. Both empty
|
|
21
|
+
* when no migration makes the table ready.
|
|
22
|
+
*/
|
|
23
|
+
steps;
|
|
24
|
+
/** The statements of both steps, in order. */
|
|
25
|
+
statements;
|
|
26
|
+
constructor(state) {
|
|
27
|
+
const table = state.schema === undefined ? state.table : `${state.schema}.${state.table}`;
|
|
28
|
+
const steps = readModelTableMigration(state);
|
|
29
|
+
super([
|
|
30
|
+
`The read model table ${table} cannot hold the trace of a deleted row: ${reasonsOf(state).join('; ')}.`,
|
|
31
|
+
...adviceOf(state, table),
|
|
32
|
+
...migrationOf(steps),
|
|
33
|
+
].join(' '));
|
|
34
|
+
this.state = state;
|
|
35
|
+
this.name = 'ReadModelTableNotReadyError';
|
|
36
|
+
this.table = table;
|
|
37
|
+
this.columns = state.refusing;
|
|
38
|
+
this.steps = steps;
|
|
39
|
+
this.statements = [...steps.definition, ...steps.validation];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const UNFIT = {
|
|
43
|
+
'primary-key': 'is part of the primary key',
|
|
44
|
+
identity: 'is an identity column',
|
|
45
|
+
generated: 'is a generated column',
|
|
46
|
+
domain: 'is of a domain that refuses NULL',
|
|
47
|
+
absent: 'is not a column of the table',
|
|
48
|
+
};
|
|
49
|
+
function reasonsOf({ exists, refusing, unfit }) {
|
|
50
|
+
if (!exists) {
|
|
51
|
+
return ['it is not in this database'];
|
|
52
|
+
}
|
|
53
|
+
const named = refusing.map((column) => `"${column}"`).join(', ');
|
|
54
|
+
return [
|
|
55
|
+
...(refusing.length === 0 ? [] : [`${named} ${refusing.length === 1 ? 'refuses' : 'refuse'} NULL`]),
|
|
56
|
+
...unfit.map(({ column, because }) => `"${column}" ${UNFIT[because]}`),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
/** What to do about each reason, and what is known of the check constraint that keeps the live rows whole. */
|
|
60
|
+
function adviceOf(state, table) {
|
|
61
|
+
const { exists, refusing, unfit } = state;
|
|
62
|
+
if (!exists) {
|
|
63
|
+
return ['The migration that creates it did not run on this database: apply the migrations of the project.'];
|
|
64
|
+
}
|
|
65
|
+
return [
|
|
66
|
+
'A deleted row keeps its key, its tenant and its stamp only.',
|
|
67
|
+
...(unfit.length === 0
|
|
68
|
+
? []
|
|
69
|
+
: [
|
|
70
|
+
'No migration opens a column of that kind: a store maps as a field of the row only a plain column, which a trace can hold NULL in. Take it out of the columns the store maps, or make it one.',
|
|
71
|
+
]),
|
|
72
|
+
...(refusing.length === 0 ? [] : constraintAdviceOf(state, table)),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/** What is known of the check constraint of a table whose columns refuse NULL: nothing before the database is read. */
|
|
76
|
+
function constraintAdviceOf({ table: named, constraint }, table) {
|
|
77
|
+
const name = liveRowsConstraintOf(named);
|
|
78
|
+
if (constraint === undefined) {
|
|
79
|
+
return [
|
|
80
|
+
`The definition the store reads says so: declare these columns nullable there, with the check constraint ${name} that keeps the live rows whole; the store then reads what ${table} needs in the database.`,
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
if (constraint.state === 'missing') {
|
|
84
|
+
return [`The check constraint ${name}, which keeps the live rows whole, is missing.`];
|
|
85
|
+
}
|
|
86
|
+
return constraint.state === 'unexpected'
|
|
87
|
+
? [
|
|
88
|
+
`A constraint ${name} is there and checks something else (${String(constraint.definition)}): the migration leaves it as it is, write by hand what keeps these columns whole in the live rows.`,
|
|
89
|
+
]
|
|
90
|
+
: [];
|
|
91
|
+
}
|
|
92
|
+
/** The two steps as a migration file holds them, each under what it does and what it costs. */
|
|
93
|
+
function migrationOf({ definition, validation }) {
|
|
94
|
+
if (definition.length + validation.length === 0) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const validates = validation.some((statement) => statement.includes(' validate constraint '));
|
|
98
|
+
const cleans = validation.some((statement) => statement.startsWith('update '));
|
|
99
|
+
const second = [
|
|
100
|
+
validates ? ['the validation of the constraint'] : [],
|
|
101
|
+
cleans ? ['the cleaning of the rows deleted before'] : [],
|
|
102
|
+
]
|
|
103
|
+
.flat()
|
|
104
|
+
.join(' and ');
|
|
105
|
+
return [
|
|
106
|
+
[
|
|
107
|
+
'The migration to write:',
|
|
108
|
+
...(definition.length === 0
|
|
109
|
+
? []
|
|
110
|
+
: [
|
|
111
|
+
'-- The change of definition: brief, under the lock that stops the readers and the writers of the table.',
|
|
112
|
+
...definition,
|
|
113
|
+
]),
|
|
114
|
+
...(validation.length === 0
|
|
115
|
+
? []
|
|
116
|
+
: [
|
|
117
|
+
`-- Then ${second}, which reads the whole table: in the same migration on a small table; on a large one, in a migration that runs outside the transaction of the change of definition, where it stops neither readers nor writers.`,
|
|
118
|
+
...validation,
|
|
119
|
+
]),
|
|
120
|
+
...placeholderNote([...definition, ...validation]),
|
|
121
|
+
].join('\n'),
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
/** The statements hold a question mark only when a name does: `knex.raw` would read it as a placeholder. */
|
|
125
|
+
function placeholderNote(statements) {
|
|
126
|
+
return statements.some((statement) => statement.includes('?'))
|
|
127
|
+
? [
|
|
128
|
+
'-- A name of these statements holds a question mark, which knex.raw reads as a placeholder: write it "\\?" there, or run the statements otherwise.',
|
|
129
|
+
]
|
|
130
|
+
: [];
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=read-model-table-not-ready-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-not-ready-error.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-not-ready-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;;;;;GAQG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAiB/B,KAAK;IAhB1B,oDAAoD;IAC3C,KAAK,CAAS;IAEvB,+CAA+C;IACtC,OAAO,CAAoB;IAEpC;;;;OAIG;IACM,KAAK,CAA6C;IAE3D,8CAA8C;IACrC,UAAU,CAAoB;IAEvC,YAAqB,KAA0B;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,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CAAC;KACb,CAAC;AACJ,CAAC;AAED,4GAA4G;AAC5G,SAAS,eAAe,CAAC,UAA6B;IACpD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC;YACE,oJAAoJ;SACrJ;QACH,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
|
|
2
|
+
/**
|
|
3
|
+
* What is said, as a warning, of a table the check does not refuse and cannot vouch for: its
|
|
4
|
+
* check constraint is not validated, or a constraint of that name checks something else; another
|
|
5
|
+
* check constraint names a column of its row and may refuse the NULL of a trace; it is a view,
|
|
6
|
+
* whose base columns are not read.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readModelTableNotes(state: ReadModelTableState): string[];
|
|
9
|
+
//# sourceMappingURL=read-model-table-notes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-notes.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-notes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAE/F;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,EAAE,CA2BxE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { liveRowsConstraintOf } from './live-rows-constraint-of.js';
|
|
2
|
+
import { readModelTableMigration } from './read-model-table-migration.js';
|
|
3
|
+
/**
|
|
4
|
+
* What is said, as a warning, of a table the check does not refuse and cannot vouch for: its
|
|
5
|
+
* check constraint is not validated, or a constraint of that name checks something else; another
|
|
6
|
+
* check constraint names a column of its row and may refuse the NULL of a trace; it is a view,
|
|
7
|
+
* whose base columns are not read.
|
|
8
|
+
*/
|
|
9
|
+
export function readModelTableNotes(state) {
|
|
10
|
+
const name = liveRowsConstraintOf(state.table);
|
|
11
|
+
const table = state.schema === undefined ? state.table : `${state.schema}.${state.table}`;
|
|
12
|
+
const others = (state.checks ?? []).map((check) => `${check.name} ${check.definition}`);
|
|
13
|
+
return [
|
|
14
|
+
...(state.constraint?.state === 'not-valid'
|
|
15
|
+
? [
|
|
16
|
+
`The check constraint ${name} of ${table} is not validated: the rows written before it are not held to it. Run: ${readModelTableMigration(state).validation.join(' ')}`,
|
|
17
|
+
]
|
|
18
|
+
: []),
|
|
19
|
+
...(state.constraint?.state === 'unexpected'
|
|
20
|
+
? [
|
|
21
|
+
`The check constraint ${name} of ${table} is not written as the kit writes it, "deleted or (<column> is not null and ...)": ${String(state.constraint.definition)}. It is left as it is, and nothing says whether it lets a trace in.`,
|
|
22
|
+
]
|
|
23
|
+
: []),
|
|
24
|
+
...(others.length === 0
|
|
25
|
+
? []
|
|
26
|
+
: [
|
|
27
|
+
`Other check constraints of ${table} name a column of its row: ${others.join('; ')}. One that refuses NULL there refuses the trace of a deleted row: written for the live rows only ("deleted or ..."), it lets every trace in and is no longer named here.`,
|
|
28
|
+
]),
|
|
29
|
+
...(state.relation === undefined
|
|
30
|
+
? []
|
|
31
|
+
: [
|
|
32
|
+
`${table} is a ${state.relation.replace('-', ' ')}, not a table: what its base columns refuse is not read, so nothing says whether a trace is taken.`,
|
|
33
|
+
]),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=read-model-table-notes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-notes.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-notes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,K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AAoG;aACtJ,CAAC;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
|
|
2
|
+
/** Whether the table can hold the trace of a deleted row: one verdict, for a store before its first trace and for the tables an application lists. */
|
|
3
|
+
export declare function readModelTableReady({ exists, refusing, unfit }: ReadModelTableState): boolean;
|
|
4
|
+
//# sourceMappingURL=read-model-table-ready.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-ready.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-ready.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAE/F,sJAAsJ;AACtJ,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAE7F"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Whether the table can hold the trace of a deleted row: one verdict, for a store before its first trace and for the tables an application lists. */
|
|
2
|
+
export function readModelTableReady({ exists, refusing, unfit }) {
|
|
3
|
+
return exists && refusing.length === 0 && unfit.length === 0;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=read-model-table-ready.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-model-table-ready.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-table-ready.ts"],"names":[],"mappings":"AAEA,sJAAsJ;AACtJ,MAAM,UAAU,mBAAmB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAuB;IAClF,OAAO,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|