@ddd-ts-kit/kernel 0.111.0 → 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.
Files changed (126) hide show
  1. package/README.fr.md +52 -3
  2. package/README.md +48 -1
  3. package/dist/application/files/content-expectation.d.ts +6 -0
  4. package/dist/application/files/content-expectation.d.ts.map +1 -1
  5. package/dist/application/files/content-matches.d.ts +12 -3
  6. package/dist/application/files/content-matches.d.ts.map +1 -1
  7. package/dist/application/files/content-matches.js +23 -28
  8. package/dist/application/files/content-matches.js.map +1 -1
  9. package/dist/application/files/content-rule-defects.d.ts +9 -0
  10. package/dist/application/files/content-rule-defects.d.ts.map +1 -0
  11. package/dist/application/files/content-rule-defects.js +57 -0
  12. package/dist/application/files/content-rule-defects.js.map +1 -0
  13. package/dist/application/files/content-rule-of.d.ts +11 -0
  14. package/dist/application/files/content-rule-of.d.ts.map +1 -0
  15. package/dist/application/files/content-rule-of.js +28 -0
  16. package/dist/application/files/content-rule-of.js.map +1 -0
  17. package/dist/application/files/content-rule.d.ts +4 -0
  18. package/dist/application/files/content-rule.d.ts.map +1 -0
  19. package/dist/application/files/content-rule.js +2 -0
  20. package/dist/application/files/content-rule.js.map +1 -0
  21. package/dist/application/files/content-rules.d.ts +4 -0
  22. package/dist/application/files/content-rules.d.ts.map +1 -0
  23. package/dist/application/files/content-rules.js +2 -0
  24. package/dist/application/files/content-rules.js.map +1 -0
  25. package/dist/application/files/index.d.ts +10 -0
  26. package/dist/application/files/index.d.ts.map +1 -1
  27. package/dist/application/files/index.js +10 -0
  28. package/dist/application/files/index.js.map +1 -1
  29. package/dist/application/files/is-utf8.d.ts +8 -0
  30. package/dist/application/files/is-utf8.d.ts.map +1 -0
  31. package/dist/application/files/is-utf8.js +16 -0
  32. package/dist/application/files/is-utf8.js.map +1 -0
  33. package/dist/application/files/looks-like-text.d.ts +8 -0
  34. package/dist/application/files/looks-like-text.d.ts.map +1 -0
  35. package/dist/application/files/looks-like-text.js +28 -0
  36. package/dist/application/files/looks-like-text.js.map +1 -0
  37. package/dist/application/files/named-only-media-types.d.ts +6 -0
  38. package/dist/application/files/named-only-media-types.d.ts.map +1 -0
  39. package/dist/application/files/named-only-media-types.js +12 -0
  40. package/dist/application/files/named-only-media-types.js.map +1 -0
  41. package/dist/application/files/signed-media-types.d.ts +3 -0
  42. package/dist/application/files/signed-media-types.d.ts.map +1 -0
  43. package/dist/application/files/signed-media-types.js +13 -0
  44. package/dist/application/files/signed-media-types.js.map +1 -0
  45. package/dist/application/files/stated-content-rule.d.ts +7 -0
  46. package/dist/application/files/stated-content-rule.d.ts.map +1 -0
  47. package/dist/application/files/stated-content-rule.js +2 -0
  48. package/dist/application/files/stated-content-rule.js.map +1 -0
  49. package/dist/application/files/text-media-types.d.ts +3 -0
  50. package/dist/application/files/text-media-types.d.ts.map +1 -0
  51. package/dist/application/files/text-media-types.js +10 -0
  52. package/dist/application/files/text-media-types.js.map +1 -0
  53. package/dist/application/files/text-rule.d.ts +17 -0
  54. package/dist/application/files/text-rule.d.ts.map +1 -0
  55. package/dist/application/files/text-rule.js +2 -0
  56. package/dist/application/files/text-rule.js.map +1 -0
  57. package/dist/application/files/zip-containers.d.ts +3 -0
  58. package/dist/application/files/zip-containers.d.ts.map +1 -0
  59. package/dist/application/files/zip-containers.js +10 -0
  60. package/dist/application/files/zip-containers.js.map +1 -0
  61. package/dist/application/ports/read-model-table.d.ts +7 -0
  62. package/dist/application/ports/read-model-table.d.ts.map +1 -1
  63. package/dist/application/ports/read-model-table.js.map +1 -1
  64. package/dist/application/read-model/read-model-table-state.d.ts +53 -0
  65. package/dist/application/read-model/read-model-table-state.d.ts.map +1 -0
  66. package/dist/application/read-model/read-model-table-state.js +2 -0
  67. package/dist/application/read-model/read-model-table-state.js.map +1 -0
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +3 -0
  71. package/dist/index.js.map +1 -1
  72. package/dist/infrastructure/files/file-inspection.js +1 -1
  73. package/dist/infrastructure/files/file-inspection.js.map +1 -1
  74. package/dist/infrastructure/files/file-staging.d.ts +4 -2
  75. package/dist/infrastructure/files/file-staging.d.ts.map +1 -1
  76. package/dist/infrastructure/files/file-staging.js +14 -6
  77. package/dist/infrastructure/files/file-staging.js.map +1 -1
  78. package/dist/infrastructure/read-model/database-failure.d.ts +19 -0
  79. package/dist/infrastructure/read-model/database-failure.d.ts.map +1 -0
  80. package/dist/infrastructure/read-model/database-failure.js +71 -0
  81. package/dist/infrastructure/read-model/database-failure.js.map +1 -0
  82. package/dist/infrastructure/read-model/live-rows-columns-of.d.ts +7 -0
  83. package/dist/infrastructure/read-model/live-rows-columns-of.d.ts.map +1 -0
  84. package/dist/infrastructure/read-model/live-rows-columns-of.js +20 -0
  85. package/dist/infrastructure/read-model/live-rows-columns-of.js.map +1 -0
  86. package/dist/infrastructure/read-model/live-rows-constraint-form.d.ts +11 -0
  87. package/dist/infrastructure/read-model/live-rows-constraint-form.d.ts.map +1 -0
  88. package/dist/infrastructure/read-model/live-rows-constraint-form.js +13 -0
  89. package/dist/infrastructure/read-model/live-rows-constraint-form.js.map +1 -0
  90. package/dist/infrastructure/read-model/live-rows-constraint-of.d.ts +6 -0
  91. package/dist/infrastructure/read-model/live-rows-constraint-of.d.ts.map +1 -0
  92. package/dist/infrastructure/read-model/live-rows-constraint-of.js +18 -0
  93. package/dist/infrastructure/read-model/live-rows-constraint-of.js.map +1 -0
  94. package/dist/infrastructure/read-model/postgres-trace-columns.d.ts +17 -7
  95. package/dist/infrastructure/read-model/postgres-trace-columns.d.ts.map +1 -1
  96. package/dist/infrastructure/read-model/postgres-trace-columns.js +101 -14
  97. package/dist/infrastructure/read-model/postgres-trace-columns.js.map +1 -1
  98. package/dist/infrastructure/read-model/read-model-table-migration.d.ts +31 -0
  99. package/dist/infrastructure/read-model/read-model-table-migration.d.ts.map +1 -0
  100. package/dist/infrastructure/read-model/read-model-table-migration.js +82 -0
  101. package/dist/infrastructure/read-model/read-model-table-migration.js.map +1 -0
  102. package/dist/infrastructure/read-model/read-model-table-not-ready-error.d.ts +21 -5
  103. package/dist/infrastructure/read-model/read-model-table-not-ready-error.d.ts.map +1 -1
  104. package/dist/infrastructure/read-model/read-model-table-not-ready-error.js +123 -10
  105. package/dist/infrastructure/read-model/read-model-table-not-ready-error.js.map +1 -1
  106. package/dist/infrastructure/read-model/read-model-table-notes.d.ts +9 -0
  107. package/dist/infrastructure/read-model/read-model-table-notes.d.ts.map +1 -0
  108. package/dist/infrastructure/read-model/read-model-table-notes.js +36 -0
  109. package/dist/infrastructure/read-model/read-model-table-notes.js.map +1 -0
  110. package/dist/infrastructure/read-model/read-model-table-ready.d.ts +4 -0
  111. package/dist/infrastructure/read-model/read-model-table-ready.d.ts.map +1 -0
  112. package/dist/infrastructure/read-model/read-model-table-ready.js +5 -0
  113. package/dist/infrastructure/read-model/read-model-table-ready.js.map +1 -0
  114. package/dist/infrastructure/read-model/read-model-tables-not-ready-error.d.ts +24 -0
  115. package/dist/infrastructure/read-model/read-model-tables-not-ready-error.d.ts.map +1 -0
  116. package/dist/infrastructure/read-model/read-model-tables-not-ready-error.js +40 -0
  117. package/dist/infrastructure/read-model/read-model-tables-not-ready-error.js.map +1 -0
  118. package/dist/infrastructure/read-model/read-model-tables.d.ts +82 -0
  119. package/dist/infrastructure/read-model/read-model-tables.d.ts.map +1 -0
  120. package/dist/infrastructure/read-model/read-model-tables.js +161 -0
  121. package/dist/infrastructure/read-model/read-model-tables.js.map +1 -0
  122. package/dist/infrastructure/read-model/table-read-model-store.d.ts +7 -0
  123. package/dist/infrastructure/read-model/table-read-model-store.d.ts.map +1 -1
  124. package/dist/infrastructure/read-model/table-read-model-store.js +8 -0
  125. package/dist/infrastructure/read-model/table-read-model-store.js.map +1 -1
  126. package/package.json +1 -1
@@ -1,19 +1,132 @@
1
+ import { liveRowsConstraintOf } from './live-rows-constraint-of.js';
2
+ import { readModelTableMigration } from './read-model-table-migration.js';
1
3
  /**
2
- * The table of a read model has columns that refuse NULL, so it cannot hold the trace of a
3
- * deleted row: its key, its stamp and `deleted`, NULL in every other column. An adapter raises it
4
- * from the definition of the table or from one read of its columns, before any statement the
5
- * database would refuse, since on PostgreSQL that refusal aborts the transaction of the event.
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.
6
11
  */
7
12
  export class ReadModelTableNotReadyError extends Error {
13
+ state;
14
+ /** The table as it is said: `scheduling.agenda`. */
8
15
  table;
16
+ /** The columns of the row that refuse NULL. */
9
17
  columns;
10
- constructor(table, columns) {
11
- const named = columns.map((column) => `"${column}"`);
12
- const whole = named.map((column) => `${column} is not null`).join(' and ');
13
- super(`The read model table ${table} cannot hold the trace of a deleted row: ${named.join(', ')} ${columns.length === 1 ? 'refuses' : 'refuse'} NULL, and a deleted row keeps its key and its stamp only. Write a migration that drops NOT NULL there (alter table ${table} alter column <column> drop not null) and keeps the live rows whole with a check constraint: check (deleted or (${whole}))`);
14
- this.table = table;
15
- this.columns = 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;
16
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.'];
17
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
+ : [];
18
131
  }
19
132
  //# sourceMappingURL=read-model-table-not-ready-error.js.map
@@ -1 +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;;;;;GAKG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAEzC,KAAK;IACL,OAAO;IAFlB,YACW,KAAa,EACb,OAA0B;QAEnC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE3E,KAAK,CACH,wBAAwB,KAAK,4CAA4C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,uHAAuH,KAAK,mHAAmH,KAAK,IAAI,CACjY,CAAC;qBARO,KAAK;uBACL,OAAO;QAShB,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF"}
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,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1F,MAAM,KAAK,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAE7C,KAAK,CACH;YACE,wBAAwB,KAAK,4CAA4C,SAAS,CAAC,K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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,KAA0B;IAC5D,MAAM,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1F,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAExF,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,KAAK,WAAW;YACzC,CAAC,CAAC;gBACE,wBAAwB,IAAI,OAAO,KAAK,0EAA0E,uBAAuB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;aACxK;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,KAAK,YAAY;YAC1C,CAAC,CAAC;gBACE,wBAAwB,IAAI,OAAO,KAAK,sFAAsF,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,qEAAqE;aACvO;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YACrB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,8BAA8B,KAAK,8BAA8B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,0KAA0K;aAC7P,CAAC;QACN,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS;YAC9B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,GAAG,KAAK,SAAS,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,oGAAoG;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"}
@@ -0,0 +1,24 @@
1
+ import { ReadModelTableNotReadyError } from './read-model-table-not-ready-error.js';
2
+ import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
3
+ /** A listed read model whose table could not be read: its store could not be built, or the database refused the reading. */
4
+ interface UnreadReadModel {
5
+ /** The name the list gives the read model: the class of its store. */
6
+ readonly name: string;
7
+ readonly cause: unknown;
8
+ }
9
+ /**
10
+ * Read model tables the application lists cannot hold the trace of a deleted row, or could not be
11
+ * read: every one of them, in one error, each table with what keeps it from it and the migration
12
+ * to write, each unread one under its name with what failed, in a few words: the message of the
13
+ * driver, never the statement an ORM wraps it in. Raised when the tables are checked
14
+ * in one pass, at the start of an application or before a deployment, where
15
+ * `ReadModelTableNotReadyError` is the refusal of one store before its first trace. Each entry of
16
+ * `tables` is that very refusal: the verdict and the migration are the ones the store would give.
17
+ */
18
+ export declare class ReadModelTablesNotReadyError extends Error {
19
+ readonly unread: readonly UnreadReadModel[];
20
+ readonly tables: readonly ReadModelTableNotReadyError[];
21
+ constructor(unready: readonly ReadModelTableState[], unread?: readonly UnreadReadModel[]);
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=read-model-tables-not-ready-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-model-tables-not-ready-error.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-tables-not-ready-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAE/F,4HAA4H;AAC5H,UAAU,eAAe;IACvB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IAKnD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE;IAJ7C,QAAQ,CAAC,MAAM,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAExD,YACE,OAAO,EAAE,SAAS,mBAAmB,EAAE,EAC9B,MAAM,GAAE,SAAS,eAAe,EAAO,EAQjD;CACF"}
@@ -0,0 +1,40 @@
1
+ import { databaseFailure } from './database-failure.js';
2
+ import { ReadModelTableNotReadyError } from './read-model-table-not-ready-error.js';
3
+ /**
4
+ * Read model tables the application lists cannot hold the trace of a deleted row, or could not be
5
+ * read: every one of them, in one error, each table with what keeps it from it and the migration
6
+ * to write, each unread one under its name with what failed, in a few words: the message of the
7
+ * driver, never the statement an ORM wraps it in. Raised when the tables are checked
8
+ * in one pass, at the start of an application or before a deployment, where
9
+ * `ReadModelTableNotReadyError` is the refusal of one store before its first trace. Each entry of
10
+ * `tables` is that very refusal: the verdict and the migration are the ones the store would give.
11
+ */
12
+ export class ReadModelTablesNotReadyError extends Error {
13
+ unread;
14
+ tables;
15
+ constructor(unready, unread = []) {
16
+ const tables = unready.map((table) => new ReadModelTableNotReadyError(table));
17
+ super([...notReady(tables), ...notRead(unread), ...tables.map(({ message }) => message)].join('\n\n'));
18
+ this.unread = unread;
19
+ this.name = 'ReadModelTablesNotReadyError';
20
+ this.tables = tables;
21
+ }
22
+ }
23
+ function notReady(tables) {
24
+ if (tables.length === 0) {
25
+ return [];
26
+ }
27
+ const counted = tables.length === 1 ? '1 read model table is' : `${String(tables.length)} read model tables are`;
28
+ return [
29
+ `${counted} not ready for this version: ${tables.map(({ table }) => table).join(', ')}. Apply the migrations of the project before the application starts; a table they leave as it is takes the migration written under its name.`,
30
+ ];
31
+ }
32
+ function notRead(unread) {
33
+ if (unread.length === 0) {
34
+ return [];
35
+ }
36
+ const counted = unread.length === 1 ? 'The table of 1 read model' : `The tables of ${String(unread.length)} read models`;
37
+ const each = unread.map(({ name, cause }) => `${name} (${databaseFailure(cause).cause})`);
38
+ return [`${counted} could not be read, so nothing says whether a trace is taken: ${each.join('; ')}.`];
39
+ }
40
+ //# sourceMappingURL=read-model-tables-not-ready-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-model-tables-not-ready-error.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-tables-not-ready-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAUjF;;;;;;;;GAQG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAK1C,MAAM;IAJR,MAAM,CAAyC;IAExD,YACE,OAAuC,EAC9B,MAAM,GAA+B,EAAE;QAEhD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;QAE9E,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EA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logger } from '../../application/ports/logger.js';
2
+ import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
3
+ /** A read model as an application lists it: its store, or the table under it, which reads what that table can hold. */
4
+ export interface ReadModelInATable {
5
+ /** Absent, or `undefined`, where the rows are not kept in a table: such a read model has nothing to check. */
6
+ tableState?(): Promise<ReadModelTableState | undefined>;
7
+ }
8
+ /** One entry of the list: the name a failure is told under, and how the store is built, as the application binds it. */
9
+ export interface ListedReadModel {
10
+ readonly name: string;
11
+ /** The bounded context the read model belongs to, when the application hosts several: what `hosting` selects by. */
12
+ readonly context?: string;
13
+ build(): ReadModelInATable;
14
+ }
15
+ /**
16
+ * What an application does at its start with the listed tables that are not ready or could not
17
+ * be read: `required` refuses to start, `reported` logs them as one error and starts, for a
18
+ * deployment that starts the application before its migrations ran.
19
+ */
20
+ export type ReadModelTablesAtStart = 'required' | 'reported';
21
+ /** What a check of the listed tables found, as a command says it. */
22
+ export interface ReadModelTablesReport {
23
+ readonly ready: boolean;
24
+ /** `unread` when no listed table could be read and one failed: the database does not answer, or refuses the reading. */
25
+ readonly outcome: 'ready' | 'not-ready' | 'unread';
26
+ readonly text: string;
27
+ }
28
+ /**
29
+ * The read model tables an application declares, checked in one pass before a request or an
30
+ * event reaches a store, whenever the stores themselves are built. Each entry builds the store of
31
+ * one read model, the class the application binds, with its own options: the table is then read
32
+ * by the code that store runs before its first trace, so the verdict is the store's and the
33
+ * migration names its columns. Every entry is tried: a store whose definition refuses its table
34
+ * is reported like the others, and one that cannot be built or read (a role without the right to
35
+ * read its schema) is told under its name with what failed, the others still read. Nothing is
36
+ * guessed from the database: a table that is not listed is not read, and an empty list checks
37
+ * nothing. `unlisted` names the read model stores the application knows it does not list: they
38
+ * are told as a warning, since nothing checks them. A database that cannot be reached (a refused
39
+ * connection, a host that is not found, a timeout) is no answer about a table: the reading stops
40
+ * there, a start goes on with one warning, since it never depended on the database being up, and
41
+ * a command says the database could not be read.
42
+ */
43
+ export declare class ReadModelTables {
44
+ private readonly listed;
45
+ private readonly unlisted;
46
+ constructor(listed: readonly ListedReadModel[], unlisted?: readonly string[]);
47
+ /** The contexts the entries belong to, each once, in the order of the list: what a command names when it is asked for one the list does not hold. */
48
+ get contexts(): readonly string[];
49
+ /**
50
+ * The entries of these contexts alone, for an application that hosts some of them; every entry
51
+ * when none is named. A name no entry carries selects nothing, which is right for a root (a
52
+ * context may keep no read model) and wrong for a command: it compares the name with `contexts`.
53
+ */
54
+ hosting(contexts?: readonly string[]): ReadModelTables;
55
+ /** What each listed table that could be read can hold, in the order of the list. */
56
+ states(): Promise<readonly ReadModelTableState[]>;
57
+ /** The listed tables that cannot hold the trace of a deleted row, every one of them. */
58
+ notReady(): Promise<readonly ReadModelTableState[]>;
59
+ /** Refuses with `ReadModelTablesNotReadyError`, which names every listed table that is not ready, with its migration, and every one that could not be read. */
60
+ require(): Promise<void>;
61
+ /**
62
+ * The check an application makes when it starts. `required`, the default, refuses to start;
63
+ * `reported` writes the same message as an error and lets the start go on: each store still
64
+ * refuses by name before its first trace. What the check cannot decide is a warning either
65
+ * way: a check constraint that is not validated or that checks something else, another check
66
+ * on a column of the row, a view, a store nobody lists. A database that could not be reached
67
+ * is one warning too, with its cause in a few words, and never a refusal: the check tells the
68
+ * tables that are not ready, it does not make the start wait for the database.
69
+ */
70
+ atStart(logger: Logger, unready?: ReadModelTablesAtStart): Promise<void>;
71
+ /** The same check as a command prints it: how many tables it read and their names, the warnings, then every refusal. */
72
+ report(): Promise<ReadModelTablesReport>;
73
+ private nothingRead;
74
+ /**
75
+ * Every entry is tried, in the order of the list: one that fails does not hide the next. The
76
+ * reading stops at the first one that finds the database unreachable: the next would wait for
77
+ * the same refusal.
78
+ */
79
+ private read;
80
+ private notes;
81
+ }
82
+ //# sourceMappingURL=read-model-tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-model-tables.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-tables.ts"],"names":[],"mappings":"AAAA,OAAO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;IAED,+JAA+J;IACzJ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7B;IAED;;;;;;;;OAQG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,sBAAmC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBzF;IAED,wHAAwH;IAClH,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAoB7C;IAED,OAAO,CAAC,WAAW;IAMnB;;;;OAIG;YACW,IAAI;IAqBlB,OAAO,CAAC,KAAK;CAUd"}
@@ -0,0 +1,161 @@
1
+ import { databaseFailure } from './database-failure.js';
2
+ import { ReadModelTableNotReadyError } from './read-model-table-not-ready-error.js';
3
+ import { readModelTableNotes } from './read-model-table-notes.js';
4
+ import { readModelTableReady } from './read-model-table-ready.js';
5
+ import { ReadModelTablesNotReadyError } from './read-model-tables-not-ready-error.js';
6
+ /**
7
+ * The read model tables an application declares, checked in one pass before a request or an
8
+ * event reaches a store, whenever the stores themselves are built. Each entry builds the store of
9
+ * one read model, the class the application binds, with its own options: the table is then read
10
+ * by the code that store runs before its first trace, so the verdict is the store's and the
11
+ * migration names its columns. Every entry is tried: a store whose definition refuses its table
12
+ * is reported like the others, and one that cannot be built or read (a role without the right to
13
+ * read its schema) is told under its name with what failed, the others still read. Nothing is
14
+ * guessed from the database: a table that is not listed is not read, and an empty list checks
15
+ * nothing. `unlisted` names the read model stores the application knows it does not list: they
16
+ * are told as a warning, since nothing checks them. A database that cannot be reached (a refused
17
+ * connection, a host that is not found, a timeout) is no answer about a table: the reading stops
18
+ * there, a start goes on with one warning, since it never depended on the database being up, and
19
+ * a command says the database could not be read.
20
+ */
21
+ export class ReadModelTables {
22
+ listed;
23
+ unlisted;
24
+ constructor(listed, unlisted = []) {
25
+ this.listed = listed;
26
+ this.unlisted = unlisted;
27
+ }
28
+ /** The contexts the entries belong to, each once, in the order of the list: what a command names when it is asked for one the list does not hold. */
29
+ get contexts() {
30
+ return [...new Set(this.listed.flatMap(({ context }) => (context === undefined ? [] : [context])))];
31
+ }
32
+ /**
33
+ * The entries of these contexts alone, for an application that hosts some of them; every entry
34
+ * when none is named. A name no entry carries selects nothing, which is right for a root (a
35
+ * context may keep no read model) and wrong for a command: it compares the name with `contexts`.
36
+ */
37
+ hosting(contexts) {
38
+ return contexts === undefined
39
+ ? this
40
+ : new ReadModelTables(this.listed.filter(({ context }) => context !== undefined && contexts.includes(context)), this.unlisted);
41
+ }
42
+ /** What each listed table that could be read can hold, in the order of the list. */
43
+ async states() {
44
+ return (await this.read()).states;
45
+ }
46
+ /** The listed tables that cannot hold the trace of a deleted row, every one of them. */
47
+ async notReady() {
48
+ return (await this.states()).filter((state) => !readModelTableReady(state));
49
+ }
50
+ /** Refuses with `ReadModelTablesNotReadyError`, which names every listed table that is not ready, with its migration, and every one that could not be read. */
51
+ async require() {
52
+ const refusal = refusalOf(await this.read(), 'strict');
53
+ if (refusal !== undefined) {
54
+ throw refusal;
55
+ }
56
+ }
57
+ /**
58
+ * The check an application makes when it starts. `required`, the default, refuses to start;
59
+ * `reported` writes the same message as an error and lets the start go on: each store still
60
+ * refuses by name before its first trace. What the check cannot decide is a warning either
61
+ * way: a check constraint that is not validated or that checks something else, another check
62
+ * on a column of the row, a view, a store nobody lists. A database that could not be reached
63
+ * is one warning too, with its cause in a few words, and never a refusal: the check tells the
64
+ * tables that are not ready, it does not make the start wait for the database.
65
+ */
66
+ async atStart(logger, unready = 'required') {
67
+ const reading = await this.read();
68
+ const refusal = refusalOf(reading);
69
+ for (const note of [...unreachedNote(reading), ...this.notes(reading)]) {
70
+ logger.warn(note);
71
+ }
72
+ if (refusal === undefined) {
73
+ return;
74
+ }
75
+ if (unready === 'required') {
76
+ throw refusal;
77
+ }
78
+ logger.error(refusal.message, {
79
+ tables: refusal.tables.map(({ table }) => table).join(', '),
80
+ unread: refusal.unread.map(({ name }) => name).join(', '),
81
+ });
82
+ }
83
+ /** The same check as a command prints it: how many tables it read and their names, the warnings, then every refusal. */
84
+ async report() {
85
+ const reading = await this.read();
86
+ const refusal = refusalOf(reading, 'strict');
87
+ const { states } = reading;
88
+ const counted = states.length === 1 ? '1 read model table' : `${String(states.length)} read model tables`;
89
+ const lines = [
90
+ states.length === 0 ? this.nothingRead() : `Checked ${counted}: ${states.map(nameOf).join(', ')}.`,
91
+ ...this.notes(reading),
92
+ ...(refusal === undefined ? [] : ['', refusal.message]),
93
+ ...(refusal === undefined && states.length > 0 ? ['Each can hold the trace of a deleted row.'] : []),
94
+ ];
95
+ const unread = reading.unreached !== undefined || (states.length === 0 && reading.unread.length > 0);
96
+ return {
97
+ ready: refusal === undefined,
98
+ outcome: refusal === undefined ? 'ready' : unread ? 'unread' : 'not-ready',
99
+ text: lines.join('\n'),
100
+ };
101
+ }
102
+ nothingRead() {
103
+ return this.listed.length === 0
104
+ ? 'No read model table is listed: nothing was checked.'
105
+ : 'No listed read model keeps a table that could be read.';
106
+ }
107
+ /**
108
+ * Every entry is tried, in the order of the list: one that fails does not hide the next. The
109
+ * reading stops at the first one that finds the database unreachable: the next would wait for
110
+ * the same refusal.
111
+ */
112
+ async read() {
113
+ const states = [];
114
+ const unread = [];
115
+ for (const entry of this.listed) {
116
+ try {
117
+ states.push(...[await entry.build().tableState?.()].filter((state) => state !== undefined));
118
+ }
119
+ catch (cause) {
120
+ if (cause instanceof ReadModelTableNotReadyError) {
121
+ states.push(cause.state);
122
+ }
123
+ else if (databaseFailure(cause).unreachable) {
124
+ return { states, unread, unreached: { name: entry.name, cause } };
125
+ }
126
+ else {
127
+ unread.push({ name: entry.name, cause });
128
+ }
129
+ }
130
+ }
131
+ return { states, unread };
132
+ }
133
+ notes({ states }) {
134
+ return [
135
+ ...states.flatMap(readModelTableNotes),
136
+ ...(this.unlisted.length === 0
137
+ ? []
138
+ : [
139
+ `Read model stores of the application are not listed, so nothing checks their tables: ${this.unlisted.join(', ')}. Add each to the list of the read model tables.`,
140
+ ]),
141
+ ];
142
+ }
143
+ }
144
+ /** The refusal of a reading; `strict`, for a command, a database that could not be reached is one too. */
145
+ function refusalOf(reading, strict) {
146
+ const refused = reading.states.filter((state) => !readModelTableReady(state));
147
+ const unreached = strict === undefined || reading.unreached === undefined ? [] : [reading.unreached];
148
+ const unread = [...reading.unread, ...unreached];
149
+ return refused.length + unread.length === 0 ? undefined : new ReadModelTablesNotReadyError(refused, unread);
150
+ }
151
+ function unreachedNote({ unreached }) {
152
+ return unreached === undefined
153
+ ? []
154
+ : [
155
+ `The read model tables could not be checked: the database could not be reached (${databaseFailure(unreached.cause).cause}). The start goes on; each store still refuses a table that is not ready before its first trace.`,
156
+ ];
157
+ }
158
+ function nameOf({ schema, table }) {
159
+ return schema === undefined ? table : `${schema}.${table}`;
160
+ }
161
+ //# sourceMappingURL=read-model-tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-model-tables.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/read-model-tables.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAwCnF;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAe;IAEP,MAAM;IACN,QAAQ;IAF3B,YACmB,MAAkC,EAClC,QAAQ,GAAsB,EAAE;sBADhC,MAAM;wBACN,QAAQ;IACxB,CAAC;IAEJ,qJAAqJ;IACrJ,IAAI,QAAQ;QACV,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC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AO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IAEjD,OAAO,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9G,CAAC;AAED,SAAS,aAAa,CAAC,EAAE,SAAS,EAAW;IAC3C,OAAO,SAAS,KAAK,SAAS;QAC5B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE,kFAAkF,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,kGAAkG;SAC3N,CAAC;AACR,CAAC;AAED,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAuB;IACpD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;AAC7D,CAAC"}
@@ -4,6 +4,7 @@ import type { Page } from '../../application/pagination/page.js';
4
4
  import type { ReadModelStore } from '../../application/ports/read-model-store.js';
5
5
  import type { ReadModelTable } from '../../application/ports/read-model-table.js';
6
6
  import type { EventStamp } from '../../application/read-model/event-stamp.js';
7
+ import type { ReadModelTableState } from '../../application/read-model/read-model-table-state.js';
7
8
  import type { ReadModelWrite } from '../../application/read-model/read-model-write.js';
8
9
  /**
9
10
  * A `ReadModelStore` over the table an adapter gives: the same class in memory and on every
@@ -18,6 +19,12 @@ export declare class TableReadModelStore<Row extends object> implements ReadMode
18
19
  upsertIfNewer(key: string, stamp: EventStamp, next: (current: Row | undefined) => Row | undefined): Promise<ReadModelWrite>;
19
20
  updateIfNewer(key: string, stamp: EventStamp, change: (current: Row) => Row): Promise<ReadModelWrite>;
20
21
  delete(key: string, stamp: EventStamp): Promise<ReadModelWrite>;
22
+ /**
23
+ * What the table of the read model can hold, read by the code the adapter runs before its first
24
+ * trace; `undefined` where the rows are not kept in a table (memory, a search engine). What
25
+ * `ReadModelTables` asks of each store an application lists.
26
+ */
27
+ tableState(): Promise<ReadModelTableState | undefined>;
21
28
  search(criteria: ScopedCriteria<Row>): Promise<Page<Row>>;
22
29
  private written;
23
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table-read-model-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/table-read-model-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAGpF;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,GAAG,SAAS,MAAM,CAAE,YAAW,cAAc,CAAC,GAAG,CAAC;IAE/E,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC;IAF9C,YACW,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAC1B,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAC1C;IAEE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAE/C;IAED,aAAa,CACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,GAAG,SAAS,KAAK,GAAG,GAAG,SAAS,GAClD,OAAO,CAAC,cAAc,CAAC,CAEzB;IAED,aAAa,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EAC1C;IAEE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAE/C;IAED,aAAa,CACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,GAAG,SAAS,KAAK,GAAG,GAAG,SAAS,GAClD,OAAO,CAAC,cAAc,CAAC,CAEzB;IAED,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAEpG;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAE9D;IAED;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAE3D;IAEK,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAU9D;YAEa,OAAO;CAOtB"}
@@ -25,6 +25,14 @@ export class TableReadModelStore {
25
25
  delete(key, stamp) {
26
26
  return this.written({ key, stamp });
27
27
  }
28
+ /**
29
+ * What the table of the read model can hold, read by the code the adapter runs before its first
30
+ * trace; `undefined` where the rows are not kept in a table (memory, a search engine). What
31
+ * `ReadModelTables` asks of each store an application lists.
32
+ */
33
+ async tableState() {
34
+ return this.table.tableState?.();
35
+ }
28
36
  async search(criteria) {
29
37
  const plan = planCriteria(this.definition, criteria);
30
38
  if (plan.empty) {