ddd-ts-kit 0.109.0 → 0.110.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 (479) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.fr.md +31 -13
  3. package/README.md +26 -13
  4. package/dist/affected/reach-of.d.ts.map +1 -1
  5. package/dist/affected/reach-of.js +4 -1
  6. package/dist/affected/reach-of.js.map +1 -1
  7. package/dist/check/canonical/holds-shared-files.d.ts +3 -0
  8. package/dist/check/canonical/holds-shared-files.d.ts.map +1 -0
  9. package/dist/check/canonical/holds-shared-files.js +7 -0
  10. package/dist/check/canonical/holds-shared-files.js.map +1 -0
  11. package/dist/check/canonical/is-shared-directory.d.ts +7 -0
  12. package/dist/check/canonical/is-shared-directory.d.ts.map +1 -0
  13. package/dist/check/canonical/is-shared-directory.js +13 -0
  14. package/dist/check/canonical/is-shared-directory.js.map +1 -0
  15. package/dist/check/canonical/role.d.ts +2 -0
  16. package/dist/check/canonical/role.d.ts.map +1 -1
  17. package/dist/check/canonical/roles.d.ts.map +1 -1
  18. package/dist/check/canonical/roles.js +10 -5
  19. package/dist/check/canonical/roles.js.map +1 -1
  20. package/dist/check/canonical/shared-directories.d.ts +3 -0
  21. package/dist/check/canonical/shared-directories.d.ts.map +1 -0
  22. package/dist/check/canonical/shared-directories.js +8 -0
  23. package/dist/check/canonical/shared-directories.js.map +1 -0
  24. package/dist/check/canonical/stray-entry.d.ts.map +1 -1
  25. package/dist/check/canonical/stray-entry.js +43 -4
  26. package/dist/check/canonical/stray-entry.js.map +1 -1
  27. package/dist/check/configuration/module-problems.js +20 -16
  28. package/dist/check/configuration/module-problems.js.map +1 -1
  29. package/dist/check/errors/code-reference.d.ts +7 -0
  30. package/dist/check/errors/code-reference.d.ts.map +1 -0
  31. package/dist/check/errors/code-reference.js +2 -0
  32. package/dist/check/errors/code-reference.js.map +1 -0
  33. package/dist/check/errors/code-references.d.ts +7 -0
  34. package/dist/check/errors/code-references.d.ts.map +1 -0
  35. package/dist/check/errors/code-references.js +13 -0
  36. package/dist/check/errors/code-references.js.map +1 -0
  37. package/dist/check/errors/kit-code-keys.d.ts +3 -0
  38. package/dist/check/errors/kit-code-keys.d.ts.map +1 -0
  39. package/dist/check/errors/kit-code-keys.js +5 -0
  40. package/dist/check/errors/kit-code-keys.js.map +1 -0
  41. package/dist/check/errors/kit-codes-list.d.ts +3 -0
  42. package/dist/check/errors/kit-codes-list.d.ts.map +1 -0
  43. package/dist/check/errors/kit-codes-list.js +3 -0
  44. package/dist/check/errors/kit-codes-list.js.map +1 -0
  45. package/dist/check/explain/errors-docs.d.ts.map +1 -1
  46. package/dist/check/explain/errors-docs.js +5 -2
  47. package/dist/check/explain/errors-docs.js.map +1 -1
  48. package/dist/check/explain/module-docs.d.ts.map +1 -1
  49. package/dist/check/explain/module-docs.js +9 -6
  50. package/dist/check/explain/module-docs.js.map +1 -1
  51. package/dist/check/explain/tree-docs.d.ts.map +1 -1
  52. package/dist/check/explain/tree-docs.js +3 -1
  53. package/dist/check/explain/tree-docs.js.map +1 -1
  54. package/dist/check/fixtures/errors-route.d.ts +1 -1
  55. package/dist/check/fixtures/errors-route.d.ts.map +1 -1
  56. package/dist/check/fixtures/errors-route.js +2 -2
  57. package/dist/check/fixtures/errors-route.js.map +1 -1
  58. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  59. package/dist/check/fixtures/fixtures.js +2 -0
  60. package/dist/check/fixtures/fixtures.js.map +1 -1
  61. package/dist/check/fixtures/module-fixtures.d.ts.map +1 -1
  62. package/dist/check/fixtures/module-fixtures.js +27 -31
  63. package/dist/check/fixtures/module-fixtures.js.map +1 -1
  64. package/dist/check/fixtures/named-refusal-fixtures.d.ts.map +1 -1
  65. package/dist/check/fixtures/named-refusal-fixtures.js +40 -0
  66. package/dist/check/fixtures/named-refusal-fixtures.js.map +1 -1
  67. package/dist/check/fixtures/shared-folder-fixtures.d.ts +7 -0
  68. package/dist/check/fixtures/shared-folder-fixtures.d.ts.map +1 -0
  69. package/dist/check/fixtures/shared-folder-fixtures.js +176 -0
  70. package/dist/check/fixtures/shared-folder-fixtures.js.map +1 -0
  71. package/dist/check/fixtures/shared-kernel-fixtures.d.ts.map +1 -1
  72. package/dist/check/fixtures/shared-kernel-fixtures.js +11 -0
  73. package/dist/check/fixtures/shared-kernel-fixtures.js.map +1 -1
  74. package/dist/check/fixtures/with-modules.d.ts +4 -0
  75. package/dist/check/fixtures/with-modules.d.ts.map +1 -0
  76. package/dist/check/fixtures/with-modules.js +22 -0
  77. package/dist/check/fixtures/with-modules.js.map +1 -0
  78. package/dist/check/model/context-location.d.ts +5 -0
  79. package/dist/check/model/context-location.d.ts.map +1 -1
  80. package/dist/check/project/locate.js +12 -5
  81. package/dist/check/project/locate.js.map +1 -1
  82. package/dist/check/rules/errors-known-code.d.ts.map +1 -1
  83. package/dist/check/rules/errors-known-code.js +60 -9
  84. package/dist/check/rules/errors-known-code.js.map +1 -1
  85. package/dist/check/rules/module-complete.d.ts.map +1 -1
  86. package/dist/check/rules/module-complete.js +19 -20
  87. package/dist/check/rules/module-complete.js.map +1 -1
  88. package/dist/check/rules/module-declared.js +5 -1
  89. package/dist/check/rules/module-declared.js.map +1 -1
  90. package/dist/check/rules/test-acceptance-black-box.d.ts.map +1 -1
  91. package/dist/check/rules/test-acceptance-black-box.js +6 -7
  92. package/dist/check/rules/test-acceptance-black-box.js.map +1 -1
  93. package/dist/check/rules/test-builder-required.d.ts.map +1 -1
  94. package/dist/check/rules/test-builder-required.js +15 -12
  95. package/dist/check/rules/test-builder-required.js.map +1 -1
  96. package/dist/check/rules/test-spec-required.d.ts.map +1 -1
  97. package/dist/check/rules/test-spec-required.js +12 -11
  98. package/dist/check/rules/test-spec-required.js.map +1 -1
  99. package/dist/check/rules/tree-closed.js +1 -1
  100. package/dist/check/rules/tree-closed.js.map +1 -1
  101. package/dist/check/support/path-in-context.d.ts +1 -1
  102. package/dist/check/support/path-in-context.d.ts.map +1 -1
  103. package/dist/check/support/path-in-context.js +6 -3
  104. package/dist/check/support/path-in-context.js.map +1 -1
  105. package/dist/check/support/test-folder-of.d.ts +11 -0
  106. package/dist/check/support/test-folder-of.d.ts.map +1 -0
  107. package/dist/check/support/test-folder-of.js +12 -0
  108. package/dist/check/support/test-folder-of.js.map +1 -0
  109. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  110. package/dist/commands/drizzle-generate.js +9 -0
  111. package/dist/commands/drizzle-generate.js.map +1 -1
  112. package/dist/commands/generate.js +9 -1
  113. package/dist/commands/generate.js.map +1 -1
  114. package/dist/commands/lint.d.ts +2 -1
  115. package/dist/commands/lint.d.ts.map +1 -1
  116. package/dist/commands/lint.js +4 -1
  117. package/dist/commands/lint.js.map +1 -1
  118. package/dist/commands/move-to-module.d.ts.map +1 -1
  119. package/dist/commands/move-to-module.js +0 -2
  120. package/dist/commands/move-to-module.js.map +1 -1
  121. package/dist/context-layout/context-layout.d.ts +3 -2
  122. package/dist/context-layout/context-layout.d.ts.map +1 -1
  123. package/dist/context-layout/context-layout.js +18 -8
  124. package/dist/context-layout/context-layout.js.map +1 -1
  125. package/dist/context-layout/imports-of.d.ts +11 -0
  126. package/dist/context-layout/imports-of.d.ts.map +1 -0
  127. package/dist/context-layout/imports-of.js +20 -0
  128. package/dist/context-layout/imports-of.js.map +1 -0
  129. package/dist/context-layout/module-moves.d.ts +10 -7
  130. package/dist/context-layout/module-moves.d.ts.map +1 -1
  131. package/dist/context-layout/module-moves.js +65 -122
  132. package/dist/context-layout/module-moves.js.map +1 -1
  133. package/dist/context-layout/runner-configs-by-hand.d.ts +11 -0
  134. package/dist/context-layout/runner-configs-by-hand.d.ts.map +1 -0
  135. package/dist/context-layout/runner-configs-by-hand.js +23 -0
  136. package/dist/context-layout/runner-configs-by-hand.js.map +1 -0
  137. package/dist/context-layout/settle.d.ts +20 -0
  138. package/dist/context-layout/settle.d.ts.map +1 -0
  139. package/dist/context-layout/settle.js +58 -0
  140. package/dist/context-layout/settle.js.map +1 -0
  141. package/dist/controllers/declared-code.d.ts +3 -0
  142. package/dist/controllers/declared-code.d.ts.map +1 -0
  143. package/dist/controllers/declared-code.js +8 -0
  144. package/dist/controllers/declared-code.js.map +1 -0
  145. package/dist/controllers/finish-migration.d.ts.map +1 -1
  146. package/dist/controllers/finish-migration.js +5 -3
  147. package/dist/controllers/finish-migration.js.map +1 -1
  148. package/dist/controllers/migrate-context.js +3 -2
  149. package/dist/controllers/migrate-context.js.map +1 -1
  150. package/dist/controllers/plan-context.d.ts +1 -1
  151. package/dist/controllers/plan-context.d.ts.map +1 -1
  152. package/dist/controllers/plan-context.js +11 -6
  153. package/dist/controllers/plan-context.js.map +1 -1
  154. package/dist/controllers/render-controller.d.ts.map +1 -1
  155. package/dist/controllers/render-controller.js +20 -4
  156. package/dist/controllers/render-controller.js.map +1 -1
  157. package/dist/depcruise/hygiene-rules.js +2 -2
  158. package/dist/depcruise/hygiene-rules.js.map +1 -1
  159. package/dist/depcruise/test-files.d.ts +4 -1
  160. package/dist/depcruise/test-files.d.ts.map +1 -1
  161. package/dist/depcruise/test-files.js +5 -2
  162. package/dist/depcruise/test-files.js.map +1 -1
  163. package/dist/describe/codes-named-in.d.ts +8 -0
  164. package/dist/describe/codes-named-in.d.ts.map +1 -0
  165. package/dist/describe/codes-named-in.js +33 -0
  166. package/dist/describe/codes-named-in.js.map +1 -0
  167. package/dist/describe/read-controllers.js +2 -2
  168. package/dist/describe/read-controllers.js.map +1 -1
  169. package/dist/describe/read-route-groups.d.ts +6 -2
  170. package/dist/describe/read-route-groups.d.ts.map +1 -1
  171. package/dist/describe/read-route-groups.js +8 -4
  172. package/dist/describe/read-route-groups.js.map +1 -1
  173. package/dist/describe/read-routes.d.ts.map +1 -1
  174. package/dist/describe/read-routes.js +7 -2
  175. package/dist/describe/read-routes.js.map +1 -1
  176. package/dist/docs/spec-heading.d.ts +5 -4
  177. package/dist/docs/spec-heading.d.ts.map +1 -1
  178. package/dist/docs/spec-heading.js +4 -6
  179. package/dist/docs/spec-heading.js.map +1 -1
  180. package/dist/docs/spec-of-page.d.ts +7 -2
  181. package/dist/docs/spec-of-page.d.ts.map +1 -1
  182. package/dist/docs/spec-of-page.js +8 -3
  183. package/dist/docs/spec-of-page.js.map +1 -1
  184. package/dist/docs/specs-by-directory.d.ts +2 -2
  185. package/dist/docs/specs-by-directory.d.ts.map +1 -1
  186. package/dist/docs/specs-by-directory.js +4 -5
  187. package/dist/docs/specs-by-directory.js.map +1 -1
  188. package/dist/docs/write-behaviour.d.ts +1 -1
  189. package/dist/docs/write-behaviour.d.ts.map +1 -1
  190. package/dist/docs/write-behaviour.js +17 -2
  191. package/dist/docs/write-behaviour.js.map +1 -1
  192. package/dist/file-moves/follow-in-migrations.d.ts +10 -0
  193. package/dist/file-moves/follow-in-migrations.d.ts.map +1 -0
  194. package/dist/file-moves/follow-in-migrations.js +30 -0
  195. package/dist/file-moves/follow-in-migrations.js.map +1 -0
  196. package/dist/file-moves/move-files.d.ts +2 -1
  197. package/dist/file-moves/move-files.d.ts.map +1 -1
  198. package/dist/file-moves/move-files.js +4 -2
  199. package/dist/file-moves/move-files.js.map +1 -1
  200. package/dist/generate/errors/write-named-refusal.d.ts.map +1 -1
  201. package/dist/generate/errors/write-named-refusal.js +6 -2
  202. package/dist/generate/errors/write-named-refusal.js.map +1 -1
  203. package/dist/generate/kinds/builder-kind.js +1 -1
  204. package/dist/generate/kinds/builder-kind.js.map +1 -1
  205. package/dist/generate/kinds/declarations-of.js +1 -1
  206. package/dist/generate/kinds/declarations-of.js.map +1 -1
  207. package/dist/generate/kinds/declare-storage.d.ts +2 -1
  208. package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
  209. package/dist/generate/kinds/declare-storage.js +19 -5
  210. package/dist/generate/kinds/declare-storage.js.map +1 -1
  211. package/dist/generate/kinds/e2e/acting-role.d.ts +15 -0
  212. package/dist/generate/kinds/e2e/acting-role.d.ts.map +1 -0
  213. package/dist/generate/kinds/e2e/acting-role.js +19 -0
  214. package/dist/generate/kinds/e2e/acting-role.js.map +1 -0
  215. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  216. package/dist/generate/kinds/e2e-kind.js +5 -1
  217. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  218. package/dist/generate/kinds/gateway-kind.d.ts.map +1 -1
  219. package/dist/generate/kinds/gateway-kind.js +14 -2
  220. package/dist/generate/kinds/gateway-kind.js.map +1 -1
  221. package/dist/generate/kinds/generate-repository.js +1 -1
  222. package/dist/generate/kinds/generate-repository.js.map +1 -1
  223. package/dist/generate/kinds/module-kind.d.ts.map +1 -1
  224. package/dist/generate/kinds/module-kind.js +9 -1
  225. package/dist/generate/kinds/module-kind.js.map +1 -1
  226. package/dist/generate/kinds/route/group-vars.d.ts.map +1 -1
  227. package/dist/generate/kinds/route/group-vars.js +5 -3
  228. package/dist/generate/kinds/route/group-vars.js.map +1 -1
  229. package/dist/generate/kinds/route/route-vars.js +1 -1
  230. package/dist/generate/kinds/route/route-vars.js.map +1 -1
  231. package/dist/generate/kinds/world/context-fakes.d.ts +1 -1
  232. package/dist/generate/kinds/world/context-fakes.d.ts.map +1 -1
  233. package/dist/generate/kinds/world/context-fakes.js +8 -7
  234. package/dist/generate/kinds/world/context-fakes.js.map +1 -1
  235. package/dist/generate/kinds/world/context-world.d.ts +1 -1
  236. package/dist/generate/kinds/world/context-world.d.ts.map +1 -1
  237. package/dist/generate/kinds/world/context-world.js +3 -1
  238. package/dist/generate/kinds/world/context-world.js.map +1 -1
  239. package/dist/generate/place-generated-files.d.ts +2 -0
  240. package/dist/generate/place-generated-files.d.ts.map +1 -1
  241. package/dist/generate/place-generated-files.js +13 -13
  242. package/dist/generate/place-generated-files.js.map +1 -1
  243. package/dist/generate/refresh-docs.d.ts +1 -1
  244. package/dist/generate/refresh-docs.d.ts.map +1 -1
  245. package/dist/generate/refresh-docs.js +3 -1
  246. package/dist/generate/refresh-docs.js.map +1 -1
  247. package/dist/generate/refuse-earlier-layout.d.ts +4 -3
  248. package/dist/generate/refuse-earlier-layout.d.ts.map +1 -1
  249. package/dist/generate/refuse-earlier-layout.js +9 -6
  250. package/dist/generate/refuse-earlier-layout.js.map +1 -1
  251. package/dist/help/flag-notes.d.ts.map +1 -1
  252. package/dist/help/flag-notes.js +8 -7
  253. package/dist/help/flag-notes.js.map +1 -1
  254. package/dist/help/tool-notes.d.ts.map +1 -1
  255. package/dist/help/tool-notes.js +23 -17
  256. package/dist/help/tool-notes.js.map +1 -1
  257. package/dist/help/usage.js +1 -1
  258. package/dist/help/work-notes.d.ts.map +1 -1
  259. package/dist/help/work-notes.js +4 -3
  260. package/dist/help/work-notes.js.map +1 -1
  261. package/dist/init/manifest/versions.js +25 -25
  262. package/dist/init/rewire-personal-data.d.ts.map +1 -1
  263. package/dist/init/rewire-personal-data.js +4 -2
  264. package/dist/init/rewire-personal-data.js.map +1 -1
  265. package/dist/init/rewire-tables.d.ts.map +1 -1
  266. package/dist/init/rewire-tables.js +4 -2
  267. package/dist/init/rewire-tables.js.map +1 -1
  268. package/dist/init/with-held-imports.d.ts +9 -0
  269. package/dist/init/with-held-imports.d.ts.map +1 -0
  270. package/dist/init/with-held-imports.js +15 -0
  271. package/dist/init/with-held-imports.js.map +1 -0
  272. package/dist/knip/enter-module-test-folders.d.ts +10 -0
  273. package/dist/knip/enter-module-test-folders.d.ts.map +1 -0
  274. package/dist/knip/enter-module-test-folders.js +42 -0
  275. package/dist/knip/enter-module-test-folders.js.map +1 -0
  276. package/dist/knip/index.d.ts +1 -0
  277. package/dist/knip/index.d.ts.map +1 -1
  278. package/dist/knip/index.js +1 -0
  279. package/dist/knip/index.js.map +1 -1
  280. package/dist/lint/eslint-in-project.d.ts +1 -1
  281. package/dist/lint/eslint-in-project.d.ts.map +1 -1
  282. package/dist/lint/eslint-in-project.js +3 -2
  283. package/dist/lint/eslint-in-project.js.map +1 -1
  284. package/dist/lint/lint-run.d.ts +2 -0
  285. package/dist/lint/lint-run.d.ts.map +1 -1
  286. package/dist/merge/landed-commit.js +14 -2
  287. package/dist/merge/landed-commit.js.map +1 -1
  288. package/dist/merge/landed-point.js +3 -0
  289. package/dist/merge/landed-point.js.map +1 -1
  290. package/dist/merge/lost/dropped-additions.d.ts +20 -0
  291. package/dist/merge/lost/dropped-additions.d.ts.map +1 -0
  292. package/dist/merge/lost/dropped-additions.js +42 -0
  293. package/dist/merge/lost/dropped-additions.js.map +1 -0
  294. package/dist/merge/lost/expected-over.d.ts +13 -0
  295. package/dist/merge/lost/expected-over.d.ts.map +1 -0
  296. package/dist/merge/lost/expected-over.js +16 -0
  297. package/dist/merge/lost/expected-over.js.map +1 -0
  298. package/dist/merge/lost/kept-rows.d.ts +4 -2
  299. package/dist/merge/lost/kept-rows.d.ts.map +1 -1
  300. package/dist/merge/lost/kept-rows.js +10 -7
  301. package/dist/merge/lost/kept-rows.js.map +1 -1
  302. package/dist/merge/lost/lost-lines.d.ts +2 -2
  303. package/dist/merge/lost/lost-lines.d.ts.map +1 -1
  304. package/dist/merge/lost/lost-lines.js +5 -3
  305. package/dist/merge/lost/lost-lines.js.map +1 -1
  306. package/dist/merge/lost/lost-tests.d.ts +2 -2
  307. package/dist/merge/lost/lost-tests.d.ts.map +1 -1
  308. package/dist/merge/lost/lost-tests.js +5 -3
  309. package/dist/merge/lost/lost-tests.js.map +1 -1
  310. package/dist/merge/lost/verify-merge.d.ts.map +1 -1
  311. package/dist/merge/lost/verify-merge.js +12 -5
  312. package/dist/merge/lost/verify-merge.js.map +1 -1
  313. package/dist/merge/merge-trunk.d.ts.map +1 -1
  314. package/dist/merge/merge-trunk.js +35 -7
  315. package/dist/merge/merge-trunk.js.map +1 -1
  316. package/dist/merge/slices-from-fork.d.ts +20 -0
  317. package/dist/merge/slices-from-fork.d.ts.map +1 -0
  318. package/dist/merge/slices-from-fork.js +27 -0
  319. package/dist/merge/slices-from-fork.js.map +1 -0
  320. package/dist/merge/trunk-of.d.ts +4 -2
  321. package/dist/merge/trunk-of.d.ts.map +1 -1
  322. package/dist/merge/trunk-of.js +4 -2
  323. package/dist/merge/trunk-of.js.map +1 -1
  324. package/dist/migration/warn-dropped-context-tables.d.ts.map +1 -1
  325. package/dist/migration/warn-dropped-context-tables.js +6 -4
  326. package/dist/migration/warn-dropped-context-tables.js.map +1 -1
  327. package/dist/model-modules/context-level-folder-of.d.ts +9 -0
  328. package/dist/model-modules/context-level-folder-of.d.ts.map +1 -0
  329. package/dist/model-modules/context-level-folder-of.js +11 -0
  330. package/dist/model-modules/context-level-folder-of.js.map +1 -0
  331. package/dist/model-modules/earlier-folders.d.ts +10 -0
  332. package/dist/model-modules/earlier-folders.d.ts.map +1 -0
  333. package/dist/model-modules/earlier-folders.js +20 -0
  334. package/dist/model-modules/earlier-folders.js.map +1 -0
  335. package/dist/model-modules/folders-of-context.d.ts +8 -0
  336. package/dist/model-modules/folders-of-context.d.ts.map +1 -0
  337. package/dist/model-modules/folders-of-context.js +11 -0
  338. package/dist/model-modules/folders-of-context.js.map +1 -0
  339. package/dist/model-modules/held-file-of.d.ts +10 -0
  340. package/dist/model-modules/held-file-of.d.ts.map +1 -0
  341. package/dist/model-modules/held-file-of.js +18 -0
  342. package/dist/model-modules/held-file-of.js.map +1 -0
  343. package/dist/model-modules/index.d.ts +8 -1
  344. package/dist/model-modules/index.d.ts.map +1 -1
  345. package/dist/model-modules/index.js +8 -1
  346. package/dist/model-modules/index.js.map +1 -1
  347. package/dist/model-modules/into-module.d.ts +3 -3
  348. package/dist/model-modules/into-module.d.ts.map +1 -1
  349. package/dist/model-modules/into-module.js +9 -12
  350. package/dist/model-modules/into-module.js.map +1 -1
  351. package/dist/model-modules/is-context-level.d.ts +4 -5
  352. package/dist/model-modules/is-context-level.d.ts.map +1 -1
  353. package/dist/model-modules/is-context-level.js +6 -16
  354. package/dist/model-modules/is-context-level.js.map +1 -1
  355. package/dist/model-modules/is-held-by-shared.d.ts +8 -0
  356. package/dist/model-modules/is-held-by-shared.d.ts.map +1 -0
  357. package/dist/model-modules/is-held-by-shared.js +20 -0
  358. package/dist/model-modules/is-held-by-shared.js.map +1 -0
  359. package/dist/model-modules/module-layers.d.ts +9 -2
  360. package/dist/model-modules/module-layers.d.ts.map +1 -1
  361. package/dist/model-modules/module-layers.js +10 -3
  362. package/dist/model-modules/module-layers.js.map +1 -1
  363. package/dist/model-modules/module-name-flaw.d.ts +4 -1
  364. package/dist/model-modules/module-name-flaw.d.ts.map +1 -1
  365. package/dist/model-modules/module-name-flaw.js +6 -2
  366. package/dist/model-modules/module-name-flaw.js.map +1 -1
  367. package/dist/model-modules/module-placement.d.ts +8 -6
  368. package/dist/model-modules/module-placement.d.ts.map +1 -1
  369. package/dist/model-modules/module-placement.js +32 -30
  370. package/dist/model-modules/module-placement.js.map +1 -1
  371. package/dist/model-modules/module-split.d.ts +7 -5
  372. package/dist/model-modules/module-split.d.ts.map +1 -1
  373. package/dist/model-modules/module-split.js +18 -17
  374. package/dist/model-modules/module-split.js.map +1 -1
  375. package/dist/model-modules/module-test-folder-of.d.ts +8 -0
  376. package/dist/model-modules/module-test-folder-of.d.ts.map +1 -0
  377. package/dist/model-modules/module-test-folder-of.js +11 -0
  378. package/dist/model-modules/module-test-folder-of.js.map +1 -0
  379. package/dist/model-modules/role-folders-of.d.ts +5 -3
  380. package/dist/model-modules/role-folders-of.d.ts.map +1 -1
  381. package/dist/model-modules/role-folders-of.js +19 -11
  382. package/dist/model-modules/role-folders-of.js.map +1 -1
  383. package/dist/model-modules/role-folders.d.ts +1 -1
  384. package/dist/model-modules/role-folders.js +1 -1
  385. package/dist/model-modules/subject-module.d.ts +13 -0
  386. package/dist/model-modules/subject-module.d.ts.map +1 -0
  387. package/dist/model-modules/subject-module.js +34 -0
  388. package/dist/model-modules/subject-module.js.map +1 -0
  389. package/dist/move-to-module/moves-into-module.d.ts.map +1 -1
  390. package/dist/move-to-module/moves-into-module.js +29 -16
  391. package/dist/move-to-module/moves-into-module.js.map +1 -1
  392. package/dist/naming/plural.d.ts.map +1 -1
  393. package/dist/naming/plural.js +5 -0
  394. package/dist/naming/plural.js.map +1 -1
  395. package/dist/plan/format-plan.js +1 -1
  396. package/dist/plan/format-plan.js.map +1 -1
  397. package/dist/progress/build-next-of.d.ts.map +1 -1
  398. package/dist/progress/build-next-of.js +8 -3
  399. package/dist/progress/build-next-of.js.map +1 -1
  400. package/dist/refusals/apply-plan.d.ts.map +1 -1
  401. package/dist/refusals/apply-plan.js +8 -4
  402. package/dist/refusals/apply-plan.js.map +1 -1
  403. package/dist/refusals/move-named-specs.d.ts.map +1 -1
  404. package/dist/refusals/move-named-specs.js +7 -4
  405. package/dist/refusals/move-named-specs.js.map +1 -1
  406. package/dist/refusals/unit-folder-of.d.ts +9 -0
  407. package/dist/refusals/unit-folder-of.d.ts.map +1 -0
  408. package/dist/refusals/unit-folder-of.js +15 -0
  409. package/dist/refusals/unit-folder-of.js.map +1 -0
  410. package/dist/slice/plan-staging.d.ts +2 -1
  411. package/dist/slice/plan-staging.d.ts.map +1 -1
  412. package/dist/slice/plan-staging.js +3 -1
  413. package/dist/slice/plan-staging.js.map +1 -1
  414. package/dist/stack/declares-roles.d.ts +8 -0
  415. package/dist/stack/declares-roles.d.ts.map +1 -0
  416. package/dist/stack/declares-roles.js +11 -0
  417. package/dist/stack/declares-roles.js.map +1 -0
  418. package/dist/stack/stack-vars.d.ts.map +1 -1
  419. package/dist/stack/stack-vars.js +2 -1
  420. package/dist/stack/stack-vars.js.map +1 -1
  421. package/dist/version.d.ts +1 -1
  422. package/dist/version.js +1 -1
  423. package/dist/worker/progress-of.js +12 -1
  424. package/dist/worker/progress-of.js.map +1 -1
  425. package/dist/worker/row-commits.js +7 -1
  426. package/dist/worker/row-commits.js.map +1 -1
  427. package/package.json +6 -6
  428. package/templates/command/handler.spec.buses.ts.tpl +4 -1
  429. package/templates/command/handler.spec.container.ts.tpl +6 -1
  430. package/templates/controller/controller.spec.ts.tpl +4 -1
  431. package/templates/controller/guard.spec.ts.tpl +2 -2
  432. package/templates/controller/guard.ts.tpl +2 -1
  433. package/templates/e2e/e2e.spec.ts.tpl +5 -2
  434. package/templates/error/codes-import.ts.tpl +1 -0
  435. package/templates/error/refusal-case.spec.ts.tpl +1 -1
  436. package/templates/error/refusal.spec.ts.tpl +1 -0
  437. package/templates/file-upload/handler.spec.ts.tpl +4 -1
  438. package/templates/init/e2e/create-credentials.jwt.ts.tpl +13 -0
  439. package/templates/init/e2e/create-credentials.keycloak.ts.tpl +13 -0
  440. package/templates/init/e2e/create-credentials.none.ts.tpl +13 -0
  441. package/templates/init/e2e/create-credentials.passport.ts.tpl +13 -0
  442. package/templates/init/platform/audit/search-audit-entries/search-audit-entries.controller.ts.tpl +2 -2
  443. package/templates/init/platform/audit/search-audit-entries/search-audit-entries.route.ts.tpl +2 -2
  444. package/templates/init/platform/composition/create-platform.manual.ts.tpl +14 -4
  445. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +8 -2
  446. package/templates/init/rules/presentation.md.tpl +2 -2
  447. package/templates/init/rules/tests.md.tpl +1 -0
  448. package/templates/nest-controller/controller.spec.ts.tpl +4 -1
  449. package/templates/pipeline/biome.json.tpl +1 -1
  450. package/templates/pipeline/jest.mutation.config.js.tpl +1 -1
  451. package/templates/pipeline/knip.json.tpl +2 -0
  452. package/templates/pipeline/package-scripts.json +2 -2
  453. package/templates/pipeline/vitest.config.ts.tpl +11 -6
  454. package/templates/pipeline/vitest.mutation.config.ts.tpl +1 -1
  455. package/templates/presets/identity/context/presentation/http/accounts.routes.ts.tpl +2 -1
  456. package/templates/presets/identity/context/presentation/http/invitations.routes.ts.tpl +2 -1
  457. package/templates/presets/identity/context/presentation/http/organisations.routes.ts.tpl +2 -1
  458. package/templates/presets/identity/context/test/unit/change-member-role.handler.spec.ts.tpl +2 -1
  459. package/templates/presets/identity/context/test/unit/deactivate-account.handler.spec.ts.tpl +4 -4
  460. package/templates/presets/identity/context/test/unit/grant-delegation.handler.spec.ts.tpl +2 -1
  461. package/templates/presets/identity/context/test/unit/invite-member.handler.spec.ts.tpl +3 -3
  462. package/templates/presets/identity/context/test/unit/provision-account.handler.spec.ts.tpl +2 -1
  463. package/templates/presets/identity/context/test/unit/remove-member.handler.spec.ts.tpl +2 -1
  464. package/templates/presets/identity/context/test/unit/revoke-delegation.handler.spec.ts.tpl +2 -1
  465. package/templates/presets/identity/context/test/unit/revoke-invitation.handler.spec.ts.tpl +2 -1
  466. package/templates/presets/identity/context/test/unit/search-members.handler.spec.ts.tpl +2 -2
  467. package/templates/query/handler.spec.buses.ts.tpl +4 -1
  468. package/templates/query/handler.spec.container.ts.tpl +6 -1
  469. package/templates/query/search.handler.spec.buses.ts.tpl +2 -2
  470. package/templates/query/search.handler.spec.container.ts.tpl +2 -2
  471. package/templates/query/search.reader.spec.ts.tpl +2 -2
  472. package/templates/route/route.class-validator.ts.tpl +5 -0
  473. package/templates/route/route.none.ts.tpl +6 -1
  474. package/templates/route/route.search.ts.tpl +3 -3
  475. package/templates/route/route.spec.ts.tpl +4 -1
  476. package/templates/route/route.standard-schema.ts.tpl +5 -0
  477. package/templates/route/route.typebox.ts.tpl +5 -0
  478. package/templates/route/route.zod.ts.tpl +5 -0
  479. package/templates/value-object/value-object.spec.ts.tpl +6 -3
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
2
  import { anActor } from '@ddd-ts-kit/auth/testing';
3
3
  import type { GuardRequest } from '@ddd-ts-kit/http';
4
- import { type Actor, executionContext } from '@ddd-ts-kit/kernel';
4
+ import { type Actor, executionContext, KitCodes } from '@ddd-ts-kit/kernel';
5
5
  import { {{name.pascal}}Guard } from '{{alias.context}}/presentation/http/guards/{{name.kebab}}.guard{{alias.ext}}';
6
6
 
7
7
  describe('Who may pass the {{name.words}} guard', () => {
@@ -9,7 +9,7 @@ describe('Who may pass the {{name.words}} guard', () => {
9
9
  it('refuses a caller with 403', () => {
10
10
  const request = requestOf(anActor().build());
11
11
 
12
- expect(() => new {{name.pascal}}Guard().check(request)).toThrow(expect.objectContaining({ code: 'FORBIDDEN' }));
12
+ expect(() => new {{name.pascal}}Guard().check(request)).toThrow(expect.objectContaining({ code: KitCodes.Forbidden }));
13
13
  });
14
14
 
15
15
  it.todo('lets through the caller it is written for');
@@ -1,9 +1,10 @@
1
1
  import { ForbiddenError, Guard, type GuardRequest } from '@ddd-ts-kit/http';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
 
3
4
  // TODO(domain): say in one sentence what this guard controls at the edge. It reads the caller and the request, never an aggregate: a right that depends on the element is a permission of the use case (`@Requires`).
4
5
  @Guard()
5
6
  export class {{name.pascal}}Guard implements Guard {
6
- readonly documents = { errors: ['FORBIDDEN'] };
7
+ readonly documents = { errors: [KitCodes.Forbidden] };
7
8
 
8
9
  // TODO(domain): a guard refuses everybody until it is written. Replace this refusal by the control, read from `actor` and `params` of the request: a role of the caller, a membership read from the path, a key of the request.
9
10
  check(_request: GuardRequest): void {
@@ -11,6 +11,9 @@ import { reportSeedOnFailure } from '@ddd-ts-kit/testing/faker';
11
11
  {{#if e2e.traced}}
12
12
  import { expectSpanTree, installTestTracing } from '@ddd-ts-kit/tracing/testing';
13
13
  {{/if}}
14
+ {{#if e2e.namesRole}}
15
+ {{e2e.roleImport}}
16
+ {{/if}}
14
17
  import { startApplication, type RunningApplication } from '{{alias.test}}/e2e/support/start-application{{alias.ext}}';
15
18
  {{#if e2e.traced}}
16
19
  import { storyOf } from '{{alias.test}}/e2e/support/story-of{{alias.ext}}';
@@ -63,7 +66,7 @@ describe('{{name.title}}, end to end', () => {
63
66
  {{#if authz.rebac}}
64
67
  await application.relate({ object: 'context:{{context.kebab}}', relation: 'operator', subject: 'user:ada' });
65
68
  {{/if}}
66
- const ada = await application.as({ id: 'ada', roles: ['admin']{{e2e.tenant}} });
69
+ const ada = await application.as({ id: 'ada', roles: [{{e2e.role}}]{{e2e.tenant}} });
67
70
 
68
71
  const trace = await tracing.traceOf(async () => {
69
72
  expectStatus(await ada.{{e2e.call}}('{{e2e.samplePath}}'{{e2e.body}}), {{e2e.status}});
@@ -88,7 +91,7 @@ describe('{{name.title}}, end to end', () => {
88
91
  {{#if authz.rebac}}
89
92
  await application.relate({ object: 'context:{{context.kebab}}', relation: 'operator', subject: 'user:ada' });
90
93
  {{/if}}
91
- const ada = await application.as({ id: 'ada', roles: ['admin']{{e2e.tenant}} });
94
+ const ada = await application.as({ id: 'ada', roles: [{{e2e.role}}]{{e2e.tenant}} });
92
95
 
93
96
  const response = await ada.{{e2e.call}}('{{e2e.samplePath}}'{{e2e.body}});
94
97
  {{/if}}
@@ -0,0 +1 @@
1
+ import { {{codes.list}} } from '{{alias.context}}/{{context.kebab}}.codes{{alias.ext}}';
@@ -2,6 +2,6 @@
2
2
  const error = {{name.pascal}}.{{factory.camel}}();
3
3
 
4
4
  expect(error).toBeInstanceOf(DomainRefusal);
5
- expect(error.code).toBe('{{error.code}}');
5
+ expect(error.code).toBe({{codes.list}}.{{name.pascal}});
6
6
  expect(error.facts).toEqual({});
7
7
  });
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
2
  import { DomainRefusal } from '@ddd-ts-kit/kernel';
3
+ {{error.codesImport}}
3
4
  import { {{name.pascal}} } from '{{alias.context}}/domain/errors/{{name.kebab}}.error{{alias.ext}}';
4
5
 
5
6
  describe('{{name.pascal}}', () => {
@@ -9,6 +9,9 @@ import {
9
9
  FileStaging,
10
10
  InMemoryErrorReporter,
11
11
  InMemoryFileStorage,
12
+ {{#if access.protected}}
13
+ KitCodes,
14
+ {{/if}}
12
15
  TenantFileKeys,
13
16
  fileUploadsMiddleware,
14
17
  } from '@ddd-ts-kit/kernel';
@@ -47,7 +50,7 @@ describe('{{name.title}}', () => {
47
50
  const { commandBus, storage } = arrange();
48
51
  const command = new {{name.pascal}}Command(anActor().build(), aFile());
49
52
 
50
- await expect(commandBus.execute(command)).rejects.toMatchObject({ code: 'FORBIDDEN' });
53
+ await expect(commandBus.execute(command)).rejects.toMatchObject({ code: KitCodes.Forbidden });
51
54
  expect(storage.keys()).toEqual([]);
52
55
  });
53
56
  {{/if}}
@@ -2,15 +2,28 @@ import type { Authenticator } from '@ddd-ts-kit/auth';
2
2
  import { JwtAuthenticator } from '@ddd-ts-kit/auth/jwt';
3
3
  import type { HttpHeaders } from '@ddd-ts-kit/testing/e2e';
4
4
  import { SignJWT, generateKeyPair, type CryptoKey } from 'jose';
5
+ {{#if authz.roles}}
6
+ import type { Role } from '{{alias.platform}}/auth/authorization/role{{alias.ext}}';
7
+ {{/if}}
5
8
  import { authEnvironment } from '{{alias.test}}/e2e/support/auth-environment{{alias.ext}}';
6
9
 
7
10
  const issuer = authEnvironment.AUTH_ISSUER;
8
11
  const audience = authEnvironment.AUTH_AUDIENCE;
9
12
 
13
+ {{#if authz.roles}}
14
+ /** Who a test calls as: the subject, the roles and the tenant its token carries. A role is one the platform declares (`Role.Admin`): another does not compile. */
15
+ {{/if}}
16
+ {{#unless authz.roles}}
10
17
  /** Who a test calls as: the subject, the roles and the tenant its token carries. */
18
+ {{/unless}}
11
19
  export interface TestActor {
12
20
  readonly id: string;
21
+ {{#if authz.roles}}
22
+ readonly roles?: readonly Role[];
23
+ {{/if}}
24
+ {{#unless authz.roles}}
13
25
  readonly roles?: readonly string[];
26
+ {{/unless}}
14
27
  readonly tenantId?: string;
15
28
  }
16
29
 
@@ -4,16 +4,29 @@ import type { Authenticator } from '@ddd-ts-kit/auth';
4
4
  import { keycloakAuthenticator } from '@ddd-ts-kit/auth/jwt';
5
5
  import type { HttpHeaders } from '@ddd-ts-kit/testing/e2e';
6
6
  import { SignJWT, exportJWK, generateKeyPair, type CryptoKey, type JWK } from 'jose';
7
+ {{#if authz.roles}}
8
+ import type { Role } from '{{alias.platform}}/auth/authorization/role{{alias.ext}}';
9
+ {{/if}}
7
10
  import { authEnvironment } from '{{alias.test}}/e2e/support/auth-environment{{alias.ext}}';
8
11
 
9
12
  const realm = authEnvironment.KEYCLOAK_REALM;
10
13
  const audience = authEnvironment.KEYCLOAK_AUDIENCE;
11
14
  const keyId = 'e2e-key';
12
15
 
16
+ {{#if authz.roles}}
17
+ /** Who a test calls as: the subject, the realm roles and the tenant its token carries. A role is one the platform declares (`Role.Admin`): another does not compile. */
18
+ {{/if}}
19
+ {{#unless authz.roles}}
13
20
  /** Who a test calls as: the subject, the realm roles and the tenant its token carries. */
21
+ {{/unless}}
14
22
  export interface TestActor {
15
23
  readonly id: string;
24
+ {{#if authz.roles}}
25
+ readonly roles?: readonly Role[];
26
+ {{/if}}
27
+ {{#unless authz.roles}}
16
28
  readonly roles?: readonly string[];
29
+ {{/unless}}
17
30
  readonly tenantId?: string;
18
31
  }
19
32
 
@@ -2,11 +2,24 @@ import type { Authenticator } from '@ddd-ts-kit/auth';
2
2
  import type { HttpHeaders } from '@ddd-ts-kit/testing/e2e';
3
3
  import { developmentActorHeader } from '{{alias.platform}}/auth/authentication/development-actor-header{{alias.ext}}';
4
4
  import { DevelopmentHeaderAuthenticator } from '{{alias.platform}}/auth/authentication/development-header-authenticator{{alias.ext}}';
5
+ {{#if authz.roles}}
6
+ import type { Role } from '{{alias.platform}}/auth/authorization/role{{alias.ext}}';
7
+ {{/if}}
5
8
 
9
+ {{#if authz.roles}}
10
+ /** Who a test calls as: the identity, the roles and the tenant the development header carries. A role is one the platform declares (`Role.Admin`): another does not compile. */
11
+ {{/if}}
12
+ {{#unless authz.roles}}
6
13
  /** Who a test calls as: the identity, the roles and the tenant the development header carries. */
14
+ {{/unless}}
7
15
  export interface TestActor {
8
16
  readonly id: string;
17
+ {{#if authz.roles}}
18
+ readonly roles?: readonly Role[];
19
+ {{/if}}
20
+ {{#unless authz.roles}}
9
21
  readonly roles?: readonly string[];
22
+ {{/unless}}
10
23
  readonly tenantId?: string;
11
24
  }
12
25
 
@@ -4,15 +4,28 @@ import type { HttpHeaders } from '@ddd-ts-kit/testing/e2e';
4
4
  import { SignJWT, exportSPKI, generateKeyPair, type CryptoKey } from 'jose';
5
5
  import { actorOfToken } from '{{alias.platform}}/auth/authentication/actor-of-token{{alias.ext}}';
6
6
  import { bearerStrategy } from '{{alias.platform}}/auth/authentication/bearer-strategy{{alias.ext}}';
7
+ {{#if authz.roles}}
8
+ import type { Role } from '{{alias.platform}}/auth/authorization/role{{alias.ext}}';
9
+ {{/if}}
7
10
  import { authEnvironment } from '{{alias.test}}/e2e/support/auth-environment{{alias.ext}}';
8
11
 
9
12
  const issuer = authEnvironment.AUTH_ISSUER;
10
13
  const audience = authEnvironment.AUTH_AUDIENCE;
11
14
 
15
+ {{#if authz.roles}}
16
+ /** Who a test calls as: the subject, the roles and the tenant its token carries. A role is one the platform declares (`Role.Admin`): another does not compile. */
17
+ {{/if}}
18
+ {{#unless authz.roles}}
12
19
  /** Who a test calls as: the subject, the roles and the tenant its token carries. */
20
+ {{/unless}}
13
21
  export interface TestActor {
14
22
  readonly id: string;
23
+ {{#if authz.roles}}
24
+ readonly roles?: readonly Role[];
25
+ {{/if}}
26
+ {{#unless authz.roles}}
15
27
  readonly roles?: readonly string[];
28
+ {{/unless}}
16
29
  readonly tenantId?: string;
17
30
  }
18
31
 
@@ -7,7 +7,7 @@ import {
7
7
  type HttpRequest,
8
8
  type PageBody,
9
9
  } from '@ddd-ts-kit/http';
10
- import type { QueryBus } from '@ddd-ts-kit/kernel';
10
+ import { KitCodes, type QueryBus } from '@ddd-ts-kit/kernel';
11
11
  import { auditEntriesFilterOf } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-filter-of{{alias.ext}}';
12
12
  import {
13
13
  auditEntriesParameters,
@@ -27,7 +27,7 @@ import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-e
27
27
  guards: [Authenticated],
28
28
  query: auditEntriesParameters,
29
29
  response: { status: 200, description: 'A page of entries.', body: pageSchemaOf(auditEntrySchema) },
30
- errors: ['FORBIDDEN'],
30
+ errors: [KitCodes.Forbidden],
31
31
  })
32
32
  export class SearchAuditEntriesController {
33
33
  constructor(private readonly queries: QueryBus) {}
@@ -1,6 +1,6 @@
1
1
  import { actorOf } from '@ddd-ts-kit/auth';
2
2
  import { defineRoute, pageRequestFrom, pageResponse, pageSchemaOf, type Route } from '@ddd-ts-kit/http';
3
- import type { QueryBus } from '@ddd-ts-kit/kernel';
3
+ import { KitCodes, type QueryBus } from '@ddd-ts-kit/kernel';
4
4
  import { auditEntriesFilterOf } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-filter-of{{alias.ext}}';
5
5
  import { auditEntriesParameters, auditPageLimits } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-parameters{{alias.ext}}';
6
6
  import { auditEntrySchema } from '{{alias.platform}}/audit/search-audit-entries/audit-entry-view{{alias.ext}}';
@@ -18,7 +18,7 @@ export function searchAuditEntriesRoute(queries: QueryBus): Route {
18
18
  tags: ['audit'],
19
19
  request: { query: auditEntriesParameters },
20
20
  responses: { 200: { description: 'A page of entries.', body: pageSchemaOf(auditEntrySchema) } },
21
- errors: ['UNAUTHORIZED', 'FORBIDDEN'],
21
+ errors: [KitCodes.Unauthorized, KitCodes.Forbidden],
22
22
  security: ['{{authn.scheme}}'],
23
23
  },
24
24
  async (input) => {
@@ -11,6 +11,7 @@ import {
11
11
  dispatchingOnSave,
12
12
  reportAfterCommitFailures,
13
13
  type DomainEventDispatcher,
14
+ type ExecutionScope,
14
15
  } from '@ddd-ts-kit/kernel';
15
16
  import type { TracedApplication } from '@ddd-ts-kit/tracing';
16
17
  import { accessPolicies } from '{{alias.platform}}/auth/authorization/access-policies{{alias.ext}}';
@@ -62,7 +63,7 @@ export function createPlatform(persistence: Persistence, options: PlatformOption
62
63
  const domainEvents = traced.domainEvents(new InMemoryDomainEventDispatcher(afterCommitFailed));
63
64
  const authorizer = createAuthorizer();
64
65
  const protection = new UseCaseProtection(authorizer, onDecision);
65
- const adapter = adapterOf(options.resilience ?? defaultResilienceSettings, { traced, domainEvents });
66
+ const adapter = adapterOf(options.resilience ?? defaultResilienceSettings, { traced, domainEvents, scope });
66
67
  {{#if files.any}}
67
68
  const files = filesOf(options, foundations);
68
69
  {{/if}}
@@ -103,19 +104,28 @@ function filesOf(options: PlatformOptions, foundations: Foundations): Files {
103
104
  interface Outside {
104
105
  readonly traced: TracedApplication;
105
106
  readonly domainEvents: DomainEventDispatcher;
107
+ readonly scope: ExecutionScope;
106
108
  }
107
109
 
108
110
  /**
109
111
  * Around every adapter, outermost first: its span, for a repository the dispatch of the domain
110
- * events of what it saves (handlers only save), then the retries and the time limit of what
112
+ * events of what it saves (handlers only save, and run in the execution context of the save), then the retries and the time limit of what
111
113
  * leaves the process.
112
114
  */
113
- function adapterOf(settings: ResilienceSettings, { traced, domainEvents }: Outside): Platform['adapter'] {
115
+ function adapterOf(settings: ResilienceSettings, { traced, domainEvents, scope }: Outside): Platform['adapter'] {
114
116
  const governed = defaultPolicy(settings);
115
117
 
116
118
  return (instance, info) => {
117
119
  const resilient = governed(instance, info);
118
- const saving = info.kind === 'repository' ? dispatchingOnSave(resilient, () => domainEvents) : resilient;
120
+
121
+ const saving =
122
+ info.kind === 'repository'
123
+ ? dispatchingOnSave(
124
+ resilient,
125
+ () => domainEvents,
126
+ () => scope,
127
+ )
128
+ : resilient;
119
129
 
120
130
  return traced.binding(saving, { ...info, context: info.context ?? 'platform' });
121
131
  };
@@ -65,9 +65,15 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
65
65
  {{/if}}
66
66
  await app.listen({ port: config.port, host: '0.0.0.0' });
67
67
 
68
- const [address] = app.addresses();
68
+ return { port: boundPort(app.addresses()), close: () => app.close() };
69
+ }
70
+
71
+ // A server bound to a pipe gives its path, a string, where one bound to a port gives the port.
72
+ function boundPort(addresses: readonly unknown[]): number {
73
+ const [address] = addresses;
74
+ const port: unknown = typeof address === 'object' && address !== null && 'port' in address ? address.port : 0;
69
75
 
70
- return { port: address?.port ?? 0, close: () => app.close() };
76
+ return typeof port === 'number' ? port : 0;
71
77
  }
72
78
 
73
79
  /** TRUST_PROXY as Fastify takes it: a number of hops as the test of each hop. */
@@ -30,10 +30,10 @@ paths:
30
30
  - Imports `application/` (and domain types for mapping), never `infrastructure/` (`layer/presentation-no-infrastructure`).
31
31
  - Input shape is validated here with the schema library of the project, behind the `Schema` port. Business rules are not validated here.
32
32
  {{#if refusals.named}}
33
- - Every route says who may call it (its group or its guards for a controller, `security` for a function) and the codes of the refusals it can answer in `errors`, as the code list of its context, `<context>.codes.ts`, lists them (`errors/known-code`); the mapping from code to status lives in one place, the error mapper. A client reads the `code`, under `facts` only what a factory exposed, and the message of the refusal as `detail` unless it quotes a fact that is not exposed.
33
+ - Every route says who may call it (its group or its guards for a controller, `security` for a function) and the codes of the refusals it can answer in `errors`, as the code list of its context, `<context>.codes.ts`, lists them, each named by its member of that list (`<Context>Codes.<Refusal>`) and a code of the kit by `KitCodes` of `@ddd-ts-kit/kernel` (`KitCodes.Forbidden`), so that a misspelled code does not compile (`errors/known-code`); the mapping from code to status lives in one place, the error mapper. A client reads the `code`, under `facts` only what a factory exposed, and the message of the refusal as `detail` unless it quotes a fact that is not exposed.
34
34
  {{/if}}
35
35
  {{#if refusals.factories}}
36
- - Every route says who may call it (its group or its guards for a controller, `security` for a function) and the codes of the refusals it can answer in `errors`, as their factories set them (`errors/known-code`); the mapping from code to status lives in one place, the error mapper. A client reads the `code`, under `facts` only what a factory exposed, and the message of the refusal as `detail` unless it quotes a fact that is not exposed.
36
+ - Every route says who may call it (its group or its guards for a controller, `security` for a function) and the codes of the refusals it can answer in `errors`, as their factories set them, a code of the kit named by `KitCodes` of `@ddd-ts-kit/kernel` (`KitCodes.Forbidden`) (`errors/known-code`); the mapping from code to status lives in one place, the error mapper. A client reads the `code`, under `facts` only what a factory exposed, and the message of the refusal as `detail` unless it quotes a fact that is not exposed.
37
37
  {{/if}}
38
38
  {{#if refusals.classes}}
39
39
  - Every route says who may call it (its group or its guards for a controller, `security` for a function) and the `DomainError` codes it can answer in `errors`; the mapping from code to status lives in one place, the error mapper.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  paths:
3
3
  - "{{config.contextsDir}}/*/test/**"
4
+ - "{{config.contextsDir}}/*/*/test/**"
4
5
  - "**/*.spec.ts"
5
6
  - "test/**"
6
7
  ---
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
2
  import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
3
3
  import { routeOf } from '@ddd-ts-kit/http/testing';
4
+ {{#if route.refusesMissing}}
5
+ import { KitCodes } from '@ddd-ts-kit/kernel';
6
+ {{/if}}
4
7
  import { {{route.recordingBus}} } from '@ddd-ts-kit/kernel/testing';
5
8
  import { classSchema } from '@ddd-ts-kit/validation/class-validator';
6
9
  {{route.messageImport}}
@@ -43,7 +46,7 @@ describe('{{route.method}} {{route.path}}', () => {
43
46
  expect(response).toMatchObject({
44
47
  status: 422,
45
48
  body: {
46
- code: 'VALIDATION_FAILED',
49
+ code: KitCodes.ValidationFailed,
47
50
  issues: expect.arrayContaining([expect.objectContaining({ path: 'body.{{route.missingField}}' })]),
48
51
  },
49
52
  });
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.6.3/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.6.4/schema.json",
3
3
  "vcs": {
4
4
  "enabled": true,
5
5
  "clientKind": "git",
@@ -4,5 +4,5 @@ import base from './jest.config.js';
4
4
  export default {
5
5
  ...base,
6
6
  testMatch: ['<rootDir>/{{config.sourceRoot}}/**/*.spec.ts'],
7
- testPathIgnorePatterns: [...base.testPathIgnorePatterns, '/{{config.contextsDir}}/[^/]+/test/integration/'],
7
+ testPathIgnorePatterns: [...base.testPathIgnorePatterns, '/{{config.contextsDir}}/[^/]+/(?:test|[^/]+/test)/integration/'],
8
8
  };
@@ -20,6 +20,8 @@
20
20
  "{{config.sourceRoot}}/**/*.spec.ts",
21
21
  "{{config.contextsDir}}/*/test/fakes/*.ts",
22
22
  "{{config.contextsDir}}/*/test/worlds/*.ts",
23
+ "{{config.contextsDir}}/*/*/test/fakes/*.ts",
24
+ "{{config.contextsDir}}/*/*/test/worlds/*.ts",
23
25
  "test/architecture/**/*.spec.ts"{{knip.e2eSpecs}}{{knip.testDatabase}}
24
26
  ]
25
27
  }
@@ -20,10 +20,10 @@
20
20
  "ci:build": "npm run build"
21
21
  },
22
22
  "devDependencies": {
23
- "@biomejs/biome": "2.6.3",
23
+ "@biomejs/biome": "2.6.4",
24
24
  "@commitlint/cli": "^21.2.3",
25
25
  "@commitlint/config-conventional": "^21.2.3",
26
- "@ddd-ts-kit/eslint-plugin": "^0.109.0",
26
+ "@ddd-ts-kit/eslint-plugin": "^0.110.0",
27
27
  "@eslint/js": "^10.0.1",
28
28
  "@typescript/native": "npm:typescript@~7.0.2",
29
29
  "@vitest/coverage-v8": "^5.0.3",
@@ -1,13 +1,18 @@
1
1
  import { governedCoverage, unaffectedContexts } from '@ddd-ts-kit/testing/coverage';
2
2
  {{#if decorators.standard}}
3
- import { decorators } from '@ddd-ts-kit/testing/vitest';
3
+ import { decoratorCoverage, decorators } from '@ddd-ts-kit/testing/vitest';
4
4
  {{/if}}
5
5
  {{#if decorators.legacy}}
6
6
  import { decoratorCoverage } from '@ddd-ts-kit/testing/vitest';
7
7
  {{/if}}
8
8
  import { configDefaults, defineConfig, type TestProjectInlineConfiguration } from 'vitest/config';
9
9
 
10
- const INTEGRATION_SPECS = '{{config.contextsDir}}/*/test/integration/**/*.spec.ts';
10
+ // The integration specs of a context, and of a module of its model that holds its tests.
11
+ const INTEGRATION_SPECS = [
12
+ '{{config.contextsDir}}/*/test/integration/**/*.spec.ts',
13
+ '{{config.contextsDir}}/*/*/test/integration/**/*.spec.ts',
14
+ ];
15
+
11
16
  const INTEGRATION_MODE = 'integration';
12
17
  // A pull request names the contexts its change reaches (DDD_TS_KIT_AFFECTED, from `ddd-ts-kit affected`): the specs of the others are left to the default branch.
13
18
  const NOT_AFFECTED = unaffectedContexts().map((directory) => `${directory}**`);
@@ -19,7 +24,7 @@ const UNIT_PROJECT: TestProjectInlineConfiguration = {
19
24
  test: {
20
25
  name: 'unit',
21
26
  include: ['{{config.sourceRoot}}/**/*.spec.ts', 'test/architecture/**/*.spec.ts'],
22
- exclude: [INTEGRATION_SPECS, ...NOT_AFFECTED],
27
+ exclude: [...INTEGRATION_SPECS, ...NOT_AFFECTED],
23
28
  // The unit specs share no state: each worker runs them in one module graph, the declarations of a context evaluated once rather than once per spec file. `isolate: true` gives each file its own graph again.
24
29
  isolate: false,
25
30
  },
@@ -29,7 +34,7 @@ const INTEGRATION_PROJECT: TestProjectInlineConfiguration = {
29
34
  extends: true,
30
35
  test: {
31
36
  name: INTEGRATION_MODE,
32
- include: [INTEGRATION_SPECS],
37
+ include: INTEGRATION_SPECS,
33
38
  exclude: NOT_AFFECTED,
34
39
  {{#if persistence.hasDatabase}}
35
40
  globalSetup: ['test/support/test-database-template.ts'],
@@ -44,8 +49,8 @@ const INTEGRATION_PROJECT: TestProjectInlineConfiguration = {
44
49
 
45
50
  export default defineConfig(({ mode }) => ({
46
51
  {{#if decorators.standard}}
47
- // Vitest does not lower standard (TC39) decorators, which every class of a declared context carries: the compiler the project builds with does.
48
- plugins: [decorators({ compiler: '@typescript/native' })],
52
+ // Vitest does not lower standard (TC39) decorators, which every class of a declared context carries: the compiler the project builds with does. What it writes to apply them holds closures no spec calls, kept out of the measure.
53
+ plugins: [decorators({ compiler: '@typescript/native' }), decoratorCoverage()],
49
54
  {{/if}}
50
55
  {{#if decorators.legacy}}
51
56
  // Under `emitDecoratorMetadata` the transform guards every type a decorated class names with a branch no test can take: the statements that apply decorators are kept out of the measure.
@@ -20,7 +20,7 @@ export default defineConfig({
20
20
  resolve: { tsconfigPaths: true },
21
21
  test: {
22
22
  include: ['{{config.sourceRoot}}/**/*.spec.ts'],
23
- exclude: ['{{config.contextsDir}}/*/test/integration/**'],
23
+ exclude: ['{{config.contextsDir}}/*/test/integration/**', '{{config.contextsDir}}/*/*/test/integration/**'],
24
24
  {{#if assembly.discovery}}
25
25
  // Discovery imports the role files of a context itself: inlined, the package loads them through the runner, which compiles them.
26
26
  server: { deps: { inline: ['@ddd-ts-kit/di'] } },
@@ -1,5 +1,6 @@
1
1
  import { Authenticated, RouteGroup } from '@ddd-ts-kit/http';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
 
3
4
  /** The account of the person who calls: every route is about the caller, named by their token. */
4
- @RouteGroup({ prefix: '/accounts', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: ['FORBIDDEN'] })
5
+ @RouteGroup({ prefix: '/accounts', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: [KitCodes.Forbidden] })
5
6
  export class AccountsRoutes {}
@@ -1,5 +1,6 @@
1
1
  import { Authenticated, RouteGroup } from '@ddd-ts-kit/http';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
 
3
4
  /** The answers of a person to an invitation sent to them, by its token. */
4
- @RouteGroup({ prefix: '/invitations', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: ['FORBIDDEN'] })
5
+ @RouteGroup({ prefix: '/invitations', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: [KitCodes.Forbidden] })
5
6
  export class InvitationsRoutes {}
@@ -1,5 +1,6 @@
1
1
  import { Authenticated, RouteGroup } from '@ddd-ts-kit/http';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
 
3
4
  /** The organisations, their members, their invitations and their delegations: inside one, the policies of the context decide. */
4
- @RouteGroup({ prefix: '/organisations', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: ['FORBIDDEN'] })
5
+ @RouteGroup({ prefix: '/organisations', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: [KitCodes.Forbidden] })
5
6
  export class OrganisationsRoutes {}
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
  import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
3
4
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
4
5
  import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
@@ -76,7 +77,7 @@ describe('Change member role', () => {
76
77
 
77
78
  await expect(
78
79
  arranged.application.commandBus.execute(new ChangeMemberRoleCommand(arranged.as('subject-alan'), 'acme', 'subject-grace', MemberRole.Admin)),
79
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
80
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
80
81
  });
81
82
  });
82
83
 
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
- import { offsetPage } from '@ddd-ts-kit/kernel';
2
+ import { KitCodes, offsetPage } from '@ddd-ts-kit/kernel';
3
3
  import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
4
4
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
5
5
  import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
@@ -74,9 +74,9 @@ describe('Deactivate account', () => {
74
74
  const remove = new RemoveMemberCommand(as('subject-grace'), 'acme', 'subject-alan');
75
75
  const search = new SearchMembersQuery(as('subject-grace'), 'acme', offsetPage({ limit: 20 }));
76
76
 
77
- await expect(application.commandBus.execute(invite)).rejects.toMatchObject({ code: 'FORBIDDEN' });
78
- await expect(application.commandBus.execute(remove)).rejects.toMatchObject({ code: 'FORBIDDEN' });
79
- await expect(application.queryBus.execute(search)).rejects.toMatchObject({ code: 'FORBIDDEN' });
77
+ await expect(application.commandBus.execute(invite)).rejects.toMatchObject({ code: KitCodes.Forbidden });
78
+ await expect(application.commandBus.execute(remove)).rejects.toMatchObject({ code: KitCodes.Forbidden });
79
+ await expect(application.queryBus.execute(search)).rejects.toMatchObject({ code: KitCodes.Forbidden });
80
80
  expect(await members.countOwners('acme')).toBe(1);
81
81
  });
82
82
 
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
  import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
3
4
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
4
5
  import { GrantDelegationCommand } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.command{{alias.ext}}';
@@ -57,7 +58,7 @@ describe('Grant delegation', () => {
57
58
 
58
59
  await expect(
59
60
  application.commandBus.execute(new GrantDelegationCommand(as('subject-ada'), 'acme', lend(MemberRight.InviteMembers))),
60
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
61
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
61
62
  });
62
63
  });
63
64
 
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
- import type { DomainEvent } from '@ddd-ts-kit/kernel';
2
+ import { type DomainEvent, KitCodes } from '@ddd-ts-kit/kernel';
3
3
  import { InvitationIssued } from '{{alias.context}}/domain/events/invitation-issued.event{{alias.ext}}';
4
4
  import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
5
5
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
@@ -87,11 +87,11 @@ describe('Invite member', () => {
87
87
 
88
88
  await expect(
89
89
  application.commandBus.execute(new InviteMemberCommand(as('subject-alan'), 'acme', grace)),
90
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
90
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
91
91
 
92
92
  await expect(
93
93
  application.commandBus.execute(new InviteMemberCommand(as('subject-mallory'), 'acme', grace)),
94
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
94
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
95
95
 
96
96
  expect(invitations.all()).toEqual([]);
97
97
  });
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
  import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
3
4
  import { anAccount } from '{{alias.context}}/test/builders/account.builder{{alias.ext}}';
4
5
  import { arrangeIdentity } from '{{alias.context}}/test/worlds/{{context.kebab}}.world{{alias.ext}}';
@@ -59,7 +60,7 @@ describe('Provision account', () => {
59
60
  const { application, stranger } = arrangeIdentity();
60
61
 
61
62
  await expect(application.commandBus.execute(new ProvisionAccountCommand(stranger, profile))).rejects.toMatchObject({
62
- code: 'FORBIDDEN',
63
+ code: KitCodes.Forbidden,
63
64
  });
64
65
  });
65
66
  });
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
  import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
3
4
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
4
5
  import { RemoveMemberCommand } from '{{alias.context}}/application/commands/remove-member/remove-member.command{{alias.ext}}';
@@ -68,7 +69,7 @@ describe('Remove member', () => {
68
69
 
69
70
  await expect(
70
71
  application.commandBus.execute(new RemoveMemberCommand(as('subject-alan'), 'acme', 'subject-grace')),
71
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
72
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
72
73
  });
73
74
  });
74
75
 
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from '{{tests.module}}';
2
+ import { KitCodes } from '@ddd-ts-kit/kernel';
2
3
  import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
3
4
  import { RevokeDelegationCommand } from '{{alias.context}}/application/commands/revoke-delegation/revoke-delegation.command{{alias.ext}}';
4
5
  import { aDelegation } from '{{alias.context}}/test/builders/delegation.builder{{alias.ext}}';
@@ -46,6 +47,6 @@ describe('Revoke delegation', () => {
46
47
 
47
48
  await expect(
48
49
  application.commandBus.execute(new RevokeDelegationCommand(as('subject-alan'), 'acme', 'delegation-1')),
49
- ).rejects.toMatchObject({ code: 'FORBIDDEN' });
50
+ ).rejects.toMatchObject({ code: KitCodes.Forbidden });
50
51
  });
51
52
  });