@ddd-ts-kit/kernel 0.9.0 → 0.10.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 (260) hide show
  1. package/README.md +138 -2
  2. package/dist/application/criteria/index.d.ts +33 -0
  3. package/dist/application/criteria/index.d.ts.map +1 -0
  4. package/dist/application/criteria/index.js +33 -0
  5. package/dist/application/criteria/index.js.map +1 -0
  6. package/dist/application/event-sourcing/appended.d.ts +8 -0
  7. package/dist/application/event-sourcing/appended.d.ts.map +1 -0
  8. package/dist/application/event-sourcing/appended.js +2 -0
  9. package/dist/application/event-sourcing/appended.js.map +1 -0
  10. package/dist/application/event-sourcing/define-stored-event.d.ts +10 -0
  11. package/dist/application/event-sourcing/define-stored-event.d.ts.map +1 -0
  12. package/dist/application/event-sourcing/define-stored-event.js +22 -0
  13. package/dist/application/event-sourcing/define-stored-event.js.map +1 -0
  14. package/dist/application/event-sourcing/erased-personal-data.d.ts +3 -0
  15. package/dist/application/event-sourcing/erased-personal-data.d.ts.map +1 -0
  16. package/dist/application/event-sourcing/erased-personal-data.js +3 -0
  17. package/dist/application/event-sourcing/erased-personal-data.js.map +1 -0
  18. package/dist/application/event-sourcing/event-envelope.d.ts +9 -0
  19. package/dist/application/event-sourcing/event-envelope.d.ts.map +1 -0
  20. package/dist/application/event-sourcing/event-envelope.js +2 -0
  21. package/dist/application/event-sourcing/event-envelope.js.map +1 -0
  22. package/dist/application/event-sourcing/event-to-append.d.ts +15 -0
  23. package/dist/application/event-sourcing/event-to-append.d.ts.map +1 -0
  24. package/dist/application/event-sourcing/event-to-append.js +2 -0
  25. package/dist/application/event-sourcing/event-to-append.js.map +1 -0
  26. package/dist/application/event-sourcing/index.d.ts +21 -0
  27. package/dist/application/event-sourcing/index.d.ts.map +1 -0
  28. package/dist/application/event-sourcing/index.js +21 -0
  29. package/dist/application/event-sourcing/index.js.map +1 -0
  30. package/dist/application/event-sourcing/is-stored-data.d.ts +5 -0
  31. package/dist/application/event-sourcing/is-stored-data.d.ts.map +1 -0
  32. package/dist/application/event-sourcing/is-stored-data.js +5 -0
  33. package/dist/application/event-sourcing/is-stored-data.js.map +1 -0
  34. package/dist/application/event-sourcing/is-stored-list.d.ts +4 -0
  35. package/dist/application/event-sourcing/is-stored-list.d.ts.map +1 -0
  36. package/dist/application/event-sourcing/is-stored-list.js +5 -0
  37. package/dist/application/event-sourcing/is-stored-list.js.map +1 -0
  38. package/dist/application/event-sourcing/personal-data.d.ts +14 -0
  39. package/dist/application/event-sourcing/personal-data.d.ts.map +1 -0
  40. package/dist/application/event-sourcing/personal-data.js +9 -0
  41. package/dist/application/event-sourcing/personal-data.js.map +1 -0
  42. package/dist/application/event-sourcing/stored-data-of.d.ts +9 -0
  43. package/dist/application/event-sourcing/stored-data-of.d.ts.map +1 -0
  44. package/dist/application/event-sourcing/stored-data-of.js +40 -0
  45. package/dist/application/event-sourcing/stored-data-of.js.map +1 -0
  46. package/dist/application/event-sourcing/stored-data.d.ts +6 -0
  47. package/dist/application/event-sourcing/stored-data.d.ts.map +1 -0
  48. package/dist/application/event-sourcing/stored-data.js +2 -0
  49. package/dist/application/event-sourcing/stored-data.js.map +1 -0
  50. package/dist/application/event-sourcing/stored-event-data.d.ts +25 -0
  51. package/dist/application/event-sourcing/stored-event-data.d.ts.map +1 -0
  52. package/dist/application/event-sourcing/stored-event-data.js +82 -0
  53. package/dist/application/event-sourcing/stored-event-data.js.map +1 -0
  54. package/dist/application/event-sourcing/stored-event-spec.d.ts +20 -0
  55. package/dist/application/event-sourcing/stored-event-spec.d.ts.map +1 -0
  56. package/dist/application/event-sourcing/stored-event-spec.js +2 -0
  57. package/dist/application/event-sourcing/stored-event-spec.js.map +1 -0
  58. package/dist/application/event-sourcing/stored-event-type.d.ts +14 -0
  59. package/dist/application/event-sourcing/stored-event-type.d.ts.map +1 -0
  60. package/dist/application/event-sourcing/stored-event-type.js +2 -0
  61. package/dist/application/event-sourcing/stored-event-type.js.map +1 -0
  62. package/dist/application/event-sourcing/stored-event-types.d.ts +9 -0
  63. package/dist/application/event-sourcing/stored-event-types.d.ts.map +1 -0
  64. package/dist/application/event-sourcing/stored-event-types.js +2 -0
  65. package/dist/application/event-sourcing/stored-event-types.js.map +1 -0
  66. package/dist/application/event-sourcing/stored-event.d.ts +12 -0
  67. package/dist/application/event-sourcing/stored-event.d.ts.map +1 -0
  68. package/dist/application/event-sourcing/stored-event.js +2 -0
  69. package/dist/application/event-sourcing/stored-event.js.map +1 -0
  70. package/dist/application/event-sourcing/stored-json.d.ts +5 -0
  71. package/dist/application/event-sourcing/stored-json.d.ts.map +1 -0
  72. package/dist/application/event-sourcing/stored-json.js +2 -0
  73. package/dist/application/event-sourcing/stored-json.js.map +1 -0
  74. package/dist/application/event-sourcing/stored-snapshot.d.ts +11 -0
  75. package/dist/application/event-sourcing/stored-snapshot.d.ts.map +1 -0
  76. package/dist/application/event-sourcing/stored-snapshot.js +2 -0
  77. package/dist/application/event-sourcing/stored-snapshot.js.map +1 -0
  78. package/dist/application/event-sourcing/subject-key.d.ts +10 -0
  79. package/dist/application/event-sourcing/subject-key.d.ts.map +1 -0
  80. package/dist/application/event-sourcing/subject-key.js +2 -0
  81. package/dist/application/event-sourcing/subject-key.js.map +1 -0
  82. package/dist/application/event-sourcing/unreadable-event-error.d.ts +5 -0
  83. package/dist/application/event-sourcing/unreadable-event-error.d.ts.map +1 -0
  84. package/dist/application/event-sourcing/unreadable-event-error.js +8 -0
  85. package/dist/application/event-sourcing/unreadable-event-error.js.map +1 -0
  86. package/dist/application/event-sourcing/upcaster.d.ts +4 -0
  87. package/dist/application/event-sourcing/upcaster.d.ts.map +1 -0
  88. package/dist/application/event-sourcing/upcaster.js +2 -0
  89. package/dist/application/event-sourcing/upcaster.js.map +1 -0
  90. package/dist/application/persistence/append-changes.d.ts +18 -0
  91. package/dist/application/persistence/append-changes.d.ts.map +1 -0
  92. package/dist/application/persistence/append-changes.js +17 -0
  93. package/dist/application/persistence/append-changes.js.map +1 -0
  94. package/dist/application/ports/checkpoint-store.d.ts +14 -0
  95. package/dist/application/ports/checkpoint-store.d.ts.map +1 -0
  96. package/dist/application/ports/checkpoint-store.js +10 -0
  97. package/dist/application/ports/checkpoint-store.js.map +1 -0
  98. package/dist/application/ports/event-store.d.ts +24 -0
  99. package/dist/application/ports/event-store.d.ts.map +1 -0
  100. package/dist/application/ports/event-store.js +12 -0
  101. package/dist/application/ports/event-store.js.map +1 -0
  102. package/dist/application/ports/snapshot-store.d.ts +8 -0
  103. package/dist/application/ports/snapshot-store.d.ts.map +1 -0
  104. package/dist/application/ports/snapshot-store.js +7 -0
  105. package/dist/application/ports/snapshot-store.js.map +1 -0
  106. package/dist/application/ports/subject-key-store.d.ts +17 -0
  107. package/dist/application/ports/subject-key-store.d.ts.map +1 -0
  108. package/dist/application/ports/subject-key-store.js +13 -0
  109. package/dist/application/ports/subject-key-store.js.map +1 -0
  110. package/dist/declarations/decorators/projection-options.d.ts +5 -0
  111. package/dist/declarations/decorators/projection-options.d.ts.map +1 -0
  112. package/dist/declarations/decorators/projection-options.js +2 -0
  113. package/dist/declarations/decorators/projection-options.js.map +1 -0
  114. package/dist/declarations/decorators/projection.d.ts +4 -0
  115. package/dist/declarations/decorators/projection.d.ts.map +1 -1
  116. package/dist/declarations/decorators/projection.js +16 -8
  117. package/dist/declarations/decorators/projection.js.map +1 -1
  118. package/dist/declarations/model/projection-declaration.d.ts +3 -0
  119. package/dist/declarations/model/projection-declaration.d.ts.map +1 -1
  120. package/dist/declarations/model/projection-feed.d.ts +8 -0
  121. package/dist/declarations/model/projection-feed.d.ts.map +1 -0
  122. package/dist/declarations/model/projection-feed.js +2 -0
  123. package/dist/declarations/model/projection-feed.js.map +1 -0
  124. package/dist/declarations/projection/applying-projection.d.ts +14 -0
  125. package/dist/declarations/projection/applying-projection.d.ts.map +1 -0
  126. package/dist/declarations/projection/applying-projection.js +32 -0
  127. package/dist/declarations/projection/applying-projection.js.map +1 -0
  128. package/dist/declarations.d.ts +3 -0
  129. package/dist/declarations.d.ts.map +1 -1
  130. package/dist/declarations.js +1 -0
  131. package/dist/declarations.js.map +1 -1
  132. package/dist/domain/event-sourcing/aggregate-history.d.ts +10 -0
  133. package/dist/domain/event-sourcing/aggregate-history.d.ts.map +1 -0
  134. package/dist/domain/event-sourcing/aggregate-history.js +2 -0
  135. package/dist/domain/event-sourcing/aggregate-history.js.map +1 -0
  136. package/dist/domain/event-sourcing/aggregate-snapshot.d.ts +6 -0
  137. package/dist/domain/event-sourcing/aggregate-snapshot.d.ts.map +1 -0
  138. package/dist/domain/event-sourcing/aggregate-snapshot.js +2 -0
  139. package/dist/domain/event-sourcing/aggregate-snapshot.js.map +1 -0
  140. package/dist/domain/event-sourcing/appliers.d.ts +12 -0
  141. package/dist/domain/event-sourcing/appliers.d.ts.map +1 -0
  142. package/dist/domain/event-sourcing/appliers.js +2 -0
  143. package/dist/domain/event-sourcing/appliers.js.map +1 -0
  144. package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts +28 -0
  145. package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts.map +1 -0
  146. package/dist/domain/event-sourcing/event-sourced-aggregate.js +51 -0
  147. package/dist/domain/event-sourcing/event-sourced-aggregate.js.map +1 -0
  148. package/dist/domain/event-sourcing/unstored-events.d.ts +8 -0
  149. package/dist/domain/event-sourcing/unstored-events.d.ts.map +1 -0
  150. package/dist/domain/event-sourcing/unstored-events.js +7 -0
  151. package/dist/domain/event-sourcing/unstored-events.js.map +1 -0
  152. package/dist/index.d.ts +32 -32
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +32 -32
  155. package/dist/index.js.map +1 -1
  156. package/dist/infrastructure/event-sourcing/catch-up-subscription.d.ts +33 -0
  157. package/dist/infrastructure/event-sourcing/catch-up-subscription.d.ts.map +1 -0
  158. package/dist/infrastructure/event-sourcing/catch-up-subscription.js +39 -0
  159. package/dist/infrastructure/event-sourcing/catch-up-subscription.js.map +1 -0
  160. package/dist/infrastructure/event-sourcing/event-serializer.d.ts +35 -0
  161. package/dist/infrastructure/event-sourcing/event-serializer.d.ts.map +1 -0
  162. package/dist/infrastructure/event-sourcing/event-serializer.js +104 -0
  163. package/dist/infrastructure/event-sourcing/event-serializer.js.map +1 -0
  164. package/dist/infrastructure/event-sourcing/event-sourced-repository.d.ts +32 -0
  165. package/dist/infrastructure/event-sourcing/event-sourced-repository.d.ts.map +1 -0
  166. package/dist/infrastructure/event-sourcing/event-sourced-repository.js +68 -0
  167. package/dist/infrastructure/event-sourcing/event-sourced-repository.js.map +1 -0
  168. package/dist/infrastructure/event-sourcing/event-sourcing-stores.d.ts +12 -0
  169. package/dist/infrastructure/event-sourcing/event-sourcing-stores.d.ts.map +1 -0
  170. package/dist/infrastructure/event-sourcing/event-sourcing-stores.js +2 -0
  171. package/dist/infrastructure/event-sourcing/event-sourcing-stores.js.map +1 -0
  172. package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.d.ts +34 -0
  173. package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.d.ts.map +1 -0
  174. package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.js +48 -0
  175. package/dist/infrastructure/event-sourcing/event-store-projection-rebuild.js.map +1 -0
  176. package/dist/infrastructure/event-sourcing/personal-data-cipher.d.ts +19 -0
  177. package/dist/infrastructure/event-sourcing/personal-data-cipher.d.ts.map +1 -0
  178. package/dist/infrastructure/event-sourcing/personal-data-cipher.js +84 -0
  179. package/dist/infrastructure/event-sourcing/personal-data-cipher.js.map +1 -0
  180. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.d.ts +6 -0
  181. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.d.ts.map +1 -0
  182. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.js +2 -0
  183. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-options.js.map +1 -0
  184. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.d.ts +9 -0
  185. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.d.ts.map +1 -0
  186. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.js +32 -0
  187. package/dist/infrastructure/event-sourcing/postgres/event-store-tables-sql.js.map +1 -0
  188. package/dist/infrastructure/event-sourcing/postgres/event-store-tables.d.ts +9 -0
  189. package/dist/infrastructure/event-sourcing/postgres/event-store-tables.d.ts.map +1 -0
  190. package/dist/infrastructure/event-sourcing/postgres/event-store-tables.js +9 -0
  191. package/dist/infrastructure/event-sourcing/postgres/event-store-tables.js.map +1 -0
  192. package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.d.ts +3 -0
  193. package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.d.ts.map +1 -0
  194. package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.js +22 -0
  195. package/dist/infrastructure/event-sourcing/postgres/is-append-conflict.js.map +1 -0
  196. package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.d.ts +12 -0
  197. package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.d.ts.map +1 -0
  198. package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.js +26 -0
  199. package/dist/infrastructure/event-sourcing/postgres/postgres-checkpoint-store.js.map +1 -0
  200. package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.d.ts +6 -0
  201. package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.d.ts.map +1 -0
  202. package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.js +14 -0
  203. package/dist/infrastructure/event-sourcing/postgres/postgres-event-sourcing.js.map +1 -0
  204. package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.d.ts +31 -0
  205. package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.d.ts.map +1 -0
  206. package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.js +120 -0
  207. package/dist/infrastructure/event-sourcing/postgres/postgres-event-store.js.map +1 -0
  208. package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.d.ts +13 -0
  209. package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.d.ts.map +1 -0
  210. package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.js +28 -0
  211. package/dist/infrastructure/event-sourcing/postgres/postgres-snapshot-store.js.map +1 -0
  212. package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.d.ts +21 -0
  213. package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.d.ts.map +1 -0
  214. package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.js +48 -0
  215. package/dist/infrastructure/event-sourcing/postgres/postgres-subject-key-store.js.map +1 -0
  216. package/dist/infrastructure/event-sourcing/postgres/qualified-table.d.ts +4 -0
  217. package/dist/infrastructure/event-sourcing/postgres/qualified-table.d.ts.map +1 -0
  218. package/dist/infrastructure/event-sourcing/postgres/qualified-table.js +10 -0
  219. package/dist/infrastructure/event-sourcing/postgres/qualified-table.js.map +1 -0
  220. package/dist/infrastructure/event-sourcing/postgres/stored-data-from.d.ts +4 -0
  221. package/dist/infrastructure/event-sourcing/postgres/stored-data-from.d.ts.map +1 -0
  222. package/dist/infrastructure/event-sourcing/postgres/stored-data-from.js +23 -0
  223. package/dist/infrastructure/event-sourcing/postgres/stored-data-from.js.map +1 -0
  224. package/dist/infrastructure/event-sourcing/rewrite-objects.d.ts +8 -0
  225. package/dist/infrastructure/event-sourcing/rewrite-objects.d.ts.map +1 -0
  226. package/dist/infrastructure/event-sourcing/rewrite-objects.js +16 -0
  227. package/dist/infrastructure/event-sourcing/rewrite-objects.js.map +1 -0
  228. package/dist/infrastructure/event-sourcing/snapshot-policy.d.ts +14 -0
  229. package/dist/infrastructure/event-sourcing/snapshot-policy.d.ts.map +1 -0
  230. package/dist/infrastructure/event-sourcing/snapshot-policy.js +2 -0
  231. package/dist/infrastructure/event-sourcing/snapshot-policy.js.map +1 -0
  232. package/dist/infrastructure/event-sourcing/stored-origins.d.ts +5 -0
  233. package/dist/infrastructure/event-sourcing/stored-origins.d.ts.map +1 -0
  234. package/dist/infrastructure/event-sourcing/stored-origins.js +3 -0
  235. package/dist/infrastructure/event-sourcing/stored-origins.js.map +1 -0
  236. package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts +10 -0
  237. package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts.map +1 -0
  238. package/dist/infrastructure/event-sourcing/stored-stamp-of.js +14 -0
  239. package/dist/infrastructure/event-sourcing/stored-stamp-of.js.map +1 -0
  240. package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts +8 -0
  241. package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts.map +1 -0
  242. package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js +15 -0
  243. package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js.map +1 -0
  244. package/dist/infrastructure/in-memory/in-memory-event-store.d.ts +14 -0
  245. package/dist/infrastructure/in-memory/in-memory-event-store.d.ts.map +1 -0
  246. package/dist/infrastructure/in-memory/in-memory-event-store.js +37 -0
  247. package/dist/infrastructure/in-memory/in-memory-event-store.js.map +1 -0
  248. package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts +9 -0
  249. package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts.map +1 -0
  250. package/dist/infrastructure/in-memory/in-memory-snapshot-store.js +15 -0
  251. package/dist/infrastructure/in-memory/in-memory-snapshot-store.js.map +1 -0
  252. package/dist/infrastructure/in-memory/in-memory-subject-key-store.d.ts +10 -0
  253. package/dist/infrastructure/in-memory/in-memory-subject-key-store.d.ts.map +1 -0
  254. package/dist/infrastructure/in-memory/in-memory-subject-key-store.js +21 -0
  255. package/dist/infrastructure/in-memory/in-memory-subject-key-store.js.map +1 -0
  256. package/dist/infrastructure/read-model/shadow-read-model-store.d.ts +20 -0
  257. package/dist/infrastructure/read-model/shadow-read-model-store.d.ts.map +1 -0
  258. package/dist/infrastructure/read-model/shadow-read-model-store.js +25 -0
  259. package/dist/infrastructure/read-model/shadow-read-model-store.js.map +1 -0
  260. package/package.json +1 -1
@@ -0,0 +1,21 @@
1
+ import type { SubjectKey } from '../../../application/event-sourcing/subject-key.js';
2
+ import type { SubjectKeyStore } from '../../../application/ports/subject-key-store.js';
3
+ import type { SqlRun } from '../../read-model/sql-run.js';
4
+ import type { EventStoreTablesOptions } from './event-store-tables-options.js';
5
+ /**
6
+ * The keys of the data subjects on PostgreSQL: one row per subject, deleted by an erasure. A
7
+ * deleted row is gone from the table at once, and from the backups as they expire. In the
8
+ * database of the events, a backup older than an erasure holds both the sealed values and their
9
+ * key: in production give this store a `SqlRun` of another database, backed up with a shorter
10
+ * retention than the events.
11
+ */
12
+ export declare class PostgresSubjectKeyStore implements SubjectKeyStore {
13
+ private readonly run;
14
+ private readonly table;
15
+ constructor(run: SqlRun, options?: EventStoreTablesOptions);
16
+ keyFor(subject: string): Promise<SubjectKey>;
17
+ find(keyId: string): Promise<SubjectKey | undefined>;
18
+ erase(subject: string): Promise<boolean>;
19
+ private held;
20
+ }
21
+ //# sourceMappingURL=postgres-subject-key-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-subject-key-store.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-subject-key-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAK/E;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAI3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,YACmB,GAAG,EAAE,MAAM,EAC5B,OAAO,GAAE,uBAA4B,EAGtC;IAEK,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAmBjD;IAEK,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAMzD;IAEK,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI7C;YAEa,IAAI;CAOnB"}
@@ -0,0 +1,48 @@
1
+ import { randomBytes, randomUUID } from 'node:crypto';
2
+ import { qualifiedTable } from './qualified-table.js';
3
+ /**
4
+ * The keys of the data subjects on PostgreSQL: one row per subject, deleted by an erasure. A
5
+ * deleted row is gone from the table at once, and from the backups as they expire. In the
6
+ * database of the events, a backup older than an erasure holds both the sealed values and their
7
+ * key: in production give this store a `SqlRun` of another database, backed up with a shorter
8
+ * retention than the events.
9
+ */
10
+ export class PostgresSubjectKeyStore {
11
+ run;
12
+ table;
13
+ constructor(run, options = {}) {
14
+ this.run = run;
15
+ this.table = qualifiedTable(options.schema, 'subjectKeys');
16
+ }
17
+ async keyFor(subject) {
18
+ const held = await this.held(subject);
19
+ if (held !== undefined) {
20
+ return held;
21
+ }
22
+ await this.run(`insert into ${this.table} (subject, key_id, material) values ($1::text, $2::text, $3::text) on conflict (subject) do nothing`, [subject, randomUUID(), randomBytes(32).toString('base64')]);
23
+ const created = await this.held(subject);
24
+ if (created === undefined) {
25
+ throw new TypeError(`The key of ${subject} was erased while it was being created`);
26
+ }
27
+ return created;
28
+ }
29
+ async find(keyId) {
30
+ const [row] = await this.run(`select subject, key_id, material from ${this.table} where key_id = $1::text`, [
31
+ keyId,
32
+ ]);
33
+ return row === undefined ? undefined : keyOf(row);
34
+ }
35
+ async erase(subject) {
36
+ return ((await this.run(`delete from ${this.table} where subject = $1::text returning subject`, [subject])).length > 0);
37
+ }
38
+ async held(subject) {
39
+ const [row] = await this.run(`select subject, key_id, material from ${this.table} where subject = $1::text`, [
40
+ subject,
41
+ ]);
42
+ return row === undefined ? undefined : keyOf(row);
43
+ }
44
+ }
45
+ function keyOf(row) {
46
+ return { id: String(row['key_id']), subject: String(row['subject']), material: String(row['material']) };
47
+ }
48
+ //# sourceMappingURL=postgres-subject-key-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-subject-key-store.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/postgres-subject-key-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD;;;;;;GAMG;AACH,MAAM,OAAO,uBAAuB;IAIf,GAAG;IAHL,KAAK,CAAS;IAE/B,YACmB,GAAW,EAC5B,OAAO,GAA4B,EAAE;mBADpB,GAAG;QAGpB,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,CAAC,GAAG,CACZ,eAAe,IAAI,CAAC,KAAK,qGAAqG,EAC9H,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAC5D,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,cAAc,OAAO,wCAAwC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,yCAAyC,IAAI,CAAC,KAAK,0BAA0B,EAAE;YAC1G,KAAK;SACN,CAAC,CAAC;QAEH,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe;QACzB,OAAO,CACL,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,KAAK,6CAA6C,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAC/G,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,OAAe;QAChC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,yCAAyC,IAAI,CAAC,KAAK,2BAA2B,EAAE;YAC3G,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;CACF;AAED,SAAS,KAAK,CAAC,GAAQ;IACrB,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;AAC3G,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { EVENT_STORE_TABLES } from './event-store-tables.js';
2
+ /** A table of the event store, quoted and in its schema when it has one. */
3
+ export declare function qualifiedTable(schema: string | undefined, table: keyof typeof EVENT_STORE_TABLES): string;
4
+ //# sourceMappingURL=qualified-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qualified-table.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/qualified-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,kBAAkB,GAAG,MAAM,CAIzG"}
@@ -0,0 +1,10 @@
1
+ import { EVENT_STORE_TABLES } from './event-store-tables.js';
2
+ /** A table of the event store, quoted and in its schema when it has one. */
3
+ export function qualifiedTable(schema, table) {
4
+ const name = quoted(EVENT_STORE_TABLES[table]);
5
+ return schema === undefined ? name : `${quoted(schema)}.${name}`;
6
+ }
7
+ function quoted(identifier) {
8
+ return `"${identifier.replaceAll('"', '""')}"`;
9
+ }
10
+ //# sourceMappingURL=qualified-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qualified-table.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/qualified-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAAC,MAA0B,EAAE,KAAsC;IAC/F,MAAM,IAAI,GAAG,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,MAAM,CAAC,UAAkB;IAChC,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AACjD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { StoredData } from '../../../application/event-sourcing/stored-data.js';
2
+ /** A `jsonb` column as the driver answered it, parsed when it came back as text, checked to be a JSON object. */
3
+ export declare function storedDataFrom(value: unknown, where: string): StoredData;
4
+ //# sourceMappingURL=stored-data-from.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-data-from.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/stored-data-from.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAIrF,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAQxE"}
@@ -0,0 +1,23 @@
1
+ import { UnreadableEventError } from '../../../application/event-sourcing/unreadable-event-error.js';
2
+ /** A `jsonb` column as the driver answered it, parsed when it came back as text, checked to be a JSON object. */
3
+ export function storedDataFrom(value, where) {
4
+ const parsed = typeof value === 'string' ? JSON.parse(value) : value;
5
+ if (!isJsonObject(parsed)) {
6
+ throw new UnreadableEventError(`${where} is not a JSON object`);
7
+ }
8
+ return parsed;
9
+ }
10
+ function isJsonObject(value) {
11
+ if (typeof value !== 'object' || value === null) {
12
+ return false;
13
+ }
14
+ const prototype = Object.getPrototypeOf(value);
15
+ return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJson);
16
+ }
17
+ function isJson(value) {
18
+ if (value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number') {
19
+ return true;
20
+ }
21
+ return Array.isArray(value) ? value.every(isJson) : isJsonObject(value);
22
+ }
23
+ //# sourceMappingURL=stored-data-from.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-data-from.js","sourceRoot":"","sources":["../../../../src/infrastructure/event-sourcing/postgres/stored-data-from.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+DAA+D,CAAC;AAErG,iHAAiH;AACjH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAY,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAE9E,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,oBAAoB,CAAC,GAAG,KAAK,uBAAuB,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAExD,OAAO,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { StoredData } from '../../application/event-sourcing/stored-data.js';
2
+ import type { StoredJson } from '../../application/event-sourcing/stored-json.js';
3
+ /** Answers what replaces an object of the data, or `undefined` to keep it and look inside. */
4
+ type Rewrite = (object: StoredData) => Promise<StoredJson> | undefined;
5
+ /** A copy of the data where `rewrite` replaced the objects it recognised, at any depth. */
6
+ export declare function rewriteObjects(data: StoredData, rewrite: Rewrite): Promise<StoredData>;
7
+ export {};
8
+ //# sourceMappingURL=rewrite-objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewrite-objects.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/rewrite-objects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAElF,8FAA8F;AAC9F,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAEvE,2FAA2F;AAC3F,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAM5F"}
@@ -0,0 +1,16 @@
1
+ import { isStoredData } from '../../application/event-sourcing/is-stored-data.js';
2
+ /** A copy of the data where `rewrite` replaced the objects it recognised, at any depth. */
3
+ export async function rewriteObjects(data, rewrite) {
4
+ const entries = await Promise.all(Object.entries(data).map(async ([key, value]) => [key, await rewritten(value, rewrite)]));
5
+ return Object.fromEntries(entries);
6
+ }
7
+ async function rewritten(value, rewrite) {
8
+ if (Array.isArray(value)) {
9
+ return Promise.all(value.map((item) => rewritten(item, rewrite)));
10
+ }
11
+ if (!isStoredData(value)) {
12
+ return value;
13
+ }
14
+ return (await rewrite(value)) ?? rewriteObjects(value, rewrite);
15
+ }
16
+ //# sourceMappingURL=rewrite-objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewrite-objects.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/rewrite-objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAOlF,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAgB,EAAE,OAAgB;IACrE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAU,CAAC,CAClG,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAiB,EAAE,OAAgB;IAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { StoredEventData } from '../../application/event-sourcing/stored-event-data.js';
2
+ import type { SnapshotStore } from '../../application/ports/snapshot-store.js';
3
+ /** When and how an event-sourced repository keeps snapshots of its aggregates: a choice per aggregate. */
4
+ export interface SnapshotPolicy<A, S> {
5
+ readonly store: SnapshotStore;
6
+ /** A snapshot is taken by the save that makes the stream reach a multiple of this many events. */
7
+ readonly every: number;
8
+ /** The version of the shape `encode` writes: a snapshot of another version is ignored, the stream replayed from its start. */
9
+ readonly version: number;
10
+ /** The state to keep, as plain data. */
11
+ encode(aggregate: A): object;
12
+ decode(data: StoredEventData): S;
13
+ }
14
+ //# sourceMappingURL=snapshot-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-policy.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E,0GAA0G;AAC1G,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8HAA8H;IAC9H,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,CAAC,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=snapshot-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-policy.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { StoredEvent } from '../../application/event-sourcing/stored-event.js';
2
+ import type { DomainEvent } from '../../domain/domain-event.js';
3
+ /** The stored event each domain event was read from, for `storedStampOf`. */
4
+ export declare const storedOrigins: WeakMap<DomainEvent, StoredEvent>;
5
+ //# sourceMappingURL=stored-origins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-origins.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-origins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,6EAA6E;AAC7E,eAAO,MAAM,aAAa,mCAA0C,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The stored event each domain event was read from, for `storedStampOf`. */
2
+ export const storedOrigins = new WeakMap();
3
+ //# sourceMappingURL=stored-origins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-origins.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-origins.ts"],"names":[],"mappings":"AAGA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,EAA4B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { EventStamp } from '../../application/read-model/event-stamp.js';
2
+ import type { DomainEvent } from '../../domain/domain-event.js';
3
+ /**
4
+ * The stamp of a domain event read from an event store, for the row of a read model it changes:
5
+ * the id of the stored event, its instant and its version in its stream, so that the rows of one
6
+ * stream are ordered by the stream and not by clocks. `undefined` for an event that was not read
7
+ * from a store (dispatched by a save): a projection fed both ways falls back to `stampOf`.
8
+ */
9
+ export declare function storedStampOf(event: DomainEvent): EventStamp | undefined;
10
+ //# sourceMappingURL=stored-stamp-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-stamp-of.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-stamp-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAMxE"}
@@ -0,0 +1,14 @@
1
+ import { storedOrigins } from './stored-origins.js';
2
+ /**
3
+ * The stamp of a domain event read from an event store, for the row of a read model it changes:
4
+ * the id of the stored event, its instant and its version in its stream, so that the rows of one
5
+ * stream are ordered by the stream and not by clocks. `undefined` for an event that was not read
6
+ * from a store (dispatched by a save): a projection fed both ways falls back to `stampOf`.
7
+ */
8
+ export function storedStampOf(event) {
9
+ const stored = storedOrigins.get(event);
10
+ return stored === undefined
11
+ ? undefined
12
+ : { eventId: stored.id, occurredAt: stored.occurredAt, version: stored.version };
13
+ }
14
+ //# sourceMappingURL=stored-stamp-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-stamp-of.js","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/stored-stamp-of.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;AACrF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CheckpointStore } from '../../application/ports/checkpoint-store.js';
2
+ /** Reference implementation, for tests and single-process apps. */
3
+ export declare class InMemoryCheckpointStore implements CheckpointStore {
4
+ private readonly positions;
5
+ position(subscriber: string): Promise<number>;
6
+ advance(subscriber: string, from: number, to: number): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=in-memory-checkpoint-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-checkpoint-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-checkpoint-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAGnF,mEAAmE;AACnE,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAEjD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAElD;IAEK,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzE;CACF"}
@@ -0,0 +1,15 @@
1
+ import { ConcurrencyError } from '../../domain/errors/concurrency-error.js';
2
+ /** Reference implementation, for tests and single-process apps. */
3
+ export class InMemoryCheckpointStore {
4
+ positions = new Map();
5
+ async position(subscriber) {
6
+ return this.positions.get(subscriber) ?? 0;
7
+ }
8
+ async advance(subscriber, from, to) {
9
+ if ((this.positions.get(subscriber) ?? 0) !== from) {
10
+ throw new ConcurrencyError(subscriber);
11
+ }
12
+ this.positions.set(subscriber, to);
13
+ }
14
+ }
15
+ //# sourceMappingURL=in-memory-checkpoint-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-checkpoint-store.js","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-checkpoint-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,mEAAmE;AACnE,MAAM,OAAO,uBAAuB;IACjB,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEvD,KAAK,CAAC,QAAQ,CAAC,UAAkB;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAkB,EAAE,IAAY,EAAE,EAAU;QACxD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACnD,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { Appended } from '../../application/event-sourcing/appended.js';
2
+ import type { EventToAppend } from '../../application/event-sourcing/event-to-append.js';
3
+ import type { StoredEvent } from '../../application/event-sourcing/stored-event.js';
4
+ import type { EventStore } from '../../application/ports/event-store.js';
5
+ /** Reference implementation, for tests and single-process apps. Not transactional: a failed unit of work keeps what it appended. */
6
+ export declare class InMemoryEventStore implements EventStore {
7
+ private readonly events;
8
+ append(stream: string, expectedVersion: number, events: readonly EventToAppend[]): Promise<Appended>;
9
+ readStream(stream: string, after?: number): Promise<readonly StoredEvent[]>;
10
+ readAll(after: number, limit: number): Promise<readonly StoredEvent[]>;
11
+ head(): Promise<number>;
12
+ private versionOf;
13
+ }
14
+ //# sourceMappingURL=in-memory-event-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-event-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-event-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAGzE,oIAAoI;AACpI,qBAAa,kBAAmB,YAAW,UAAU;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAEtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoBzG;IAEK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAE3E;IAEK,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAE3E;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAED,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,37 @@
1
+ import { ConcurrencyError } from '../../domain/errors/concurrency-error.js';
2
+ /** Reference implementation, for tests and single-process apps. Not transactional: a failed unit of work keeps what it appended. */
3
+ export class InMemoryEventStore {
4
+ events = [];
5
+ async append(stream, expectedVersion, events) {
6
+ const version = this.versionOf(stream);
7
+ if (version !== expectedVersion) {
8
+ throw new ConcurrencyError(stream);
9
+ }
10
+ events.forEach((event, index) => {
11
+ this.events.push(structuredClone({
12
+ ...event,
13
+ metadata: event.metadata ?? {},
14
+ stream,
15
+ version: version + index + 1,
16
+ position: this.events.length + 1,
17
+ }));
18
+ });
19
+ return { version: version + events.length, position: this.events.length };
20
+ }
21
+ async readStream(stream, after = 0) {
22
+ return this.events.filter((event) => event.stream === stream && event.version > after).map(copy);
23
+ }
24
+ async readAll(after, limit) {
25
+ return this.events.slice(Math.max(0, after), Math.max(0, after) + Math.max(0, limit)).map(copy);
26
+ }
27
+ async head() {
28
+ return this.events.length;
29
+ }
30
+ versionOf(stream) {
31
+ return this.events.filter((event) => event.stream === stream).length;
32
+ }
33
+ }
34
+ function copy(event) {
35
+ return structuredClone(event);
36
+ }
37
+ //# sourceMappingURL=in-memory-event-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-event-store.js","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-event-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,oIAAoI;AACpI,MAAM,OAAO,kBAAkB;IACZ,MAAM,GAAkB,EAAE,CAAC;IAE5C,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,eAAuB,EAAE,MAAgC;QACpF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEvC,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;YAChC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,eAAe,CAAC;gBACd,GAAG,KAAK;gBACR,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;gBAC9B,MAAM;gBACN,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,CAAC;gBAC5B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;aACjC,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,KAAK,GAAG,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,KAAa;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEO,SAAS,CAAC,MAAc;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IACvE,CAAC;CACF;AAED,SAAS,IAAI,CAAC,KAAkB;IAC9B,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { StoredSnapshot } from '../../application/event-sourcing/stored-snapshot.js';
2
+ import type { SnapshotStore } from '../../application/ports/snapshot-store.js';
3
+ /** Reference implementation, for tests and single-process apps. */
4
+ export declare class InMemorySnapshotStore implements SnapshotStore {
5
+ private readonly snapshots;
6
+ find(stream: string): Promise<StoredSnapshot | undefined>;
7
+ save(snapshot: StoredSnapshot): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=in-memory-snapshot-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-snapshot-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E,mEAAmE;AACnE,qBAAa,qBAAsB,YAAW,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqC;IAEzD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAI9D;IAEK,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAMlD;CACF"}
@@ -0,0 +1,15 @@
1
+ /** Reference implementation, for tests and single-process apps. */
2
+ export class InMemorySnapshotStore {
3
+ snapshots = new Map();
4
+ async find(stream) {
5
+ const snapshot = this.snapshots.get(stream);
6
+ return snapshot === undefined ? undefined : structuredClone(snapshot);
7
+ }
8
+ async save(snapshot) {
9
+ const held = this.snapshots.get(snapshot.stream);
10
+ if (held === undefined || held.version < snapshot.version) {
11
+ this.snapshots.set(snapshot.stream, structuredClone(snapshot));
12
+ }
13
+ }
14
+ }
15
+ //# sourceMappingURL=in-memory-snapshot-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-snapshot-store.js","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-snapshot-store.ts"],"names":[],"mappings":"AAGA,mEAAmE;AACnE,MAAM,OAAO,qBAAqB;IACf,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE/D,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE5C,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAwB;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { SubjectKey } from '../../application/event-sourcing/subject-key.js';
2
+ import type { SubjectKeyStore } from '../../application/ports/subject-key-store.js';
3
+ /** Reference implementation, for tests and single-process apps: the keys die with the process. */
4
+ export declare class InMemorySubjectKeyStore implements SubjectKeyStore {
5
+ private readonly current;
6
+ keyFor(subject: string): Promise<SubjectKey>;
7
+ find(keyId: string): Promise<SubjectKey | undefined>;
8
+ erase(subject: string): Promise<boolean>;
9
+ }
10
+ //# sourceMappingURL=in-memory-subject-key-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-subject-key-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-subject-key-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEpF,kGAAkG;AAClG,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEnD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAYjD;IAEK,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAEzD;IAEK,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7C;CACF"}
@@ -0,0 +1,21 @@
1
+ import { randomBytes, randomUUID } from 'node:crypto';
2
+ /** Reference implementation, for tests and single-process apps: the keys die with the process. */
3
+ export class InMemorySubjectKeyStore {
4
+ current = new Map();
5
+ async keyFor(subject) {
6
+ const held = this.current.get(subject);
7
+ if (held !== undefined) {
8
+ return held;
9
+ }
10
+ const key = { id: randomUUID(), subject, material: randomBytes(32).toString('base64') };
11
+ this.current.set(subject, key);
12
+ return key;
13
+ }
14
+ async find(keyId) {
15
+ return [...this.current.values()].find((key) => key.id === keyId);
16
+ }
17
+ async erase(subject) {
18
+ return this.current.delete(subject);
19
+ }
20
+ }
21
+ //# sourceMappingURL=in-memory-subject-key-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-subject-key-store.js","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-memory-subject-key-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAItD,kGAAkG;AAClG,MAAM,OAAO,uBAAuB;IACjB,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEzD,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAExF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { ScopedCriteria } from '../../application/criteria/scoped-criteria.js';
2
+ import type { Page } from '../../application/pagination/page.js';
3
+ import type { ReadModelRows } from '../../application/ports/read-model-rows.js';
4
+ import type { ReadModelStore } from '../../application/ports/read-model-store.js';
5
+ import type { EventStamp } from '../../application/read-model/event-stamp.js';
6
+ import type { ReadModelWrite } from '../../application/read-model/read-model-write.js';
7
+ /**
8
+ * The copy a rebuild fills, as the store of a projection: the same writes as the live store,
9
+ * "apply if newer" included, on the rows `ReadModelTable.shadow()` gives. A projection writes, it
10
+ * does not search: `search` is refused.
11
+ */
12
+ export declare class ShadowReadModelStore<Row> implements ReadModelStore<Row> {
13
+ private readonly rows;
14
+ constructor(rows: ReadModelRows<Row>);
15
+ get(key: string): Promise<Row | undefined>;
16
+ upsertIfNewer(key: string, stamp: EventStamp, next: (current: Row | undefined) => Row | undefined): Promise<ReadModelWrite>;
17
+ delete(key: string, stamp: EventStamp): Promise<ReadModelWrite>;
18
+ search(criteria: ScopedCriteria<Row>): Promise<Page<Row>>;
19
+ }
20
+ //# sourceMappingURL=shadow-read-model-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadow-read-model-store.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/read-model/shadow-read-model-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAGvF;;;;GAIG;AACH,qBAAa,oBAAoB,CAAC,GAAG,CAAE,YAAW,cAAc,CAAC,GAAG,CAAC;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAI;IAEnD,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,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAE9D;IAED,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAExD;CACF"}
@@ -0,0 +1,25 @@
1
+ import { writeIfNewer } from './write-if-newer.js';
2
+ /**
3
+ * The copy a rebuild fills, as the store of a projection: the same writes as the live store,
4
+ * "apply if newer" included, on the rows `ReadModelTable.shadow()` gives. A projection writes, it
5
+ * does not search: `search` is refused.
6
+ */
7
+ export class ShadowReadModelStore {
8
+ rows;
9
+ constructor(rows) {
10
+ this.rows = rows;
11
+ }
12
+ async get(key) {
13
+ return (await this.rows.find(key))?.row;
14
+ }
15
+ upsertIfNewer(key, stamp, next) {
16
+ return writeIfNewer(this.rows, { key, stamp, next });
17
+ }
18
+ delete(key, stamp) {
19
+ return writeIfNewer(this.rows, { key, stamp });
20
+ }
21
+ search(criteria) {
22
+ return Promise.reject(new TypeError('The copy of a read model being rebuilt is written, never searched'));
23
+ }
24
+ }
25
+ //# sourceMappingURL=shadow-read-model-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadow-read-model-store.js","sourceRoot":"","sources":["../../../src/infrastructure/read-model/shadow-read-model-store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACF,IAAI;IAAjC,YAA6B,IAAwB;oBAAxB,IAAI;IAAuB,CAAC;IAEzD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;IAC1C,CAAC;IAED,aAAa,CACX,GAAW,EACX,KAAiB,EACjB,IAAmD;QAEnD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,KAAiB;QACnC,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,QAA6B;QAClC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,mEAAmE,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/kernel",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Framework-agnostic DDD building blocks, application ports and an in-memory event bus.",
5
5
  "license": "MIT",
6
6
  "repository": {