ddd-ts-kit 0.89.0 → 0.91.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 (463) hide show
  1. package/CHANGELOG.md +318 -0
  2. package/README.fr.md +58 -12
  3. package/README.md +54 -11
  4. package/dist/alias/index.d.ts +2 -1
  5. package/dist/alias/index.d.ts.map +1 -1
  6. package/dist/alias/index.js +1 -0
  7. package/dist/alias/index.js.map +1 -1
  8. package/dist/alias/mapper-target-text.d.ts +4 -0
  9. package/dist/alias/mapper-target-text.d.ts.map +1 -0
  10. package/dist/alias/mapper-target-text.js +5 -0
  11. package/dist/alias/mapper-target-text.js.map +1 -0
  12. package/dist/alias/module-name-mapper.d.ts +5 -2
  13. package/dist/alias/module-name-mapper.d.ts.map +1 -1
  14. package/dist/alias/module-name-mapper.js +5 -2
  15. package/dist/alias/module-name-mapper.js.map +1 -1
  16. package/dist/check/alias/test-runners.js +8 -3
  17. package/dist/check/alias/test-runners.js.map +1 -1
  18. package/dist/check/baseline/apply-baseline.d.ts +14 -0
  19. package/dist/check/baseline/apply-baseline.d.ts.map +1 -0
  20. package/dist/check/baseline/apply-baseline.js +30 -0
  21. package/dist/check/baseline/apply-baseline.js.map +1 -0
  22. package/dist/check/baseline/baseline-following-moves.d.ts +9 -0
  23. package/dist/check/baseline/baseline-following-moves.d.ts.map +1 -0
  24. package/dist/check/baseline/baseline-following-moves.js +10 -0
  25. package/dist/check/baseline/baseline-following-moves.js.map +1 -0
  26. package/dist/check/baseline/baseline-move.d.ts +6 -0
  27. package/dist/check/baseline/baseline-move.d.ts.map +1 -0
  28. package/dist/check/baseline/baseline-move.js +2 -0
  29. package/dist/check/baseline/baseline-move.js.map +1 -0
  30. package/dist/check/baseline/baseline-text.d.ts +4 -0
  31. package/dist/check/baseline/baseline-text.d.ts.map +1 -0
  32. package/dist/check/baseline/baseline-text.js +12 -0
  33. package/dist/check/baseline/baseline-text.js.map +1 -0
  34. package/dist/check/baseline/baseline.d.ts +6 -0
  35. package/dist/check/baseline/baseline.d.ts.map +1 -0
  36. package/dist/check/baseline/baseline.js +2 -0
  37. package/dist/check/baseline/baseline.js.map +1 -0
  38. package/dist/check/baseline/moved-baseline-text.d.ts +4 -0
  39. package/dist/check/baseline/moved-baseline-text.d.ts.map +1 -0
  40. package/dist/check/baseline/moved-baseline-text.js +13 -0
  41. package/dist/check/baseline/moved-baseline-text.js.map +1 -0
  42. package/dist/check/baseline/parse-baseline.d.ts +4 -0
  43. package/dist/check/baseline/parse-baseline.d.ts.map +1 -0
  44. package/dist/check/baseline/parse-baseline.js +19 -0
  45. package/dist/check/baseline/parse-baseline.js.map +1 -0
  46. package/dist/check/baseline/pruned-baseline.d.ts +5 -0
  47. package/dist/check/baseline/pruned-baseline.d.ts.map +1 -0
  48. package/dist/check/baseline/pruned-baseline.js +14 -0
  49. package/dist/check/baseline/pruned-baseline.js.map +1 -0
  50. package/dist/check/baseline/read-baseline.d.ts +6 -0
  51. package/dist/check/baseline/read-baseline.d.ts.map +1 -0
  52. package/dist/check/baseline/read-baseline.js +11 -0
  53. package/dist/check/baseline/read-baseline.js.map +1 -0
  54. package/dist/check/baseline/recorded-baseline.d.ts +5 -0
  55. package/dist/check/baseline/recorded-baseline.d.ts.map +1 -0
  56. package/dist/check/baseline/recorded-baseline.js +11 -0
  57. package/dist/check/baseline/recorded-baseline.js.map +1 -0
  58. package/dist/check/baseline/renamed-files.d.ts +8 -0
  59. package/dist/check/baseline/renamed-files.d.ts.map +1 -0
  60. package/dist/check/baseline/renamed-files.js +23 -0
  61. package/dist/check/baseline/renamed-files.js.map +1 -0
  62. package/dist/check/baseline/write-baseline.d.ts +4 -0
  63. package/dist/check/baseline/write-baseline.d.ts.map +1 -0
  64. package/dist/check/baseline/write-baseline.js +9 -0
  65. package/dist/check/baseline/write-baseline.js.map +1 -0
  66. package/dist/check/canonical/stray-entry.d.ts.map +1 -1
  67. package/dist/check/canonical/stray-entry.js +5 -1
  68. package/dist/check/canonical/stray-entry.js.map +1 -1
  69. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  70. package/dist/check/catalogue/architecture-rules.js +4 -0
  71. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  72. package/dist/check/catalogue/default-severities.d.ts.map +1 -1
  73. package/dist/check/catalogue/default-severities.js +0 -4
  74. package/dist/check/catalogue/default-severities.js.map +1 -1
  75. package/dist/check/commands/check-command.d.ts.map +1 -1
  76. package/dist/check/commands/check-command.js +46 -1
  77. package/dist/check/commands/check-command.js.map +1 -1
  78. package/dist/check/commands/check-file-command.d.ts +5 -0
  79. package/dist/check/commands/check-file-command.d.ts.map +1 -1
  80. package/dist/check/commands/check-file-command.js +27 -6
  81. package/dist/check/commands/check-file-command.js.map +1 -1
  82. package/dist/check/explain/nest-docs.d.ts +3 -0
  83. package/dist/check/explain/nest-docs.d.ts.map +1 -0
  84. package/dist/check/explain/nest-docs.js +31 -0
  85. package/dist/check/explain/nest-docs.js.map +1 -0
  86. package/dist/check/explain/rule-docs.d.ts.map +1 -1
  87. package/dist/check/explain/rule-docs.js +2 -0
  88. package/dist/check/explain/rule-docs.js.map +1 -1
  89. package/dist/check/fixtures/alias-declared-fixtures.js +1 -1
  90. package/dist/check/fixtures/alias-declared-fixtures.js.map +1 -1
  91. package/dist/check/fixtures/authz-declared-fixtures.js +1 -1
  92. package/dist/check/fixtures/authz-declared-fixtures.js.map +1 -1
  93. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  94. package/dist/check/fixtures/fixtures.js +4 -0
  95. package/dist/check/fixtures/fixtures.js.map +1 -1
  96. package/dist/check/fixtures/nest-controllers-fixtures.d.ts +3 -0
  97. package/dist/check/fixtures/nest-controllers-fixtures.d.ts.map +1 -0
  98. package/dist/check/fixtures/nest-controllers-fixtures.js +86 -0
  99. package/dist/check/fixtures/nest-controllers-fixtures.js.map +1 -0
  100. package/dist/check/fixtures/nest-fixtures.d.ts +3 -0
  101. package/dist/check/fixtures/nest-fixtures.d.ts.map +1 -0
  102. package/dist/check/fixtures/nest-fixtures.js +59 -0
  103. package/dist/check/fixtures/nest-fixtures.js.map +1 -0
  104. package/dist/check/nest/nest-equivalents-of.d.ts +14 -0
  105. package/dist/check/nest/nest-equivalents-of.d.ts.map +1 -0
  106. package/dist/check/nest/nest-equivalents-of.js +119 -0
  107. package/dist/check/nest/nest-equivalents-of.js.map +1 -0
  108. package/dist/check/project/load-project.d.ts +2 -0
  109. package/dist/check/project/load-project.d.ts.map +1 -1
  110. package/dist/check/project/load-project.js +7 -3
  111. package/dist/check/project/load-project.js.map +1 -1
  112. package/dist/check/rules/nest-controllers-current.d.ts +3 -0
  113. package/dist/check/rules/nest-controllers-current.d.ts.map +1 -0
  114. package/dist/check/rules/nest-controllers-current.js +43 -0
  115. package/dist/check/rules/nest-controllers-current.js.map +1 -0
  116. package/dist/check/rules/nest-no-parallel-pipeline.d.ts +3 -0
  117. package/dist/check/rules/nest-no-parallel-pipeline.d.ts.map +1 -0
  118. package/dist/check/rules/nest-no-parallel-pipeline.js +70 -0
  119. package/dist/check/rules/nest-no-parallel-pipeline.js.map +1 -0
  120. package/dist/check/support/is-generated-context-file.d.ts.map +1 -1
  121. package/dist/check/support/is-generated-context-file.js +4 -1
  122. package/dist/check/support/is-generated-context-file.js.map +1 -1
  123. package/dist/commands/doctor.d.ts.map +1 -1
  124. package/dist/commands/doctor.js +4 -2
  125. package/dist/commands/doctor.js.map +1 -1
  126. package/dist/commands/init.d.ts.map +1 -1
  127. package/dist/commands/init.js +1 -0
  128. package/dist/commands/init.js.map +1 -1
  129. package/dist/config/config.d.ts +6 -0
  130. package/dist/config/config.d.ts.map +1 -1
  131. package/dist/config/index.d.ts +1 -1
  132. package/dist/config/index.d.ts.map +1 -1
  133. package/dist/config/index.js +1 -1
  134. package/dist/config/index.js.map +1 -1
  135. package/dist/config/parse-config.js +1 -0
  136. package/dist/config/parse-config.js.map +1 -1
  137. package/dist/config/parse-stack.d.ts.map +1 -1
  138. package/dist/config/parse-stack.js +2 -1
  139. package/dist/config/parse-stack.js.map +1 -1
  140. package/dist/config/serialize-config.js +9 -2
  141. package/dist/config/serialize-config.js.map +1 -1
  142. package/dist/config/stack.d.ts +17 -4
  143. package/dist/config/stack.d.ts.map +1 -1
  144. package/dist/config/stack.js +4 -1
  145. package/dist/config/stack.js.map +1 -1
  146. package/dist/dev/refresh-declarations.d.ts.map +1 -1
  147. package/dist/dev/refresh-declarations.js +4 -1
  148. package/dist/dev/refresh-declarations.js.map +1 -1
  149. package/dist/docs/write-docs.d.ts.map +1 -1
  150. package/dist/docs/write-docs.js +2 -0
  151. package/dist/docs/write-docs.js.map +1 -1
  152. package/dist/doctor/diagnose.d.ts +2 -1
  153. package/dist/doctor/diagnose.d.ts.map +1 -1
  154. package/dist/doctor/diagnose.js +4 -1
  155. package/dist/doctor/diagnose.js.map +1 -1
  156. package/dist/doctor/doctor-finding.d.ts +3 -2
  157. package/dist/doctor/doctor-finding.d.ts.map +1 -1
  158. package/dist/doctor/format-diagnosis.js +4 -1
  159. package/dist/doctor/format-diagnosis.js.map +1 -1
  160. package/dist/doctor/override-findings.d.ts +10 -0
  161. package/dist/doctor/override-findings.d.ts.map +1 -0
  162. package/dist/doctor/override-findings.js +87 -0
  163. package/dist/doctor/override-findings.js.map +1 -0
  164. package/dist/file-moves/move-files.d.ts.map +1 -1
  165. package/dist/file-moves/move-files.js +10 -0
  166. package/dist/file-moves/move-files.js.map +1 -1
  167. package/dist/generate/kinds/property-kind.d.ts +3 -0
  168. package/dist/generate/kinds/property-kind.d.ts.map +1 -0
  169. package/dist/generate/kinds/property-kind.js +51 -0
  170. package/dist/generate/kinds/property-kind.js.map +1 -0
  171. package/dist/generate/kinds/route/nest-controller-vars.d.ts +11 -0
  172. package/dist/generate/kinds/route/nest-controller-vars.d.ts.map +1 -0
  173. package/dist/generate/kinds/route/nest-controller-vars.js +97 -0
  174. package/dist/generate/kinds/route/nest-controller-vars.js.map +1 -0
  175. package/dist/generate/kinds/route/route-vars.d.ts.map +1 -1
  176. package/dist/generate/kinds/route/route-vars.js +1 -9
  177. package/dist/generate/kinds/route/route-vars.js.map +1 -1
  178. package/dist/generate/kinds/route/success-status.d.ts +5 -0
  179. package/dist/generate/kinds/route/success-status.d.ts.map +1 -0
  180. package/dist/generate/kinds/route/success-status.js +11 -0
  181. package/dist/generate/kinds/route/success-status.js.map +1 -0
  182. package/dist/generate/kinds/route/write-nest-controller.d.ts +8 -0
  183. package/dist/generate/kinds/route/write-nest-controller.d.ts.map +1 -0
  184. package/dist/generate/kinds/route/write-nest-controller.js +52 -0
  185. package/dist/generate/kinds/route/write-nest-controller.js.map +1 -0
  186. package/dist/generate/kinds/route-kind.d.ts.map +1 -1
  187. package/dist/generate/kinds/route-kind.js +6 -1
  188. package/dist/generate/kinds/route-kind.js.map +1 -1
  189. package/dist/generate/kinds.d.ts.map +1 -1
  190. package/dist/generate/kinds.js +2 -0
  191. package/dist/generate/kinds.js.map +1 -1
  192. package/dist/generate/refresh-docs.d.ts.map +1 -1
  193. package/dist/generate/refresh-docs.js +2 -0
  194. package/dist/generate/refresh-docs.js.map +1 -1
  195. package/dist/generate/shared-writes.d.ts.map +1 -1
  196. package/dist/generate/shared-writes.js +5 -0
  197. package/dist/generate/shared-writes.js.map +1 -1
  198. package/dist/help/notes.d.ts +1 -1
  199. package/dist/help/notes.d.ts.map +1 -1
  200. package/dist/help/notes.js +3 -1
  201. package/dist/help/notes.js.map +1 -1
  202. package/dist/help/usage.d.ts +1 -1
  203. package/dist/help/usage.d.ts.map +1 -1
  204. package/dist/help/usage.js +4 -2
  205. package/dist/help/usage.js.map +1 -1
  206. package/dist/init/agent-permissions.js +2 -0
  207. package/dist/init/agent-permissions.js.map +1 -1
  208. package/dist/init/files/audit-files.js +1 -1
  209. package/dist/init/files/audit-files.js.map +1 -1
  210. package/dist/init/files/persistence-files.d.ts.map +1 -1
  211. package/dist/init/files/persistence-files.js +2 -0
  212. package/dist/init/files/persistence-files.js.map +1 -1
  213. package/dist/init/knip-vars.d.ts.map +1 -1
  214. package/dist/init/knip-vars.js +10 -2
  215. package/dist/init/knip-vars.js.map +1 -1
  216. package/dist/init/manifest/dependencies-against-stack.d.ts +18 -0
  217. package/dist/init/manifest/dependencies-against-stack.d.ts.map +1 -0
  218. package/dist/init/manifest/dependencies-against-stack.js +95 -0
  219. package/dist/init/manifest/dependencies-against-stack.js.map +1 -0
  220. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  221. package/dist/init/manifest/dependencies-for.js +12 -2
  222. package/dist/init/manifest/dependencies-for.js.map +1 -1
  223. package/dist/init/manifest/overrides-for.d.ts +7 -0
  224. package/dist/init/manifest/overrides-for.d.ts.map +1 -0
  225. package/dist/init/manifest/overrides-for.js +9 -0
  226. package/dist/init/manifest/overrides-for.js.map +1 -0
  227. package/dist/init/manifest/pinned-below-a-fix.d.ts +14 -0
  228. package/dist/init/manifest/pinned-below-a-fix.d.ts.map +1 -0
  229. package/dist/init/manifest/pinned-below-a-fix.js +20 -0
  230. package/dist/init/manifest/pinned-below-a-fix.js.map +1 -0
  231. package/dist/init/manifest/scripts-for.js +5 -2
  232. package/dist/init/manifest/scripts-for.js.map +1 -1
  233. package/dist/init/manifest/versions.d.ts.map +1 -1
  234. package/dist/init/manifest/versions.js +31 -25
  235. package/dist/init/manifest/versions.js.map +1 -1
  236. package/dist/init/manifest/write-overrides.d.ts +9 -0
  237. package/dist/init/manifest/write-overrides.d.ts.map +1 -0
  238. package/dist/init/manifest/write-overrides.js +56 -0
  239. package/dist/init/manifest/write-overrides.js.map +1 -0
  240. package/dist/init/run-init.d.ts.map +1 -1
  241. package/dist/init/run-init.js +19 -3
  242. package/dist/init/run-init.js.map +1 -1
  243. package/dist/init/stack/resolve-queue.d.ts +4 -10
  244. package/dist/init/stack/resolve-queue.d.ts.map +1 -1
  245. package/dist/init/stack/resolve-queue.js +7 -11
  246. package/dist/init/stack/resolve-queue.js.map +1 -1
  247. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  248. package/dist/init/stack/resolve-stack.js +23 -4
  249. package/dist/init/stack/resolve-stack.js.map +1 -1
  250. package/dist/init/stack/stack-options.d.ts +2 -0
  251. package/dist/init/stack/stack-options.d.ts.map +1 -1
  252. package/dist/nest-controllers/controllers-file.d.ts +3 -0
  253. package/dist/nest-controllers/controllers-file.d.ts.map +1 -0
  254. package/dist/nest-controllers/controllers-file.js +5 -0
  255. package/dist/nest-controllers/controllers-file.js.map +1 -0
  256. package/dist/nest-controllers/nest-answer.d.ts +16 -0
  257. package/dist/nest-controllers/nest-answer.d.ts.map +1 -0
  258. package/dist/nest-controllers/nest-answer.js +2 -0
  259. package/dist/nest-controllers/nest-answer.js.map +1 -0
  260. package/dist/nest-controllers/nest-controller-entry.d.ts +16 -0
  261. package/dist/nest-controllers/nest-controller-entry.d.ts.map +1 -0
  262. package/dist/nest-controllers/nest-controller-entry.js +2 -0
  263. package/dist/nest-controllers/nest-controller-entry.js.map +1 -0
  264. package/dist/nest-controllers/read-nest-controllers.d.ts +15 -0
  265. package/dist/nest-controllers/read-nest-controllers.d.ts.map +1 -0
  266. package/dist/nest-controllers/read-nest-controllers.js +89 -0
  267. package/dist/nest-controllers/read-nest-controllers.js.map +1 -0
  268. package/dist/nest-controllers/refresh-nest-controllers.d.ts +9 -0
  269. package/dist/nest-controllers/refresh-nest-controllers.d.ts.map +1 -0
  270. package/dist/nest-controllers/refresh-nest-controllers.js +32 -0
  271. package/dist/nest-controllers/refresh-nest-controllers.js.map +1 -0
  272. package/dist/nest-controllers/render-controllers-file.d.ts +8 -0
  273. package/dist/nest-controllers/render-controllers-file.d.ts.map +1 -0
  274. package/dist/nest-controllers/render-controllers-file.js +56 -0
  275. package/dist/nest-controllers/render-controllers-file.js.map +1 -0
  276. package/dist/platform-folders/platform-folders.d.ts.map +1 -1
  277. package/dist/platform-folders/platform-folders.js +10 -0
  278. package/dist/platform-folders/platform-folders.js.map +1 -1
  279. package/dist/presets/apply-preset.d.ts.map +1 -1
  280. package/dist/presets/apply-preset.js +22 -2
  281. package/dist/presets/apply-preset.js.map +1 -1
  282. package/dist/presets/identity-preset.d.ts.map +1 -1
  283. package/dist/presets/identity-preset.js +4 -1
  284. package/dist/presets/identity-preset.js.map +1 -1
  285. package/dist/presets/identity-refusal.d.ts.map +1 -1
  286. package/dist/presets/identity-refusal.js +11 -5
  287. package/dist/presets/identity-refusal.js.map +1 -1
  288. package/dist/presets/lay-out-prisma-models.d.ts +8 -0
  289. package/dist/presets/lay-out-prisma-models.d.ts.map +1 -0
  290. package/dist/presets/lay-out-prisma-models.js +51 -0
  291. package/dist/presets/lay-out-prisma-models.js.map +1 -0
  292. package/dist/presets/preset-files.d.ts.map +1 -1
  293. package/dist/presets/preset-files.js +3 -0
  294. package/dist/presets/preset-files.js.map +1 -1
  295. package/dist/presets/preset.d.ts +11 -0
  296. package/dist/presets/preset.d.ts.map +1 -1
  297. package/dist/sdk/client-files.d.ts +5 -3
  298. package/dist/sdk/client-files.d.ts.map +1 -1
  299. package/dist/sdk/client-files.js +8 -3
  300. package/dist/sdk/client-files.js.map +1 -1
  301. package/dist/sdk/client-manifest.d.ts +3 -0
  302. package/dist/sdk/client-manifest.d.ts.map +1 -1
  303. package/dist/sdk/client-manifest.js +15 -2
  304. package/dist/sdk/client-manifest.js.map +1 -1
  305. package/dist/sdk/client-operation.d.ts +6 -0
  306. package/dist/sdk/client-operation.d.ts.map +1 -1
  307. package/dist/sdk/read-operation.d.ts.map +1 -1
  308. package/dist/sdk/read-operation.js +6 -0
  309. package/dist/sdk/read-operation.js.map +1 -1
  310. package/dist/sdk/render-orpc.d.ts +8 -0
  311. package/dist/sdk/render-orpc.d.ts.map +1 -0
  312. package/dist/sdk/render-orpc.js +42 -0
  313. package/dist/sdk/render-orpc.js.map +1 -0
  314. package/dist/sdk/render-readme.d.ts +3 -0
  315. package/dist/sdk/render-readme.d.ts.map +1 -1
  316. package/dist/sdk/render-readme.js +46 -0
  317. package/dist/sdk/render-readme.js.map +1 -1
  318. package/dist/sdk/render-trpc.d.ts +9 -0
  319. package/dist/sdk/render-trpc.d.ts.map +1 -0
  320. package/dist/sdk/render-trpc.js +36 -0
  321. package/dist/sdk/render-trpc.js.map +1 -0
  322. package/dist/sdk/rpc-packages.d.ts +7 -0
  323. package/dist/sdk/rpc-packages.d.ts.map +1 -0
  324. package/dist/sdk/rpc-packages.js +9 -0
  325. package/dist/sdk/rpc-packages.js.map +1 -0
  326. package/dist/sdk/rpc.d.ts +4 -0
  327. package/dist/sdk/rpc.d.ts.map +1 -0
  328. package/dist/sdk/rpc.js +2 -0
  329. package/dist/sdk/rpc.js.map +1 -0
  330. package/dist/sdk/write-clients.d.ts.map +1 -1
  331. package/dist/sdk/write-clients.js +18 -3
  332. package/dist/sdk/write-clients.js.map +1 -1
  333. package/dist/stack/alias-vars.d.ts.map +1 -1
  334. package/dist/stack/alias-vars.js +2 -2
  335. package/dist/stack/alias-vars.js.map +1 -1
  336. package/dist/stack/audit-vars.js +1 -1
  337. package/dist/stack/audit-vars.js.map +1 -1
  338. package/dist/stack/cache-vars.d.ts +5 -1
  339. package/dist/stack/cache-vars.d.ts.map +1 -1
  340. package/dist/stack/cache-vars.js +9 -3
  341. package/dist/stack/cache-vars.js.map +1 -1
  342. package/dist/stack/stack-vars.d.ts +1 -1
  343. package/dist/stack/stack-vars.d.ts.map +1 -1
  344. package/dist/stack/stack-vars.js +11 -6
  345. package/dist/stack/stack-vars.js.map +1 -1
  346. package/dist/version.d.ts +1 -1
  347. package/dist/version.js +1 -1
  348. package/package.json +4 -4
  349. package/templates/architecture/extractable.declared.spec.ts.tpl +22 -17
  350. package/templates/architecture/extractable.manual.spec.ts.tpl +14 -9
  351. package/templates/architecture/extractable.tsyringe.spec.ts.tpl +19 -14
  352. package/templates/context/module.manual.ts.tpl +11 -0
  353. package/templates/init/jest.config.js.tpl +6 -0
  354. package/templates/init/platform/composition/compose-application.manual.ts.tpl +50 -0
  355. package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +9 -3
  356. package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +1 -1
  357. package/templates/init/platform/database/persistence-over.knex.ts.tpl +1 -1
  358. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +30 -1
  359. package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +23 -1
  360. package/templates/init/platform/database/persistence.contract.spec.ts.tpl +113 -0
  361. package/templates/init/platform/database/persistence.orm.ts.tpl +8 -3
  362. package/templates/init/platform/database/schema.prisma.tpl +53 -0
  363. package/templates/init/platform/database/schema.typeorm.ts.tpl +17 -3
  364. package/templates/init/platform/database/table-statements.drizzle.ts.tpl +36 -0
  365. package/templates/init/platform/files/bind-files.tsyringe.ts.tpl +1 -1
  366. package/templates/init/platform/files/create-files.ts.tpl +1 -1
  367. package/templates/init/platform/http/create-app-module.ts.tpl +20 -0
  368. package/templates/init/platform/http/start-http-server.express.ts.tpl +48 -1
  369. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +50 -2
  370. package/templates/init/platform/http/start-http-server.hono.ts.tpl +60 -1
  371. package/templates/init/platform/http/start-http-server.nest.ts.tpl +61 -3
  372. package/templates/init/platform/jobs/create-background-work.ts.tpl +2 -2
  373. package/templates/init/rules/infrastructure.md.tpl +3 -0
  374. package/templates/init/rules/presentation.md.tpl +7 -0
  375. package/templates/nest-controller/controller.spec.ts.tpl +57 -0
  376. package/templates/nest-controller/controller.ts.tpl +65 -0
  377. package/templates/pipeline/knip.json.tpl +4 -8
  378. package/templates/pipeline/package-scripts.json +1 -1
  379. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +254 -0
  380. package/templates/presets/identity/context/application/authorization/change-member-roles.policy.ts.tpl +10 -0
  381. package/templates/presets/identity/context/application/authorization/grant-delegations.policy.ts.tpl +10 -0
  382. package/templates/presets/identity/context/application/authorization/invite-members.policy.ts.tpl +10 -0
  383. package/templates/presets/identity/context/application/authorization/read-members.policy.ts.tpl +10 -0
  384. package/templates/presets/identity/context/application/authorization/remove-members.policy.ts.tpl +10 -0
  385. package/templates/presets/identity/context/application/authorization/revoke-delegations.policy.ts.tpl +10 -0
  386. package/templates/presets/identity/context/application/authorization/revoke-invitations.policy.ts.tpl +10 -0
  387. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.command.ts.tpl +6 -0
  388. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +12 -0
  389. package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.command.ts.tpl +6 -0
  390. package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.handler.ts.tpl +12 -0
  391. package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.command.ts.tpl +6 -0
  392. package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.handler.ts.tpl +12 -0
  393. package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.command.ts.tpl +6 -0
  394. package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.handler.ts.tpl +12 -0
  395. package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.command.ts.tpl +6 -0
  396. package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.handler.ts.tpl +12 -0
  397. package/templates/presets/identity/context/application/commands/invite-member/invite-member.command.ts.tpl +6 -0
  398. package/templates/presets/identity/context/application/commands/invite-member/invite-member.handler.ts.tpl +12 -0
  399. package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.command.ts.tpl +6 -0
  400. package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.handler.ts.tpl +12 -0
  401. package/templates/presets/identity/context/application/commands/provision-account/provision-account.command.ts.tpl +6 -0
  402. package/templates/presets/identity/context/application/commands/provision-account/provision-account.handler.ts.tpl +12 -0
  403. package/templates/presets/identity/context/application/commands/remove-member/remove-member.command.ts.tpl +6 -0
  404. package/templates/presets/identity/context/application/commands/remove-member/remove-member.handler.ts.tpl +12 -0
  405. package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.command.ts.tpl +6 -0
  406. package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.handler.ts.tpl +12 -0
  407. package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.command.ts.tpl +6 -0
  408. package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.handler.ts.tpl +12 -0
  409. package/templates/presets/identity/context/application/integration/handlers/account-deactivated.integration-handler.ts.tpl +4 -0
  410. package/templates/presets/identity/context/application/integration/handlers/member-joined.integration-handler.ts.tpl +4 -0
  411. package/templates/presets/identity/context/application/integration/handlers/member-removed.integration-handler.ts.tpl +4 -0
  412. package/templates/presets/identity/context/application/integration/handlers/organisation-opened.integration-handler.ts.tpl +4 -0
  413. package/templates/presets/identity/context/application/integration/publishers/account-deactivated.publisher.ts.tpl +10 -1
  414. package/templates/presets/identity/context/application/integration/publishers/delegation-granted.publisher.ts.tpl +10 -1
  415. package/templates/presets/identity/context/application/integration/publishers/delegation-revoked.publisher.ts.tpl +10 -1
  416. package/templates/presets/identity/context/application/integration/publishers/member-joined.publisher.ts.tpl +10 -1
  417. package/templates/presets/identity/context/application/integration/publishers/member-removed.publisher.ts.tpl +10 -1
  418. package/templates/presets/identity/context/application/integration/publishers/member-role-changed.publisher.ts.tpl +10 -1
  419. package/templates/presets/identity/context/application/integration/publishers/organisation-opened.publisher.ts.tpl +10 -1
  420. package/templates/presets/identity/context/application/queries/search-members/search-members.handler.ts.tpl +12 -0
  421. package/templates/presets/identity/context/application/queries/search-members/search-members.query.ts.tpl +6 -0
  422. package/templates/presets/identity/context/infrastructure/external/crypto-invitation-tokens.adapter.ts.tpl +9 -0
  423. package/templates/presets/identity/context/infrastructure/external/environment-identity-provider-connection.adapter.ts.tpl +9 -0
  424. package/templates/presets/identity/context/infrastructure/external/keycloak-identity-provider-admin.adapter.ts.tpl +9 -0
  425. package/templates/presets/identity/context/infrastructure/persistence/account.mapper.prisma.ts.tpl +36 -0
  426. package/templates/presets/identity/context/infrastructure/persistence/account.personal-fields.privacy.prisma.ts.tpl +19 -0
  427. package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.prisma.ts.tpl +48 -0
  428. package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +9 -0
  429. package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +9 -0
  430. package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +9 -0
  431. package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +9 -0
  432. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +9 -0
  433. package/templates/presets/identity/context/infrastructure/persistence/drizzle-search-members-reader.repository.drizzle.ts.tpl +9 -0
  434. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.prisma.ts.tpl +43 -0
  435. package/templates/presets/identity/context/infrastructure/persistence/invitation.personal-fields.privacy.prisma.ts.tpl +20 -0
  436. package/templates/presets/identity/context/infrastructure/persistence/knex-account.repository.knex.ts.tpl +9 -0
  437. package/templates/presets/identity/context/infrastructure/persistence/knex-delegation.repository.knex.ts.tpl +9 -0
  438. package/templates/presets/identity/context/infrastructure/persistence/knex-invitation.repository.knex.ts.tpl +9 -0
  439. package/templates/presets/identity/context/infrastructure/persistence/knex-member.repository.knex.ts.tpl +9 -0
  440. package/templates/presets/identity/context/infrastructure/persistence/knex-organisation.repository.knex.ts.tpl +9 -0
  441. package/templates/presets/identity/context/infrastructure/persistence/knex-search-members-reader.repository.knex.ts.tpl +9 -0
  442. package/templates/presets/identity/context/infrastructure/persistence/member.mapper.prisma.ts.tpl +34 -0
  443. package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.prisma.ts.tpl +26 -0
  444. package/templates/presets/identity/context/infrastructure/persistence/prisma-account.repository.prisma.ts.tpl +63 -0
  445. package/templates/presets/identity/context/infrastructure/persistence/prisma-delegation.repository.prisma.ts.tpl +81 -0
  446. package/templates/presets/identity/context/infrastructure/persistence/prisma-invitation.repository.prisma.ts.tpl +69 -0
  447. package/templates/presets/identity/context/infrastructure/persistence/prisma-member.repository.prisma.ts.tpl +80 -0
  448. package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation.repository.prisma.ts.tpl +63 -0
  449. package/templates/presets/identity/context/infrastructure/persistence/prisma-search-members-reader.repository.prisma.ts.tpl +82 -0
  450. package/templates/presets/identity/context/test/integration/account.repository.contract.spec.ts.tpl +3 -3
  451. package/templates/presets/identity/context/test/integration/delegation.repository.contract.spec.ts.tpl +5 -5
  452. package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +5 -5
  453. package/templates/presets/identity/context/test/integration/member.repository.contract.spec.ts.tpl +5 -5
  454. package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +3 -3
  455. package/templates/presets/identity/context/test/integration/search-members-reader.spec.ts.tpl +8 -8
  456. package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl +95 -0
  457. package/templates/presets/identity/context/test/worlds/__context__.world.explicit.ts.tpl +332 -0
  458. package/templates/presets/identity/explicit/access-policies.wiring.tpl +16 -0
  459. package/templates/presets/identity/prisma/models.prisma.tpl +128 -0
  460. package/templates/property/value-object.properties.spec.ts.tpl +38 -0
  461. package/templates/sdk/orpc.ts.tpl +46 -0
  462. package/templates/sdk/trpc.ts.tpl +86 -0
  463. /package/templates/presets/identity/context/test/worlds/{__context__.world.ts.tpl → __context__.world.declared.ts.tpl} +0 -0
@@ -2,6 +2,14 @@ import type { Server } from 'node:http';
2
2
  import type { AddressInfo } from 'node:net';
3
3
  import express from 'express';
4
4
  import { mountExpress } from '@ddd-ts-kit/http/express';
5
+ {{#if rpc.orpc}}
6
+ import { orpcRouter } from '@ddd-ts-kit/http/orpc';
7
+ import { RPCHandler } from '@orpc/server/node';
8
+ {{/if}}
9
+ {{#if rpc.trpc}}
10
+ import { trpcRouter } from '@ddd-ts-kit/http/trpc';
11
+ import { createExpressMiddleware } from '@trpc/server/adapters/express';
12
+ {{/if}}
5
13
  import type { Application } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
6
14
  import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
7
15
  {{#if cache.rateLimit}}
@@ -24,7 +32,9 @@ type Served = Pick<Application, 'routes' | 'boundary'{{#if cache.rateLimit}} | '
24
32
  /**
25
33
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
26
34
  * server), the signed file links before any body parser (with a storage the application serves),
27
- * the routes of the contexts, then the pages of the contract (with documentation on).
35
+ * the routes of the contexts, then the pages of the contract (with documentation on).{{#if rpc.orpc}} The same
36
+ * routes are served as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same
37
+ * routes are served as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
28
38
  */
29
39
  export async function startHttpServer(served: Served, config: AppConfig): Promise<HttpServer> {
30
40
  const app = express();
@@ -39,6 +49,9 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
39
49
  mountExpress(app, served.fileRoutes, served.boundary);
40
50
  {{/if}}
41
51
  app.use(express.json());
52
+ {{#unless rpc.none}}
53
+ serveProcedures(app, served);
54
+ {{/unless}}
42
55
  {{#if docs.any}}
43
56
  mountExpress(app, withDocumentation(served.routes, config, served.boundary), served.boundary);
44
57
  {{/if}}
@@ -74,6 +87,40 @@ function limitEachCaller(app: express.Express, served: Served, config: AppConfig
74
87
  });
75
88
  }
76
89
  {{/if}}
90
+ {{#if rpc.orpc}}
91
+
92
+ const RPC_PREFIX = '/rpc';
93
+
94
+ /** Each route as the procedure named by its operationId: the same pipeline, the JSON body already read. */
95
+ function serveProcedures(app: express.Express, served: Served): void {
96
+ const handler = new RPCHandler(orpcRouter(served.routes, served.boundary));
97
+
98
+ app.use(RPC_PREFIX, (request, response, next) => {
99
+ const context = { headers: request.headers, raw: request };
100
+
101
+ void handler.handle(request, response, { prefix: RPC_PREFIX, context }).then(({ matched }) => {
102
+ if (!matched) {
103
+ next();
104
+ }
105
+ }, next);
106
+ });
107
+ }
108
+ {{/if}}
109
+ {{#if rpc.trpc}}
110
+
111
+ const TRPC_ENDPOINT = '/trpc';
112
+
113
+ /** Each route as the procedure named by its operationId: the same pipeline, the JSON body already read. */
114
+ function serveProcedures(app: express.Express, served: Served): void {
115
+ app.use(
116
+ TRPC_ENDPOINT,
117
+ createExpressMiddleware({
118
+ router: trpcRouter(served.routes, served.boundary),
119
+ createContext: ({ req }) => ({ headers: req.headers, raw: req }),
120
+ }),
121
+ );
122
+ }
123
+ {{/if}}
77
124
 
78
125
  function listen(app: express.Express, port: number): Promise<Server> {
79
126
  return new Promise<Server>((resolve) => {
@@ -1,5 +1,13 @@
1
- import Fastify{{#if cache.rateLimit}}, { type FastifyInstance }{{/if}} from 'fastify';
1
+ import Fastify{{#if cache.rateLimit}}, { type FastifyInstance }{{/if}}{{#unless cache.rateLimit}}{{#unless rpc.none}}, { type FastifyInstance }{{/unless}}{{/unless}} from 'fastify';
2
2
  import { mountFastify } from '@ddd-ts-kit/http/fastify';
3
+ {{#if rpc.orpc}}
4
+ import { orpcRouter } from '@ddd-ts-kit/http/orpc';
5
+ import { RPCHandler } from '@orpc/server/fastify';
6
+ {{/if}}
7
+ {{#if rpc.trpc}}
8
+ import { type TrpcRouter, trpcRouter } from '@ddd-ts-kit/http/trpc';
9
+ import { type FastifyTRPCPluginOptions, fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';
10
+ {{/if}}
3
11
  import type { Application } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
4
12
  import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
5
13
  {{#if cache.rateLimit}}
@@ -22,7 +30,9 @@ type Served = Pick<Application, 'routes' | 'boundary'{{#if cache.rateLimit}} | '
22
30
  /**
23
31
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
24
32
  * server), the signed file links (with a storage the application serves), the routes of the
25
- * contexts, then the pages of the contract (with documentation on).
33
+ * contexts, then the pages of the contract (with documentation on).{{#if rpc.orpc}} The same routes are served
34
+ * as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same routes are served
35
+ * as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
26
36
  */
27
37
  export async function startHttpServer(served: Served, config: AppConfig): Promise<HttpServer> {
28
38
  const app = Fastify();
@@ -40,6 +50,12 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
40
50
  {{#unless docs.any}}
41
51
  mountFastify(app, served.routes, served.boundary);
42
52
  {{/unless}}
53
+ {{#if rpc.orpc}}
54
+ serveProcedures(app, served);
55
+ {{/if}}
56
+ {{#if rpc.trpc}}
57
+ await serveProcedures(app, served);
58
+ {{/if}}
43
59
  await app.listen({ port: config.port, host: '0.0.0.0' });
44
60
 
45
61
  const [address] = app.addresses();
@@ -72,3 +88,35 @@ function limitEachCaller(app: FastifyInstance, served: Served, config: AppConfig
72
88
  });
73
89
  }
74
90
  {{/if}}
91
+ {{#if rpc.orpc}}
92
+
93
+ const RPC_PREFIX = '/rpc';
94
+
95
+ /** Each route as the procedure named by its operationId: the same pipeline, the JSON body already read by Fastify. */
96
+ function serveProcedures(app: FastifyInstance, served: Served): void {
97
+ const handler = new RPCHandler(orpcRouter(served.routes, served.boundary));
98
+
99
+ app.all(`${RPC_PREFIX}/*`, async (request, reply) => {
100
+ const context = { headers: request.headers, raw: request };
101
+ const { matched } = await handler.handle(request, reply, { prefix: RPC_PREFIX, context });
102
+
103
+ if (!matched) {
104
+ reply.callNotFound();
105
+ }
106
+ });
107
+ }
108
+ {{/if}}
109
+ {{#if rpc.trpc}}
110
+
111
+ const TRPC_ENDPOINT = '/trpc';
112
+
113
+ /** Each route as the procedure named by its operationId: the same pipeline, the JSON body already read by Fastify. */
114
+ async function serveProcedures(app: FastifyInstance, served: Served): Promise<void> {
115
+ const trpcOptions: FastifyTRPCPluginOptions<TrpcRouter>['trpcOptions'] = {
116
+ router: trpcRouter(served.routes, served.boundary),
117
+ createContext: ({ req }) => ({ headers: req.headers, raw: req }),
118
+ };
119
+
120
+ await app.register(fastifyTRPCPlugin, { prefix: TRPC_ENDPOINT, trpcOptions });
121
+ }
122
+ {{/if}}
@@ -5,6 +5,14 @@ import { getConnInfo } from '@hono/node-server/conninfo';
5
5
  {{/if}}
6
6
  import { Hono } from 'hono';
7
7
  import { mountHono } from '@ddd-ts-kit/http/hono';
8
+ {{#if rpc.orpc}}
9
+ import { orpcRouter } from '@ddd-ts-kit/http/orpc';
10
+ import { RPCHandler } from '@orpc/server/fetch';
11
+ {{/if}}
12
+ {{#if rpc.trpc}}
13
+ import { trpcRouter } from '@ddd-ts-kit/http/trpc';
14
+ import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
15
+ {{/if}}
8
16
  import type { Application } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
9
17
  import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
10
18
  {{#if cache.rateLimit}}
@@ -27,7 +35,9 @@ type Served = Pick<Application, 'routes' | 'boundary'{{#if cache.rateLimit}} | '
27
35
  /**
28
36
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
29
37
  * server), the signed file links (with a storage the application serves), the routes of the
30
- * contexts, then the pages of the contract (with documentation on).
38
+ * contexts, then the pages of the contract (with documentation on).{{#if rpc.orpc}} The same routes are served
39
+ * as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same routes are served
40
+ * as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
31
41
  */
32
42
  export async function startHttpServer(served: Served, config: AppConfig): Promise<HttpServer> {
33
43
  const app = new Hono();
@@ -39,6 +49,9 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
39
49
  {{#if files.http}}
40
50
  mountHono(app, served.fileRoutes, served.boundary);
41
51
  {{/if}}
52
+ {{#unless rpc.none}}
53
+ serveProcedures(app, served);
54
+ {{/unless}}
42
55
  {{#if docs.any}}
43
56
  mountHono(app, withDocumentation(served.routes, config, served.boundary), served.boundary);
44
57
  {{/if}}
@@ -77,6 +90,52 @@ function limitEachCaller(app: Hono, served: Served, config: AppConfig): void {
77
90
  });
78
91
  }
79
92
  {{/if}}
93
+ {{#if rpc.orpc}}
94
+
95
+ const RPC_PREFIX = '/rpc';
96
+
97
+ /** Each route as the procedure named by its operationId: the same pipeline, the raw request what the routes read. */
98
+ function serveProcedures(app: Hono, served: Served): void {
99
+ const handler = new RPCHandler(orpcRouter(served.routes, served.boundary));
100
+
101
+ app.use(`${RPC_PREFIX}/*`, async (context, next) => {
102
+ const headers = context.req.header();
103
+
104
+ const { matched, response } = await handler.handle(context.req.raw, {
105
+ prefix: RPC_PREFIX,
106
+ context: { headers, raw: { headers, context } },
107
+ });
108
+
109
+ if (matched) {
110
+ return context.newResponse(response.body, response);
111
+ }
112
+
113
+ await next();
114
+
115
+ return undefined;
116
+ });
117
+ }
118
+ {{/if}}
119
+ {{#if rpc.trpc}}
120
+
121
+ const TRPC_ENDPOINT = '/trpc';
122
+
123
+ /** Each route as the procedure named by its operationId: the same pipeline, the raw request what the routes read. */
124
+ function serveProcedures(app: Hono, served: Served): void {
125
+ const router = trpcRouter(served.routes, served.boundary);
126
+
127
+ app.all(`${TRPC_ENDPOINT}/*`, (context) => {
128
+ const headers = context.req.header();
129
+
130
+ return fetchRequestHandler({
131
+ endpoint: TRPC_ENDPOINT,
132
+ req: context.req.raw,
133
+ router,
134
+ createContext: () => ({ headers, raw: { headers, context } }),
135
+ });
136
+ });
137
+ }
138
+ {{/if}}
80
139
 
81
140
  function listen(app: Hono, port: number): Promise<ServerType> {
82
141
  return new Promise<ServerType>((resolve) => {
@@ -1,6 +1,14 @@
1
1
  import 'reflect-metadata';
2
- import { Server } from 'node:http';
2
+ import { {{#if rpc.orpc}}type IncomingMessage, {{/if}}{{#if rpc.trpc}}type RequestListener, {{/if}}Server{{#if rpc.orpc}}, type ServerResponse{{/if}} } from 'node:http';
3
3
  import { NestFactory } from '@nestjs/core';
4
+ {{#if rpc.orpc}}
5
+ import { orpcRouter } from '@ddd-ts-kit/http/orpc';
6
+ import { RPCHandler } from '@orpc/server/node';
7
+ {{/if}}
8
+ {{#if rpc.trpc}}
9
+ import { trpcRouter } from '@ddd-ts-kit/http/trpc';
10
+ import { createHTTPHandler } from '@trpc/server/adapters/standalone';
11
+ {{/if}}
4
12
  import type { Application } from '{{alias.platform}}/composition/compose-application{{alias.ext}}';
5
13
  import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
6
14
  import { createAppModule } from '{{alias.platform}}/http/create-app-module{{alias.ext}}';
@@ -19,7 +27,7 @@ export interface HttpServer {
19
27
  }
20
28
 
21
29
  /** What the server needs of the application: its routes and what stands at its edge. */
22
- type Served = Pick<Application, 'routes' | 'boundary'{{#if cache.rateLimit}} | 'rateLimiter' | 'ready'{{/if}}{{#if files.http}} | 'fileRoutes'{{/if}}>;
30
+ type Served = Pick<Application, 'routes' | 'boundary'{{#if routes.nest}} | 'controllers'{{/if}}{{#if cache.rateLimit}} | 'rateLimiter' | 'ready'{{/if}}{{#if files.http}} | 'fileRoutes'{{/if}}>;
23
31
  {{#if cache.rateLimit}}
24
32
 
25
33
  /** The part of the incoming request and of its response the limiter and the probe need, whatever Nest runs on. */
@@ -40,7 +48,9 @@ type Middleware = (request: Incoming, response: Outgoing, next: () => void) => v
40
48
  /**
41
49
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
42
50
  * server), then the routes of the contexts, the pages of the contract (with documentation on) and
43
- * the signed file links (with a storage the application serves), all in one Nest module.
51
+ * the signed file links (with a storage the application serves), all in one Nest module.{{#if rpc.orpc}} The
52
+ * routes of the contexts are served as oRPC procedures under /rpc too, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The
53
+ * routes of the contexts are served as tRPC procedures under /trpc too, for the typed client of the contract.{{/if}}
44
54
  */
45
55
  export async function startHttpServer(served: Served, config: AppConfig): Promise<HttpServer> {
46
56
  {{#if files.http}}
@@ -60,12 +70,27 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
60
70
  {{/unless}}
61
71
  {{/unless}}
62
72
 
73
+ {{#if routes.nest}}
74
+ const app = await NestFactory.create(createAppModule(routes, served.boundary, served.controllers), {
75
+ logger: ['error', 'warn'],
76
+ });
77
+ {{/if}}
78
+ {{#unless routes.nest}}
63
79
  const app = await NestFactory.create(createAppModule(routes, served.boundary), { logger: ['error', 'warn'] });
80
+ {{/unless}}
64
81
 
65
82
  {{#if cache.rateLimit}}
66
83
  app.use(answeringReadiness(served));
67
84
  app.use(limitingEachCaller(served, config));
68
85
 
86
+ {{/if}}
87
+ {{#if rpc.orpc}}
88
+ app.use(RPC_PREFIX, servingProcedures(served));
89
+
90
+ {{/if}}
91
+ {{#if rpc.trpc}}
92
+ app.use(TRPC_ENDPOINT, servingProcedures(served));
93
+
69
94
  {{/if}}
70
95
  await app.listen(config.port);
71
96
 
@@ -103,6 +128,39 @@ function limitingEachCaller(served: Served, config: AppConfig): Middleware {
103
128
  };
104
129
  }
105
130
  {{/if}}
131
+ {{#if rpc.orpc}}
132
+
133
+ const RPC_PREFIX = '/rpc';
134
+
135
+ /** Each route as the procedure named by its operationId: the same pipeline, the JSON body already read by Nest. */
136
+ function servingProcedures(
137
+ served: Served,
138
+ ): (request: IncomingMessage, response: ServerResponse, next: (error?: unknown) => void) => void {
139
+ const handler = new RPCHandler(orpcRouter(served.routes, served.boundary));
140
+
141
+ return (request, response, next) => {
142
+ const context = { headers: request.headers, raw: request };
143
+
144
+ void handler.handle(request, response, { prefix: RPC_PREFIX, context }).then(({ matched }) => {
145
+ if (!matched) {
146
+ next();
147
+ }
148
+ }, next);
149
+ };
150
+ }
151
+ {{/if}}
152
+ {{#if rpc.trpc}}
153
+
154
+ const TRPC_ENDPOINT = '/trpc';
155
+
156
+ /** Each route as the procedure named by its operationId, its path what Nest leaves of the URL: the JSON body already read by Nest. */
157
+ function servingProcedures(served: Served): RequestListener {
158
+ return createHTTPHandler({
159
+ router: trpcRouter(served.routes, served.boundary),
160
+ createContext: ({ req }) => ({ headers: req.headers, raw: req }),
161
+ });
162
+ }
163
+ {{/if}}
106
164
 
107
165
  // Nest types its HTTP server loosely: the port is read only from what proves to be a Node server.
108
166
  function boundPort(server: unknown): number {
@@ -90,10 +90,10 @@ export function createBackgroundWork({
90
90
  processes: new StoredProcessRunner({
91
91
  {{#if queue.processTable}}
92
92
  // The instances of the process managers, saved in the transaction of each step.
93
- store: persistence.processes,
93
+ store: persistence.processes(scope),
94
94
  {{/if}}
95
95
  {{#unless queue.processTable}}
96
- // The instances of the process managers, in the memory of the process: `KnexProcessStore` or `DrizzleProcessStore` keeps them with the steps.
96
+ // The instances of the process managers, in the memory of the process: the process store of the ORM package keeps them with the steps.
97
97
  store: new InMemoryProcessStore(),
98
98
  {{/unless}}
99
99
  jobs: jobQueue,
@@ -11,6 +11,9 @@ paths:
11
11
  {{#if literals.named}}
12
12
  - A word of the other model stays its word: a translator keys its tables by the type of that model, `Record<TheirRecord['code'], InvoiceStatus>` (an annotation or `satisfies`), and compares with `'code' satisfies TheirRecord['code']`, so that the compiler holds its spelling; the value of the context it produces is read from its vocabulary (`language/declared-vocabulary`).
13
13
  {{/if}}
14
+ {{#if http.nest}}
15
+ - An adapter throws no `HttpException` of Nest and logs through the `Logger` of the kernel, not the one of Nest; `@nestjs/config`, `@nestjs/typeorm` and the other modules of Nest whose work the kit does stay out of a context (`nest/no-parallel-pipeline`). `@Injectable()` and `@Inject()` are allowed here, for an adapter bound as a Nest provider.
16
+ {{/if}}
14
17
  - Rows never leave `persistence/`: a mapper translates to and from the aggregate, and is the only place for a type assertion (`clean/no-escape-hatch`).
15
18
  - The content of a file never goes in a table: no binary or base64 column (`persistence/no-file-content`). The file lives in the `FileStorage` port; a row keeps the key, size, media type and checksum of its `StoredFile`.
16
19
  - Own tables, in the schema of the context: no join, foreign key or transaction across contexts (`context/extractable`).
@@ -17,9 +17,16 @@ paths:
17
17
  - A route group (`<resource>.routes.ts`, `@RouteGroup`) gives its controllers a prefix, a tag and guards. A controller names its group, or says `guards: [Public]`: nothing is open by omission (`authz/declared`).
18
18
  - A guard is a control at the edge (authenticated, a role, the tenant of the path); a permission stays on the use case (`@Requires`), where a job and an event handler meet it too. A guard of the project is a declared class in `presentation/http/guards/*.guard.ts` and never imports `domain/`, `infrastructure/`, a repository or the command bus (`presentation/guard-at-the-edge`).
19
19
  {{/if}}
20
+ {{#if routes.nest}}
21
+ - A route is a Nest controller the kit serves: `<use-case>.controller.ts` in `presentation/http/<resource>/<use-case>/`, `@Controller()` and `@KitRoutes({ group: <Resource>Routes })` on the class, `@Post`, `@Get`... of Nest on its method, which names the route (its `operationId`) after the method, and `@KitRoute({ request, response, errors })` of `@ddd-ts-kit/http/nest` for what Nest does not say. The method reads `@Param()`, `@Query()`, `@Headers()`, `@Body()` typed by the DTO classes beside it, and the caller with `@CurrentActor()`; it builds the command or the query and sends it through the bus the constructor injects (`@Inject(CommandBus)`), nothing else: the buses are the only providers the platform gives Nest for the controllers. Nest builds the controller (the module of the context lists it under `controllers`), the kit serves it: guards of the group, validation by `request`, problem documents, the contract.
22
+ - A method answers what its signature says: a DTO class (`Promise<<UseCase>Answer>`), `Accepted` or `void`, which `ddd-ts-kit` reads into the generated `<context>.controllers.ts` the module lists (`nest/controllers-current` keeps it current); any other answer is said in `response` of `@KitRoute`. The raw request and answer of Nest (`@Req`, `@Res`, `@Header`), its guards, pipes, interceptors and filters are refused (`nest/no-parallel-pipeline`): the kit would not run them.
23
+ {{/if}}
20
24
  {{#if routes.functions}}
21
25
  - A route validates the shape of the input, builds a command or a query with the actor, executes it through `CommandBus` or `QueryBus` (never a handler class) and maps the answer. Nothing else.
22
26
  {{/if}}
27
+ {{#if http.nest}}
28
+ - Nothing of Nest's request pipeline in a context: no controller Nest serves, guard, pipe, exception filter, interceptor, raw request or `HttpException` of Nest, no `@nestjs/swagger`, `@nestjs/cqrs` or `@nestjs/passport` (`nest/no-parallel-pipeline`). The routes of the kit do not go through that pipeline, and a Nest controller is a route the kit does not see: no declared security, no problem codes, missing from the contract. A route is the kit's, a right is the permission of the use case, a refusal comes from the code list; each finding names the tool of the kit to use. A Nest controller stays a Nest controller once the kit serves it: `@KitRoute` of `@ddd-ts-kit/http/nest` on each method (its `operationId`, `summary`, `guards`, `errors`), `@CurrentActor()` for the caller, served by `createControllersModule`. Nest stays in the platform, for what reaches no use case.
29
+ {{/if}}
23
30
  - Imports `application/` (and domain types for mapping), never `infrastructure/` (`layer/presentation-no-infrastructure`).
24
31
  - Input shape is validated here with the schema library of the project, behind the `Schema` port. Business rules are not validated here.
25
32
  {{#if refusals.named}}
@@ -0,0 +1,57 @@
1
+ import { describe, expect, it } from '{{tests.module}}';
2
+ import { executeRoute } from '@ddd-ts-kit/http';
3
+ import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
4
+ import { classSchema } from '@ddd-ts-kit/validation/class-validator';
5
+ import { {{route.busClass}}{{#if route.protected}}, type Actor{{/if}} } from '@ddd-ts-kit/kernel';
6
+ {{route.messageImport}}
7
+ {{route.specImports}}
8
+ import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
9
+
10
+ {{#if route.protected}}
11
+ const caller: Actor = { id: 'user-1', type: 'user', roles: [], attributes: {} };
12
+
13
+ {{/if}}
14
+ describe('{{route.method}} {{route.path}}', () => {
15
+ it('answers {{route.status}} when the use case succeeds', async () => {
16
+ {{#if route.isPlainQuery}}
17
+ const {{route.bus}} = new {{route.busClass}}().register({{route.input}}, {
18
+ execute: async () => ({}),
19
+ });
20
+ {{/if}}
21
+ {{#if route.isSearch}}
22
+ const {{route.bus}} = new {{route.busClass}}().register({{route.input}}, {
23
+ execute: async () => ({ items: [{ id: '{{name.kebab}}-1' }], total: 1 }),
24
+ });
25
+ {{/if}}
26
+ {{#if route.returnsId}}
27
+ const {{route.bus}} = new {{route.busClass}}().register({{route.input}}, {
28
+ execute: async () => '{{name.kebab}}-1',
29
+ });
30
+ {{/if}}
31
+ {{#if route.returnsNothing}}
32
+ const {{route.bus}} = new {{route.busClass}}().register({{route.input}}, {
33
+ execute: async () => undefined,
34
+ });
35
+ {{/if}}
36
+
37
+ const route = nestControllerRoute({{name.pascal}}Controller, {
38
+ instanceOf: () => new {{name.pascal}}Controller({{route.specArguments}}),
39
+ // A DTO without a decorated field yet accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
40
+ schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
41
+ });
42
+
43
+ const response = await executeRoute(
44
+ route,
45
+ { params: {{route.sampleParams}}, query: {}, headers: {}, body: {}, raw: undefined },
46
+ { validateResponses: true{{#if route.protected}}, resolvePrincipal: () => caller{{/if}} },
47
+ );
48
+
49
+ expect(response.status).toBe({{route.status}});
50
+ expect(route.path).toBe('{{route.path}}');
51
+ expect({{context.camel}}Controllers).toContain({{name.pascal}}Controller);
52
+ });
53
+
54
+ // TODO(domain): replace each entry below by a test of the contract a client relies on.
55
+ it.todo('refuses an input that does not have the expected shape with 422');
56
+ it.todo('answers the documented status for each error code of the use case');
57
+ });
@@ -0,0 +1,65 @@
1
+ import { {{route.nestImports}} } from '@nestjs/common';
2
+ {{#if route.importsFromTheKit}}
3
+ import { {{route.kitImports}} } from '@ddd-ts-kit/http';
4
+ {{/if}}
5
+ import { {{route.bridgeImports}} } from '@ddd-ts-kit/http/nest';
6
+ import { {{route.kernelImports}} } from '@ddd-ts-kit/kernel';
7
+ {{#if route.readsSchemas}}
8
+ import { classSchema } from '@ddd-ts-kit/validation/class-validator';
9
+ {{/if}}
10
+ {{route.imports}}
11
+
12
+ {{#if route.hasParams}}
13
+ const paramsSchema = classSchema({{name.pascal}}Params);
14
+ {{/if}}
15
+ {{#if route.hasBody}}
16
+ // TODO(domain): once {{name.pascal}}Body has its decorated fields, drop the second argument: it only lets a class without any decorated field through.
17
+ const bodySchema = classSchema({{name.pascal}}Body, { validator: { forbidUnknownValues: false } });
18
+ {{/if}}
19
+ {{#if route.readsSchemas}}
20
+
21
+ {{/if}}
22
+ /** Built by Nest with the bus it injects, served by the kit: what each method answers is read from its signature. */
23
+ @Controller()
24
+ @KitRoutes({ {{route.nestShared}} })
25
+ export class {{name.pascal}}Controller {
26
+ constructor({{route.nestConstructor}}) {}
27
+
28
+ @{{route.nestMethod}}({{route.nestPath}})
29
+ {{#if route.hasHttpCode}}
30
+ @HttpCode({{route.nestHttpCode}})
31
+ {{/if}}
32
+ @KitRoute({
33
+ {{#if route.readsRequest}}
34
+ request: { {{route.nestRequest}} },
35
+ {{/if}}
36
+ // TODO(domain): list the codes of the refusals "{{name.words}}" can raise, as their factories set them, so that they appear in the contract with their status (`errors/known-code`).
37
+ errors: [],
38
+ {{#if route.cached}}
39
+ cache: {{route.cache}},
40
+ {{/if}}
41
+ })
42
+ {{#if route.isQuery}}
43
+ async {{name.camel}}({{route.nestParameters}}): Promise<{{route.answerType}}> {
44
+ // TODO(domain): build the query from the parameters; the caller is already there.
45
+ // TODO(domain): map the answer of the query to the public fields.
46
+ await this.{{route.bus}}.execute({{route.nestMessage}});
47
+
48
+ return {};
49
+ }
50
+ {{/if}}
51
+ {{#if route.returnsId}}
52
+ async {{name.camel}}({{route.nestParameters}}): Promise<{{route.acceptedType}}> {
53
+ // TODO(domain): build the command from the parameters (body, params); the caller is already there.
54
+ const id = await this.{{route.bus}}.execute({{route.nestMessage}});
55
+
56
+ return { id };
57
+ }
58
+ {{/if}}
59
+ {{#if route.returnsNothing}}
60
+ async {{name.camel}}({{route.nestParameters}}): Promise<void> {
61
+ // TODO(domain): build the command from the parameters (body, params); the caller is already there.
62
+ await this.{{route.bus}}.execute({{route.nestMessage}});
63
+ }
64
+ {{/if}}
65
+ }
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "$schema": "https://unpkg.com/knip@6/schema.json",
3
3
  "entry": [
4
- {{#if tests.jest}}
5
- "{{config.contextsDir}}/*/test/fakes/*.ts",
6
- "{{config.contextsDir}}/*/test/worlds/*.ts",
7
- {{/if}}
8
4
  {{#if knip.apps}}
9
5
  "{{config.sourceRoot}}/apps/*/main.ts",
10
6
  {{/if}}
11
- "scripts/*.ts"{{knip.e2eEntry}}
7
+ "scripts/*.ts"{{knip.e2eEntry}}{{knip.toolEntry}}
12
8
  ],
13
- "project": ["{{config.sourceRoot}}/**/*.ts", "scripts/**/*.ts"{{knip.e2eProject}}],
9
+ "project": ["{{config.sourceRoot}}/**/*.ts", "scripts/**/*.ts"{{knip.e2eProject}}{{#if orm.prisma}}, "prisma/**/*.prisma"{{/if}}],
14
10
  {{#if knip.ignores}}
15
11
  "ignoreDependencies": {{knip.ignored}},
16
12
  {{/if}}
@@ -20,8 +16,8 @@
20
16
  "{{config.contextsDir}}/*/*.codes.ts": ["types"]
21
17
  },
22
18
  {{/if}}
23
- "vitest": {
24
- "config": ["vitest.config.ts"{{knip.e2eConfig}}{{knip.mutationConfig}}],
19
+ "{{knip.runner}}": {
20
+ "config": [{{knip.runnerConfigs}}],
25
21
  "entry": [
26
22
  "{{config.sourceRoot}}/**/*.spec.ts",
27
23
  "{{config.contextsDir}}/*/test/fakes/*.ts",
@@ -23,7 +23,7 @@
23
23
  "@biomejs/biome": "2.5.15",
24
24
  "@commitlint/cli": "^21.2.3",
25
25
  "@commitlint/config-conventional": "^21.2.3",
26
- "@ddd-ts-kit/eslint-plugin": "^0.89.0",
26
+ "@ddd-ts-kit/eslint-plugin": "^0.91.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",