ddd-ts-kit 0.97.0 → 0.98.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 (174) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.fr.md +5 -5
  3. package/README.md +4 -4
  4. package/dist/check/canonical/stray-entry.d.ts.map +1 -1
  5. package/dist/check/canonical/stray-entry.js +14 -2
  6. package/dist/check/canonical/stray-entry.js.map +1 -1
  7. package/dist/check/domain-events/event-handlers-of.d.ts.map +1 -1
  8. package/dist/check/domain-events/event-handlers-of.js +21 -8
  9. package/dist/check/domain-events/event-handlers-of.js.map +1 -1
  10. package/dist/check/events/consumer-registrations.d.ts +2 -0
  11. package/dist/check/events/consumer-registrations.d.ts.map +1 -1
  12. package/dist/check/events/consumer-registrations.js +44 -2
  13. package/dist/check/events/consumer-registrations.js.map +1 -1
  14. package/dist/check/explain/events-docs.js +1 -1
  15. package/dist/check/explain/events-docs.js.map +1 -1
  16. package/dist/check/explain/tree-docs.d.ts.map +1 -1
  17. package/dist/check/explain/tree-docs.js +7 -4
  18. package/dist/check/explain/tree-docs.js.map +1 -1
  19. package/dist/check/explain/wiring-docs.js +1 -1
  20. package/dist/check/explain/wiring-docs.js.map +1 -1
  21. package/dist/check/fixtures/consumer-fixtures.d.ts.map +1 -1
  22. package/dist/check/fixtures/consumer-fixtures.js +33 -0
  23. package/dist/check/fixtures/consumer-fixtures.js.map +1 -1
  24. package/dist/check/project/locate.js +9 -3
  25. package/dist/check/project/locate.js.map +1 -1
  26. package/dist/check/rules/composition-only-in-module.js +2 -2
  27. package/dist/check/rules/composition-only-in-module.js.map +1 -1
  28. package/dist/check/rules/declarations-port-adapter-wired.js +1 -1
  29. package/dist/check/rules/declarations-port-adapter-wired.js.map +1 -1
  30. package/dist/check/rules/events-consumer-idempotent.d.ts.map +1 -1
  31. package/dist/check/rules/events-consumer-idempotent.js +6 -3
  32. package/dist/check/rules/events-consumer-idempotent.js.map +1 -1
  33. package/dist/check/rules/tree-closed.js +1 -1
  34. package/dist/check/rules/tree-closed.js.map +1 -1
  35. package/dist/commands/generate.js +2 -0
  36. package/dist/commands/generate.js.map +1 -1
  37. package/dist/describe/context-sources.d.ts +1 -1
  38. package/dist/describe/context-sources.d.ts.map +1 -1
  39. package/dist/describe/describe-context.js +2 -2
  40. package/dist/describe/describe-context.js.map +1 -1
  41. package/dist/docs/personal-declarations-in.js +6 -1
  42. package/dist/docs/personal-declarations-in.js.map +1 -1
  43. package/dist/docs/personal-table-cells.js +7 -1
  44. package/dist/docs/personal-table-cells.js.map +1 -1
  45. package/dist/docs/personal-table-facts.d.ts +1 -1
  46. package/dist/docs/personal-table-facts.d.ts.map +1 -1
  47. package/dist/docs/read-jobs.d.ts +1 -1
  48. package/dist/docs/read-jobs.d.ts.map +1 -1
  49. package/dist/docs/read-jobs.js +3 -3
  50. package/dist/docs/read-jobs.js.map +1 -1
  51. package/dist/generate/apply-wiring.js +1 -1
  52. package/dist/generate/apply-wiring.js.map +1 -1
  53. package/dist/generate/kind.d.ts +2 -0
  54. package/dist/generate/kind.d.ts.map +1 -1
  55. package/dist/generate/kinds/adapter-kind.js +2 -2
  56. package/dist/generate/kinds/adapter-kind.js.map +1 -1
  57. package/dist/generate/kinds/ask-policy-in-generated-use-case.d.ts.map +1 -1
  58. package/dist/generate/kinds/ask-policy-in-generated-use-case.js +10 -4
  59. package/dist/generate/kinds/ask-policy-in-generated-use-case.js.map +1 -1
  60. package/dist/generate/kinds/command-context.d.ts +5 -2
  61. package/dist/generate/kinds/command-context.d.ts.map +1 -1
  62. package/dist/generate/kinds/command-context.js +11 -3
  63. package/dist/generate/kinds/command-context.js.map +1 -1
  64. package/dist/generate/kinds/command-kind.d.ts.map +1 -1
  65. package/dist/generate/kinds/command-kind.js +9 -4
  66. package/dist/generate/kinds/command-kind.js.map +1 -1
  67. package/dist/generate/kinds/e2e/jobs-sending.d.ts +5 -0
  68. package/dist/generate/kinds/e2e/jobs-sending.d.ts.map +1 -0
  69. package/dist/generate/kinds/e2e/jobs-sending.js +11 -0
  70. package/dist/generate/kinds/e2e/jobs-sending.js.map +1 -0
  71. package/dist/generate/kinds/e2e/reaction-of.d.ts +9 -2
  72. package/dist/generate/kinds/e2e/reaction-of.d.ts.map +1 -1
  73. package/dist/generate/kinds/e2e/reaction-of.js +16 -7
  74. package/dist/generate/kinds/e2e/reaction-of.js.map +1 -1
  75. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  76. package/dist/generate/kinds/e2e-kind.js +20 -5
  77. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  78. package/dist/generate/kinds/erasure-handler-kind.js +7 -0
  79. package/dist/generate/kinds/erasure-handler-kind.js.map +1 -1
  80. package/dist/generate/kinds/job/read-sent-command.d.ts.map +1 -1
  81. package/dist/generate/kinds/job/read-sent-command.js +2 -1
  82. package/dist/generate/kinds/job/read-sent-command.js.map +1 -1
  83. package/dist/generate/kinds/module-kind.d.ts.map +1 -1
  84. package/dist/generate/kinds/module-kind.js +22 -2
  85. package/dist/generate/kinds/module-kind.js.map +1 -1
  86. package/dist/generate/kinds/repository-line.d.ts +4 -0
  87. package/dist/generate/kinds/repository-line.d.ts.map +1 -0
  88. package/dist/generate/kinds/repository-line.js +5 -0
  89. package/dist/generate/kinds/repository-line.js.map +1 -0
  90. package/dist/generate/kinds/wire-repository-on-first-use.d.ts +3 -2
  91. package/dist/generate/kinds/wire-repository-on-first-use.d.ts.map +1 -1
  92. package/dist/generate/kinds/wire-repository-on-first-use.js +8 -3
  93. package/dist/generate/kinds/wire-repository-on-first-use.js.map +1 -1
  94. package/dist/generate/registration.d.ts +10 -0
  95. package/dist/generate/registration.d.ts.map +1 -0
  96. package/dist/generate/registration.js +2 -0
  97. package/dist/generate/registration.js.map +1 -0
  98. package/dist/generate/wire.d.ts +5 -2
  99. package/dist/generate/wire.d.ts.map +1 -1
  100. package/dist/generate/wire.js +6 -3
  101. package/dist/generate/wire.js.map +1 -1
  102. package/dist/generate/wirings.d.ts +2 -1
  103. package/dist/generate/wirings.d.ts.map +1 -1
  104. package/dist/generate/wirings.js +25 -4
  105. package/dist/generate/wirings.js.map +1 -1
  106. package/dist/init/files/persistence-files.d.ts.map +1 -1
  107. package/dist/init/files/persistence-files.js +5 -2
  108. package/dist/init/files/persistence-files.js.map +1 -1
  109. package/dist/init/manifest/versions.js +24 -24
  110. package/dist/model-modules/index.d.ts +4 -0
  111. package/dist/model-modules/index.d.ts.map +1 -1
  112. package/dist/model-modules/index.js +4 -0
  113. package/dist/model-modules/index.js.map +1 -1
  114. package/dist/model-modules/module-file-of.d.ts +7 -0
  115. package/dist/model-modules/module-file-of.d.ts.map +1 -0
  116. package/dist/model-modules/module-file-of.js +9 -0
  117. package/dist/model-modules/module-file-of.js.map +1 -0
  118. package/dist/model-modules/module-of-module-file.d.ts +3 -0
  119. package/dist/model-modules/module-of-module-file.d.ts.map +1 -0
  120. package/dist/model-modules/module-of-module-file.js +6 -0
  121. package/dist/model-modules/module-of-module-file.js.map +1 -0
  122. package/dist/model-modules/wiring-files-of.d.ts +4 -0
  123. package/dist/model-modules/wiring-files-of.d.ts.map +1 -0
  124. package/dist/model-modules/wiring-files-of.js +6 -0
  125. package/dist/model-modules/wiring-files-of.js.map +1 -0
  126. package/dist/model-modules/wiring-text-of.d.ts +5 -0
  127. package/dist/model-modules/wiring-text-of.d.ts.map +1 -0
  128. package/dist/model-modules/wiring-text-of.js +8 -0
  129. package/dist/model-modules/wiring-text-of.js.map +1 -0
  130. package/dist/presets/apply-preset.d.ts.map +1 -1
  131. package/dist/presets/apply-preset.js +5 -0
  132. package/dist/presets/apply-preset.js.map +1 -1
  133. package/dist/presets/identity-preset.d.ts.map +1 -1
  134. package/dist/presets/identity-preset.js +1 -0
  135. package/dist/presets/identity-preset.js.map +1 -1
  136. package/dist/presets/no-flags.d.ts.map +1 -1
  137. package/dist/presets/no-flags.js +1 -0
  138. package/dist/presets/no-flags.js.map +1 -1
  139. package/dist/presets/preset.d.ts +6 -0
  140. package/dist/presets/preset.d.ts.map +1 -1
  141. package/dist/version.d.ts +1 -1
  142. package/dist/version.js +1 -1
  143. package/dist/workspace/workspace.d.ts +2 -1
  144. package/dist/workspace/workspace.d.ts.map +1 -1
  145. package/dist/workspace/workspace.js +6 -5
  146. package/dist/workspace/workspace.js.map +1 -1
  147. package/package.json +4 -4
  148. package/templates/command/handler.declared.ts.tpl +39 -1
  149. package/templates/command/handler.spec.buses.ts.tpl +4 -4
  150. package/templates/command/handler.spec.tsyringe.ts.tpl +2 -2
  151. package/templates/command/handler.ts.tpl +38 -1
  152. package/templates/command/wiring.manual.tpl +4 -1
  153. package/templates/command/wiring.tsyringe.tpl +7 -2
  154. package/templates/e2e/e2e-job-case.ts.tpl +8 -0
  155. package/templates/e2e/e2e-job.spec.ts.tpl +43 -0
  156. package/templates/init/e2e/start-application.database.ts.tpl +94 -9
  157. package/templates/init/e2e/start-application.memory.ts.tpl +76 -9
  158. package/templates/init/jest.config.js.tpl +11 -2
  159. package/templates/init/platform/composition/compose-application.manual.ts.tpl +11 -2
  160. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +4 -0
  161. package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +1 -5
  162. package/templates/init/platform/database/open-test-database.knex.ts.tpl +1 -5
  163. package/templates/init/platform/database/open-test-database.prisma.ts.tpl +1 -5
  164. package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +1 -5
  165. package/templates/init/platform/database/test-database-teardown.ts.tpl +11 -0
  166. package/templates/init/platform/database/test-database-template.ts.tpl +16 -1
  167. package/templates/init/rules/tests.md.tpl +1 -1
  168. package/templates/module/module-file.manual.ts.tpl +46 -0
  169. package/templates/module/module-file.tsyringe.ts.tpl +14 -0
  170. package/templates/module/wiring.manual.tpl +14 -0
  171. package/templates/module/wiring.tsyringe.tpl +6 -0
  172. package/templates/pipeline/package-scripts.json +1 -1
  173. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +10 -4
  174. package/templates/presets/identity/e2e/support.wiring.tpl +17 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,118 @@ What each version changes for someone who uses the kit. The packages of `package
4
4
  together, under one version; the notes of each [GitHub release](https://github.com/gbourgeat/ddd-ts-kit/releases)
5
5
  list the pull requests behind it.
6
6
 
7
+ ## 0.98.0
8
+
9
+ **The test runners page measures Vitest against Jest, and says which settings make each faster.**
10
+ `docs/tools/test-runners.md` (and its French page) said speed was not measured; it now gives the
11
+ wall time, CPU and memory of both runners on three pairs of projects identical but for `--tests` (a
12
+ new project, the identity preset, the scheduling example ported to Jest), cold and warm, with and
13
+ without coverage, unit and integration specs apart, one file, and on four CPUs as on a hosted
14
+ runner. Without coverage Jest is 24 to 29 percent faster on the larger projects; with coverage as
15
+ generated Vitest is 1.6 to 2.4 times faster on the example, the cost of Jest's `v8` provider, while
16
+ Jest with the `babel` provider is the fastest of the three (20.6 s against 29.5 and 48.0). The page
17
+ also measures the coverage providers and what each one reports, the number of workers, the pool
18
+ and isolation of Vitest, the worker threads of Jest, the related specs of a changed file, a
19
+ pipeline without cache, the install and mutation testing, and closes on a table of recommendations
20
+ by case, each with its measured gain and what to watch. It names two limits of the Jest template
21
+ the measures found: coverage through `v8`, and PostgreSQL started in process once per spec file
22
+ where the Vitest template starts it once per run.
23
+
24
+ **A Jest project starts PostgreSQL in process once per run, as a Vitest project does.** On an ORM,
25
+ `init --tests jest` writes `test/support/test-database-template.ts`, a global setup that initialises
26
+ the PGlite cluster once and saves it, and `test/support/test-database-teardown.ts`, which deletes
27
+ it, both named in `jest.config.js`; `open-test-database.ts` opens a copy of that cluster in each
28
+ spec instead of running an initdb of its own, as it already did under Vitest. On the identity
29
+ preset the integration specs under Jest take 26 CPU seconds instead of 45, for the same wall time
30
+ on a workstation (`docs/tools/test-runners.md`), and a busy machine no longer makes the hook that
31
+ opens the database outlast its timeout.
32
+
33
+ To move: in a Jest project on an ORM, copy the two files of `test/support/` from a new project
34
+ (`init --tests jest` with the same `--orm`), name them in `jest.config.js`
35
+ (`globalSetup: '<rootDir>/test/support/test-database-template.ts'`,
36
+ `globalTeardown: '<rootDir>/test/support/test-database-teardown.ts'`), and take
37
+ `inProcessPostgres()` of the new `src/platform/database/open-test-database.ts` in place of
38
+ `PGlite.create()`.
39
+
40
+ **A Jest project measures its coverage through the `babel` provider.** The `jest.config.js` that
41
+ `init --tests jest` writes sets `coverageProvider: 'babel'` instead of `'v8'`: on the scheduling
42
+ example ported to Jest, a run with coverage takes 20.6 s instead of 48.0 s on a workstation, and
43
+ 65 s instead of 201 s on four CPUs, faster than the same specs under Vitest (measured in
44
+ `docs/tools/test-runners.md`). The branches it reports are those of the `v8` provider of Vitest;
45
+ the `v8` provider of Jest reported two to three points more. A line left out of the measure carries
46
+ the hint the provider reads, `istanbul ignore`, which `v8` did not read, as `babel` does not read
47
+ `v8 ignore`: the explanation of `test/coverage-governed` (`ddd-ts-kit explain`) gives both, and
48
+ the testing rules of a new project name the one its runner reads.
49
+
50
+ To move: in the `jest.config.js` of an existing Jest project, set `coverageProvider: 'babel'`,
51
+ rewrite each `v8 ignore` comment as `istanbul ignore` with its decision record, and run
52
+ `npm run test:coverage` once: a layer whose branch threshold sat within three points of the old
53
+ figure can fall under it.
54
+
55
+ **The test runners page says how mutation testing fares under each runner.** On the identity
56
+ preset, Stryker completes under Vitest in 1 min 46 s with 19 processes and 1 min 54 s with 8, for
57
+ 11.6 GB and 5.4 GB of summed memory; under Jest it did not complete on a workstation of 31 GB, at
58
+ 19 or 8 processes nor with each process restarted after 10 runs, each Jest process reaching about
59
+ 2.5 GB within the first minute. `docs/tools/test-runners.md` gives the figures, a recommendation
60
+ (`--concurrency 8` under Vitest on a workstation, the mutation job planned on Vitest) and a limit
61
+ of Jest.
62
+
63
+ **`reset()` of the end-to-end support writes the grants of the system actors again.** With `--authz rebac` and a database (any ORM), `startApplication().reset()` emptied the relation tuples with every other table, so the relationships `relateSystemActors` wrote at start were gone from the second test of a spec on, and a reaction that sent a protected command as a system actor was refused with FORBIDDEN. `reset()` now calls `relateSystemActors()` after emptying the database, which leaves the application in the state it had right after start while the specs stay isolated.
64
+
65
+ To move: in a generated project, make `reset` in `test/e2e/support/start-application.ts` call `relateSystemActors()` after `database.reset()`, and drop the calls a spec made to relate its system actors again.
66
+
67
+ **The privacy register no longer says "until erased" for a retention read from configuration.**
68
+ `personalFields` accepts `configuredRetention: 'RETENTION_PERIODS'`, the key of the configuration
69
+ that gives the period when the project reads it at run time and purges by its own job. The generated
70
+ register and the `CONTEXT.md` write ``configured by `RETENTION_PERIODS` `` in the Kept column. The key
71
+ is read from the source text, never the value; the kit's own purge still runs only from a literal
72
+ `retention`, and the two together are refused.
73
+
74
+ **`generate erasure-handler` on an event-sourced context says that the key of the subject erases it, instead of sending to a table.** The context has no table to erase: its personal values are sealed by `personalData(subjectId, value)`, and `privacy:erase` (`eraseDataSubject`) destroys the key, which erases them in every context. The refusal now names `personalData`, `eraseDataSubject` and the guides, and the privacy guide, the persistence and integration-event skills say that a retention date on such a context is a scheduled job that calls the same key destruction.
75
+
76
+ **A file of types only no longer fails the coverage floor of a Jest project on the `v8` provider.**
77
+ A file that declares interfaces and type aliases and is imported with `import type` only, for
78
+ example `application/commands/pay/pay.result.ts`, is never loaded at run time, and the `v8`
79
+ provider of Jest reported all its lines uncovered, so that the floor of the layer failed though
80
+ nothing executable was untested. `governedJestCoverage()` now reads each source file as text and
81
+ leaves out of `collectCoverageFrom` those that declare types only, as it does for the ports; a
82
+ layer that holds nothing else is held to nothing, under Vitest too. Vitest and the `babel`
83
+ provider of Jest already skipped such a file.
84
+
85
+ To move: nothing; a project that moved its types into the command file to get around it can move
86
+ them back.
87
+
88
+ **`generate e2e` writes the spec of a use case only a job starts.** A use case with no route and no integration event handler used to be refused, although a job (`generate job`) is a starter of a use case too. The spec now starts the application, runs the job as the scheduler would with `await application.runJob('<context>.<job>')`, awaits `settled()` and leaves the `then` to fill. The refusal, when nothing starts the use case, names the job as a third starter it looked for. The shared support `test/e2e/support/start-application.ts` gains `runJob(name)`, which rejects when the run did not succeed, and `composeApplication` returns its `jobs` scheduler.
89
+
90
+ To move: in an existing project, add `runJob(name: string): Promise<void>;` to `RunningApplication` in `test/e2e/support/start-application.ts` and implement it with `jobs.runNow(name)` on the composed application (a run whose `outcome` is not `succeeded` throws); add `readonly jobs: JobScheduler` to `Application` in `compose-application.ts`, returned as `platform.jobs` (manual wiring) or `container.resolve(JobScheduler)` (tsyringe). `generate e2e` notes a support without `runJob`.
91
+
92
+ **`events/consumer-idempotent` accepts options spread from a shared object.**
93
+ `consume(definition, { ...options, consumer: 'ctx.name' }, handler)` passes when `options` is a
94
+ `const` of the same file initialised with an object literal that carries `processed`, or a value typed
95
+ `ConsumeOptions`; the consumer name is still read as the literal `consumer` key. A spread whose content
96
+ the file does not show is still refused, and the fix says that `processed` cannot be read.
97
+
98
+ **`generate command --aggregate` writes a handler that changes an aggregate that exists and writes nothing, and `--creates` is the birth.** Until now every command generated with `--aggregate` called `<Aggregate>.create(...)` and saved a new row on each run, so the use case a job sends created a row on every tick until a worker filled it, and the handler did not compile when `create` of the aggregate takes other arguments (TS2554). The handler now receives the repository of the aggregate, answers `void`, and holds a `TODO(domain)` (load, call one intention method, save): it compiles against the aggregate as it is and writes nothing. `--aggregate <Name> --creates` generates the former handler, which gives birth to the aggregate and answers its identifier. `--creates` without `--aggregate` is refused. A policy added later to the permission of a generated command is asked in either form.
99
+
100
+ To move: add `--creates` to the `generate command ... --aggregate` of each slice that is the birth of its aggregate (a `Start with` cell of a story included). A handler already generated is left as it is.
101
+
102
+ **In the explicit style, each module of the model has its module file, `<module>/<module>.module.ts`, composed by `<context>.module.ts`.** A context divided into modules (`contexts.<name>.modules`) registered the handlers, consumers and reactions of every module in its one `<context>.module.ts`, which passed the 350 lines of `clean/file-size` on a large context, and `tree/closed` refused any other file at the root of the context, so a project had to declare an extra directory to split it. Now `generate module <context> <module>` writes `<module>/<module>.module.ts` and composes it from `<context>.module.ts`: on tsyringe the file exports `{ register(builder), onStart({ resolve }) }`, called from `register` and `onStart` of the context; wired by hand (`--di manual` or `nest`) it exports `registerHandlers`, `registerReactions`, `registerJobs`, `useCases()` and `routes(platform)`, called from the functions of the same names. `generate <kind> ... --module <module>` writes its registration there when the file exists; wired by hand, a use case whose repository another module file already creates is registered in that file, so a repository is still created once per context. `tree/closed` accepts the module file at the root of a declared module and reports any other file there; `check` reads it as a module file (`composition/only-in-module`, `declarations/port-adapter-wired`, `authz/declared`, `domain-events/transactional-before-commit`), and so do `describe`, `docs` and the generators that read the registrations. A wiring block written into a module file also merges an import it repeats once the import names the file in its module, which wrote the same import twice in a context with modules. The declared style is unchanged: a module has no module file, its classes declare themselves.
103
+
104
+ To move: in an explicit context with modules, run `npx ddd-ts-kit generate module <context> <module>` again for each module (it adds the module file and its composition, and nothing else), then move the registrations of each module from `<context>.module.ts` to its module file, with their imports; a `composition/` folder declared in `extraDirectories` for this can go.
105
+
106
+ **The end-to-end support binds the fake identity provider admin once the identity preset is written.**
107
+ Opening an organisation queues `identity.organisation.opened` and `identity.member.joined`, whose
108
+ handlers call the identity provider admin; in a test run no provider answers, so the outbox retried
109
+ for ever and `settled()` failed (`outbox: 2 (2 failed, waiting for a retry)`) in every spec that opens
110
+ an organisation. `test/e2e/support/start-application.ts` now composes the contexts through
111
+ `contextsOfTheRun()`, the place where the fake of an outside system is bound, and the identity preset
112
+ (with `init --preset identity` or `generate context identity --preset identity`) binds
113
+ `FakeIdentityProviderAdmin` there. In the explicit style, `identityModule(platform, outside)` takes
114
+ the adapters a test run replaces.
115
+
116
+ To move: in a project written before, bind the fake yourself in `contextsOfTheRun()`; the support
117
+ of an existing project is not rewritten.
118
+
7
119
  ## 0.97.0
8
120
 
9
121
  **Under the sandbox of the regulated profile, `prisma-generate` and `typeorm-generate` say that the database is out of reach instead of failing with a raw connection error.** A sandboxed command cannot open a TCP connection to the local PostgreSQL (probed on Claude Code 2.1.311 on Linux: `allowedDomains` with the host and the port, `allowLocalBinding` and `allowAllUnixSockets` all end in `ECONNREFUSED`; the sandbox's network leaves through an HTTP proxy only, and `allowLocalBinding` and `allowUnixSockets` are macOS settings), so `init` writes no setting for it. When `DATABASE_URL` is set and its server does not answer, the two commands stop before the ORM tool, exit 3 and say that migrations and database tests run outside the sandbox, by the owner or the CI. `drizzle-kit generate` needs no connection and is unchanged. The sandbox guide (and its French translation), the notes of `init` and the `persistence`, `parallel-work` and `story` skills say it.
package/README.fr.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:f7701cee925ecc13 -->
2
+ <!-- translation-of: README.md sha256:abcea9074d99a803 -->
3
3
 
4
4
  # ddd-ts-kit
5
5
 
@@ -30,7 +30,7 @@ Aucune dépendance d'exécution. Node 22.12 ou ultérieur.
30
30
  npx ddd-ts-kit init
31
31
  npx ddd-ts-kit generate context billing --classification core --term "Invoice=A request for payment"
32
32
  npx ddd-ts-kit generate aggregate billing Invoice
33
- npx ddd-ts-kit generate command billing IssueInvoice --aggregate Invoice --permission invoice.issue --grant accountant --term "Issue=To make an invoice final"
33
+ npx ddd-ts-kit generate command billing IssueInvoice --aggregate Invoice --creates --permission invoice.issue --grant accountant --term "Issue=To make an invoice final"
34
34
  npx ddd-ts-kit generate route billing IssueInvoice --method POST --path /invoices
35
35
  npx ddd-ts-kit check
36
36
  ```
@@ -193,7 +193,7 @@ lui remet, dans l'un ou l'autre assemblage. Une configuration écrite avant l'ex
193
193
  Le même cas d'usage dans les deux styles. Dans le style déclaré, la commande et son gestionnaire
194
194
  (handler) portent leur décorateur, et le constructeur du gestionnaire dit ce dont il a besoin. Le
195
195
  corps du gestionnaire est celui qu'écrit
196
- `generate command billing IssueInvoice --aggregate Invoice --permission invoice.issue`, avant
196
+ `generate command billing IssueInvoice --aggregate Invoice --creates --permission invoice.issue`, avant
197
197
  que son `TODO(domain)` soit traité ; l'entrée de la commande est remplie :
198
198
 
199
199
  <!-- checked sample -->
@@ -761,7 +761,7 @@ Next, in this order: the language of the context first, then the business decisi
761
761
  | `domain-service` | `<context> <Name>` | service, *spec* |
762
762
  | `state-machine` | `<context> <Aggregate> [--value <state>]... [--transition "<intention>:<from>[,<from>]...[><to>]"]...` | le vocabulaire `<Aggregate>Status` (créé depuis `--value`, deux états au moins, ou complété des valeurs qui lui manquent), `domain/state-machines/<aggregate>.state-machine.ts` (`<aggregate>Lifecycle` : chaque valeur un état, la première initiale, les transitions demandées, un `TODO(domain)` pour le refus de l'erreur du concept) et `test/unit/<aggregate>.state-machine.spec.ts` (chaque transition là où elle mène, un refus depuis un état qu'elle ne quitte pas) ; c'est à l'agrégat de l'utiliser |
763
763
  | `repository` | `<context> <Aggregate> [--tenant-scoped] [--personal <colonne>,... [--subject <colonne>] [--erasure pseudonymise\|row] [--retention <colonne>:<n><d\|m\|y>]]` | le port `domain/repositories/<name>.repository.ts` (`abstract class <Name>Repository extends Repository<<Name>>`), l'adaptateur de l'ORM du projet (qui `implements` le port) avec son *mapper* et sa table (ou son modèle), un *fake*, une *spec* `repositoryContract` exécutée sur les deux, l'enregistrement. Sur un agrégat *event-sourced* (sa classe étend `EventSourcedAggregate`), ni table ni *mapper* : `event-store-<name>.repository.ts` délègue à `EventSourcedRepository` du kernel au-dessus de l'`EventStore` et du `PersonalDataCipher` que lie la plateforme, avec le codec de `<name>-events.mapper.ts` (la politique de *snapshot* laissée en `TODO(domain)`), le *fake* est cet adaptateur sur les stores en mémoire, et la suite de contrat s'exécute sur les deux (son cas de sauvegarde périmée en attente tant qu'un `mutate` qui enregistre un événement n'est pas ajouté) ; `--personal` y est refusé, les valeurs personnelles étant scellées dans les événements. Avec `--personal`, les colonnes de la table qui tiennent des données personnelles : ajoutées au stockage et au type de ligne en texte nullable (le *mapper* les écrit vides tant que l'agrégat ne les porte pas), déclarées à côté du *mapper* dans `<name>.personal-fields.ts` (`personalFields` du kernel : la colonne du sujet, `id` sauf si `--subject` nomme la colonne qui tient l'id de la personne, les champs, `pseudonymise` sauf `--erasure row`), épelées comme l'effacement de l'ORM les lit (noms SQL sur Knex et Prisma, propriétés sur Drizzle et TypeORM) ; et, une fois par contexte, son effacement : le port `application/ports/<context>-personal-data-erasure.port.ts` (`extends PersonalDataErasure`), l'adaptateur `<orm>-<context>-personal-data-erasure.repository.ts` sur `<Orm>PersonalDataErasure` du paquet d'ORM (confiné au *tenant* du travail avec `--tenant-scoped`), son *fake*, lié là où le contexte lie ses adaptateurs et listé dans `src/platform/privacy/data-subject-copies.ts`, pour que `npm run privacy:erase` l'atteigne ; et son export : le port `<context>-personal-data-export.port.ts` (`extends PersonalDataExport`), l'adaptateur `<orm>-<context>-personal-data-export.repository.ts` sur `<Orm>PersonalDataExport`, son *fake*, lié de même et listé dans `data-subject-exports.ts`, pour que `npm run privacy:export` le remette ; une seule *spec*, `test/integration/<context>-personal-data.spec.ts`, prouve les deux sur la base de test. Avec `--retention <colonne>:<n><d|m|y>`, la déclaration gagne `retention`, comptée depuis une colonne qui date la fin de la relation et rejoint le stockage en horodatage nullable, vide tant qu'elle dure (une colonne que la table garde pour elle, `registered_at` d'abord, est refusée : comptée depuis l'inscription, la purge effacerait des personnes encore clientes) et la *spec* prouve la purge de ce qui l'a dépassée. Une deuxième table du contexte rejoint les déclarations des deux adaptateurs. Refusé sans `stack.privacy` à `on` (`init --force --privacy on`), avec `--orm none` ou `custom`, et avant d'écrire quoi que ce soit pour une colonne qui n'en est pas une, une colonne que la table garde pour elle, un sujet listé comme personnel ou un mode qui n'existe pas |
764
- | `command` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--aggregate <Name>]` | `<use-case>.command.ts` sur `AuthorizedCommand` (simple `Command` quand elle est publique), `<use-case>.handler.ts` (il construit l'agrégat, le sauvegarde et répond : les événements partent avec la sauvegarde), une *spec* par le bus avec le refus d'un acteur à qui manque la permission, l'enregistrement avec `.requires(...)` ou `.public()` (et le *repository* s'il manque). Une commande générée répond `void` ou l'identifiant de son agrégat, si bien qu'aucun `<use-case>.result.ts` n'est écrit |
764
+ | `command` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--aggregate <Name> [--creates]]` | `<use-case>.command.ts` sur `AuthorizedCommand` (simple `Command` quand elle est publique), `<use-case>.handler.ts` (avec `--aggregate`, il reçoit le *repository* et n'écrit rien tant que son `TODO(domain)` n'est pas traité : une commande change un agrégat qui existe ; avec `--creates`, il construit l'agrégat, le sauvegarde et répond son identifiant : les événements partent avec la sauvegarde), une *spec* par le bus avec le refus d'un acteur à qui manque la permission, l'enregistrement avec `.requires(...)` ou `.public()` (et le *repository* s'il manque). Une commande générée répond `void` ou l'identifiant de son agrégat, si bien qu'aucun `<use-case>.result.ts` n'est écrit |
765
765
  | `query` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--search]` | `<use-case>.query.ts` sur `AuthorizedQuery` (simple `Query` quand elle est publique), `<use-case>.result.ts`, `<use-case>.handler.ts`, le port de lecture `application/ports/<use-case>-reader.port.ts` (une classe abstraite), son adaptateur en mémoire, un *fake*, une *spec*, l'enregistrement sur le bus de requêtes. Avec `--search` (demande `--permission`) : une `PageRequest` du kernel dans la requête, l'élément, le tri et `Page<Item>` dans le fichier de résultat, un gestionnaire qui demande `Access.scope` et remet le périmètre au port de lecture, un lecteur en mémoire qui pagine par décalage ou par curseur |
766
766
  | `port` | `<context> <Name>` | `application/ports/<name>.port.ts`, une classe abstraite, et son *fake* |
767
767
  | `route` | `<context> <UseCaseName> --method <GET\|POST\|PUT\|PATCH\|DELETE> --path <p> [--command\|--query] [--group <Name>] [--mapper] [--serializer] [--cache public\|private\|no-store]` | sous `"stack.routes": "controllers"` : une classe contrôleur dans `presentation/http/<resource>/<use-case>/` (la ressource est le premier segment du chemin), qui dépend de `CommandBus` ou de `QueryBus`, derrière le groupe de routes de sa ressource, écrit avec elle quand il est nouveau (`<resource>.routes.ts` : préfixe, étiquette, `Authenticated`) ; un cas d'usage public ne se tient dans aucun groupe et dit `guards: [Public]` ; avec class-validator, une classe par fichier (`<use-case>.params.ts`, `.body.ts`, `.answer.ts`, `.accepted.ts`, `.line.ts`) ; `--mapper` et `--serializer` ajoutent un *mapper* de requête HTTP et un sérialiseur que reçoit le contrôleur ; une *spec* ; aucun enregistrement dans un projet déclaré, un contrôleur construit à la main dans `<context>.routes.ts` (le fichier de module en câblage manuel) dans un projet explicite. Sous `"functions"` : une fonction `defineRoute`, sa *spec*, son enregistrement dans `<context>.routes.ts`, et des classes `<use-case>-<role>.dto.ts` |
@@ -774,7 +774,7 @@ Next, in this order: the language of the context first, then the business decisi
774
774
  | `schema` | `<context\|shared-kernel> <Name>` | `presentation/http/shared/<name>.schema.ts` du contexte, ou `presentation/<name>.schema.ts` du noyau partagé : une forme du contrat déclarée une fois (un schéma zod avec `.meta({ id })`, une classe class-validator, ou un schéma enveloppé par `sharedSchema`), à remplir ; les routes l'utilisent en entier, imbriquée ou en partie |
775
775
  | `integration-event` | `<context> <Aggregate> <Fact> [--version n]` | la déclaration `defineIntegrationEvent` dans le langage publié (sa charge utile dans `<event>.v<n>.payload.ts` avec class-validator ou un schéma à vous), l'export de l'index, le *publisher* `application/integration/publishers/<event>.publisher.ts`, une *spec*, l'enregistrement, une ligne de `platform/audit/audited-events.ts` |
776
776
  | `integration-handler` (`consumer`) | `<context> <upstreamContext> <eventType>` | `application/integration/handlers/<name>.integration-handler.ts`, une classe `<Name>IntegrationHandler` qui dépend de `CommandBus`, sa *spec*, son abonnement idempotent sous le nom de consommateur `<context>.<name>` ; refusé sauf si l'amont est déclaré |
777
- | `erasure-handler` | `<context>` | `application/integration/handlers/data-subject-erased.integration-handler.ts`, une classe `DataSubjectErasedIntegrationHandler` qui efface ce que le contexte garde d'une personne par son `<Context>PersonalDataErasure` quand la plateforme annonce `privacy.data-subject.erased` (`dataSubjectErasedV1` du kernel), sa *spec* sur le *fake*, son abonnement idempotent sous le nom de consommateur `<context>.data-subject-erased` (dans une transaction derrière un *broker*) ; pour un contexte qui tourne comme un service à part ou copie des données personnelles depuis des événements. Refusé tant que le contexte n'a pas son effacement (`generate repository --personal`) |
777
+ | `erasure-handler` | `<context>` | `application/integration/handlers/data-subject-erased.integration-handler.ts`, une classe `DataSubjectErasedIntegrationHandler` qui efface ce que le contexte garde d'une personne par son `<Context>PersonalDataErasure` quand la plateforme annonce `privacy.data-subject.erased` (`dataSubjectErasedV1` du kernel), sa *spec* sur le *fake*, son abonnement idempotent sous le nom de consommateur `<context>.data-subject-erased` (dans une transaction derrière un *broker*) ; pour un contexte qui tourne comme un service à part ou copie des données personnelles depuis des événements. Refusé tant que le contexte n'a pas son effacement (`generate repository --personal`), et refusé sur un contexte en *event sourcing*, dont les valeurs personnelles s'effacent en détruisant la clé du sujet (`eraseDataSubject`) |
778
778
  | `event-handler` | `<context> <Aggregate> <Fact> [--phase before-commit\|after-commit]` | réaction à un événement du domaine du contexte, *spec*, abonnement ; avant la validation (commit) de l'unité de travail par défaut, après elle avec `--phase after-commit` (un effet qu'aucune transaction ne couvre, au plus une fois), et la *spec* exécute la réaction dans cette phase |
779
779
  | `projection` (`projector`) | `<context> <Name> <event-type>` | un projecteur dans `application/projections/<name>.projection.ts`, déclaré avec `@Projection('<context>.<name>')` et une méthode `@On(definition)` pour l'événement d'intégration, que publie le contexte lui-même ou un amont déclaré, et sa *spec*. Dans le style explicite sur tsyringe, le fichier de module du contexte l'inclut par `builder.include(<Name>Projection)` ; sur une plateforme câblée à la main, la classe est simple et le module la souscrit sous son nom de consommateur. Il tient un seul modèle de lecture : son port est reçu par le constructeur |
780
780
  | `job` | `<context> <Name> (--every <duration> \| --cron "<expression>" [--time-zone <zone>]) --command <UseCaseName>` | `application/scheduling/<name>.job.ts`, une classe `<Name>Job implements ScheduledJob` qui envoie la commande, en tant que `systemActor('<context>.<name>')` quand elle est protégée, avec `execution.scheduledAt` quand la commande le prend ; `test/unit/<name>.job.spec.ts`, qui exécute le *job* (par son nom sur tsyringe, `application.jobs.runNow` ; `job.run(occurrence)` en câblage manuel) et vérifie la commande qu'il a envoyée ; son enregistrement ; son interrupteur dans `platform/jobs/job-settings.ts` ; l'autorisation de son acteur système (ci-dessous) |
package/README.md CHANGED
@@ -28,7 +28,7 @@ No runtime dependency. Node 22.12 or later.
28
28
  npx ddd-ts-kit init
29
29
  npx ddd-ts-kit generate context billing --classification core --term "Invoice=A request for payment"
30
30
  npx ddd-ts-kit generate aggregate billing Invoice
31
- npx ddd-ts-kit generate command billing IssueInvoice --aggregate Invoice --permission invoice.issue --grant accountant --term "Issue=To make an invoice final"
31
+ npx ddd-ts-kit generate command billing IssueInvoice --aggregate Invoice --creates --permission invoice.issue --grant accountant --term "Issue=To make an invoice final"
32
32
  npx ddd-ts-kit generate route billing IssueInvoice --method POST --path /invoices
33
33
  npx ddd-ts-kit check
34
34
  ```
@@ -177,7 +177,7 @@ A config written before `stack.style` existed is explicit.
177
177
 
178
178
  The same use case in both styles. In the declared style, the command and its handler carry their
179
179
  decorator, and the handler's constructor says what it needs. The body of the handler is the one
180
- `generate command billing IssueInvoice --aggregate Invoice --permission invoice.issue` writes,
180
+ `generate command billing IssueInvoice --aggregate Invoice --creates --permission invoice.issue` writes,
181
181
  before its `TODO(domain)` is answered; the input of the command is filled in:
182
182
 
183
183
  <!-- checked sample -->
@@ -732,7 +732,7 @@ Next, in this order: the language of the context first, then the business decisi
732
732
  | `domain-service` | `<context> <Name>` | service, spec |
733
733
  | `state-machine` | `<context> <Aggregate> [--value <state>]... [--transition "<intention>:<from>[,<from>]...[><to>]"]...` | the vocabulary `<Aggregate>Status` (created from `--value`, two states at least, or given the values it misses), `domain/state-machines/<aggregate>.state-machine.ts` (`<aggregate>Lifecycle`: every value a state, the first one initial, the transitions asked, a `TODO(domain)` for the refusal of the concept error) and `test/unit/<aggregate>.state-machine.spec.ts` (each transition where it leads, a refusal from a state it does not leave); the aggregate is left to use it |
734
734
  | `repository` | `<context> <Aggregate> [--tenant-scoped] [--personal <column>,... [--subject <column>] [--erasure pseudonymise\|row] [--retention <column>:<n><d\|m\|y>]]` | the port `domain/repositories/<name>.repository.ts` (`abstract class <Name>Repository extends Repository<<Name>>`), the adapter of the project's ORM (`implements` the port) with its mapper and table (or model), a fake, one `repositoryContract` spec run on both, registration. On an event-sourced aggregate (its class extends `EventSourcedAggregate`) there is no table nor mapper: `event-store-<name>.repository.ts` delegates to `EventSourcedRepository` of the kernel over the `EventStore` and the `PersonalDataCipher` the platform binds, with the codec of `<name>-events.mapper.ts` (the snapshot policy left as a `TODO(domain)`), the fake is that adapter over the in-memory stores, and the contract suite runs on both (its stale-save case pending until a `mutate` that records an event is added); `--personal` is refused there, the personal values being sealed in the events. With `--personal`, the columns of the table that hold personal data: added to the storage and to the row type as nullable text (the mapper writes them empty until the aggregate carries them), declared next to the mapper in `<name>.personal-fields.ts` (`personalFields` of the kernel: the subject column, `id` unless `--subject` names the column that holds the id of the person, the fields, `pseudonymise` unless `--erasure row`), spelled as the erasure of the ORM reads them (SQL names on Knex and Prisma, properties on Drizzle and TypeORM); and, once per context, its erasure: the port `application/ports/<context>-personal-data-erasure.port.ts` (`extends PersonalDataErasure`), the adapter `<orm>-<context>-personal-data-erasure.repository.ts` over `<Orm>PersonalDataErasure` of the ORM package (confined to the tenant of the work with `--tenant-scoped`), its fake, bound where the context binds its adapters and listed in `src/platform/privacy/data-subject-copies.ts`, so that `npm run privacy:erase` reaches it; and its export: the port `<context>-personal-data-export.port.ts` (`extends PersonalDataExport`), the adapter `<orm>-<context>-personal-data-export.repository.ts` over `<Orm>PersonalDataExport`, its fake, bound the same way and listed in `data-subject-exports.ts`, so that `npm run privacy:export` hands it over; one spec, `test/integration/<context>-personal-data.spec.ts`, proves both on the test database. With `--retention <column>:<n><d|m|y>`, the declaration gains `retention`, counted from a column that dates the end of the relation and joins the storage as a nullable timestamp, empty while it lasts (a column the table keeps for itself, `registered_at` first, is refused: counted from the registration, the purge would erase people who are still customers) and the spec proves the purge of what outlived it. A second table of the context joins the declarations of both adapters. Refused without `stack.privacy` on (`init --force --privacy on`), with `--orm none` or `custom`, and before anything is written for a column that is not one, a column the table keeps for itself, a subject listed as personal or a mode that does not exist |
735
- | `command` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--aggregate <Name>]` | `<use-case>.command.ts` on `AuthorizedCommand` (plain `Command` when public), `<use-case>.handler.ts` (it builds the aggregate, saves it and answers: the events leave with the save), spec through the bus with the refusal of an actor who lacks the permission, registration with `.requires(...)` or `.public()` (and the repository when missing). A generated command answers `void` or the identifier of its aggregate, so no `<use-case>.result.ts` is written |
735
+ | `command` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--aggregate <Name> [--creates]]` | `<use-case>.command.ts` on `AuthorizedCommand` (plain `Command` when public), `<use-case>.handler.ts` (with `--aggregate` it receives the repository and writes nothing until its `TODO(domain)` is answered: a command changes an aggregate that exists; with `--creates` it builds the aggregate, saves it and answers its identifier: the events leave with the save), spec through the bus with the refusal of an actor who lacks the permission, registration with `.requires(...)` or `.public()` (and the repository when missing). A generated command answers `void` or the identifier of its aggregate, so no `<use-case>.result.ts` is written |
736
736
  | `query` | `<context> <UseCaseName> (--permission <aggregate>.<action> [--grant <role>] \| --public) [--search]` | `<use-case>.query.ts` on `AuthorizedQuery` (plain `Query` when public), `<use-case>.result.ts`, `<use-case>.handler.ts`, the read port `application/ports/<use-case>-reader.port.ts` (an abstract class), its in-memory adapter, fake, spec, registration on the query bus. With `--search` (needs `--permission`): a kernel `PageRequest` in the query, the item, the sort and `Page<Item>` in the result file, a handler that asks `Access.scope` and hands the scope to the read port, an in-memory reader paging by offset or cursor |
737
737
  | `port` | `<context> <Name>` | `application/ports/<name>.port.ts`, one abstract class, and its fake |
738
738
  | `route` | `<context> <UseCaseName> --method <GET\|POST\|PUT\|PATCH\|DELETE> --path <p> [--command\|--query] [--group <Name>] [--mapper] [--serializer] [--cache public\|private\|no-store]` | under `"stack.routes": "controllers"`: a controller class in `presentation/http/<resource>/<use-case>/` (the resource is the first segment of the path), depending on `CommandBus` or `QueryBus`, behind the route group of its resource, written with it when it is new (`<resource>.routes.ts`: prefix, tag, `Authenticated`); a public use case stands in no group and says `guards: [Public]`; with class-validator one class per file (`<use-case>.params.ts`, `.body.ts`, `.answer.ts`, `.accepted.ts`, `.line.ts`); `--mapper` and `--serializer` add a request mapper and a serializer the controller is given; a spec; no registration in a declared project, a controller built by hand in `<context>.routes.ts` (the module file with hand wiring) in an explicit one. Under `"functions"`: a `defineRoute` function, its spec, its registration in `<context>.routes.ts`, and `<use-case>-<role>.dto.ts` classes |
@@ -745,7 +745,7 @@ Next, in this order: the language of the context first, then the business decisi
745
745
  | `schema` | `<context\|shared-kernel> <Name>` | `presentation/http/shared/<name>.schema.ts` of the context, or `presentation/<name>.schema.ts` of the shared kernel: one shape of the contract declared once (a zod schema with `.meta({ id })`, a class-validator class, or a schema wrapped by `sharedSchema`), to fill; the routes use it whole, nested or in part |
746
746
  | `integration-event` | `<context> <Aggregate> <Fact> [--version n]` | `defineIntegrationEvent` declaration in the published language (its payload in `<event>.v<n>.payload.ts` with class-validator or a schema of your own), index export, the publisher `application/integration/publishers/<event>.publisher.ts`, spec, registration, a line of `platform/audit/audited-events.ts` |
747
747
  | `integration-handler` (`consumer`) | `<context> <upstreamContext> <eventType>` | `application/integration/handlers/<name>.integration-handler.ts`, a class `<Name>IntegrationHandler` depending on `CommandBus`, its spec, its idempotent subscription under the consumer name `<context>.<name>`; refused unless the upstream is declared |
748
- | `erasure-handler` | `<context>` | `application/integration/handlers/data-subject-erased.integration-handler.ts`, a class `DataSubjectErasedIntegrationHandler` that erases what the context keeps of a person through its `<Context>PersonalDataErasure` when the platform announces `privacy.data-subject.erased` (`dataSubjectErasedV1` of the kernel), its spec on the fake, its idempotent subscription under the consumer name `<context>.data-subject-erased` (in a transaction behind a broker); for a context that runs as a service of its own or copies personal data from events. Refused until the context has its erasure (`generate repository --personal`) |
748
+ | `erasure-handler` | `<context>` | `application/integration/handlers/data-subject-erased.integration-handler.ts`, a class `DataSubjectErasedIntegrationHandler` that erases what the context keeps of a person through its `<Context>PersonalDataErasure` when the platform announces `privacy.data-subject.erased` (`dataSubjectErasedV1` of the kernel), its spec on the fake, its idempotent subscription under the consumer name `<context>.data-subject-erased` (in a transaction behind a broker); for a context that runs as a service of its own or copies personal data from events. Refused until the context has its erasure (`generate repository --personal`), and refused on an event-sourced context, whose personal values are erased by destroying the key of the subject (`eraseDataSubject`) |
749
749
  | `event-handler` | `<context> <Aggregate> <Fact> [--phase before-commit\|after-commit]` | reaction to a domain event of the context, spec, subscription; before the commit of the unit of work by default, after it with `--phase after-commit` (an effect no transaction covers, at most once), and the spec runs the reaction in that phase |
750
750
  | `projection` (`projector`) | `<context> <Name> <event-type>` | a projector in `application/projections/<name>.projection.ts`, declared with `@Projection('<context>.<name>')` and one `@On(definition)` method for the integration event, which the context itself or a declared upstream publishes, and its spec. In the explicit style on tsyringe the module file of the context includes it with `builder.include(<Name>Projection)`; on a hand-wired platform the class is plain and the module subscribes it under its consumer name. It keeps one read model: its port is received in the constructor |
751
751
  | `job` | `<context> <Name> (--every <duration> \| --cron "<expression>" [--time-zone <zone>]) --command <UseCaseName>` | `application/scheduling/<name>.job.ts`, a class `<Name>Job implements ScheduledJob` that sends the command, as `systemActor('<context>.<name>')` when it is protected, with `execution.scheduledAt` when the command takes it; `test/unit/<name>.job.spec.ts`, which runs the job (by name on tsyringe, `application.jobs.runNow`; `job.run(occurrence)` with hand wiring) and asserts the command it sent; its registration; its switch in `platform/jobs/job-settings.ts`; the grant of its system actor (below) |
@@ -1 +1 @@
1
- {"version":3,"file":"stray-entry.d.ts","sourceRoot":"","sources":["../../../src/check/canonical/stray-entry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAgB1C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAS1E"}
1
+ {"version":3,"file":"stray-entry.d.ts","sourceRoot":"","sources":["../../../src/check/canonical/stray-entry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAkB1C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAc1E"}
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import { CONTEXT_FILES } from '../../context-files/index.js';
3
3
  import { controllersFile } from '../../nest-controllers/controllers-file.js';
4
4
  import { barrelFile, dependenciesFile, isDeclarationsFile } from '../../declared/index.js';
5
- import { declaredModules, moduleSplit, WITHOUT_MODULE } from '../../model-modules/index.js';
5
+ import { declaredModules, moduleFileOf, moduleOfModuleFile, moduleSplit, WITHOUT_MODULE } from '../../model-modules/index.js';
6
6
  import { isCanonicalDirectory } from './is-canonical-directory.js';
7
7
  import { OPEN_DIRECTORIES } from './open-directories.js';
8
8
  import { roleOf } from './role-of.js';
@@ -16,6 +16,10 @@ export function strayEntry(entry, config) {
16
16
  if (placed === undefined || (placed.module !== undefined && placed.inside === '') || inDotDirectory(entry)) {
17
17
  return undefined;
18
18
  }
19
+ // At its root, a module of the model holds its module file, which the module file of the context composes.
20
+ if (moduleOfModuleFile(placed.inside, placed.modules) !== undefined) {
21
+ return undefined;
22
+ }
19
23
  return entry.endsWith('/') ? strayDirectory(placed) : straySource(placed);
20
24
  }
21
25
  /** A dot-directory of a context (the `.claude/` a sandbox leaves) is written by a tool: it is no part of the tree. */
@@ -33,11 +37,13 @@ function place(entry, config) {
33
37
  if (rest.length === 0) {
34
38
  return undefined;
35
39
  }
36
- const { module, path: inside } = moduleSplit(rest.join('/'), declaredModules(config, context));
40
+ const modules = declaredModules(config, context);
41
+ const { module, path: inside } = moduleSplit(rest.join('/'), modules);
37
42
  return {
38
43
  context,
39
44
  declared: stack.style === 'declared',
40
45
  inside,
46
+ modules,
41
47
  ...(module === undefined ? {} : { module }),
42
48
  extras: contexts[context]?.extraDirectories ?? [],
43
49
  };
@@ -72,6 +78,12 @@ function straySource(placed) {
72
78
  if (open || generated || roleOf(directory) !== undefined || coveredByExtra(extras, directory)) {
73
79
  return undefined;
74
80
  }
81
+ if (placed.modules.includes(directory)) {
82
+ return {
83
+ message: `"${inside}" sits at the root of the module ${directory}.`,
84
+ fix: `Move it into the directory of its role (${directory}/<layer>/<role>/); only ${moduleFileOf(directory)}, its module file in the explicit style, lives at the root of a module.`,
85
+ };
86
+ }
75
87
  return {
76
88
  message: `"${inside}" is not in a role directory.`,
77
89
  fix: `Move it one level down into the directory of its role (for example ${directory.split('/')[0] ?? directory}/<role>/), so that its suffix and its tests can be checked.`,
@@ -1 +1 @@
1
- {"version":3,"file":"stray-entry.js","sourceRoot":"","sources":["../../../src/check/canonical/stray-entry.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAanC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,MAAc;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEpC,8FAA8F;IAC9F,IAA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,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CACzG,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"event-handlers-of.d.ts","sourceRoot":"","sources":["../../../src/check/domain-events/event-handlers-of.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,EAAE,CAgClF"}
1
+ {"version":3,"file":"event-handlers-of.d.ts","sourceRoot":"","sources":["../../../src/check/domain-events/event-handlers-of.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,EAAE,CAmClF"}
@@ -1,3 +1,4 @@
1
+ import { treeOf, wiringFilesOf } from '../../model-modules/index.js';
1
2
  import { classesOf } from '../declarations/classes-of.js';
2
3
  import { optionOf } from '../declarations/option-of.js';
3
4
  import { sourceAt } from '../project/source-at.js';
@@ -22,7 +23,7 @@ export function eventHandlersOf(project, file) {
22
23
  const wired = isRoleFile(file)
23
24
  ? file.structure.classes.filter((shape) => shape.isExported && shape.depth === 0 && !known.has(shape.name))
24
25
  : [];
25
- const module = wired.length === 0 ? undefined : sourceAt(project, `${project.config.contextsDir}/${context}/${context}.module.ts`);
26
+ const modules = wired.length === 0 ? [] : moduleFiles(project, context);
26
27
  return [
27
28
  ...declared.map((handler) => ({
28
29
  name: handler.name,
@@ -31,15 +32,27 @@ export function eventHandlersOf(project, file) {
31
32
  isAfterCommit: declaresAfterCommit(file, handler),
32
33
  dependencies: handlerDependencies(file, handler.name),
33
34
  })),
34
- ...wired.map(({ name, line }) => ({
35
- name,
36
- line,
37
- context,
38
- isAfterCommit: isRegisteredAfterCommit(module, name),
39
- dependencies: [...handlerDependencies(file, name), ...boundByModule(module, { name, line })],
40
- })),
35
+ ...wired.map(({ name, line }) => {
36
+ const module = registeringModule(modules, name);
37
+ return {
38
+ name,
39
+ line,
40
+ context,
41
+ isAfterCommit: isRegisteredAfterCommit(module, name),
42
+ dependencies: [...handlerDependencies(file, name), ...boundByModule(module, { name, line })],
43
+ };
44
+ }),
41
45
  ];
42
46
  }
47
+ /** The module file of the context, then the one of each module of its model that exists. */
48
+ function moduleFiles(project, context) {
49
+ return wiringFilesOf(treeOf(project.config, context), context).flatMap((path) => sourceAt(project, path) ?? []);
50
+ }
51
+ /** The module file that registers a class: the first that names it, else the module file of the context. */
52
+ function registeringModule(modules, name) {
53
+ const named = new RegExp(`(?<![\\w$])${name}(?![\\w$])`);
54
+ return modules.find((module) => named.test(module.scan.code)) ?? modules[0];
55
+ }
43
56
  function isRoleFile(file) {
44
57
  const [folder, inside] = inLayer(file, 'application')?.inside ?? [];
45
58
  if (folder === 'event-handlers') {
@@ -1 +1 @@
1
- {"version":3,"file":"event-handlers-of.js","sourceRoot":"","sources":["../../../src/check/domain-events/event-handlers-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,mB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D,CAAC;IAED,OAAO,MAAM,KAAK,aAAa,IAAI,MAAM,KAAK,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACpG,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAgB,EAAE,OAAsB;IACnE,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAC7B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,YAAY,CACpH,CAAC;AACJ,CAAC;AAED,2HAA2H;AAC3H,SAAS,aAAa,CACpB,MAA8B,EAC9B,EAAE,IAAI,EAAE,IAAI,EAAuC;IAEnD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACtH,CAAC"}
@@ -8,6 +8,8 @@ export interface ConsumerRegistration {
8
8
  readonly nameLine: number;
9
9
  /** False for a free `on` or `consume` that is given no processed-event store. */
10
10
  readonly deduplicates: boolean;
11
+ /** True when the options spread an object whose content this file does not show, and nothing else gives `processed`. */
12
+ readonly spreadsUnreadable: boolean;
11
13
  }
12
14
  /**
13
15
  * Calls that subscribe a consumer under a name: `builder.on(definition, { consumer })`,
@@ -1 +1 @@
1
- {"version":3,"file":"consumer-registrations.d.ts","sourceRoot":"","sources":["../../../src/check/events/consumer-registrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAQD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAkB9E"}
1
+ {"version":3,"file":"consumer-registrations.d.ts","sourceRoot":"","sources":["../../../src/check/events/consumer-registrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAavD,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,wHAAwH;IACxH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AAQD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAgC9E"}
@@ -1,8 +1,12 @@
1
1
  import { chainEnd } from '../text/chain-end.js';
2
+ import { escapeRegExp } from '../text/escape-reg-exp.js';
3
+ import { matchingBracket } from '../text/matching-bracket.js';
2
4
  const CALL = /(?:(\.)\s*|(?<![\w$.]))(on|consume|idempotent)\s*(?:<[^<>()]*>)?\s*\(/g;
3
5
  const CONSUMER_KEY = /(?<![\w$.])consumer\s*:\s*$/;
4
6
  const CONSUMER_OPTION = /(?<![\w$.])consumer\s*[:,}]/;
5
7
  const STORE_OPTION = /(?<![\w$.])processed\s*[:,}]/;
8
+ const SPREAD = /\.\.\.\s*([A-Za-z_$][\w$]*)\s*(?=[,}])/g;
9
+ const OPTIONS_TYPE = /^(?:Readonly\s*<\s*)?ConsumeOptions\b|^Omit\s*<\s*ConsumeOptions\s*,([^>]*)>/;
6
10
  /**
7
11
  * Calls that subscribe a consumer under a name: `builder.on(definition, { consumer })`,
8
12
  * `consume(definition, { consumer, processed, unitOfWork }, handler)`,
@@ -19,10 +23,27 @@ export function consumerRegistrations(file) {
19
23
  return [];
20
24
  }
21
25
  const line = file.scan.lineAt(span.start);
22
- const deduplicates = match[1] !== undefined || match[2] === 'idempotent' || STORE_OPTION.test(registered);
23
- return [{ code: registered, line, name: literal?.value, nameLine: literal?.line ?? line, deduplicates }];
26
+ const { deduplicates, spreadsUnreadable } = storeOf(file, registered, match[1] !== undefined || match[2] === 'idempotent');
27
+ return [
28
+ {
29
+ code: registered,
30
+ line,
31
+ name: literal?.value,
32
+ nameLine: literal?.line ?? line,
33
+ deduplicates,
34
+ spreadsUnreadable,
35
+ },
36
+ ];
24
37
  });
25
38
  }
39
+ function storeOf(file, registered, given) {
40
+ if (given || STORE_OPTION.test(registered)) {
41
+ return { deduplicates: true, spreadsUnreadable: false };
42
+ }
43
+ const spreads = [...registered.matchAll(SPREAD)].map((spread) => spread[1] ?? '');
44
+ const deduplicates = spreads.some((name) => spreadCarriesStore(file, name));
45
+ return { deduplicates, spreadsUnreadable: !deduplicates && spreads.length > 0 };
46
+ }
26
47
  function firstLiteral(file, { open, end }) {
27
48
  return file.scan.strings.find((literal) => literal.start >= open && literal.start < end && file.scan.code.slice(open, literal.start).trim() === '');
28
49
  }
@@ -32,4 +53,25 @@ function optionLiteral(file, { open, end }) {
32
53
  literal.start < end &&
33
54
  CONSUMER_KEY.test(code.slice(Math.max(open, literal.start - 40), literal.start)));
34
55
  }
56
+ /**
57
+ * Whether the object spread under `name` shows `processed` in this file: a `const` initialised with an
58
+ * object literal that carries it, or a `const` or a parameter typed with `ConsumeOptions`.
59
+ */
60
+ function spreadCarriesStore(file, name) {
61
+ const { code } = file.scan;
62
+ const word = escapeRegExp(name);
63
+ const initialised = new RegExp(`\\b(?:const|let)\\s+${word}\\s*(?::[^=]*)?=\\s*\\{`).exec(code);
64
+ if (initialised !== null) {
65
+ const open = initialised.index + initialised[0].length - 1;
66
+ if (STORE_OPTION.test(code.slice(open, matchingBracket(code, open) + 1))) {
67
+ return true;
68
+ }
69
+ }
70
+ const typed = new RegExp(`(?<![\\w$.])${word}\\s*\\??:\\s*`, 'g');
71
+ return [...code.matchAll(typed)].some((declared) => {
72
+ const start = declared.index + declared[0].length;
73
+ const type = OPTIONS_TYPE.exec(file.text.slice(start, start + 120));
74
+ return type !== null && !/\bprocessed\b/.test(type[1] ?? '');
75
+ });
76
+ }
35
77
  //# sourceMappingURL=consumer-registrations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consumer-registrations.js","sourceRoot":"","sources":["../../../src/check/events/consumer-registrations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,IAAI,GAAG,wEAAwE,CAAC;AACtF,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,eAAe,GAAG,6BAA6B,CAAC;AACtD,MAAM,YAAY,GAAG,8BAA8B,CAAC;AAmBpD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;IAE3B,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EA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AAG,CAAC,CAAC,CAAC;QAEpE,OAAO,IAAI,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -33,7 +33,7 @@ constructor(private readonly publisher: IntegrationEventPublisher) {}
33
33
  eventPublisher: new OutboxPublisher(persistence.outbox),`,
34
34
  },
35
35
  'events/consumer-idempotent': {
36
- why: 'Delivery is at least once: a consumer sees the same event again after a retry, a restart or a replay. The processed-event store recognises a redelivery by the pair consumer name and event id, in the transaction of the handler. A consumer without a name, or sharing the name of another, either handles events twice or skips events it never handled. An integration event handler class that carries @IntegrationEventHandler(definition, { consumer }) is named by its declaration and needs no registration; the name is a string literal, and it is unique across declarations and registrations alike.',
36
+ why: "Delivery is at least once: a consumer sees the same event again after a retry, a restart or a replay. The processed-event store recognises a redelivery by the pair consumer name and event id, in the transaction of the handler. A consumer without a name, or sharing the name of another, either handles events twice or skips events it never handled. An integration event handler class that carries @IntegrationEventHandler(definition, { consumer }) is named by its declaration and needs no registration; the name is a string literal, and it is unique across declarations and registrations alike. Options that spread a shared object ({ ...options, consumer: 'ctx.name' }) are accepted when the file shows that object carrying `processed`: a `const` initialised with an object literal, or a value typed `ConsumeOptions`; a spread whose content is not in the file is refused.",
37
37
  bad: `// billing.module.ts
38
38
  subscriber.subscribe('catalog.product.listed', (event) => productListedHandler.handle(event));
39
39
  // application/integration/handlers/product-listed.integration-handler.ts
@@ -1 +1 @@
1
- {"version":3,"file":"events-docs.js","sourceRoot":"","sources":["../../../src/check/explain/events-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,oBAAoB,EAAE;QACpB,GAAG,EAAE,2LAA2L;QAChM,GAAG,EAAE,8CAA8C;QACnD,IAAI,EAAE,uDAAuD;KAC9D;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,8dAA8d;QACne,GAAG,EAAE;;EAEP;QACE,IAAI,EAAE;EACR;KACC;IACD,sCAAsC,EAAE;QACtC,GAAG,EAAE,2UAA2U;QAChV,GAAG,EAAE;uEAC8D;QACnE,IAAI,EAAE;;;IAGN;KACD;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,wVAAwV;QAC7V,GAAG,EAAE;;;qDAG4C;QACjD,IAAI,EAAE;;;yDAG+C;KACtD;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,mlBAAmlB;QACxlB,GAAG,EAAE;;;uEAG8D;QACnE,IAAI,EAAE;;;;;;;;EAQR;KACC;IACD,kCAAkC,EAAE;QAClC,GAAG,EAAE,svBAAsvB;QAC3vB,GAAG,EAAE;;;;sDAI6C;QAClD,IAAI,EAAE;;;;;qCAK2B;KAClC;IACD,2CAA2C,EAAE;QAC3C,GAAG,EAAE,uxDAAuxD;QAC5xD,GAAG,EAAE;;;;;;;;;;sFAU6E;QAClF,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;EAsBR;KACC;CACF,CAAC"}
1
+ {"version":3,"file":"events-docs.js","sourceRoot":"","sources":["../../../src/check/explain/events-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,oBAAoB,EAAE;QACpB,GAAG,EAAE,2LAA2L;QAChM,GAAG,EAAE,8CAA8C;QACnD,IAAI,EAAE,uDAAuD;KAC9D;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,8dAA8d;QACne,GAAG,EAAE;;EAEP;QACE,IAAI,EAAE;EACR;KACC;IACD,sCAAsC,EAAE;QACtC,GAAG,EAAE,2UAA2U;QAChV,GAAG,EAAE;uEAC8D;QACnE,IAAI,EAAE;;;IAGN;KACD;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,wVAAwV;QAC7V,GAAG,EAAE;;;qDAG4C;QACjD,IAAI,EAAE;;;yDAG+C;KACtD;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,w2BAAw2B;QAC72B,GAAG,EAAE;;;uEAG8D;QACnE,IAAI,EAAE;;;;;;;;EAQR;KACC;IACD,kCAAkC,EAAE;QAClC,GAAG,EAAE,svBAAsvB;QAC3vB,GAAG,EAAE;;;;sDAI6C;QAClD,IAAI,EAAE;;;;;qCAK2B;KAClC;IACD,2CAA2C,EAAE;QAC3C,GAAG,EAAE,uxDAAuxD;QAC5xD,GAAG,EAAE;;;;;;;;;;sFAU6E;QAClF,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;EAsBR;KACC;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tree-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/tree-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6HvD,CAAC"}
1
+ {"version":3,"file":"tree-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/tree-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgIvD,CAAC"}
@@ -1,10 +1,11 @@
1
1
  export const TREE_DOCS = {
2
2
  'tree/closed': {
3
- why: 'A fixed tree means every concept has one obvious place, so people and tools find it without reading the code. An ad hoc folder (utils, helpers, common, types, functions) is where unnamed concepts go to hide: a function that reads a value is a method of that value object, a decision over several objects a domain service, a shared shape of data a value object, an interchangeable rule an abstract class of domain/services with one service per variant (docs/ARCHITECTURE.md, a concept with no role of its own). A real new need is declared in extraDirectories with its reason. In the declared style the generated summary <context>.declarations.ts lives at the root of the context, next to CONTEXT.md, and the generated <layer>.declarations.ts of each layer in that layer; a module file may stay at the root when the wiring of a context is unusual. The tree is read as git sees it: what git ignores, and a dot-directory of a context such as the .claude/ a sandbox leaves behind, are not part of it.',
3
+ why: 'A fixed tree means every concept has one obvious place, so people and tools find it without reading the code. An ad hoc folder (utils, helpers, common, types, functions) is where unnamed concepts go to hide: a function that reads a value is a method of that value object, a decision over several objects a domain service, a shared shape of data a value object, an interchangeable rule an abstract class of domain/services with one service per variant (docs/ARCHITECTURE.md, a concept with no role of its own). A real new need is declared in extraDirectories with its reason. In the declared style the generated summary <context>.declarations.ts lives at the root of the context, next to CONTEXT.md, and the generated <layer>.declarations.ts of each layer in that layer; a module file may stay at the root when the wiring of a context is unusual. A context divided into modules of its model keeps one more place in the explicit style: <module>/<module>.module.ts, at the root of the folder of each module, registers what the module holds (its handlers, consumers, reactions, jobs and routes) and is composed by <context>.module.ts, which then stays small; nothing else sits at the root of a module. The tree is read as git sees it: what git ignores, and a dot-directory of a context such as the .claude/ a sandbox leaves behind, are not part of it.',
4
4
  bad: `contexts/billing/domain/utils/rounding.ts`,
5
5
  good: `contexts/billing/domain/value-objects/money.vo.ts
6
6
  contexts/billing/billing.declarations.ts // declared style only
7
- contexts/billing/application/application.declarations.ts // declared style only`,
7
+ contexts/billing/application/application.declarations.ts // declared style only
8
+ contexts/billing/invoices/invoices.module.ts // explicit style, a module of the model`,
8
9
  },
9
10
  'tree/context-doc': {
10
11
  why: 'CONTEXT.md is where the vocabulary and the boundaries are agreed with the domain experts. Without it, names drift and nobody can tell whether a concept belongs here. The classification says how much design effort the context deserves.',
@@ -81,8 +82,10 @@ coverage: { provider: 'v8', reporter: ['text', 'cobertura', 'lcov'], ...governed
81
82
  // ddd-ts-kit.config.json
82
83
  "coverage": { "infrastructure": { "branches": 50 } },
83
84
  "deviations": [{ "what": "coverage.infrastructure.branches", "adr": "0011", "reason": "The driver's failure branches are held by its contract suite." }]
84
- // domain/aggregates/invoice.aggregate.ts
85
- /* v8 ignore next 3 -- ADR-0012: reached only by the legacy import, removed with it */`,
85
+ // domain/aggregates/invoice.aggregate.ts, under Vitest, whose v8 provider reads v8 hints only
86
+ /* v8 ignore next 3 -- ADR-0012: reached only by the legacy import, removed with it */
87
+ // the same under Jest, whose babel provider reads istanbul hints only
88
+ /* istanbul ignore next -- ADR-0012: reached only by the legacy import, removed with it */`,
86
89
  },
87
90
  'test/mutation-governed': {
88
91
  why: 'A mutation score says how many of the changes made to the domain and the application its tests would notice, and it only says so while the measure is honest. One source holds it: the "mutation" key of ddd-ts-kit.config.json gives the floor of each layer every context must reach, the domain and the application (80 and 75 when the key is absent), and the Stryker config reads it through governedMutation of @ddd-ts-kit/testing/mutation, which also mutates the domain and application layers of every context, the texts of their refusals left out through the ignorer of the kit, since a refusal is asserted by its code and never by its text, every other string measured. Raising the floor is free; lowering it is a deviation with its decision record (governance/recorded-deviation). What this rule refuses is the quiet way around: a mutate, mutator, ignorers, ignoreStatic or thresholds written by hand in the Stryker config, or a config that does not read the kit at all. A survivor is a rule no test states: it is read as a decision, then tested or left alive and said so, never hidden by the configuration.',
@@ -1 +1 @@
1
- {"version":3,"file":"tree-docs.js","sourceRoot":"","sources":["../../../src/check/explain/tree-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsC;IAC1D,aAAa,EAAE;QACb,GAAG,EAAE,q+BAAq+B;QAC1+B,GAAG,EAAE,2CAA2C;QAChD,IAAI,EAAE;;yFAE+E;KACtF;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,4OAA4O;QACjP,GAAG,EAAE,6GAA6G;QAClH,IAAI,EAAE,6GAA6G;KACpH;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,g9BAAg9B;QACr9B,GAAG,EAAE,iHAAiH;QACtH,IAAI,EAAE,2HAA2H;KAClI;IACD,eAAe,EAAE;QACf,GAAG,EAAE,y3BAAy3B;QAC93B,GAAG,EAAE,8BAA8B;QACnC,IAAI,EAAE;;;;qEAI2D;KAClE;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,kyBAAkyB;QACvyB,GAAG,EAAE;;;;kCAIyB;QAC9B,IAAI,EAAE;;;;;oCAK0B;KACjC;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,svCAAsvC;QAC3vC,GAAG,EAAE;;;EAGP;QACE,IAAI,EAAE;;;EAGR;KACC;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,kYAAkY;QACvY,GAAG,EAAE;;;;;;;2CAOkC;QACvC,IAAI,EAAE;;;4BAGkB;KACzB;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,kaAAka;QACva,GAAG,EAAE,kFAAkF;QACvF,IAAI,EAAE,qCAAqC;KAC5C;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,y9BAAy9B;QAC99B,GAAG,EAAE;;;uBAGc;QACnB,IAAI,EAAE;;;;;;uFAM6E;KACpF;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,qlCAAqlC;QAC1lC,GAAG,EAAE;gHACuG;QAC5G,IAAI,EAAE;;;;;qHAK2G;KAClH;IACD,eAAe,EAAE;QACf,GAAG,EAAE,4SAA4S;QACjT,GAAG,EAAE;gDACuC;QAC5C,IAAI,EAAE;qDAC2C;KAClD;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,gUAAgU;QACrU,GAAG,EAAE,iFAAiF;QACtF,IAAI,EAAE;8BACoB;KAC3B;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,uvBAAuvB;QAC5vB,GAAG,EAAE;qFAC4E;QACjF,IAAI,EAAE;;;KAGL;KACF;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,yqBAAyqB;QAC9qB,GAAG,EAAE,yEAAyE;QAC9E,IAAI,EAAE;qFAC2E;KAClF;CACF,CAAC"}
1
+ {"version":3,"file":"tree-docs.js","sourceRoot":"","sources":["../../../src/check/explain/tree-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAsC;IAC1D,aAAa,EAAE;QACb,GAAG,EAAE,q0CAAq0C;QAC10C,GAAG,EAAE,2CAA2C;QACh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;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,uvBAAuvB;QAC5vB,GAAG,EAAE;qFAC4E;QACjF,IAAI,EAAE;;;KAGL;KACF;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,yqBAAyqB;QAC9qB,GAAG,EAAE,yEAAyE;QAC9E,IAAI,EAAE;qFAC2E;KAClF;CACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export const WIRING_DOCS = {
2
2
  'composition/only-in-module': {
3
- why: 'When adapters are created in one place, replacing one (a fake in a test, another provider in production) is a one-line change and tracing can wrap them all. A `new PgRepository()` buried in a handler, or a `bind(Port).toClass(PgRepository)` written outside the composition root, hides a dependency and defeats both. A class carrying @Repository, @Gateway or @Adapter is bound by its declaration, so nothing instantiates it at all. What turns declarations into bindings (contextModule, discoverContext, include on a module builder) is composition too and stays in main.ts, apps/<context>/main.ts, the platform and a module file.',
3
+ why: 'When adapters are created in one place, replacing one (a fake in a test, another provider in production) is a one-line change and tracing can wrap them all. A `new PgRepository()` buried in a handler, or a `bind(Port).toClass(PgRepository)` written outside the composition root, hides a dependency and defeats both. A class carrying @Repository, @Gateway or @Adapter is bound by its declaration, so nothing instantiates it at all. What turns declarations into bindings (contextModule, discoverContext, include on a module builder) is composition too and stays in main.ts, apps/<context>/main.ts, the platform and a module file: <context>.module.ts, or, in a context divided into modules of its model, the <module>/<module>.module.ts it composes.',
4
4
  bad: `// application/commands/issue-invoice/issue-invoice.handler.ts
5
5
  const repository = new PgInvoiceRepository();
6
6
  // infrastructure/external/extend-billing.ts
@@ -1 +1 @@
1
- {"version":3,"file":"wiring-docs.js","sourceRoot":"","sources":["../../../src/check/explain/wiring-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,4BAA4B,EAAE;QAC5B,GAAG,EAAE,qnBAAqnB;QAC1nB,GAAG,EAAE;;;sCAG6B;QAClC,IAAI,EAAE;;;;;;+CAMqC;KAC5C;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,irBAAirB;QACtrB,GAAG,EAAE;;;;;;wBAMe;QACpB,IAAI,EAAE;;;;;0CAKgC;KACvC;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,yqDAAyqD;QAC9qD,GAAG,EAAE;;;;;;;6FAOoF;QACzF,IAAI,EAAE;;;;;;;;;;;;;;+EAcqE;KAC5E;IACD,oCAAoC,EAAE;QACpC,GAAG,EAAE,omCAAomC;QACzmC,GAAG,EAAE;;;;;;;;;iEASwD;QAC7D,IAAI,EAAE;;;;;;;EAOR;KACC;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,o8BAAo8B;QACz8B,GAAG,EAAE;+DACsD;QAC3D,IAAI,EAAE;;;;;;;+DAOqD;KAC5D;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,+bAA+b;QACpc,GAAG,EAAE;yIACgI;QACrI,IAAI,EAAE;yIAC+H;KACtI;IACD,cAAc,EAAE;QACd,GAAG,EAAE,kXAAkX;QACvX,GAAG,EAAE;;uEAE8D;QACnE,IAAI,EAAE;;2IAEiI;KACxI;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,qMAAqM;QAC1M,GAAG,EAAE,qDAAqD;QAC1D,IAAI,EAAE,qGAAqG;KAC5G;CACF,CAAC"}
1
+ {"version":3,"file":"wiring-docs.js","sourceRoot":"","sources":["../../../src/check/explain/wiring-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,4BAA4B,EAAE;QAC5B,GAAG,EAAE,2uBAA2uB;QAChvB,GAAG,EAAE;;;sCAG6B;QAClC,IAAI,EAAE;;;;;;+CAMqC;KAC5C;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,irBAAirB;QACtrB,GAAG,EAAE;;;;;;wBAMe;QACpB,IAAI,EAAE;;;;;0CAKgC;KACvC;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,yqDAAyqD;QAC9qD,GAAG,EAAE;;;;;;;6FAOoF;QACzF,IAAI,EAAE;;;;;;;;;;;;;;+EAcqE;KAC5E;IACD,oCAAoC,EAAE;QACpC,GAAG,EAAE,omCAAomC;QACzmC,GAAG,EAAE;;;;;;;;;iEASwD;QAC7D,IAAI,EAAE;;;;;;;EAOR;KACC;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,o8BAAo8B;QACz8B,GAAG,EAAE;+DACsD;QAC3D,IAAI,EAAE;;;;;;;+DAOqD;KAC5D;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,+bAA+b;QACpc,GAAG,EAAE;yIACgI;QACrI,IAAI,EAAE;yIAC+H;KACtI;IACD,cAAc,EAAE;QACd,GAAG,EAAE,kXAAkX;QACvX,GAAG,EAAE;;uEAE8D;QACnE,IAAI,EAAE;;2IAEiI;KACxI;IACD,iCAAiC,EAAE;QACjC,GAAG,EAAE,qMAAqM;QAC1M,GAAG,EAAE,qDAAqD;QAC1D,IAAI,EAAE,qGAAqG;KAC5G;CACF,CAAC"}