ddd-ts-kit 0.102.0 → 0.103.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 (548) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/README.fr.md +8 -9
  3. package/README.md +7 -8
  4. package/dist/acceptance/check-locked-files.d.ts.map +1 -1
  5. package/dist/acceptance/check-locked-files.js +6 -3
  6. package/dist/acceptance/check-locked-files.js.map +1 -1
  7. package/dist/build/rewrite-aliases.d.ts.map +1 -1
  8. package/dist/build/rewrite-aliases.js +3 -0
  9. package/dist/build/rewrite-aliases.js.map +1 -1
  10. package/dist/check/baseline/write-baseline.d.ts.map +1 -1
  11. package/dist/check/baseline/write-baseline.js +2 -3
  12. package/dist/check/baseline/write-baseline.js.map +1 -1
  13. package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
  14. package/dist/check/errors/kit-error-codes.js +1 -0
  15. package/dist/check/errors/kit-error-codes.js.map +1 -1
  16. package/dist/check/explain/authz-docs.js +1 -1
  17. package/dist/check/explain/authz-docs.js.map +1 -1
  18. package/dist/check/explain/errors-docs.js +1 -1
  19. package/dist/check/explain/errors-docs.js.map +1 -1
  20. package/dist/check/fixtures/authz-policy-fixtures.d.ts.map +1 -1
  21. package/dist/check/fixtures/authz-policy-fixtures.js +13 -1
  22. package/dist/check/fixtures/authz-policy-fixtures.js.map +1 -1
  23. package/dist/check/rules/authz-policy-asked.d.ts.map +1 -1
  24. package/dist/check/rules/authz-policy-asked.js +45 -6
  25. package/dist/check/rules/authz-policy-asked.js.map +1 -1
  26. package/dist/check/rules/test-spec-required.d.ts.map +1 -1
  27. package/dist/check/rules/test-spec-required.js +3 -1
  28. package/dist/check/rules/test-spec-required.js.map +1 -1
  29. package/dist/check/scan/named-outside-imports.d.ts +3 -0
  30. package/dist/check/scan/named-outside-imports.d.ts.map +1 -0
  31. package/dist/check/scan/named-outside-imports.js +8 -0
  32. package/dist/check/scan/named-outside-imports.js.map +1 -0
  33. package/dist/check/scan/star-exports-of.d.ts +3 -0
  34. package/dist/check/scan/star-exports-of.d.ts.map +1 -0
  35. package/dist/check/scan/star-exports-of.js +8 -0
  36. package/dist/check/scan/star-exports-of.js.map +1 -0
  37. package/dist/check/scan/string-at.d.ts +3 -0
  38. package/dist/check/scan/string-at.d.ts.map +1 -0
  39. package/dist/check/scan/string-at.js +5 -0
  40. package/dist/check/scan/string-at.js.map +1 -0
  41. package/dist/check/text/closing-bracket.d.ts +6 -0
  42. package/dist/check/text/closing-bracket.d.ts.map +1 -0
  43. package/dist/check/text/closing-bracket.js +24 -0
  44. package/dist/check/text/closing-bracket.js.map +1 -0
  45. package/dist/commands/depcruise-config.d.ts.map +1 -1
  46. package/dist/commands/depcruise-config.js +4 -0
  47. package/dist/commands/depcruise-config.js.map +1 -1
  48. package/dist/commands/drizzle-generate.d.ts +3 -2
  49. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  50. package/dist/commands/drizzle-generate.js +14 -6
  51. package/dist/commands/drizzle-generate.js.map +1 -1
  52. package/dist/commands/generate.d.ts.map +1 -1
  53. package/dist/commands/generate.js +3 -2
  54. package/dist/commands/generate.js.map +1 -1
  55. package/dist/commands/knex-generate.d.ts +10 -0
  56. package/dist/commands/knex-generate.d.ts.map +1 -0
  57. package/dist/commands/knex-generate.js +74 -0
  58. package/dist/commands/knex-generate.js.map +1 -0
  59. package/dist/commands/lint.js +15 -0
  60. package/dist/commands/lint.js.map +1 -1
  61. package/dist/commands/move-to-module.d.ts.map +1 -1
  62. package/dist/commands/move-to-module.js +3 -0
  63. package/dist/commands/move-to-module.js.map +1 -1
  64. package/dist/commands/mutation.js +1 -1
  65. package/dist/commands/mutation.js.map +1 -1
  66. package/dist/commands/parse-migration-arguments.d.ts +11 -0
  67. package/dist/commands/parse-migration-arguments.d.ts.map +1 -0
  68. package/dist/commands/parse-migration-arguments.js +17 -0
  69. package/dist/commands/parse-migration-arguments.js.map +1 -0
  70. package/dist/commands/prisma-generate.d.ts.map +1 -1
  71. package/dist/commands/prisma-generate.js +5 -11
  72. package/dist/commands/prisma-generate.js.map +1 -1
  73. package/dist/commands/typeorm-generate.d.ts +2 -1
  74. package/dist/commands/typeorm-generate.d.ts.map +1 -1
  75. package/dist/commands/typeorm-generate.js +5 -2
  76. package/dist/commands/typeorm-generate.js.map +1 -1
  77. package/dist/doctor/permission-findings.d.ts.map +1 -1
  78. package/dist/doctor/permission-findings.js +68 -4
  79. package/dist/doctor/permission-findings.js.map +1 -1
  80. package/dist/generate/concept-role.d.ts +10 -0
  81. package/dist/generate/concept-role.d.ts.map +1 -1
  82. package/dist/generate/concept.d.ts.map +1 -1
  83. package/dist/generate/concept.js +5 -1
  84. package/dist/generate/concept.js.map +1 -1
  85. package/dist/generate/emit.d.ts +5 -2
  86. package/dist/generate/emit.d.ts.map +1 -1
  87. package/dist/generate/emit.js +5 -4
  88. package/dist/generate/emit.js.map +1 -1
  89. package/dist/generate/event-names.d.ts.map +1 -1
  90. package/dist/generate/event-names.js.map +1 -1
  91. package/dist/generate/files-without-modules.d.ts +8 -0
  92. package/dist/generate/files-without-modules.d.ts.map +1 -0
  93. package/dist/generate/files-without-modules.js +12 -0
  94. package/dist/generate/files-without-modules.js.map +1 -0
  95. package/dist/generate/grant-permission.js +2 -2
  96. package/dist/generate/grant-permission.js.map +1 -1
  97. package/dist/generate/kinds/aggregate-kind.js +4 -4
  98. package/dist/generate/kinds/aggregate-kind.js.map +1 -1
  99. package/dist/generate/kinds/command-kind.d.ts.map +1 -1
  100. package/dist/generate/kinds/command-kind.js +6 -1
  101. package/dist/generate/kinds/command-kind.js.map +1 -1
  102. package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
  103. package/dist/generate/kinds/declare-storage.js +4 -10
  104. package/dist/generate/kinds/declare-storage.js.map +1 -1
  105. package/dist/generate/kinds/domain-event-kind.d.ts.map +1 -1
  106. package/dist/generate/kinds/domain-event-kind.js +3 -1
  107. package/dist/generate/kinds/domain-event-kind.js.map +1 -1
  108. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  109. package/dist/generate/kinds/e2e-kind.js +8 -1
  110. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  111. package/dist/generate/kinds/ensure-domain-event.d.ts.map +1 -1
  112. package/dist/generate/kinds/ensure-domain-event.js +2 -0
  113. package/dist/generate/kinds/ensure-domain-event.js.map +1 -1
  114. package/dist/generate/kinds/extraction/add-compose-service.js +1 -1
  115. package/dist/generate/kinds/extraction/add-compose-service.js.map +1 -1
  116. package/dist/generate/kinds/extraction/compose-service-of.d.ts +5 -0
  117. package/dist/generate/kinds/extraction/compose-service-of.d.ts.map +1 -0
  118. package/dist/generate/kinds/extraction/compose-service-of.js +8 -0
  119. package/dist/generate/kinds/extraction/compose-service-of.js.map +1 -0
  120. package/dist/generate/kinds/gateway-kind.js +9 -0
  121. package/dist/generate/kinds/gateway-kind.js.map +1 -1
  122. package/dist/generate/kinds/generate-context.d.ts.map +1 -1
  123. package/dist/generate/kinds/generate-context.js +36 -0
  124. package/dist/generate/kinds/generate-context.js.map +1 -1
  125. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  126. package/dist/generate/kinds/generate-repository.js +13 -0
  127. package/dist/generate/kinds/generate-repository.js.map +1 -1
  128. package/dist/generate/kinds/query-kind.d.ts.map +1 -1
  129. package/dist/generate/kinds/query-kind.js +24 -2
  130. package/dist/generate/kinds/query-kind.js.map +1 -1
  131. package/dist/generate/kinds/route/find-use-case.js +1 -1
  132. package/dist/generate/kinds/route/find-use-case.js.map +1 -1
  133. package/dist/generate/kinds/service-kind.d.ts.map +1 -1
  134. package/dist/generate/kinds/service-kind.js +3 -2
  135. package/dist/generate/kinds/service-kind.js.map +1 -1
  136. package/dist/generate/kinds/tables-files.d.ts +3 -0
  137. package/dist/generate/kinds/tables-files.d.ts.map +1 -0
  138. package/dist/generate/kinds/tables-files.js +7 -0
  139. package/dist/generate/kinds/tables-files.js.map +1 -0
  140. package/dist/generate/kinds/worker-kind.d.ts.map +1 -1
  141. package/dist/generate/kinds/worker-kind.js +12 -0
  142. package/dist/generate/kinds/worker-kind.js.map +1 -1
  143. package/dist/generate/kinds/write-birth.d.ts +8 -0
  144. package/dist/generate/kinds/write-birth.d.ts.map +1 -0
  145. package/dist/generate/kinds/write-birth.js +13 -0
  146. package/dist/generate/kinds/write-birth.js.map +1 -0
  147. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
  148. package/dist/generate/kinds/write-event-sourced-aggregate.js +8 -1
  149. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
  150. package/dist/generate/mark-policy-questions.js +2 -2
  151. package/dist/generate/mark-policy-questions.js.map +1 -1
  152. package/dist/generate/permission-name.d.ts +3 -0
  153. package/dist/generate/permission-name.d.ts.map +1 -0
  154. package/dist/generate/permission-name.js +3 -0
  155. package/dist/generate/permission-name.js.map +1 -0
  156. package/dist/generate/permission-named.d.ts.map +1 -1
  157. package/dist/generate/permission-named.js +1 -1
  158. package/dist/generate/permission-named.js.map +1 -1
  159. package/dist/generate/permission-words.d.ts +7 -0
  160. package/dist/generate/permission-words.d.ts.map +1 -0
  161. package/dist/generate/permission-words.js +11 -0
  162. package/dist/generate/permission-words.js.map +1 -0
  163. package/dist/generate/refined-by-policy.js +2 -2
  164. package/dist/generate/refined-by-policy.js.map +1 -1
  165. package/dist/generate/refuse-stuttering-event.d.ts +8 -0
  166. package/dist/generate/refuse-stuttering-event.d.ts.map +1 -0
  167. package/dist/generate/refuse-stuttering-event.js +14 -0
  168. package/dist/generate/refuse-stuttering-event.js.map +1 -0
  169. package/dist/generate/shared-writes.d.ts.map +1 -1
  170. package/dist/generate/shared-writes.js +1 -0
  171. package/dist/generate/shared-writes.js.map +1 -1
  172. package/dist/generate/spoken-in-language.d.ts +11 -2
  173. package/dist/generate/spoken-in-language.d.ts.map +1 -1
  174. package/dist/generate/spoken-in-language.js +27 -12
  175. package/dist/generate/spoken-in-language.js.map +1 -1
  176. package/dist/help/flag-notes.d.ts.map +1 -1
  177. package/dist/help/flag-notes.js +5 -1
  178. package/dist/help/flag-notes.js.map +1 -1
  179. package/dist/help/tool-notes.d.ts.map +1 -1
  180. package/dist/help/tool-notes.js +16 -0
  181. package/dist/help/tool-notes.js.map +1 -1
  182. package/dist/help/usage.d.ts.map +1 -1
  183. package/dist/help/usage.js +1 -0
  184. package/dist/help/usage.js.map +1 -1
  185. package/dist/init/agent-permissions.d.ts.map +1 -1
  186. package/dist/init/agent-permissions.js +18 -3
  187. package/dist/init/agent-permissions.js.map +1 -1
  188. package/dist/init/files/audit-files.d.ts.map +1 -1
  189. package/dist/init/files/audit-files.js +1 -0
  190. package/dist/init/files/audit-files.js.map +1 -1
  191. package/dist/init/files/persistence-files.d.ts.map +1 -1
  192. package/dist/init/files/persistence-files.js +2 -1
  193. package/dist/init/files/persistence-files.js.map +1 -1
  194. package/dist/init/files/script-files.d.ts +4 -1
  195. package/dist/init/files/script-files.d.ts.map +1 -1
  196. package/dist/init/files/script-files.js +6 -1
  197. package/dist/init/files/script-files.js.map +1 -1
  198. package/dist/init/is-team-file.d.ts +2 -2
  199. package/dist/init/is-team-file.d.ts.map +1 -1
  200. package/dist/init/is-team-file.js +5 -3
  201. package/dist/init/is-team-file.js.map +1 -1
  202. package/dist/init/keep-regions.d.ts +21 -0
  203. package/dist/init/keep-regions.d.ts.map +1 -0
  204. package/dist/init/keep-regions.js +63 -0
  205. package/dist/init/keep-regions.js.map +1 -0
  206. package/dist/init/kept-combination-notes.d.ts.map +1 -1
  207. package/dist/init/kept-combination-notes.js +6 -2
  208. package/dist/init/kept-combination-notes.js.map +1 -1
  209. package/dist/init/kept-compose-services.d.ts +6 -0
  210. package/dist/init/kept-compose-services.d.ts.map +1 -0
  211. package/dist/init/kept-compose-services.js +42 -0
  212. package/dist/init/kept-compose-services.js.map +1 -0
  213. package/dist/init/kept-role-vocabulary.d.ts +3 -0
  214. package/dist/init/kept-role-vocabulary.d.ts.map +1 -0
  215. package/dist/init/kept-role-vocabulary.js +7 -0
  216. package/dist/init/kept-role-vocabulary.js.map +1 -0
  217. package/dist/init/kept-roles.d.ts +12 -0
  218. package/dist/init/kept-roles.d.ts.map +1 -0
  219. package/dist/init/kept-roles.js +29 -0
  220. package/dist/init/kept-roles.js.map +1 -0
  221. package/dist/init/kept-wiring.d.ts +22 -0
  222. package/dist/init/kept-wiring.d.ts.map +1 -0
  223. package/dist/init/kept-wiring.js +91 -0
  224. package/dist/init/kept-wiring.js.map +1 -0
  225. package/dist/init/knip-vars.d.ts.map +1 -1
  226. package/dist/init/knip-vars.js +5 -1
  227. package/dist/init/knip-vars.js.map +1 -1
  228. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  229. package/dist/init/manifest/database-scripts.js +5 -3
  230. package/dist/init/manifest/database-scripts.js.map +1 -1
  231. package/dist/init/manifest/scripts-for.d.ts.map +1 -1
  232. package/dist/init/manifest/scripts-for.js +8 -0
  233. package/dist/init/manifest/scripts-for.js.map +1 -1
  234. package/dist/init/manifest/versions.js +24 -24
  235. package/dist/init/orphaned-wiring-notes.d.ts +13 -0
  236. package/dist/init/orphaned-wiring-notes.d.ts.map +1 -0
  237. package/dist/init/orphaned-wiring-notes.js +42 -0
  238. package/dist/init/orphaned-wiring-notes.js.map +1 -0
  239. package/dist/init/profile-hooks.js +1 -1
  240. package/dist/init/profile-hooks.js.map +1 -1
  241. package/dist/init/repositories-left-behind.d.ts +12 -0
  242. package/dist/init/repositories-left-behind.d.ts.map +1 -0
  243. package/dist/init/repositories-left-behind.js +26 -0
  244. package/dist/init/repositories-left-behind.js.map +1 -0
  245. package/dist/init/rewire-audited-events.d.ts +10 -0
  246. package/dist/init/rewire-audited-events.d.ts.map +1 -0
  247. package/dist/init/rewire-audited-events.js +32 -0
  248. package/dist/init/rewire-audited-events.js.map +1 -0
  249. package/dist/init/rewire-contexts.d.ts +15 -0
  250. package/dist/init/rewire-contexts.d.ts.map +1 -0
  251. package/dist/init/rewire-contexts.js +41 -0
  252. package/dist/init/rewire-contexts.js.map +1 -0
  253. package/dist/init/rewire-preset.d.ts +9 -0
  254. package/dist/init/rewire-preset.d.ts.map +1 -0
  255. package/dist/init/rewire-preset.js +29 -0
  256. package/dist/init/rewire-preset.js.map +1 -0
  257. package/dist/init/rewire-tables.d.ts +10 -0
  258. package/dist/init/rewire-tables.d.ts.map +1 -0
  259. package/dist/init/rewire-tables.js +54 -0
  260. package/dist/init/rewire-tables.js.map +1 -0
  261. package/dist/init/run-init.d.ts.map +1 -1
  262. package/dist/init/run-init.js +28 -28
  263. package/dist/init/run-init.js.map +1 -1
  264. package/dist/init/stack/kept-flag-notes.d.ts +7 -0
  265. package/dist/init/stack/kept-flag-notes.d.ts.map +1 -0
  266. package/dist/init/stack/kept-flag-notes.js +24 -0
  267. package/dist/init/stack/kept-flag-notes.js.map +1 -0
  268. package/dist/init/stack/refuse-unused-no-outbox.d.ts +4 -0
  269. package/dist/init/stack/refuse-unused-no-outbox.d.ts.map +1 -0
  270. package/dist/init/stack/refuse-unused-no-outbox.js +9 -0
  271. package/dist/init/stack/refuse-unused-no-outbox.js.map +1 -0
  272. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  273. package/dist/init/stack/resolve-stack.js +10 -0
  274. package/dist/init/stack/resolve-stack.js.map +1 -1
  275. package/dist/init/stack-before.d.ts +4 -0
  276. package/dist/init/stack-before.d.ts.map +1 -0
  277. package/dist/init/stack-before.js +11 -0
  278. package/dist/init/stack-before.js.map +1 -0
  279. package/dist/init/wiring-notes.d.ts +9 -0
  280. package/dist/init/wiring-notes.d.ts.map +1 -0
  281. package/dist/init/wiring-notes.js +22 -0
  282. package/dist/init/wiring-notes.js.map +1 -0
  283. package/dist/init/with-named-imports.d.ts +8 -0
  284. package/dist/init/with-named-imports.d.ts.map +1 -0
  285. package/dist/init/with-named-imports.js +69 -0
  286. package/dist/init/with-named-imports.js.map +1 -0
  287. package/dist/init/with-system-grants.d.ts +7 -0
  288. package/dist/init/with-system-grants.d.ts.map +1 -0
  289. package/dist/init/with-system-grants.js +26 -0
  290. package/dist/init/with-system-grants.js.map +1 -0
  291. package/dist/init/write-local-environment.d.ts +8 -0
  292. package/dist/init/write-local-environment.d.ts.map +1 -0
  293. package/dist/init/write-local-environment.js +18 -0
  294. package/dist/init/write-local-environment.js.map +1 -0
  295. package/dist/lint/eslint-in-project.d.ts +1 -1
  296. package/dist/lint/eslint-in-project.d.ts.map +1 -1
  297. package/dist/lint/eslint-in-project.js +11 -2
  298. package/dist/lint/eslint-in-project.js.map +1 -1
  299. package/dist/markers/index.d.ts +3 -0
  300. package/dist/markers/index.d.ts.map +1 -1
  301. package/dist/markers/index.js +3 -0
  302. package/dist/markers/index.js.map +1 -1
  303. package/dist/markers/region-marker.d.ts +3 -0
  304. package/dist/markers/region-marker.d.ts.map +1 -0
  305. package/dist/markers/region-marker.js +3 -0
  306. package/dist/markers/region-marker.js.map +1 -0
  307. package/dist/markers/regions-of.d.ts +9 -0
  308. package/dist/markers/regions-of.d.ts.map +1 -0
  309. package/dist/markers/regions-of.js +20 -0
  310. package/dist/markers/regions-of.js.map +1 -0
  311. package/dist/markers/unpaired-markers.d.ts +3 -0
  312. package/dist/markers/unpaired-markers.d.ts.map +1 -0
  313. package/dist/markers/unpaired-markers.js +13 -0
  314. package/dist/markers/unpaired-markers.js.map +1 -0
  315. package/dist/merge/apply-resolutions.d.ts.map +1 -1
  316. package/dist/merge/apply-resolutions.js +6 -4
  317. package/dist/merge/apply-resolutions.js.map +1 -1
  318. package/dist/merge/continue-merge.d.ts.map +1 -1
  319. package/dist/merge/continue-merge.js +1 -0
  320. package/dist/merge/continue-merge.js.map +1 -1
  321. package/dist/merge/ensure-mergeable.js +1 -1
  322. package/dist/merge/ensure-mergeable.js.map +1 -1
  323. package/dist/merge/lost/verify-merges.d.ts.map +1 -1
  324. package/dist/merge/lost/verify-merges.js +4 -0
  325. package/dist/merge/lost/verify-merges.js.map +1 -1
  326. package/dist/merge/merge-state.d.ts.map +1 -1
  327. package/dist/merge/merge-state.js +2 -2
  328. package/dist/merge/merge-state.js.map +1 -1
  329. package/dist/merge/merge-trunk.d.ts.map +1 -1
  330. package/dist/merge/merge-trunk.js +4 -0
  331. package/dist/merge/merge-trunk.js.map +1 -1
  332. package/dist/merge/refuse-shallow-history.d.ts +10 -0
  333. package/dist/merge/refuse-shallow-history.d.ts.map +1 -0
  334. package/dist/merge/refuse-shallow-history.js +15 -0
  335. package/dist/merge/refuse-shallow-history.js.map +1 -0
  336. package/dist/merge/resume-merge.js +2 -2
  337. package/dist/merge/resume-merge.js.map +1 -1
  338. package/dist/merge/settle-regions.d.ts.map +1 -1
  339. package/dist/merge/settle-regions.js +3 -4
  340. package/dist/merge/settle-regions.js.map +1 -1
  341. package/dist/migration/audit-guard/append-audit-guard.d.ts +4 -2
  342. package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -1
  343. package/dist/migration/audit-guard/append-audit-guard.js +18 -3
  344. package/dist/migration/audit-guard/append-audit-guard.js.map +1 -1
  345. package/dist/migration/declared-tables.d.ts +8 -0
  346. package/dist/migration/declared-tables.d.ts.map +1 -0
  347. package/dist/migration/declared-tables.js +13 -0
  348. package/dist/migration/declared-tables.js.map +1 -0
  349. package/dist/migration/find-project-formatter.d.ts.map +1 -1
  350. package/dist/migration/find-project-formatter.js +2 -1
  351. package/dist/migration/find-project-formatter.js.map +1 -1
  352. package/dist/migration/index.d.ts +8 -0
  353. package/dist/migration/index.d.ts.map +1 -1
  354. package/dist/migration/index.js +8 -0
  355. package/dist/migration/index.js.map +1 -1
  356. package/dist/migration/knex-migration-text.d.ts +4 -0
  357. package/dist/migration/knex-migration-text.d.ts.map +1 -0
  358. package/dist/migration/knex-migration-text.js +24 -0
  359. package/dist/migration/knex-migration-text.js.map +1 -0
  360. package/dist/migration/knex-schema-difference.d.ts +12 -0
  361. package/dist/migration/knex-schema-difference.d.ts.map +1 -0
  362. package/dist/migration/knex-schema-difference.js +165 -0
  363. package/dist/migration/knex-schema-difference.js.map +1 -0
  364. package/dist/migration/listed-in-index.d.ts +6 -0
  365. package/dist/migration/listed-in-index.d.ts.map +1 -0
  366. package/dist/migration/listed-in-index.js +8 -0
  367. package/dist/migration/listed-in-index.js.map +1 -0
  368. package/dist/migration/refuse-other-orm.d.ts +8 -0
  369. package/dist/migration/refuse-other-orm.d.ts.map +1 -0
  370. package/dist/migration/refuse-other-orm.js +34 -0
  371. package/dist/migration/refuse-other-orm.js.map +1 -0
  372. package/dist/migration/required-migration-name.d.ts +3 -0
  373. package/dist/migration/required-migration-name.d.ts.map +1 -0
  374. package/dist/migration/required-migration-name.js +11 -0
  375. package/dist/migration/required-migration-name.js.map +1 -0
  376. package/dist/migration/warn-dropped-context-tables.d.ts +12 -0
  377. package/dist/migration/warn-dropped-context-tables.d.ts.map +1 -0
  378. package/dist/migration/warn-dropped-context-tables.js +88 -0
  379. package/dist/migration/warn-dropped-context-tables.js.map +1 -0
  380. package/dist/package-manager/dialects.js +1 -1
  381. package/dist/package-manager/dialects.js.map +1 -1
  382. package/dist/package-manager/in-project-dialect.d.ts +8 -0
  383. package/dist/package-manager/in-project-dialect.d.ts.map +1 -0
  384. package/dist/package-manager/in-project-dialect.js +22 -0
  385. package/dist/package-manager/in-project-dialect.js.map +1 -0
  386. package/dist/presets/adapter-of.d.ts +5 -0
  387. package/dist/presets/adapter-of.d.ts.map +1 -0
  388. package/dist/presets/adapter-of.js +6 -0
  389. package/dist/presets/adapter-of.js.map +1 -0
  390. package/dist/presets/apply-preset.d.ts.map +1 -1
  391. package/dist/presets/apply-preset.js +1 -5
  392. package/dist/presets/apply-preset.js.map +1 -1
  393. package/dist/presets/grant-to-signed-in.d.ts.map +1 -1
  394. package/dist/presets/grant-to-signed-in.js +1 -24
  395. package/dist/presets/grant-to-signed-in.js.map +1 -1
  396. package/dist/presets/identity-terms.d.ts.map +1 -1
  397. package/dist/presets/identity-terms.js +4 -0
  398. package/dist/presets/identity-terms.js.map +1 -1
  399. package/dist/presets/lay-out-prisma-models.js +1 -19
  400. package/dist/presets/lay-out-prisma-models.js.map +1 -1
  401. package/dist/presets/organisations-as-tenants.d.ts +2 -2
  402. package/dist/presets/organisations-as-tenants.d.ts.map +1 -1
  403. package/dist/presets/organisations-as-tenants.js +46 -2
  404. package/dist/presets/organisations-as-tenants.js.map +1 -1
  405. package/dist/presets/preset-named.d.ts +2 -0
  406. package/dist/presets/preset-named.d.ts.map +1 -1
  407. package/dist/presets/preset-named.js +1 -1
  408. package/dist/presets/preset-named.js.map +1 -1
  409. package/dist/presets/wrap-authorizer.d.ts +4 -0
  410. package/dist/presets/wrap-authorizer.d.ts.map +1 -0
  411. package/dist/presets/wrap-authorizer.js +25 -0
  412. package/dist/presets/wrap-authorizer.js.map +1 -0
  413. package/dist/prisma-schema/datasource-schemas.d.ts +3 -0
  414. package/dist/prisma-schema/datasource-schemas.d.ts.map +1 -0
  415. package/dist/prisma-schema/datasource-schemas.js +5 -0
  416. package/dist/prisma-schema/datasource-schemas.js.map +1 -0
  417. package/dist/prisma-schema/index.d.ts +4 -0
  418. package/dist/prisma-schema/index.d.ts.map +1 -1
  419. package/dist/prisma-schema/index.js +4 -0
  420. package/dist/prisma-schema/index.js.map +1 -1
  421. package/dist/prisma-schema/preview-features-of.d.ts +3 -0
  422. package/dist/prisma-schema/preview-features-of.d.ts.map +1 -0
  423. package/dist/prisma-schema/preview-features-of.js +7 -0
  424. package/dist/prisma-schema/preview-features-of.js.map +1 -0
  425. package/dist/prisma-schema/with-datasource-schema.d.ts +3 -0
  426. package/dist/prisma-schema/with-datasource-schema.d.ts.map +1 -0
  427. package/dist/prisma-schema/with-datasource-schema.js +9 -0
  428. package/dist/prisma-schema/with-datasource-schema.js.map +1 -0
  429. package/dist/prisma-schema/with-preview-feature.d.ts +3 -0
  430. package/dist/prisma-schema/with-preview-feature.d.ts.map +1 -0
  431. package/dist/prisma-schema/with-preview-feature.js +19 -0
  432. package/dist/prisma-schema/with-preview-feature.js.map +1 -0
  433. package/dist/run.d.ts.map +1 -1
  434. package/dist/run.js +10 -1
  435. package/dist/run.js.map +1 -1
  436. package/dist/sdk/render-client.js +1 -1
  437. package/dist/sdk/render-client.js.map +1 -1
  438. package/dist/slice/record-verification.d.ts.map +1 -1
  439. package/dist/slice/record-verification.js +2 -5
  440. package/dist/slice/record-verification.js.map +1 -1
  441. package/dist/stack/stack-vars.js +6 -2
  442. package/dist/stack/stack-vars.js.map +1 -1
  443. package/dist/stories/open-story-scope.d.ts.map +1 -1
  444. package/dist/stories/open-story-scope.js +2 -4
  445. package/dist/stories/open-story-scope.js.map +1 -1
  446. package/dist/story/change-gated.d.ts +3 -3
  447. package/dist/story/change-gated.d.ts.map +1 -1
  448. package/dist/story/change-gated.js +13 -7
  449. package/dist/story/change-gated.js.map +1 -1
  450. package/dist/version.d.ts +1 -1
  451. package/dist/version.js +1 -1
  452. package/dist/worker/open-worker-scope.d.ts.map +1 -1
  453. package/dist/worker/open-worker-scope.js +2 -3
  454. package/dist/worker/open-worker-scope.js.map +1 -1
  455. package/dist/workspace/write-inside-project.d.ts +8 -0
  456. package/dist/workspace/write-inside-project.d.ts.map +1 -0
  457. package/dist/workspace/write-inside-project.js +17 -0
  458. package/dist/workspace/write-inside-project.js.map +1 -0
  459. package/package.json +5 -5
  460. package/templates/aggregate/event-sourced.events.mapper.ts.tpl +5 -1
  461. package/templates/command/handler.declared.ts.tpl +4 -12
  462. package/templates/command/handler.ts.tpl +4 -12
  463. package/templates/e2e/e2e.spec.ts.tpl +2 -2
  464. package/templates/init/README.md.tpl +29 -5
  465. package/templates/init/docker/docker-compose.yml.tpl +5 -2
  466. package/templates/init/docker/dockerignore.tpl +1 -0
  467. package/templates/init/docker/env.example.tpl +8 -1
  468. package/templates/init/gitignore.tpl +1 -0
  469. package/templates/init/hooks/change-reference.mjs +96 -17
  470. package/templates/init/hooks/production-gate.mjs +65 -11
  471. package/templates/init/jest.config.js.tpl +4 -1
  472. package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +25 -8
  473. package/templates/init/platform/audit/create-audit-trail.ts.tpl +59 -0
  474. package/templates/init/platform/audit/create-audit.ts.tpl +1 -46
  475. package/templates/init/platform/auth/authentication/development-header-authenticator.ts.tpl +7 -3
  476. package/templates/init/platform/auth/relationships/relationship-schema.ts.tpl +5 -0
  477. package/templates/init/platform/composition/compose-application.manual.ts.tpl +22 -7
  478. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +2 -4
  479. package/templates/init/platform/config/app-config.ts.tpl +9 -0
  480. package/templates/init/platform/config/load-config.ts.tpl +24 -0
  481. package/templates/init/platform/database/data-source.typeorm.ts.tpl +6 -0
  482. package/templates/init/platform/database/gitkeep +0 -0
  483. package/templates/init/platform/database/knexfile.js.tpl +10 -3
  484. package/templates/init/platform/database/open-persistence.prisma.ts.tpl +5 -2
  485. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +11 -3
  486. package/templates/init/platform/database/prisma.config.ts.tpl +6 -0
  487. package/templates/init/platform/database/schema.knex.ts.tpl +4 -3
  488. package/templates/init/platform/http/start-http-server.express.ts.tpl +9 -6
  489. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +5 -2
  490. package/templates/init/platform/http/start-http-server.hono.ts.tpl +5 -2
  491. package/templates/init/platform/jobs/job-settings.ts.tpl +3 -0
  492. package/templates/init/platform/privacy/run-export.manual.ts.tpl +24 -2
  493. package/templates/init/platform/privacy/run-export.tsyringe.ts.tpl +30 -1
  494. package/templates/init/scripts/audit-verify.ts.tpl +35 -0
  495. package/templates/init/scripts/privacy-export.manual.ts.tpl +1 -7
  496. package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +1 -7
  497. package/templates/pipeline/github/dependabot.yml +6 -0
  498. package/templates/pipeline/github/workflows/ci.yml.tpl +26 -1
  499. package/templates/pipeline/github/workflows/claude-review.yml +3 -2
  500. package/templates/pipeline/github/workflows/claude-triage.yml +1 -1
  501. package/templates/pipeline/github/workflows/codeql.yml +2 -0
  502. package/templates/pipeline/github/workflows/copilot-setup-steps.yml +2 -0
  503. package/templates/pipeline/github/workflows/intent-to-spec.yml +12 -4
  504. package/templates/pipeline/github/workflows/pr-title.yml +2 -0
  505. package/templates/pipeline/gitlab/claude-review.gitlab-ci.yml.tpl +1 -1
  506. package/templates/pipeline/knip.json.tpl +1 -4
  507. package/templates/pipeline/package-scripts.json +2 -2
  508. package/templates/pipeline/renovate.json +11 -0
  509. package/templates/pipeline/vitest.config.ts.tpl +3 -2
  510. package/templates/presets/identity/context/__context__.codes.named.ts.tpl +1 -0
  511. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +1 -1
  512. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +28 -1
  513. package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +13 -1
  514. package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +6 -1
  515. package/templates/presets/identity/context/domain/errors/invitation-withdrawn.error.named.ts.tpl +13 -0
  516. package/templates/presets/identity/context/domain/errors/invitation.error.factories.ts.tpl +8 -0
  517. package/templates/presets/identity/context/domain/services/role-rights.service.ts.tpl +23 -1
  518. package/templates/presets/identity/context/infrastructure/persistence/__context__.schema.drizzle.ts.tpl +1 -0
  519. package/templates/presets/identity/context/infrastructure/persistence/create-__context__-tables.schema.knex.ts.tpl +1 -0
  520. package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +6 -2
  521. package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +6 -2
  522. package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +6 -2
  523. package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +6 -2
  524. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +6 -2
  525. package/templates/presets/identity/context/infrastructure/persistence/invitation-row.schema.knex.ts.tpl +1 -0
  526. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.drizzle.ts.tpl +2 -0
  527. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.knex.ts.tpl +2 -0
  528. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.prisma.ts.tpl +2 -0
  529. package/templates/presets/identity/context/infrastructure/persistence/prisma-account.repository.prisma.ts.tpl +8 -5
  530. package/templates/presets/identity/context/infrastructure/persistence/prisma-delegation.repository.prisma.ts.tpl +8 -5
  531. package/templates/presets/identity/context/infrastructure/persistence/prisma-invitation.repository.prisma.ts.tpl +8 -5
  532. package/templates/presets/identity/context/infrastructure/persistence/prisma-member.repository.prisma.ts.tpl +8 -5
  533. package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation.repository.prisma.ts.tpl +8 -5
  534. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.kit-routes.ts.tpl +1 -0
  535. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +1 -0
  536. package/templates/presets/identity/context/test/builders/invitation.builder.ts.tpl +15 -2
  537. package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +10 -0
  538. package/templates/presets/identity/context/test/unit/accept-invitation.handler.spec.ts.tpl +114 -4
  539. package/templates/presets/identity/context/test/worlds/__context__.world.explicit.ts.tpl +1 -1
  540. package/templates/presets/identity/design.md.tpl +3 -1
  541. package/templates/presets/identity/prisma/models.prisma.tpl +1 -0
  542. package/templates/query/reader.fake.ts.tpl +4 -6
  543. package/templates/query/reader.in-memory.ts.tpl +1 -1
  544. package/templates/repository/drizzle/repository.ts.tpl +4 -3
  545. package/templates/repository/knex/table.tpl +1 -1
  546. package/templates/repository/prisma/repository.ts.tpl +24 -18
  547. package/templates/state-machine/state-machine.spec.ts.tpl +5 -0
  548. package/templates/init/platform/database/migration.knex.js.tpl +0 -8
@@ -1,8 +1,13 @@
1
1
  {{#if audit.archive}}
2
- import { ArchiveAuditEntries, AuditReader, AuditTrail } from '@ddd-ts-kit/audit';
2
+ import { ArchiveAuditEntries, AuditReader, AuditTrail, VerifyAuditTrail } from '@ddd-ts-kit/audit';
3
3
  {{/if}}
4
4
  {{#unless audit.archive}}
5
+ {{#if audit.sql}}
6
+ import { AuditReader, AuditTrail, VerifyAuditTrail } from '@ddd-ts-kit/audit';
7
+ {{/if}}
8
+ {{#if audit.memory}}
5
9
  import { AuditReader, AuditTrail } from '@ddd-ts-kit/audit';
10
+ {{/if}}
6
11
  {{/unless}}
7
12
  import { defineContextModule, type ContextModule } from '@ddd-ts-kit/di';
8
13
  import { subscribeAll } from '@ddd-ts-kit/events';
@@ -25,16 +30,17 @@ import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-e
25
30
  * The audit trail as a capability of the platform, not a bounded context: the store behind its
26
31
  * two ports, the subscription to every declared integration event, under a name of its own{{#if audit.route}}, and
27
32
  * its read side, one protected query registered like any use case so that reading the trail is
28
- * authorized and recorded{{/if}}{{#if audit.archive}}; and on the first day of every month at 04:00 UTC,
29
- * the entries older than the twelve whole months kept online moved to the storage of files,
30
- * verified and anchored (`audit.archive`){{/if}}.
33
+ * authorized and recorded{{/if}}{{#if audit.sql}}; every night at 04:30 UTC, every chain verified from its last archive{{#if audit.archive}},
34
+ * every archive proved against its file,{{/if}} to its head, a break failing the run (`audit.verify`){{/if}}{{#if audit.archive}}; and on the
35
+ * first day of every month at 04:00 UTC, the entries older than the twelve whole months kept online moved to the
36
+ * storage of files, verified and anchored (`audit.archive`){{/if}}.
31
37
  */
32
- {{#if audit.archive}}
38
+ {{#if audit.sql}}
33
39
  export function auditModule(audit: Audit, { jobs = true }: { readonly jobs?: boolean } = {}): ContextModule {
34
40
  {{/if}}
35
- {{#unless audit.archive}}
41
+ {{#if audit.memory}}
36
42
  export function auditModule(audit: Audit): ContextModule {
37
- {{/unless}}
43
+ {{/if}}
38
44
  return defineContextModule({
39
45
  name: 'audit',
40
46
  register(builder) {
@@ -61,13 +67,24 @@ export function auditModule(audit: Audit): ContextModule {
61
67
  .handledBy(SearchAuditEntriesHandler, [AuditReader]);
62
68
  {{/unless}}
63
69
  {{/if}}
64
- {{#if audit.archive}}
70
+ {{#if audit.sql}}
65
71
 
66
72
  // Registered by the process that runs the jobs of the platform; a service of the deployment passes `jobs: false`.
67
73
  if (jobs) {
74
+ builder
75
+ .job('audit.verify', { cron: '30 4 * * *', tenancy: 'global' })
76
+ {{#if audit.archive}}
77
+ .handledByFactory((resolve) => new VerifyAuditTrail(audit.trail, resolve(FileStorage)));
78
+ {{/if}}
79
+ {{#unless audit.archive}}
80
+ .handledByFactory(() => new VerifyAuditTrail(audit.trail));
81
+ {{/unless}}
82
+ {{#if audit.archive}}
83
+
68
84
  builder
69
85
  .job('audit.archive', { cron: '0 4 1 * *', tenancy: 'global' })
70
86
  .handledByFactory((resolve) => new ArchiveAuditEntries(audit.trail, resolve(FileStorage), resolve(Clock)));
87
+ {{/if}}
71
88
  }
72
89
  {{/if}}
73
90
  },
@@ -0,0 +1,59 @@
1
+ {{#if audit.sql}}
2
+ import type { ArchivableAuditTrail, AuditReader, AuditTrail } from '@ddd-ts-kit/audit';
3
+ {{/if}}
4
+ {{#if audit.memory}}
5
+ import { InMemoryAuditTrail, type ArchivableAuditTrail, type AuditReader, type AuditTrail } from '@ddd-ts-kit/audit';
6
+ {{/if}}
7
+ {{#if audit.knex}}
8
+ import { KnexAuditTrail } from '@ddd-ts-kit/audit/knex';
9
+ {{/if}}
10
+ {{#if audit.drizzle}}
11
+ import { DrizzleAuditTrail } from '@ddd-ts-kit/audit/drizzle';
12
+ {{/if}}
13
+ {{#if audit.prisma}}
14
+ import { PrismaAuditTrail } from '@ddd-ts-kit/audit/prisma';
15
+ {{/if}}
16
+ {{#if audit.typeorm}}
17
+ import { TypeOrmAuditTrail } from '@ddd-ts-kit/audit/typeorm';
18
+ {{/if}}
19
+ {{#if audit.sql}}
20
+ import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
21
+ {{/if}}
22
+ {{#if audit.schemaFile}}
23
+ import { AUDIT_SCHEMA } from '{{alias.platform}}/database/schema{{alias.ext}}';
24
+ {{/if}}
25
+
26
+ {{#if audit.knex}}
27
+ /** The store of the entries in the database of the project: the platform writes it, `scripts/audit-verify.ts` verifies it. */
28
+ export function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
29
+ return new KnexAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
30
+ }
31
+ {{/if}}
32
+ {{#if audit.drizzle}}
33
+ /** The store of the entries in the database of the project: the platform writes it, `scripts/audit-verify.ts` verifies it. */
34
+ export function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
35
+ return new DrizzleAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
36
+ }
37
+ {{/if}}
38
+ {{#if audit.prisma}}
39
+ /** The schema the models of the trail declare in prisma/schema/schema.prisma (`@@schema("audit")`). */
40
+ const AUDIT_SCHEMA = 'audit';
41
+
42
+ /** The store of the entries in the database of the project: the platform writes it, `scripts/audit-verify.ts` verifies it. */
43
+ export function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
44
+ return new PrismaAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
45
+ }
46
+ {{/if}}
47
+ {{#if audit.typeorm}}
48
+ /** The store of the entries in the database of the project: the platform writes it, `scripts/audit-verify.ts` verifies it. */
49
+ export function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
50
+ return new TypeOrmAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
51
+ }
52
+ {{/if}}
53
+ {{#if audit.memory}}
54
+ /** The store of the entries, in the memory of the process. */
55
+ // TODO(platform): the audit package stores on the four ORMs only: write an adapter of AuditTrail and AuditReader for your storage, hold it to `auditTrailContract` of @ddd-ts-kit/audit/testing and answer it here. Until then the entries live in the memory of the process and are lost when it stops.
56
+ export function createAuditTrail(): AuditTrail & AuditReader & ArchivableAuditTrail {
57
+ return new InMemoryAuditTrail();
58
+ }
59
+ {{/if}}
@@ -17,7 +17,6 @@ import {
17
17
  {{/if}}
18
18
  {{#if audit.memory}}
19
19
  import {
20
- InMemoryAuditTrail,
21
20
  {{#if tenancy.any}}
22
21
  TenantAuditReader,
23
22
  {{/if}}
@@ -33,29 +32,15 @@ import {
33
32
  type GuardRefusalOfARoute,
34
33
  } from '@ddd-ts-kit/audit';
35
34
  {{/if}}
36
- {{#if audit.knex}}
37
- import { KnexAuditTrail } from '@ddd-ts-kit/audit/knex';
38
- {{/if}}
39
- {{#if audit.drizzle}}
40
- import { DrizzleAuditTrail } from '@ddd-ts-kit/audit/drizzle';
41
- {{/if}}
42
- {{#if audit.prisma}}
43
- import { PrismaAuditTrail } from '@ddd-ts-kit/audit/prisma';
44
- {{/if}}
45
- {{#if audit.typeorm}}
46
- import { TypeOrmAuditTrail } from '@ddd-ts-kit/audit/typeorm';
47
- {{/if}}
48
35
  import type { OnDecision } from '@ddd-ts-kit/auth';
49
36
  import type { EventSubscription } from '@ddd-ts-kit/events';
50
37
  import type { AuditRecord, BusMiddleware, Logger } from '@ddd-ts-kit/kernel';
51
38
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
52
- {{#if audit.schemaFile}}
53
- import { AUDIT_SCHEMA } from '{{alias.platform}}/database/schema{{alias.ext}}';
54
- {{/if}}
55
39
  {{#if audit.route}}
56
40
  import { auditPermissions } from '{{alias.platform}}/audit/audit.permissions{{alias.ext}}';
57
41
  {{/if}}
58
42
  import { auditedEvents } from '{{alias.platform}}/audit/audited-events{{alias.ext}}';
43
+ import { createAuditTrail } from '{{alias.platform}}/audit/create-audit-trail{{alias.ext}}';
59
44
  {{#if audit.route}}
60
45
  import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.query{{alias.ext}}';
61
46
  {{/if}}
@@ -131,33 +116,3 @@ export function createAudit(persistence: Persistence, source: AuditSource, logge
131
116
  onLostRecord,
132
117
  };
133
118
  }
134
-
135
- {{#if audit.knex}}
136
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
137
- return new KnexAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
138
- }
139
- {{/if}}
140
- {{#if audit.drizzle}}
141
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
142
- return new DrizzleAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
143
- }
144
- {{/if}}
145
- {{#if audit.prisma}}
146
- /** The schema the models of the trail declare in prisma/schema/schema.prisma (`@@schema("audit")`). */
147
- const AUDIT_SCHEMA = 'audit';
148
-
149
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
150
- return new PrismaAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
151
- }
152
- {{/if}}
153
- {{#if audit.typeorm}}
154
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
155
- return new TypeOrmAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
156
- }
157
- {{/if}}
158
- {{#if audit.memory}}
159
- // TODO(platform): the audit package stores on the four ORMs only: write an adapter of AuditTrail and AuditReader for your storage, hold it to `auditTrailContract` of @ddd-ts-kit/audit/testing and answer it here. Until then the entries live in the memory of the process and are lost when it stops.
160
- function createAuditTrail(): AuditTrail & AuditReader & ArchivableAuditTrail {
161
- return new InMemoryAuditTrail();
162
- }
163
- {{/if}}
@@ -1,15 +1,19 @@
1
1
  import { InvalidCredentialError, type Authenticator } from '@ddd-ts-kit/auth';
2
2
  import { anonymousActor, type Actor } from '@ddd-ts-kit/kernel';
3
3
 
4
+ /** Where a header is believed in place of a credential: nowhere else, production included. */
5
+ const BELIEVED_IN = ['development', 'test'];
6
+
4
7
  /**
5
8
  * Development only: trusts a header instead of verifying a credential. The header reads
6
- * `<id>`, `<id>;roles=<a>,<b>` or `<id>;roles=<a>;tenant=<t>`. It refuses to exist in production.
9
+ * `<id>`, `<id>;roles=<a>,<b>` or `<id>;roles=<a>;tenant=<t>`. It exists in development and test
10
+ * only, never in production.
7
11
  */
8
12
  export class DevelopmentHeaderAuthenticator implements Authenticator {
9
13
  constructor(environment: string) {
10
- if (environment === 'production') {
14
+ if (!BELIEVED_IN.includes(environment)) {
11
15
  throw new Error(
12
- 'DevelopmentHeaderAuthenticator must never run in production: bind a real adapter of Authenticator',
16
+ 'DevelopmentHeaderAuthenticator runs in development and test only, never in production: bind a real adapter of Authenticator',
13
17
  );
14
18
  }
15
19
  }
@@ -19,6 +19,11 @@ const modelledOnAnElement = new Set(Object.values(elements).flatMap((element) =>
19
19
  * element names its context as the resource (`{ type: 'context', id: '<context>' }`), and the
20
20
  * operators of the context hold every permission no element derives. A system actor (a scheduled
21
21
  * job, an integration event handler) is a subject of type `system`.
22
+ {{#if tenancy.any}}
23
+ * A tuple names no tenant: the operator of a context operates it in every tenant, so decide per
24
+ * tenant what a use case on no element allows (roles with the tenant check, or an object that
25
+ * names the tenant), and keep the relationships for the elements, whose ids no two tenants share.
26
+ {{/if}}
22
27
  */
23
28
  export const relationshipSchema = defineSchema({
24
29
  user: {},
@@ -18,8 +18,13 @@ import { CommandBus, QueryBus } from '@ddd-ts-kit/kernel';
18
18
  import { classSchema } from '@ddd-ts-kit/validation/class-validator';
19
19
  {{/if}}
20
20
  {{#if audit.archive}}
21
- import { ArchiveAuditEntries } from '@ddd-ts-kit/audit';
21
+ import { ArchiveAuditEntries, VerifyAuditTrail } from '@ddd-ts-kit/audit';
22
22
  {{/if}}
23
+ {{#unless audit.archive}}
24
+ {{#if audit.sql}}
25
+ import { VerifyAuditTrail } from '@ddd-ts-kit/audit';
26
+ {{/if}}
27
+ {{/unless}}
23
28
  {{#if files.any}}
24
29
  import { PurgeStagedFiles } from '@ddd-ts-kit/kernel';
25
30
  {{/if}}
@@ -322,8 +327,8 @@ function registerPlatformJobs(platform: Platform, options: ApplicationOptions):
322
327
  {{#if files.any}}
323
328
  purgeStagedFiles(platform);
324
329
  {{/if}}
325
- {{#if audit.archive}}
326
- archiveAuditEntries(platform);
330
+ {{#if audit.sql}}
331
+ auditJobs(platform);
327
332
  {{/if}}
328
333
  {{#if privacy.on}}
329
334
  purgeExpiredEveryNight(platform);
@@ -345,16 +350,26 @@ function purgeStagedFiles(platform: Platform): void {
345
350
  platform.jobs.register({ name: 'files.purge-staged', schedule: { every: '1h' }, run: () => purge.run() });
346
351
  }
347
352
  {{/if}}
348
- {{#if audit.archive}}
353
+ {{#if audit.sql}}
349
354
 
350
355
  /**
351
- * The entries of the audit trail older than the twelve whole months it keeps online, moved to the
352
- * storage on the first day of every month at 04:00 UTC, verified and anchored.
356
+ * Every chain of the audit trail verified every night at 04:30 UTC, from its last archive{{#if audit.archive}}, proved against its file,{{/if}} to its head{{#if audit.archive}}; and the entries
357
+ * older than the twelve whole months it keeps online moved to the storage on the first day of every month at 04:00 UTC,
358
+ * verified and anchored{{/if}}.
353
359
  */
354
- function archiveAuditEntries(platform: Platform): void {
360
+ function auditJobs(platform: Platform): void {
361
+ {{#if audit.archive}}
362
+ const verify = new VerifyAuditTrail(platform.audit.trail, platform.files.storage);
355
363
  const archive = new ArchiveAuditEntries(platform.audit.trail, platform.files.storage, platform.clock);
364
+ {{/if}}
365
+ {{#unless audit.archive}}
366
+ const verify = new VerifyAuditTrail(platform.audit.trail);
367
+ {{/unless}}
356
368
 
369
+ platform.jobs.register({ name: 'audit.verify', schedule: { cron: '30 4 * * *' }, run: () => verify.run() });
370
+ {{#if audit.archive}}
357
371
  platform.jobs.register({ name: 'audit.archive', schedule: { cron: '0 4 1 * *' }, run: () => archive.run() });
372
+ {{/if}}
358
373
  }
359
374
  {{/if}}
360
375
  {{#if privacy.on}}
@@ -217,13 +217,11 @@ export function composeApplication(
217
217
  eventSourcingModule(foundations.eventSourcing),
218
218
  {{/if}}
219
219
  guard,
220
- {{#if audit.on}}
221
- {{#if audit.archive}}
220
+ {{#if audit.sql}}
222
221
  auditModule(foundations.audit, { jobs: options.platformJobs !== false }),
223
222
  {{/if}}
224
- {{#unless audit.archive}}
223
+ {{#if audit.memory}}
225
224
  auditModule(foundations.audit),
226
- {{/unless}}
227
225
  {{/if}}
228
226
  {{#if files.any}}
229
227
  filesModule(options.files ?? new InMemoryFileStorage(), { jobs: options.platformJobs !== false }),
@@ -36,6 +36,15 @@ export interface AppConfig {
36
36
  {{#if persistence.needsUrl}}
37
37
  readonly databaseUrl: string;
38
38
  {{/if}}
39
+ {{#if orm.prisma}}
40
+ /**
41
+ * How long a unit of work waits for its transaction, every connection being busy
42
+ * (`DATABASE_TRANSACTION_WAIT_MS`), and how long the transaction may run
43
+ * (`DATABASE_TRANSACTION_TIMEOUT_MS`): Prisma bounds both, beyond which the unit of work is
44
+ * answered 503.
45
+ */
46
+ readonly databaseTransaction: { readonly waitMs: number; readonly timeoutMs: number };
47
+ {{/if}}
39
48
  {{#if events.outbox}}
40
49
  readonly outboxRelayIntervalMs: number;
41
50
  {{/if}}
@@ -45,6 +45,13 @@ const runJobsByDefault = false;
45
45
  export function loadConfig(variables: Variables): AppConfig {
46
46
  const env = new Environment(variables);
47
47
  const environment = env.oneOf('NODE_ENV', environments, 'development');
48
+ {{#if authn.none}}
49
+
50
+ // The development header is believed where NODE_ENV says so, never by default.
51
+ if (env.optional('NODE_ENV') === undefined) {
52
+ env.problem('NODE_ENV must be development or test: the development header is believed there only');
53
+ }
54
+ {{/if}}
48
55
 
49
56
  const config: AppConfig = {
50
57
  serviceName: env.optional('OTEL_SERVICE_NAME') ?? '{{project.name}}',
@@ -62,6 +69,9 @@ export function loadConfig(variables: Variables): AppConfig {
62
69
  {{#if persistence.needsUrl}}
63
70
  databaseUrl: env.url('DATABASE_URL'),
64
71
  {{/if}}
72
+ {{#if orm.prisma}}
73
+ databaseTransaction: readDatabaseTransaction(env),
74
+ {{/if}}
65
75
  {{#if events.outbox}}
66
76
  outboxRelayIntervalMs: env.integer('OUTBOX_RELAY_INTERVAL_MS', { fallback: 500, min: 10, max: 60000 }),
67
77
  {{/if}}
@@ -131,6 +141,20 @@ function readHousekeeping(env: Environment): Housekeeping {
131
141
  };
132
142
  }
133
143
 
144
+ {{/if}}
145
+ {{#if orm.prisma}}
146
+ /**
147
+ * The limits of an interactive transaction of Prisma: 10 seconds of waiting for a connection and
148
+ * 30 of work by default, where Prisma gives up after 2 and 5. Not more: a caller gives up near 30
149
+ * seconds, and a connection held longer for an answer nobody reads sheds no load.
150
+ */
151
+ function readDatabaseTransaction(env: Environment): AppConfig['databaseTransaction'] {
152
+ return {
153
+ waitMs: env.integer('DATABASE_TRANSACTION_WAIT_MS', { fallback: 10_000, min: 1, max: 3_600_000 }),
154
+ timeoutMs: env.integer('DATABASE_TRANSACTION_TIMEOUT_MS', { fallback: 30_000, min: 1, max: 3_600_000 }),
155
+ };
156
+ }
157
+
134
158
  {{/if}}
135
159
  {{#if tenancy.any}}
136
160
  /** `TENANTS=acme,globex`: each id in the grammar of a tenant id. */
@@ -1,6 +1,12 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import { DataSource } from 'typeorm';
2
3
  import { entities } from '{{alias.platform}}/database/schema{{alias.ext}}';
3
4
 
5
+ // The TypeORM CLI reads no .env: `npm run db:migrate` finds DATABASE_URL there, and what the shell sets wins.
6
+ if (existsSync('.env')) {
7
+ process.loadEnvFile('.env');
8
+ }
9
+
4
10
  // Read by the TypeORM CLI only (`npm run db:generate migrations/<what-it-does>`, `npm run db:migrate`), once compiled.
5
11
  export default new DataSource({
6
12
  type: 'postgres',
File without changes
@@ -1,9 +1,16 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import { createRequire } from 'node:module';
2
3
  import process from 'node:process';
3
4
 
4
- // Read by the knex CLI (`npm run db:migrate`, `npm run db:generate <what-it-does>`). The migrations
5
- // call the compiled schema of the application: run `npm run build` first. A new migration is
6
- // `<timestamp>_<what-it-does>.js`, written from the ES module stub of knex: the project is ESM.
5
+ // The knex CLI reads no .env: `npm run db:migrate` finds DATABASE_URL there, and what the shell sets wins.
6
+ if (existsSync('.env')) {
7
+ process.loadEnvFile('.env');
8
+ }
9
+
10
+ // Read by the knex CLI (`npm run db:migrate`) and by `npm run db:generate <what-it-does>`, which
11
+ // writes `<timestamp>_<what-it-does>.js`, its SQL held in the file: a migration calls nothing of the
12
+ // application, so that it builds the same tables whatever the schema becomes. With `--custom`, the
13
+ // file is the ES module stub of knex (the project is ESM), to fill by hand.
7
14
  export default {
8
15
  client: 'pg',
9
16
  connection: process.env.DATABASE_URL,
@@ -1,11 +1,14 @@
1
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
1
2
  import { createClient } from '{{alias.platform}}/database/create-client{{alias.ext}}';
2
3
  import { persistenceOver } from '{{alias.platform}}/database/persistence-over{{alias.ext}}';
3
4
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
4
5
 
5
- export async function openPersistence(config: { readonly databaseUrl: string }): Promise<Persistence> {
6
+ export async function openPersistence(
7
+ config: Pick<AppConfig, 'databaseUrl' | 'databaseTransaction'>,
8
+ ): Promise<Persistence> {
6
9
  const client = createClient(config.databaseUrl);
7
10
 
8
11
  await client.$connect();
9
12
 
10
- return persistenceOver(client);
13
+ return persistenceOver(client, config.databaseTransaction);
11
14
  }
@@ -26,6 +26,7 @@ import { createPrismaUnitOfWork, PrismaOutboxStore, PrismaProcessedEventStore }
26
26
  {{/unless}}
27
27
  {{/unless}}
28
28
  import type { PrismaClient } from '{{alias.generated}}/prisma/client{{alias.ext}}';
29
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
29
30
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
30
31
 
31
32
  /** The schema of the messaging tables{{#if queue.processTable}} and of the background work{{/if}}, as prisma/schema/schema.prisma names it. */
@@ -35,9 +36,16 @@ const MESSAGING_SCHEMA = 'messaging';
35
36
  const EVENT_STORE_SCHEMA = 'event_store';
36
37
  {{/if}}
37
38
 
38
- /** One object is the unit of work and what repositories query through; the stores are told how to reach their model. */
39
- export function persistenceOver(client: PrismaClient): Persistence {
40
- const unitOfWork = createPrismaUnitOfWork(client);
39
+ /**
40
+ * One object is the unit of work and what repositories query through; the stores are told how to reach their model.
41
+ * `transaction` bounds the wait and the run of each transaction (`maxWait`, `timeout`); left out, the defaults of
42
+ * Prisma apply (2 and 5 seconds), as in the tests.
43
+ */
44
+ export function persistenceOver(client: PrismaClient, transaction?: AppConfig['databaseTransaction']): Persistence {
45
+ const unitOfWork = createPrismaUnitOfWork(
46
+ client,
47
+ transaction === undefined ? undefined : { maxWait: transaction.waitMs, timeout: transaction.timeoutMs },
48
+ );
41
49
 
42
50
  return {
43
51
  unitOfWork,
@@ -1,5 +1,11 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import { defineConfig } from 'prisma/config';
2
3
 
4
+ // The Prisma CLI reads no .env: `npm run db:migrate` finds DATABASE_URL there, and what the shell sets wins.
5
+ if (existsSync('.env')) {
6
+ process.loadEnvFile('.env');
7
+ }
8
+
3
9
  export default defineConfig({
4
10
  // Every .prisma file of the folder: schema.prisma (the client, the datasource, the platform) and one file per context.
5
11
  schema: './prisma/schema',
@@ -18,9 +18,10 @@ export const AUDIT_SCHEMA = 'audit';
18
18
  {{/if}}
19
19
 
20
20
  /**
21
- * Every table of the application. The first migration (migrations/00000000000000_initial.js) and the
22
- * in-process database of the tests both call it; once a database is shared, a change of an
23
- * existing table goes into a migration of its own (`npm run db:generate <what-it-does>`).
21
+ * Every table of the application: what the in-process database of the tests runs, and what
22
+ * `npm run db:generate <what-it-does>` compares with the migrations, to write the difference into a
23
+ * new one. No migration calls it: a migration holds its SQL, and builds the same tables whatever
24
+ * this function becomes.
24
25
  */
25
26
  export const createTables = async (knex: Knex): Promise<void> => {
26
27
  {{#if tenancy.any}}
@@ -1,7 +1,7 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { AddressInfo } from 'node:net';
3
3
  import express from 'express';
4
- import { mountExpress, problemErrorHandler } from '@ddd-ts-kit/http/express';
4
+ import { mountExpress, problemErrorHandler, problemNotFoundHandler } from '@ddd-ts-kit/http/express';
5
5
  {{#if rpc.orpc}}
6
6
  import { orpcRouter } from '@ddd-ts-kit/http/orpc';
7
7
  import { RPCHandler } from '@orpc/server/node';
@@ -33,8 +33,8 @@ type Served = Pick<Application, 'routes' | 'boundary' | 'logger'{{#if cache.rate
33
33
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
34
34
  * server), the signed file links before any body parser (with a storage the application serves),
35
35
  * the routes of the contexts, then the pages of the contract (with documentation on), and last the
36
- * problem of a request refused before its route: a body that is not JSON or too large, a failed
37
- * middleware.{{#if rpc.orpc}} The same
36
+ * problem of a path no route serves and of a request refused before its route: a body that is not
37
+ * JSON or too large, a failed middleware.{{#if rpc.orpc}} The same
38
38
  * routes are served as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same
39
39
  * routes are served as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
40
40
  */
@@ -71,7 +71,9 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
71
71
  {{#unless docs.any}}
72
72
  mountExpress(app, served.routes, served.boundary);
73
73
  {{/unless}}
74
- // Instead of the final handler of Express, which answers HTML and writes the error, body included, to stderr.
74
+ // Instead of the final handler of Express, which answers HTML: a path no route serves, then an error, the
75
+ // one written to stderr with the body it quotes.
76
+ app.use(problemNotFoundHandler({ logger: served.logger }));
75
77
  app.use(problemErrorHandler({ logger: served.logger }));
76
78
 
77
79
  const server = await listen(app, config.port);
@@ -138,8 +140,9 @@ function serveProcedures(app: express.Express, served: Served): void {
138
140
  {{/if}}
139
141
 
140
142
  function listen(app: express.Express, port: number): Promise<Server> {
141
- return new Promise<Server>((resolve) => {
142
- const server = app.listen(port, () => resolve(server));
143
+ return new Promise<Server>((resolve, reject) => {
144
+ // Express 5 hands the error of listen to this callback, a port in use among them: the start fails with it.
145
+ const server = app.listen(port, (error) => (error === undefined ? resolve(server) : reject(error)));
143
146
  });
144
147
  }
145
148
 
@@ -1,5 +1,5 @@
1
1
  import Fastify{{#if cache.rateLimit}}, { type FastifyInstance }{{/if}}{{#unless cache.rateLimit}}{{#unless rpc.none}}, { type FastifyInstance }{{/unless}}{{/unless}} from 'fastify';
2
- import { mountFastify, problemErrorHandler } from '@ddd-ts-kit/http/fastify';
2
+ import { mountFastify, problemErrorHandler, problemNotFoundHandler } from '@ddd-ts-kit/http/fastify';
3
3
  {{#if rpc.orpc}}
4
4
  import { orpcRouter } from '@ddd-ts-kit/http/orpc';
5
5
  import { RPCHandler } from '@orpc/server/fastify';
@@ -30,7 +30,8 @@ type Served = Pick<Application, 'routes' | 'boundary' | 'logger'{{#if cache.rate
30
30
  /**
31
31
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
32
32
  * server), the signed file links (with a storage the application serves), the routes of the
33
- * contexts, then the pages of the contract (with documentation on).{{#if rpc.orpc}} The same routes are served
33
+ * contexts, then the pages of the contract (with documentation on), and last the problem of a
34
+ * path no route serves.{{#if rpc.orpc}} The same routes are served
34
35
  * as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same routes are served
35
36
  * as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
36
37
  */
@@ -40,6 +41,8 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
40
41
 
41
42
  // Before any route: a body Fastify refuses and a failed hook are answered as problems, not with their message.
42
43
  app.setErrorHandler(problemErrorHandler({ logger: served.logger }));
44
+ // A path no route serves is answered 404 as a problem, not as `{ message, error, statusCode }`.
45
+ app.setNotFoundHandler(problemNotFoundHandler({ logger: served.logger }));
43
46
 
44
47
  {{#if cache.rateLimit}}
45
48
  answerReadiness(app, served);
@@ -4,7 +4,7 @@ import { serve, type ServerType } from '@hono/node-server';
4
4
  import { getConnInfo } from '@hono/node-server/conninfo';
5
5
  {{/if}}
6
6
  import { Hono } from 'hono';
7
- import { mountHono, problemErrorHandler } from '@ddd-ts-kit/http/hono';
7
+ import { mountHono, problemErrorHandler, problemNotFoundHandler } from '@ddd-ts-kit/http/hono';
8
8
  {{#if rpc.orpc}}
9
9
  import { orpcRouter } from '@ddd-ts-kit/http/orpc';
10
10
  import { RPCHandler } from '@orpc/server/fetch';
@@ -35,7 +35,8 @@ type Served = Pick<Application, 'routes' | 'boundary' | 'logger'{{#if cache.rate
35
35
  /**
36
36
  * Serves, in this order: the readiness probe and the limit of each caller (with a Redis protocol
37
37
  * server), the signed file links (with a storage the application serves), the routes of the
38
- * contexts, then the pages of the contract (with documentation on).{{#if rpc.orpc}} The same routes are served
38
+ * contexts, then the pages of the contract (with documentation on), and last the problem of a
39
+ * path no route serves.{{#if rpc.orpc}} The same routes are served
39
40
  * as oRPC procedures under /rpc, for the typed client of the contract.{{/if}}{{#if rpc.trpc}} The same routes are served
40
41
  * as tRPC procedures under /trpc, for the typed client of the contract.{{/if}}
41
42
  */
@@ -44,6 +45,8 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
44
45
 
45
46
  // A failed middleware is answered as a problem, not as a text with the error written to stderr.
46
47
  app.onError(problemErrorHandler({ logger: served.logger }));
48
+ // A path no route serves is answered 404 as a problem, not as the text of Hono.
49
+ app.notFound(problemNotFoundHandler({ logger: served.logger }));
47
50
 
48
51
  {{#if cache.rateLimit}}
49
52
  answerReadiness(app, served);
@@ -19,6 +19,9 @@ const extracted: readonly string[] = [
19
19
  */
20
20
  export function jobSettings(environment: Environment, context?: string): Readonly<Record<string, JobSettings>> {
21
21
  const settings: Readonly<Record<string, JobSettings>> = {
22
+ {{#if audit.sql}}
23
+ 'audit.verify': { enabled: environment['JOB_AUDIT_VERIFY_ENABLED'] !== 'false' },
24
+ {{/if}}
22
25
  {{#if audit.archiveByDefault}}
23
26
  'audit.archive': { enabled: environment['JOB_AUDIT_ARCHIVE_ENABLED'] !== 'false' },
24
27
  {{/if}}