ddd-ts-kit 0.91.0 → 0.92.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 (399) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/README.fr.md +16 -12
  3. package/README.md +15 -10
  4. package/dist/acceptance/lock-acceptance.d.ts.map +1 -1
  5. package/dist/acceptance/lock-acceptance.js +2 -1
  6. package/dist/acceptance/lock-acceptance.js.map +1 -1
  7. package/dist/check/event-sourcing/read-stored-shape.d.ts +2 -0
  8. package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -1
  9. package/dist/check/event-sourcing/read-stored-shape.js +3 -1
  10. package/dist/check/event-sourcing/read-stored-shape.js.map +1 -1
  11. package/dist/check/event-sourcing/stored-event-declaration.d.ts +2 -0
  12. package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -1
  13. package/dist/check/event-sourcing/stored-event-declarations.js +1 -0
  14. package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -1
  15. package/dist/check/event-sourcing/stored-shape.d.ts +2 -0
  16. package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -1
  17. package/dist/check/fixtures/nest-controllers-fixtures.d.ts.map +1 -1
  18. package/dist/check/fixtures/nest-controllers-fixtures.js +21 -3
  19. package/dist/check/fixtures/nest-controllers-fixtures.js.map +1 -1
  20. package/dist/check/nest/nest-equivalents-of.d.ts.map +1 -1
  21. package/dist/check/nest/nest-equivalents-of.js +7 -2
  22. package/dist/check/nest/nest-equivalents-of.js.map +1 -1
  23. package/dist/check/rules/nest-controllers-current.d.ts.map +1 -1
  24. package/dist/check/rules/nest-controllers-current.js +13 -2
  25. package/dist/check/rules/nest-controllers-current.js.map +1 -1
  26. package/dist/commands/docs.d.ts.map +1 -1
  27. package/dist/commands/docs.js +13 -5
  28. package/dist/commands/docs.js.map +1 -1
  29. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  30. package/dist/commands/drizzle-generate.js +21 -1
  31. package/dist/commands/drizzle-generate.js.map +1 -1
  32. package/dist/commands/generate.js +2 -0
  33. package/dist/commands/generate.js.map +1 -1
  34. package/dist/commands/prisma-generate.d.ts +7 -0
  35. package/dist/commands/prisma-generate.d.ts.map +1 -0
  36. package/dist/commands/prisma-generate.js +23 -0
  37. package/dist/commands/prisma-generate.js.map +1 -0
  38. package/dist/commands/typeorm-generate.d.ts +10 -0
  39. package/dist/commands/typeorm-generate.d.ts.map +1 -0
  40. package/dist/commands/typeorm-generate.js +37 -0
  41. package/dist/commands/typeorm-generate.js.map +1 -0
  42. package/dist/config/stack.d.ts +1 -1
  43. package/dist/config/stack.d.ts.map +1 -1
  44. package/dist/config/stack.js +1 -1
  45. package/dist/config/stack.js.map +1 -1
  46. package/dist/describe/guard-errors.d.ts +3 -0
  47. package/dist/describe/guard-errors.d.ts.map +1 -0
  48. package/dist/describe/guard-errors.js +10 -0
  49. package/dist/describe/guard-errors.js.map +1 -0
  50. package/dist/describe/no-group.d.ts +4 -0
  51. package/dist/describe/no-group.d.ts.map +1 -0
  52. package/dist/describe/no-group.js +3 -0
  53. package/dist/describe/no-group.js.map +1 -0
  54. package/dist/describe/read-controllers.d.ts +1 -1
  55. package/dist/describe/read-controllers.d.ts.map +1 -1
  56. package/dist/describe/read-controllers.js +12 -19
  57. package/dist/describe/read-controllers.js.map +1 -1
  58. package/dist/describe/read-nest-controller-routes.d.ts +16 -0
  59. package/dist/describe/read-nest-controller-routes.d.ts.map +1 -0
  60. package/dist/describe/read-nest-controller-routes.js +117 -0
  61. package/dist/describe/read-nest-controller-routes.js.map +1 -0
  62. package/dist/describe/schema-class-of.d.ts +3 -0
  63. package/dist/describe/schema-class-of.d.ts.map +1 -0
  64. package/dist/describe/schema-class-of.js +10 -0
  65. package/dist/describe/schema-class-of.js.map +1 -0
  66. package/dist/docs/declared-stored-events.d.ts +6 -2
  67. package/dist/docs/declared-stored-events.d.ts.map +1 -1
  68. package/dist/docs/declared-stored-events.js +4 -3
  69. package/dist/docs/declared-stored-events.js.map +1 -1
  70. package/dist/docs/emptily-recorded-stored-events.d.ts +6 -0
  71. package/dist/docs/emptily-recorded-stored-events.d.ts.map +1 -0
  72. package/dist/docs/emptily-recorded-stored-events.js +12 -0
  73. package/dist/docs/emptily-recorded-stored-events.js.map +1 -0
  74. package/dist/docs/refuse-unreadable-stored-events.d.ts +7 -0
  75. package/dist/docs/refuse-unreadable-stored-events.d.ts.map +1 -0
  76. package/dist/docs/refuse-unreadable-stored-events.js +27 -0
  77. package/dist/docs/refuse-unreadable-stored-events.js.map +1 -0
  78. package/dist/docs/write-stored-events-lock.d.ts +3 -2
  79. package/dist/docs/write-stored-events-lock.d.ts.map +1 -1
  80. package/dist/docs/write-stored-events-lock.js +5 -2
  81. package/dist/docs/write-stored-events-lock.js.map +1 -1
  82. package/dist/generate/kind.d.ts +2 -0
  83. package/dist/generate/kind.d.ts.map +1 -1
  84. package/dist/generate/kinds/aggregate-kind.d.ts.map +1 -1
  85. package/dist/generate/kinds/aggregate-kind.js +6 -2
  86. package/dist/generate/kinds/aggregate-kind.js.map +1 -1
  87. package/dist/generate/kinds/assert-event-store.d.ts +4 -0
  88. package/dist/generate/kinds/assert-event-store.d.ts.map +1 -0
  89. package/dist/generate/kinds/assert-event-store.js +10 -0
  90. package/dist/generate/kinds/assert-event-store.js.map +1 -0
  91. package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts +9 -0
  92. package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts.map +1 -0
  93. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js +49 -0
  94. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js.map +1 -0
  95. package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -1
  96. package/dist/generate/kinds/file-upload-kind.js +9 -2
  97. package/dist/generate/kinds/file-upload-kind.js.map +1 -1
  98. package/dist/generate/kinds/form-kind.d.ts.map +1 -1
  99. package/dist/generate/kinds/form-kind.js +15 -11
  100. package/dist/generate/kinds/form-kind.js.map +1 -1
  101. package/dist/generate/kinds/generate-event-sourced-repository.d.ts +11 -0
  102. package/dist/generate/kinds/generate-event-sourced-repository.d.ts.map +1 -0
  103. package/dist/generate/kinds/generate-event-sourced-repository.js +48 -0
  104. package/dist/generate/kinds/generate-event-sourced-repository.js.map +1 -0
  105. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  106. package/dist/generate/kinds/generate-repository.js +5 -0
  107. package/dist/generate/kinds/generate-repository.js.map +1 -1
  108. package/dist/generate/kinds/is-event-sourced.d.ts +9 -0
  109. package/dist/generate/kinds/is-event-sourced.d.ts.map +1 -0
  110. package/dist/generate/kinds/is-event-sourced.js +11 -0
  111. package/dist/generate/kinds/is-event-sourced.js.map +1 -0
  112. package/dist/generate/kinds/presentation/controller-source.d.ts +11 -3
  113. package/dist/generate/kinds/presentation/controller-source.d.ts.map +1 -1
  114. package/dist/generate/kinds/presentation/controller-source.js +25 -4
  115. package/dist/generate/kinds/presentation/controller-source.js.map +1 -1
  116. package/dist/generate/kinds/repository-kind.js +1 -1
  117. package/dist/generate/kinds/repository-kind.js.map +1 -1
  118. package/dist/generate/kinds/representation-kind.d.ts.map +1 -1
  119. package/dist/generate/kinds/representation-kind.js +4 -3
  120. package/dist/generate/kinds/representation-kind.js.map +1 -1
  121. package/dist/generate/kinds/route/nest-controller-vars.d.ts +2 -2
  122. package/dist/generate/kinds/route/nest-controller-vars.js +3 -9
  123. package/dist/generate/kinds/route/nest-controller-vars.js.map +1 -1
  124. package/dist/generate/kinds/route/nest-search-vars.d.ts +6 -0
  125. package/dist/generate/kinds/route/nest-search-vars.d.ts.map +1 -0
  126. package/dist/generate/kinds/route/nest-search-vars.js +18 -0
  127. package/dist/generate/kinds/route/nest-search-vars.js.map +1 -0
  128. package/dist/generate/kinds/route/write-nest-controller.d.ts.map +1 -1
  129. package/dist/generate/kinds/route/write-nest-controller.js +6 -8
  130. package/dist/generate/kinds/route/write-nest-controller.js.map +1 -1
  131. package/dist/generate/kinds/route-kind.js +1 -1
  132. package/dist/generate/kinds/route-kind.js.map +1 -1
  133. package/dist/generate/kinds/wire-repository-on-first-use.d.ts.map +1 -1
  134. package/dist/generate/kinds/wire-repository-on-first-use.js +2 -1
  135. package/dist/generate/kinds/wire-repository-on-first-use.js.map +1 -1
  136. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
  137. package/dist/generate/kinds/write-event-sourced-aggregate.js +5 -13
  138. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
  139. package/dist/help/notes.d.ts +1 -1
  140. package/dist/help/notes.d.ts.map +1 -1
  141. package/dist/help/notes.js +3 -1
  142. package/dist/help/notes.js.map +1 -1
  143. package/dist/help/usage.d.ts +1 -1
  144. package/dist/help/usage.d.ts.map +1 -1
  145. package/dist/help/usage.js +3 -1
  146. package/dist/help/usage.js.map +1 -1
  147. package/dist/init/agent-permissions.js +10 -6
  148. package/dist/init/agent-permissions.js.map +1 -1
  149. package/dist/init/files/auth-files.js +4 -0
  150. package/dist/init/files/auth-files.js.map +1 -1
  151. package/dist/init/files/platform-files.js +1 -0
  152. package/dist/init/files/platform-files.js.map +1 -1
  153. package/dist/init/knip-vars.js +4 -3
  154. package/dist/init/knip-vars.js.map +1 -1
  155. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  156. package/dist/init/manifest/database-scripts.js +10 -4
  157. package/dist/init/manifest/database-scripts.js.map +1 -1
  158. package/dist/init/manifest/dependencies-against-stack.d.ts.map +1 -1
  159. package/dist/init/manifest/dependencies-against-stack.js +5 -1
  160. package/dist/init/manifest/dependencies-against-stack.js.map +1 -1
  161. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  162. package/dist/init/manifest/dependencies-for.js +7 -1
  163. package/dist/init/manifest/dependencies-for.js.map +1 -1
  164. package/dist/init/manifest/versions.d.ts.map +1 -1
  165. package/dist/init/manifest/versions.js +34 -30
  166. package/dist/init/manifest/versions.js.map +1 -1
  167. package/dist/init/stack/resolve-stack.js +9 -7
  168. package/dist/init/stack/resolve-stack.js.map +1 -1
  169. package/dist/init/template-vars.js +1 -1
  170. package/dist/init/template-vars.js.map +1 -1
  171. package/dist/init/write-type-script-configs.d.ts.map +1 -1
  172. package/dist/init/write-type-script-configs.js +4 -1
  173. package/dist/init/write-type-script-configs.js.map +1 -1
  174. package/dist/markers/insert-in-region.js +1 -1
  175. package/dist/markers/insert-in-region.js.map +1 -1
  176. package/dist/merge/lost/untouched-by-branch.d.ts +12 -0
  177. package/dist/merge/lost/untouched-by-branch.d.ts.map +1 -0
  178. package/dist/merge/lost/untouched-by-branch.js +22 -0
  179. package/dist/merge/lost/untouched-by-branch.js.map +1 -0
  180. package/dist/merge/lost/verify-merge.d.ts.map +1 -1
  181. package/dist/merge/lost/verify-merge.js +6 -1
  182. package/dist/merge/lost/verify-merge.js.map +1 -1
  183. package/dist/migration/audit-guard/append-audit-guard.d.ts +18 -0
  184. package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -0
  185. package/dist/migration/audit-guard/append-audit-guard.js +27 -0
  186. package/dist/migration/audit-guard/append-audit-guard.js.map +1 -0
  187. package/dist/migration/audit-guard/audit-guard-statements-of.d.ts +7 -0
  188. package/dist/migration/audit-guard/audit-guard-statements-of.d.ts.map +1 -0
  189. package/dist/migration/audit-guard/audit-guard-statements-of.js +18 -0
  190. package/dist/migration/audit-guard/audit-guard-statements-of.js.map +1 -0
  191. package/dist/migration/audit-guard/audit-schema-created.d.ts +3 -0
  192. package/dist/migration/audit-guard/audit-schema-created.d.ts.map +1 -0
  193. package/dist/migration/audit-guard/audit-schema-created.js +9 -0
  194. package/dist/migration/audit-guard/audit-schema-created.js.map +1 -0
  195. package/dist/migration/audit-guard/generate-guarded.d.ts +16 -0
  196. package/dist/migration/audit-guard/generate-guarded.d.ts.map +1 -0
  197. package/dist/migration/audit-guard/generate-guarded.js +22 -0
  198. package/dist/migration/audit-guard/generate-guarded.js.map +1 -0
  199. package/dist/migration/audit-guard/guard-marker.d.ts +3 -0
  200. package/dist/migration/audit-guard/guard-marker.d.ts.map +1 -0
  201. package/dist/migration/audit-guard/guard-marker.js +3 -0
  202. package/dist/migration/audit-guard/guard-marker.js.map +1 -0
  203. package/dist/migration/audit-guard/guarded-text.d.ts +5 -0
  204. package/dist/migration/audit-guard/guarded-text.d.ts.map +1 -0
  205. package/dist/migration/audit-guard/guarded-text.js +26 -0
  206. package/dist/migration/audit-guard/guarded-text.js.map +1 -0
  207. package/dist/migration/audit-guard/migrations-under.d.ts +3 -0
  208. package/dist/migration/audit-guard/migrations-under.d.ts.map +1 -0
  209. package/dist/migration/audit-guard/migrations-under.js +15 -0
  210. package/dist/migration/audit-guard/migrations-under.js.map +1 -0
  211. package/dist/migration/audit-guard/run-orm-tool.d.ts +3 -0
  212. package/dist/migration/audit-guard/run-orm-tool.d.ts.map +1 -0
  213. package/dist/migration/audit-guard/run-orm-tool.js +13 -0
  214. package/dist/migration/audit-guard/run-orm-tool.js.map +1 -0
  215. package/dist/migration/audit-guard/schemas-first.d.ts +6 -0
  216. package/dist/migration/audit-guard/schemas-first.d.ts.map +1 -0
  217. package/dist/migration/audit-guard/schemas-first.js +17 -0
  218. package/dist/migration/audit-guard/schemas-first.js.map +1 -0
  219. package/dist/migration/audit-guard/schemas-if-missing.d.ts +7 -0
  220. package/dist/migration/audit-guard/schemas-if-missing.d.ts.map +1 -0
  221. package/dist/migration/audit-guard/schemas-if-missing.js +9 -0
  222. package/dist/migration/audit-guard/schemas-if-missing.js.map +1 -0
  223. package/dist/migration/audit-guard/type-only-imports.d.ts +6 -0
  224. package/dist/migration/audit-guard/type-only-imports.d.ts.map +1 -0
  225. package/dist/migration/audit-guard/type-only-imports.js +8 -0
  226. package/dist/migration/audit-guard/type-only-imports.js.map +1 -0
  227. package/dist/migration/format-as-the-project.d.ts +4 -0
  228. package/dist/migration/format-as-the-project.d.ts.map +1 -0
  229. package/dist/migration/format-as-the-project.js +27 -0
  230. package/dist/migration/format-as-the-project.js.map +1 -0
  231. package/dist/migration/format-written-files.d.ts.map +1 -1
  232. package/dist/migration/format-written-files.js +2 -24
  233. package/dist/migration/format-written-files.js.map +1 -1
  234. package/dist/migration/index.d.ts +8 -0
  235. package/dist/migration/index.d.ts.map +1 -1
  236. package/dist/migration/index.js +8 -0
  237. package/dist/migration/index.js.map +1 -1
  238. package/dist/nest-controllers/nest-answer.d.ts +2 -10
  239. package/dist/nest-controllers/nest-answer.d.ts.map +1 -1
  240. package/dist/nest-controllers/nest-controller-entry.d.ts +4 -2
  241. package/dist/nest-controllers/nest-controller-entry.d.ts.map +1 -1
  242. package/dist/nest-controllers/nest-controllers-in.d.ts +6 -0
  243. package/dist/nest-controllers/nest-controllers-in.d.ts.map +1 -0
  244. package/dist/nest-controllers/nest-controllers-in.js +108 -0
  245. package/dist/nest-controllers/nest-controllers-in.js.map +1 -0
  246. package/dist/nest-controllers/nest-read-type.d.ts +12 -0
  247. package/dist/nest-controllers/nest-read-type.d.ts.map +1 -0
  248. package/dist/nest-controllers/nest-read-type.js +2 -0
  249. package/dist/nest-controllers/nest-read-type.js.map +1 -0
  250. package/dist/nest-controllers/nest-request-part.d.ts +9 -0
  251. package/dist/nest-controllers/nest-request-part.d.ts.map +1 -0
  252. package/dist/nest-controllers/nest-request-part.js +2 -0
  253. package/dist/nest-controllers/nest-request-part.js.map +1 -0
  254. package/dist/nest-controllers/parameters-of.d.ts +8 -0
  255. package/dist/nest-controllers/parameters-of.d.ts.map +1 -0
  256. package/dist/nest-controllers/parameters-of.js +32 -0
  257. package/dist/nest-controllers/parameters-of.js.map +1 -0
  258. package/dist/nest-controllers/project-files.d.ts +6 -0
  259. package/dist/nest-controllers/project-files.d.ts.map +1 -0
  260. package/dist/nest-controllers/project-files.js +2 -0
  261. package/dist/nest-controllers/project-files.js.map +1 -0
  262. package/dist/nest-controllers/read-nest-controllers.d.ts +6 -9
  263. package/dist/nest-controllers/read-nest-controllers.d.ts.map +1 -1
  264. package/dist/nest-controllers/read-nest-controllers.js +10 -82
  265. package/dist/nest-controllers/read-nest-controllers.js.map +1 -1
  266. package/dist/nest-controllers/render-controllers-file.d.ts +4 -3
  267. package/dist/nest-controllers/render-controllers-file.d.ts.map +1 -1
  268. package/dist/nest-controllers/render-controllers-file.js +45 -29
  269. package/dist/nest-controllers/render-controllers-file.js.map +1 -1
  270. package/dist/platform-layout/platform-layout.d.ts +3 -0
  271. package/dist/platform-layout/platform-layout.d.ts.map +1 -1
  272. package/dist/platform-layout/platform-layout.js +3 -0
  273. package/dist/platform-layout/platform-layout.js.map +1 -1
  274. package/dist/presets/identity-refusal.js +3 -3
  275. package/dist/presets/identity-refusal.js.map +1 -1
  276. package/dist/presets/preset-files.d.ts.map +1 -1
  277. package/dist/presets/preset-files.js +3 -1
  278. package/dist/presets/preset-files.js.map +1 -1
  279. package/dist/run.d.ts.map +1 -1
  280. package/dist/run.js +4 -0
  281. package/dist/run.js.map +1 -1
  282. package/dist/stack/authentication-vars.d.ts.map +1 -1
  283. package/dist/stack/authentication-vars.js +8 -2
  284. package/dist/stack/authentication-vars.js.map +1 -1
  285. package/dist/version.d.ts +1 -1
  286. package/dist/version.js +1 -1
  287. package/dist/worker/briefing-of.d.ts.map +1 -1
  288. package/dist/worker/briefing-of.js +2 -4
  289. package/dist/worker/briefing-of.js.map +1 -1
  290. package/dist/worker/resume-message.d.ts.map +1 -1
  291. package/dist/worker/resume-message.js +1 -2
  292. package/dist/worker/resume-message.js.map +1 -1
  293. package/package.json +6 -4
  294. package/templates/background-job/wiring.manual.tpl +1 -1
  295. package/templates/command/wiring.manual.tpl +1 -1
  296. package/templates/context/module.manual.ts.tpl +41 -10
  297. package/templates/erasure-handler/wiring.manual.tpl +1 -1
  298. package/templates/event-handler/wiring.manual.tpl +1 -1
  299. package/templates/file-upload/wiring.manual.tpl +1 -1
  300. package/templates/init/docker/env.example.tpl +1 -1
  301. package/templates/init/e2e/auth-environment.passport.ts.tpl +6 -0
  302. package/templates/init/e2e/create-credentials.passport.ts.tpl +47 -0
  303. package/templates/init/platform/auth/authentication/actor-of-token.ts.tpl +15 -0
  304. package/templates/init/platform/auth/authentication/bearer-strategy.ts.tpl +29 -0
  305. package/templates/init/platform/auth/authentication/create-authenticator.passport.ts.tpl +13 -0
  306. package/templates/init/platform/composition/compose-application.manual.ts.tpl +5 -2
  307. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +1 -1
  308. package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +1 -1
  309. package/templates/init/platform/composition/platform-error-mapper.ts.tpl +9 -0
  310. package/templates/init/platform/composition/platform-test.module.tsyringe.ts.tpl +11 -0
  311. package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +5 -2
  312. package/templates/init/platform/config/app-config.ts.tpl +2 -2
  313. package/templates/init/platform/config/load-config.ts.tpl +2 -2
  314. package/templates/init/platform/database/open-persistence.memory.ts.tpl +10 -0
  315. package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +5 -0
  316. package/templates/init/platform/database/persistence-over.knex.ts.tpl +5 -0
  317. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +5 -0
  318. package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +5 -0
  319. package/templates/init/platform/database/persistence.contract.spec.ts.tpl +18 -0
  320. package/templates/init/platform/database/persistence.memory.ts.tpl +7 -1
  321. package/templates/init/platform/database/persistence.orm.ts.tpl +9 -1
  322. package/templates/init/platform/database/schema.drizzle.ts.tpl +11 -1
  323. package/templates/init/platform/database/schema.prisma.tpl +2 -1
  324. package/templates/init/platform/database/schema.typeorm.ts.tpl +1 -1
  325. package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +18 -6
  326. package/templates/init/platform/http/start-http-server.express.ts.tpl +10 -1
  327. package/templates/init/platform/http/start-http-server.nest.ts.tpl +6 -1
  328. package/templates/init/rules/presentation.md.tpl +1 -1
  329. package/templates/integration-event/wiring.manual.tpl +1 -1
  330. package/templates/integration-handler/wiring.manual.tpl +1 -1
  331. package/templates/job/wiring.manual.tpl +1 -1
  332. package/templates/nest-controller/controller.search.ts.tpl +38 -0
  333. package/templates/nest-controller/controller.ts.tpl +1 -17
  334. package/templates/nest-controller/upload.spec.ts.tpl +47 -0
  335. package/templates/nest-controller/upload.ts.tpl +25 -0
  336. package/templates/pipeline/biome.json.tpl +2 -2
  337. package/templates/pipeline/eslint.config.mjs.tpl +6 -0
  338. package/templates/pipeline/package-scripts.json +2 -2
  339. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +17 -0
  340. package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.controller.nest-routes.ts.tpl +31 -0
  341. package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.controller.nest-routes.ts.tpl +44 -0
  342. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +56 -0
  343. package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.controller.nest-routes.ts.tpl +54 -0
  344. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.controller.nest-routes.ts.tpl +32 -0
  345. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.controller.nest-routes.ts.tpl +43 -0
  346. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.controller.nest-routes.ts.tpl +25 -0
  347. package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.controller.nest-routes.ts.tpl +37 -0
  348. package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.controller.nest-routes.ts.tpl +31 -0
  349. package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.controller.nest-routes.ts.tpl +31 -0
  350. package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.controller.nest-routes.ts.tpl +31 -0
  351. package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.controller.nest-routes.ts.tpl +42 -0
  352. package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +1 -1
  353. package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl +13 -0
  354. package/templates/presets/identity/context/test/unit/accept-invitation.controller.spec.nest-routes.ts.tpl +70 -0
  355. package/templates/presets/identity/context/test/unit/change-member-role.controller.spec.nest-routes.ts.tpl +70 -0
  356. package/templates/presets/identity/context/test/unit/deactivate-account.controller.spec.nest-routes.ts.tpl +57 -0
  357. package/templates/presets/identity/context/test/unit/decline-invitation.controller.spec.nest-routes.ts.tpl +70 -0
  358. package/templates/presets/identity/context/test/unit/grant-delegation.controller.spec.nest-routes.ts.tpl +70 -0
  359. package/templates/presets/identity/context/test/unit/invite-member.controller.spec.nest-routes.ts.tpl +70 -0
  360. package/templates/presets/identity/context/test/unit/open-organisation.controller.spec.nest-routes.ts.tpl +70 -0
  361. package/templates/presets/identity/context/test/unit/provision-account.controller.spec.nest-routes.ts.tpl +99 -0
  362. package/templates/presets/identity/context/test/unit/remove-member.controller.spec.nest-routes.ts.tpl +57 -0
  363. package/templates/presets/identity/context/test/unit/revoke-delegation.controller.spec.nest-routes.ts.tpl +57 -0
  364. package/templates/presets/identity/context/test/unit/revoke-invitation.controller.spec.nest-routes.ts.tpl +57 -0
  365. package/templates/presets/identity/context/test/unit/search-members.controller.spec.nest-routes.ts.tpl +54 -0
  366. package/templates/process/timeout-job.wiring.manual.tpl +1 -1
  367. package/templates/query/search.wiring.manual.tpl +1 -1
  368. package/templates/query/wiring.manual.tpl +1 -1
  369. package/templates/repository/contract.spec.ts.tpl +1 -3
  370. package/templates/repository/event-sourced/contract.spec.ts.tpl +36 -0
  371. package/templates/repository/event-sourced/fake.ts.tpl +24 -0
  372. package/templates/repository/event-sourced/repository.ts.tpl +38 -0
  373. package/templates/repository/event-sourced-first-use.wiring.manual.tpl +4 -0
  374. package/templates/repository/event-sourced.wiring.tsyringe.tpl +6 -0
  375. package/templates/repository/first-use.wiring.manual.tpl +1 -1
  376. /package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/{deactivate-account.controller.ts.tpl → deactivate-account.controller.kit-routes.ts.tpl} +0 -0
  377. /package/templates/presets/identity/context/presentation/http/accounts/provision-account/{provision-account.controller.ts.tpl → provision-account.controller.kit-routes.ts.tpl} +0 -0
  378. /package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/{accept-invitation.controller.ts.tpl → accept-invitation.controller.kit-routes.ts.tpl} +0 -0
  379. /package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/{decline-invitation.controller.ts.tpl → decline-invitation.controller.kit-routes.ts.tpl} +0 -0
  380. /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
  381. /package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/{grant-delegation.controller.ts.tpl → grant-delegation.controller.kit-routes.ts.tpl} +0 -0
  382. /package/templates/presets/identity/context/presentation/http/organisations/invite-member/{invite-member.controller.ts.tpl → invite-member.controller.kit-routes.ts.tpl} +0 -0
  383. /package/templates/presets/identity/context/presentation/http/organisations/open-organisation/{open-organisation.controller.ts.tpl → open-organisation.controller.kit-routes.ts.tpl} +0 -0
  384. /package/templates/presets/identity/context/presentation/http/organisations/remove-member/{remove-member.controller.ts.tpl → remove-member.controller.kit-routes.ts.tpl} +0 -0
  385. /package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/{revoke-delegation.controller.ts.tpl → revoke-delegation.controller.kit-routes.ts.tpl} +0 -0
  386. /package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/{revoke-invitation.controller.ts.tpl → revoke-invitation.controller.kit-routes.ts.tpl} +0 -0
  387. /package/templates/presets/identity/context/presentation/http/organisations/search-members/{search-members.controller.ts.tpl → search-members.controller.kit-routes.ts.tpl} +0 -0
  388. /package/templates/presets/identity/context/test/unit/{accept-invitation.controller.spec.ts.tpl → accept-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  389. /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
  390. /package/templates/presets/identity/context/test/unit/{deactivate-account.controller.spec.ts.tpl → deactivate-account.controller.spec.kit-routes.ts.tpl} +0 -0
  391. /package/templates/presets/identity/context/test/unit/{decline-invitation.controller.spec.ts.tpl → decline-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  392. /package/templates/presets/identity/context/test/unit/{grant-delegation.controller.spec.ts.tpl → grant-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
  393. /package/templates/presets/identity/context/test/unit/{invite-member.controller.spec.ts.tpl → invite-member.controller.spec.kit-routes.ts.tpl} +0 -0
  394. /package/templates/presets/identity/context/test/unit/{open-organisation.controller.spec.ts.tpl → open-organisation.controller.spec.kit-routes.ts.tpl} +0 -0
  395. /package/templates/presets/identity/context/test/unit/{provision-account.controller.spec.ts.tpl → provision-account.controller.spec.kit-routes.ts.tpl} +0 -0
  396. /package/templates/presets/identity/context/test/unit/{remove-member.controller.spec.ts.tpl → remove-member.controller.spec.kit-routes.ts.tpl} +0 -0
  397. /package/templates/presets/identity/context/test/unit/{revoke-delegation.controller.spec.ts.tpl → revoke-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
  398. /package/templates/presets/identity/context/test/unit/{revoke-invitation.controller.spec.ts.tpl → revoke-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
  399. /package/templates/presets/identity/context/test/unit/{search-members.controller.spec.ts.tpl → search-members.controller.spec.kit-routes.ts.tpl} +0 -0
@@ -3,4 +3,12 @@ export { generateDrizzleMigration } from './generate-drizzle-migration.js';
3
3
  export { primaryKeyOrderFindings } from './primary-key-order-findings.js';
4
4
  export { replayDrizzleMigrations } from './replay-drizzle-migrations.js';
5
5
  export { tidyWrittenMigration } from './tidy-written-migration.js';
6
+ export { appendAuditGuard } from './audit-guard/append-audit-guard.js';
7
+ export { auditGuardStatementsOf } from './audit-guard/audit-guard-statements-of.js';
8
+ export { generateGuarded } from './audit-guard/generate-guarded.js';
9
+ export { runOrmTool } from './audit-guard/run-orm-tool.js';
10
+ export { formatAsTheProject } from './format-as-the-project.js';
11
+ export { typeOnlyImports } from './audit-guard/type-only-imports.js';
12
+ export { schemasFirst } from './audit-guard/schemas-first.js';
13
+ export { schemasIfMissing } from './audit-guard/schemas-if-missing.js';
6
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -1,16 +1,8 @@
1
+ import type { NestReadType } from './nest-read-type.js';
1
2
  /** What a method of a Nest controller answers, as its signature says it. */
2
3
  export type NestAnswer = {
3
4
  readonly kind: 'none';
4
5
  } | {
5
6
  readonly kind: 'accepted';
6
- } | {
7
- readonly kind: 'class';
8
- readonly name: string;
9
- readonly specifier: string;
10
- }
11
- /** A type the kit cannot turn into a schema (an array, a type written inline, an interface), or no type at all. */
12
- | {
13
- readonly kind: 'unread';
14
- readonly text: string;
15
- };
7
+ } | NestReadType;
16
8
  //# sourceMappingURL=nest-answer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nest-answer.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-answer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC/E,mHAAmH;GACjH;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"nest-answer.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAAC"}
@@ -1,15 +1,17 @@
1
1
  import type { NestAnswer } from './nest-answer.js';
2
- /** A Nest controller of a context the kit serves, and what each of its route methods answers. */
2
+ import type { NestRequestPart } from './nest-request-part.js';
3
+ /** A Nest controller of a context the kit serves, and what the signature of each of its route methods says. */
3
4
  export interface NestControllerEntry {
4
5
  readonly file: string;
5
6
  readonly className: string;
6
7
  readonly specifier: string;
7
8
  readonly methods: readonly NestRouteMethod[];
8
9
  }
9
- /** A route method of a Nest controller: what its signature says it answers, and whether `@KitRoute` says it instead. */
10
+ /** A route method of a Nest controller: what its signature says it takes and answers, and whether `@KitRoute` says its answer instead. */
10
11
  export interface NestRouteMethod {
11
12
  readonly name: string;
12
13
  readonly line: number;
14
+ readonly request: readonly NestRequestPart[];
13
15
  readonly answer: NestAnswer;
14
16
  readonly declaresResponse: boolean;
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nest-controller-entry.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controller-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,iGAAiG;AACjG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED,wHAAwH;AACxH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC"}
1
+ {"version":3,"file":"nest-controller-entry.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controller-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,+GAA+G;AAC/G,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED,0IAA0I;AAC1I,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC"}
@@ -0,0 +1,6 @@
1
+ import type { Config } from '../config/index.js';
2
+ import type { NestControllerEntry } from './nest-controller-entry.js';
3
+ import type { ProjectFiles } from './project-files.js';
4
+ /** The Nest controllers the kit serves in one file, with what the signature of each route method says. */
5
+ export declare function nestControllersIn(files: ProjectFiles, config: Config, file: string): NestControllerEntry[];
6
+ //# sourceMappingURL=nest-controllers-in.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-controllers-in.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controllers-in.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,yBAAyB,CAAC;AAIpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAuBpD,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAqB1G"}
@@ -0,0 +1,108 @@
1
+ import { specifierOf } from '../alias/index.js';
2
+ import { aliasRoots } from '../alias/alias-roots.js';
3
+ import { scan } from '../check/scan/scan.js';
4
+ import { readStructure } from '../check/structure/read-structure.js';
5
+ import { parametersOf } from './parameters-of.js';
6
+ const NEST = '@nestjs/common';
7
+ const BRIDGE = '@ddd-ts-kit/http/nest';
8
+ const ROUTE_DECORATOR = /@(?:Get|Post|Put|Patch|Delete|Head|Options)\s*\(/;
9
+ const RETURN_TYPE = /\)\s*:\s*([\s\S]+?)\s*$/;
10
+ const PROMISED = /^Promise\s*<([\s\S]+)>$/;
11
+ const TYPE_NAME = /^[A-Z][\w$]*$/;
12
+ const CONTROLLER = /@Controller\s*\(/;
13
+ const DECLARED_RESPONSE = /@KitRoute\s*\(\s*\{[\s\S]*\bresponse\s*:/;
14
+ const DECLARED_REQUEST = /@KitRoute\s*\(\s*\{[\s\S]*\brequest\s*:\s*\{([^}]*)\}/;
15
+ /** A parameter that takes a part of the request whole: `@Body() body: IssueInvoiceBody`. */
16
+ const WHOLE_PART = /^@(Body|Query|Param|Headers)\s*\(\s*\)\s*(?:(?:public|private|protected|readonly)\s+)*[\w$]+\??\s*:\s*([\s\S]+)$/;
17
+ const SOURCES = {
18
+ Body: 'body',
19
+ Query: 'query',
20
+ Param: 'params',
21
+ Headers: 'headers',
22
+ };
23
+ /** The Nest controllers the kit serves in one file, with what the signature of each route method says. */
24
+ export function nestControllersIn(files, config, file) {
25
+ const text = files.read(file) ?? '';
26
+ const scanned = scan(text);
27
+ const { imports } = scanned;
28
+ if (!imports.some(({ specifier }) => specifier === NEST) || !imports.some(({ specifier }) => specifier === BRIDGE)) {
29
+ return [];
30
+ }
31
+ const reading = { files, config, imports, text, code: scanned.code };
32
+ return readStructure(scanned)
33
+ .classes.filter(({ isExported, start }) => isExported && CONTROLLER.test(scanned.code.slice(Math.max(0, start - 400), start)))
34
+ .map((shape) => ({
35
+ file,
36
+ className: shape.name,
37
+ specifier: specifierOf(config, file),
38
+ methods: routeMethodsOf(shape, reading),
39
+ }));
40
+ }
41
+ /** The methods of the class that carry a route decorator of Nest, each with what its signature takes and answers. */
42
+ function routeMethodsOf(shape, reading) {
43
+ let previous = shape.bodyStart;
44
+ return shape.methods.flatMap((method) => {
45
+ const decorators = reading.code.slice(previous, method.start);
46
+ previous = method.end;
47
+ if (method.isConstructor || !ROUTE_DECORATOR.test(decorators)) {
48
+ return [];
49
+ }
50
+ const signature = reading.text.slice(method.start, method.bodyStart);
51
+ const written = RETURN_TYPE.exec(signature)?.[1];
52
+ return [
53
+ {
54
+ name: method.name,
55
+ line: method.line,
56
+ request: requestOf(method, decorators, reading),
57
+ answer: written === undefined ? { kind: 'unread', text: 'no return type' } : answerOf(written, reading),
58
+ declaresResponse: DECLARED_RESPONSE.test(decorators),
59
+ },
60
+ ];
61
+ });
62
+ }
63
+ /** The parts of the request the parameters take whole, each with its type and whether `@KitRoute` gives it. */
64
+ function requestOf({ start, bodyStart }, decorators, reading) {
65
+ const declared = DECLARED_REQUEST.exec(decorators)?.[1] ?? '';
66
+ return parametersOf(reading.text.slice(start, bodyStart), reading.code.slice(start, bodyStart)).flatMap((parameter) => {
67
+ const [, decorator = '', type = ''] = WHOLE_PART.exec(parameter) ?? [];
68
+ const source = SOURCES[decorator];
69
+ return source === undefined
70
+ ? []
71
+ : [{ source, type: typeOf(type.trim(), reading), declared: givesPart(declared, source) }];
72
+ });
73
+ }
74
+ /** Whether the members of `request` of `@KitRoute` name that part, written in full (`query: schema`) or short (`query`). */
75
+ function givesPart(members, source) {
76
+ return new RegExp(`(?:^|,)\\s*${source}\\s*(?::|,|$)`).test(members.trim());
77
+ }
78
+ function answerOf(written, reading) {
79
+ const type = (PROMISED.exec(written)?.[1] ?? written).trim();
80
+ if (type === 'void' || type === 'undefined') {
81
+ return { kind: 'none' };
82
+ }
83
+ if (type === 'Accepted' && importOf(type, reading)?.specifier === '@ddd-ts-kit/http') {
84
+ return { kind: 'accepted' };
85
+ }
86
+ const read = typeOf(type, reading);
87
+ return read.kind === 'class' ? read : { kind: 'unread', text: written };
88
+ }
89
+ /** A DTO class imported by its name from a file of the project, else a type the kit cannot read. */
90
+ function typeOf(type, reading) {
91
+ const imported = importOf(type, reading);
92
+ return imported !== undefined && isClassAt(reading, imported.specifier, type)
93
+ ? { kind: 'class', name: type, specifier: imported.specifier }
94
+ : { kind: 'unread', text: type };
95
+ }
96
+ function importOf(type, { imports }) {
97
+ return TYPE_NAME.test(type) ? imports.find(({ names }) => names.includes(type)) : undefined;
98
+ }
99
+ /** Whether the file an alias names exports a class of that name: an interface or a type has no schema to read. */
100
+ function isClassAt({ files, config }, specifier, name) {
101
+ const root = aliasRoots(config).find(({ prefix }) => specifier.startsWith(prefix));
102
+ if (root === undefined) {
103
+ return false;
104
+ }
105
+ const file = `${root.directory}/${specifier.slice(root.prefix.length).replace(/\.js$/, '')}.ts`;
106
+ return new RegExp(`export\\s+(?:abstract\\s+)?class\\s+${name}\\b`).test(files.read(file) ?? '');
107
+ }
108
+ //# sourceMappingURL=nest-controllers-in.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-controllers-in.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-controllers-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI1C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,MAAM,eAAe,GAAG,kDAAkD,CAAC;AAC3E,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAC9C,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,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC;AAED,kHAAkH;AAClH,SAAS,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAW,EAAE,SAAiB,EAAE,IAAY;IAC5E,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC;IAEhG,OAAO,IAAI,MAAM,CAAC,uCAAuC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** A type of a signature the kit turns into a schema, a DTO class, or one it cannot read, as written. */
2
+ export type NestReadType = {
3
+ readonly kind: 'class';
4
+ readonly name: string;
5
+ readonly specifier: string;
6
+ }
7
+ /** A type the kit cannot turn into a schema (an array, a type written inline, an interface), or no type at all. */
8
+ | {
9
+ readonly kind: 'unread';
10
+ readonly text: string;
11
+ };
12
+ //# sourceMappingURL=nest-read-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-read-type.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-read-type.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC/E,mHAAmH;GACjH;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=nest-read-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-read-type.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-read-type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { NestReadType } from './nest-read-type.js';
2
+ /** A part of the request a parameter of a route method takes whole (`@Body() body: IssueInvoiceBody`), and its type. */
3
+ export interface NestRequestPart {
4
+ readonly source: 'params' | 'query' | 'headers' | 'body';
5
+ readonly type: NestReadType;
6
+ /** Whether `request` of `@KitRoute` gives the schema of this part instead. */
7
+ readonly declared: boolean;
8
+ }
9
+ //# sourceMappingURL=nest-request-part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-request-part.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-request-part.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,wHAAwH;AACxH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=nest-request-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-request-part.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-request-part.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The parameters of a method as written, from the text of its signature (`issue(@Body() body: X,
3
+ * actor: Actor): Promise<Y>`): what stands between its parentheses, cut at the commas that no
4
+ * bracket holds. `code` is the same text with its comments and strings blanked, where the
5
+ * brackets are counted.
6
+ */
7
+ export declare function parametersOf(text: string, code: string): string[];
8
+ //# sourceMappingURL=parameters-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters-of.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/parameters-of.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBjE"}
@@ -0,0 +1,32 @@
1
+ const OPENING = '([{<';
2
+ const CLOSING = ')]}>';
3
+ /**
4
+ * The parameters of a method as written, from the text of its signature (`issue(@Body() body: X,
5
+ * actor: Actor): Promise<Y>`): what stands between its parentheses, cut at the commas that no
6
+ * bracket holds. `code` is the same text with its comments and strings blanked, where the
7
+ * brackets are counted.
8
+ */
9
+ export function parametersOf(text, code) {
10
+ const open = code.indexOf('(');
11
+ const parameters = [];
12
+ let depth = 0;
13
+ let from = open + 1;
14
+ for (let at = from; open >= 0 && at < code.length; at += 1) {
15
+ const char = code.charAt(at);
16
+ if (depth === 0 && (char === ',' || char === ')')) {
17
+ parameters.push(text.slice(from, at).trim());
18
+ from = at + 1;
19
+ if (char === ')') {
20
+ break;
21
+ }
22
+ }
23
+ else if (OPENING.includes(char)) {
24
+ depth += 1;
25
+ }
26
+ else if (CLOSING.includes(char) && code.charAt(at - 1) !== '=') {
27
+ depth -= 1;
28
+ }
29
+ }
30
+ return parameters.filter((parameter) => parameter !== '');
31
+ }
32
+ //# sourceMappingURL=parameters-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters-of.js","sourceRoot":"","sources":["../../src/nest-controllers/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S,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** What the reader needs of the project: the text of a file, and the files below a directory. */
2
+ export interface ProjectFiles {
3
+ read(file: string): string | undefined;
4
+ under(directory: string): readonly string[];
5
+ }
6
+ //# sourceMappingURL=project-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-files.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/project-files.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=project-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../src/nest-controllers/project-files.ts"],"names":[],"mappings":""}
@@ -1,15 +1,12 @@
1
1
  import type { Config } from '../config/index.js';
2
2
  import type { NestControllerEntry } from './nest-controller-entry.js';
3
- /** What the reader needs of the project: the text of a file, and the files below a directory. */
4
- export interface ProjectFiles {
5
- read(file: string): string | undefined;
6
- under(directory: string): readonly string[];
7
- }
3
+ import type { ProjectFiles } from './project-files.js';
8
4
  /**
9
- * The Nest controllers of a context that the kit serves (a class of `presentation/` carrying
10
- * Nest's `@Controller`, in a file that imports the bridge), in the order of their files, with what
11
- * each route method answers as its signature says: `Promise<IssuedInvoice>` a DTO class,
12
- * `Promise<Accepted>` an identifier, `Promise<void>` nothing.
5
+ * The Nest controllers of a context that the kit serves (a class of a `presentation/` folder of the
6
+ * context or of one of its modules, carrying Nest's `@Controller`, in a file that imports the
7
+ * bridge), in the order of their files, with what the signature of each route method says: the DTO class of each part of the request a parameter
8
+ * takes whole (`@Body() body: IssueInvoiceBody`), and its answer, `Promise<IssuedInvoice>` a DTO
9
+ * class, `Promise<Accepted>` an identifier, `Promise<void>` nothing.
13
10
  */
14
11
  export declare function readNestControllers(files: ProjectFiles, config: Config, context: string): NestControllerEntry[];
15
12
  //# sourceMappingURL=read-nest-controllers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-nest-controllers.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,yBAAyB,CAAC;AAEpF,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC7C;AAWD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAQ/G"}
1
+ {"version":3,"file":"read-nest-controllers.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAO/G"}
@@ -1,89 +1,17 @@
1
- import { specifierOf } from '../alias/index.js';
2
- import { aliasRoots } from '../alias/alias-roots.js';
3
- import { scan } from '../check/scan/scan.js';
4
- import { readStructure } from '../check/structure/read-structure.js';
5
- const NEST = '@nestjs/common';
6
- const BRIDGE = '@ddd-ts-kit/http/nest';
7
- const ROUTE_DECORATOR = /@(?:Get|Post|Put|Patch|Delete|Head|Options)\s*\(/;
8
- const RETURN_TYPE = /\)\s*:\s*([\s\S]+?)\s*$/;
9
- const PROMISED = /^Promise\s*<([\s\S]+)>$/;
10
- const TYPE_NAME = /^[A-Z][\w$]*$/;
11
- const CONTROLLER = /@Controller\s*\(/;
12
- const DECLARED_RESPONSE = /@KitRoute\s*\(\s*\{[\s\S]*\bresponse\s*:/;
1
+ import { nestControllersIn } from './nest-controllers-in.js';
13
2
  /**
14
- * The Nest controllers of a context that the kit serves (a class of `presentation/` carrying
15
- * Nest's `@Controller`, in a file that imports the bridge), in the order of their files, with what
16
- * each route method answers as its signature says: `Promise<IssuedInvoice>` a DTO class,
17
- * `Promise<Accepted>` an identifier, `Promise<void>` nothing.
3
+ * The Nest controllers of a context that the kit serves (a class of a `presentation/` folder of the
4
+ * context or of one of its modules, carrying Nest's `@Controller`, in a file that imports the
5
+ * bridge), in the order of their files, with what the signature of each route method says: the DTO class of each part of the request a parameter
6
+ * takes whole (`@Body() body: IssueInvoiceBody`), and its answer, `Promise<IssuedInvoice>` a DTO
7
+ * class, `Promise<Accepted>` an identifier, `Promise<void>` nothing.
18
8
  */
19
9
  export function readNestControllers(files, config, context) {
20
- const presentation = `${config.contextsDir}/${context}/presentation`;
10
+ // The presentation of the context, and that of each of its modules.
21
11
  return files
22
- .under(presentation)
23
- .filter((file) => file.endsWith('.ts') && !file.endsWith('.spec.ts'))
12
+ .under(`${config.contextsDir}/${context}`)
13
+ .filter((file) => file.includes('/presentation/') && file.endsWith('.ts') && !file.endsWith('.spec.ts'))
24
14
  .sort()
25
- .flatMap((file) => controllersIn(files, config, file));
26
- }
27
- function controllersIn(files, config, file) {
28
- const text = files.read(file) ?? '';
29
- const scanned = scan(text);
30
- const { imports } = scanned;
31
- if (!imports.some(({ specifier }) => specifier === NEST) || !imports.some(({ specifier }) => specifier === BRIDGE)) {
32
- return [];
33
- }
34
- const reading = { files, config, imports, text, code: scanned.code };
35
- return readStructure(scanned)
36
- .classes.filter(({ isExported, start }) => isExported && CONTROLLER.test(scanned.code.slice(Math.max(0, start - 400), start)))
37
- .map((shape) => ({
38
- file,
39
- className: shape.name,
40
- specifier: specifierOf(config, file),
41
- methods: routeMethodsOf(shape, reading),
42
- }));
43
- }
44
- /** The methods of the class that carry a route decorator of Nest, each with what its signature answers. */
45
- function routeMethodsOf(shape, reading) {
46
- let previous = shape.bodyStart;
47
- return shape.methods.flatMap((method) => {
48
- const decorators = reading.code.slice(previous, method.start);
49
- previous = method.end;
50
- if (method.isConstructor || !ROUTE_DECORATOR.test(decorators)) {
51
- return [];
52
- }
53
- const written = RETURN_TYPE.exec(reading.text.slice(method.start, method.bodyStart))?.[1];
54
- return [
55
- {
56
- name: method.name,
57
- line: method.line,
58
- answer: written === undefined ? { kind: 'unread', text: 'no return type' } : answerOf(written, reading),
59
- declaresResponse: DECLARED_RESPONSE.test(decorators),
60
- },
61
- ];
62
- });
63
- }
64
- function answerOf(written, reading) {
65
- const type = (PROMISED.exec(written)?.[1] ?? written).trim();
66
- if (type === 'void' || type === 'undefined') {
67
- return { kind: 'none' };
68
- }
69
- const imported = TYPE_NAME.test(type) ? reading.imports.find(({ names }) => names.includes(type)) : undefined;
70
- if (imported === undefined) {
71
- return { kind: 'unread', text: written };
72
- }
73
- if (type === 'Accepted' && imported.specifier === '@ddd-ts-kit/http') {
74
- return { kind: 'accepted' };
75
- }
76
- return isClassAt(reading, imported.specifier, type)
77
- ? { kind: 'class', name: type, specifier: imported.specifier }
78
- : { kind: 'unread', text: written };
79
- }
80
- /** Whether the file an alias names exports a class of that name: an interface or a type has no schema to read. */
81
- function isClassAt({ files, config }, specifier, name) {
82
- const root = aliasRoots(config).find(({ prefix }) => specifier.startsWith(prefix));
83
- if (root === undefined) {
84
- return false;
85
- }
86
- const file = `${root.directory}/${specifier.slice(root.prefix.length).replace(/\.js$/, '')}.ts`;
87
- return new RegExp(`export\\s+(?:abstract\\s+)?class\\s+${name}\\b`).test(files.read(file) ?? '');
15
+ .flatMap((file) => nestControllersIn(files, config, file));
88
16
  }
89
17
  //# sourceMappingURL=read-nest-controllers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-nest-controllers.js","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAWlE,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,MAAM,eAAe,GAAG,kDAAkD,CAAC;AAC3E,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAC9C,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAC3C,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AACtC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAErE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAmB,EAAE,MAAc,EAAE,OAAe;IACtF,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,WAAW,IAAI,OAAO,eAAe,CAAC;IAErE,OAAO,KAAK;SACT,KAAK,CAAC,YAAY,CAAC;SACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACpE,IAAI,EAAE;SACN,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D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AO,EAAE,EAAE,CAAC,KAAK,CAAC;IAEhG,OAAO,IAAI,MAAM,CAAC,uCAAuC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACnG,CAAC"}
1
+ {"version":3,"file":"read-nest-controllers.js","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAmB,EAAE,MAAc,EAAE,OAAe;IACtF,oEAAoE;IACpE,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,MAAM,CAAC,WAAW,IAAI,OAAO,EAAE,CAAC;SACzC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACvG,IAAI,EAAE;SACN,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import type { NestControllerEntry } from './nest-controller-entry.js';
2
2
  /**
3
- * `<context>.controllers.ts`: the Nest controllers of a context, each with what its methods answer
4
- * as their signatures say it, for the module to list and the bridge to read. A method whose answer
5
- * cannot be read is left out: `@KitRoute` says it, or `nest/controllers-current` reports it.
3
+ * `<context>.controllers.ts`: the Nest controllers of a context, each with what the signatures of
4
+ * its methods say, for the module to list and the bridge to read: the DTO classes of the parts of
5
+ * the request they take whole, and what they answer. What cannot be read is left out: `@KitRoute`
6
+ * says it, or `nest/controllers-current` reports it.
6
7
  */
7
8
  export declare function renderControllersFile(context: string, constant: string, entries: readonly NestControllerEntry[]): string;
8
9
  //# sourceMappingURL=render-controllers-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-controllers-file.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/render-controllers-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,mBAAmB,EAAE,GACtC,MAAM,CAYR"}
1
+ {"version":3,"file":"render-controllers-file.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/render-controllers-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,yBAAyB,CAAC;AAIpF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,mBAAmB,EAAE,GACtC,MAAM,CAYR"}
@@ -1,56 +1,72 @@
1
1
  const WIDTH = 120;
2
2
  /**
3
- * `<context>.controllers.ts`: the Nest controllers of a context, each with what its methods answer
4
- * as their signatures say it, for the module to list and the bridge to read. A method whose answer
5
- * cannot be read is left out: `@KitRoute` says it, or `nest/controllers-current` reports it.
3
+ * `<context>.controllers.ts`: the Nest controllers of a context, each with what the signatures of
4
+ * its methods say, for the module to list and the bridge to read: the DTO classes of the parts of
5
+ * the request they take whole, and what they answer. What cannot be read is left out: `@KitRoute`
6
+ * says it, or `nest/controllers-current` reports it.
6
7
  */
7
8
  export function renderControllersFile(context, constant, entries) {
8
9
  const list = entries.length === 0
9
10
  ? ' = [];'
10
- : ` = [\n${entries.map((entry) => `${entryOf(entry.className, answersOf(entry))}\n`).join('')}];`;
11
+ : ` = [\n${entries.map((entry) => `${entryOf(entry.className, entry.methods.flatMap(methodOf))}\n`).join('')}];`;
11
12
  return `// Generated by ddd-ts-kit from the Nest controllers of ${context} and the signatures of their methods: never edit it.
12
13
  ${importsOf(entries).join('\n')}
13
14
 
14
- /** The Nest controllers of ${context}, each with what its methods answer: the module of the context lists them, Nest builds them. */
15
+ /** The Nest controllers of ${context}, each with what the signatures of its methods say: the module of the context lists them, Nest builds them. */
15
16
  export const ${constant}: readonly Type<unknown>[]${list}
16
17
  `;
17
18
  }
18
- /** The import lines: the bridge and the schema of an identifier when they are used, the controllers, then the DTO classes they answer. */
19
+ /** The import lines: the bridge and the schema of an identifier when they are used, the controllers, then the DTO classes they name. */
19
20
  function importsOf(entries) {
20
- const answers = entries.flatMap(({ methods }) => methods.map(({ answer }) => answer));
21
- const types = new Map(answers.flatMap((answer) => (answer.kind === 'class' ? [[answer.name, answer.specifier]] : [])));
21
+ const methods = entries.flatMap(({ methods: of }) => of);
22
+ const types = new Map(methods
23
+ .flatMap(({ request, answer }) => [...request.map(({ type }) => type), answer])
24
+ .flatMap((type) => (type.kind === 'class' ? [[type.name, type.specifier]] : [])));
22
25
  return [
23
26
  ...new Set([
24
- ...(answers.some(({ kind }) => kind === 'accepted')
27
+ ...(methods.some(({ answer }) => answer.kind === 'accepted')
25
28
  ? ["import { acceptedSchema } from '@ddd-ts-kit/http';"]
26
29
  : []),
27
- ...(entries.length === 0 ? [] : ["import { withAnswers } from '@ddd-ts-kit/http/nest';"]),
30
+ ...(entries.length === 0 ? [] : ["import { withSignatures } from '@ddd-ts-kit/http/nest';"]),
28
31
  "import type { Type } from '@nestjs/common';",
29
32
  ...entries.map(({ className, specifier }) => `import { ${className} } from '${specifier}';`),
30
33
  ...[...types].map(([name, specifier]) => `import { ${name} } from '${specifier}';`),
31
34
  ]),
32
35
  ];
33
36
  }
34
- /** What each method answers, as `withAnswers` takes it; a method whose answer could not be read is left out. */
35
- function answersOf({ methods }) {
36
- return methods.flatMap(({ name, answer }) => {
37
- if (answer.kind === 'none') {
38
- return [`${name}: null`];
39
- }
40
- if (answer.kind === 'accepted') {
41
- return [`${name}: acceptedSchema`];
42
- }
43
- return answer.kind === 'class' ? [`${name}: ${answer.name}`] : [];
44
- });
37
+ /** What the signature of a method says, as `withSignatures` takes it; left out when nothing of it was read. */
38
+ function methodOf({ name, request, answer }) {
39
+ const members = [
40
+ ...request.flatMap(({ source, type }) => (type.kind === 'class' ? [`${source}: ${type.name}`] : [])),
41
+ ...answerOf(answer),
42
+ ];
43
+ return members.length === 0 ? [] : [{ name, members }];
45
44
  }
46
- /** One entry of the list, on one line when the formatter would keep it there. */
47
- function entryOf(className, answers) {
48
- if (answers.length === 0) {
49
- return ` withAnswers(${className}, {}),`;
45
+ function answerOf(answer) {
46
+ if (answer.kind === 'none') {
47
+ return ['answer: null'];
50
48
  }
51
- const line = ` withAnswers(${className}, { ${answers.join(', ')} }),`;
52
- return line.length <= WIDTH
53
- ? line
54
- : ` withAnswers(${className}, {\n${answers.map((answer) => ` ${answer},\n`).join('')} }),`;
49
+ if (answer.kind === 'accepted') {
50
+ return ['answer: acceptedSchema'];
51
+ }
52
+ return answer.kind === 'class' ? [`answer: ${answer.name}`] : [];
53
+ }
54
+ /** One entry of the list, each object on one line when the formatter would keep it there. */
55
+ function entryOf(className, methods) {
56
+ if (methods.length === 0) {
57
+ return ` withSignatures(${className}, {}),`;
58
+ }
59
+ const inline = methods.map(({ name, members }) => `${name}: { ${members.join(', ')} }`);
60
+ const line = ` withSignatures(${className}, { ${inline.join(', ')} }),`;
61
+ if (line.length <= WIDTH) {
62
+ return line;
63
+ }
64
+ const lines = methods.map(({ name, members }, at) => {
65
+ const one = ` ${inline[at] ?? ''},`;
66
+ return one.length <= WIDTH
67
+ ? one
68
+ : ` ${name}: {\n${members.map((member) => ` ${member},\n`).join('')} },`;
69
+ });
70
+ return ` withSignatures(${className}, {\n${lines.join('\n')}\n }),`;
55
71
  }
56
72
  //# sourceMappingURL=render-controllers-file.js.map