@ddd-ts-kit/kernel 0.113.2 → 0.115.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 (319) hide show
  1. package/README.fr.md +70 -62
  2. package/README.md +65 -57
  3. package/dist/application/audit/restamped.d.ts +9 -0
  4. package/dist/application/audit/restamped.d.ts.map +1 -0
  5. package/dist/application/audit/restamped.js +9 -0
  6. package/dist/application/audit/restamped.js.map +1 -0
  7. package/dist/application/audit/stamp-update.d.ts +1 -6
  8. package/dist/application/audit/stamp-update.d.ts.map +1 -1
  9. package/dist/application/audit/stamp-update.js +2 -8
  10. package/dist/application/audit/stamp-update.js.map +1 -1
  11. package/dist/application/background/enqueued-job.d.ts +1 -1
  12. package/dist/application/background/enqueued-job.d.ts.map +1 -1
  13. package/dist/application/error-reporting/report-once.d.ts.map +1 -1
  14. package/dist/application/error-reporting/report-once.js +2 -6
  15. package/dist/application/error-reporting/report-once.js.map +1 -1
  16. package/dist/application/event-sourcing/event-envelope.d.ts +2 -1
  17. package/dist/application/event-sourcing/event-envelope.d.ts.map +1 -1
  18. package/dist/application/event-sourcing/event-to-append.d.ts +1 -1
  19. package/dist/application/event-sourcing/event-to-append.d.ts.map +1 -1
  20. package/dist/application/execution/with-actor.d.ts +2 -2
  21. package/dist/application/execution/with-actor.js +3 -3
  22. package/dist/application/execution/with-actor.js.map +1 -1
  23. package/dist/application/files/stored-file.d.ts +3 -3
  24. package/dist/application/files/stored-file.d.ts.map +1 -1
  25. package/dist/application/hydration/hydration.d.ts.map +1 -1
  26. package/dist/application/hydration/hydration.js +3 -2
  27. package/dist/application/hydration/hydration.js.map +1 -1
  28. package/dist/application/logging/hidden-keys.d.ts +8 -0
  29. package/dist/application/logging/hidden-keys.d.ts.map +1 -0
  30. package/dist/application/logging/hidden-keys.js +10 -0
  31. package/dist/application/logging/hidden-keys.js.map +1 -0
  32. package/dist/application/logging/index.d.ts +1 -0
  33. package/dist/application/logging/index.d.ts.map +1 -1
  34. package/dist/application/logging/index.js +1 -0
  35. package/dist/application/logging/index.js.map +1 -1
  36. package/dist/application/observation/safely.d.ts +6 -0
  37. package/dist/application/observation/safely.d.ts.map +1 -0
  38. package/dist/application/observation/safely.js +13 -0
  39. package/dist/application/observation/safely.js.map +1 -0
  40. package/dist/application/persistence/append-changes.d.ts +1 -0
  41. package/dist/application/persistence/append-changes.d.ts.map +1 -1
  42. package/dist/application/persistence/append-changes.js +7 -6
  43. package/dist/application/persistence/append-changes.js.map +1 -1
  44. package/dist/application/persistence/optimistic-update.d.ts +6 -2
  45. package/dist/application/persistence/optimistic-update.d.ts.map +1 -1
  46. package/dist/application/persistence/optimistic-update.js +11 -3
  47. package/dist/application/persistence/optimistic-update.js.map +1 -1
  48. package/dist/application/ports/domain-event-dispatcher.d.ts +1 -1
  49. package/dist/application/ports/domain-event-dispatcher.js +1 -1
  50. package/dist/application/ports/logger.d.ts +3 -3
  51. package/dist/application/ports/unit-of-work.d.ts +1 -1
  52. package/dist/application/ports/unit-of-work.js +1 -1
  53. package/dist/application/read-model/stamp-of.d.ts +11 -4
  54. package/dist/application/read-model/stamp-of.d.ts.map +1 -1
  55. package/dist/application/read-model/stamp-of.js +10 -8
  56. package/dist/application/read-model/stamp-of.js.map +1 -1
  57. package/dist/application/session/anonymous-session.d.ts.map +1 -1
  58. package/dist/application/session/anonymous-session.js +4 -2
  59. package/dist/application/session/anonymous-session.js.map +1 -1
  60. package/dist/application/session/never-issued.d.ts +2 -1
  61. package/dist/application/session/never-issued.d.ts.map +1 -1
  62. package/dist/application/session/never-issued.js +4 -1
  63. package/dist/application/session/never-issued.js.map +1 -1
  64. package/dist/application/session/system-session.d.ts.map +1 -1
  65. package/dist/application/session/system-session.js +2 -2
  66. package/dist/application/session/system-session.js.map +1 -1
  67. package/dist/application/undecided/index.d.ts +3 -0
  68. package/dist/application/undecided/index.d.ts.map +1 -0
  69. package/dist/application/undecided/index.js +3 -0
  70. package/dist/application/undecided/index.js.map +1 -0
  71. package/dist/application/undecided/undecided-error.d.ts +12 -0
  72. package/dist/application/undecided/undecided-error.d.ts.map +1 -0
  73. package/dist/application/undecided/undecided-error.js +15 -0
  74. package/dist/application/undecided/undecided-error.js.map +1 -0
  75. package/dist/application/undecided/undecided.d.ts +7 -0
  76. package/dist/application/undecided/undecided.d.ts.map +1 -0
  77. package/dist/application/undecided/undecided.js +9 -0
  78. package/dist/application/undecided/undecided.js.map +1 -0
  79. package/dist/domain/aggregate-root.d.ts +6 -13
  80. package/dist/domain/aggregate-root.d.ts.map +1 -1
  81. package/dist/domain/aggregate-root.js +10 -16
  82. package/dist/domain/aggregate-root.js.map +1 -1
  83. package/dist/domain/aggregate-tracking.d.ts +30 -0
  84. package/dist/domain/aggregate-tracking.d.ts.map +1 -0
  85. package/dist/domain/aggregate-tracking.js +48 -0
  86. package/dist/domain/aggregate-tracking.js.map +1 -0
  87. package/dist/domain/domain-event.d.ts +4 -0
  88. package/dist/domain/domain-event.d.ts.map +1 -1
  89. package/dist/domain/domain-event.js.map +1 -1
  90. package/dist/domain/errors/domain-error.d.ts.map +1 -1
  91. package/dist/domain/errors/domain-error.js +2 -1
  92. package/dist/domain/errors/domain-error.js.map +1 -1
  93. package/dist/domain/errors/factual-refusal.d.ts.map +1 -1
  94. package/dist/domain/errors/factual-refusal.js +3 -0
  95. package/dist/domain/errors/factual-refusal.js.map +1 -1
  96. package/dist/domain/errors/kit-codes.d.ts +2 -0
  97. package/dist/domain/errors/kit-codes.d.ts.map +1 -1
  98. package/dist/domain/errors/kit-codes.js +2 -0
  99. package/dist/domain/errors/kit-codes.js.map +1 -1
  100. package/dist/domain/event-id-of.d.ts +8 -0
  101. package/dist/domain/event-id-of.d.ts.map +1 -0
  102. package/dist/domain/event-id-of.js +10 -0
  103. package/dist/domain/event-id-of.js.map +1 -0
  104. package/dist/domain/event-rank.d.ts +8 -0
  105. package/dist/domain/event-rank.d.ts.map +1 -0
  106. package/dist/domain/event-rank.js +8 -0
  107. package/dist/domain/event-rank.js.map +1 -0
  108. package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts +0 -1
  109. package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts.map +1 -1
  110. package/dist/domain/event-sourcing/event-sourced-aggregate.js +4 -8
  111. package/dist/domain/event-sourcing/event-sourced-aggregate.js.map +1 -1
  112. package/dist/domain/named-domain-event.d.ts +11 -4
  113. package/dist/domain/named-domain-event.d.ts.map +1 -1
  114. package/dist/domain/named-domain-event.js +14 -3
  115. package/dist/domain/named-domain-event.js.map +1 -1
  116. package/dist/domain/rank-of.d.ts +8 -0
  117. package/dist/domain/rank-of.d.ts.map +1 -0
  118. package/dist/domain/rank-of.js +14 -0
  119. package/dist/domain/rank-of.js.map +1 -0
  120. package/dist/domain/ranked.d.ts +10 -0
  121. package/dist/domain/ranked.d.ts.map +1 -0
  122. package/dist/domain/ranked.js +19 -0
  123. package/dist/domain/ranked.js.map +1 -0
  124. package/dist/domain/result/unwrap.d.ts +1 -0
  125. package/dist/domain/result/unwrap.d.ts.map +1 -1
  126. package/dist/domain/result/unwrap.js +4 -1
  127. package/dist/domain/result/unwrap.js.map +1 -1
  128. package/dist/domain/state-machine/state-machine.d.ts +4 -0
  129. package/dist/domain/state-machine/state-machine.d.ts.map +1 -1
  130. package/dist/domain/state-machine/state-machine.js +14 -4
  131. package/dist/domain/state-machine/state-machine.js.map +1 -1
  132. package/dist/domain/value-object/frozen-copy.d.ts +8 -0
  133. package/dist/domain/value-object/frozen-copy.d.ts.map +1 -0
  134. package/dist/domain/value-object/frozen-copy.js +34 -0
  135. package/dist/domain/value-object/frozen-copy.js.map +1 -0
  136. package/dist/domain/value-object/index.d.ts +2 -0
  137. package/dist/domain/value-object/index.d.ts.map +1 -0
  138. package/dist/domain/value-object/index.js +2 -0
  139. package/dist/domain/value-object/index.js.map +1 -0
  140. package/dist/domain/value-object/is-plain-record.d.ts +3 -0
  141. package/dist/domain/value-object/is-plain-record.d.ts.map +1 -0
  142. package/dist/domain/value-object/is-plain-record.js +9 -0
  143. package/dist/domain/value-object/is-plain-record.js.map +1 -0
  144. package/dist/domain/value-object/same-value.d.ts +8 -0
  145. package/dist/domain/value-object/same-value.d.ts.map +1 -0
  146. package/dist/domain/value-object/same-value.js +43 -0
  147. package/dist/domain/value-object/same-value.js.map +1 -0
  148. package/dist/domain/value-object/value-object.d.ts +28 -0
  149. package/dist/domain/value-object/value-object.d.ts.map +1 -0
  150. package/dist/domain/value-object/value-object.js +24 -0
  151. package/dist/domain/value-object/value-object.js.map +1 -0
  152. package/dist/index.d.ts +9 -12
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +9 -12
  155. package/dist/index.js.map +1 -1
  156. package/dist/infrastructure/aggregates/aggregate-mapper.d.ts +21 -0
  157. package/dist/infrastructure/aggregates/aggregate-mapper.d.ts.map +1 -0
  158. package/dist/infrastructure/aggregates/aggregate-mapper.js +18 -0
  159. package/dist/infrastructure/aggregates/aggregate-mapper.js.map +1 -0
  160. package/dist/infrastructure/aggregates/aggregate-save.d.ts +22 -0
  161. package/dist/infrastructure/aggregates/aggregate-save.d.ts.map +1 -0
  162. package/dist/infrastructure/aggregates/aggregate-save.js +2 -0
  163. package/dist/infrastructure/aggregates/aggregate-save.js.map +1 -0
  164. package/dist/infrastructure/aggregates/as-found.d.ts +8 -0
  165. package/dist/infrastructure/aggregates/as-found.d.ts.map +1 -0
  166. package/dist/infrastructure/aggregates/as-found.js +2 -0
  167. package/dist/infrastructure/aggregates/as-found.js.map +1 -0
  168. package/dist/infrastructure/aggregates/give-back.d.ts +9 -0
  169. package/dist/infrastructure/aggregates/give-back.d.ts.map +1 -0
  170. package/dist/infrastructure/aggregates/give-back.js +13 -0
  171. package/dist/infrastructure/aggregates/give-back.js.map +1 -0
  172. package/dist/infrastructure/aggregates/index.d.ts +7 -0
  173. package/dist/infrastructure/aggregates/index.d.ts.map +1 -0
  174. package/dist/infrastructure/aggregates/index.js +7 -0
  175. package/dist/infrastructure/aggregates/index.js.map +1 -0
  176. package/dist/infrastructure/aggregates/loaded-at.d.ts +8 -0
  177. package/dist/infrastructure/aggregates/loaded-at.d.ts.map +1 -0
  178. package/dist/infrastructure/aggregates/loaded-at.js +12 -0
  179. package/dist/infrastructure/aggregates/loaded-at.js.map +1 -0
  180. package/dist/infrastructure/aggregates/noted-as-found.d.ts +8 -0
  181. package/dist/infrastructure/aggregates/noted-as-found.d.ts.map +1 -0
  182. package/dist/infrastructure/aggregates/noted-as-found.js +15 -0
  183. package/dist/infrastructure/aggregates/noted-as-found.js.map +1 -0
  184. package/dist/infrastructure/aggregates/recorded-events-of.d.ts +4 -0
  185. package/dist/infrastructure/aggregates/recorded-events-of.d.ts.map +1 -0
  186. package/dist/infrastructure/aggregates/recorded-events-of.js +6 -0
  187. package/dist/infrastructure/aggregates/recorded-events-of.js.map +1 -0
  188. package/dist/infrastructure/aggregates/save-aggregate-row.d.ts +23 -0
  189. package/dist/infrastructure/aggregates/save-aggregate-row.d.ts.map +1 -0
  190. package/dist/infrastructure/aggregates/save-aggregate-row.js +17 -0
  191. package/dist/infrastructure/aggregates/save-aggregate-row.js.map +1 -0
  192. package/dist/infrastructure/aggregates/stored-at.d.ts +7 -0
  193. package/dist/infrastructure/aggregates/stored-at.d.ts.map +1 -0
  194. package/dist/infrastructure/aggregates/stored-at.js +14 -0
  195. package/dist/infrastructure/aggregates/stored-at.js.map +1 -0
  196. package/dist/infrastructure/aggregates/take-recorded-events.d.ts +9 -0
  197. package/dist/infrastructure/aggregates/take-recorded-events.d.ts.map +1 -0
  198. package/dist/infrastructure/aggregates/take-recorded-events.js +17 -0
  199. package/dist/infrastructure/aggregates/take-recorded-events.js.map +1 -0
  200. package/dist/infrastructure/aggregates/unstored-events-of.d.ts +4 -0
  201. package/dist/infrastructure/aggregates/unstored-events-of.d.ts.map +1 -0
  202. package/dist/infrastructure/aggregates/unstored-events-of.js +7 -0
  203. package/dist/infrastructure/aggregates/unstored-events-of.js.map +1 -0
  204. package/dist/infrastructure/clock/fixed-clock.d.ts +2 -1
  205. package/dist/infrastructure/clock/fixed-clock.d.ts.map +1 -1
  206. package/dist/infrastructure/clock/fixed-clock.js +5 -4
  207. package/dist/infrastructure/clock/fixed-clock.js.map +1 -1
  208. package/dist/infrastructure/context/scoped-actor-context.d.ts.map +1 -1
  209. package/dist/infrastructure/context/scoped-actor-context.js +2 -6
  210. package/dist/infrastructure/context/scoped-actor-context.js.map +1 -1
  211. package/dist/infrastructure/domain-events/announce-domain-events.d.ts +1 -1
  212. package/dist/infrastructure/domain-events/announce-domain-events.js +1 -1
  213. package/dist/infrastructure/domain-events/dispatching-on-save.d.ts +1 -1
  214. package/dist/infrastructure/domain-events/dispatching-on-save.d.ts.map +1 -1
  215. package/dist/infrastructure/domain-events/dispatching-on-save.js +3 -2
  216. package/dist/infrastructure/domain-events/dispatching-on-save.js.map +1 -1
  217. package/dist/infrastructure/domain-events/index.d.ts +13 -0
  218. package/dist/infrastructure/domain-events/index.d.ts.map +1 -0
  219. package/dist/infrastructure/domain-events/index.js +13 -0
  220. package/dist/infrastructure/domain-events/index.js.map +1 -0
  221. package/dist/infrastructure/domain-events/recorded-aggregates.d.ts +2 -5
  222. package/dist/infrastructure/domain-events/recorded-aggregates.d.ts.map +1 -1
  223. package/dist/infrastructure/domain-events/recorded-aggregates.js +3 -5
  224. package/dist/infrastructure/domain-events/recorded-aggregates.js.map +1 -1
  225. package/dist/infrastructure/domain-events/unit-of-work-aborted-error.d.ts +10 -0
  226. package/dist/infrastructure/domain-events/unit-of-work-aborted-error.d.ts.map +1 -0
  227. package/dist/infrastructure/domain-events/unit-of-work-aborted-error.js +13 -0
  228. package/dist/infrastructure/domain-events/unit-of-work-aborted-error.js.map +1 -0
  229. package/dist/infrastructure/domain-events/unit-of-work-over.d.ts +43 -0
  230. package/dist/infrastructure/domain-events/unit-of-work-over.d.ts.map +1 -0
  231. package/dist/infrastructure/domain-events/unit-of-work-over.js +132 -0
  232. package/dist/infrastructure/domain-events/unit-of-work-over.js.map +1 -0
  233. package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts +9 -1
  234. package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts.map +1 -1
  235. package/dist/infrastructure/domain-events/unit-of-work-scope.js.map +1 -1
  236. package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.d.ts +8 -0
  237. package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.d.ts.map +1 -0
  238. package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.js +11 -0
  239. package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.js.map +1 -0
  240. package/dist/infrastructure/domain-events/when-committed.d.ts.map +1 -1
  241. package/dist/infrastructure/domain-events/when-committed.js +2 -9
  242. package/dist/infrastructure/domain-events/when-committed.js.map +1 -1
  243. package/dist/infrastructure/event-sourcing/aggregate-id-of.d.ts +4 -0
  244. package/dist/infrastructure/event-sourcing/aggregate-id-of.d.ts.map +1 -0
  245. package/dist/infrastructure/event-sourcing/aggregate-id-of.js +6 -0
  246. package/dist/infrastructure/event-sourcing/aggregate-id-of.js.map +1 -0
  247. package/dist/infrastructure/event-sourcing/event-serializer.d.ts +3 -4
  248. package/dist/infrastructure/event-sourcing/event-serializer.d.ts.map +1 -1
  249. package/dist/infrastructure/event-sourcing/event-serializer.js +10 -12
  250. package/dist/infrastructure/event-sourcing/event-serializer.js.map +1 -1
  251. package/dist/infrastructure/event-sourcing/event-store-personal-data-export.d.ts.map +1 -1
  252. package/dist/infrastructure/event-sourcing/event-store-personal-data-export.js +1 -5
  253. package/dist/infrastructure/event-sourcing/event-store-personal-data-export.js.map +1 -1
  254. package/dist/infrastructure/events/idempotent.d.ts.map +1 -1
  255. package/dist/infrastructure/events/idempotent.js +9 -3
  256. package/dist/infrastructure/events/idempotent.js.map +1 -1
  257. package/dist/infrastructure/in-memory/as-json-carries.d.ts +9 -0
  258. package/dist/infrastructure/in-memory/as-json-carries.d.ts.map +1 -0
  259. package/dist/infrastructure/in-memory/as-json-carries.js +12 -0
  260. package/dist/infrastructure/in-memory/as-json-carries.js.map +1 -0
  261. package/dist/infrastructure/in-memory/composite-key.d.ts +6 -0
  262. package/dist/infrastructure/in-memory/composite-key.d.ts.map +1 -0
  263. package/dist/infrastructure/in-memory/composite-key.js +8 -0
  264. package/dist/infrastructure/in-memory/composite-key.js.map +1 -0
  265. package/dist/infrastructure/in-memory/in-memory-cache.d.ts +3 -1
  266. package/dist/infrastructure/in-memory/in-memory-cache.d.ts.map +1 -1
  267. package/dist/infrastructure/in-memory/in-memory-cache.js +7 -3
  268. package/dist/infrastructure/in-memory/in-memory-cache.js.map +1 -1
  269. package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.d.ts +0 -1
  270. package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.d.ts.map +1 -1
  271. package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.js +2 -9
  272. package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.js.map +1 -1
  273. package/dist/infrastructure/in-memory/in-memory-event-bus.d.ts +7 -14
  274. package/dist/infrastructure/in-memory/in-memory-event-bus.d.ts.map +1 -1
  275. package/dist/infrastructure/in-memory/in-memory-event-bus.js +17 -9
  276. package/dist/infrastructure/in-memory/in-memory-event-bus.js.map +1 -1
  277. package/dist/infrastructure/in-memory/in-memory-event-store.d.ts +1 -0
  278. package/dist/infrastructure/in-memory/in-memory-event-store.d.ts.map +1 -1
  279. package/dist/infrastructure/in-memory/in-memory-event-store.js +11 -10
  280. package/dist/infrastructure/in-memory/in-memory-event-store.js.map +1 -1
  281. package/dist/infrastructure/in-memory/in-memory-process-store.d.ts.map +1 -1
  282. package/dist/infrastructure/in-memory/in-memory-process-store.js +4 -6
  283. package/dist/infrastructure/in-memory/in-memory-process-store.js.map +1 -1
  284. package/dist/infrastructure/in-memory/in-memory-processed-event-store.d.ts.map +1 -1
  285. package/dist/infrastructure/in-memory/in-memory-processed-event-store.js +3 -6
  286. package/dist/infrastructure/in-memory/in-memory-processed-event-store.js.map +1 -1
  287. package/dist/infrastructure/in-memory/in-memory-unit-of-work.d.ts +4 -2
  288. package/dist/infrastructure/in-memory/in-memory-unit-of-work.d.ts.map +1 -1
  289. package/dist/infrastructure/in-memory/in-memory-unit-of-work.js +6 -4
  290. package/dist/infrastructure/in-memory/in-memory-unit-of-work.js.map +1 -1
  291. package/dist/infrastructure/in-memory/in-process-bus.d.ts +1 -0
  292. package/dist/infrastructure/in-memory/in-process-bus.d.ts.map +1 -1
  293. package/dist/infrastructure/in-memory/in-process-bus.js +4 -3
  294. package/dist/infrastructure/in-memory/in-process-bus.js.map +1 -1
  295. package/dist/infrastructure/in-memory/unit-of-work-middleware.d.ts +5 -5
  296. package/dist/infrastructure/in-memory/unit-of-work-middleware.d.ts.map +1 -1
  297. package/dist/infrastructure/in-memory/unit-of-work-middleware.js +13 -4
  298. package/dist/infrastructure/in-memory/unit-of-work-middleware.js.map +1 -1
  299. package/package.json +4 -4
  300. package/dist/domain/event-sourcing/unstored-events.d.ts +0 -8
  301. package/dist/domain/event-sourcing/unstored-events.d.ts.map +0 -1
  302. package/dist/domain/event-sourcing/unstored-events.js +0 -7
  303. package/dist/domain/event-sourcing/unstored-events.js.map +0 -1
  304. package/dist/domain/value-object.d.ts +0 -12
  305. package/dist/domain/value-object.d.ts.map +0 -1
  306. package/dist/domain/value-object.js +0 -40
  307. package/dist/domain/value-object.js.map +0 -1
  308. package/dist/infrastructure/domain-events/within-unit-of-work.d.ts +0 -25
  309. package/dist/infrastructure/domain-events/within-unit-of-work.d.ts.map +0 -1
  310. package/dist/infrastructure/domain-events/within-unit-of-work.js +0 -85
  311. package/dist/infrastructure/domain-events/within-unit-of-work.js.map +0 -1
  312. package/dist/infrastructure/event-sourcing/stored-origins.d.ts +0 -5
  313. package/dist/infrastructure/event-sourcing/stored-origins.d.ts.map +0 -1
  314. package/dist/infrastructure/event-sourcing/stored-origins.js +0 -3
  315. package/dist/infrastructure/event-sourcing/stored-origins.js.map +0 -1
  316. package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts +0 -11
  317. package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts.map +0 -1
  318. package/dist/infrastructure/event-sourcing/stored-stamp-of.js +0 -15
  319. package/dist/infrastructure/event-sourcing/stored-stamp-of.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Says at which version an aggregate was loaded: what a repository adapter calls on the aggregate
3
+ * its mapper rebuilt, with the version of the row it read. The next save expects that version.
4
+ *
5
+ * return row === undefined ? undefined : loadedAt(InvoiceMapper.toDomain(row), row.version);
6
+ */
7
+ export declare function loadedAt<A extends object>(aggregate: A, version: number): A;
8
+ //# sourceMappingURL=loaded-at.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaded-at.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/loaded-at.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAI3E"}
@@ -0,0 +1,12 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ /**
3
+ * Says at which version an aggregate was loaded: what a repository adapter calls on the aggregate
4
+ * its mapper rebuilt, with the version of the row it read. The next save expects that version.
5
+ *
6
+ * return row === undefined ? undefined : loadedAt(InvoiceMapper.toDomain(row), row.version);
7
+ */
8
+ export function loadedAt(aggregate, version) {
9
+ AggregateTracking.of(aggregate).version = version;
10
+ return aggregate;
11
+ }
12
+ //# sourceMappingURL=loaded-at.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaded-at.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/loaded-at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAmB,SAAY,EAAE,OAAe;IACtE,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;IAElD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ import type { AsFound } from './as-found.js';
3
+ /**
4
+ * Notes, once per unit of work and before a save moves it, how the unit of work in progress found
5
+ * an aggregate. Nothing is noted outside of one: a save made alone has nothing to roll back.
6
+ */
7
+ export declare function notedAsFound(tracking: AggregateTracking): AsFound | undefined;
8
+ //# sourceMappingURL=noted-as-found.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noted-as-found.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/noted-as-found.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,GAAG,SAAS,CAY7E"}
@@ -0,0 +1,15 @@
1
+ import { unitOfWorkScope } from '../domain-events/unit-of-work-scope.js';
2
+ /**
3
+ * Notes, once per unit of work and before a save moves it, how the unit of work in progress found
4
+ * an aggregate. Nothing is noted outside of one: a save made alone has nothing to roll back.
5
+ */
6
+ export function notedAsFound(tracking) {
7
+ const scope = unitOfWorkScope.getStore();
8
+ if (scope?.found === undefined || scope.stage === 'after-commit' || scope.stage === 'closed') {
9
+ return undefined;
10
+ }
11
+ const found = scope.found.get(tracking) ?? { version: tracking.version, appended: tracking.appended, taken: [] };
12
+ scope.found.set(tracking, found);
13
+ return found;
14
+ }
15
+ //# sourceMappingURL=noted-as-found.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noted-as-found.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/noted-as-found.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGtE;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,QAA2B;IACtD,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;IAEzC,IAAI,KAAK,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,cAAc,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC7F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAEjH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEjC,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DomainEvent } from '../../domain/domain-event.js';
2
+ /** The events an aggregate recorded and has yet to announce, oldest first: read, and left on the aggregate. */
3
+ export declare function recordedEventsOf(aggregate: object): readonly DomainEvent[];
4
+ //# sourceMappingURL=recorded-events-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recorded-events-of.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/recorded-events-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,+GAA+G;AAC/G,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAE1E"}
@@ -0,0 +1,6 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ /** The events an aggregate recorded and has yet to announce, oldest first: read, and left on the aggregate. */
3
+ export function recordedEventsOf(aggregate) {
4
+ return [...AggregateTracking.of(aggregate).recorded];
5
+ }
6
+ //# sourceMappingURL=recorded-events-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recorded-events-of.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/recorded-events-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,+GAA+G;AAC/G,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,CAAC,GAAG,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { AuditStamp } from '../../application/audit/audit-stamp.js';
2
+ import type { UpdateStamp } from '../../application/audit/update-stamp.js';
3
+ import type { AggregateSave } from './aggregate-save.js';
4
+ /** The two statements an ORM writes the row of an aggregate with. */
5
+ export interface RowStatements<Columns> {
6
+ /** Inserts the row unless its key exists, and says whether it did. */
7
+ insert(row: Columns & {
8
+ readonly version: number;
9
+ }, stamp: AuditStamp): Promise<boolean>;
10
+ /** Updates the row while it still holds `expected`, and answers how many rows it wrote. */
11
+ update(row: Columns & {
12
+ readonly version: number;
13
+ }, stamp: UpdateStamp, expected: number): Promise<number>;
14
+ }
15
+ /**
16
+ * What the `saveAggregate` of each ORM package is made of: the save of an aggregate under
17
+ * optimistic concurrency (`optimisticUpdate`), as an insert the first time and an update guarded by
18
+ * the version afterwards, each with its audit stamp. A project calls the function of its ORM.
19
+ */
20
+ export declare function saveAggregateRow<Columns extends {
21
+ readonly id: string | number;
22
+ }>({ aggregate, row, scope, clock }: AggregateSave<Columns>, statements: RowStatements<Columns>): Promise<void>;
23
+ //# sourceMappingURL=save-aggregate-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-aggregate-row.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/save-aggregate-row.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qEAAqE;AACrE,MAAM,WAAW,aAAa,CAAC,OAAO;IACpC,sEAAsE;IACtE,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzF,2FAA2F;IAC3F,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5G;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAC/E,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,aAAa,CAAC,OAAO,CAAC,EACxD,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1,17 @@
1
+ import { optimisticUpdate } from '../../application/persistence/optimistic-update.js';
2
+ import { stampCreation } from '../../application/audit/stamp-creation.js';
3
+ import { stampUpdate } from '../../application/audit/stamp-update.js';
4
+ /**
5
+ * What the `saveAggregate` of each ORM package is made of: the save of an aggregate under
6
+ * optimistic concurrency (`optimisticUpdate`), as an insert the first time and an update guarded by
7
+ * the version afterwards, each with its audit stamp. A project calls the function of its ORM.
8
+ */
9
+ export function saveAggregateRow({ aggregate, row, scope, clock }, statements) {
10
+ return optimisticUpdate(aggregate, async ({ expected, next }) => {
11
+ const versioned = { ...row, version: next };
12
+ return expected === 0
13
+ ? Number(await statements.insert(versioned, stampCreation(scope, clock)))
14
+ : statements.update(versioned, stampUpdate(scope, clock), expected);
15
+ });
16
+ }
17
+ //# sourceMappingURL=save-aggregate-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-aggregate-row.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/save-aggregate-row.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAanE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAA0B,EACxD,UAAkC;IAElC,OAAO,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;QAC9D,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAE5C,OAAO,QAAQ,KAAK,CAAC;YACnB,CAAC,CAAC,MAAM,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACzE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Notes what a save wrote: the aggregate stands at `version`, and `appended` more of its recorded
3
+ * events are behind that version, in its stream when it has one. Inside a unit of work, the
4
+ * aggregate is first noted as it stood: a rollback puts it back.
5
+ */
6
+ export declare function storedAt(aggregate: object, version: number, appended?: number): void;
7
+ //# sourceMappingURL=stored-at.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-at.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/stored-at.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,IAAI,CAM/E"}
@@ -0,0 +1,14 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ import { notedAsFound } from './noted-as-found.js';
3
+ /**
4
+ * Notes what a save wrote: the aggregate stands at `version`, and `appended` more of its recorded
5
+ * events are behind that version, in its stream when it has one. Inside a unit of work, the
6
+ * aggregate is first noted as it stood: a rollback puts it back.
7
+ */
8
+ export function storedAt(aggregate, version, appended = 0) {
9
+ const tracking = AggregateTracking.of(aggregate);
10
+ notedAsFound(tracking);
11
+ tracking.version = version;
12
+ tracking.appended += appended;
13
+ }
14
+ //# sourceMappingURL=stored-at.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-at.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/stored-at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAiB,EAAE,OAAe,EAAE,QAAQ,GAAG,CAAC;IACvE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAEjD,YAAY,CAAC,QAAQ,CAAC,CAAC;IACvB,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC;AAChC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { DomainEvent } from '../../domain/domain-event.js';
2
+ /**
3
+ * Hands over the events an aggregate recorded and leaves it with none. Called for the handlers by
4
+ * the save of the repository (`dispatchingOnSave`); a use case and a repository adapter never
5
+ * call it (`domain-events/dispatched-on-save`). Inside a unit of work they are noted as taken: a
6
+ * rollback gives them back to the aggregate.
7
+ */
8
+ export declare function takeRecordedEvents(aggregate: object): DomainEvent[];
9
+ //# sourceMappingURL=take-recorded-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"take-recorded-events.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/take-recorded-events.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CASnE"}
@@ -0,0 +1,17 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ import { notedAsFound } from './noted-as-found.js';
3
+ /**
4
+ * Hands over the events an aggregate recorded and leaves it with none. Called for the handlers by
5
+ * the save of the repository (`dispatchingOnSave`); a use case and a repository adapter never
6
+ * call it (`domain-events/dispatched-on-save`). Inside a unit of work they are noted as taken: a
7
+ * rollback gives them back to the aggregate.
8
+ */
9
+ export function takeRecordedEvents(aggregate) {
10
+ const tracking = AggregateTracking.of(aggregate);
11
+ const found = notedAsFound(tracking);
12
+ const taken = tracking.recorded.splice(0);
13
+ tracking.appended = 0;
14
+ found?.taken.push(...taken);
15
+ return taken;
16
+ }
17
+ //# sourceMappingURL=take-recorded-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"take-recorded-events.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/take-recorded-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE1C,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAE5B,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DomainEvent } from '../../domain/domain-event.js';
2
+ /** The events an aggregate recorded that no save wrote yet, oldest first: what its next save stores, or counts its version by. */
3
+ export declare function unstoredEventsOf(aggregate: object): readonly DomainEvent[];
4
+ //# sourceMappingURL=unstored-events-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unstored-events-of.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/unstored-events-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,kIAAkI;AAClI,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAI1E"}
@@ -0,0 +1,7 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
2
+ /** The events an aggregate recorded that no save wrote yet, oldest first: what its next save stores, or counts its version by. */
3
+ export function unstoredEventsOf(aggregate) {
4
+ const { recorded, appended } = AggregateTracking.of(aggregate);
5
+ return recorded.slice(appended);
6
+ }
7
+ //# sourceMappingURL=unstored-events-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unstored-events-of.js","sourceRoot":"","sources":["../../../src/infrastructure/aggregates/unstored-events-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,kIAAkI;AAClI,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAE/D,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { Clock } from '../../application/ports/clock.js';
2
+ /** A clock that stands still until a test advances it. Each `now()` is a date of its own, as `SystemClock` answers. */
2
3
  export declare class FixedClock implements Clock {
3
- private current;
4
+ private instant;
4
5
  constructor(current: Date);
5
6
  now(): Date;
6
7
  advance(ms: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"fixed-clock.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/clock/fixed-clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAE3D,qBAAa,UAAW,YAAW,KAAK;IAC1B,OAAO,CAAC,OAAO;IAA3B,YAAoB,OAAO,EAAE,IAAI,EAAI;IAErC,GAAG,IAAI,IAAI,CAEV;IAED,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAExB;CACF"}
1
+ {"version":3,"file":"fixed-clock.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/clock/fixed-clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAE3D,uHAAuH;AACvH,qBAAa,UAAW,YAAW,KAAK;IACtC,OAAO,CAAC,OAAO,CAAS;IAExB,YAAY,OAAO,EAAE,IAAI,EAExB;IAED,GAAG,IAAI,IAAI,CAEV;IAED,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAExB;CACF"}
@@ -1,13 +1,14 @@
1
+ /** A clock that stands still until a test advances it. Each `now()` is a date of its own, as `SystemClock` answers. */
1
2
  export class FixedClock {
2
- current;
3
+ instant;
3
4
  constructor(current) {
4
- this.current = current;
5
+ this.instant = current.getTime();
5
6
  }
6
7
  now() {
7
- return this.current;
8
+ return new Date(this.instant);
8
9
  }
9
10
  advance(ms) {
10
- this.current = new Date(this.current.getTime() + ms);
11
+ this.instant += ms;
11
12
  }
12
13
  }
13
14
  //# sourceMappingURL=fixed-clock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixed-clock.js","sourceRoot":"","sources":["../../../src/infrastructure/clock/fixed-clock.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAU;IACD,OAAO;IAA3B,YAAoB,OAAa;uBAAb,OAAO;IAAS,CAAC;IAErC,GAAG;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}
1
+ {"version":3,"file":"fixed-clock.js","sourceRoot":"","sources":["../../../src/infrastructure/clock/fixed-clock.ts"],"names":[],"mappings":"AAEA,uHAAuH;AACvH,MAAM,OAAO,UAAU;IACb,OAAO,CAAS;IAExB,YAAY,OAAa;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAED,GAAG;QACD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"scoped-actor-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/scoped-actor-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAEnD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAFjC,YACmB,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,WAAW,EAC1C;IAEJ,OAAO,IAAI,KAAK,GAAG,SAAS,CAE3B;IAED,OAAO,IAAI,KAAK,CAQf;IAED,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CASrC;CACF"}
1
+ {"version":3,"file":"scoped-actor-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/scoped-actor-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAEnD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAFjC,YACmB,KAAK,EAAE,cAAc,EACrB,cAAc,EAAE,WAAW,EAC1C;IAEJ,OAAO,IAAI,KAAK,GAAG,SAAS,CAE3B;IAED,OAAO,IAAI,KAAK,CAEf;IAED,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CASrC;CACF"}
@@ -1,6 +1,6 @@
1
- import { NoCurrentActorError } from '../../application/actor/no-current-actor-error.js';
2
1
  import { executionContext } from '../../application/execution/execution-context.js';
3
2
  import { withActor } from '../../application/execution/with-actor.js';
3
+ import { requiredActor } from './required-actor.js';
4
4
  /**
5
5
  * The `ActorContext` of an application that has an execution scope: one source of truth, so
6
6
  * the two cannot disagree. The current actor is the actor of the current execution context;
@@ -18,11 +18,7 @@ export class ScopedActorContext {
18
18
  return this.scope.current()?.actor;
19
19
  }
20
20
  require() {
21
- const actor = this.current();
22
- if (actor === undefined) {
23
- throw new NoCurrentActorError();
24
- }
25
- return actor;
21
+ return requiredActor(this.current());
26
22
  }
27
23
  run(actor, work) {
28
24
  const current = this.scope.current();
@@ -1 +1 @@
1
- {"version":3,"file":"scoped-actor-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/scoped-actor-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAKnE;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAEV,KAAK;IACL,cAAc;IAFjC,YACmB,KAAqB,EACrB,cAA2B;qBAD3B,KAAK;8BACL,cAAc;IAC9B,CAAC;IAEJ,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC;IACrC,CAAC;IAED,OAAO;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAE7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,mBAAmB,EAAE,CAAC;QAClC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAI,KAAY,EAAE,IAAa;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAErC,MAAM,OAAO,GACX,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YAC5F,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
1
+ {"version":3,"file":"scoped-actor-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/scoped-actor-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAInE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAEV,KAAK;IACL,cAAc;IAFjC,YACmB,KAAqB,EACrB,cAA2B;qBAD3B,KAAK;8BACL,cAAc;IAC9B,CAAC;IAEJ,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC;IACrC,CAAC;IAED,OAAO;QACL,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAI,KAAY,EAAE,IAAa;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAErC,MAAM,OAAO,GACX,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YAC5F,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -5,7 +5,7 @@ import type { DomainEvent } from '../../domain/domain-event.js';
5
5
  * Hands over the events a save pulled from its aggregates.
6
6
  *
7
7
  * Inside a unit of work they only join its queue, behind what earlier saves recorded: the unit
8
- * of work dispatches them at its end, before the commit (`withinUnitOfWork`), and the promise
8
+ * of work dispatches them at its end, before the commit (`unitOfWorkOver`), and the promise
9
9
  * resolves at once.
10
10
  *
11
11
  * Outside of any, the save is all there is to wait for: they are dispatched now, `before-commit`
@@ -9,7 +9,7 @@ import { unitOfWorkScope } from './unit-of-work-scope.js';
9
9
  * Hands over the events a save pulled from its aggregates.
10
10
  *
11
11
  * Inside a unit of work they only join its queue, behind what earlier saves recorded: the unit
12
- * of work dispatches them at its end, before the commit (`withinUnitOfWork`), and the promise
12
+ * of work dispatches them at its end, before the commit (`unitOfWorkOver`), and the promise
13
13
  * resolves at once.
14
14
  *
15
15
  * Outside of any, the save is all there is to wait for: they are dispatched now, `before-commit`
@@ -16,7 +16,7 @@ type Scoping = () => ExecutionScope | undefined;
16
16
  * The repository is wrapped in place, as tracing and the aspects do, so the same object is
17
17
  * answered and wrapping twice is a no-op; a sealed or frozen one is fronted by a proxy. The
18
18
  * dispatcher is asked for at each dispatch. An adapter contains no dispatch code: one that
19
- * pulls the events itself leaves nothing to dispatch here.
19
+ * takes the events itself leaves nothing to dispatch here.
20
20
  *
21
21
  * Given the execution scope, the handlers run in the execution context of the save (its tenant, its
22
22
  * actor, its correlation id), also when the unit of work that dispatches them was opened in another:
@@ -1 +1 @@
1
- {"version":3,"file":"dispatching-on-save.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/dispatching-on-save.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAQ9E,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;AAEjE,6GAA6G;AAC7G,KAAK,OAAO,GAAG,MAAM,cAAc,GAAG,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAgB9G"}
1
+ {"version":3,"file":"dispatching-on-save.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/dispatching-on-save.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAS9E,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;AAEjE,6GAA6G;AAC7G,KAAK,OAAO,GAAG,MAAM,cAAc,GAAG,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAgB9G"}
@@ -1,3 +1,4 @@
1
+ import { takeRecordedEvents } from '../aggregates/take-recorded-events.js';
1
2
  import { announceDomainEvents } from './announce-domain-events.js';
2
3
  import { recordedAggregates } from './recorded-aggregates.js';
3
4
  import { SaveAfterCommitError } from './save-after-commit-error.js';
@@ -16,7 +17,7 @@ const wrapped = new WeakSet();
16
17
  * The repository is wrapped in place, as tracing and the aspects do, so the same object is
17
18
  * answered and wrapping twice is a no-op; a sealed or frozen one is fronted by a proxy. The
18
19
  * dispatcher is asked for at each dispatch. An adapter contains no dispatch code: one that
19
- * pulls the events itself leaves nothing to dispatch here.
20
+ * takes the events itself leaves nothing to dispatch here.
20
21
  *
21
22
  * Given the execution scope, the handlers run in the execution context of the save (its tenant, its
22
23
  * actor, its correlation id), also when the unit of work that dispatches them was opened in another:
@@ -58,7 +59,7 @@ function isMethod(value) {
58
59
  function announcing(original, dispatcher, scope) {
59
60
  const announced = async (args, result) => {
60
61
  const value = await result;
61
- await announceDomainEvents(recordedAggregates(args).flatMap((aggregate) => aggregate.pullEvents()), dispatcher(), scope?.());
62
+ await announceDomainEvents(recordedAggregates(args).flatMap(takeRecordedEvents), dispatcher(), scope?.());
62
63
  return value;
63
64
  };
64
65
  const wrapper = original.constructor.name === 'AsyncFunction'
@@ -1 +1 @@
1
- {"version":3,"file":"dispatching-on-save.js","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/dispatching-on-save.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AASvD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAU,CAAC;AAEtC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAmB,UAAa,EAAE,UAAuB,EAAE,KAAe;IACzG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEhH,OAAO,CAAC,GAAG,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AAW,EAAE,QAAqC;IACpF,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,UAAU,IAAI,KAAK,CAAC;QAExF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gHAAgH;AAChH,SAAS,OAAO,CAAmB,QAAW,EAAE,QAAqC;IACnF,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAiB;YACrC,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAElF,OAAO,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './after-commit.js';
2
+ export * from './announce-domain-events.js';
3
+ export * from './at-commit.js';
4
+ export * from './commit-step.js';
5
+ export * from './dispatching-on-save.js';
6
+ export * from './report-after-commit-failures.js';
7
+ export * from './save-after-commit-error.js';
8
+ export * from './unit-of-work-aborted-error.js';
9
+ export * from './unit-of-work-over.js';
10
+ export * from './unit-of-work-stage.js';
11
+ export * from './unscoped-unit-of-work-error.js';
12
+ export * from './when-committed.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './after-commit.js';
2
+ export * from './announce-domain-events.js';
3
+ export * from './at-commit.js';
4
+ export * from './commit-step.js';
5
+ export * from './dispatching-on-save.js';
6
+ export * from './report-after-commit-failures.js';
7
+ export * from './save-after-commit-error.js';
8
+ export * from './unit-of-work-aborted-error.js';
9
+ export * from './unit-of-work-over.js';
10
+ export * from './unit-of-work-stage.js';
11
+ export * from './unscoped-unit-of-work-error.js';
12
+ export * from './when-committed.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC"}
@@ -1,10 +1,7 @@
1
- import type { AggregateRoot } from '../../domain/aggregate-root.js';
2
- type EventSource = Pick<AggregateRoot<string | number>, 'pullEvents'>;
3
1
  /**
4
2
  * The aggregates among the arguments of a call, given as such or in arrays, in the order
5
- * written. Recognised by what they do, not by their class: a context compiled apart extends
3
+ * written. Recognised by what they carry, not by their class: a context compiled apart extends
6
4
  * its own copy of `AggregateRoot`.
7
5
  */
8
- export declare function recordedAggregates(args: readonly unknown[]): EventSource[];
9
- export {};
6
+ export declare function recordedAggregates(args: readonly unknown[]): object[];
10
7
  //# sourceMappingURL=recorded-aggregates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"recorded-aggregates.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/recorded-aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,KAAK,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,WAAW,EAAE,CAE1E"}
1
+ {"version":3,"file":"recorded-aggregates.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/recorded-aggregates.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAErE"}
@@ -1,15 +1,13 @@
1
+ import { AggregateTracking } from '../../domain/aggregate-tracking.js';
1
2
  /**
2
3
  * The aggregates among the arguments of a call, given as such or in arrays, in the order
3
- * written. Recognised by what they do, not by their class: a context compiled apart extends
4
+ * written. Recognised by what they carry, not by their class: a context compiled apart extends
4
5
  * its own copy of `AggregateRoot`.
5
6
  */
6
7
  export function recordedAggregates(args) {
7
- return args.flatMap(listOf).filter(isEventSource);
8
+ return args.flatMap(listOf).filter((argument) => AggregateTracking.follows(argument));
8
9
  }
9
10
  function listOf(argument) {
10
11
  return Array.isArray(argument) ? argument : [argument];
11
12
  }
12
- function isEventSource(value) {
13
- return typeof value === 'object' && value !== null && 'pullEvents' in value && typeof value.pullEvents === 'function';
14
- }
15
13
  //# sourceMappingURL=recorded-aggregates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recorded-aggregates.js","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/recorded-aggregates.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAwB;IACzD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,MAAM,CAAC,QAAiB;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC;AACxH,CAAC"}
1
+ {"version":3,"file":"recorded-aggregates.js","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/recorded-aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAwB;IACzD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,SAAS,MAAM,CAAC,QAAiB;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A `run` that joined the unit of work failed, and its failure did not reach the outermost one:
3
+ * the work caught it and went on. What that run wrote before it failed is in the transaction, so
4
+ * committing would keep a part of it: the unit of work rolls back as a whole instead. The
5
+ * failure of the joined run is the `cause`.
6
+ */
7
+ export declare class UnitOfWorkAbortedError extends Error {
8
+ constructor(cause: unknown);
9
+ }
10
+ //# sourceMappingURL=unit-of-work-aborted-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-of-work-aborted-error.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/unit-of-work-aborted-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,KAAK,EAAE,OAAO,EAOzB;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A `run` that joined the unit of work failed, and its failure did not reach the outermost one:
3
+ * the work caught it and went on. What that run wrote before it failed is in the transaction, so
4
+ * committing would keep a part of it: the unit of work rolls back as a whole instead. The
5
+ * failure of the joined run is the `cause`.
6
+ */
7
+ export class UnitOfWorkAbortedError extends Error {
8
+ constructor(cause) {
9
+ super('A run that joined this unit of work failed and its failure was caught: nothing of the unit of work is committed. Let the failure reach the outermost run, or decide before the write instead of catching after it.', { cause });
10
+ this.name = 'UnitOfWorkAbortedError';
11
+ }
12
+ }
13
+ //# sourceMappingURL=unit-of-work-aborted-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-of-work-aborted-error.js","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/unit-of-work-aborted-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,KAAc;QACxB,KAAK,CACH,oNAAoN,EACpN,EAAE,KAAK,EAAE,CACV,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ import type { UnitOfWork } from '../../application/ports/unit-of-work.js';
2
+ /** Runs what it is given atomically: it begins, calls it, and commits when it resolved or rolls back when it rejected. */
3
+ type Transaction = <T>(work: () => Promise<T>) => Promise<T>;
4
+ export interface UnitOfWorkOverOptions {
5
+ /**
6
+ * False when `transaction` undoes nothing of what the work wrote, as a unit of work in memory:
7
+ * the aggregates then stay as their saves left them, in step with what was stored.
8
+ */
9
+ readonly rollsBack?: boolean;
10
+ }
11
+ /**
12
+ * What every `UnitOfWork` is made of: the unit of work over the transactions of one database.
13
+ *
14
+ * The domain events of the aggregates saved by the work of a `run` wait in the scope of this
15
+ * unit of work, in recording order across the saves. Once the work has returned they are
16
+ * dispatched, still inside `transaction`: the handlers see every save, and what they save or
17
+ * append to the outbox commits with the rest. A handler that fails, like the work that fails,
18
+ * rejects the whole: the transaction rolls back, the waiting events reach no handler, and the
19
+ * aggregates the work saved are put back as it found them, at the version they were loaded at and
20
+ * with the events they had recorded, so the same instances can be saved again. The steps handed to
21
+ * `atCommit` are applied last, still inside
22
+ * `transaction`; when it rejects, those applied are undone. Once `transaction` has resolved, and
23
+ * only then, the `after-commit` handlers run, then the work handed to `afterCommit`.
24
+ *
25
+ * A deadlock or a serialization failure the database raised anywhere in the transaction, on the
26
+ * statement it chose, rejects the outermost `run` as a `TransactionConflictError`, a
27
+ * `ConcurrencyError` whose `cause` is the error of the driver: the caller runs it again. A
28
+ * transaction its ORM could not start in time, the pool being busy, or ended for running too
29
+ * long rejects it as a `TransactionTimeoutError` (`SERVICE_UNAVAILABLE`), the same way.
30
+ *
31
+ * `transaction` is called to open one, never to join: a `run` called while a transaction of
32
+ * this unit of work is open on the asynchronous call chain joins it, its work and nothing else,
33
+ * so one dispatch, at the end of the outermost. A unit of work over another database is another
34
+ * one, wherever it is called from: its own transaction, and its own events dispatched before its
35
+ * own commit. Two concurrent calls never share a scope.
36
+ *
37
+ * It commits or rolls back as a whole: once a `run` that joined has failed, the outermost one
38
+ * rejects, with that failure when it travelled up, with a `UnitOfWorkAbortedError` whose
39
+ * `cause` it is when the work caught it, a retry that then succeeded included.
40
+ */
41
+ export declare function unitOfWorkOver(transaction: Transaction, { rollsBack }?: UnitOfWorkOverOptions): UnitOfWork;
42
+ export {};
43
+ //# sourceMappingURL=unit-of-work-over.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-of-work-over.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/domain-events/unit-of-work-over.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAYvE,0HAA0H;AAC1H,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,SAAgB,EAAE,GAAE,qBAA0B,GAAG,UAAU,CAmBrH"}