ddd-ts-kit 0.91.0 → 0.93.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 (484) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/README.fr.md +27 -18
  3. package/README.md +24 -15
  4. package/dist/acceptance/check-locked-files.d.ts +25 -0
  5. package/dist/acceptance/check-locked-files.d.ts.map +1 -0
  6. package/dist/acceptance/check-locked-files.js +84 -0
  7. package/dist/acceptance/check-locked-files.js.map +1 -0
  8. package/dist/acceptance/lock-acceptance.d.ts.map +1 -1
  9. package/dist/acceptance/lock-acceptance.js +2 -1
  10. package/dist/acceptance/lock-acceptance.js.map +1 -1
  11. package/dist/acceptance/scenarios-in.d.ts +4 -0
  12. package/dist/acceptance/scenarios-in.d.ts.map +1 -1
  13. package/dist/acceptance/scenarios-in.js +2 -2
  14. package/dist/acceptance/scenarios-in.js.map +1 -1
  15. package/dist/check/event-sourcing/read-stored-shape.d.ts +2 -0
  16. package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -1
  17. package/dist/check/event-sourcing/read-stored-shape.js +3 -1
  18. package/dist/check/event-sourcing/read-stored-shape.js.map +1 -1
  19. package/dist/check/event-sourcing/stored-event-declaration.d.ts +2 -0
  20. package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -1
  21. package/dist/check/event-sourcing/stored-event-declarations.js +1 -0
  22. package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -1
  23. package/dist/check/event-sourcing/stored-shape.d.ts +2 -0
  24. package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -1
  25. package/dist/check/fixtures/nest-controllers-fixtures.d.ts.map +1 -1
  26. package/dist/check/fixtures/nest-controllers-fixtures.js +21 -3
  27. package/dist/check/fixtures/nest-controllers-fixtures.js.map +1 -1
  28. package/dist/check/nest/nest-equivalents-of.d.ts.map +1 -1
  29. package/dist/check/nest/nest-equivalents-of.js +7 -2
  30. package/dist/check/nest/nest-equivalents-of.js.map +1 -1
  31. package/dist/check/rules/nest-controllers-current.d.ts.map +1 -1
  32. package/dist/check/rules/nest-controllers-current.js +13 -2
  33. package/dist/check/rules/nest-controllers-current.js.map +1 -1
  34. package/dist/commands/acceptance.d.ts.map +1 -1
  35. package/dist/commands/acceptance.js +14 -0
  36. package/dist/commands/acceptance.js.map +1 -1
  37. package/dist/commands/docs.d.ts.map +1 -1
  38. package/dist/commands/docs.js +13 -5
  39. package/dist/commands/docs.js.map +1 -1
  40. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  41. package/dist/commands/drizzle-generate.js +21 -1
  42. package/dist/commands/drizzle-generate.js.map +1 -1
  43. package/dist/commands/generate.js +4 -0
  44. package/dist/commands/generate.js.map +1 -1
  45. package/dist/commands/prisma-generate.d.ts +7 -0
  46. package/dist/commands/prisma-generate.d.ts.map +1 -0
  47. package/dist/commands/prisma-generate.js +23 -0
  48. package/dist/commands/prisma-generate.js.map +1 -0
  49. package/dist/commands/typeorm-generate.d.ts +10 -0
  50. package/dist/commands/typeorm-generate.d.ts.map +1 -0
  51. package/dist/commands/typeorm-generate.js +37 -0
  52. package/dist/commands/typeorm-generate.js.map +1 -0
  53. package/dist/commit/run-git.d.ts +5 -1
  54. package/dist/commit/run-git.d.ts.map +1 -1
  55. package/dist/commit/run-git.js +19 -2
  56. package/dist/commit/run-git.js.map +1 -1
  57. package/dist/config/stack.d.ts +1 -1
  58. package/dist/config/stack.d.ts.map +1 -1
  59. package/dist/config/stack.js +1 -1
  60. package/dist/config/stack.js.map +1 -1
  61. package/dist/controllers/finish-migration.js +4 -2
  62. package/dist/controllers/finish-migration.js.map +1 -1
  63. package/dist/describe/guard-errors.d.ts +3 -0
  64. package/dist/describe/guard-errors.d.ts.map +1 -0
  65. package/dist/describe/guard-errors.js +10 -0
  66. package/dist/describe/guard-errors.js.map +1 -0
  67. package/dist/describe/no-group.d.ts +4 -0
  68. package/dist/describe/no-group.d.ts.map +1 -0
  69. package/dist/describe/no-group.js +3 -0
  70. package/dist/describe/no-group.js.map +1 -0
  71. package/dist/describe/read-controllers.d.ts +1 -1
  72. package/dist/describe/read-controllers.d.ts.map +1 -1
  73. package/dist/describe/read-controllers.js +12 -19
  74. package/dist/describe/read-controllers.js.map +1 -1
  75. package/dist/describe/read-nest-controller-routes.d.ts +16 -0
  76. package/dist/describe/read-nest-controller-routes.d.ts.map +1 -0
  77. package/dist/describe/read-nest-controller-routes.js +117 -0
  78. package/dist/describe/read-nest-controller-routes.js.map +1 -0
  79. package/dist/describe/schema-class-of.d.ts +3 -0
  80. package/dist/describe/schema-class-of.d.ts.map +1 -0
  81. package/dist/describe/schema-class-of.js +10 -0
  82. package/dist/describe/schema-class-of.js.map +1 -0
  83. package/dist/docs/behaviour-page.d.ts.map +1 -1
  84. package/dist/docs/behaviour-page.js +9 -1
  85. package/dist/docs/behaviour-page.js.map +1 -1
  86. package/dist/docs/declared-stored-events.d.ts +6 -2
  87. package/dist/docs/declared-stored-events.d.ts.map +1 -1
  88. package/dist/docs/declared-stored-events.js +4 -3
  89. package/dist/docs/declared-stored-events.js.map +1 -1
  90. package/dist/docs/emptily-recorded-stored-events.d.ts +6 -0
  91. package/dist/docs/emptily-recorded-stored-events.d.ts.map +1 -0
  92. package/dist/docs/emptily-recorded-stored-events.js +12 -0
  93. package/dist/docs/emptily-recorded-stored-events.js.map +1 -0
  94. package/dist/docs/refuse-unreadable-stored-events.d.ts +7 -0
  95. package/dist/docs/refuse-unreadable-stored-events.d.ts.map +1 -0
  96. package/dist/docs/refuse-unreadable-stored-events.js +27 -0
  97. package/dist/docs/refuse-unreadable-stored-events.js.map +1 -0
  98. package/dist/docs/write-stored-events-lock.d.ts +3 -2
  99. package/dist/docs/write-stored-events-lock.d.ts.map +1 -1
  100. package/dist/docs/write-stored-events-lock.js +5 -2
  101. package/dist/docs/write-stored-events-lock.js.map +1 -1
  102. package/dist/generate/kind.d.ts +4 -0
  103. package/dist/generate/kind.d.ts.map +1 -1
  104. package/dist/generate/kinds/aggregate-kind.d.ts.map +1 -1
  105. package/dist/generate/kinds/aggregate-kind.js +6 -2
  106. package/dist/generate/kinds/aggregate-kind.js.map +1 -1
  107. package/dist/generate/kinds/assert-event-store.d.ts +4 -0
  108. package/dist/generate/kinds/assert-event-store.d.ts.map +1 -0
  109. package/dist/generate/kinds/assert-event-store.js +10 -0
  110. package/dist/generate/kinds/assert-event-store.js.map +1 -0
  111. package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts +9 -0
  112. package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts.map +1 -0
  113. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js +49 -0
  114. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js.map +1 -0
  115. package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -1
  116. package/dist/generate/kinds/file-upload-kind.js +9 -2
  117. package/dist/generate/kinds/file-upload-kind.js.map +1 -1
  118. package/dist/generate/kinds/form-kind.d.ts.map +1 -1
  119. package/dist/generate/kinds/form-kind.js +15 -11
  120. package/dist/generate/kinds/form-kind.js.map +1 -1
  121. package/dist/generate/kinds/generate-event-sourced-repository.d.ts +11 -0
  122. package/dist/generate/kinds/generate-event-sourced-repository.d.ts.map +1 -0
  123. package/dist/generate/kinds/generate-event-sourced-repository.js +48 -0
  124. package/dist/generate/kinds/generate-event-sourced-repository.js.map +1 -0
  125. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  126. package/dist/generate/kinds/generate-repository.js +5 -0
  127. package/dist/generate/kinds/generate-repository.js.map +1 -1
  128. package/dist/generate/kinds/is-event-sourced.d.ts +9 -0
  129. package/dist/generate/kinds/is-event-sourced.d.ts.map +1 -0
  130. package/dist/generate/kinds/is-event-sourced.js +11 -0
  131. package/dist/generate/kinds/is-event-sourced.js.map +1 -0
  132. package/dist/generate/kinds/job/job-vars.d.ts +4 -1
  133. package/dist/generate/kinds/job/job-vars.d.ts.map +1 -1
  134. package/dist/generate/kinds/job/job-vars.js +11 -1
  135. package/dist/generate/kinds/job/job-vars.js.map +1 -1
  136. package/dist/generate/kinds/job-kind.js +20 -3
  137. package/dist/generate/kinds/job-kind.js.map +1 -1
  138. package/dist/generate/kinds/presentation/controller-source.d.ts +11 -3
  139. package/dist/generate/kinds/presentation/controller-source.d.ts.map +1 -1
  140. package/dist/generate/kinds/presentation/controller-source.js +25 -4
  141. package/dist/generate/kinds/presentation/controller-source.js.map +1 -1
  142. package/dist/generate/kinds/repository-kind.js +1 -1
  143. package/dist/generate/kinds/repository-kind.js.map +1 -1
  144. package/dist/generate/kinds/representation-kind.d.ts.map +1 -1
  145. package/dist/generate/kinds/representation-kind.js +4 -3
  146. package/dist/generate/kinds/representation-kind.js.map +1 -1
  147. package/dist/generate/kinds/route/nest-controller-vars.d.ts +2 -2
  148. package/dist/generate/kinds/route/nest-controller-vars.js +3 -9
  149. package/dist/generate/kinds/route/nest-controller-vars.js.map +1 -1
  150. package/dist/generate/kinds/route/nest-search-vars.d.ts +6 -0
  151. package/dist/generate/kinds/route/nest-search-vars.d.ts.map +1 -0
  152. package/dist/generate/kinds/route/nest-search-vars.js +18 -0
  153. package/dist/generate/kinds/route/nest-search-vars.js.map +1 -0
  154. package/dist/generate/kinds/route/write-nest-controller.d.ts.map +1 -1
  155. package/dist/generate/kinds/route/write-nest-controller.js +6 -8
  156. package/dist/generate/kinds/route/write-nest-controller.js.map +1 -1
  157. package/dist/generate/kinds/route-kind.js +1 -1
  158. package/dist/generate/kinds/route-kind.js.map +1 -1
  159. package/dist/generate/kinds/service-kind.d.ts.map +1 -1
  160. package/dist/generate/kinds/service-kind.js +30 -3
  161. package/dist/generate/kinds/service-kind.js.map +1 -1
  162. package/dist/generate/kinds/wire-repository-on-first-use.d.ts.map +1 -1
  163. package/dist/generate/kinds/wire-repository-on-first-use.js +2 -1
  164. package/dist/generate/kinds/wire-repository-on-first-use.js.map +1 -1
  165. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
  166. package/dist/generate/kinds/write-event-sourced-aggregate.js +5 -13
  167. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
  168. package/dist/help/notes.d.ts +1 -1
  169. package/dist/help/notes.d.ts.map +1 -1
  170. package/dist/help/notes.js +3 -1
  171. package/dist/help/notes.js.map +1 -1
  172. package/dist/help/usage.d.ts +1 -1
  173. package/dist/help/usage.d.ts.map +1 -1
  174. package/dist/help/usage.js +3 -1
  175. package/dist/help/usage.js.map +1 -1
  176. package/dist/init/agent-permissions.js +10 -6
  177. package/dist/init/agent-permissions.js.map +1 -1
  178. package/dist/init/files/auth-files.js +4 -0
  179. package/dist/init/files/auth-files.js.map +1 -1
  180. package/dist/init/files/inert-persistence-file.d.ts +5 -0
  181. package/dist/init/files/inert-persistence-file.d.ts.map +1 -0
  182. package/dist/init/files/inert-persistence-file.js +16 -0
  183. package/dist/init/files/inert-persistence-file.js.map +1 -0
  184. package/dist/init/files/platform-files.js +7 -1
  185. package/dist/init/files/platform-files.js.map +1 -1
  186. package/dist/init/knip-vars.js +4 -3
  187. package/dist/init/knip-vars.js.map +1 -1
  188. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  189. package/dist/init/manifest/database-scripts.js +10 -4
  190. package/dist/init/manifest/database-scripts.js.map +1 -1
  191. package/dist/init/manifest/dependencies-against-stack.d.ts.map +1 -1
  192. package/dist/init/manifest/dependencies-against-stack.js +5 -1
  193. package/dist/init/manifest/dependencies-against-stack.js.map +1 -1
  194. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  195. package/dist/init/manifest/dependencies-for.js +7 -1
  196. package/dist/init/manifest/dependencies-for.js.map +1 -1
  197. package/dist/init/manifest/versions.d.ts.map +1 -1
  198. package/dist/init/manifest/versions.js +34 -30
  199. package/dist/init/manifest/versions.js.map +1 -1
  200. package/dist/init/stack/resolve-stack.js +9 -7
  201. package/dist/init/stack/resolve-stack.js.map +1 -1
  202. package/dist/init/template-vars.js +1 -1
  203. package/dist/init/template-vars.js.map +1 -1
  204. package/dist/init/write-type-script-configs.d.ts.map +1 -1
  205. package/dist/init/write-type-script-configs.js +4 -1
  206. package/dist/init/write-type-script-configs.js.map +1 -1
  207. package/dist/markers/insert-in-region.js +1 -1
  208. package/dist/markers/insert-in-region.js.map +1 -1
  209. package/dist/measures/branch-commits.d.ts +4 -2
  210. package/dist/measures/branch-commits.d.ts.map +1 -1
  211. package/dist/measures/branch-commits.js +32 -8
  212. package/dist/measures/branch-commits.js.map +1 -1
  213. package/dist/measures/timeline-of.d.ts +3 -2
  214. package/dist/measures/timeline-of.d.ts.map +1 -1
  215. package/dist/measures/timeline-of.js +37 -8
  216. package/dist/measures/timeline-of.js.map +1 -1
  217. package/dist/merge/lost/untouched-by-branch.d.ts +12 -0
  218. package/dist/merge/lost/untouched-by-branch.d.ts.map +1 -0
  219. package/dist/merge/lost/untouched-by-branch.js +22 -0
  220. package/dist/merge/lost/untouched-by-branch.js.map +1 -0
  221. package/dist/merge/lost/verify-merge.d.ts.map +1 -1
  222. package/dist/merge/lost/verify-merge.js +6 -1
  223. package/dist/merge/lost/verify-merge.js.map +1 -1
  224. package/dist/migration/audit-guard/append-audit-guard.d.ts +18 -0
  225. package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -0
  226. package/dist/migration/audit-guard/append-audit-guard.js +27 -0
  227. package/dist/migration/audit-guard/append-audit-guard.js.map +1 -0
  228. package/dist/migration/audit-guard/audit-guard-statements-of.d.ts +7 -0
  229. package/dist/migration/audit-guard/audit-guard-statements-of.d.ts.map +1 -0
  230. package/dist/migration/audit-guard/audit-guard-statements-of.js +18 -0
  231. package/dist/migration/audit-guard/audit-guard-statements-of.js.map +1 -0
  232. package/dist/migration/audit-guard/audit-schema-created.d.ts +3 -0
  233. package/dist/migration/audit-guard/audit-schema-created.d.ts.map +1 -0
  234. package/dist/migration/audit-guard/audit-schema-created.js +9 -0
  235. package/dist/migration/audit-guard/audit-schema-created.js.map +1 -0
  236. package/dist/migration/audit-guard/generate-guarded.d.ts +16 -0
  237. package/dist/migration/audit-guard/generate-guarded.d.ts.map +1 -0
  238. package/dist/migration/audit-guard/generate-guarded.js +22 -0
  239. package/dist/migration/audit-guard/generate-guarded.js.map +1 -0
  240. package/dist/migration/audit-guard/guard-marker.d.ts +3 -0
  241. package/dist/migration/audit-guard/guard-marker.d.ts.map +1 -0
  242. package/dist/migration/audit-guard/guard-marker.js +3 -0
  243. package/dist/migration/audit-guard/guard-marker.js.map +1 -0
  244. package/dist/migration/audit-guard/guarded-text.d.ts +5 -0
  245. package/dist/migration/audit-guard/guarded-text.d.ts.map +1 -0
  246. package/dist/migration/audit-guard/guarded-text.js +26 -0
  247. package/dist/migration/audit-guard/guarded-text.js.map +1 -0
  248. package/dist/migration/audit-guard/migrations-under.d.ts +3 -0
  249. package/dist/migration/audit-guard/migrations-under.d.ts.map +1 -0
  250. package/dist/migration/audit-guard/migrations-under.js +15 -0
  251. package/dist/migration/audit-guard/migrations-under.js.map +1 -0
  252. package/dist/migration/audit-guard/run-orm-tool.d.ts +3 -0
  253. package/dist/migration/audit-guard/run-orm-tool.d.ts.map +1 -0
  254. package/dist/migration/audit-guard/run-orm-tool.js +13 -0
  255. package/dist/migration/audit-guard/run-orm-tool.js.map +1 -0
  256. package/dist/migration/audit-guard/schemas-first.d.ts +6 -0
  257. package/dist/migration/audit-guard/schemas-first.d.ts.map +1 -0
  258. package/dist/migration/audit-guard/schemas-first.js +17 -0
  259. package/dist/migration/audit-guard/schemas-first.js.map +1 -0
  260. package/dist/migration/audit-guard/schemas-if-missing.d.ts +7 -0
  261. package/dist/migration/audit-guard/schemas-if-missing.d.ts.map +1 -0
  262. package/dist/migration/audit-guard/schemas-if-missing.js +9 -0
  263. package/dist/migration/audit-guard/schemas-if-missing.js.map +1 -0
  264. package/dist/migration/audit-guard/type-only-imports.d.ts +6 -0
  265. package/dist/migration/audit-guard/type-only-imports.d.ts.map +1 -0
  266. package/dist/migration/audit-guard/type-only-imports.js +8 -0
  267. package/dist/migration/audit-guard/type-only-imports.js.map +1 -0
  268. package/dist/migration/format-as-the-project.d.ts +4 -0
  269. package/dist/migration/format-as-the-project.d.ts.map +1 -0
  270. package/dist/migration/format-as-the-project.js +27 -0
  271. package/dist/migration/format-as-the-project.js.map +1 -0
  272. package/dist/migration/format-written-files.d.ts.map +1 -1
  273. package/dist/migration/format-written-files.js +2 -24
  274. package/dist/migration/format-written-files.js.map +1 -1
  275. package/dist/migration/index.d.ts +8 -0
  276. package/dist/migration/index.d.ts.map +1 -1
  277. package/dist/migration/index.js +8 -0
  278. package/dist/migration/index.js.map +1 -1
  279. package/dist/nest-controllers/nest-answer.d.ts +2 -10
  280. package/dist/nest-controllers/nest-answer.d.ts.map +1 -1
  281. package/dist/nest-controllers/nest-controller-entry.d.ts +4 -2
  282. package/dist/nest-controllers/nest-controller-entry.d.ts.map +1 -1
  283. package/dist/nest-controllers/nest-controllers-in.d.ts +6 -0
  284. package/dist/nest-controllers/nest-controllers-in.d.ts.map +1 -0
  285. package/dist/nest-controllers/nest-controllers-in.js +108 -0
  286. package/dist/nest-controllers/nest-controllers-in.js.map +1 -0
  287. package/dist/nest-controllers/nest-read-type.d.ts +12 -0
  288. package/dist/nest-controllers/nest-read-type.d.ts.map +1 -0
  289. package/dist/nest-controllers/nest-read-type.js +2 -0
  290. package/dist/nest-controllers/nest-read-type.js.map +1 -0
  291. package/dist/nest-controllers/nest-request-part.d.ts +9 -0
  292. package/dist/nest-controllers/nest-request-part.d.ts.map +1 -0
  293. package/dist/nest-controllers/nest-request-part.js +2 -0
  294. package/dist/nest-controllers/nest-request-part.js.map +1 -0
  295. package/dist/nest-controllers/parameters-of.d.ts +8 -0
  296. package/dist/nest-controllers/parameters-of.d.ts.map +1 -0
  297. package/dist/nest-controllers/parameters-of.js +32 -0
  298. package/dist/nest-controllers/parameters-of.js.map +1 -0
  299. package/dist/nest-controllers/project-files.d.ts +6 -0
  300. package/dist/nest-controllers/project-files.d.ts.map +1 -0
  301. package/dist/nest-controllers/project-files.js +2 -0
  302. package/dist/nest-controllers/project-files.js.map +1 -0
  303. package/dist/nest-controllers/read-nest-controllers.d.ts +6 -9
  304. package/dist/nest-controllers/read-nest-controllers.d.ts.map +1 -1
  305. package/dist/nest-controllers/read-nest-controllers.js +10 -82
  306. package/dist/nest-controllers/read-nest-controllers.js.map +1 -1
  307. package/dist/nest-controllers/render-controllers-file.d.ts +4 -3
  308. package/dist/nest-controllers/render-controllers-file.d.ts.map +1 -1
  309. package/dist/nest-controllers/render-controllers-file.js +45 -29
  310. package/dist/nest-controllers/render-controllers-file.js.map +1 -1
  311. package/dist/platform-layout/platform-layout.d.ts +5 -0
  312. package/dist/platform-layout/platform-layout.d.ts.map +1 -1
  313. package/dist/platform-layout/platform-layout.js +5 -0
  314. package/dist/platform-layout/platform-layout.js.map +1 -1
  315. package/dist/presets/identity-refusal.js +3 -3
  316. package/dist/presets/identity-refusal.js.map +1 -1
  317. package/dist/presets/no-flags.d.ts.map +1 -1
  318. package/dist/presets/no-flags.js +1 -0
  319. package/dist/presets/no-flags.js.map +1 -1
  320. package/dist/presets/preset-files.d.ts.map +1 -1
  321. package/dist/presets/preset-files.js +3 -1
  322. package/dist/presets/preset-files.js.map +1 -1
  323. package/dist/progress/build-next-of.d.ts +9 -0
  324. package/dist/progress/build-next-of.d.ts.map +1 -0
  325. package/dist/progress/build-next-of.js +22 -0
  326. package/dist/progress/build-next-of.js.map +1 -0
  327. package/dist/progress/format-progress.d.ts.map +1 -1
  328. package/dist/progress/format-progress.js +3 -0
  329. package/dist/progress/format-progress.js.map +1 -1
  330. package/dist/progress/progress.d.ts +3 -1
  331. package/dist/progress/progress.d.ts.map +1 -1
  332. package/dist/progress/read-progress.d.ts.map +1 -1
  333. package/dist/progress/read-progress.js +7 -2
  334. package/dist/progress/read-progress.js.map +1 -1
  335. package/dist/run.d.ts.map +1 -1
  336. package/dist/run.js +4 -0
  337. package/dist/run.js.map +1 -1
  338. package/dist/stack/authentication-vars.d.ts.map +1 -1
  339. package/dist/stack/authentication-vars.js +8 -2
  340. package/dist/stack/authentication-vars.js.map +1 -1
  341. package/dist/version.d.ts +1 -1
  342. package/dist/version.js +1 -1
  343. package/dist/worker/briefing-of.d.ts.map +1 -1
  344. package/dist/worker/briefing-of.js +2 -4
  345. package/dist/worker/briefing-of.js.map +1 -1
  346. package/dist/worker/resume-message.d.ts.map +1 -1
  347. package/dist/worker/resume-message.js +1 -2
  348. package/dist/worker/resume-message.js.map +1 -1
  349. package/package.json +6 -4
  350. package/templates/architecture/extractable.declared.spec.ts.tpl +2 -2
  351. package/templates/architecture/extractable.manual.spec.ts.tpl +2 -2
  352. package/templates/architecture/extractable.tsyringe.spec.ts.tpl +2 -2
  353. package/templates/architecture/hosting.declared.spec.ts.tpl +69 -0
  354. package/templates/architecture/hosting.manual.spec.ts.tpl +57 -0
  355. package/templates/architecture/hosting.tsyringe.spec.ts.tpl +69 -0
  356. package/templates/background-job/wiring.manual.tpl +1 -1
  357. package/templates/command/wiring.manual.tpl +1 -1
  358. package/templates/context/module.manual.ts.tpl +41 -10
  359. package/templates/erasure-handler/wiring.manual.tpl +1 -1
  360. package/templates/event-handler/wiring.manual.tpl +1 -1
  361. package/templates/file-upload/wiring.manual.tpl +1 -1
  362. package/templates/init/docker/env.example.tpl +9 -1
  363. package/templates/init/e2e/auth-environment.passport.ts.tpl +6 -0
  364. package/templates/init/e2e/create-credentials.passport.ts.tpl +47 -0
  365. package/templates/init/gitignore.tpl +3 -0
  366. package/templates/init/main.ts.tpl +27 -20
  367. package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +11 -3
  368. package/templates/init/platform/auth/authentication/actor-of-token.ts.tpl +15 -0
  369. package/templates/init/platform/auth/authentication/bearer-strategy.ts.tpl +29 -0
  370. package/templates/init/platform/auth/authentication/create-authenticator.passport.ts.tpl +13 -0
  371. package/templates/init/platform/composition/compose-application.manual.ts.tpl +30 -6
  372. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +47 -65
  373. package/templates/init/platform/composition/context-selection.tsyringe.ts.tpl +17 -0
  374. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +16 -1
  375. package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +1 -1
  376. package/templates/init/platform/composition/platform-error-mapper.ts.tpl +9 -0
  377. package/templates/init/platform/composition/platform-options.manual.ts.tpl +9 -0
  378. package/templates/init/platform/composition/platform-test.module.tsyringe.ts.tpl +11 -0
  379. package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +5 -2
  380. package/templates/init/platform/composition/routes-of.tsyringe.ts.tpl +51 -0
  381. package/templates/init/platform/config/app-config.ts.tpl +9 -2
  382. package/templates/init/platform/config/load-config.ts.tpl +27 -2
  383. package/templates/init/platform/database/open-persistence.memory.ts.tpl +10 -0
  384. package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +5 -0
  385. package/templates/init/platform/database/persistence-over.knex.ts.tpl +5 -0
  386. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +5 -0
  387. package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +5 -0
  388. package/templates/init/platform/database/persistence.contract.spec.ts.tpl +18 -0
  389. package/templates/init/platform/database/persistence.memory.ts.tpl +7 -1
  390. package/templates/init/platform/database/persistence.orm.ts.tpl +9 -1
  391. package/templates/init/platform/database/schema.drizzle.ts.tpl +11 -1
  392. package/templates/init/platform/database/schema.prisma.tpl +2 -1
  393. package/templates/init/platform/database/schema.typeorm.ts.tpl +1 -1
  394. package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +18 -6
  395. package/templates/init/platform/files/files.module.tsyringe.ts.tpl +6 -2
  396. package/templates/init/platform/http/start-http-server.express.ts.tpl +10 -1
  397. package/templates/init/platform/http/start-http-server.nest.ts.tpl +6 -1
  398. package/templates/init/platform/jobs/job-settings.ts.tpl +13 -3
  399. package/templates/init/platform/privacy/privacy.module.tsyringe.ts.tpl +9 -6
  400. package/templates/init/platform/redis/open-redis.ts.tpl +13 -8
  401. package/templates/init/rules/presentation.md.tpl +1 -1
  402. package/templates/integration-event/wiring.manual.tpl +1 -1
  403. package/templates/integration-handler/wiring.manual.tpl +1 -1
  404. package/templates/job/job.declared.ts.tpl +1 -1
  405. package/templates/job/job.spec.buses.ts.tpl +3 -0
  406. package/templates/job/job.spec.tsyringe.ts.tpl +29 -1
  407. package/templates/job/wiring.manual.tpl +4 -1
  408. package/templates/job/wiring.tsyringe.tpl +1 -1
  409. package/templates/nest-controller/controller.search.ts.tpl +38 -0
  410. package/templates/nest-controller/controller.ts.tpl +1 -17
  411. package/templates/nest-controller/upload.spec.ts.tpl +47 -0
  412. package/templates/nest-controller/upload.ts.tpl +25 -0
  413. package/templates/pipeline/biome.json.tpl +9 -2
  414. package/templates/pipeline/eslint.config.mjs.tpl +6 -0
  415. package/templates/pipeline/knip.json.tpl +1 -0
  416. package/templates/pipeline/package-scripts.json +2 -2
  417. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +17 -0
  418. package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.controller.nest-routes.ts.tpl +31 -0
  419. package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.controller.nest-routes.ts.tpl +44 -0
  420. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +56 -0
  421. package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.controller.nest-routes.ts.tpl +54 -0
  422. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.controller.nest-routes.ts.tpl +32 -0
  423. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.controller.nest-routes.ts.tpl +43 -0
  424. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.controller.nest-routes.ts.tpl +25 -0
  425. package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.controller.nest-routes.ts.tpl +37 -0
  426. package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.controller.nest-routes.ts.tpl +31 -0
  427. package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.controller.nest-routes.ts.tpl +31 -0
  428. package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.controller.nest-routes.ts.tpl +31 -0
  429. package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.controller.nest-routes.ts.tpl +42 -0
  430. package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +1 -1
  431. package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl +13 -0
  432. package/templates/presets/identity/context/test/unit/accept-invitation.controller.spec.nest-routes.ts.tpl +70 -0
  433. package/templates/presets/identity/context/test/unit/change-member-role.controller.spec.nest-routes.ts.tpl +70 -0
  434. package/templates/presets/identity/context/test/unit/deactivate-account.controller.spec.nest-routes.ts.tpl +57 -0
  435. package/templates/presets/identity/context/test/unit/decline-invitation.controller.spec.nest-routes.ts.tpl +70 -0
  436. package/templates/presets/identity/context/test/unit/grant-delegation.controller.spec.nest-routes.ts.tpl +70 -0
  437. package/templates/presets/identity/context/test/unit/invite-member.controller.spec.nest-routes.ts.tpl +70 -0
  438. package/templates/presets/identity/context/test/unit/open-organisation.controller.spec.nest-routes.ts.tpl +70 -0
  439. package/templates/presets/identity/context/test/unit/provision-account.controller.spec.nest-routes.ts.tpl +99 -0
  440. package/templates/presets/identity/context/test/unit/remove-member.controller.spec.nest-routes.ts.tpl +57 -0
  441. package/templates/presets/identity/context/test/unit/revoke-delegation.controller.spec.nest-routes.ts.tpl +57 -0
  442. package/templates/presets/identity/context/test/unit/revoke-invitation.controller.spec.nest-routes.ts.tpl +57 -0
  443. package/templates/presets/identity/context/test/unit/search-members.controller.spec.nest-routes.ts.tpl +54 -0
  444. package/templates/process/timeout-job.wiring.manual.tpl +1 -1
  445. package/templates/query/search.wiring.manual.tpl +1 -1
  446. package/templates/query/wiring.manual.tpl +1 -1
  447. package/templates/repository/contract.spec.ts.tpl +1 -3
  448. package/templates/repository/event-sourced/contract.spec.ts.tpl +36 -0
  449. package/templates/repository/event-sourced/fake.ts.tpl +24 -0
  450. package/templates/repository/event-sourced/repository.ts.tpl +38 -0
  451. package/templates/repository/event-sourced-first-use.wiring.manual.tpl +4 -0
  452. package/templates/repository/event-sourced.wiring.tsyringe.tpl +6 -0
  453. package/templates/repository/first-use.wiring.manual.tpl +1 -1
  454. package/templates/service/compose.tpl +1 -1
  455. package/templates/service/extracted-name.tpl +2 -0
  456. package/templates/service/extracted.declared.tpl +6 -0
  457. package/templates/service/extracted.manual.tpl +2 -0
  458. package/templates/service/extracted.tsyringe.tpl +6 -0
  459. package/templates/service/main.ts.tpl +5 -1
  460. package/templates/worker/main.ts.tpl +20 -13
  461. /package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/{deactivate-account.controller.ts.tpl → deactivate-account.controller.kit-routes.ts.tpl} +0 -0
  462. /package/templates/presets/identity/context/presentation/http/accounts/provision-account/{provision-account.controller.ts.tpl → provision-account.controller.kit-routes.ts.tpl} +0 -0
  463. /package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/{accept-invitation.controller.ts.tpl → accept-invitation.controller.kit-routes.ts.tpl} +0 -0
  464. /package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/{decline-invitation.controller.ts.tpl → decline-invitation.controller.kit-routes.ts.tpl} +0 -0
  465. /package/templates/presets/identity/context/presentation/http/organisations/change-member-role/{change-member-role.controller.ts.tpl → change-member-role.controller.kit-routes.ts.tpl} +0 -0
  466. /package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/{grant-delegation.controller.ts.tpl → grant-delegation.controller.kit-routes.ts.tpl} +0 -0
  467. /package/templates/presets/identity/context/presentation/http/organisations/invite-member/{invite-member.controller.ts.tpl → invite-member.controller.kit-routes.ts.tpl} +0 -0
  468. /package/templates/presets/identity/context/presentation/http/organisations/open-organisation/{open-organisation.controller.ts.tpl → open-organisation.controller.kit-routes.ts.tpl} +0 -0
  469. /package/templates/presets/identity/context/presentation/http/organisations/remove-member/{remove-member.controller.ts.tpl → remove-member.controller.kit-routes.ts.tpl} +0 -0
  470. /package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/{revoke-delegation.controller.ts.tpl → revoke-delegation.controller.kit-routes.ts.tpl} +0 -0
  471. /package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/{revoke-invitation.controller.ts.tpl → revoke-invitation.controller.kit-routes.ts.tpl} +0 -0
  472. /package/templates/presets/identity/context/presentation/http/organisations/search-members/{search-members.controller.ts.tpl → search-members.controller.kit-routes.ts.tpl} +0 -0
  473. /package/templates/presets/identity/context/test/unit/{accept-invitation.controller.spec.ts.tpl → accept-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  474. /package/templates/presets/identity/context/test/unit/{change-member-role.controller.spec.ts.tpl → change-member-role.controller.spec.kit-routes.ts.tpl} +0 -0
  475. /package/templates/presets/identity/context/test/unit/{deactivate-account.controller.spec.ts.tpl → deactivate-account.controller.spec.kit-routes.ts.tpl} +0 -0
  476. /package/templates/presets/identity/context/test/unit/{decline-invitation.controller.spec.ts.tpl → decline-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  477. /package/templates/presets/identity/context/test/unit/{grant-delegation.controller.spec.ts.tpl → grant-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
  478. /package/templates/presets/identity/context/test/unit/{invite-member.controller.spec.ts.tpl → invite-member.controller.spec.kit-routes.ts.tpl} +0 -0
  479. /package/templates/presets/identity/context/test/unit/{open-organisation.controller.spec.ts.tpl → open-organisation.controller.spec.kit-routes.ts.tpl} +0 -0
  480. /package/templates/presets/identity/context/test/unit/{provision-account.controller.spec.ts.tpl → provision-account.controller.spec.kit-routes.ts.tpl} +0 -0
  481. /package/templates/presets/identity/context/test/unit/{remove-member.controller.spec.ts.tpl → remove-member.controller.spec.kit-routes.ts.tpl} +0 -0
  482. /package/templates/presets/identity/context/test/unit/{revoke-delegation.controller.spec.ts.tpl → revoke-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
  483. /package/templates/presets/identity/context/test/unit/{revoke-invitation.controller.spec.ts.tpl → revoke-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  484. /package/templates/presets/identity/context/test/unit/{search-members.controller.spec.ts.tpl → search-members.controller.spec.kit-routes.ts.tpl} +0 -0
@@ -0,0 +1,57 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { describe, expect, it } from '{{tests.module}}';
3
+ {{#if http.any}}
4
+ import { offlineAuthenticator } from '{{alias.platform}}/auth/authentication/offline-authenticator{{alias.ext}}';
5
+ {{/if}}
6
+ import { composeApplication, everyContext, hostedContexts } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
7
+ import { inertPersistence } from '{{alias.platform}}/database/inert-persistence{{alias.ext}}';
8
+ import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{alias.ext}}';
9
+
10
+ /** The contexts run as services of their own: `ddd-ts-kit generate service` adds one. */
11
+ const extracted: readonly string[] = [
12
+ // ddd-ts-kit:extracted
13
+ // /ddd-ts-kit:extracted
14
+ ];
15
+
16
+ type ContextModule = (typeof everyContext)[number];
17
+
18
+ /** The modules `hostedContexts` leaves out. */
19
+ const services = everyContext.filter((module) => !hostedContexts.includes(module));
20
+
21
+ /** The jobs of the platform are named after its capabilities, and run in the whole application only. */
22
+ const PLATFORM = ['audit', 'privacy', 'files'];
23
+
24
+ const options = {
25
+ events: inProcessEvents(),
26
+ {{#if http.any}}
27
+ authenticator: offlineAuthenticator,
28
+ {{/if}}
29
+ };
30
+
31
+ describe('A context run as a service leaves the whole application', () => {
32
+ // Jest refuses a table without rows: until a context becomes a service, its cases wait.
33
+ if (extracted.length === 0) {
34
+ it.todo('hosts no job of a context run as a service, once the project has one');
35
+ } else {
36
+ it.each(extracted)('%s: the whole application schedules none of its jobs', (name) => {
37
+ const whole = composeApplication(inertPersistence(), options, hostedContexts).platform.jobs.describe();
38
+
39
+ expect(whole.filter((job) => job.name.startsWith(name + '.'))).toEqual([]);
40
+ });
41
+
42
+ it.each(services.map((module, index): [number, ContextModule] => [index + 1, module]))(
43
+ 'extracted context %s: its service schedules the jobs of one context, and none of the platform',
44
+ (_position, module) => {
45
+ const application = composeApplication(inertPersistence(), { ...options, platformJobs: false }, [module]);
46
+ const owners = application.platform.jobs.describe().map((job) => job.name.split('.')[0]);
47
+
48
+ expect(new Set(owners).size).toBeLessThanOrEqual(1);
49
+ expect(owners.filter((owner) => PLATFORM.includes(owner ?? ''))).toEqual([]);
50
+ },
51
+ );
52
+
53
+ it.each(extracted)('%s: its entry point leaves the jobs of the platform to the whole application', (name) => {
54
+ expect(readFileSync('{{config.sourceRoot}}/apps/' + name + '/main.ts', 'utf8')).toContain('platformJobs: false');
55
+ });
56
+ }
57
+ });
@@ -0,0 +1,69 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { describe, expect, it } from '{{tests.module}}';
3
+ import type { WiringDescription } from '@ddd-ts-kit/di';
4
+ {{#if http.any}}
5
+ import { offlineAuthenticator } from '{{alias.platform}}/auth/authentication/offline-authenticator{{alias.ext}}';
6
+ {{/if}}
7
+ import { composeApplication, everyContext, hostedContexts } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
8
+ import { inertPersistence } from '{{alias.platform}}/database/inert-persistence{{alias.ext}}';
9
+ import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{alias.ext}}';
10
+
11
+ /** The contexts run as services of their own: `ddd-ts-kit generate service` adds one. */
12
+ const extracted: readonly string[] = [
13
+ // ddd-ts-kit:extracted
14
+ // /ddd-ts-kit:extracted
15
+ ];
16
+
17
+ const options = {
18
+ events: inProcessEvents(),
19
+ {{#if http.any}}
20
+ authenticator: offlineAuthenticator,
21
+ {{/if}}
22
+ };
23
+
24
+ describe('A context run as a service leaves the whole application', () => {
25
+ // Jest refuses a table without rows: until a context becomes a service, its cases wait.
26
+ if (extracted.length === 0) {
27
+ it.todo('hosts no consumer, process nor job of a context run as a service, once the project has one');
28
+ } else {
29
+ it.each(extracted)('%s: the whole application hosts none of its modules, consumers, processes nor jobs', (name) => {
30
+ const whole = composeApplication(inertPersistence(), options, hostedContexts).container.describe();
31
+
32
+ expect(whole.modules).not.toContain(name);
33
+ expect(registrationsOf(whole, name)).toEqual([]);
34
+ });
35
+
36
+ it.each(extracted)('%s: its service hosts it, each consumer once, and no job of the platform', (name) => {
37
+ const service = composeApplication(
38
+ inertPersistence(),
39
+ { ...options, platformJobs: false },
40
+ { modules: everyContext.modules.filter((module) => module.name === name) },
41
+ ).container.describe();
42
+
43
+ const consumers = service.integrationEventHandlers.map((handler) => `${handler.consumer}:${handler.event}`);
44
+
45
+ expect(service.modules).toContain(name);
46
+ expect(new Set(consumers).size).toBe(consumers.length);
47
+ expect(service.jobs.filter((job) => !job.name.startsWith(name + '.'))).toEqual([]);
48
+ });
49
+
50
+ it.each(extracted)('%s: its entry point leaves the jobs of the platform to the whole application', (name) => {
51
+ expect(readFileSync('{{config.sourceRoot}}/apps/' + name + '/main.ts', 'utf8')).toContain('platformJobs: false');
52
+ });
53
+ }
54
+ });
55
+
56
+ /** What a module registers to be driven by something other than a request: the reactions, the jobs, the projections. */
57
+ function registrationsOf(description: WiringDescription, name: string): readonly string[] {
58
+ return [
59
+ ...description.integrationEventHandlers,
60
+ ...description.domainEventHandlers,
61
+ ...description.projections,
62
+ ...description.jobs,
63
+ ...description.backgroundJobs,
64
+ ...description.commands,
65
+ ...description.queries,
66
+ ]
67
+ .filter(({ module }) => module === name)
68
+ .map((registration) => JSON.stringify(registration));
69
+ }
@@ -1,4 +1,4 @@
1
1
  @@imports
2
2
  import { {{name.pascal}}BackgroundJob } from '{{alias.context}}/application/background/{{name.kebab}}.background-job{{alias.ext}}';
3
- @@registrations
3
+ @@jobs
4
4
  platform.backgroundJobs.register({{name.pascal}}BackgroundJob, [platform.commands]);
@@ -3,7 +3,7 @@
3
3
  {{access.permissionsImport}}
4
4
  import { {{name.pascal}}Command } from '{{alias.context}}/application/commands/{{name.kebab}}/{{name.kebab}}.command{{alias.ext}}';
5
5
  import { {{name.pascal}}Handler } from '{{alias.context}}/application/commands/{{name.kebab}}/{{name.kebab}}.handler{{alias.ext}}';
6
- @@registrations
6
+ @@handlers
7
7
  {{#if command.hasAggregate}}
8
8
  platform.commands.register({{name.pascal}}Command, new {{name.pascal}}Handler({{aggregate.camel}}Repository, platform.ids, platform.clock{{#if access.policy}}, platform.access{{/if}}), { context: '{{context.kebab}}' });
9
9
  {{/if}}
@@ -23,23 +23,54 @@ export interface {{context.pascal}}Wiring {
23
23
  }
24
24
 
25
25
  export function {{context.camel}}Module(platform: Platform): {{context.pascal}}Wiring {
26
- // ddd-ts-kit:registrations
27
- // /ddd-ts-kit:registrations
26
+ registerHandlers(platform);
27
+ registerReactions(platform);
28
+ registerJobs(platform);
28
29
 
29
30
  return {
30
31
  name: '{{context.kebab}}',
31
- useCases: [
32
- // ddd-ts-kit:authorization
33
- // /ddd-ts-kit:authorization
34
- ],
32
+ useCases: declaredUseCases(),
35
33
  {{#if http.any}}
36
- routes: [
37
- // ddd-ts-kit:routes
38
- // /ddd-ts-kit:routes
39
- ],
34
+ routes: routesOf(platform),
40
35
  {{/if}}
41
36
  {{#if routes.nest}}
42
37
  controllers: {{context.camel}}Controllers,
43
38
  {{/if}}
44
39
  };
45
40
  }
41
+
42
+ /** The command and query handlers of the context, with the repositories and readers they are given. */
43
+ function registerHandlers(platform: Platform): void {
44
+ // ddd-ts-kit:handlers
45
+ // /ddd-ts-kit:handlers
46
+ }
47
+
48
+ /** What the context does when an event happens: its own events and those of the other contexts. */
49
+ function registerReactions(platform: Platform): void {
50
+ // ddd-ts-kit:reactions
51
+ // /ddd-ts-kit:reactions
52
+ }
53
+
54
+ /** The jobs of the context, scheduled and in the background. */
55
+ function registerJobs(platform: Platform): void {
56
+ // ddd-ts-kit:jobs
57
+ // /ddd-ts-kit:jobs
58
+ }
59
+
60
+ /** What each use case requires, or that it is public. */
61
+ function declaredUseCases(): UseCaseDeclaration[] {
62
+ return [
63
+ // ddd-ts-kit:authorization
64
+ // /ddd-ts-kit:authorization
65
+ ];
66
+ }
67
+ {{#if http.any}}
68
+
69
+ /** The routes the context answers, over the buses of the platform. */
70
+ function routesOf(platform: Platform): Route[] {
71
+ return [
72
+ // ddd-ts-kit:routes
73
+ // /ddd-ts-kit:routes
74
+ ];
75
+ }
76
+ {{/if}}
@@ -8,7 +8,7 @@ import { on, subscribeAll } from '@ddd-ts-kit/events';
8
8
  import { dataSubjectErasedV1 } from '@ddd-ts-kit/kernel';
9
9
  import { {{personal.names.adapter}} } from '{{alias.context}}/infrastructure/persistence/{{personal.names.adapterKebab}}.repository{{alias.ext}}';
10
10
  import { DataSubjectErasedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/data-subject-erased.integration-handler{{alias.ext}}';
11
- @@registrations
11
+ @@reactions
12
12
  const dataSubjectErasedIntegrationHandler = new DataSubjectErasedIntegrationHandler(platform.adapter(new {{personal.names.adapter}}(platform.persistence.database{{#if tenant.scoped}}, platform.scope{{/if}}), { kind: 'repository', context: '{{context.kebab}}', token: '{{personal.names.port}}' }));
13
13
 
14
14
  {{#if consumer.transactional}}
@@ -1,7 +1,7 @@
1
1
  @@imports
2
2
  import { {{handler.pascal}}EventHandler } from '{{alias.context}}/application/event-handlers/{{handler.kebab}}.event-handler{{alias.ext}}';
3
3
  import { {{event.pascal}} } from '{{alias.context}}/domain/events/{{event.kebab}}.event{{alias.ext}}';
4
- @@registrations
4
+ @@reactions
5
5
  const {{handler.camel}}EventHandler = platform.adapter(new {{handler.pascal}}EventHandler(), { kind: 'domain-event-handler', context: '{{context.kebab}}' });
6
6
 
7
7
  {{#if handler.afterCommit}}
@@ -3,7 +3,7 @@
3
3
  {{access.permissionsImport}}
4
4
  import { {{name.pascal}}Command } from '{{alias.context}}/application/commands/{{name.kebab}}/{{name.kebab}}.command{{alias.ext}}';
5
5
  import { {{name.pascal}}Handler } from '{{alias.context}}/application/commands/{{name.kebab}}/{{name.kebab}}.handler{{alias.ext}}';
6
- @@registrations
6
+ @@handlers
7
7
  platform.commands.register({{name.pascal}}Command, new {{name.pascal}}Handler(platform.files.staging), { context: '{{context.kebab}}' });
8
8
  @@authorization
9
9
  {{access.manualDeclaration}}
@@ -77,7 +77,7 @@ KAFKA_BROKERS=localhost:9092
77
77
  NATS_PORT=4222
78
78
  NATS_URL=nats://localhost:4222
79
79
  {{/if}}
80
- {{#if authn.jwt}}
80
+ {{#if authn.jwks}}
81
81
 
82
82
  # Authentication: the issuer of the tokens, the audience this service answers to, the keys of the issuer.
83
83
  AUTH_ISSUER=https://id.example.com/realms/app
@@ -165,6 +165,14 @@ MINIO_PORT=9000
165
165
  # TRACE_SAMPLE_RATIO=1
166
166
  # continue: a consumed event stays in the trace of the request that published it. link: each delivery starts its own trace, linked to it.
167
167
  # TRACE_CONSUMERS=continue
168
+ # What this process is called in traces and logs: one name per container (the worker, a service) tells the processes apart.
168
169
  OTEL_SERVICE_NAME={{project.name}}
170
+ # What every process of one deployment shares: the namespace of the keys they exchange through the server (the lock of a job, the cache,
171
+ # the rate limiter, the job store). The same for the API, the worker and the services; never the name of a container.
172
+ DEPLOYMENT_NAME={{project.name}}
173
+ {{#if tenancy.any}}
174
+ # The tenants that exist, comma separated: a scheduled job declared per-tenant runs once for each, and the privacy scripts reach each.
175
+ TENANTS=
176
+ {{/if}}
169
177
  JAEGER_UI_PORT=16686
170
178
  OTLP_HTTP_PORT=4318
@@ -0,0 +1,6 @@
1
+ /** What the configuration of the application needs to be valid in a test; no key is ever fetched. */
2
+ export const authEnvironment = {
3
+ AUTH_ISSUER: 'https://issuer.e2e.test',
4
+ AUTH_AUDIENCE: 'e2e',
5
+ AUTH_JWKS_URI: 'https://issuer.e2e.test/keys',
6
+ };
@@ -0,0 +1,47 @@
1
+ import type { Authenticator } from '@ddd-ts-kit/auth';
2
+ import { passportAuthenticator } from '@ddd-ts-kit/auth/passport';
3
+ import type { HttpHeaders } from '@ddd-ts-kit/testing/e2e';
4
+ import { SignJWT, exportSPKI, generateKeyPair, type CryptoKey } from 'jose';
5
+ import { actorOfToken } from '{{alias.platform}}/auth/authentication/actor-of-token{{alias.ext}}';
6
+ import { bearerStrategy } from '{{alias.platform}}/auth/authentication/bearer-strategy{{alias.ext}}';
7
+ import { authEnvironment } from '{{alias.test}}/e2e/support/auth-environment{{alias.ext}}';
8
+
9
+ const issuer = authEnvironment.AUTH_ISSUER;
10
+ const audience = authEnvironment.AUTH_AUDIENCE;
11
+
12
+ /** Who a test calls as: the subject, the roles and the tenant its token carries. */
13
+ export interface TestActor {
14
+ readonly id: string;
15
+ readonly roles?: readonly string[];
16
+ readonly tenantId?: string;
17
+ }
18
+
19
+ export interface Credentials {
20
+ /** The strategy of the platform, on a key pair made for this run: tokens are signed here, verified by the application. */
21
+ readonly authenticator: Authenticator;
22
+
23
+ headersOf(actor: TestActor): Promise<HttpHeaders>;
24
+ }
25
+
26
+ export async function createCredentials(): Promise<Credentials> {
27
+ const { publicKey, privateKey } = await generateKeyPair('RS256', { extractable: true });
28
+ const strategy = bearerStrategy({ issuer, audience, publicKey: await exportSPKI(publicKey) });
29
+
30
+ return {
31
+ authenticator: passportAuthenticator(strategy, { actorOf: actorOfToken }),
32
+ headersOf: async (actor) => ({ authorization: 'Bearer ' + (await tokenOf(actor, privateKey)) }),
33
+ };
34
+ }
35
+
36
+ function tokenOf(actor: TestActor, key: CryptoKey): Promise<string> {
37
+ const claims = { roles: actor.roles ?? [], ...(actor.tenantId === undefined ? {} : { tenant_id: actor.tenantId }) };
38
+
39
+ return new SignJWT(claims)
40
+ .setProtectedHeader({ alg: 'RS256' })
41
+ .setSubject(actor.id)
42
+ .setIssuer(issuer)
43
+ .setAudience(audience)
44
+ .setIssuedAt()
45
+ .setExpirationTime('5m')
46
+ .sign(key);
47
+ }
@@ -6,6 +6,9 @@ dist
6
6
  .ddd-ts-kit/
7
7
  .eslintcache/
8
8
  .worktrees/
9
+ {{#if pm.pnpm}}
10
+ .pnpm-store/
11
+ {{/if}}
9
12
  .stryker-tmp/
10
13
  /reports/mutation/
11
14
  {{#if orm.prisma}}
@@ -11,7 +11,7 @@ import { PurgingPublisher } from '@ddd-ts-kit/kernel';
11
11
  {{#if http.any}}
12
12
  import { createAuthenticator } from '{{alias.platform}}/auth/authentication/create-authenticator{{alias.ext}}';
13
13
  {{/if}}
14
- import { composeApplication } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
14
+ import { composeApplication, hostedContexts } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
15
15
  import { loadConfig } from '{{alias.platform}}/config/load-config{{alias.ext}}';
16
16
  import { openPersistence } from '{{alias.platform}}/database/open-persistence{{alias.ext}}';
17
17
  import { {{events.providerName}} } from '{{alias.platform}}/events/{{events.providerFile}}{{alias.ext}}';
@@ -40,25 +40,32 @@ const persistence = openPersistence();
40
40
  const redis = openRedis(config);
41
41
  {{/if}}
42
42
 
43
- const application = composeApplication(persistence, {
44
- events: {{events.provider}},
45
- {{#if errors.sentry}}
46
- errors,
47
- {{/if}}
48
- {{#if http.any}}
49
- authenticator: createAuthenticator(config),
50
- {{/if}}
51
- log: { ...config.log, service: config.serviceName, environment: config.environment },
52
- traceConsumers: config.tracing.consumers,
53
- resilience: config.resilience,
54
- jobs: { start: config.runJobs, settings: jobSettings(process.env) },
55
- {{#if cache.redis}}
56
- redis,
57
- {{/if}}
58
- {{#if files.any}}
59
- files: openFiles(config.files),
60
- {{/if}}
61
- });
43
+ const application = composeApplication(
44
+ persistence,
45
+ {
46
+ events: {{events.provider}},
47
+ {{#if errors.sentry}}
48
+ errors,
49
+ {{/if}}
50
+ {{#if http.any}}
51
+ authenticator: createAuthenticator(config),
52
+ {{/if}}
53
+ log: { ...config.log, service: config.serviceName, environment: config.environment },
54
+ traceConsumers: config.tracing.consumers,
55
+ resilience: config.resilience,
56
+ jobs: { start: config.runJobs, settings: jobSettings(process.env) },
57
+ {{#if tenancy.any}}
58
+ tenants: config.tenants,
59
+ {{/if}}
60
+ {{#if cache.redis}}
61
+ redis,
62
+ {{/if}}
63
+ {{#if files.any}}
64
+ files: openFiles(config.files),
65
+ {{/if}}
66
+ },
67
+ hostedContexts,
68
+ );
62
69
 
63
70
  await application.start();
64
71
 
@@ -29,7 +29,12 @@ import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-e
29
29
  * the entries older than the twelve whole months kept online moved to the storage of files,
30
30
  * verified and anchored (`audit.archive`){{/if}}.
31
31
  */
32
+ {{#if audit.archive}}
33
+ export function auditModule(audit: Audit, { jobs = true }: { readonly jobs?: boolean } = {}): ContextModule {
34
+ {{/if}}
35
+ {{#unless audit.archive}}
32
36
  export function auditModule(audit: Audit): ContextModule {
37
+ {{/unless}}
33
38
  return defineContextModule({
34
39
  name: 'audit',
35
40
  register(builder) {
@@ -58,9 +63,12 @@ export function auditModule(audit: Audit): ContextModule {
58
63
  {{/if}}
59
64
  {{#if audit.archive}}
60
65
 
61
- builder
62
- .job('audit.archive', { cron: '0 4 1 * *' })
63
- .handledByFactory((resolve) => new ArchiveAuditEntries(audit.trail, resolve(FileStorage), resolve(Clock)));
66
+ // Registered by the process that runs the jobs of the platform; a service of the deployment passes `jobs: false`.
67
+ if (jobs) {
68
+ builder
69
+ .job('audit.archive', { cron: '0 4 1 * *' })
70
+ .handledByFactory((resolve) => new ArchiveAuditEntries(audit.trail, resolve(FileStorage), resolve(Clock)));
71
+ }
64
72
  {{/if}}
65
73
  },
66
74
  onStart({ resolve }) {
@@ -0,0 +1,15 @@
1
+ import { InvalidCredentialError, actorOfClaims } from '@ddd-ts-kit/auth';
2
+ import type { Actor } from '@ddd-ts-kit/kernel';
3
+
4
+ /**
5
+ * The actor the payload of a verified token stands for, as the kit reads claims: `sub`, the roles
6
+ * (`realm_access.roles`, `roles`, then `scope`), the tenant (`tenant_id`) and the profile. Change it
7
+ * here when the tokens of the issuer say these elsewhere.
8
+ */
9
+ export function actorOfToken(payload: unknown): Actor {
10
+ if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
11
+ throw new InvalidCredentialError('NO_CLAIMS');
12
+ }
13
+
14
+ return actorOfClaims({ ...payload });
15
+ }
@@ -0,0 +1,29 @@
1
+ import { passportJwtSecret } from 'jwks-rsa';
2
+ import { ExtractJwt, Strategy } from 'passport-jwt';
3
+
4
+ /** Who issues the tokens and whom they are for, with where the keys that sign them are. */
5
+ export type BearerTokens = {
6
+ readonly issuer: string;
7
+ readonly audience: string;
8
+ } & ({ readonly jwksUri: string } | { readonly publicKey: string });
9
+
10
+ const ALGORITHMS = ['RS256', 'PS256', 'ES256'] as const;
11
+
12
+ /**
13
+ * The strategy of Passport that verifies a bearer token: its signature, against the key set the
14
+ * issuer publishes (or one public key, as the end-to-end tests sign with), its issuer, its
15
+ * audience, its expiry. It hands the payload on as the user; `actorOfToken` reads it.
16
+ */
17
+ export function bearerStrategy(tokens: BearerTokens): Strategy {
18
+ const verified = { jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), issuer: tokens.issuer, audience: tokens.audience, algorithms: [...ALGORITHMS] };
19
+ const handOn = (payload: unknown, done: (error: unknown, user?: unknown) => void): void => done(null, payload);
20
+
21
+ if ('publicKey' in tokens) {
22
+ return new Strategy({ ...verified, secretOrKey: tokens.publicKey }, handOn);
23
+ }
24
+
25
+ return new Strategy(
26
+ { ...verified, secretOrKeyProvider: passportJwtSecret({ jwksUri: tokens.jwksUri, cache: true, rateLimit: true }) },
27
+ handOn,
28
+ );
29
+ }
@@ -0,0 +1,13 @@
1
+ import type { Authenticator } from '@ddd-ts-kit/auth';
2
+ import { passportAuthenticator } from '@ddd-ts-kit/auth/passport';
3
+ import { actorOfToken } from '{{alias.platform}}/auth/authentication/actor-of-token{{alias.ext}}';
4
+ import { bearerStrategy } from '{{alias.platform}}/auth/authentication/bearer-strategy{{alias.ext}}';
5
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
6
+
7
+ /**
8
+ * Verifies the bearer token with the strategy of Passport of the platform, against the keys the
9
+ * issuer publishes; the guards of the routes and the permissions of the use cases then decide.
10
+ */
11
+ export function createAuthenticator(config: AppConfig): Authenticator {
12
+ return passportAuthenticator(bearerStrategy(config.auth), { actorOf: actorOfToken });
13
+ }
@@ -9,7 +9,7 @@ import type { UseCaseDeclaration } from '@ddd-ts-kit/auth';
9
9
  import { subscribeAll } from '@ddd-ts-kit/events';
10
10
  {{/if}}
11
11
  {{#if http.any}}
12
- import { createErrorMapper, defineRoutes, type Route } from '@ddd-ts-kit/http';
12
+ import { defineRoutes, type Route } from '@ddd-ts-kit/http';
13
13
  {{/if}}
14
14
  {{#if routes.nest}}
15
15
  import type { Type } from '@nestjs/common';
@@ -45,6 +45,9 @@ import { withForms } from '{{alias.platform}}/http/with-forms{{alias.ext}}';
45
45
  import { relateSystemActors } from '{{alias.platform}}/auth/relationships/relate-system-actors{{alias.ext}}';
46
46
  {{/if}}
47
47
  import { createPlatform } from '{{alias.platform}}/composition/create-platform{{alias.ext}}';
48
+ {{#if http.any}}
49
+ import { platformErrorMapper } from '{{alias.platform}}/composition/platform-error-mapper{{alias.ext}}';
50
+ {{/if}}
48
51
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
49
52
  {{#if files.http}}
50
53
  import { fileRoutes } from '{{alias.platform}}/files/file-routes{{alias.ext}}';
@@ -83,11 +86,28 @@ export type ApplicationOptions = PlatformOptions;
83
86
  /** Wires one context on the platform. An application hosts all of them here, one alone in `apps/<context>/main.ts`. */
84
87
  type ContextModule = (platform: Platform) => ContextWiring;
85
88
 
86
- const everyContext: readonly ContextModule[] = [
89
+ export const everyContext: readonly ContextModule[] = [
87
90
  // ddd-ts-kit:contexts
88
91
  // /ddd-ts-kit:contexts
89
92
  ];
90
93
 
94
+ /**
95
+ * The contexts run as services of their own (`ddd-ts-kit generate service`): the application
96
+ * `main.ts` and the worker run leaves them out, since their consumers, their processes and their
97
+ * jobs belong to the service, not to both.
98
+ */
99
+ const extracted: readonly ContextModule[] = [
100
+ // ddd-ts-kit:extracted
101
+ // /ddd-ts-kit:extracted
102
+ ];
103
+
104
+ /**
105
+ * What the application of `main.ts` and the worker host: every context but the extracted ones.
106
+ * `everyContext` stays the full list, the default of the tools, the contracts and the end-to-end
107
+ * tests, which see the whole system in one process.
108
+ */
109
+ export const hostedContexts: readonly ContextModule[] = everyContext.filter((module) => !extracted.includes(module));
110
+
91
111
  export interface Application {
92
112
  {{#if http.any}}
93
113
  readonly routes: readonly Route[];
@@ -139,7 +159,7 @@ export function composeApplication(
139
159
 
140
160
  installAspectRuntime({ logger, metrics, cache, clock });
141
161
  {{#if platformJobs.any}}
142
- registerPlatformJobs(platform);
162
+ registerPlatformJobs(platform, options);
143
163
  {{/if}}
144
164
 
145
165
  {{#if audit.route}}
@@ -182,7 +202,7 @@ export function composeApplication(
182
202
  boundary: httpBoundary({
183
203
  authenticator: options.authenticator,
184
204
  executionScope: platform.scope,
185
- errorMapper: createErrorMapper(),
205
+ errorMapper: platformErrorMapper(),
186
206
  clock,
187
207
  logger,
188
208
  {{#if audit.on}}
@@ -273,8 +293,12 @@ async function stop(platform: Platform, options: ApplicationOptions): Promise<vo
273
293
  }
274
294
  {{#if platformJobs.any}}
275
295
 
276
- /** The jobs of the platform itself, run by the process that runs the jobs. */
277
- function registerPlatformJobs(platform: Platform): void {
296
+ /** The jobs of the platform itself, run by the whole application: a service passes `platformJobs: false`. */
297
+ function registerPlatformJobs(platform: Platform, options: ApplicationOptions): void {
298
+ if (options.platformJobs === false) {
299
+ return;
300
+ }
301
+
278
302
  {{#if files.any}}
279
303
  purgeStagedFiles(platform);
280
304
  {{/if}}