ddd-ts-kit 0.88.0 → 0.89.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 (708) hide show
  1. package/CHANGELOG.md +593 -0
  2. package/README.fr.md +67 -26
  3. package/README.md +62 -23
  4. package/dist/check/canonical/roles.d.ts.map +1 -1
  5. package/dist/check/canonical/roles.js +4 -1
  6. package/dist/check/canonical/roles.js.map +1 -1
  7. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  8. package/dist/check/catalogue/architecture-rules.js +12 -0
  9. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  10. package/dist/check/catalogue/default-severities.d.ts.map +1 -1
  11. package/dist/check/catalogue/default-severities.js +9 -0
  12. package/dist/check/catalogue/default-severities.js.map +1 -1
  13. package/dist/check/catalogue/delegated-rules.js +1 -1
  14. package/dist/check/catalogue/delegated-rules.js.map +1 -1
  15. package/dist/check/catalogue/eslint-only-rules.d.ts.map +1 -1
  16. package/dist/check/catalogue/eslint-only-rules.js +24 -0
  17. package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
  18. package/dist/check/configuration/config-inspection.d.ts +2 -2
  19. package/dist/check/configuration/config-inspection.d.ts.map +1 -1
  20. package/dist/check/configuration/config-inspection.js +5 -4
  21. package/dist/check/configuration/config-inspection.js.map +1 -1
  22. package/dist/check/configuration/measure-settings.d.ts +10 -0
  23. package/dist/check/configuration/measure-settings.d.ts.map +1 -0
  24. package/dist/check/configuration/measure-settings.js +17 -0
  25. package/dist/check/configuration/measure-settings.js.map +1 -0
  26. package/dist/check/explain/privacy-docs.d.ts +3 -0
  27. package/dist/check/explain/privacy-docs.d.ts.map +1 -0
  28. package/dist/check/explain/privacy-docs.js +52 -0
  29. package/dist/check/explain/privacy-docs.js.map +1 -0
  30. package/dist/check/explain/rule-docs.d.ts.map +1 -1
  31. package/dist/check/explain/rule-docs.js +2 -0
  32. package/dist/check/explain/rule-docs.js.map +1 -1
  33. package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
  34. package/dist/check/explain/tenancy-docs.js +13 -3
  35. package/dist/check/explain/tenancy-docs.js.map +1 -1
  36. package/dist/check/explain/tree-docs.d.ts.map +1 -1
  37. package/dist/check/explain/tree-docs.js +11 -0
  38. package/dist/check/explain/tree-docs.js.map +1 -1
  39. package/dist/check/explain/wiring-docs.js +1 -1
  40. package/dist/check/explain/wiring-docs.js.map +1 -1
  41. package/dist/check/fixtures/budget-fixtures.d.ts +3 -0
  42. package/dist/check/fixtures/budget-fixtures.d.ts.map +1 -0
  43. package/dist/check/fixtures/budget-fixtures.js +43 -0
  44. package/dist/check/fixtures/budget-fixtures.js.map +1 -0
  45. package/dist/check/fixtures/declarations-fixtures.d.ts.map +1 -1
  46. package/dist/check/fixtures/declarations-fixtures.js +17 -3
  47. package/dist/check/fixtures/declarations-fixtures.js.map +1 -1
  48. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  49. package/dist/check/fixtures/fixtures.js +6 -0
  50. package/dist/check/fixtures/fixtures.js.map +1 -1
  51. package/dist/check/fixtures/mutation-fixtures.d.ts +3 -0
  52. package/dist/check/fixtures/mutation-fixtures.d.ts.map +1 -0
  53. package/dist/check/fixtures/mutation-fixtures.js +81 -0
  54. package/dist/check/fixtures/mutation-fixtures.js.map +1 -0
  55. package/dist/check/fixtures/privacy-fixtures.d.ts +3 -0
  56. package/dist/check/fixtures/privacy-fixtures.d.ts.map +1 -0
  57. package/dist/check/fixtures/privacy-fixtures.js +198 -0
  58. package/dist/check/fixtures/privacy-fixtures.js.map +1 -0
  59. package/dist/check/fixtures/tenancy-bypass.d.ts +24 -0
  60. package/dist/check/fixtures/tenancy-bypass.d.ts.map +1 -0
  61. package/dist/check/fixtures/tenancy-bypass.js +22 -0
  62. package/dist/check/fixtures/tenancy-bypass.js.map +1 -0
  63. package/dist/check/fixtures/tenancy-config.d.ts +3 -0
  64. package/dist/check/fixtures/tenancy-config.d.ts.map +1 -0
  65. package/dist/check/fixtures/tenancy-config.js +7 -0
  66. package/dist/check/fixtures/tenancy-config.js.map +1 -0
  67. package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
  68. package/dist/check/fixtures/tenancy-fixtures.js +31 -41
  69. package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
  70. package/dist/check/fixtures/tenancy-prisma-fixtures.d.ts +4 -0
  71. package/dist/check/fixtures/tenancy-prisma-fixtures.d.ts.map +1 -0
  72. package/dist/check/fixtures/tenancy-prisma-fixtures.js +73 -0
  73. package/dist/check/fixtures/tenancy-prisma-fixtures.js.map +1 -0
  74. package/dist/check/fixtures/tenancy-typeorm-fixtures.d.ts +4 -0
  75. package/dist/check/fixtures/tenancy-typeorm-fixtures.d.ts.map +1 -0
  76. package/dist/check/fixtures/tenancy-typeorm-fixtures.js +88 -0
  77. package/dist/check/fixtures/tenancy-typeorm-fixtures.js.map +1 -0
  78. package/dist/check/mutation/stryker-settings.d.ts +8 -0
  79. package/dist/check/mutation/stryker-settings.d.ts.map +1 -0
  80. package/dist/check/mutation/stryker-settings.js +74 -0
  81. package/dist/check/mutation/stryker-settings.js.map +1 -0
  82. package/dist/check/privacy/column-definitions-in.d.ts +15 -0
  83. package/dist/check/privacy/column-definitions-in.d.ts.map +1 -0
  84. package/dist/check/privacy/column-definitions-in.js +32 -0
  85. package/dist/check/privacy/column-definitions-in.js.map +1 -0
  86. package/dist/check/privacy/declares-name.d.ts +4 -0
  87. package/dist/check/privacy/declares-name.d.ts.map +1 -0
  88. package/dist/check/privacy/declares-name.js +7 -0
  89. package/dist/check/privacy/declares-name.js.map +1 -0
  90. package/dist/check/privacy/personal-declarations-of.d.ts +15 -0
  91. package/dist/check/privacy/personal-declarations-of.d.ts.map +1 -0
  92. package/dist/check/privacy/personal-declarations-of.js +33 -0
  93. package/dist/check/privacy/personal-declarations-of.js.map +1 -0
  94. package/dist/check/privacy/personal-term-of.d.ts +3 -0
  95. package/dist/check/privacy/personal-term-of.d.ts.map +1 -0
  96. package/dist/check/privacy/personal-term-of.js +10 -0
  97. package/dist/check/privacy/personal-term-of.js.map +1 -0
  98. package/dist/check/privacy/personal-vocabulary.d.ts +9 -0
  99. package/dist/check/privacy/personal-vocabulary.d.ts.map +1 -0
  100. package/dist/check/privacy/personal-vocabulary.js +37 -0
  101. package/dist/check/privacy/personal-vocabulary.js.map +1 -0
  102. package/dist/check/privacy/prisma-columns-of.d.ts +17 -0
  103. package/dist/check/privacy/prisma-columns-of.d.ts.map +1 -0
  104. package/dist/check/privacy/prisma-columns-of.js +58 -0
  105. package/dist/check/privacy/prisma-columns-of.js.map +1 -0
  106. package/dist/check/privacy/privacy-judged.d.ts +8 -0
  107. package/dist/check/privacy/privacy-judged.d.ts.map +1 -0
  108. package/dist/check/privacy/privacy-judged.js +9 -0
  109. package/dist/check/privacy/privacy-judged.js.map +1 -0
  110. package/dist/check/privacy/published-events-of.d.ts +29 -0
  111. package/dist/check/privacy/published-events-of.d.ts.map +1 -0
  112. package/dist/check/privacy/published-events-of.js +80 -0
  113. package/dist/check/privacy/published-events-of.js.map +1 -0
  114. package/dist/check/privacy/same-name.d.ts +3 -0
  115. package/dist/check/privacy/same-name.d.ts.map +1 -0
  116. package/dist/check/privacy/same-name.js +6 -0
  117. package/dist/check/privacy/same-name.js.map +1 -0
  118. package/dist/check/privacy/vocabulary-of.d.ts +4 -0
  119. package/dist/check/privacy/vocabulary-of.d.ts.map +1 -0
  120. package/dist/check/privacy/vocabulary-of.js +10 -0
  121. package/dist/check/privacy/vocabulary-of.js.map +1 -0
  122. package/dist/check/privacy/words-of-name.d.ts +3 -0
  123. package/dist/check/privacy/words-of-name.d.ts.map +1 -0
  124. package/dist/check/privacy/words-of-name.js +9 -0
  125. package/dist/check/privacy/words-of-name.js.map +1 -0
  126. package/dist/check/rules/config-valid.js +1 -1
  127. package/dist/check/rules/config-valid.js.map +1 -1
  128. package/dist/check/rules/declarations-port-adapter-wired.d.ts.map +1 -1
  129. package/dist/check/rules/declarations-port-adapter-wired.js +21 -2
  130. package/dist/check/rules/declarations-port-adapter-wired.js.map +1 -1
  131. package/dist/check/rules/governance-recorded-deviation.d.ts.map +1 -1
  132. package/dist/check/rules/governance-recorded-deviation.js +20 -2
  133. package/dist/check/rules/governance-recorded-deviation.js.map +1 -1
  134. package/dist/check/rules/privacy-declared-field.d.ts +11 -0
  135. package/dist/check/rules/privacy-declared-field.d.ts.map +1 -0
  136. package/dist/check/rules/privacy-declared-field.js +63 -0
  137. package/dist/check/rules/privacy-declared-field.js.map +1 -0
  138. package/dist/check/rules/privacy-erasure-reaches-copies.d.ts +10 -0
  139. package/dist/check/rules/privacy-erasure-reaches-copies.d.ts.map +1 -0
  140. package/dist/check/rules/privacy-erasure-reaches-copies.js +46 -0
  141. package/dist/check/rules/privacy-erasure-reaches-copies.js.map +1 -0
  142. package/dist/check/rules/privacy-event-payload-declared.d.ts +10 -0
  143. package/dist/check/rules/privacy-event-payload-declared.d.ts.map +1 -0
  144. package/dist/check/rules/privacy-event-payload-declared.js +39 -0
  145. package/dist/check/rules/privacy-event-payload-declared.js.map +1 -0
  146. package/dist/check/rules/privacy-no-personal-data-in-logs.d.ts +12 -0
  147. package/dist/check/rules/privacy-no-personal-data-in-logs.d.ts.map +1 -0
  148. package/dist/check/rules/privacy-no-personal-data-in-logs.js +57 -0
  149. package/dist/check/rules/privacy-no-personal-data-in-logs.js.map +1 -0
  150. package/dist/check/rules/privacy-subject-is-opaque.d.ts +9 -0
  151. package/dist/check/rules/privacy-subject-is-opaque.d.ts.map +1 -0
  152. package/dist/check/rules/privacy-subject-is-opaque.js +50 -0
  153. package/dist/check/rules/privacy-subject-is-opaque.js.map +1 -0
  154. package/dist/check/rules/tenancy-scoped-statement.d.ts.map +1 -1
  155. package/dist/check/rules/tenancy-scoped-statement.js +6 -2
  156. package/dist/check/rules/tenancy-scoped-statement.js.map +1 -1
  157. package/dist/check/rules/test-mutation-governed.d.ts +3 -0
  158. package/dist/check/rules/test-mutation-governed.d.ts.map +1 -0
  159. package/dist/check/rules/test-mutation-governed.js +12 -0
  160. package/dist/check/rules/test-mutation-governed.js.map +1 -0
  161. package/dist/check/tenancy/accessor-uses.d.ts +13 -0
  162. package/dist/check/tenancy/accessor-uses.d.ts.map +1 -0
  163. package/dist/check/tenancy/accessor-uses.js +19 -0
  164. package/dist/check/tenancy/accessor-uses.js.map +1 -0
  165. package/dist/check/tenancy/declaration-of.d.ts +7 -0
  166. package/dist/check/tenancy/declaration-of.d.ts.map +1 -0
  167. package/dist/check/tenancy/declaration-of.js +11 -0
  168. package/dist/check/tenancy/declaration-of.js.map +1 -0
  169. package/dist/check/tenancy/declared-in-arguments.d.ts +13 -0
  170. package/dist/check/tenancy/declared-in-arguments.d.ts.map +1 -0
  171. package/dist/check/tenancy/declared-in-arguments.js +25 -0
  172. package/dist/check/tenancy/declared-in-arguments.js.map +1 -0
  173. package/dist/check/tenancy/declared-with.d.ts +3 -1
  174. package/dist/check/tenancy/declared-with.d.ts.map +1 -1
  175. package/dist/check/tenancy/declared-with.js +4 -3
  176. package/dist/check/tenancy/declared-with.js.map +1 -1
  177. package/dist/check/tenancy/drizzle-unscoped.d.ts.map +1 -1
  178. package/dist/check/tenancy/drizzle-unscoped.js +4 -3
  179. package/dist/check/tenancy/drizzle-unscoped.js.map +1 -1
  180. package/dist/check/tenancy/executor-uses.d.ts +3 -10
  181. package/dist/check/tenancy/executor-uses.d.ts.map +1 -1
  182. package/dist/check/tenancy/executor-uses.js +3 -11
  183. package/dist/check/tenancy/executor-uses.js.map +1 -1
  184. package/dist/check/tenancy/prisma-unscoped.d.ts +7 -0
  185. package/dist/check/tenancy/prisma-unscoped.d.ts.map +1 -0
  186. package/dist/check/tenancy/prisma-unscoped.js +60 -0
  187. package/dist/check/tenancy/prisma-unscoped.js.map +1 -0
  188. package/dist/check/tenancy/typeorm-unscoped.d.ts +7 -0
  189. package/dist/check/tenancy/typeorm-unscoped.d.ts.map +1 -0
  190. package/dist/check/tenancy/typeorm-unscoped.js +103 -0
  191. package/dist/check/tenancy/typeorm-unscoped.js.map +1 -0
  192. package/dist/check/tenancy/unscoped-read-models.js +2 -2
  193. package/dist/check/tenancy/unscoped-read-models.js.map +1 -1
  194. package/dist/commands/docs.d.ts.map +1 -1
  195. package/dist/commands/docs.js +23 -1
  196. package/dist/commands/docs.js.map +1 -1
  197. package/dist/commands/generate.js +9 -1
  198. package/dist/commands/generate.js.map +1 -1
  199. package/dist/commands/init.d.ts.map +1 -1
  200. package/dist/commands/init.js +4 -0
  201. package/dist/commands/init.js.map +1 -1
  202. package/dist/commands/lint.d.ts +3 -2
  203. package/dist/commands/lint.d.ts.map +1 -1
  204. package/dist/commands/lint.js +16 -4
  205. package/dist/commands/lint.js.map +1 -1
  206. package/dist/commands/mutation.d.ts +14 -0
  207. package/dist/commands/mutation.d.ts.map +1 -0
  208. package/dist/commands/mutation.js +62 -0
  209. package/dist/commands/mutation.js.map +1 -0
  210. package/dist/config/budget-levels.d.ts +3 -0
  211. package/dist/config/budget-levels.d.ts.map +1 -0
  212. package/dist/config/budget-levels.js +3 -0
  213. package/dist/config/budget-levels.js.map +1 -0
  214. package/dist/config/budget-problems.d.ts +10 -0
  215. package/dist/config/budget-problems.d.ts.map +1 -0
  216. package/dist/config/budget-problems.js +61 -0
  217. package/dist/config/budget-problems.js.map +1 -0
  218. package/dist/config/budget.d.ts +10 -0
  219. package/dist/config/budget.d.ts.map +1 -0
  220. package/dist/config/budget.js +2 -0
  221. package/dist/config/budget.js.map +1 -0
  222. package/dist/config/config.d.ts +16 -0
  223. package/dist/config/config.d.ts.map +1 -1
  224. package/dist/config/index.d.ts +7 -1
  225. package/dist/config/index.d.ts.map +1 -1
  226. package/dist/config/index.js +7 -1
  227. package/dist/config/index.js.map +1 -1
  228. package/dist/config/is-duration.d.ts +3 -0
  229. package/dist/config/is-duration.d.ts.map +1 -0
  230. package/dist/config/is-duration.js +5 -0
  231. package/dist/config/is-duration.js.map +1 -0
  232. package/dist/config/is-reference-budget.d.ts +4 -0
  233. package/dist/config/is-reference-budget.d.ts.map +1 -0
  234. package/dist/config/is-reference-budget.js +8 -0
  235. package/dist/config/is-reference-budget.js.map +1 -0
  236. package/dist/config/is-reference-mutation.d.ts +4 -0
  237. package/dist/config/is-reference-mutation.d.ts.map +1 -0
  238. package/dist/config/is-reference-mutation.js +7 -0
  239. package/dist/config/is-reference-mutation.js.map +1 -0
  240. package/dist/config/mutation-layers.d.ts +3 -0
  241. package/dist/config/mutation-layers.d.ts.map +1 -0
  242. package/dist/config/mutation-layers.js +3 -0
  243. package/dist/config/mutation-layers.js.map +1 -0
  244. package/dist/config/mutation-problems.d.ts +10 -0
  245. package/dist/config/mutation-problems.d.ts.map +1 -0
  246. package/dist/config/mutation-problems.js +46 -0
  247. package/dist/config/mutation-problems.js.map +1 -0
  248. package/dist/config/mutation.d.ts +4 -0
  249. package/dist/config/mutation.d.ts.map +1 -0
  250. package/dist/config/mutation.js +2 -0
  251. package/dist/config/mutation.js.map +1 -0
  252. package/dist/config/parse-budget.d.ts +4 -0
  253. package/dist/config/parse-budget.d.ts.map +1 -0
  254. package/dist/config/parse-budget.js +17 -0
  255. package/dist/config/parse-budget.js.map +1 -0
  256. package/dist/config/parse-config.d.ts.map +1 -1
  257. package/dist/config/parse-config.js +6 -0
  258. package/dist/config/parse-config.js.map +1 -1
  259. package/dist/config/parse-mutation.d.ts +4 -0
  260. package/dist/config/parse-mutation.d.ts.map +1 -0
  261. package/dist/config/parse-mutation.js +16 -0
  262. package/dist/config/parse-mutation.js.map +1 -0
  263. package/dist/config/parse-privacy.d.ts +4 -0
  264. package/dist/config/parse-privacy.d.ts.map +1 -0
  265. package/dist/config/parse-privacy.js +12 -0
  266. package/dist/config/parse-privacy.js.map +1 -0
  267. package/dist/config/parse-stack.d.ts.map +1 -1
  268. package/dist/config/parse-stack.js +4 -1
  269. package/dist/config/parse-stack.js.map +1 -1
  270. package/dist/config/reference-budget.d.ts +8 -0
  271. package/dist/config/reference-budget.d.ts.map +1 -0
  272. package/dist/config/reference-budget.js +7 -0
  273. package/dist/config/reference-budget.js.map +1 -0
  274. package/dist/config/reference-mutation.d.ts +10 -0
  275. package/dist/config/reference-mutation.d.ts.map +1 -0
  276. package/dist/config/reference-mutation.js +9 -0
  277. package/dist/config/reference-mutation.js.map +1 -0
  278. package/dist/config/serialize-config.d.ts.map +1 -1
  279. package/dist/config/serialize-config.js +13 -1
  280. package/dist/config/serialize-config.js.map +1 -1
  281. package/dist/config/stack.d.ts +17 -0
  282. package/dist/config/stack.d.ts.map +1 -1
  283. package/dist/config/stack.js +2 -0
  284. package/dist/config/stack.js.map +1 -1
  285. package/dist/docs/behaviour-page.d.ts +8 -0
  286. package/dist/docs/behaviour-page.d.ts.map +1 -0
  287. package/dist/docs/behaviour-page.js +83 -0
  288. package/dist/docs/behaviour-page.js.map +1 -0
  289. package/dist/docs/context-facts.d.ts +8 -0
  290. package/dist/docs/context-facts.d.ts.map +1 -1
  291. package/dist/docs/counts-of.d.ts +10 -0
  292. package/dist/docs/counts-of.d.ts.map +1 -0
  293. package/dist/docs/counts-of.js +14 -0
  294. package/dist/docs/counts-of.js.map +1 -0
  295. package/dist/docs/declared-table-of.d.ts +14 -0
  296. package/dist/docs/declared-table-of.d.ts.map +1 -0
  297. package/dist/docs/declared-table-of.js +39 -0
  298. package/dist/docs/declared-table-of.js.map +1 -0
  299. package/dist/docs/ensure-personal-data-region.d.ts +7 -0
  300. package/dist/docs/ensure-personal-data-region.d.ts.map +1 -0
  301. package/dist/docs/ensure-personal-data-region.js +21 -0
  302. package/dist/docs/ensure-personal-data-region.js.map +1 -0
  303. package/dist/docs/page-section.d.ts +12 -0
  304. package/dist/docs/page-section.d.ts.map +1 -0
  305. package/dist/docs/page-section.js +2 -0
  306. package/dist/docs/page-section.js.map +1 -0
  307. package/dist/docs/personal-data-lines.d.ts +7 -0
  308. package/dist/docs/personal-data-lines.d.ts.map +1 -0
  309. package/dist/docs/personal-data-lines.js +29 -0
  310. package/dist/docs/personal-data-lines.js.map +1 -0
  311. package/dist/docs/personal-declarations-in.d.ts +13 -0
  312. package/dist/docs/personal-declarations-in.d.ts.map +1 -0
  313. package/dist/docs/personal-declarations-in.js +66 -0
  314. package/dist/docs/personal-declarations-in.js.map +1 -0
  315. package/dist/docs/personal-table-cells.d.ts +12 -0
  316. package/dist/docs/personal-table-cells.d.ts.map +1 -0
  317. package/dist/docs/personal-table-cells.js +13 -0
  318. package/dist/docs/personal-table-cells.js.map +1 -0
  319. package/dist/docs/personal-table-facts.d.ts +17 -0
  320. package/dist/docs/personal-table-facts.d.ts.map +1 -0
  321. package/dist/docs/personal-table-facts.js +2 -0
  322. package/dist/docs/personal-table-facts.js.map +1 -0
  323. package/dist/docs/privacy-register-lines.d.ts +7 -0
  324. package/dist/docs/privacy-register-lines.d.ts.map +1 -0
  325. package/dist/docs/privacy-register-lines.js +34 -0
  326. package/dist/docs/privacy-register-lines.js.map +1 -0
  327. package/dist/docs/read-context.d.ts.map +1 -1
  328. package/dist/docs/read-context.js +17 -1
  329. package/dist/docs/read-context.js.map +1 -1
  330. package/dist/docs/read-personal-data.d.ts +12 -0
  331. package/dist/docs/read-personal-data.d.ts.map +1 -0
  332. package/dist/docs/read-personal-data.js +22 -0
  333. package/dist/docs/read-personal-data.js.map +1 -0
  334. package/dist/docs/refresh-context-doc.d.ts.map +1 -1
  335. package/dist/docs/refresh-context-doc.js +9 -1
  336. package/dist/docs/refresh-context-doc.js.map +1 -1
  337. package/dist/docs/rules-in.d.ts +25 -0
  338. package/dist/docs/rules-in.d.ts.map +1 -0
  339. package/dist/docs/rules-in.js +83 -0
  340. package/dist/docs/rules-in.js.map +1 -0
  341. package/dist/docs/write-behaviour.d.ts +10 -0
  342. package/dist/docs/write-behaviour.d.ts.map +1 -0
  343. package/dist/docs/write-behaviour.js +97 -0
  344. package/dist/docs/write-behaviour.js.map +1 -0
  345. package/dist/docs/write-docs.d.ts +12 -2
  346. package/dist/docs/write-docs.d.ts.map +1 -1
  347. package/dist/docs/write-docs.js +8 -2
  348. package/dist/docs/write-docs.js.map +1 -1
  349. package/dist/docs/write-privacy-register.d.ts +9 -0
  350. package/dist/docs/write-privacy-register.d.ts.map +1 -0
  351. package/dist/docs/write-privacy-register.js +26 -0
  352. package/dist/docs/write-privacy-register.js.map +1 -0
  353. package/dist/generate/kind.d.ts +14 -0
  354. package/dist/generate/kind.d.ts.map +1 -1
  355. package/dist/generate/kinds/acceptance-kind.js +5 -1
  356. package/dist/generate/kinds/acceptance-kind.js.map +1 -1
  357. package/dist/generate/kinds/background/spec-family.d.ts +8 -0
  358. package/dist/generate/kinds/background/spec-family.d.ts.map +1 -0
  359. package/dist/generate/kinds/background/spec-family.js +9 -0
  360. package/dist/generate/kinds/background/spec-family.js.map +1 -0
  361. package/dist/generate/kinds/background-job-kind.d.ts.map +1 -1
  362. package/dist/generate/kinds/background-job-kind.js +6 -4
  363. package/dist/generate/kinds/background-job-kind.js.map +1 -1
  364. package/dist/generate/kinds/command-kind.d.ts.map +1 -1
  365. package/dist/generate/kinds/command-kind.js +4 -0
  366. package/dist/generate/kinds/command-kind.js.map +1 -1
  367. package/dist/generate/kinds/erasure-handler-kind.d.ts +3 -0
  368. package/dist/generate/kinds/erasure-handler-kind.d.ts.map +1 -0
  369. package/dist/generate/kinds/erasure-handler-kind.js +46 -0
  370. package/dist/generate/kinds/erasure-handler-kind.js.map +1 -0
  371. package/dist/generate/kinds/generate-repository.d.ts +2 -1
  372. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  373. package/dist/generate/kinds/generate-repository.js +14 -11
  374. package/dist/generate/kinds/generate-repository.js.map +1 -1
  375. package/dist/generate/kinds/personal-data/class-header.d.ts +3 -0
  376. package/dist/generate/kinds/personal-data/class-header.d.ts.map +1 -0
  377. package/dist/generate/kinds/personal-data/class-header.js +7 -0
  378. package/dist/generate/kinds/personal-data/class-header.js.map +1 -0
  379. package/dist/generate/kinds/personal-data/column-lines.d.ts +4 -0
  380. package/dist/generate/kinds/personal-data/column-lines.d.ts.map +1 -0
  381. package/dist/generate/kinds/personal-data/column-lines.js +5 -0
  382. package/dist/generate/kinds/personal-data/column-lines.js.map +1 -0
  383. package/dist/generate/kinds/personal-data/declare-personal-data.d.ts +12 -0
  384. package/dist/generate/kinds/personal-data/declare-personal-data.d.ts.map +1 -0
  385. package/dist/generate/kinds/personal-data/declare-personal-data.js +73 -0
  386. package/dist/generate/kinds/personal-data/declare-personal-data.js.map +1 -0
  387. package/dist/generate/kinds/personal-data/fields-line.d.ts +3 -0
  388. package/dist/generate/kinds/personal-data/fields-line.d.ts.map +1 -0
  389. package/dist/generate/kinds/personal-data/fields-line.js +7 -0
  390. package/dist/generate/kinds/personal-data/fields-line.js.map +1 -0
  391. package/dist/generate/kinds/personal-data/personal-column.d.ts +7 -0
  392. package/dist/generate/kinds/personal-data/personal-column.d.ts.map +1 -0
  393. package/dist/generate/kinds/personal-data/personal-column.js +5 -0
  394. package/dist/generate/kinds/personal-data/personal-column.js.map +1 -0
  395. package/dist/generate/kinds/personal-data/personal-names.d.ts +21 -0
  396. package/dist/generate/kinds/personal-data/personal-names.d.ts.map +1 -0
  397. package/dist/generate/kinds/personal-data/personal-names.js +41 -0
  398. package/dist/generate/kinds/personal-data/personal-names.js.map +1 -0
  399. package/dist/generate/kinds/personal-data/personal-request-of.d.ts +18 -0
  400. package/dist/generate/kinds/personal-data/personal-request-of.d.ts.map +1 -0
  401. package/dist/generate/kinds/personal-data/personal-request-of.js +109 -0
  402. package/dist/generate/kinds/personal-data/personal-request-of.js.map +1 -0
  403. package/dist/generate/kinds/personal-data/personal-vars.d.ts +9 -0
  404. package/dist/generate/kinds/personal-data/personal-vars.d.ts.map +1 -0
  405. package/dist/generate/kinds/personal-data/personal-vars.js +107 -0
  406. package/dist/generate/kinds/personal-data/personal-vars.js.map +1 -0
  407. package/dist/generate/kinds/personal-data/property-of.d.ts +3 -0
  408. package/dist/generate/kinds/personal-data/property-of.d.ts.map +1 -0
  409. package/dist/generate/kinds/personal-data/property-of.js +5 -0
  410. package/dist/generate/kinds/personal-data/property-of.js.map +1 -0
  411. package/dist/generate/kinds/personal-data/row-object.d.ts +3 -0
  412. package/dist/generate/kinds/personal-data/row-object.d.ts.map +1 -0
  413. package/dist/generate/kinds/personal-data/row-object.js +5 -0
  414. package/dist/generate/kinds/personal-data/row-object.js.map +1 -0
  415. package/dist/generate/kinds/process-kind.d.ts.map +1 -1
  416. package/dist/generate/kinds/process-kind.js +5 -3
  417. package/dist/generate/kinds/process-kind.js.map +1 -1
  418. package/dist/generate/kinds/repository-kind.d.ts.map +1 -1
  419. package/dist/generate/kinds/repository-kind.js +6 -3
  420. package/dist/generate/kinds/repository-kind.js.map +1 -1
  421. package/dist/generate/kinds/repository-prefix.d.ts +5 -0
  422. package/dist/generate/kinds/repository-prefix.d.ts.map +1 -0
  423. package/dist/generate/kinds/repository-prefix.js +11 -0
  424. package/dist/generate/kinds/repository-prefix.js.map +1 -0
  425. package/dist/generate/kinds/state-machine/state-machine-vars.js +3 -1
  426. package/dist/generate/kinds/state-machine/state-machine-vars.js.map +1 -1
  427. package/dist/generate/kinds/wire-repository-on-first-use.d.ts +10 -0
  428. package/dist/generate/kinds/wire-repository-on-first-use.d.ts.map +1 -0
  429. package/dist/generate/kinds/wire-repository-on-first-use.js +14 -0
  430. package/dist/generate/kinds/wire-repository-on-first-use.js.map +1 -0
  431. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts +2 -1
  432. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
  433. package/dist/generate/kinds/write-event-sourced-aggregate.js +13 -2
  434. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
  435. package/dist/generate/kinds.d.ts.map +1 -1
  436. package/dist/generate/kinds.js +2 -0
  437. package/dist/generate/kinds.js.map +1 -1
  438. package/dist/generate/refresh-docs.d.ts +2 -1
  439. package/dist/generate/refresh-docs.d.ts.map +1 -1
  440. package/dist/generate/refresh-docs.js +2 -2
  441. package/dist/generate/refresh-docs.js.map +1 -1
  442. package/dist/help/notes.d.ts +1 -1
  443. package/dist/help/notes.d.ts.map +1 -1
  444. package/dist/help/notes.js +16 -0
  445. package/dist/help/notes.js.map +1 -1
  446. package/dist/help/usage.d.ts +1 -1
  447. package/dist/help/usage.d.ts.map +1 -1
  448. package/dist/help/usage.js +4 -3
  449. package/dist/help/usage.js.map +1 -1
  450. package/dist/init/files/event-sourcing-files.d.ts +9 -0
  451. package/dist/init/files/event-sourcing-files.d.ts.map +1 -0
  452. package/dist/init/files/event-sourcing-files.js +18 -0
  453. package/dist/init/files/event-sourcing-files.js.map +1 -0
  454. package/dist/init/files/init-files.d.ts.map +1 -1
  455. package/dist/init/files/init-files.js +4 -0
  456. package/dist/init/files/init-files.js.map +1 -1
  457. package/dist/init/files/platform-files.js +6 -1
  458. package/dist/init/files/platform-files.js.map +1 -1
  459. package/dist/init/files/privacy-files.d.ts +10 -0
  460. package/dist/init/files/privacy-files.d.ts.map +1 -0
  461. package/dist/init/files/privacy-files.js +24 -0
  462. package/dist/init/files/privacy-files.js.map +1 -0
  463. package/dist/init/files/project-files.d.ts.map +1 -1
  464. package/dist/init/files/project-files.js +5 -0
  465. package/dist/init/files/project-files.js.map +1 -1
  466. package/dist/init/files/script-files.d.ts +1 -0
  467. package/dist/init/files/script-files.d.ts.map +1 -1
  468. package/dist/init/files/script-files.js +8 -0
  469. package/dist/init/files/script-files.js.map +1 -1
  470. package/dist/init/knip-vars.d.ts.map +1 -1
  471. package/dist/init/knip-vars.js +1 -0
  472. package/dist/init/knip-vars.js.map +1 -1
  473. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  474. package/dist/init/manifest/database-scripts.js +9 -3
  475. package/dist/init/manifest/database-scripts.js.map +1 -1
  476. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  477. package/dist/init/manifest/dependencies-for.js +6 -2
  478. package/dist/init/manifest/dependencies-for.js.map +1 -1
  479. package/dist/init/manifest/scripts-for.js +17 -0
  480. package/dist/init/manifest/scripts-for.js.map +1 -1
  481. package/dist/init/manifest/test-scripts.d.ts.map +1 -1
  482. package/dist/init/manifest/test-scripts.js +3 -0
  483. package/dist/init/manifest/test-scripts.js.map +1 -1
  484. package/dist/init/manifest/versions.d.ts.map +1 -1
  485. package/dist/init/manifest/versions.js +27 -24
  486. package/dist/init/manifest/versions.js.map +1 -1
  487. package/dist/init/rewire-personal-data.d.ts +10 -0
  488. package/dist/init/rewire-personal-data.d.ts.map +1 -0
  489. package/dist/init/rewire-personal-data.js +32 -0
  490. package/dist/init/rewire-personal-data.js.map +1 -0
  491. package/dist/init/run-init.d.ts.map +1 -1
  492. package/dist/init/run-init.js +3 -1
  493. package/dist/init/run-init.js.map +1 -1
  494. package/dist/init/stack/resolve-personal-data.d.ts +10 -0
  495. package/dist/init/stack/resolve-personal-data.d.ts.map +1 -0
  496. package/dist/init/stack/resolve-personal-data.js +22 -0
  497. package/dist/init/stack/resolve-personal-data.js.map +1 -0
  498. package/dist/init/stack/resolve-queue.d.ts +4 -3
  499. package/dist/init/stack/resolve-queue.d.ts.map +1 -1
  500. package/dist/init/stack/resolve-queue.js +4 -6
  501. package/dist/init/stack/resolve-queue.js.map +1 -1
  502. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  503. package/dist/init/stack/resolve-stack.js +2 -0
  504. package/dist/init/stack/resolve-stack.js.map +1 -1
  505. package/dist/init/stack/resolve-tenancy.d.ts +3 -3
  506. package/dist/init/stack/resolve-tenancy.js +5 -5
  507. package/dist/init/stack/resolve-tenancy.js.map +1 -1
  508. package/dist/init/stack/stack-options.d.ts +4 -0
  509. package/dist/init/stack/stack-options.d.ts.map +1 -1
  510. package/dist/init/write-contracts.d.ts +2 -1
  511. package/dist/init/write-contracts.d.ts.map +1 -1
  512. package/dist/init/write-contracts.js +6 -3
  513. package/dist/init/write-contracts.js.map +1 -1
  514. package/dist/lint/eslint-in-project.d.ts +3 -2
  515. package/dist/lint/eslint-in-project.d.ts.map +1 -1
  516. package/dist/lint/eslint-in-project.js +5 -3
  517. package/dist/lint/eslint-in-project.js.map +1 -1
  518. package/dist/lint/lint-cache-of.d.ts +7 -0
  519. package/dist/lint/lint-cache-of.d.ts.map +1 -0
  520. package/dist/lint/lint-cache-of.js +47 -0
  521. package/dist/lint/lint-cache-of.js.map +1 -0
  522. package/dist/lint/lint-run.d.ts +2 -0
  523. package/dist/lint/lint-run.d.ts.map +1 -1
  524. package/dist/mutation/changed-files.d.ts +7 -0
  525. package/dist/mutation/changed-files.d.ts.map +1 -0
  526. package/dist/mutation/changed-files.js +15 -0
  527. package/dist/mutation/changed-files.js.map +1 -0
  528. package/dist/mutation/format-mutation.d.ts +4 -0
  529. package/dist/mutation/format-mutation.d.ts.map +1 -0
  530. package/dist/mutation/format-mutation.js +29 -0
  531. package/dist/mutation/format-mutation.js.map +1 -0
  532. package/dist/mutation/format-survivors.d.ts +8 -0
  533. package/dist/mutation/format-survivors.d.ts.map +1 -0
  534. package/dist/mutation/format-survivors.js +19 -0
  535. package/dist/mutation/format-survivors.js.map +1 -0
  536. package/dist/mutation/mutation-report-file.d.ts +3 -0
  537. package/dist/mutation/mutation-report-file.d.ts.map +1 -0
  538. package/dist/mutation/mutation-report-file.js +3 -0
  539. package/dist/mutation/mutation-report-file.js.map +1 -0
  540. package/dist/mutation/mutation-scores.d.ts +35 -0
  541. package/dist/mutation/mutation-scores.d.ts.map +1 -0
  542. package/dist/mutation/mutation-scores.js +55 -0
  543. package/dist/mutation/mutation-scores.js.map +1 -0
  544. package/dist/mutation/read-mutation-report.d.ts +16 -0
  545. package/dist/mutation/read-mutation-report.d.ts.map +1 -0
  546. package/dist/mutation/read-mutation-report.js +38 -0
  547. package/dist/mutation/read-mutation-report.js.map +1 -0
  548. package/dist/mutation/survivors.d.ts +19 -0
  549. package/dist/mutation/survivors.d.ts.map +1 -0
  550. package/dist/mutation/survivors.js +24 -0
  551. package/dist/mutation/survivors.js.map +1 -0
  552. package/dist/platform-layout/platform-layout.d.ts +2 -0
  553. package/dist/platform-layout/platform-layout.d.ts.map +1 -1
  554. package/dist/platform-layout/platform-layout.js +2 -0
  555. package/dist/platform-layout/platform-layout.js.map +1 -1
  556. package/dist/presets/apply-preset.js +2 -1
  557. package/dist/presets/apply-preset.js.map +1 -1
  558. package/dist/presets/identity-preset.d.ts.map +1 -1
  559. package/dist/presets/identity-preset.js +17 -1
  560. package/dist/presets/identity-preset.js.map +1 -1
  561. package/dist/presets/preset-files.d.ts.map +1 -1
  562. package/dist/presets/preset-files.js +1 -0
  563. package/dist/presets/preset-files.js.map +1 -1
  564. package/dist/presets/preset-step.d.ts +3 -1
  565. package/dist/presets/preset-step.d.ts.map +1 -1
  566. package/dist/run.d.ts.map +1 -1
  567. package/dist/run.js +2 -0
  568. package/dist/run.js.map +1 -1
  569. package/dist/stack/audit-vars.d.ts +1 -1
  570. package/dist/stack/audit-vars.d.ts.map +1 -1
  571. package/dist/stack/audit-vars.js +26 -8
  572. package/dist/stack/audit-vars.js.map +1 -1
  573. package/dist/stack/stack-vars.d.ts.map +1 -1
  574. package/dist/stack/stack-vars.js +44 -2
  575. package/dist/stack/stack-vars.js.map +1 -1
  576. package/dist/version.d.ts +1 -1
  577. package/dist/version.js +1 -1
  578. package/package.json +4 -2
  579. package/templates/background-job/background-job.spec.buses.ts.tpl +57 -0
  580. package/templates/background-job/wiring.manual.tpl +4 -0
  581. package/templates/context/CONTEXT.md.tpl +5 -0
  582. package/templates/controller/guard.spec.ts.tpl +2 -2
  583. package/templates/docs/asyncapi.privacy.json.tpl +100 -0
  584. package/templates/docs/event-catalog.privacy.md +18 -0
  585. package/templates/docs/privacy-register.md.tpl +25 -0
  586. package/templates/erasure-handler/erasure-handler.declared.ts.tpl +22 -0
  587. package/templates/erasure-handler/erasure-handler.spec.ts.tpl +36 -0
  588. package/templates/erasure-handler/erasure-handler.ts.tpl +20 -0
  589. package/templates/erasure-handler/wiring.manual.tpl +23 -0
  590. package/templates/erasure-handler/wiring.tsyringe.tpl +6 -0
  591. package/templates/init/README.md.tpl +43 -3
  592. package/templates/init/gitignore.tpl +3 -0
  593. package/templates/init/jest.config.js.tpl +2 -0
  594. package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +19 -1
  595. package/templates/init/platform/audit/create-audit.ts.tpl +28 -6
  596. package/templates/init/platform/composition/compose-application.manual.ts.tpl +64 -6
  597. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +12 -0
  598. package/templates/init/platform/composition/create-platform.manual.ts.tpl +7 -3
  599. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +14 -2
  600. package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +17 -1
  601. package/templates/init/platform/composition/platform-options.manual.ts.tpl +4 -1
  602. package/templates/init/platform/composition/platform-test.module.tsyringe.ts.tpl +36 -0
  603. package/templates/init/platform/composition/platform.manual.ts.tpl +16 -0
  604. package/templates/init/platform/database/open-persistence.memory.ts.tpl +20 -0
  605. package/templates/init/platform/database/open-test-database.prisma.ts.tpl +13 -2
  606. package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +21 -1
  607. package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +17 -1
  608. package/templates/init/platform/database/persistence-over.knex.ts.tpl +20 -1
  609. package/templates/init/platform/database/persistence-over.prisma.ts.tpl +21 -0
  610. package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +14 -1
  611. package/templates/init/platform/database/persistence.memory.ts.tpl +9 -0
  612. package/templates/init/platform/database/persistence.orm.ts.tpl +9 -1
  613. package/templates/init/platform/database/schema.drizzle.ts.tpl +18 -3
  614. package/templates/init/platform/database/schema.knex.ts.tpl +8 -1
  615. package/templates/init/platform/database/schema.prisma.tpl +131 -1
  616. package/templates/init/platform/database/schema.typeorm.ts.tpl +32 -1
  617. package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +36 -0
  618. package/templates/init/platform/event-sourcing/event-sourcing.module.ts.tpl +22 -0
  619. package/templates/init/platform/jobs/background-jobs.ts.tpl +21 -0
  620. package/templates/init/platform/jobs/create-background-work.ts.tpl +147 -0
  621. package/templates/init/platform/jobs/job-settings.ts.tpl +11 -0
  622. package/templates/init/platform/privacy/data-subject-copies.manual.ts.tpl +14 -0
  623. package/templates/init/platform/privacy/data-subject-copies.tsyringe.ts.tpl +13 -0
  624. package/templates/init/platform/privacy/data-subject-exports.manual.ts.tpl +14 -0
  625. package/templates/init/platform/privacy/data-subject-exports.tsyringe.ts.tpl +13 -0
  626. package/templates/init/platform/privacy/privacy.module.tsyringe.ts.tpl +20 -0
  627. package/templates/init/platform/privacy/run-erasure.manual.ts.tpl +100 -0
  628. package/templates/init/platform/privacy/run-erasure.tsyringe.ts.tpl +104 -0
  629. package/templates/init/platform/privacy/run-export.manual.ts.tpl +64 -0
  630. package/templates/init/platform/privacy/run-export.tsyringe.ts.tpl +71 -0
  631. package/templates/init/platform/privacy/run-purge.manual.ts.tpl +39 -0
  632. package/templates/init/platform/privacy/run-purge.tsyringe.ts.tpl +45 -0
  633. package/templates/init/rules/infrastructure.md.tpl +1 -1
  634. package/templates/init/rules/tests.md.tpl +1 -1
  635. package/templates/init/scripts/events.ts.tpl +12 -0
  636. package/templates/init/scripts/privacy-erase.manual.ts.tpl +78 -0
  637. package/templates/init/scripts/privacy-erase.tsyringe.ts.tpl +78 -0
  638. package/templates/init/scripts/privacy-export.manual.ts.tpl +79 -0
  639. package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +79 -0
  640. package/templates/init/scripts/privacy-purge.manual.ts.tpl +48 -0
  641. package/templates/init/scripts/privacy-purge.tsyringe.ts.tpl +48 -0
  642. package/templates/personal-data/adapter-field.tpl +4 -0
  643. package/templates/personal-data/copies.manual.tpl +4 -0
  644. package/templates/personal-data/copies.tsyringe.tpl +4 -0
  645. package/templates/personal-data/declaration.drizzle.ts.tpl +22 -0
  646. package/templates/personal-data/declaration.knex.ts.tpl +24 -0
  647. package/templates/personal-data/declaration.prisma.ts.tpl +24 -0
  648. package/templates/personal-data/declaration.typeorm.ts.tpl +21 -0
  649. package/templates/personal-data/erasure.drizzle.ts.tpl +43 -0
  650. package/templates/personal-data/erasure.knex.ts.tpl +41 -0
  651. package/templates/personal-data/erasure.prisma.ts.tpl +43 -0
  652. package/templates/personal-data/erasure.typeorm.ts.tpl +41 -0
  653. package/templates/personal-data/export-fake.ts.tpl +24 -0
  654. package/templates/personal-data/export-port.ts.tpl +8 -0
  655. package/templates/personal-data/export.drizzle.ts.tpl +43 -0
  656. package/templates/personal-data/export.knex.ts.tpl +41 -0
  657. package/templates/personal-data/export.prisma.ts.tpl +43 -0
  658. package/templates/personal-data/export.typeorm.ts.tpl +41 -0
  659. package/templates/personal-data/exports.manual.tpl +4 -0
  660. package/templates/personal-data/exports.tsyringe.tpl +4 -0
  661. package/templates/personal-data/fake.ts.tpl +26 -0
  662. package/templates/personal-data/port.ts.tpl +8 -0
  663. package/templates/personal-data/spec.ts.tpl +280 -0
  664. package/templates/personal-data/wiring.tsyringe.tpl +12 -0
  665. package/templates/pipeline/github/workflows/ci.yml.tpl +62 -0
  666. package/templates/pipeline/gitlab/gitlab-ci.yml.tpl +64 -2
  667. package/templates/pipeline/jest.mutation.config.js.tpl +8 -0
  668. package/templates/pipeline/knip.json.tpl +1 -1
  669. package/templates/pipeline/lefthook.yml +6 -0
  670. package/templates/pipeline/package-scripts.json +1 -1
  671. package/templates/pipeline/stryker.config.mjs.tpl +25 -0
  672. package/templates/pipeline/vitest.config.ts.tpl +2 -0
  673. package/templates/pipeline/vitest.mutation.config.ts.tpl +29 -0
  674. package/templates/presets/identity/context/infrastructure/persistence/account.personal-fields.privacy.drizzle.ts.tpl +17 -0
  675. package/templates/presets/identity/context/infrastructure/persistence/account.personal-fields.privacy.knex.ts.tpl +19 -0
  676. package/templates/presets/identity/context/infrastructure/persistence/invitation.personal-fields.privacy.drizzle.ts.tpl +18 -0
  677. package/templates/presets/identity/context/infrastructure/persistence/invitation.personal-fields.privacy.knex.ts.tpl +20 -0
  678. package/templates/presets/identity/context/test/unit/account-deactivated.integration-handler.spec.ts.tpl +4 -2
  679. package/templates/presets/identity/context/test/unit/deactivate-account.handler.spec.ts.tpl +7 -5
  680. package/templates/presets/identity/context/test/unit/environment-identity-provider-connection.adapter.spec.ts.tpl +7 -3
  681. package/templates/presets/identity/context/test/unit/invite-member.handler.spec.ts.tpl +7 -7
  682. package/templates/presets/identity/context/test/unit/member-joined.integration-handler.spec.ts.tpl +4 -2
  683. package/templates/presets/identity/context/test/unit/member-removed.integration-handler.spec.ts.tpl +5 -3
  684. package/templates/presets/identity/context/test/unit/organisation-opened.integration-handler.spec.ts.tpl +4 -2
  685. package/templates/presets/identity/context/test/unit/revoke-invitation.handler.spec.ts.tpl +7 -5
  686. package/templates/process/process.spec.ts.tpl +6 -3
  687. package/templates/process/timeout-job.spec.buses.ts.tpl +42 -0
  688. package/templates/process/timeout-job.wiring.manual.tpl +4 -0
  689. package/templates/repository/drizzle/mapper.ts.tpl +10 -0
  690. package/templates/repository/drizzle/table.tpl +6 -0
  691. package/templates/repository/knex/mapper.ts.tpl +10 -0
  692. package/templates/repository/knex/row.ts.tpl +3 -0
  693. package/templates/repository/knex/table.tpl +3 -0
  694. package/templates/repository/prisma/mapper.ts.tpl +16 -1
  695. package/templates/repository/prisma/model.tpl +9 -0
  696. package/templates/repository/prisma/repository.ts.tpl +55 -0
  697. package/templates/repository/typeorm/mapper.ts.tpl +10 -0
  698. package/templates/repository/typeorm/repository.ts.tpl +48 -0
  699. package/templates/repository/typeorm/row.ts.tpl +9 -1
  700. package/templates/repository/typeorm/table.tpl +27 -0
  701. package/templates/value-object/value-object.spec.ts.tpl +1 -0
  702. package/dist/generate/kinds/background/require-container.d.ts +0 -7
  703. package/dist/generate/kinds/background/require-container.d.ts.map +0 -1
  704. package/dist/generate/kinds/background/require-container.js +0 -13
  705. package/dist/generate/kinds/background/require-container.js.map +0 -1
  706. /package/templates/background-job/{background-job.spec.ts.tpl → background-job.spec.tsyringe.ts.tpl} +0 -0
  707. /package/templates/process/{timeout-job.spec.ts.tpl → timeout-job.spec.tsyringe.ts.tpl} +0 -0
  708. /package/templates/repository/{wiring.manual.tpl → first-use.wiring.manual.tpl} +0 -0
@@ -1,7 +1,17 @@
1
1
  import type { DataSource } from 'typeorm';
2
+ {{#if eventSourcing.on}}
3
+ import {
4
+ createTypeOrmEventSourcing,
5
+ createTypeOrmUnitOfWork,
6
+ TypeOrmOutboxStore,
7
+ TypeOrmProcessedEventStore,
8
+ } from '@ddd-ts-kit/typeorm';
9
+ {{/if}}
10
+ {{#unless eventSourcing.on}}
2
11
  import { createTypeOrmUnitOfWork, TypeOrmOutboxStore, TypeOrmProcessedEventStore } from '@ddd-ts-kit/typeorm';
12
+ {{/unless}}
3
13
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
4
- import { outbox, processedEvents } from '{{alias.platform}}/database/schema{{alias.ext}}';
14
+ import { {{#if eventSourcing.on}}EVENT_STORE_SCHEMA, {{/if}}outbox, processedEvents } from '{{alias.platform}}/database/schema{{alias.ext}}';
5
15
 
6
16
  /** One object is the unit of work and what repositories query through; the stores write through its manager. */
7
17
  export function persistenceOver(dataSource: DataSource): Persistence {
@@ -12,6 +22,9 @@ export function persistenceOver(dataSource: DataSource): Persistence {
12
22
  database: unitOfWork,
13
23
  outbox: new TypeOrmOutboxStore(unitOfWork, { entity: outbox }),
14
24
  processedEvents: new TypeOrmProcessedEventStore(unitOfWork, { entity: processedEvents }),
25
+ {{#if eventSourcing.on}}
26
+ eventSourcing: createTypeOrmEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA }),
27
+ {{/if}}
15
28
  close: async () => {
16
29
  if (dataSource.isInitialized) {
17
30
  await dataSource.destroy();
@@ -4,7 +4,12 @@ import type { OutboxStore, RelaySignal } from '@ddd-ts-kit/events';
4
4
  {{#unless persistence.signals}}
5
5
  import type { OutboxStore } from '@ddd-ts-kit/events';
6
6
  {{/unless}}
7
+ {{#if eventSourcing.on}}
8
+ import type { EventSourcingStores, ProcessedEventStore, UnitOfWork } from '@ddd-ts-kit/kernel';
9
+ {{/if}}
10
+ {{#unless eventSourcing.on}}
7
11
  import type { ProcessedEventStore, UnitOfWork } from '@ddd-ts-kit/kernel';
12
+ {{/unless}}
8
13
 
9
14
  /** Where state lives and how a command is made atomic. The composition root binds each member to its port. */
10
15
  export interface Persistence {
@@ -15,6 +20,10 @@ export interface Persistence {
15
20
  readonly relaySignal: RelaySignal;
16
21
  {{/if}}
17
22
  readonly processedEvents: ProcessedEventStore;
23
+ {{#if eventSourcing.on}}
24
+ /** The event store, the snapshots, the checkpoints and the keys of the data subjects: what an event-sourced aggregate is saved through, and what seals its personal values. */
25
+ readonly eventSourcing: EventSourcingStores;
26
+ {{/if}}
18
27
 
19
28
  close(): Promise<void>;
20
29
  }
@@ -1,5 +1,5 @@
1
1
  import type { OutboxStore } from '@ddd-ts-kit/events';
2
- import type { ProcessedEventStore, {{#if queue.processTable}}ProcessStore, {{/if}}UnitOfWork } from '@ddd-ts-kit/kernel';
2
+ import type { {{#if eventSourcing.on}}EventSourcingStores, {{/if}}ProcessedEventStore, {{#if queue.processTable}}ProcessStore, {{/if}}UnitOfWork } from '@ddd-ts-kit/kernel';
3
3
  {{#if queue.database}}
4
4
  import type { JobStore } from '@ddd-ts-kit/scheduling';
5
5
  {{/if}}
@@ -25,6 +25,14 @@ export interface Persistence {
25
25
  {{/if}}
26
26
  /** What repositories query through: the transaction of the current unit of work, or the database. */
27
27
  readonly database: {{persistence.token}};
28
+ {{#if eventSourcing.on}}
29
+ /**
30
+ * The event store, the snapshots, the checkpoints of the projections it feeds and the keys of the
31
+ * data subjects, in the `event_store` schema: what an event-sourced aggregate is loaded and saved
32
+ * through, and what seals its personal values. The platform binds each store to its port.
33
+ */
34
+ readonly eventSourcing: EventSourcingStores;
35
+ {{/if}}
28
36
 
29
37
  close(): Promise<void>;
30
38
  }
@@ -1,11 +1,11 @@
1
1
  {{#if audit.on}}
2
- import { auditChainsTable, auditEntriesTable } from '@ddd-ts-kit/audit/drizzle';
2
+ import { auditArchivesTable, auditChainsTable, auditEntriesTable } from '@ddd-ts-kit/audit/drizzle';
3
3
  {{/if}}
4
4
  {{#if tenancy.any}}
5
- import { {{#if queue.database}}jobsTable, {{/if}}processedEventsTable{{#if queue.processTable}}, processesTable{{/if}}, tenantOutboxTable } from '@ddd-ts-kit/drizzle/postgres';
5
+ import { {{#if eventSourcing.on}}eventStoreTables, {{/if}}{{#if queue.database}}jobsTable, {{/if}}processedEventsTable{{#if queue.processTable}}, processesTable{{/if}}, tenantOutboxTable } from '@ddd-ts-kit/drizzle/postgres';
6
6
  {{/if}}
7
7
  {{#unless tenancy.any}}
8
- import { {{#if queue.database}}jobsTable, {{/if}}outboxTable, processedEventsTable{{#if queue.processTable}}, processesTable{{/if}} } from '@ddd-ts-kit/drizzle/postgres';
8
+ import { {{#if eventSourcing.on}}eventStoreTables, {{/if}}{{#if queue.database}}jobsTable, {{/if}}outboxTable, processedEventsTable{{#if queue.processTable}}, processesTable{{/if}} } from '@ddd-ts-kit/drizzle/postgres';
9
9
  {{/unless}}
10
10
 
11
11
  /** The schema of what the kit stores for the application: the outbox and the processed events{{#if queue.database}}, the background jobs{{/if}}{{#if queue.processTable}}, the process instances{{/if}}. */
@@ -37,6 +37,21 @@ export const AUDIT_SCHEMA = 'audit';
37
37
  // TODO(platform): drizzle-kit writes no trigger. After the first `npm run db:generate <name>`, add a custom migration (`npm run db:generate -- audit-guard --custom`) holding the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
38
38
  export const auditEntries = auditEntriesTable(AUDIT_SCHEMA);
39
39
  export const auditChains = auditChainsTable(AUDIT_SCHEMA);
40
+ /** One row per range of a chain moved to the storage of files: the anchor the chain goes on from. */
41
+ export const auditArchives = auditArchivesTable(AUDIT_SCHEMA);
42
+ {{/if}}
43
+ {{#if eventSourcing.on}}
44
+
45
+ /** The schema of the event store: the events, the snapshots, the checkpoints and the keys of the data subjects. It records no tenant. */
46
+ export const EVENT_STORE_SCHEMA = 'event_store';
47
+
48
+ const eventStore = eventStoreTables(EVENT_STORE_SCHEMA);
49
+
50
+ export const storedEventsHead = eventStore.head;
51
+ export const storedEvents = eventStore.events;
52
+ export const streamSnapshots = eventStore.snapshots;
53
+ export const subscriptionCheckpoints = eventStore.checkpoints;
54
+ export const subjectKeys = eventStore.subjectKeys;
40
55
  {{/if}}
41
56
 
42
57
  // ddd-ts-kit:schemas
@@ -2,12 +2,16 @@ import type { Knex } from 'knex';
2
2
  {{#if audit.on}}
3
3
  import { createAuditTables } from '@ddd-ts-kit/audit/knex';
4
4
  {{/if}}
5
- import { {{#if queue.database}}createJobTable, {{/if}}createOutboxTables{{#if queue.processTable}}, createProcessTable{{/if}} } from '@ddd-ts-kit/knex';
5
+ import { {{#if eventSourcing.on}}createEventStoreTables, {{/if}}{{#if queue.database}}createJobTable, {{/if}}createOutboxTables{{#if queue.processTable}}, createProcessTable{{/if}} } from '@ddd-ts-kit/knex';
6
6
  // ddd-ts-kit:imports
7
7
  // /ddd-ts-kit:imports
8
8
 
9
9
  /** The schema of what the kit stores for the application: the outbox and the processed events{{#if queue.database}}, the background jobs{{/if}}{{#if queue.processTable}}, the process instances{{/if}}. */
10
10
  export const MESSAGING_SCHEMA = 'messaging';
11
+ {{#if eventSourcing.on}}
12
+ /** The schema of the event store: the events, the snapshots, the checkpoints and the keys of the data subjects. It records no tenant. */
13
+ export const EVENT_STORE_SCHEMA = 'event_store';
14
+ {{/if}}
11
15
  {{#if audit.on}}
12
16
  /** The schema of the audit trail: two tables, and the triggers that keep the entries append-only. */
13
17
  export const AUDIT_SCHEMA = 'audit';
@@ -35,6 +39,9 @@ export const createTables = async (knex: Knex): Promise<void> => {
35
39
  {{#if audit.on}}
36
40
  await createAuditTables(knex, { schema: AUDIT_SCHEMA });
37
41
  {{/if}}
42
+ {{#if eventSourcing.on}}
43
+ await createEventStoreTables(knex, { schema: EVENT_STORE_SCHEMA });
44
+ {{/if}}
38
45
  // ddd-ts-kit:schemas
39
46
  // /ddd-ts-kit:schemas
40
47
  };
@@ -7,7 +7,7 @@ generator client {
7
7
 
8
8
  datasource db {
9
9
  provider = "postgresql"
10
- schemas = ["messaging"]
10
+ schemas = ["messaging"{{#if eventSourcing.on}}, "event_store"{{/if}}{{#if audit.on}}, "audit"{{/if}}]
11
11
  }
12
12
 
13
13
  // The outbox and the idempotency table, from @ddd-ts-kit/prisma. Keep the field names: the
@@ -21,6 +21,10 @@ model OutboxRecord {
21
21
  payload Json?
22
22
  traceparent String?
23
23
  correlationId String? @map("correlation_id")
24
+ {{#if tenancy.any}}
25
+ /// The tenant of the event, so that its consumers run in that tenant.
26
+ tenantId String? @map("tenant_id")
27
+ {{/if}}
24
28
  status String @default("pending")
25
29
  attempts Int @default(0)
26
30
  nextAttemptAt DateTime @map("next_attempt_at") @db.Timestamptz(3)
@@ -46,3 +50,129 @@ model ProcessedEvent {
46
50
  // One schema per bounded context, no relation across contexts.
47
51
  // ddd-ts-kit:models
48
52
  // /ddd-ts-kit:models
53
+ {{#if eventSourcing.on}}
54
+
55
+ // The event store of @ddd-ts-kit/prisma: the events, the snapshots, the checkpoints and the
56
+ // keys of the data subjects. Keep the table and column names: the stores run raw statements
57
+ // against them. It records no tenant.
58
+ model StoredEventsHead {
59
+ id Int @id @db.SmallInt
60
+ position BigInt
61
+
62
+ @@map("stored_events_head")
63
+ @@schema("event_store")
64
+ }
65
+
66
+ model StoredEvent {
67
+ position BigInt @id
68
+ stream String
69
+ version Int
70
+ eventId String @unique @map("event_id")
71
+ type String
72
+ schemaVersion Int @map("schema_version")
73
+ data Json
74
+ metadata Json
75
+ occurredAt DateTime @map("occurred_at") @db.Timestamptz(3)
76
+ recordedAt DateTime @default(now()) @map("recorded_at") @db.Timestamptz(3)
77
+
78
+ @@unique([stream, version])
79
+ @@map("stored_events")
80
+ @@schema("event_store")
81
+ }
82
+
83
+ model StreamSnapshot {
84
+ stream String @id
85
+ version Int
86
+ schemaVersion Int @map("schema_version")
87
+ data Json
88
+ takenAt DateTime @default(now()) @map("taken_at") @db.Timestamptz(3)
89
+
90
+ @@map("stream_snapshots")
91
+ @@schema("event_store")
92
+ }
93
+
94
+ model SubscriptionCheckpoint {
95
+ subscriber String @id
96
+ position BigInt
97
+ updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz(3)
98
+
99
+ @@map("subscription_checkpoints")
100
+ @@schema("event_store")
101
+ }
102
+
103
+ /// One key per data subject: erasing the subject deletes its row.
104
+ model SubjectKey {
105
+ subject String @id
106
+ keyId String @unique @map("key_id")
107
+ material String
108
+ createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
109
+
110
+ @@map("subject_keys")
111
+ @@schema("event_store")
112
+ }
113
+ {{/if}}
114
+ {{#if audit.on}}
115
+
116
+ // TODO(platform): Prisma writes no trigger. After the first `npm run db:generate <name>`, add a migration (`npm run db:generate audit-guard`) holding the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
117
+ /// The audit trail of @ddd-ts-kit/audit: written by PrismaAuditTrail with raw statements, append-only once the guard is migrated.
118
+ model AuditEntry {
119
+ id String @unique
120
+ chain String
121
+ sequence BigInt
122
+ occurredAt DateTime @map("occurred_at") @db.Timestamptz(3)
123
+ category String
124
+ action String
125
+ outcome String
126
+ reason String?
127
+ actorId String @map("actor_id")
128
+ actorType String @map("actor_type")
129
+ actorTenantId String? @map("actor_tenant_id")
130
+ tenantId String? @map("tenant_id")
131
+ impersonatedBy String? @map("impersonated_by")
132
+ sessionId String? @map("session_id")
133
+ resourceType String? @map("resource_type")
134
+ resourceId String? @map("resource_id")
135
+ context String?
136
+ correlationId String @map("correlation_id")
137
+ causationId String? @map("causation_id")
138
+ origin String
139
+ changes Json?
140
+ extensions Json @default("{}")
141
+ previousHash String @map("previous_hash")
142
+ hash String
143
+
144
+ @@id([chain, sequence])
145
+ @@index([occurredAt, chain, sequence], map: "audit_entries_occurred_idx")
146
+ @@index([actorId, occurredAt], map: "audit_entries_actor_idx")
147
+ @@index([resourceType, resourceId], map: "audit_entries_resource_idx")
148
+ @@index([correlationId], map: "audit_entries_correlation_idx")
149
+ @@map("audit_entries")
150
+ @@schema("audit")
151
+ }
152
+
153
+ /// The archives of the audit trail: one row per range of a chain written to the file storage, append-only, read by the guard.
154
+ model AuditArchive {
155
+ chain String
156
+ fromSequence BigInt @map("from_sequence")
157
+ toSequence BigInt @map("to_sequence")
158
+ lastHash String @map("last_hash")
159
+ entries Int
160
+ fileKey String @map("file_key")
161
+ fileDigest String @map("file_digest")
162
+ archivedAt DateTime @map("archived_at") @db.Timestamptz(3)
163
+
164
+ @@id([chain, toSequence])
165
+ @@map("audit_archives")
166
+ @@schema("audit")
167
+ }
168
+
169
+ /// The head of each chain of the audit trail: the row an append locks.
170
+ model AuditChain {
171
+ chain String @id
172
+ sequence BigInt
173
+ hash String
174
+
175
+ @@map("audit_chains")
176
+ @@schema("audit")
177
+ }
178
+ {{/if}}
@@ -1,18 +1,49 @@
1
+ {{#if audit.on}}
2
+ import { auditEntities } from '@ddd-ts-kit/audit/typeorm';
3
+ {{/if}}
1
4
  import type { EntitySchema } from 'typeorm';
2
- import { outboxEntity, processedEventEntity } from '@ddd-ts-kit/typeorm';
5
+ import { {{#if eventSourcing.on}}eventStoreEntities, {{/if}}outboxEntity, processedEventEntity } from '@ddd-ts-kit/typeorm';
3
6
  // ddd-ts-kit:imports
4
7
  // /ddd-ts-kit:imports
5
8
 
6
9
  /** The schema of what the kit stores for the application: the outbox and the processed events. */
7
10
  export const MESSAGING_SCHEMA = 'messaging';
8
11
 
12
+ {{#if tenancy.any}}
13
+ // The tenant of each event, so that its consumers run in that tenant.
14
+ export const outbox = outboxEntity({ schema: MESSAGING_SCHEMA, tenant: true });
15
+ {{/if}}
16
+ {{#unless tenancy.any}}
9
17
  export const outbox = outboxEntity({ schema: MESSAGING_SCHEMA });
18
+ {{/unless}}
10
19
  export const processedEvents = processedEventEntity({ schema: MESSAGING_SCHEMA });
11
20
 
21
+ {{#if eventSourcing.on}}
22
+ /** The schema of the event store: the events, the snapshots, the checkpoints and the keys of the data subjects. It records no tenant. */
23
+ export const EVENT_STORE_SCHEMA = 'event_store';
24
+
25
+ /** The five tables of the event store, registered with the data source and migrated like the others. */
26
+ export const eventStore = eventStoreEntities({ schema: EVENT_STORE_SCHEMA });
27
+
28
+ {{/if}}
29
+ {{#if audit.on}}
30
+ /** The schema of the audit trail. */
31
+ export const AUDIT_SCHEMA = 'audit';
32
+
33
+ // TODO(platform): TypeORM generates no trigger. After the first `npm run db:generate migrations/<name>`, add a migration of your own that runs the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
34
+ export const auditTrail = auditEntities({ schema: AUDIT_SCHEMA });
35
+
36
+ {{/if}}
12
37
  /** Every table of the application: what the data source registers and what migrations are generated from. */
13
38
  export const entities: readonly EntitySchema[] = [
14
39
  outbox,
15
40
  processedEvents,
41
+ {{#if eventSourcing.on}}
42
+ ...eventStore,
43
+ {{/if}}
44
+ {{#if audit.on}}
45
+ ...auditTrail,
46
+ {{/if}}
16
47
  // ddd-ts-kit:schemas
17
48
  // /ddd-ts-kit:schemas
18
49
  ];
@@ -0,0 +1,36 @@
1
+ {{#if audit.on}}
2
+ import { auditedSubjectKeys, type AuditSource } from '@ddd-ts-kit/audit';
3
+ {{/if}}
4
+ import { PersonalDataCipher, type EventSourcingStores } from '@ddd-ts-kit/kernel';
5
+ {{#if audit.on}}
6
+ import type { Audit } from '{{alias.platform}}/audit/create-audit{{alias.ext}}';
7
+ {{/if}}
8
+ import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
9
+
10
+ /**
11
+ * The event store as the platform hands it on: the stores an event-sourced repository adapter is
12
+ * given (the events, the snapshots, the checkpoints of the projections the store feeds), the keys
13
+ * of the data subjects and the cipher that seals a personal value of a stored event with the key
14
+ * of its subject. An erasure destroys the key{{#if audit.on}}, and every erasure leaves a dated entry in the audit
15
+ * trail, whoever asks for it{{/if}}. The keys live in the `subject_keys` table of the event store: a
16
+ * deployment that promises erasure keeps them in a store of their own, with a shorter backup
17
+ * retention than the events (docs/concepts/event-sourcing.md of ddd-ts-kit, "Personal data").
18
+ */
19
+ export interface EventSourcing extends EventSourcingStores {
20
+ readonly cipher: PersonalDataCipher;
21
+ }
22
+
23
+ {{#if audit.on}}
24
+ export function createEventSourcing(persistence: Persistence, audit: Audit, source: AuditSource): EventSourcing {
25
+ const subjectKeys = auditedSubjectKeys(persistence.eventSourcing.subjectKeys, audit.trail, source);
26
+
27
+ return { ...persistence.eventSourcing, subjectKeys, cipher: new PersonalDataCipher(subjectKeys) };
28
+ }
29
+ {{/if}}
30
+ {{#unless audit.on}}
31
+ export function createEventSourcing(persistence: Persistence): EventSourcing {
32
+ const { subjectKeys } = persistence.eventSourcing;
33
+
34
+ return { ...persistence.eventSourcing, cipher: new PersonalDataCipher(subjectKeys) };
35
+ }
36
+ {{/unless}}
@@ -0,0 +1,22 @@
1
+ import { defineContextModule, type ContextModule } from '@ddd-ts-kit/di';
2
+ import { CheckpointStore, EventStore, PersonalDataCipher, SnapshotStore, SubjectKeyStore } from '@ddd-ts-kit/kernel';
3
+ import type { EventSourcing } from '{{alias.platform}}/event-sourcing/create-event-sourcing{{alias.ext}}';
4
+
5
+ /**
6
+ * The event store as a capability of the platform, not a bounded context: the stores an
7
+ * event-sourced repository adapter names in its constructor (`EventStore`, `SnapshotStore`,
8
+ * `CheckpointStore`), the keys of the data subjects{{#if audit.on}}, audited,{{/if}} and the cipher that seals a personal
9
+ * value of a stored event (`PersonalDataCipher`).
10
+ */
11
+ export function eventSourcingModule(eventSourcing: EventSourcing): ContextModule {
12
+ return defineContextModule({
13
+ name: 'event-sourcing',
14
+ register(builder) {
15
+ builder.bind(EventStore).toValue(eventSourcing.events);
16
+ builder.bind(SnapshotStore).toValue(eventSourcing.snapshots);
17
+ builder.bind(CheckpointStore).toValue(eventSourcing.checkpoints);
18
+ builder.bind(SubjectKeyStore).toValue(eventSourcing.subjectKeys);
19
+ builder.bind(PersonalDataCipher).toValue(eventSourcing.cipher);
20
+ },
21
+ });
22
+ }
@@ -0,0 +1,21 @@
1
+ import type { BackgroundJob, BackgroundJobOptions } from '@ddd-ts-kit/kernel';
2
+
3
+ /** A background job class: named by its static `jobName`, built from what its constructor takes. */
4
+ export interface BackgroundJobClass<Deps extends readonly unknown[]> {
5
+ readonly jobName: string;
6
+ new (...deps: Deps): BackgroundJob<unknown>;
7
+ }
8
+
9
+ /** Where a context registers its background jobs; the application starts it when this process runs the jobs. */
10
+ export interface BackgroundJobs {
11
+ /** Registers a job under its static `jobName`, built once from its dependencies; each attempt is observed from outside (its span), named after the job and its context. */
12
+ register<const Deps extends readonly unknown[]>(
13
+ job: BackgroundJobClass<Deps>,
14
+ deps: Deps,
15
+ options?: BackgroundJobOptions,
16
+ ): void;
17
+
18
+ start(): Promise<void>;
19
+
20
+ stop(): Promise<void>;
21
+ }
@@ -0,0 +1,147 @@
1
+ {{#if queue.processTable}}
2
+ import type { CommandBus, JobQueue, ProcessRunner } from '@ddd-ts-kit/kernel';
3
+ {{/if}}
4
+ {{#unless queue.processTable}}
5
+ import { InMemoryProcessStore, type CommandBus, type JobQueue, type ProcessRunner } from '@ddd-ts-kit/kernel';
6
+ {{/unless}}
7
+ {{#if queue.database}}
8
+ {{#if errors.sentry}}
9
+ import {
10
+ QueueWorker,
11
+ StoredJobQueue,
12
+ StoredProcessRunner,
13
+ reportFailedBackgroundJobs,
14
+ type JobStore,
15
+ } from '@ddd-ts-kit/scheduling';
16
+ {{/if}}
17
+ {{#unless errors.sentry}}
18
+ import { QueueWorker, StoredJobQueue, StoredProcessRunner, type JobStore } from '@ddd-ts-kit/scheduling';
19
+ {{/unless}}
20
+ {{/if}}
21
+ {{#unless queue.database}}
22
+ import {
23
+ InMemoryJobStore,
24
+ QueueWorker,
25
+ StoredJobQueue,
26
+ StoredProcessRunner,
27
+ {{#if errors.sentry}}
28
+ reportFailedBackgroundJobs,
29
+ {{/if}}
30
+ type JobStore,
31
+ } from '@ddd-ts-kit/scheduling';
32
+ {{/unless}}
33
+ import type { TracedApplication } from '@ddd-ts-kit/tracing';
34
+ import type { Foundations } from '{{alias.platform}}/composition/lay-foundations{{alias.ext}}';
35
+ import type { PlatformOptions } from '{{alias.platform}}/composition/platform-options{{alias.ext}}';
36
+ import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
37
+ import type { BackgroundJobs } from '{{alias.platform}}/jobs/background-jobs{{alias.ext}}';
38
+
39
+ /** The queue a use case enqueues through, the worker that consumes it and the runner of the process managers. */
40
+ export interface BackgroundWork {
41
+ /** What a use case enqueues through, in the transaction of its command when the store shares it. */
42
+ readonly jobQueue: JobQueue;
43
+ readonly backgroundJobs: BackgroundJobs;
44
+ /** Runs the steps of the process managers and delivers their timeouts. */
45
+ readonly processes: ProcessRunner;
46
+ }
47
+
48
+ interface BackgroundWorkParts {
49
+ readonly persistence: Persistence;
50
+ readonly options: PlatformOptions;
51
+ readonly foundations: Foundations;
52
+ /** The bus the runner of the process managers sends the commands of a step on. */
53
+ readonly commands: CommandBus;
54
+ }
55
+
56
+ /**
57
+ * The background work of the platform on one job store{{#if queue.database}}: the jobs table of the persistence, so a job
58
+ * enqueued by a command exists if and only if the command committed{{/if}}{{#if queue.redis}}: the server of the cache, written
59
+ * once the command committed; left out (the tools, the tests), the memory of the process{{/if}}{{#if queue.memory}}: the memory of
60
+ * the process, seen by no other process and lost when it restarts (`init --force --queue database`
61
+ * moves it to the database){{/if}}. A job carries the correlation, the actor, the tenant and the trace of the
62
+ * work that enqueued it; the worker runs each attempt in that scope.
63
+ */
64
+ export function createBackgroundWork({
65
+ persistence,
66
+ options,
67
+ foundations,
68
+ commands,
69
+ }: BackgroundWorkParts): BackgroundWork {
70
+ const { traced, clock, ids, scope } = foundations;
71
+ {{#if queue.database}}
72
+ const store = persistence.jobs;
73
+ {{/if}}
74
+ {{#if queue.redis}}
75
+ {{#if errors.sentry}}
76
+ const store = options.redis?.jobs(foundations.logger, foundations.errors) ?? new InMemoryJobStore();
77
+ {{/if}}
78
+ {{#unless errors.sentry}}
79
+ const store = options.redis?.jobs(foundations.logger) ?? new InMemoryJobStore();
80
+ {{/unless}}
81
+ {{/if}}
82
+ {{#if queue.memory}}
83
+ const store = new InMemoryJobStore();
84
+ {{/if}}
85
+ const jobQueue = new StoredJobQueue({ store, clock, ids, scope, traceparent: traced.traceparent });
86
+
87
+ return {
88
+ jobQueue,
89
+ backgroundJobs: backgroundJobsOn(workerOn(store, options, foundations), traced),
90
+ processes: new StoredProcessRunner({
91
+ {{#if queue.processTable}}
92
+ // The instances of the process managers, saved in the transaction of each step.
93
+ store: persistence.processes,
94
+ {{/if}}
95
+ {{#unless queue.processTable}}
96
+ // The instances of the process managers, in the memory of the process: `KnexProcessStore` or `DrizzleProcessStore` keeps them with the steps.
97
+ store: new InMemoryProcessStore(),
98
+ {{/unless}}
99
+ jobs: jobQueue,
100
+ commands,
101
+ unitOfWork: persistence.unitOfWork,
102
+ }),
103
+ };
104
+ }
105
+
106
+ /** The worker of the store, tuned by `queues`{{#if errors.sentry}}; an attempt that failed, retried or not, is reported with the id of the trace it ran in{{/if}}. */
107
+ function workerOn(store: JobStore, options: PlatformOptions, foundations: Foundations): QueueWorker {
108
+ const { clock, scope, logger, metrics } = foundations;
109
+
110
+ return new QueueWorker({
111
+ ...options.queues,
112
+ store,
113
+ clock,
114
+ scope,
115
+ logger,
116
+ metrics,
117
+ {{#if errors.sentry}}
118
+ onRun: reportFailedBackgroundJobs(foundations.errors),
119
+ {{/if}}
120
+ });
121
+ }
122
+
123
+ /** Each attempt observed from outside (its span), named after the job and its context. */
124
+ function backgroundJobsOn(worker: QueueWorker, traced: TracedApplication): BackgroundJobs {
125
+ return {
126
+ register: (job, deps, options) => {
127
+ const { jobName: name } = job;
128
+ const built = new job(...deps);
129
+
130
+ worker.register({
131
+ name,
132
+ ...(options === undefined ? {} : { options }),
133
+ run: traced.backgroundJob((payload, execution) => built.run(payload, execution), {
134
+ name,
135
+ context: contextOf(name),
136
+ }),
137
+ });
138
+ },
139
+ start: () => worker.start(),
140
+ stop: () => worker.stop(),
141
+ };
142
+ }
143
+
144
+ /** A background job is named `<context>.<job>`. */
145
+ function contextOf(jobName: string): string {
146
+ return jobName.split('.')[0] ?? jobName;
147
+ }
@@ -11,6 +11,17 @@ type Environment = Readonly<Record<string, string | undefined>>;
11
11
  */
12
12
  export function jobSettings(environment: Environment, context?: string): Readonly<Record<string, JobSettings>> {
13
13
  const settings: Readonly<Record<string, JobSettings>> = {
14
+ {{#if audit.archiveByDefault}}
15
+ 'audit.archive': { enabled: environment['JOB_AUDIT_ARCHIVE_ENABLED'] !== 'false' },
16
+ {{/if}}
17
+ {{#if audit.archiveOnRequest}}
18
+ // Off while the files are on the disk of the server, since an archive removes the entries from the
19
+ // database: JOB_AUDIT_ARCHIVE_ENABLED=true once that disk is durable and backed up.
20
+ 'audit.archive': { enabled: environment['JOB_AUDIT_ARCHIVE_ENABLED'] === 'true' },
21
+ {{/if}}
22
+ {{#if privacy.on}}
23
+ 'privacy.purge-expired': { enabled: environment['JOB_PRIVACY_PURGE_EXPIRED_ENABLED'] !== 'false' },
24
+ {{/if}}
14
25
  // ddd-ts-kit:jobs
15
26
  // /ddd-ts-kit:jobs
16
27
  };
@@ -0,0 +1,14 @@
1
+ import type { PersonalDataCopy } from '@ddd-ts-kit/kernel';
2
+ import type { Platform } from '{{alias.platform}}/composition/platform{{alias.ext}}';
3
+ // ddd-ts-kit:imports
4
+ // /ddd-ts-kit:imports
5
+
6
+ /**
7
+ * The copies the contexts keep of a person, each erased by the adapter of its context, instantiated
8
+ * from the platform as the module file of the context does. `generate repository <context> <Aggregate>
9
+ * --personal <column>,...` adds the adapter of its context here, once.
10
+ */
11
+ export const dataSubjectCopies: readonly ((platform: Platform) => PersonalDataCopy)[] = [
12
+ // ddd-ts-kit:copies
13
+ // /ddd-ts-kit:copies
14
+ ];
@@ -0,0 +1,13 @@
1
+ import type { PersonalDataErasure } from '@ddd-ts-kit/kernel';
2
+ // ddd-ts-kit:imports
3
+ // /ddd-ts-kit:imports
4
+
5
+ /**
6
+ * The ports of the contexts that erase what they keep of a person, one per context, each extending
7
+ * `PersonalDataErasure` of the kernel: the erasure resolves them once the application is composed.
8
+ * `generate repository <context> <Aggregate> --personal <column>,...` adds the port of its context here, once.
9
+ */
10
+ export const dataSubjectCopies: readonly (typeof PersonalDataErasure)[] = [
11
+ // ddd-ts-kit:copies
12
+ // /ddd-ts-kit:copies
13
+ ];
@@ -0,0 +1,14 @@
1
+ import type { PersonalDataExport } from '@ddd-ts-kit/kernel';
2
+ import type { Platform } from '{{alias.platform}}/composition/platform{{alias.ext}}';
3
+ // ddd-ts-kit:imports
4
+ // /ddd-ts-kit:imports
5
+
6
+ /**
7
+ * The exports of what the contexts keep of a person, each the adapter of its context, instantiated
8
+ * from the platform as the module file of the context does. A context that
9
+ * exports what it keeps of a person adds the adapter here.
10
+ */
11
+ export const dataSubjectExports: readonly ((platform: Platform) => PersonalDataExport)[] = [
12
+ // ddd-ts-kit:exports
13
+ // /ddd-ts-kit:exports
14
+ ];
@@ -0,0 +1,13 @@
1
+ import type { PersonalDataExport } from '@ddd-ts-kit/kernel';
2
+ // ddd-ts-kit:imports
3
+ // /ddd-ts-kit:imports
4
+
5
+ /**
6
+ * The ports of the contexts that export what they keep of a person, one per context, each extending
7
+ * `PersonalDataExport` of the kernel: the export resolves them once the application is composed.
8
+ * A context that erases what it keeps of a person adds its port here.
9
+ */
10
+ export const dataSubjectExports: readonly (typeof PersonalDataExport)[] = [
11
+ // ddd-ts-kit:exports
12
+ // /ddd-ts-kit:exports
13
+ ];