@ddd-ts-kit/kernel 0.10.0 → 0.12.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 (226) hide show
  1. package/README.md +129 -4
  2. package/dist/application/background/background-job-execution.d.ts +27 -0
  3. package/dist/application/background/background-job-execution.d.ts.map +1 -0
  4. package/dist/application/background/background-job-execution.js +2 -0
  5. package/dist/application/background/background-job-execution.js.map +1 -0
  6. package/dist/application/background/background-job-options.d.ts +16 -0
  7. package/dist/application/background/background-job-options.d.ts.map +1 -0
  8. package/dist/application/background/background-job-options.js +2 -0
  9. package/dist/application/background/background-job-options.js.map +1 -0
  10. package/dist/application/background/background-job-policy.d.ts +12 -0
  11. package/dist/application/background/background-job-policy.d.ts.map +1 -0
  12. package/dist/application/background/background-job-policy.js +24 -0
  13. package/dist/application/background/background-job-policy.js.map +1 -0
  14. package/dist/application/background/background-job-type.d.ts +10 -0
  15. package/dist/application/background/background-job-type.d.ts.map +1 -0
  16. package/dist/application/background/background-job-type.js +2 -0
  17. package/dist/application/background/background-job-type.js.map +1 -0
  18. package/dist/application/background/background-job.d.ts +14 -0
  19. package/dist/application/background/background-job.d.ts.map +1 -0
  20. package/dist/application/background/background-job.js +2 -0
  21. package/dist/application/background/background-job.js.map +1 -0
  22. package/dist/application/background/enqueue-options.d.ts +20 -0
  23. package/dist/application/background/enqueue-options.d.ts.map +1 -0
  24. package/dist/application/background/enqueue-options.js +2 -0
  25. package/dist/application/background/enqueue-options.js.map +1 -0
  26. package/dist/application/background/enqueued-by.d.ts +13 -0
  27. package/dist/application/background/enqueued-by.d.ts.map +1 -0
  28. package/dist/application/background/enqueued-by.js +2 -0
  29. package/dist/application/background/enqueued-by.js.map +1 -0
  30. package/dist/application/background/enqueued-job.d.ts +7 -0
  31. package/dist/application/background/enqueued-job.d.ts.map +1 -0
  32. package/dist/application/background/enqueued-job.js +2 -0
  33. package/dist/application/background/enqueued-job.js.map +1 -0
  34. package/dist/application/background/execution-context-of-background-job.d.ts +14 -0
  35. package/dist/application/background/execution-context-of-background-job.d.ts.map +1 -0
  36. package/dist/application/background/execution-context-of-background-job.js +18 -0
  37. package/dist/application/background/execution-context-of-background-job.js.map +1 -0
  38. package/dist/application/background/index.d.ts +15 -0
  39. package/dist/application/background/index.d.ts.map +1 -0
  40. package/dist/application/background/index.js +15 -0
  41. package/dist/application/background/index.js.map +1 -0
  42. package/dist/application/background/job-backoff.d.ts +10 -0
  43. package/dist/application/background/job-backoff.d.ts.map +1 -0
  44. package/dist/application/background/job-backoff.js +2 -0
  45. package/dist/application/background/job-backoff.js.map +1 -0
  46. package/dist/application/background/job-progress.d.ts +7 -0
  47. package/dist/application/background/job-progress.d.ts.map +1 -0
  48. package/dist/application/background/job-progress.js +2 -0
  49. package/dist/application/background/job-progress.js.map +1 -0
  50. package/dist/application/background/queued-job-status.d.ts +18 -0
  51. package/dist/application/background/queued-job-status.d.ts.map +1 -0
  52. package/dist/application/background/queued-job-status.js +17 -0
  53. package/dist/application/background/queued-job-status.js.map +1 -0
  54. package/dist/application/background/queued-job.d.ts +25 -0
  55. package/dist/application/background/queued-job.d.ts.map +1 -0
  56. package/dist/application/background/queued-job.js +2 -0
  57. package/dist/application/background/queued-job.js.map +1 -0
  58. package/dist/application/background/retry-delay-ms.d.ts +4 -0
  59. package/dist/application/background/retry-delay-ms.d.ts.map +1 -0
  60. package/dist/application/background/retry-delay-ms.js +6 -0
  61. package/dist/application/background/retry-delay-ms.js.map +1 -0
  62. package/dist/application/cache/cache-purge-payload.d.ts +5 -0
  63. package/dist/application/cache/cache-purge-payload.d.ts.map +1 -0
  64. package/dist/application/cache/cache-purge-payload.js +2 -0
  65. package/dist/application/cache/cache-purge-payload.js.map +1 -0
  66. package/dist/application/cache/cache-purge-request.d.ts +19 -0
  67. package/dist/application/cache/cache-purge-request.d.ts.map +1 -0
  68. package/dist/application/cache/cache-purge-request.js +24 -0
  69. package/dist/application/cache/cache-purge-request.js.map +1 -0
  70. package/dist/application/cache/cache-tag.d.ts +8 -0
  71. package/dist/application/cache/cache-tag.d.ts.map +1 -0
  72. package/dist/application/cache/cache-tag.js +10 -0
  73. package/dist/application/cache/cache-tag.js.map +1 -0
  74. package/dist/application/cache/tenant-cache-tags.d.ts +7 -0
  75. package/dist/application/cache/tenant-cache-tags.d.ts.map +1 -0
  76. package/dist/application/cache/tenant-cache-tags.js +13 -0
  77. package/dist/application/cache/tenant-cache-tags.js.map +1 -0
  78. package/dist/application/execution/execution-origin.d.ts +1 -1
  79. package/dist/application/execution/execution-origin.d.ts.map +1 -1
  80. package/dist/application/persistence/expect-version.d.ts +13 -0
  81. package/dist/application/persistence/expect-version.d.ts.map +1 -0
  82. package/dist/application/persistence/expect-version.js +16 -0
  83. package/dist/application/persistence/expect-version.js.map +1 -0
  84. package/dist/application/ports/cache-invalidation.d.ts +11 -0
  85. package/dist/application/ports/cache-invalidation.d.ts.map +1 -0
  86. package/dist/application/ports/cache-invalidation.js +13 -0
  87. package/dist/application/ports/cache-invalidation.js.map +1 -0
  88. package/dist/application/ports/cache-purger.d.ts +9 -0
  89. package/dist/application/ports/cache-purger.d.ts.map +1 -0
  90. package/dist/application/ports/cache-purger.js +11 -0
  91. package/dist/application/ports/cache-purger.js.map +1 -0
  92. package/dist/application/ports/job-queue.d.ts +26 -0
  93. package/dist/application/ports/job-queue.d.ts.map +1 -0
  94. package/dist/application/ports/job-queue.js +16 -0
  95. package/dist/application/ports/job-queue.js.map +1 -0
  96. package/dist/application/ports/process-runner.d.ts +25 -0
  97. package/dist/application/ports/process-runner.d.ts.map +1 -0
  98. package/dist/application/ports/process-runner.js +11 -0
  99. package/dist/application/ports/process-runner.js.map +1 -0
  100. package/dist/application/ports/process-store.d.ts +12 -0
  101. package/dist/application/ports/process-store.d.ts.map +1 -0
  102. package/dist/application/ports/process-store.js +7 -0
  103. package/dist/application/ports/process-store.js.map +1 -0
  104. package/dist/application/process/index.d.ts +8 -0
  105. package/dist/application/process/index.d.ts.map +1 -0
  106. package/dist/application/process/index.js +8 -0
  107. package/dist/application/process/index.js.map +1 -0
  108. package/dist/application/process/process-decision.d.ts +18 -0
  109. package/dist/application/process/process-decision.d.ts.map +1 -0
  110. package/dist/application/process/process-decision.js +2 -0
  111. package/dist/application/process/process-decision.js.map +1 -0
  112. package/dist/application/process/process-manager.d.ts +13 -0
  113. package/dist/application/process/process-manager.d.ts.map +1 -0
  114. package/dist/application/process/process-manager.js +2 -0
  115. package/dist/application/process/process-manager.js.map +1 -0
  116. package/dist/application/process/process-timeout-due.d.ts +6 -0
  117. package/dist/application/process/process-timeout-due.d.ts.map +1 -0
  118. package/dist/application/process/process-timeout-due.js +2 -0
  119. package/dist/application/process/process-timeout-due.js.map +1 -0
  120. package/dist/application/process/process-timeout.d.ts +6 -0
  121. package/dist/application/process/process-timeout.d.ts.map +1 -0
  122. package/dist/application/process/process-timeout.js +2 -0
  123. package/dist/application/process/process-timeout.js.map +1 -0
  124. package/dist/application/process/process-type.d.ts +12 -0
  125. package/dist/application/process/process-type.d.ts.map +1 -0
  126. package/dist/application/process/process-type.js +2 -0
  127. package/dist/application/process/process-type.js.map +1 -0
  128. package/dist/application/process/stored-process.d.ts +15 -0
  129. package/dist/application/process/stored-process.d.ts.map +1 -0
  130. package/dist/application/process/stored-process.js +2 -0
  131. package/dist/application/process/stored-process.js.map +1 -0
  132. package/dist/application/process/unreadable-process-state-error.d.ts +6 -0
  133. package/dist/application/process/unreadable-process-state-error.d.ts.map +1 -0
  134. package/dist/application/process/unreadable-process-state-error.js +9 -0
  135. package/dist/application/process/unreadable-process-state-error.js.map +1 -0
  136. package/dist/declarations/decorators/background.d.ts +13 -0
  137. package/dist/declarations/decorators/background.d.ts.map +1 -0
  138. package/dist/declarations/decorators/background.js +41 -0
  139. package/dist/declarations/decorators/background.js.map +1 -0
  140. package/dist/declarations/model/background-job-declaration.d.ts +14 -0
  141. package/dist/declarations/model/background-job-declaration.d.ts.map +1 -0
  142. package/dist/declarations/model/background-job-declaration.js +2 -0
  143. package/dist/declarations/model/background-job-declaration.js.map +1 -0
  144. package/dist/declarations/model/declaration.d.ts +2 -1
  145. package/dist/declarations/model/declaration.d.ts.map +1 -1
  146. package/dist/declarations.d.ts +5 -0
  147. package/dist/declarations.d.ts.map +1 -1
  148. package/dist/declarations.js +1 -0
  149. package/dist/declarations.js.map +1 -1
  150. package/dist/domain/errors/precondition-failed-error.d.ts +12 -0
  151. package/dist/domain/errors/precondition-failed-error.d.ts.map +1 -0
  152. package/dist/domain/errors/precondition-failed-error.js +12 -0
  153. package/dist/domain/errors/precondition-failed-error.js.map +1 -0
  154. package/dist/domain/state-machine/define-state-machine.d.ts +22 -0
  155. package/dist/domain/state-machine/define-state-machine.d.ts.map +1 -0
  156. package/dist/domain/state-machine/define-state-machine.js +23 -0
  157. package/dist/domain/state-machine/define-state-machine.js.map +1 -0
  158. package/dist/domain/state-machine/forbidden-transition.d.ts +6 -0
  159. package/dist/domain/state-machine/forbidden-transition.d.ts.map +1 -0
  160. package/dist/domain/state-machine/forbidden-transition.js +2 -0
  161. package/dist/domain/state-machine/forbidden-transition.js.map +1 -0
  162. package/dist/domain/state-machine/index.d.ts +10 -0
  163. package/dist/domain/state-machine/index.d.ts.map +1 -0
  164. package/dist/domain/state-machine/index.js +10 -0
  165. package/dist/domain/state-machine/index.js.map +1 -0
  166. package/dist/domain/state-machine/invalid-state-machine-error.d.ts +6 -0
  167. package/dist/domain/state-machine/invalid-state-machine-error.d.ts.map +1 -0
  168. package/dist/domain/state-machine/invalid-state-machine-error.js +9 -0
  169. package/dist/domain/state-machine/invalid-state-machine-error.js.map +1 -0
  170. package/dist/domain/state-machine/mermaid-of-state-machine.d.ts +4 -0
  171. package/dist/domain/state-machine/mermaid-of-state-machine.d.ts.map +1 -0
  172. package/dist/domain/state-machine/mermaid-of-state-machine.js +16 -0
  173. package/dist/domain/state-machine/mermaid-of-state-machine.js.map +1 -0
  174. package/dist/domain/state-machine/state-machine-declaration.d.ts +22 -0
  175. package/dist/domain/state-machine/state-machine-declaration.d.ts.map +1 -0
  176. package/dist/domain/state-machine/state-machine-declaration.js +2 -0
  177. package/dist/domain/state-machine/state-machine-declaration.js.map +1 -0
  178. package/dist/domain/state-machine/state-machine-description.d.ts +15 -0
  179. package/dist/domain/state-machine/state-machine-description.d.ts.map +1 -0
  180. package/dist/domain/state-machine/state-machine-description.js +2 -0
  181. package/dist/domain/state-machine/state-machine-description.js.map +1 -0
  182. package/dist/domain/state-machine/state-machine.d.ts +33 -0
  183. package/dist/domain/state-machine/state-machine.d.ts.map +1 -0
  184. package/dist/domain/state-machine/state-machine.js +90 -0
  185. package/dist/domain/state-machine/state-machine.js.map +1 -0
  186. package/dist/domain/state-machine/transition-declaration.d.ts +13 -0
  187. package/dist/domain/state-machine/transition-declaration.d.ts.map +1 -0
  188. package/dist/domain/state-machine/transition-declaration.js +2 -0
  189. package/dist/domain/state-machine/transition-declaration.js.map +1 -0
  190. package/dist/domain/state-machine/transition-error.d.ts +13 -0
  191. package/dist/domain/state-machine/transition-error.d.ts.map +1 -0
  192. package/dist/domain/state-machine/transition-error.js +12 -0
  193. package/dist/domain/state-machine/transition-error.js.map +1 -0
  194. package/dist/index.d.ts +21 -0
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +21 -0
  197. package/dist/index.js.map +1 -1
  198. package/dist/infrastructure/cache/published-cache-invalidation.d.ts +33 -0
  199. package/dist/infrastructure/cache/published-cache-invalidation.d.ts.map +1 -0
  200. package/dist/infrastructure/cache/published-cache-invalidation.js +35 -0
  201. package/dist/infrastructure/cache/published-cache-invalidation.js.map +1 -0
  202. package/dist/infrastructure/cache/purging-publisher.d.ts +18 -0
  203. package/dist/infrastructure/cache/purging-publisher.d.ts.map +1 -0
  204. package/dist/infrastructure/cache/purging-publisher.js +33 -0
  205. package/dist/infrastructure/cache/purging-publisher.js.map +1 -0
  206. package/dist/infrastructure/cache/repeated-cache-purger.d.ts +25 -0
  207. package/dist/infrastructure/cache/repeated-cache-purger.d.ts.map +1 -0
  208. package/dist/infrastructure/cache/repeated-cache-purger.js +37 -0
  209. package/dist/infrastructure/cache/repeated-cache-purger.js.map +1 -0
  210. package/dist/infrastructure/domain-events/when-committed.d.ts +10 -0
  211. package/dist/infrastructure/domain-events/when-committed.d.ts.map +1 -0
  212. package/dist/infrastructure/domain-events/when-committed.js +30 -0
  213. package/dist/infrastructure/domain-events/when-committed.js.map +1 -0
  214. package/dist/infrastructure/in-memory/in-memory-cache-invalidation.d.ts +7 -0
  215. package/dist/infrastructure/in-memory/in-memory-cache-invalidation.d.ts.map +1 -0
  216. package/dist/infrastructure/in-memory/in-memory-cache-invalidation.js +8 -0
  217. package/dist/infrastructure/in-memory/in-memory-cache-invalidation.js.map +1 -0
  218. package/dist/infrastructure/in-memory/in-memory-cache-purger.d.ts +13 -0
  219. package/dist/infrastructure/in-memory/in-memory-cache-purger.d.ts.map +1 -0
  220. package/dist/infrastructure/in-memory/in-memory-cache-purger.js +23 -0
  221. package/dist/infrastructure/in-memory/in-memory-cache-purger.js.map +1 -0
  222. package/dist/infrastructure/in-memory/in-memory-process-store.d.ts +11 -0
  223. package/dist/infrastructure/in-memory/in-memory-process-store.d.ts.map +1 -0
  224. package/dist/infrastructure/in-memory/in-memory-process-store.js +29 -0
  225. package/dist/infrastructure/in-memory/in-memory-process-store.js.map +1 -0
  226. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ /** A process instance as a store keeps it. */
2
+ export interface StoredProcess {
3
+ /** The `processName` of its class. */
4
+ readonly name: string;
5
+ /** The correlation key every event of the instance names: an appointment id, an order id. */
6
+ readonly id: string;
7
+ /** Plain JSON. */
8
+ readonly state: unknown;
9
+ /** Counted from 1 at the first save; what optimistic concurrency compares. */
10
+ readonly version: number;
11
+ readonly ended: boolean;
12
+ /** The armed timeouts, by name: the id of the job that delivers each. */
13
+ readonly timeouts: Readonly<Record<string, string>>;
14
+ }
15
+ //# sourceMappingURL=stored-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-process.d.ts","sourceRoot":"","sources":["../../../src/application/process/stored-process.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stored-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-process.js","sourceRoot":"","sources":["../../../src/application/process/stored-process.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /** A stored state the process does not recognise: written by another version of it, or by hand. */
2
+ export declare class UnreadableProcessStateError extends Error {
3
+ readonly code = "UNREADABLE_PROCESS_STATE";
4
+ constructor(process: string, id: string);
5
+ }
6
+ //# sourceMappingURL=unreadable-process-state-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unreadable-process-state-error.d.ts","sourceRoot":"","sources":["../../../src/application/process/unreadable-process-state-error.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,IAAI,8BAA8B;IAE3C,YAAY,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAGtC;CACF"}
@@ -0,0 +1,9 @@
1
+ /** A stored state the process does not recognise: written by another version of it, or by hand. */
2
+ export class UnreadableProcessStateError extends Error {
3
+ code = 'UNREADABLE_PROCESS_STATE';
4
+ constructor(process, id) {
5
+ super(`The stored state of process "${process}" ${id} is not one this version of the process reads.`);
6
+ this.name = 'UnreadableProcessStateError';
7
+ }
8
+ }
9
+ //# sourceMappingURL=unreadable-process-state-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unreadable-process-state-error.js","sourceRoot":"","sources":["../../../src/application/process/unreadable-process-state-error.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAC3C,IAAI,GAAG,0BAA0B,CAAC;IAE3C,YAAY,OAAe,EAAE,EAAU;QACrC,KAAK,CAAC,gCAAgC,OAAO,KAAK,EAAE,gDAAgD,CAAC,CAAC;QACtG,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import type { BackgroundJobOptions } from '../../application/background/background-job-options.js';
2
+ import type { BackgroundJob } from '../../application/background/background-job.js';
3
+ import type { ClassDeclarator } from '../dependencies/class-declarator.js';
4
+ import type { DeclaredDependencies } from '../dependencies/declared-dependencies.js';
5
+ import type { DependenciesFromSignature } from '../dependencies/dependencies-from-signature.js';
6
+ /**
7
+ * A background job, run by a worker after a use case enqueued it, named by the static `jobName`
8
+ * of the class: `@Background({ maxAttempts: 3, timeout: '10m' })`. The name and the options are
9
+ * checked when the file loads. Under standard decorators a class decorator runs before the
10
+ * static fields exist: the job is then recorded once the class is defined.
11
+ */
12
+ export declare function Background<const D extends DeclaredDependencies = DependenciesFromSignature>(options?: BackgroundJobOptions, dependencies?: D): ClassDeclarator<BackgroundJob<unknown>, D>;
13
+ //# sourceMappingURL=background.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../src/declarations/decorators/background.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAEnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAGpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAIhG;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,oBAAoB,GAAG,yBAAyB,EACzF,OAAO,GAAE,oBAAyB,EAClC,YAAY,CAAC,EAAE,CAAC,GACf,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAsB5C"}
@@ -0,0 +1,41 @@
1
+ import { backgroundJobPolicy } from '../../application/background/background-job-policy.js';
2
+ import { InvalidJobScheduleError } from '../../application/scheduling/invalid-job-schedule-error.js';
3
+ import { isJobName } from '../../application/scheduling/is-job-name.js';
4
+ import { DeclarationError } from '../registry/declaration-error.js';
5
+ import { record } from '../registry/record.js';
6
+ /**
7
+ * A background job, run by a worker after a use case enqueued it, named by the static `jobName`
8
+ * of the class: `@Background({ maxAttempts: 3, timeout: '10m' })`. The name and the options are
9
+ * checked when the file loads. Under standard decorators a class decorator runs before the
10
+ * static fields exist: the job is then recorded once the class is defined.
11
+ */
12
+ export function Background(options = {}, dependencies) {
13
+ return (target, context) => {
14
+ const declare = () => {
15
+ const name = nameOf(target);
16
+ try {
17
+ backgroundJobPolicy(options);
18
+ }
19
+ catch (error) {
20
+ throw error instanceof InvalidJobScheduleError
21
+ ? new DeclarationError(`Job "${name}": ${error.message}`)
22
+ : error;
23
+ }
24
+ record(target, { role: 'background-job', name, options, implementation: target, dependencies });
25
+ };
26
+ if (context === undefined) {
27
+ declare();
28
+ }
29
+ else {
30
+ context.addInitializer(declare);
31
+ }
32
+ };
33
+ }
34
+ function nameOf(target) {
35
+ const name = Reflect.get(target, 'jobName');
36
+ if (typeof name === 'string' && isJobName(name)) {
37
+ return name;
38
+ }
39
+ throw new DeclarationError(`${target.name} has no static jobName of the form <context>.<job-name>: write static readonly jobName = 'billing.compile-statements'.`);
40
+ }
41
+ //# sourceMappingURL=background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background.js","sourceRoot":"","sources":["../../../src/declarations/decorators/background.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,4DAA4D,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAIxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,OAAO,GAAyB,EAAE,EAClC,YAAgB;IAEhB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAE5B,IAAI,CAAC;gBACH,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,KAAK,YAAY,uBAAuB;oBAC5C,CAAC,CAAC,IAAI,gBAAgB,CAAC,QAAQ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;oBACzD,CAAC,CAAC,KAAK,CAAC;YACZ,CAAC;YAED,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;QAClG,CAAC,CAAC;QAEF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,MAAiC;IAC/C,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAErD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,gBAAgB,CACxB,GAAG,MAAM,CAAC,IAAI,wHAAwH,CACvI,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { BackgroundJobOptions } from '../../application/background/background-job-options.js';
2
+ import type { BackgroundJob } from '../../application/background/background-job.js';
3
+ import type { Token } from '../token/token.js';
4
+ export interface BackgroundJobDeclaration {
5
+ readonly role: 'background-job';
6
+ /** The static `jobName` of the class, `<context>.<job-name>`: its queue is the context. */
7
+ readonly name: string;
8
+ /** As written: the defaults are filled in where the job is registered. */
9
+ readonly options: BackgroundJobOptions;
10
+ readonly implementation: new (...args: never) => BackgroundJob<unknown>;
11
+ /** The list the decorator wrote; `undefined` when the constructor states the dependencies. */
12
+ readonly dependencies: readonly Token<unknown>[] | undefined;
13
+ }
14
+ //# sourceMappingURL=background-job-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-job-declaration.d.ts","sourceRoot":"","sources":["../../../src/declarations/model/background-job-declaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AACnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC;IACxE,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,EAAE,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;CAC9D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=background-job-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-job-declaration.js","sourceRoot":"","sources":["../../../src/declarations/model/background-job-declaration.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+ import type { BackgroundJobDeclaration } from './background-job-declaration.js';
1
2
  import type { DomainEventHandlerDeclaration } from './domain-event-handler-declaration.js';
2
3
  import type { EdgeDeclaration } from './edge-declaration.js';
3
4
  import type { HandlerDeclaration } from './handler-declaration.js';
@@ -8,5 +9,5 @@ import type { PolicyDeclaration } from './policy-declaration.js';
8
9
  import type { PortDeclaration } from './port-declaration.js';
9
10
  import type { ProjectionDeclaration } from './projection-declaration.js';
10
11
  /** What a class said about itself. Plain data: reading it instantiates and resolves nothing. */
11
- export type Declaration = MessageDeclaration | HandlerDeclaration | IntegrationEventHandlerDeclaration | DomainEventHandlerDeclaration | PortDeclaration | PolicyDeclaration | JobDeclaration | ProjectionDeclaration | EdgeDeclaration;
12
+ export type Declaration = BackgroundJobDeclaration | MessageDeclaration | HandlerDeclaration | IntegrationEventHandlerDeclaration | DomainEventHandlerDeclaration | PortDeclaration | PolicyDeclaration | JobDeclaration | ProjectionDeclaration | EdgeDeclaration;
12
13
  //# sourceMappingURL=declaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../src/declarations/model/declaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,E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EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,gGAAgG;AAChG,MAAM,MAAM,WAAW,GACnB,wBAAwB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,kCAAkC,GAClC,6BAA6B,GAC7B,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,qBAAqB,GACrB,eAAe,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { Background } from './declarations/decorators/background.js';
1
2
  export { type AdapterOptions, Adapter } from './declarations/decorators/adapter.js';
2
3
  export { CommandHandler } from './declarations/decorators/command-handler.js';
3
4
  export { type DomainEventHandlerOptions, DomainEventHandler } from './declarations/decorators/domain-event-handler.js';
@@ -31,6 +32,7 @@ export { injectedDependencies } from './declarations/injection/injected-dependen
31
32
  export { injected } from './declarations/injection/injected.js';
32
33
  export type { AccessDeclaration } from './declarations/model/access-declaration.js';
33
34
  export type { AuditedFieldHint } from './declarations/model/audited-field-hint.js';
35
+ export type { BackgroundJobDeclaration } from './declarations/model/background-job-declaration.js';
34
36
  export type { BindingAspectInfo } from './declarations/model/binding-aspect-info.js';
35
37
  export type { BindingAspect } from './declarations/model/binding-aspect.js';
36
38
  export type { Declaration } from './declarations/model/declaration.js';
@@ -69,4 +71,7 @@ export type { JobExecution } from './application/scheduling/job-execution.js';
69
71
  export type { JobOptions } from './application/scheduling/job-options.js';
70
72
  export type { IntervalSchedule, CronSchedule, JobSchedule } from './application/scheduling/job-schedule.js';
71
73
  export type { ScheduledJob } from './application/scheduling/scheduled-job.js';
74
+ export type { BackgroundJob } from './application/background/background-job.js';
75
+ export type { BackgroundJobExecution } from './application/background/background-job-execution.js';
76
+ export type { BackgroundJobOptions } from './application/background/background-job-options.js';
72
77
  //# sourceMappingURL=declarations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,sCAAsC,C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,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,YAAY,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,YAAY,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AACnF,YAAY,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,YAAY,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5G,YAAY,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,YAAY,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAChF,YAAY,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AACnG,YAAY,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { Background } from './declarations/decorators/background.js';
1
2
  export { Adapter } from './declarations/decorators/adapter.js';
2
3
  export { CommandHandler } from './declarations/decorators/command-handler.js';
3
4
  export { DomainEventHandler } from './declarations/decorators/domain-event-handler.js';
@@ -1 +1 @@
1
- {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAkC,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvH,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAEL,uBAAuB,GACxB,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAE,EAAE,EAA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C;AAC/D,OAAO,EAEL,uBAAuB,GACxB,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AACrD,OAAO,EAAsB,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF,OAAO,EAAsB,MAAM,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAyB,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAyB,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAW1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAgChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { DomainError } from './domain-error.js';
2
+ /** The code of a write refused because the version the caller read is no longer the current one. */
3
+ export declare const PRECONDITION_FAILED = "PRECONDITION_FAILED";
4
+ /**
5
+ * The caller acted on a version of the element it read, and the element changed since: answered
6
+ * 412 over HTTP, where the version came in `If-Match`. Unlike a `ConcurrencyError`, nobody wrote
7
+ * at the same instant: the caller read long enough ago for somebody else to write in between.
8
+ */
9
+ export declare class PreconditionFailedError extends DomainError {
10
+ readonly code = "PRECONDITION_FAILED";
11
+ }
12
+ //# sourceMappingURL=precondition-failed-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precondition-failed-error.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/precondition-failed-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,oGAAoG;AACpG,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,WAAW;IACtD,QAAQ,CAAC,IAAI,yBAAuB;CACrC"}
@@ -0,0 +1,12 @@
1
+ import { DomainError } from './domain-error.js';
2
+ /** The code of a write refused because the version the caller read is no longer the current one. */
3
+ export const PRECONDITION_FAILED = 'PRECONDITION_FAILED';
4
+ /**
5
+ * The caller acted on a version of the element it read, and the element changed since: answered
6
+ * 412 over HTTP, where the version came in `If-Match`. Unlike a `ConcurrencyError`, nobody wrote
7
+ * at the same instant: the caller read long enough ago for somebody else to write in between.
8
+ */
9
+ export class PreconditionFailedError extends DomainError {
10
+ code = PRECONDITION_FAILED;
11
+ }
12
+ //# sourceMappingURL=precondition-failed-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precondition-failed-error.js","sourceRoot":"","sources":["../../../src/domain/errors/precondition-failed-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,oGAAoG;AACpG,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IAC7C,IAAI,GAAG,mBAAmB,CAAC;CACrC"}
@@ -0,0 +1,22 @@
1
+ import type { StateMachineDeclaration } from './state-machine-declaration.js';
2
+ import { StateMachine } from './state-machine.js';
3
+ /**
4
+ * Declares the lifecycle of an aggregate, in `domain/state-machines/<aggregate>.state-machine.ts`:
5
+ *
6
+ * export const appointmentLifecycle = defineStateMachine({
7
+ * states: Object.values(AppointmentStatus),
8
+ * initial: [AppointmentStatus.Requested, AppointmentStatus.Booked],
9
+ * transitions: {
10
+ * confirm: { from: [AppointmentStatus.Requested], to: AppointmentStatus.Booked },
11
+ * cancel: { from: [AppointmentStatus.Requested, AppointmentStatus.Booked], to: AppointmentStatus.Cancelled },
12
+ * },
13
+ * refused: ({ from }) => AppointmentError.ended(from),
14
+ * });
15
+ *
16
+ * Without `refused`, a forbidden transition throws `TransitionError.forbidden(from, transition)`.
17
+ *
18
+ * Throws `InvalidStateMachineError` when the file loads for a declaration that names an unknown
19
+ * state. A guard receives the context the aggregate passes to `next`.
20
+ */
21
+ export declare function defineStateMachine<const State extends string, const Name extends string, Context = void>(declaration: StateMachineDeclaration<State, Name, Context>): StateMachine<State, Name, Context>;
22
+ //# sourceMappingURL=define-state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-state-machine.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/define-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,OAAO,GAAG,IAAI,EACtG,WAAW,EAAE,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,GACzD,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAEpC"}
@@ -0,0 +1,23 @@
1
+ import { StateMachine } from './state-machine.js';
2
+ /**
3
+ * Declares the lifecycle of an aggregate, in `domain/state-machines/<aggregate>.state-machine.ts`:
4
+ *
5
+ * export const appointmentLifecycle = defineStateMachine({
6
+ * states: Object.values(AppointmentStatus),
7
+ * initial: [AppointmentStatus.Requested, AppointmentStatus.Booked],
8
+ * transitions: {
9
+ * confirm: { from: [AppointmentStatus.Requested], to: AppointmentStatus.Booked },
10
+ * cancel: { from: [AppointmentStatus.Requested, AppointmentStatus.Booked], to: AppointmentStatus.Cancelled },
11
+ * },
12
+ * refused: ({ from }) => AppointmentError.ended(from),
13
+ * });
14
+ *
15
+ * Without `refused`, a forbidden transition throws `TransitionError.forbidden(from, transition)`.
16
+ *
17
+ * Throws `InvalidStateMachineError` when the file loads for a declaration that names an unknown
18
+ * state. A guard receives the context the aggregate passes to `next`.
19
+ */
20
+ export function defineStateMachine(declaration) {
21
+ return new StateMachine(declaration);
22
+ }
23
+ //# sourceMappingURL=define-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-state-machine.js","sourceRoot":"","sources":["../../../src/domain/state-machine/define-state-machine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAA0D;IAE1D,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** A transition asked of a state it does not leave: what the refusal factory is given. */
2
+ export interface ForbiddenTransition<State extends string, Name extends string> {
3
+ readonly from: State;
4
+ readonly transition: Name;
5
+ }
6
+ //# sourceMappingURL=forbidden-transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden-transition.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/forbidden-transition.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM;IAC5E,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=forbidden-transition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden-transition.js","sourceRoot":"","sources":["../../../src/domain/state-machine/forbidden-transition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export * from './define-state-machine.js';
2
+ export * from './forbidden-transition.js';
3
+ export * from './invalid-state-machine-error.js';
4
+ export * from './mermaid-of-state-machine.js';
5
+ export * from './state-machine-declaration.js';
6
+ export * from './state-machine-description.js';
7
+ export * from './state-machine.js';
8
+ export * from './transition-declaration.js';
9
+ export * from './transition-error.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export * from './define-state-machine.js';
2
+ export * from './forbidden-transition.js';
3
+ export * from './invalid-state-machine-error.js';
4
+ export * from './mermaid-of-state-machine.js';
5
+ export * from './state-machine-declaration.js';
6
+ export * from './state-machine-description.js';
7
+ export * from './state-machine.js';
8
+ export * from './transition-declaration.js';
9
+ export * from './transition-error.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/state-machine/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** A state machine whose declaration contradicts itself: raised where it is defined, when the file loads. */
2
+ export declare class InvalidStateMachineError extends Error {
3
+ readonly code = "INVALID_STATE_MACHINE";
4
+ constructor(message: string);
5
+ }
6
+ //# sourceMappingURL=invalid-state-machine-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid-state-machine-error.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/invalid-state-machine-error.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,2BAA2B;IAExC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF"}
@@ -0,0 +1,9 @@
1
+ /** A state machine whose declaration contradicts itself: raised where it is defined, when the file loads. */
2
+ export class InvalidStateMachineError extends Error {
3
+ code = 'INVALID_STATE_MACHINE';
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'InvalidStateMachineError';
7
+ }
8
+ }
9
+ //# sourceMappingURL=invalid-state-machine-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid-state-machine-error.js","sourceRoot":"","sources":["../../../src/domain/state-machine/invalid-state-machine-error.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,IAAI,GAAG,uBAAuB,CAAC;IAExC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { StateMachineDescription } from './state-machine-description.js';
2
+ /** The diagram of a state machine, as Mermaid `stateDiagram-v2`: what `CONTEXT.md` shows. */
3
+ export declare function mermaidOfStateMachine(machine: StateMachineDescription): string;
4
+ //# sourceMappingURL=mermaid-of-state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid-of-state-machine.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/mermaid-of-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAa9E"}
@@ -0,0 +1,16 @@
1
+ /** The diagram of a state machine, as Mermaid `stateDiagram-v2`: what `CONTEXT.md` shows. */
2
+ export function mermaidOfStateMachine(machine) {
3
+ const lines = [
4
+ 'stateDiagram-v2',
5
+ ...machine.states.filter((state) => idOf(state) !== state).map((state) => ` state "${state}" as ${idOf(state)}`),
6
+ ...machine.initial.map((state) => ` [*] --> ${idOf(state)}`),
7
+ ...machine.arrows.map(({ transition, from, to, guarded }) => ` ${idOf(from)} --> ${idOf(to)}: ${transition}${guarded ? ' [guarded]' : ''}`),
8
+ ...machine.final.map((state) => ` ${idOf(state)} --> [*]`),
9
+ ];
10
+ return lines.join('\n');
11
+ }
12
+ /** Mermaid takes letters, digits and underscores in an identifier. */
13
+ function idOf(state) {
14
+ return state.replace(/[^A-Za-z0-9_]/g, '_');
15
+ }
16
+ //# sourceMappingURL=mermaid-of-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid-of-state-machine.js","sourceRoot":"","sources":["../../../src/domain/state-machine/mermaid-of-state-machine.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,MAAM,UAAU,qBAAqB,CAAC,OAAgC;IACpE,MAAM,KAAK,GAAG;QACZ,iBAAiB;QACjB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACjH,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7D,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CACnB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CACpC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,KAAK,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CACjF;QACD,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;KAC5D,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,sEAAsE;AACtE,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { DomainError } from '../errors/domain-error.js';
2
+ import type { ForbiddenTransition } from './forbidden-transition.js';
3
+ import type { TransitionDeclaration } from './transition-declaration.js';
4
+ /**
5
+ * The lifecycle of an aggregate, written once: `defineStateMachine` reads it. Its states are the
6
+ * values of the `status` field of the aggregate.
7
+ */
8
+ export interface StateMachineDeclaration<State extends string, Name extends string, Context> {
9
+ /** Every state, in the order a diagram shows them: the values of the closed vocabulary of the field. */
10
+ readonly states: readonly State[];
11
+ /** The states an aggregate may be created in. */
12
+ readonly initial: readonly State[];
13
+ /** Named after the intention methods of the aggregate: `confirm`, `cancel`. */
14
+ readonly transitions: Readonly<Record<Name, TransitionDeclaration<State, Context>>>;
15
+ /**
16
+ * The refusal of a transition the current state does not allow, from a static factory of the
17
+ * concept error, given the context the aggregate passed (its identifier, typically). Default:
18
+ * `TransitionError.forbidden(from, transition)`, code `FORBIDDEN_TRANSITION`.
19
+ */
20
+ readonly refused?: (forbidden: ForbiddenTransition<State, Name>, context: Context) => DomainError;
21
+ }
22
+ //# sourceMappingURL=state-machine-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine-declaration.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/state-machine-declaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EAAE,OAAO;IACzF,wGAAwG;IACxG,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpF;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,WAAW,CAAC;CACnG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=state-machine-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine-declaration.js","sourceRoot":"","sources":["../../../src/domain/state-machine/state-machine-declaration.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ /** A state machine as data: for a diagram, a describe command or a test. */
2
+ export interface StateMachineDescription {
3
+ readonly states: readonly string[];
4
+ readonly initial: readonly string[];
5
+ /** The states no transition leaves. */
6
+ readonly final: readonly string[];
7
+ /** Each arrow: one per state a transition leaves. A transition that keeps the state is an arrow onto itself. */
8
+ readonly arrows: readonly {
9
+ readonly transition: string;
10
+ readonly from: string;
11
+ readonly to: string;
12
+ readonly guarded: boolean;
13
+ }[];
14
+ }
15
+ //# sourceMappingURL=state-machine-description.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine-description.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/state-machine-description.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gHAAgH;IAChH,QAAQ,CAAC,MAAM,EAAE,SAAS;QACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC3B,EAAE,CAAC;CACL"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=state-machine-description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine-description.js","sourceRoot":"","sources":["../../../src/domain/state-machine/state-machine-description.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { StateMachineDeclaration } from './state-machine-declaration.js';
2
+ import type { StateMachineDescription } from './state-machine-description.js';
3
+ /**
4
+ * The lifecycle of an aggregate: its states, the transitions between them and what refuses
5
+ * them. The aggregate asks it the next state instead of testing its status by hand:
6
+ *
7
+ * this.state = { ...this.state, status: appointmentLifecycle.next(this.state.status, 'confirm') };
8
+ *
9
+ * A transition the current state does not allow throws the refusal the declaration builds with
10
+ * a static factory; a guard throws its own. The status field changes through it and nowhere
11
+ * else (`lifecycle/status-through-machine`).
12
+ */
13
+ export declare class StateMachine<State extends string, Name extends string, Context = void> {
14
+ private readonly declaration;
15
+ constructor(declaration: StateMachineDeclaration<State, Name, Context>);
16
+ /** The state an aggregate is created in. Throws `InvalidStateMachineError` for a state that is not initial: a defect, not a refusal. */
17
+ start(state: State): State;
18
+ /**
19
+ * The state `transition` leads to from `from`. Throws the refusal of a forbidden transition,
20
+ * or of its guard. `context` is what the guards read; a machine without one takes none.
21
+ */
22
+ next(from: State, transition: Name, context: Context): State;
23
+ /** Whether `transition` would be accepted from `from`, its guard included. */
24
+ can(from: State, transition: Name, context: Context): boolean;
25
+ /** The transitions a state allows, guards aside. */
26
+ allowedFrom(state: State): Name[];
27
+ /** A state no transition leaves. */
28
+ isFinal(state: State): boolean;
29
+ describe(): StateMachineDescription;
30
+ private refusalOf;
31
+ private names;
32
+ }
33
+ //# sourceMappingURL=state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../../../src/domain/state-machine/state-machine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EAAE,OAAO,GAAG,IAAI;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW;IAAxC,YAA6B,WAAW,EAAE,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAEtF;IAED,wIAAwI;IACxI,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAQzB;IAED;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAQ3D;IAED,8EAA8E;IAC9E,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAE5D;IAED,oDAAoD;IACpD,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,CAEhC;IAED,oCAAoC;IACpC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAE7B;IAED,QAAQ,IAAI,uBAAuB,CAalC;IAED,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,KAAK;CAKd"}