ddd-ts-kit 0.101.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 (814) hide show
  1. package/CHANGELOG.md +320 -0
  2. package/README.fr.md +11 -12
  3. package/README.md +10 -11
  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/emitted-place.d.ts +1 -2
  8. package/dist/build/emitted-place.d.ts.map +1 -1
  9. package/dist/build/emitted-specifier.d.ts +7 -1
  10. package/dist/build/emitted-specifier.d.ts.map +1 -1
  11. package/dist/build/emitted-specifier.js +5 -6
  12. package/dist/build/emitted-specifier.js.map +1 -1
  13. package/dist/build/emitted-target.d.ts +6 -5
  14. package/dist/build/emitted-target.d.ts.map +1 -1
  15. package/dist/build/emitted-target.js +5 -9
  16. package/dist/build/emitted-target.js.map +1 -1
  17. package/dist/build/rewrite-aliases.d.ts.map +1 -1
  18. package/dist/build/rewrite-aliases.js +7 -5
  19. package/dist/build/rewrite-aliases.js.map +1 -1
  20. package/dist/build/rewrite-specifiers.d.ts +7 -6
  21. package/dist/build/rewrite-specifiers.d.ts.map +1 -1
  22. package/dist/build/rewrite-specifiers.js +6 -4
  23. package/dist/build/rewrite-specifiers.js.map +1 -1
  24. package/dist/build/unresolved-problem.d.ts +2 -1
  25. package/dist/build/unresolved-problem.d.ts.map +1 -1
  26. package/dist/build/unresolved-problem.js +2 -2
  27. package/dist/build/unresolved-problem.js.map +1 -1
  28. package/dist/check/baseline/write-baseline.d.ts.map +1 -1
  29. package/dist/check/baseline/write-baseline.js +2 -3
  30. package/dist/check/baseline/write-baseline.js.map +1 -1
  31. package/dist/check/business-names/parameter-lists.js +1 -3
  32. package/dist/check/business-names/parameter-lists.js.map +1 -1
  33. package/dist/check/engine/run-check.d.ts +3 -0
  34. package/dist/check/engine/run-check.d.ts.map +1 -1
  35. package/dist/check/engine/run-check.js +1 -1
  36. package/dist/check/engine/run-check.js.map +1 -1
  37. package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
  38. package/dist/check/errors/kit-error-codes.js +1 -0
  39. package/dist/check/errors/kit-error-codes.js.map +1 -1
  40. package/dist/check/explain/authz-docs.js +1 -1
  41. package/dist/check/explain/authz-docs.js.map +1 -1
  42. package/dist/check/explain/errors-docs.js +1 -1
  43. package/dist/check/explain/errors-docs.js.map +1 -1
  44. package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
  45. package/dist/check/explain/tenancy-docs.js +13 -3
  46. package/dist/check/explain/tenancy-docs.js.map +1 -1
  47. package/dist/check/fixtures/authz-policy-fixtures.d.ts.map +1 -1
  48. package/dist/check/fixtures/authz-policy-fixtures.js +13 -1
  49. package/dist/check/fixtures/authz-policy-fixtures.js.map +1 -1
  50. package/dist/check/fixtures/conjunct-cases.d.ts +11 -0
  51. package/dist/check/fixtures/conjunct-cases.d.ts.map +1 -0
  52. package/dist/check/fixtures/conjunct-cases.js +19 -0
  53. package/dist/check/fixtures/conjunct-cases.js.map +1 -0
  54. package/dist/check/fixtures/run-fixture.d.ts +3 -2
  55. package/dist/check/fixtures/run-fixture.d.ts.map +1 -1
  56. package/dist/check/fixtures/run-fixture.js +3 -3
  57. package/dist/check/fixtures/run-fixture.js.map +1 -1
  58. package/dist/check/fixtures/run-self-check.js +1 -1
  59. package/dist/check/fixtures/run-self-check.js.map +1 -1
  60. package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.d.ts +3 -0
  61. package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.d.ts.map +1 -0
  62. package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.js +33 -0
  63. package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.js.map +1 -0
  64. package/dist/check/fixtures/tenancy-conjunct-fixtures.d.ts +4 -0
  65. package/dist/check/fixtures/tenancy-conjunct-fixtures.d.ts.map +1 -0
  66. package/dist/check/fixtures/tenancy-conjunct-fixtures.js +12 -0
  67. package/dist/check/fixtures/tenancy-conjunct-fixtures.js.map +1 -0
  68. package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.d.ts +3 -0
  69. package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.d.ts.map +1 -0
  70. package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.js +49 -0
  71. package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.js.map +1 -0
  72. package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.d.ts +3 -0
  73. package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.d.ts.map +1 -0
  74. package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.js +32 -0
  75. package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.js.map +1 -0
  76. package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.d.ts +3 -0
  77. package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.d.ts.map +1 -0
  78. package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.js +34 -0
  79. package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.js.map +1 -0
  80. package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
  81. package/dist/check/fixtures/tenancy-fixtures.js +2 -0
  82. package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
  83. package/dist/check/rules/authz-policy-asked.d.ts.map +1 -1
  84. package/dist/check/rules/authz-policy-asked.js +45 -6
  85. package/dist/check/rules/authz-policy-asked.js.map +1 -1
  86. package/dist/check/rules/clean-one-export-per-file.js +1 -0
  87. package/dist/check/rules/clean-one-export-per-file.js.map +1 -1
  88. package/dist/check/rules/schema-no-duplicate-shape.js +1 -3
  89. package/dist/check/rules/schema-no-duplicate-shape.js.map +1 -1
  90. package/dist/check/rules/tenancy-scoped-statement.js +2 -2
  91. package/dist/check/rules/tenancy-scoped-statement.js.map +1 -1
  92. package/dist/check/rules/test-spec-required.d.ts.map +1 -1
  93. package/dist/check/rules/test-spec-required.js +3 -1
  94. package/dist/check/rules/test-spec-required.js.map +1 -1
  95. package/dist/check/scan/named-outside-imports.d.ts +3 -0
  96. package/dist/check/scan/named-outside-imports.d.ts.map +1 -0
  97. package/dist/check/scan/named-outside-imports.js +8 -0
  98. package/dist/check/scan/named-outside-imports.js.map +1 -0
  99. package/dist/check/scan/star-exports-of.d.ts +3 -0
  100. package/dist/check/scan/star-exports-of.d.ts.map +1 -0
  101. package/dist/check/scan/star-exports-of.js +8 -0
  102. package/dist/check/scan/star-exports-of.js.map +1 -0
  103. package/dist/check/scan/string-at.d.ts +3 -0
  104. package/dist/check/scan/string-at.d.ts.map +1 -0
  105. package/dist/check/scan/string-at.js +5 -0
  106. package/dist/check/scan/string-at.js.map +1 -0
  107. package/dist/check/tenancy/arguments-of-call.d.ts +3 -0
  108. package/dist/check/tenancy/arguments-of-call.d.ts.map +1 -0
  109. package/dist/check/tenancy/arguments-of-call.js +11 -0
  110. package/dist/check/tenancy/arguments-of-call.js.map +1 -0
  111. package/dist/check/tenancy/bare-expression.d.ts +3 -0
  112. package/dist/check/tenancy/bare-expression.d.ts.map +1 -0
  113. package/dist/check/tenancy/bare-expression.js +9 -0
  114. package/dist/check/tenancy/bare-expression.js.map +1 -0
  115. package/dist/check/tenancy/bracket-depth.d.ts +3 -0
  116. package/dist/check/tenancy/bracket-depth.d.ts.map +1 -0
  117. package/dist/check/tenancy/bracket-depth.js +10 -0
  118. package/dist/check/tenancy/bracket-depth.js.map +1 -0
  119. package/dist/check/tenancy/chain-links.d.ts +17 -0
  120. package/dist/check/tenancy/chain-links.d.ts.map +1 -0
  121. package/dist/check/tenancy/chain-links.js +24 -0
  122. package/dist/check/tenancy/chain-links.js.map +1 -0
  123. package/dist/check/tenancy/choice-branches.d.ts +3 -0
  124. package/dist/check/tenancy/choice-branches.d.ts.map +1 -0
  125. package/dist/check/tenancy/choice-branches.js +39 -0
  126. package/dist/check/tenancy/choice-branches.js.map +1 -0
  127. package/dist/check/tenancy/declaration-before.d.ts +12 -0
  128. package/dist/check/tenancy/declaration-before.d.ts.map +1 -0
  129. package/dist/check/tenancy/declaration-before.js +11 -0
  130. package/dist/check/tenancy/declaration-before.js.map +1 -0
  131. package/dist/check/tenancy/declaration-of.d.ts +1 -5
  132. package/dist/check/tenancy/declaration-of.d.ts.map +1 -1
  133. package/dist/check/tenancy/declaration-of.js +3 -8
  134. package/dist/check/tenancy/declaration-of.js.map +1 -1
  135. package/dist/check/tenancy/drizzle-unscoped.d.ts.map +1 -1
  136. package/dist/check/tenancy/drizzle-unscoped.js +16 -3
  137. package/dist/check/tenancy/drizzle-unscoped.js.map +1 -1
  138. package/dist/check/tenancy/enclosed-by.d.ts +3 -0
  139. package/dist/check/tenancy/enclosed-by.d.ts.map +1 -0
  140. package/dist/check/tenancy/enclosed-by.js +6 -0
  141. package/dist/check/tenancy/enclosed-by.js.map +1 -0
  142. package/dist/check/tenancy/end-of-enclosing.d.ts +7 -0
  143. package/dist/check/tenancy/end-of-enclosing.d.ts.map +1 -0
  144. package/dist/check/tenancy/end-of-enclosing.js +18 -0
  145. package/dist/check/tenancy/end-of-enclosing.js.map +1 -0
  146. package/dist/check/tenancy/holds-condition.d.ts +14 -0
  147. package/dist/check/tenancy/holds-condition.d.ts.map +1 -0
  148. package/dist/check/tenancy/holds-condition.js +26 -0
  149. package/dist/check/tenancy/holds-condition.js.map +1 -0
  150. package/dist/check/tenancy/is-conjunct.d.ts +8 -0
  151. package/dist/check/tenancy/is-conjunct.d.ts.map +1 -0
  152. package/dist/check/tenancy/is-conjunct.js +17 -0
  153. package/dist/check/tenancy/is-conjunct.js.map +1 -0
  154. package/dist/check/tenancy/is-or-link.d.ts +4 -0
  155. package/dist/check/tenancy/is-or-link.d.ts.map +1 -0
  156. package/dist/check/tenancy/is-or-link.js +7 -0
  157. package/dist/check/tenancy/is-or-link.js.map +1 -0
  158. package/dist/check/tenancy/knex-links-outside-condition.d.ts +11 -0
  159. package/dist/check/tenancy/knex-links-outside-condition.d.ts.map +1 -0
  160. package/dist/check/tenancy/knex-links-outside-condition.js +108 -0
  161. package/dist/check/tenancy/knex-links-outside-condition.js.map +1 -0
  162. package/dist/check/tenancy/knex-unscoped.d.ts +3 -1
  163. package/dist/check/tenancy/knex-unscoped.d.ts.map +1 -1
  164. package/dist/check/tenancy/knex-unscoped.js +12 -2
  165. package/dist/check/tenancy/knex-unscoped.js.map +1 -1
  166. package/dist/check/tenancy/prisma-unscoped.d.ts.map +1 -1
  167. package/dist/check/tenancy/prisma-unscoped.js +15 -10
  168. package/dist/check/tenancy/prisma-unscoped.js.map +1 -1
  169. package/dist/check/tenancy/spreads-at-top.d.ts +9 -0
  170. package/dist/check/tenancy/spreads-at-top.d.ts.map +1 -0
  171. package/dist/check/tenancy/spreads-at-top.js +49 -0
  172. package/dist/check/tenancy/spreads-at-top.js.map +1 -0
  173. package/dist/check/tenancy/top-level-parts.d.ts +3 -0
  174. package/dist/check/tenancy/top-level-parts.d.ts.map +1 -0
  175. package/dist/check/tenancy/top-level-parts.js +13 -0
  176. package/dist/check/tenancy/top-level-parts.js.map +1 -0
  177. package/dist/check/tenancy/typeorm-unscoped.d.ts.map +1 -1
  178. package/dist/check/tenancy/typeorm-unscoped.js +30 -16
  179. package/dist/check/tenancy/typeorm-unscoped.js.map +1 -1
  180. package/dist/check/tenancy/unconfined-where.d.ts +11 -0
  181. package/dist/check/tenancy/unconfined-where.d.ts.map +1 -0
  182. package/dist/check/tenancy/unconfined-where.js +18 -0
  183. package/dist/check/tenancy/unconfined-where.js.map +1 -0
  184. package/dist/check/text/closing-bracket.d.ts +6 -0
  185. package/dist/check/text/closing-bracket.d.ts.map +1 -0
  186. package/dist/check/text/closing-bracket.js +24 -0
  187. package/dist/check/text/closing-bracket.js.map +1 -0
  188. package/dist/commands/depcruise-config.d.ts.map +1 -1
  189. package/dist/commands/depcruise-config.js +4 -0
  190. package/dist/commands/depcruise-config.js.map +1 -1
  191. package/dist/commands/drizzle-generate.d.ts +3 -2
  192. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  193. package/dist/commands/drizzle-generate.js +14 -6
  194. package/dist/commands/drizzle-generate.js.map +1 -1
  195. package/dist/commands/generate.d.ts.map +1 -1
  196. package/dist/commands/generate.js +3 -2
  197. package/dist/commands/generate.js.map +1 -1
  198. package/dist/commands/knex-generate.d.ts +10 -0
  199. package/dist/commands/knex-generate.d.ts.map +1 -0
  200. package/dist/commands/knex-generate.js +74 -0
  201. package/dist/commands/knex-generate.js.map +1 -0
  202. package/dist/commands/lint.js +15 -0
  203. package/dist/commands/lint.js.map +1 -1
  204. package/dist/commands/move-to-module.d.ts.map +1 -1
  205. package/dist/commands/move-to-module.js +3 -0
  206. package/dist/commands/move-to-module.js.map +1 -1
  207. package/dist/commands/mutation.js +1 -1
  208. package/dist/commands/mutation.js.map +1 -1
  209. package/dist/commands/parse-migration-arguments.d.ts +11 -0
  210. package/dist/commands/parse-migration-arguments.d.ts.map +1 -0
  211. package/dist/commands/parse-migration-arguments.js +17 -0
  212. package/dist/commands/parse-migration-arguments.js.map +1 -0
  213. package/dist/commands/prisma-generate.d.ts.map +1 -1
  214. package/dist/commands/prisma-generate.js +5 -11
  215. package/dist/commands/prisma-generate.js.map +1 -1
  216. package/dist/commands/typeorm-generate.d.ts +2 -1
  217. package/dist/commands/typeorm-generate.d.ts.map +1 -1
  218. package/dist/commands/typeorm-generate.js +5 -2
  219. package/dist/commands/typeorm-generate.js.map +1 -1
  220. package/dist/config/read-config.d.ts.map +1 -1
  221. package/dist/config/read-config.js +20 -0
  222. package/dist/config/read-config.js.map +1 -1
  223. package/dist/declared/render-declarations.js +1 -3
  224. package/dist/declared/render-declarations.js.map +1 -1
  225. package/dist/describe/read-controllers.d.ts.map +1 -1
  226. package/dist/describe/read-controllers.js +18 -2
  227. package/dist/describe/read-controllers.js.map +1 -1
  228. package/dist/describe/schema-class-of.js +8 -1
  229. package/dist/describe/schema-class-of.js.map +1 -1
  230. package/dist/digest/tree-at.d.ts.map +1 -1
  231. package/dist/digest/tree-at.js +2 -0
  232. package/dist/digest/tree-at.js.map +1 -1
  233. package/dist/docs/context-sections.js +3 -7
  234. package/dist/docs/context-sections.js.map +1 -1
  235. package/dist/docs/personal-event-lines.d.ts +7 -0
  236. package/dist/docs/personal-event-lines.d.ts.map +1 -0
  237. package/dist/docs/personal-event-lines.js +34 -0
  238. package/dist/docs/personal-event-lines.js.map +1 -0
  239. package/dist/docs/write-docs.d.ts.map +1 -1
  240. package/dist/docs/write-docs.js +2 -0
  241. package/dist/docs/write-docs.js.map +1 -1
  242. package/dist/docs/write-personal-events.d.ts +11 -0
  243. package/dist/docs/write-personal-events.d.ts.map +1 -0
  244. package/dist/docs/write-personal-events.js +28 -0
  245. package/dist/docs/write-personal-events.js.map +1 -0
  246. package/dist/doctor/permission-findings.d.ts.map +1 -1
  247. package/dist/doctor/permission-findings.js +68 -4
  248. package/dist/doctor/permission-findings.js.map +1 -1
  249. package/dist/generate/concept-role.d.ts +10 -0
  250. package/dist/generate/concept-role.d.ts.map +1 -1
  251. package/dist/generate/concept.d.ts.map +1 -1
  252. package/dist/generate/concept.js +5 -1
  253. package/dist/generate/concept.js.map +1 -1
  254. package/dist/generate/emit.d.ts +5 -2
  255. package/dist/generate/emit.d.ts.map +1 -1
  256. package/dist/generate/emit.js +5 -4
  257. package/dist/generate/emit.js.map +1 -1
  258. package/dist/generate/event-names.d.ts.map +1 -1
  259. package/dist/generate/event-names.js.map +1 -1
  260. package/dist/generate/files-without-modules.d.ts +8 -0
  261. package/dist/generate/files-without-modules.d.ts.map +1 -0
  262. package/dist/generate/files-without-modules.js +12 -0
  263. package/dist/generate/files-without-modules.js.map +1 -0
  264. package/dist/generate/grant-permission.js +2 -2
  265. package/dist/generate/grant-permission.js.map +1 -1
  266. package/dist/generate/kinds/aggregate-kind.js +4 -4
  267. package/dist/generate/kinds/aggregate-kind.js.map +1 -1
  268. package/dist/generate/kinds/assert-event-store.d.ts +5 -1
  269. package/dist/generate/kinds/assert-event-store.d.ts.map +1 -1
  270. package/dist/generate/kinds/assert-event-store.js +11 -5
  271. package/dist/generate/kinds/assert-event-store.js.map +1 -1
  272. package/dist/generate/kinds/background/background-job-vars.js +4 -2
  273. package/dist/generate/kinds/background/background-job-vars.js.map +1 -1
  274. package/dist/generate/kinds/command-kind.d.ts.map +1 -1
  275. package/dist/generate/kinds/command-kind.js +6 -1
  276. package/dist/generate/kinds/command-kind.js.map +1 -1
  277. package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
  278. package/dist/generate/kinds/declare-storage.js +4 -10
  279. package/dist/generate/kinds/declare-storage.js.map +1 -1
  280. package/dist/generate/kinds/domain-event-kind.d.ts.map +1 -1
  281. package/dist/generate/kinds/domain-event-kind.js +3 -1
  282. package/dist/generate/kinds/domain-event-kind.js.map +1 -1
  283. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  284. package/dist/generate/kinds/e2e-kind.js +8 -1
  285. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  286. package/dist/generate/kinds/ensure-domain-event.d.ts.map +1 -1
  287. package/dist/generate/kinds/ensure-domain-event.js +2 -0
  288. package/dist/generate/kinds/ensure-domain-event.js.map +1 -1
  289. package/dist/generate/kinds/extraction/add-compose-service.js +1 -1
  290. package/dist/generate/kinds/extraction/add-compose-service.js.map +1 -1
  291. package/dist/generate/kinds/extraction/compose-service-of.d.ts +5 -0
  292. package/dist/generate/kinds/extraction/compose-service-of.d.ts.map +1 -0
  293. package/dist/generate/kinds/extraction/compose-service-of.js +8 -0
  294. package/dist/generate/kinds/extraction/compose-service-of.js.map +1 -0
  295. package/dist/generate/kinds/gateway-kind.js +9 -0
  296. package/dist/generate/kinds/gateway-kind.js.map +1 -1
  297. package/dist/generate/kinds/generate-context.d.ts.map +1 -1
  298. package/dist/generate/kinds/generate-context.js +36 -0
  299. package/dist/generate/kinds/generate-context.js.map +1 -1
  300. package/dist/generate/kinds/generate-event-sourced-repository.js +8 -1
  301. package/dist/generate/kinds/generate-event-sourced-repository.js.map +1 -1
  302. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  303. package/dist/generate/kinds/generate-repository.js +13 -0
  304. package/dist/generate/kinds/generate-repository.js.map +1 -1
  305. package/dist/generate/kinds/query-kind.d.ts.map +1 -1
  306. package/dist/generate/kinds/query-kind.js +24 -2
  307. package/dist/generate/kinds/query-kind.js.map +1 -1
  308. package/dist/generate/kinds/route/controller-vars.js +1 -1
  309. package/dist/generate/kinds/route/controller-vars.js.map +1 -1
  310. package/dist/generate/kinds/route/find-use-case.js +1 -1
  311. package/dist/generate/kinds/route/find-use-case.js.map +1 -1
  312. package/dist/generate/kinds/route/message-call.d.ts +6 -2
  313. package/dist/generate/kinds/route/message-call.d.ts.map +1 -1
  314. package/dist/generate/kinds/route/message-call.js +2 -1
  315. package/dist/generate/kinds/route/message-call.js.map +1 -1
  316. package/dist/generate/kinds/route/standard-schema-of.d.ts +2 -1
  317. package/dist/generate/kinds/route/standard-schema-of.d.ts.map +1 -1
  318. package/dist/generate/kinds/route/standard-schema-of.js +2 -4
  319. package/dist/generate/kinds/route/standard-schema-of.js.map +1 -1
  320. package/dist/generate/kinds/service-kind.d.ts.map +1 -1
  321. package/dist/generate/kinds/service-kind.js +4 -3
  322. package/dist/generate/kinds/service-kind.js.map +1 -1
  323. package/dist/generate/kinds/tables-files.d.ts +3 -0
  324. package/dist/generate/kinds/tables-files.d.ts.map +1 -0
  325. package/dist/generate/kinds/tables-files.js +7 -0
  326. package/dist/generate/kinds/tables-files.js.map +1 -0
  327. package/dist/generate/kinds/worker-kind.d.ts.map +1 -1
  328. package/dist/generate/kinds/worker-kind.js +12 -0
  329. package/dist/generate/kinds/worker-kind.js.map +1 -1
  330. package/dist/generate/kinds/write-birth.d.ts +8 -0
  331. package/dist/generate/kinds/write-birth.d.ts.map +1 -0
  332. package/dist/generate/kinds/write-birth.js +13 -0
  333. package/dist/generate/kinds/write-birth.js.map +1 -0
  334. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
  335. package/dist/generate/kinds/write-event-sourced-aggregate.js +8 -1
  336. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
  337. package/dist/generate/mark-policy-questions.js +2 -2
  338. package/dist/generate/mark-policy-questions.js.map +1 -1
  339. package/dist/generate/permission-name.d.ts +3 -0
  340. package/dist/generate/permission-name.d.ts.map +1 -0
  341. package/dist/generate/permission-name.js +3 -0
  342. package/dist/generate/permission-name.js.map +1 -0
  343. package/dist/generate/permission-named.d.ts.map +1 -1
  344. package/dist/generate/permission-named.js +1 -1
  345. package/dist/generate/permission-named.js.map +1 -1
  346. package/dist/generate/permission-words.d.ts +7 -0
  347. package/dist/generate/permission-words.d.ts.map +1 -0
  348. package/dist/generate/permission-words.js +11 -0
  349. package/dist/generate/permission-words.js.map +1 -0
  350. package/dist/generate/refined-by-policy.js +2 -2
  351. package/dist/generate/refined-by-policy.js.map +1 -1
  352. package/dist/generate/refuse-stuttering-event.d.ts +8 -0
  353. package/dist/generate/refuse-stuttering-event.d.ts.map +1 -0
  354. package/dist/generate/refuse-stuttering-event.js +14 -0
  355. package/dist/generate/refuse-stuttering-event.js.map +1 -0
  356. package/dist/generate/shared-writes.d.ts.map +1 -1
  357. package/dist/generate/shared-writes.js +1 -0
  358. package/dist/generate/shared-writes.js.map +1 -1
  359. package/dist/generate/spoken-in-language.d.ts +11 -2
  360. package/dist/generate/spoken-in-language.d.ts.map +1 -1
  361. package/dist/generate/spoken-in-language.js +27 -12
  362. package/dist/generate/spoken-in-language.js.map +1 -1
  363. package/dist/generator-lock/unreadable-lock-refusal.d.ts +4 -0
  364. package/dist/generator-lock/unreadable-lock-refusal.d.ts.map +1 -0
  365. package/dist/generator-lock/unreadable-lock-refusal.js +7 -0
  366. package/dist/generator-lock/unreadable-lock-refusal.js.map +1 -0
  367. package/dist/generator-lock/with-generator-lock.d.ts.map +1 -1
  368. package/dist/generator-lock/with-generator-lock.js +8 -7
  369. package/dist/generator-lock/with-generator-lock.js.map +1 -1
  370. package/dist/help/flag-notes.d.ts.map +1 -1
  371. package/dist/help/flag-notes.js +5 -1
  372. package/dist/help/flag-notes.js.map +1 -1
  373. package/dist/help/tool-notes.d.ts.map +1 -1
  374. package/dist/help/tool-notes.js +16 -0
  375. package/dist/help/tool-notes.js.map +1 -1
  376. package/dist/help/usage.d.ts.map +1 -1
  377. package/dist/help/usage.js +1 -0
  378. package/dist/help/usage.js.map +1 -1
  379. package/dist/init/agent-permissions.d.ts.map +1 -1
  380. package/dist/init/agent-permissions.js +18 -3
  381. package/dist/init/agent-permissions.js.map +1 -1
  382. package/dist/init/files/audit-files.d.ts.map +1 -1
  383. package/dist/init/files/audit-files.js +1 -0
  384. package/dist/init/files/audit-files.js.map +1 -1
  385. package/dist/init/files/persistence-files.d.ts.map +1 -1
  386. package/dist/init/files/persistence-files.js +2 -1
  387. package/dist/init/files/persistence-files.js.map +1 -1
  388. package/dist/init/files/platform-files.d.ts.map +1 -1
  389. package/dist/init/files/platform-files.js +14 -0
  390. package/dist/init/files/platform-files.js.map +1 -1
  391. package/dist/init/files/privacy-files.d.ts +2 -2
  392. package/dist/init/files/privacy-files.d.ts.map +1 -1
  393. package/dist/init/files/privacy-files.js +3 -2
  394. package/dist/init/files/privacy-files.js.map +1 -1
  395. package/dist/init/files/script-files.d.ts +4 -1
  396. package/dist/init/files/script-files.d.ts.map +1 -1
  397. package/dist/init/files/script-files.js +6 -1
  398. package/dist/init/files/script-files.js.map +1 -1
  399. package/dist/init/is-team-file.d.ts +2 -2
  400. package/dist/init/is-team-file.d.ts.map +1 -1
  401. package/dist/init/is-team-file.js +5 -3
  402. package/dist/init/is-team-file.js.map +1 -1
  403. package/dist/init/keep-regions.d.ts +21 -0
  404. package/dist/init/keep-regions.d.ts.map +1 -0
  405. package/dist/init/keep-regions.js +63 -0
  406. package/dist/init/keep-regions.js.map +1 -0
  407. package/dist/init/kept-combination-notes.d.ts.map +1 -1
  408. package/dist/init/kept-combination-notes.js +6 -2
  409. package/dist/init/kept-combination-notes.js.map +1 -1
  410. package/dist/init/kept-compose-services.d.ts +6 -0
  411. package/dist/init/kept-compose-services.d.ts.map +1 -0
  412. package/dist/init/kept-compose-services.js +42 -0
  413. package/dist/init/kept-compose-services.js.map +1 -0
  414. package/dist/init/kept-role-vocabulary.d.ts +3 -0
  415. package/dist/init/kept-role-vocabulary.d.ts.map +1 -0
  416. package/dist/init/kept-role-vocabulary.js +7 -0
  417. package/dist/init/kept-role-vocabulary.js.map +1 -0
  418. package/dist/init/kept-roles.d.ts +12 -0
  419. package/dist/init/kept-roles.d.ts.map +1 -0
  420. package/dist/init/kept-roles.js +29 -0
  421. package/dist/init/kept-roles.js.map +1 -0
  422. package/dist/init/kept-wiring.d.ts +22 -0
  423. package/dist/init/kept-wiring.d.ts.map +1 -0
  424. package/dist/init/kept-wiring.js +91 -0
  425. package/dist/init/kept-wiring.js.map +1 -0
  426. package/dist/init/knip-vars.d.ts.map +1 -1
  427. package/dist/init/knip-vars.js +5 -1
  428. package/dist/init/knip-vars.js.map +1 -1
  429. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  430. package/dist/init/manifest/database-scripts.js +5 -3
  431. package/dist/init/manifest/database-scripts.js.map +1 -1
  432. package/dist/init/manifest/scripts-for.d.ts.map +1 -1
  433. package/dist/init/manifest/scripts-for.js +8 -0
  434. package/dist/init/manifest/scripts-for.js.map +1 -1
  435. package/dist/init/manifest/versions.js +24 -24
  436. package/dist/init/orphaned-wiring-notes.d.ts +13 -0
  437. package/dist/init/orphaned-wiring-notes.d.ts.map +1 -0
  438. package/dist/init/orphaned-wiring-notes.js +42 -0
  439. package/dist/init/orphaned-wiring-notes.js.map +1 -0
  440. package/dist/init/profile-hooks.js +1 -1
  441. package/dist/init/profile-hooks.js.map +1 -1
  442. package/dist/init/repositories-left-behind.d.ts +12 -0
  443. package/dist/init/repositories-left-behind.d.ts.map +1 -0
  444. package/dist/init/repositories-left-behind.js +26 -0
  445. package/dist/init/repositories-left-behind.js.map +1 -0
  446. package/dist/init/rewire-audited-events.d.ts +10 -0
  447. package/dist/init/rewire-audited-events.d.ts.map +1 -0
  448. package/dist/init/rewire-audited-events.js +32 -0
  449. package/dist/init/rewire-audited-events.js.map +1 -0
  450. package/dist/init/rewire-contexts.d.ts +15 -0
  451. package/dist/init/rewire-contexts.d.ts.map +1 -0
  452. package/dist/init/rewire-contexts.js +41 -0
  453. package/dist/init/rewire-contexts.js.map +1 -0
  454. package/dist/init/rewire-preset.d.ts +9 -0
  455. package/dist/init/rewire-preset.d.ts.map +1 -0
  456. package/dist/init/rewire-preset.js +29 -0
  457. package/dist/init/rewire-preset.js.map +1 -0
  458. package/dist/init/rewire-tables.d.ts +10 -0
  459. package/dist/init/rewire-tables.d.ts.map +1 -0
  460. package/dist/init/rewire-tables.js +54 -0
  461. package/dist/init/rewire-tables.js.map +1 -0
  462. package/dist/init/run-init.d.ts.map +1 -1
  463. package/dist/init/run-init.js +28 -28
  464. package/dist/init/run-init.js.map +1 -1
  465. package/dist/init/stack/kept-flag-notes.d.ts +7 -0
  466. package/dist/init/stack/kept-flag-notes.d.ts.map +1 -0
  467. package/dist/init/stack/kept-flag-notes.js +24 -0
  468. package/dist/init/stack/kept-flag-notes.js.map +1 -0
  469. package/dist/init/stack/refuse-unused-no-outbox.d.ts +4 -0
  470. package/dist/init/stack/refuse-unused-no-outbox.d.ts.map +1 -0
  471. package/dist/init/stack/refuse-unused-no-outbox.js +9 -0
  472. package/dist/init/stack/refuse-unused-no-outbox.js.map +1 -0
  473. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  474. package/dist/init/stack/resolve-stack.js +10 -0
  475. package/dist/init/stack/resolve-stack.js.map +1 -1
  476. package/dist/init/stack-before.d.ts +4 -0
  477. package/dist/init/stack-before.d.ts.map +1 -0
  478. package/dist/init/stack-before.js +11 -0
  479. package/dist/init/stack-before.js.map +1 -0
  480. package/dist/init/wiring-notes.d.ts +9 -0
  481. package/dist/init/wiring-notes.d.ts.map +1 -0
  482. package/dist/init/wiring-notes.js +22 -0
  483. package/dist/init/wiring-notes.js.map +1 -0
  484. package/dist/init/with-named-imports.d.ts +8 -0
  485. package/dist/init/with-named-imports.d.ts.map +1 -0
  486. package/dist/init/with-named-imports.js +69 -0
  487. package/dist/init/with-named-imports.js.map +1 -0
  488. package/dist/init/with-system-grants.d.ts +7 -0
  489. package/dist/init/with-system-grants.d.ts.map +1 -0
  490. package/dist/init/with-system-grants.js +26 -0
  491. package/dist/init/with-system-grants.js.map +1 -0
  492. package/dist/init/write-local-environment.d.ts +8 -0
  493. package/dist/init/write-local-environment.d.ts.map +1 -0
  494. package/dist/init/write-local-environment.js +18 -0
  495. package/dist/init/write-local-environment.js.map +1 -0
  496. package/dist/lint/eslint-in-project.d.ts +1 -1
  497. package/dist/lint/eslint-in-project.d.ts.map +1 -1
  498. package/dist/lint/eslint-in-project.js +11 -2
  499. package/dist/lint/eslint-in-project.js.map +1 -1
  500. package/dist/markers/index.d.ts +3 -0
  501. package/dist/markers/index.d.ts.map +1 -1
  502. package/dist/markers/index.js +3 -0
  503. package/dist/markers/index.js.map +1 -1
  504. package/dist/markers/region-marker.d.ts +3 -0
  505. package/dist/markers/region-marker.d.ts.map +1 -0
  506. package/dist/markers/region-marker.js +3 -0
  507. package/dist/markers/region-marker.js.map +1 -0
  508. package/dist/markers/regions-of.d.ts +9 -0
  509. package/dist/markers/regions-of.d.ts.map +1 -0
  510. package/dist/markers/regions-of.js +20 -0
  511. package/dist/markers/regions-of.js.map +1 -0
  512. package/dist/markers/unpaired-markers.d.ts +3 -0
  513. package/dist/markers/unpaired-markers.d.ts.map +1 -0
  514. package/dist/markers/unpaired-markers.js +13 -0
  515. package/dist/markers/unpaired-markers.js.map +1 -0
  516. package/dist/measures/timeline-of.js +1 -0
  517. package/dist/measures/timeline-of.js.map +1 -1
  518. package/dist/merge/apply-resolutions.d.ts.map +1 -1
  519. package/dist/merge/apply-resolutions.js +6 -4
  520. package/dist/merge/apply-resolutions.js.map +1 -1
  521. package/dist/merge/continue-merge.d.ts.map +1 -1
  522. package/dist/merge/continue-merge.js +1 -0
  523. package/dist/merge/continue-merge.js.map +1 -1
  524. package/dist/merge/ensure-mergeable.js +1 -1
  525. package/dist/merge/ensure-mergeable.js.map +1 -1
  526. package/dist/merge/lost/verify-merges.d.ts.map +1 -1
  527. package/dist/merge/lost/verify-merges.js +4 -0
  528. package/dist/merge/lost/verify-merges.js.map +1 -1
  529. package/dist/merge/merge-state.d.ts.map +1 -1
  530. package/dist/merge/merge-state.js +2 -2
  531. package/dist/merge/merge-state.js.map +1 -1
  532. package/dist/merge/merge-trunk.d.ts.map +1 -1
  533. package/dist/merge/merge-trunk.js +4 -0
  534. package/dist/merge/merge-trunk.js.map +1 -1
  535. package/dist/merge/refuse-shallow-history.d.ts +10 -0
  536. package/dist/merge/refuse-shallow-history.d.ts.map +1 -0
  537. package/dist/merge/refuse-shallow-history.js +15 -0
  538. package/dist/merge/refuse-shallow-history.js.map +1 -0
  539. package/dist/merge/resume-merge.js +2 -2
  540. package/dist/merge/resume-merge.js.map +1 -1
  541. package/dist/merge/settle-regions.d.ts.map +1 -1
  542. package/dist/merge/settle-regions.js +3 -4
  543. package/dist/merge/settle-regions.js.map +1 -1
  544. package/dist/migration/audit-guard/append-audit-guard.d.ts +4 -2
  545. package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -1
  546. package/dist/migration/audit-guard/append-audit-guard.js +18 -3
  547. package/dist/migration/audit-guard/append-audit-guard.js.map +1 -1
  548. package/dist/migration/declared-tables.d.ts +8 -0
  549. package/dist/migration/declared-tables.d.ts.map +1 -0
  550. package/dist/migration/declared-tables.js +13 -0
  551. package/dist/migration/declared-tables.js.map +1 -0
  552. package/dist/migration/find-project-formatter.d.ts.map +1 -1
  553. package/dist/migration/find-project-formatter.js +2 -1
  554. package/dist/migration/find-project-formatter.js.map +1 -1
  555. package/dist/migration/index.d.ts +8 -0
  556. package/dist/migration/index.d.ts.map +1 -1
  557. package/dist/migration/index.js +8 -0
  558. package/dist/migration/index.js.map +1 -1
  559. package/dist/migration/knex-migration-text.d.ts +4 -0
  560. package/dist/migration/knex-migration-text.d.ts.map +1 -0
  561. package/dist/migration/knex-migration-text.js +24 -0
  562. package/dist/migration/knex-migration-text.js.map +1 -0
  563. package/dist/migration/knex-schema-difference.d.ts +12 -0
  564. package/dist/migration/knex-schema-difference.d.ts.map +1 -0
  565. package/dist/migration/knex-schema-difference.js +165 -0
  566. package/dist/migration/knex-schema-difference.js.map +1 -0
  567. package/dist/migration/listed-in-index.d.ts +6 -0
  568. package/dist/migration/listed-in-index.d.ts.map +1 -0
  569. package/dist/migration/listed-in-index.js +8 -0
  570. package/dist/migration/listed-in-index.js.map +1 -0
  571. package/dist/migration/refuse-other-orm.d.ts +8 -0
  572. package/dist/migration/refuse-other-orm.d.ts.map +1 -0
  573. package/dist/migration/refuse-other-orm.js +34 -0
  574. package/dist/migration/refuse-other-orm.js.map +1 -0
  575. package/dist/migration/required-migration-name.d.ts +3 -0
  576. package/dist/migration/required-migration-name.d.ts.map +1 -0
  577. package/dist/migration/required-migration-name.js +11 -0
  578. package/dist/migration/required-migration-name.js.map +1 -0
  579. package/dist/migration/warn-dropped-context-tables.d.ts +12 -0
  580. package/dist/migration/warn-dropped-context-tables.d.ts.map +1 -0
  581. package/dist/migration/warn-dropped-context-tables.js +88 -0
  582. package/dist/migration/warn-dropped-context-tables.js.map +1 -0
  583. package/dist/package-manager/dialects.js +1 -1
  584. package/dist/package-manager/dialects.js.map +1 -1
  585. package/dist/package-manager/in-project-dialect.d.ts +8 -0
  586. package/dist/package-manager/in-project-dialect.d.ts.map +1 -0
  587. package/dist/package-manager/in-project-dialect.js +22 -0
  588. package/dist/package-manager/in-project-dialect.js.map +1 -0
  589. package/dist/presets/adapter-of.d.ts +5 -0
  590. package/dist/presets/adapter-of.d.ts.map +1 -0
  591. package/dist/presets/adapter-of.js +6 -0
  592. package/dist/presets/adapter-of.js.map +1 -0
  593. package/dist/presets/apply-preset.d.ts.map +1 -1
  594. package/dist/presets/apply-preset.js +1 -5
  595. package/dist/presets/apply-preset.js.map +1 -1
  596. package/dist/presets/grant-to-signed-in.d.ts.map +1 -1
  597. package/dist/presets/grant-to-signed-in.js +1 -24
  598. package/dist/presets/grant-to-signed-in.js.map +1 -1
  599. package/dist/presets/identity-terms.d.ts.map +1 -1
  600. package/dist/presets/identity-terms.js +4 -0
  601. package/dist/presets/identity-terms.js.map +1 -1
  602. package/dist/presets/lay-out-prisma-models.js +1 -19
  603. package/dist/presets/lay-out-prisma-models.js.map +1 -1
  604. package/dist/presets/organisations-as-tenants.d.ts +2 -2
  605. package/dist/presets/organisations-as-tenants.d.ts.map +1 -1
  606. package/dist/presets/organisations-as-tenants.js +46 -2
  607. package/dist/presets/organisations-as-tenants.js.map +1 -1
  608. package/dist/presets/preset-named.d.ts +2 -0
  609. package/dist/presets/preset-named.d.ts.map +1 -1
  610. package/dist/presets/preset-named.js +1 -1
  611. package/dist/presets/preset-named.js.map +1 -1
  612. package/dist/presets/wrap-authorizer.d.ts +4 -0
  613. package/dist/presets/wrap-authorizer.d.ts.map +1 -0
  614. package/dist/presets/wrap-authorizer.js +25 -0
  615. package/dist/presets/wrap-authorizer.js.map +1 -0
  616. package/dist/prisma-schema/datasource-schemas.d.ts +3 -0
  617. package/dist/prisma-schema/datasource-schemas.d.ts.map +1 -0
  618. package/dist/prisma-schema/datasource-schemas.js +5 -0
  619. package/dist/prisma-schema/datasource-schemas.js.map +1 -0
  620. package/dist/prisma-schema/index.d.ts +4 -0
  621. package/dist/prisma-schema/index.d.ts.map +1 -1
  622. package/dist/prisma-schema/index.js +4 -0
  623. package/dist/prisma-schema/index.js.map +1 -1
  624. package/dist/prisma-schema/preview-features-of.d.ts +3 -0
  625. package/dist/prisma-schema/preview-features-of.d.ts.map +1 -0
  626. package/dist/prisma-schema/preview-features-of.js +7 -0
  627. package/dist/prisma-schema/preview-features-of.js.map +1 -0
  628. package/dist/prisma-schema/with-datasource-schema.d.ts +3 -0
  629. package/dist/prisma-schema/with-datasource-schema.d.ts.map +1 -0
  630. package/dist/prisma-schema/with-datasource-schema.js +9 -0
  631. package/dist/prisma-schema/with-datasource-schema.js.map +1 -0
  632. package/dist/prisma-schema/with-preview-feature.d.ts +3 -0
  633. package/dist/prisma-schema/with-preview-feature.d.ts.map +1 -0
  634. package/dist/prisma-schema/with-preview-feature.js +19 -0
  635. package/dist/prisma-schema/with-preview-feature.js.map +1 -0
  636. package/dist/progress/format-progress.js +1 -0
  637. package/dist/progress/format-progress.js.map +1 -1
  638. package/dist/run.d.ts.map +1 -1
  639. package/dist/run.js +10 -1
  640. package/dist/run.js.map +1 -1
  641. package/dist/sdk/planned-clients.d.ts +2 -2
  642. package/dist/sdk/planned-clients.d.ts.map +1 -1
  643. package/dist/sdk/planned-clients.js +2 -6
  644. package/dist/sdk/planned-clients.js.map +1 -1
  645. package/dist/sdk/render-client.js +1 -1
  646. package/dist/sdk/render-client.js.map +1 -1
  647. package/dist/sdk/set-up-sdk.d.ts.map +1 -1
  648. package/dist/sdk/set-up-sdk.js +3 -2
  649. package/dist/sdk/set-up-sdk.js.map +1 -1
  650. package/dist/slice/record-verification.d.ts.map +1 -1
  651. package/dist/slice/record-verification.js +2 -5
  652. package/dist/slice/record-verification.js.map +1 -1
  653. package/dist/stack/stack-vars.js +16 -3
  654. package/dist/stack/stack-vars.js.map +1 -1
  655. package/dist/stories/forecast-merge.js +1 -0
  656. package/dist/stories/forecast-merge.js.map +1 -1
  657. package/dist/stories/open-story-scope.d.ts.map +1 -1
  658. package/dist/stories/open-story-scope.js +2 -4
  659. package/dist/stories/open-story-scope.js.map +1 -1
  660. package/dist/story/change-gated.d.ts +3 -3
  661. package/dist/story/change-gated.d.ts.map +1 -1
  662. package/dist/story/change-gated.js +13 -7
  663. package/dist/story/change-gated.js.map +1 -1
  664. package/dist/version.d.ts +1 -1
  665. package/dist/version.js +1 -1
  666. package/dist/worker/format-resume.d.ts.map +1 -1
  667. package/dist/worker/format-resume.js +5 -0
  668. package/dist/worker/format-resume.js.map +1 -1
  669. package/dist/worker/format-workers.js +5 -0
  670. package/dist/worker/format-workers.js.map +1 -1
  671. package/dist/worker/open-worker-scope.d.ts.map +1 -1
  672. package/dist/worker/open-worker-scope.js +2 -3
  673. package/dist/worker/open-worker-scope.js.map +1 -1
  674. package/dist/worker/progress-of.d.ts +8 -3
  675. package/dist/worker/progress-of.d.ts.map +1 -1
  676. package/dist/worker/progress-of.js +2 -16
  677. package/dist/worker/progress-of.js.map +1 -1
  678. package/dist/worker/read-agent-record.d.ts.map +1 -1
  679. package/dist/worker/read-agent-record.js +15 -3
  680. package/dist/worker/read-agent-record.js.map +1 -1
  681. package/dist/worker/read-workers.js +2 -2
  682. package/dist/worker/read-workers.js.map +1 -1
  683. package/dist/worker/readable-progress.d.ts +5 -0
  684. package/dist/worker/readable-progress.d.ts.map +1 -0
  685. package/dist/worker/readable-progress.js +16 -0
  686. package/dist/worker/readable-progress.js.map +1 -0
  687. package/dist/worker/resume-worker.d.ts.map +1 -1
  688. package/dist/worker/resume-worker.js +4 -5
  689. package/dist/worker/resume-worker.js.map +1 -1
  690. package/dist/worker/worker-progress.d.ts +2 -1
  691. package/dist/worker/worker-progress.d.ts.map +1 -1
  692. package/dist/workspace/real-path-of.d.ts +2 -2
  693. package/dist/workspace/real-path-of.d.ts.map +1 -1
  694. package/dist/workspace/real-path-of.js +15 -10
  695. package/dist/workspace/real-path-of.js.map +1 -1
  696. package/dist/workspace/write-inside-project.d.ts +8 -0
  697. package/dist/workspace/write-inside-project.d.ts.map +1 -0
  698. package/dist/workspace/write-inside-project.js +17 -0
  699. package/dist/workspace/write-inside-project.js.map +1 -0
  700. package/package.json +5 -5
  701. package/templates/aggregate/event-sourced.events.mapper.ts.tpl +5 -1
  702. package/templates/command/handler.declared.ts.tpl +4 -12
  703. package/templates/command/handler.ts.tpl +4 -12
  704. package/templates/docs/privacy-register.md.tpl +2 -0
  705. package/templates/e2e/e2e.spec.ts.tpl +2 -2
  706. package/templates/init/README.md.tpl +42 -9
  707. package/templates/init/docker/docker-compose.yml.tpl +5 -2
  708. package/templates/init/docker/dockerignore.tpl +1 -0
  709. package/templates/init/docker/env.example.tpl +16 -1
  710. package/templates/init/gitignore.tpl +1 -0
  711. package/templates/init/hooks/change-reference.mjs +96 -17
  712. package/templates/init/hooks/production-gate.mjs +65 -11
  713. package/templates/init/jest.config.js.tpl +4 -1
  714. package/templates/init/main.ts.tpl +3 -0
  715. package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +25 -8
  716. package/templates/init/platform/audit/create-audit-trail.ts.tpl +59 -0
  717. package/templates/init/platform/audit/create-audit.ts.tpl +13 -52
  718. package/templates/init/platform/auth/authentication/development-header-authenticator.ts.tpl +7 -3
  719. package/templates/init/platform/auth/relationships/relationship-schema.ts.tpl +5 -0
  720. package/templates/init/platform/composition/compose-application.manual.ts.tpl +58 -7
  721. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +9 -4
  722. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +1 -1
  723. package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +1 -1
  724. package/templates/init/platform/composition/platform-options.manual.ts.tpl +7 -0
  725. package/templates/init/platform/composition/platform.manual.ts.tpl +7 -0
  726. package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +7 -0
  727. package/templates/init/platform/config/app-config.ts.tpl +16 -0
  728. package/templates/init/platform/config/load-config.ts.tpl +46 -0
  729. package/templates/init/platform/database/data-source.typeorm.ts.tpl +6 -0
  730. package/templates/init/platform/database/gitkeep +0 -0
  731. package/templates/init/platform/database/knexfile.js.tpl +10 -3
  732. package/templates/init/platform/database/open-persistence.prisma.ts.tpl +5 -2
  733. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +11 -3
  734. package/templates/init/platform/database/persistence.contract.spec.ts.tpl +14 -3
  735. package/templates/init/platform/database/prisma.config.ts.tpl +6 -0
  736. package/templates/init/platform/database/schema.knex.ts.tpl +4 -3
  737. package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +5 -1
  738. package/templates/init/platform/http/start-http-server.express.ts.tpl +9 -6
  739. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +5 -2
  740. package/templates/init/platform/http/start-http-server.hono.ts.tpl +5 -2
  741. package/templates/init/platform/jobs/create-background-work.ts.tpl +12 -0
  742. package/templates/init/platform/jobs/days-before.ts.tpl +8 -0
  743. package/templates/init/platform/jobs/housekeeping.module.tsyringe.ts.tpl +46 -0
  744. package/templates/init/platform/jobs/housekeeping.ts.tpl +24 -0
  745. package/templates/init/platform/jobs/job-settings.ts.tpl +9 -0
  746. package/templates/init/platform/privacy/personal-events.ts.tpl +11 -0
  747. package/templates/init/platform/privacy/run-erasure.manual.ts.tpl +69 -19
  748. package/templates/init/platform/privacy/run-erasure.tsyringe.ts.tpl +69 -8
  749. package/templates/init/platform/privacy/run-export.manual.ts.tpl +26 -4
  750. package/templates/init/platform/privacy/run-export.tsyringe.ts.tpl +34 -3
  751. package/templates/init/platform/privacy/run-purge.manual.ts.tpl +3 -2
  752. package/templates/init/platform/privacy/run-purge.tsyringe.ts.tpl +4 -2
  753. package/templates/init/rules/infrastructure.md.tpl +1 -1
  754. package/templates/init/scripts/audit-verify.ts.tpl +35 -0
  755. package/templates/init/scripts/privacy-erase.manual.ts.tpl +52 -7
  756. package/templates/init/scripts/privacy-erase.tsyringe.ts.tpl +52 -7
  757. package/templates/init/scripts/privacy-export.manual.ts.tpl +5 -7
  758. package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +5 -7
  759. package/templates/init/scripts/privacy-purge.manual.ts.tpl +4 -0
  760. package/templates/init/scripts/privacy-purge.tsyringe.ts.tpl +4 -0
  761. package/templates/pipeline/github/dependabot.yml +6 -0
  762. package/templates/pipeline/github/workflows/ci.yml.tpl +26 -1
  763. package/templates/pipeline/github/workflows/claude-review.yml +3 -2
  764. package/templates/pipeline/github/workflows/claude-triage.yml +1 -1
  765. package/templates/pipeline/github/workflows/codeql.yml +2 -0
  766. package/templates/pipeline/github/workflows/copilot-setup-steps.yml +2 -0
  767. package/templates/pipeline/github/workflows/intent-to-spec.yml +12 -4
  768. package/templates/pipeline/github/workflows/pr-title.yml +2 -0
  769. package/templates/pipeline/gitlab/claude-review.gitlab-ci.yml.tpl +1 -1
  770. package/templates/pipeline/knip.json.tpl +1 -4
  771. package/templates/pipeline/package-scripts.json +2 -2
  772. package/templates/pipeline/renovate.json +11 -0
  773. package/templates/pipeline/stryker.config.mjs.tpl +4 -0
  774. package/templates/pipeline/vitest.config.ts.tpl +3 -2
  775. package/templates/presets/identity/context/__context__.codes.named.ts.tpl +1 -0
  776. package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +1 -1
  777. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +28 -1
  778. package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +13 -1
  779. package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +6 -1
  780. package/templates/presets/identity/context/domain/errors/invitation-withdrawn.error.named.ts.tpl +13 -0
  781. package/templates/presets/identity/context/domain/errors/invitation.error.factories.ts.tpl +8 -0
  782. package/templates/presets/identity/context/domain/services/role-rights.service.ts.tpl +23 -1
  783. package/templates/presets/identity/context/infrastructure/persistence/__context__.schema.drizzle.ts.tpl +1 -0
  784. package/templates/presets/identity/context/infrastructure/persistence/create-__context__-tables.schema.knex.ts.tpl +1 -0
  785. package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +6 -2
  786. package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +6 -2
  787. package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +6 -2
  788. package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +6 -2
  789. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +6 -2
  790. package/templates/presets/identity/context/infrastructure/persistence/invitation-row.schema.knex.ts.tpl +1 -0
  791. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.drizzle.ts.tpl +2 -0
  792. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.knex.ts.tpl +2 -0
  793. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.prisma.ts.tpl +2 -0
  794. package/templates/presets/identity/context/infrastructure/persistence/prisma-account.repository.prisma.ts.tpl +8 -5
  795. package/templates/presets/identity/context/infrastructure/persistence/prisma-delegation.repository.prisma.ts.tpl +8 -5
  796. package/templates/presets/identity/context/infrastructure/persistence/prisma-invitation.repository.prisma.ts.tpl +8 -5
  797. package/templates/presets/identity/context/infrastructure/persistence/prisma-member.repository.prisma.ts.tpl +8 -5
  798. package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation.repository.prisma.ts.tpl +8 -5
  799. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.kit-routes.ts.tpl +1 -0
  800. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +1 -0
  801. package/templates/presets/identity/context/test/builders/invitation.builder.ts.tpl +15 -2
  802. package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +10 -0
  803. package/templates/presets/identity/context/test/unit/accept-invitation.handler.spec.ts.tpl +114 -4
  804. package/templates/presets/identity/context/test/worlds/__context__.world.explicit.ts.tpl +1 -1
  805. package/templates/presets/identity/design.md.tpl +3 -1
  806. package/templates/presets/identity/prisma/models.prisma.tpl +1 -0
  807. package/templates/query/reader.fake.ts.tpl +4 -6
  808. package/templates/query/reader.in-memory.ts.tpl +1 -1
  809. package/templates/repository/drizzle/repository.ts.tpl +4 -3
  810. package/templates/repository/knex/table.tpl +1 -1
  811. package/templates/repository/prisma/repository.ts.tpl +24 -18
  812. package/templates/state-machine/state-machine.spec.ts.tpl +5 -0
  813. package/templates/worker/main.ts.tpl +3 -0
  814. package/templates/init/platform/database/migration.knex.js.tpl +0 -8
@@ -1,32 +1,116 @@
1
- // The change reference of the regulated profile: a PreToolUse hook of Claude Code on the Edit and
2
- // Write tools, registered in .claude/settings.json by `ddd-ts-kit init --agent-profile regulated`.
1
+ // The change reference of the regulated profile: a PreToolUse hook of Claude Code on the Edit,
2
+ // Write and MultiEdit tools, registered in .claude/settings.json by `ddd-ts-kit init --agent-profile regulated`.
3
3
  // An edit of a migration or of the containers of the project asks for a change reference: the
4
4
  // person confirms, and the session records the reference as the trailer `Change: <id>` of the
5
5
  // commit that holds the file. It asks, it does not block. Owned by the team: edit the paths below.
6
- import { readFileSync } from 'node:fs';
7
- import process from 'node:process';
6
+ import { execFileSync } from 'node:child_process';
7
+ import { existsSync, readSync } from 'node:fs';
8
8
  import path from 'node:path';
9
9
 
10
+ // The same list is CHANGE_GATED of packages/cli/src/story/change-gated.ts (story-check): change both together.
10
11
  // What reaches production otherwise than through the code: the migrations of the ORM, the containers.
11
- const GATED = [/(^|\/)migrations\//, /^prisma\/migrations\//, /^docker\//, /^Dockerfile$/, /^docker-compose\.ya?ml$/];
12
+ const GATED = [
13
+ /(^|\/)migrations\//,
14
+ /^prisma\/migrations\//,
15
+ /(^|\/)docker\//,
16
+ /(^|\/)Dockerfile$/,
17
+ /(^|\/)docker-compose[\w.-]*\.ya?ml$/,
18
+ ];
12
19
 
20
+ // Reads all of stdin. A writer that is late leaves the pipe empty for a moment, which answers EAGAIN: wait for it.
21
+ function readStdin() {
22
+ const chunks = [];
23
+ const buffer = Buffer.alloc(65536);
24
+
25
+ for (;;) {
26
+ try {
27
+ const count = readSync(0, buffer, 0, buffer.length, null);
28
+
29
+ if (count === 0) {
30
+ return Buffer.concat(chunks).toString('utf8');
31
+ }
32
+
33
+ chunks.push(Buffer.from(buffer.subarray(0, count)));
34
+ } catch (error) {
35
+ if (error.code === 'EOF') {
36
+ return Buffer.concat(chunks).toString('utf8');
37
+ }
38
+
39
+ if (error.code !== 'EAGAIN') {
40
+ throw new Error(`the input could not be read (${error.code ?? 'unknown error'})`, { cause: error });
41
+ }
42
+
43
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
44
+ }
45
+ }
46
+ }
47
+
48
+ // The input of the hook, or why it cannot be judged: unreadable, not JSON, or JSON that is no object.
13
49
  function readInput() {
14
50
  try {
15
- return JSON.parse(readFileSync(0, 'utf8'));
51
+ const input = JSON.parse(readStdin());
52
+
53
+ return typeof input === 'object' && input !== null ? { input } : { failure: 'the input is not a JSON object' };
54
+ } catch (error) {
55
+ return { failure: error instanceof SyntaxError ? 'the input is not JSON' : error.message };
56
+ }
57
+ }
58
+
59
+ function ask(reason) {
60
+ process.stdout.write(
61
+ JSON.stringify({
62
+ hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'ask', permissionDecisionReason: reason },
63
+ }),
64
+ );
65
+ process.exit(0);
66
+ }
67
+
68
+ function contains(outer, inner) {
69
+ const relative = path.relative(outer, inner);
70
+
71
+ return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
72
+ }
73
+
74
+ // The root of the checkout that holds the file, a worktree of the project included, so that the
75
+ // path is read from there whatever the directory the session works in. Falls back to that directory.
76
+ function checkoutOf(absolute, cwd) {
77
+ let directory = path.dirname(absolute);
78
+
79
+ while (!existsSync(directory) && path.dirname(directory) !== directory) {
80
+ directory = path.dirname(directory);
81
+ }
82
+
83
+ try {
84
+ const top = execFileSync('git', ['rev-parse', '--show-toplevel'], {
85
+ cwd: directory,
86
+ encoding: 'utf8',
87
+ stdio: ['ignore', 'pipe', 'ignore'],
88
+ timeout: 5000,
89
+ }).trim();
90
+
91
+ return contains(top, cwd) || contains(cwd, top) ? top : cwd;
16
92
  } catch {
17
- return undefined;
93
+ return cwd;
18
94
  }
19
95
  }
20
96
 
21
- const input = readInput();
97
+ const { input, failure } = readInput();
22
98
  const file = input?.tool_input?.file_path;
23
99
 
24
- if (input === undefined || !['Edit', 'Write'].includes(input.tool_name) || typeof file !== 'string') {
100
+ if (failure !== undefined) {
101
+ ask(
102
+ `change-reference: ${failure}, so the file cannot be judged. Allow the edit only if it is no migration and no part of the containers.`,
103
+ );
104
+ }
105
+
106
+ if (!['Edit', 'Write', 'MultiEdit'].includes(input.tool_name) || typeof file !== 'string') {
25
107
  process.exit(0);
26
108
  }
27
109
 
28
- const root = typeof input.cwd === 'string' ? input.cwd : process.cwd();
29
- const relative = path.relative(root, path.resolve(root, file)).split(path.sep).join('/');
110
+ const cwd = typeof input.cwd === 'string' ? input.cwd : process.cwd();
111
+ const absolute = path.resolve(cwd, file);
112
+ const root = checkoutOf(absolute, cwd);
113
+ const relative = path.relative(root, absolute).split(path.sep).join('/');
30
114
 
31
115
  if (relative.startsWith('..') || !GATED.some((pattern) => pattern.test(relative))) {
32
116
  process.exit(0);
@@ -37,9 +121,4 @@ const reason = [
37
121
  'Allow the edit with the reference in mind (the id of the change ticket or of the story), then record it as the trailer `Change: <id>` of the commit that holds this file: `git commit -m "<message>" -m "Change: <id>"`. The trailer is read by people in the history.',
38
122
  ].join(' ');
39
123
 
40
- process.stdout.write(
41
- JSON.stringify({
42
- hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'ask', permissionDecisionReason: reason },
43
- }),
44
- );
45
- process.exit(0);
124
+ ask(reason);
@@ -3,11 +3,14 @@
3
3
  // that names the production environment of the project with a release action is blocked (exit 2,
4
4
  // the reason to the agent) unless RELEASE_APPROVAL names who approved the release and the change
5
5
  // it belongs to. Owned by the team: edit the lists below to your environments and actions.
6
- import { readFileSync } from 'node:fs';
7
- import process from 'node:process';
6
+ import { readSync } from 'node:fs';
8
7
 
9
- // The words that name the production environment in a command, as a whole word, in any case.
8
+ // The words that name the production environment in a command, as a whole word, in any case. A word is
9
+ // read between separators of any kind (a space, a colon, a dash, an underscore, a dot), so that
10
+ // `deploy-production` and `deploy_production` name it as `deploy:production` does.
10
11
  const PRODUCTION_ENVIRONMENTS = ['production'];
12
+ // A production word with one of these in front names another environment (`non-production`, `pre-prod`).
13
+ const OTHER_ENVIRONMENT_PREFIXES = ['non', 'pre'];
11
14
  // The actions a release makes: a command that carries one of them with one of the words above is gated.
12
15
  const RELEASE_ACTIONS = ['deploy', 'migrate', 'rollback'];
13
16
  // Where the release checklist of the team is, named in the refusal.
@@ -22,26 +25,77 @@ const words = (listed, variable) =>
22
25
  .filter((word) => word !== '')
23
26
  .concat(listed);
24
27
 
28
+ // Reads all of stdin. A writer that is late leaves the pipe empty for a moment, which answers EAGAIN: wait for it.
29
+ function readStdin() {
30
+ const chunks = [];
31
+ const buffer = Buffer.alloc(65536);
32
+
33
+ for (;;) {
34
+ try {
35
+ const count = readSync(0, buffer, 0, buffer.length, null);
36
+
37
+ if (count === 0) {
38
+ return Buffer.concat(chunks).toString('utf8');
39
+ }
40
+
41
+ chunks.push(Buffer.from(buffer.subarray(0, count)));
42
+ } catch (error) {
43
+ if (error.code === 'EOF') {
44
+ return Buffer.concat(chunks).toString('utf8');
45
+ }
46
+
47
+ if (error.code !== 'EAGAIN') {
48
+ throw new Error(`the input could not be read (${error.code ?? 'unknown error'})`, { cause: error });
49
+ }
50
+
51
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
52
+ }
53
+ }
54
+ }
55
+
56
+ // The input of the hook, or why it cannot be judged: unreadable, not JSON, or JSON that is no object.
25
57
  function readInput() {
26
58
  try {
27
- return JSON.parse(readFileSync(0, 'utf8'));
28
- } catch {
29
- return undefined;
59
+ const input = JSON.parse(readStdin());
60
+
61
+ return typeof input === 'object' && input !== null ? { input } : { failure: 'the input is not a JSON object' };
62
+ } catch (error) {
63
+ return { failure: error instanceof SyntaxError ? 'the input is not JSON' : error.message };
30
64
  }
31
65
  }
32
66
 
33
- function named(command, list) {
34
- return list.find((word) => new RegExp(`(^|[^\\w-])${word}([^\\w-]|$)`, 'i').test(command));
67
+ const tokens = (text) =>
68
+ text
69
+ .toLowerCase()
70
+ .split(/[^a-z0-9]+/)
71
+ .filter((token) => token !== '');
72
+ const phrase = (text) => ` ${tokens(text).join(' ')} `;
73
+
74
+ function named(command, list, others = []) {
75
+ const read = others.reduce((text, name) => text.replaceAll(phrase(name), ' '), phrase(command));
76
+
77
+ return list.find((word) => read.includes(phrase(word)));
35
78
  }
36
79
 
37
- const input = readInput();
80
+ const otherEnvironments = (environments) =>
81
+ environments.flatMap((word) => OTHER_ENVIRONMENT_PREFIXES.map((prefix) => `${prefix}-${word}`));
82
+
83
+ const { input, failure } = readInput();
84
+
85
+ if (failure !== undefined) {
86
+ process.stderr.write(
87
+ `production-gate: ${failure}, so the command cannot be judged. Nothing was run. Run the command again.\n`,
88
+ );
89
+ process.exit(2);
90
+ }
38
91
 
39
- if (input === undefined || input.tool_name !== 'Bash' || typeof input.tool_input?.command !== 'string') {
92
+ if (input.tool_name !== 'Bash' || typeof input.tool_input?.command !== 'string') {
40
93
  process.exit(0);
41
94
  }
42
95
 
43
96
  const command = input.tool_input.command;
44
- const environment = named(command, words(PRODUCTION_ENVIRONMENTS, 'PRODUCTION_GATE_ENVIRONMENTS'));
97
+ const environments = words(PRODUCTION_ENVIRONMENTS, 'PRODUCTION_GATE_ENVIRONMENTS');
98
+ const environment = named(command, environments, otherEnvironments(environments));
45
99
  const action = named(command, words(RELEASE_ACTIONS, 'PRODUCTION_GATE_ACTIONS'));
46
100
 
47
101
  if (environment === undefined || action === undefined) {
@@ -1,6 +1,8 @@
1
1
  import process from 'node:process';
2
2
  import { governedJestCoverage, unaffectedContexts } from '@ddd-ts-kit/testing/coverage';
3
3
 
4
+ const agent = Boolean(process.env.AI_AGENT || process.env.CLAUDECODE);
5
+
4
6
  export default {
5
7
  testEnvironment: 'node',
6
8
  // Jest does not read tsconfig: the import aliases of its "paths", repeated here, and held equal by `ddd-ts-kit check` (imports/alias-declared).
@@ -23,7 +25,8 @@ export default {
23
25
  {{/unless}}
24
26
  testTimeout: 60_000,
25
27
  // Each spec file is held to the time budget of its level ("budget" in ddd-ts-kit.config.json, the reference when it is absent): the slowest named at the end of the run, a file over its budget fails it.
26
- reporters: ['default', '@ddd-ts-kit/testing/budget/jest'],
28
+ // Under a coding agent the summary reporter, as Vitest picks a terse one by itself.
29
+ reporters: [agent ? 'summary' : 'default', '@ddd-ts-kit/testing/budget/jest'],
27
30
  // A pull request names the contexts its change reaches (DDD_TS_KIT_AFFECTED, from `ddd-ts-kit affected`): the specs of the others are left to the default branch.
28
31
  testPathIgnorePatterns: ['/node_modules/', ...unaffectedContexts().map((directory) => `/${directory}`)],
29
32
  extensionsToTreatAsEsm: ['.ts'],
@@ -54,6 +54,9 @@ const application = composeApplication(
54
54
  traceConsumers: config.tracing.consumers,
55
55
  resilience: config.resilience,
56
56
  jobs: { start: config.runJobs, settings: jobSettings(process.env) },
57
+ {{#if housekeeping.any}}
58
+ housekeeping: config.housekeeping,
59
+ {{/if}}
57
60
  {{#if tenancy.any}}
58
61
  tenants: config.tenants,
59
62
  {{/if}}
@@ -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}}
@@ -7,6 +7,7 @@ import {
7
7
  auditGuardRefusals,
8
8
  auditIntegrationEvents,
9
9
  auditMiddleware,
10
+ logLostRecords,
10
11
  type ArchivableAuditTrail,
11
12
  type AuditReader,
12
13
  type AuditSource,
@@ -16,7 +17,6 @@ import {
16
17
  {{/if}}
17
18
  {{#if audit.memory}}
18
19
  import {
19
- InMemoryAuditTrail,
20
20
  {{#if tenancy.any}}
21
21
  TenantAuditReader,
22
22
  {{/if}}
@@ -24,6 +24,7 @@ import {
24
24
  auditGuardRefusals,
25
25
  auditIntegrationEvents,
26
26
  auditMiddleware,
27
+ logLostRecords,
27
28
  type ArchivableAuditTrail,
28
29
  type AuditReader,
29
30
  type AuditSource,
@@ -31,29 +32,15 @@ import {
31
32
  type GuardRefusalOfARoute,
32
33
  } from '@ddd-ts-kit/audit';
33
34
  {{/if}}
34
- {{#if audit.knex}}
35
- import { KnexAuditTrail } from '@ddd-ts-kit/audit/knex';
36
- {{/if}}
37
- {{#if audit.drizzle}}
38
- import { DrizzleAuditTrail } from '@ddd-ts-kit/audit/drizzle';
39
- {{/if}}
40
- {{#if audit.prisma}}
41
- import { PrismaAuditTrail } from '@ddd-ts-kit/audit/prisma';
42
- {{/if}}
43
- {{#if audit.typeorm}}
44
- import { TypeOrmAuditTrail } from '@ddd-ts-kit/audit/typeorm';
45
- {{/if}}
46
35
  import type { OnDecision } from '@ddd-ts-kit/auth';
47
36
  import type { EventSubscription } from '@ddd-ts-kit/events';
48
- import type { BusMiddleware } from '@ddd-ts-kit/kernel';
37
+ import type { AuditRecord, BusMiddleware, Logger } from '@ddd-ts-kit/kernel';
49
38
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
50
- {{#if audit.schemaFile}}
51
- import { AUDIT_SCHEMA } from '{{alias.platform}}/database/schema{{alias.ext}}';
52
- {{/if}}
53
39
  {{#if audit.route}}
54
40
  import { auditPermissions } from '{{alias.platform}}/audit/audit.permissions{{alias.ext}}';
55
41
  {{/if}}
56
42
  import { auditedEvents } from '{{alias.platform}}/audit/audited-events{{alias.ext}}';
43
+ import { createAuditTrail } from '{{alias.platform}}/audit/create-audit-trail{{alias.ext}}';
57
44
  {{#if audit.route}}
58
45
  import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.query{{alias.ext}}';
59
46
  {{/if}}
@@ -89,11 +76,14 @@ export interface Audit {
89
76
  readonly subscriptions: readonly EventSubscription[];
90
77
  /** The name those subscriptions listen under. */
91
78
  readonly consumer: string;
79
+ /** What a source outside this file passes on: a failure whose entry could not be written is told to the log. */
80
+ readonly onLostRecord: (error: unknown, record: AuditRecord | undefined) => void;
92
81
  }
93
82
 
94
- export function createAudit(persistence: Persistence, source: AuditSource): Audit {
83
+ export function createAudit(persistence: Persistence, source: AuditSource, logger: Logger): Audit {
95
84
  const trail = createAuditTrail({{#if audit.sql}}persistence{{/if}});
96
85
  const { unitOfWork, processedEvents } = persistence;
86
+ const onLostRecord = logLostRecords(logger);
97
87
 
98
88
  return {
99
89
  trail,
@@ -104,14 +94,14 @@ export function createAudit(persistence: Persistence, source: AuditSource): Audi
104
94
  {{#if audit.route}}
105
95
  decisions: auditDecisions(trail, { ...source, sensitivePermissions: [auditPermissions['trail.read'].id] }),
106
96
  // TODO(platform): declare what may go into `changes` with `fields: [auditedFields(SomeCommand, ['status'])]`; by default an entry carries identifiers and codes only.
107
- commands: auditMiddleware(trail, { ...source, unitOfWork }),
108
- queries: auditMiddleware(trail, { ...source, queries: [SearchAuditEntriesQuery] }),
97
+ commands: auditMiddleware(trail, { ...source, unitOfWork, onLostRecord }),
98
+ queries: auditMiddleware(trail, { ...source, queries: [SearchAuditEntriesQuery], onLostRecord }),
109
99
  {{/if}}
110
100
  {{#unless audit.route}}
111
101
  decisions: auditDecisions(trail, source),
112
102
  // TODO(platform): declare what may go into `changes` with `fields: [auditedFields(SomeCommand, ['status'])]`; by default an entry carries identifiers and codes only.
113
- commands: auditMiddleware(trail, { ...source, unitOfWork }),
114
- queries: auditMiddleware(trail, source),
103
+ commands: auditMiddleware(trail, { ...source, unitOfWork, onLostRecord }),
104
+ queries: auditMiddleware(trail, { ...source, onLostRecord }),
115
105
  {{/unless}}
116
106
  subscriptions: auditIntegrationEvents(trail, {
117
107
  registry: auditedEvents,
@@ -123,35 +113,6 @@ export function createAudit(persistence: Persistence, source: AuditSource): Audi
123
113
  consumer,
124
114
  }),
125
115
  consumer,
116
+ onLostRecord,
126
117
  };
127
118
  }
128
-
129
- {{#if audit.knex}}
130
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
131
- return new KnexAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
132
- }
133
- {{/if}}
134
- {{#if audit.drizzle}}
135
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
136
- return new DrizzleAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
137
- }
138
- {{/if}}
139
- {{#if audit.prisma}}
140
- /** The schema the models of the trail declare in prisma/schema/schema.prisma (`@@schema("audit")`). */
141
- const AUDIT_SCHEMA = 'audit';
142
-
143
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
144
- return new PrismaAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
145
- }
146
- {{/if}}
147
- {{#if audit.typeorm}}
148
- function createAuditTrail(persistence: Persistence): AuditTrail & AuditReader & ArchivableAuditTrail {
149
- return new TypeOrmAuditTrail(persistence.database, { schema: AUDIT_SCHEMA });
150
- }
151
- {{/if}}
152
- {{#if audit.memory}}
153
- // 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.
154
- function createAuditTrail(): AuditTrail & AuditReader & ArchivableAuditTrail {
155
- return new InMemoryAuditTrail();
156
- }
157
- {{/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: {},