ddd-ts-kit 0.110.1 → 0.112.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 (633) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/README.fr.md +39 -8
  3. package/README.md +36 -7
  4. package/dist/alias/index.d.ts +2 -0
  5. package/dist/alias/index.d.ts.map +1 -1
  6. package/dist/alias/index.js +2 -0
  7. package/dist/alias/index.js.map +1 -1
  8. package/dist/alias/neighbour-sources.d.ts +17 -0
  9. package/dist/alias/neighbour-sources.d.ts.map +1 -0
  10. package/dist/alias/neighbour-sources.js +11 -0
  11. package/dist/alias/neighbour-sources.js.map +1 -0
  12. package/dist/alias/neighbour-suffix.d.ts +8 -0
  13. package/dist/alias/neighbour-suffix.d.ts.map +1 -0
  14. package/dist/alias/neighbour-suffix.js +10 -0
  15. package/dist/alias/neighbour-suffix.js.map +1 -0
  16. package/dist/build/rewrite-aliases.d.ts.map +1 -1
  17. package/dist/build/rewrite-aliases.js +11 -0
  18. package/dist/build/rewrite-aliases.js.map +1 -1
  19. package/dist/check/alias/build-scripts.d.ts.map +1 -1
  20. package/dist/check/alias/build-scripts.js +4 -8
  21. package/dist/check/alias/build-scripts.js.map +1 -1
  22. package/dist/check/alias/compiler-options-of.d.ts +3 -3
  23. package/dist/check/alias/compiler-options-of.js +17 -6
  24. package/dist/check/alias/compiler-options-of.js.map +1 -1
  25. package/dist/check/alias/neighbour-sources.d.ts +12 -0
  26. package/dist/check/alias/neighbour-sources.d.ts.map +1 -0
  27. package/dist/check/alias/neighbour-sources.js +80 -0
  28. package/dist/check/alias/neighbour-sources.js.map +1 -0
  29. package/dist/check/alias/script-steps.d.ts +11 -0
  30. package/dist/check/alias/script-steps.d.ts.map +1 -0
  31. package/dist/check/alias/script-steps.js +22 -0
  32. package/dist/check/alias/script-steps.js.map +1 -0
  33. package/dist/check/aspects/adapter-policies.d.ts +10 -0
  34. package/dist/check/aspects/adapter-policies.d.ts.map +1 -0
  35. package/dist/check/aspects/adapter-policies.js +104 -0
  36. package/dist/check/aspects/adapter-policies.js.map +1 -0
  37. package/dist/check/aspects/adapter-policy.d.ts +18 -0
  38. package/dist/check/aspects/adapter-policy.d.ts.map +1 -0
  39. package/dist/check/aspects/adapter-policy.js +2 -0
  40. package/dist/check/aspects/adapter-policy.js.map +1 -0
  41. package/dist/check/aspects/is-under-condition.d.ts +7 -0
  42. package/dist/check/aspects/is-under-condition.d.ts.map +1 -0
  43. package/dist/check/aspects/is-under-condition.js +50 -0
  44. package/dist/check/aspects/is-under-condition.js.map +1 -0
  45. package/dist/check/aspects/stated-policy.d.ts +18 -0
  46. package/dist/check/aspects/stated-policy.d.ts.map +1 -0
  47. package/dist/check/aspects/stated-policy.js +39 -0
  48. package/dist/check/aspects/stated-policy.js.map +1 -0
  49. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  50. package/dist/check/catalogue/architecture-rules.js +4 -0
  51. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  52. package/dist/check/explain/imports-docs.d.ts.map +1 -1
  53. package/dist/check/explain/imports-docs.js +5 -3
  54. package/dist/check/explain/imports-docs.js.map +1 -1
  55. package/dist/check/explain/persistence-docs.d.ts.map +1 -1
  56. package/dist/check/explain/persistence-docs.js +21 -0
  57. package/dist/check/explain/persistence-docs.js.map +1 -1
  58. package/dist/check/explain/standard-docs.d.ts.map +1 -1
  59. package/dist/check/explain/standard-docs.js +16 -0
  60. package/dist/check/explain/standard-docs.js.map +1 -1
  61. package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
  62. package/dist/check/explain/tenancy-docs.js +3 -1
  63. package/dist/check/explain/tenancy-docs.js.map +1 -1
  64. package/dist/check/files/kit-content-types.d.ts +12 -0
  65. package/dist/check/files/kit-content-types.d.ts.map +1 -0
  66. package/dist/check/files/kit-content-types.js +38 -0
  67. package/dist/check/files/kit-content-types.js.map +1 -0
  68. package/dist/check/files/upload-content-defect.d.ts +7 -0
  69. package/dist/check/files/upload-content-defect.d.ts.map +1 -0
  70. package/dist/check/files/upload-content-defect.js +2 -0
  71. package/dist/check/files/upload-content-defect.js.map +1 -0
  72. package/dist/check/files/upload-content-defects.d.ts +9 -0
  73. package/dist/check/files/upload-content-defects.d.ts.map +1 -0
  74. package/dist/check/files/upload-content-defects.js +54 -0
  75. package/dist/check/files/upload-content-defects.js.map +1 -0
  76. package/dist/check/files/upload-declaration.d.ts +7 -0
  77. package/dist/check/files/upload-declaration.d.ts.map +1 -0
  78. package/dist/check/files/upload-declaration.js +2 -0
  79. package/dist/check/files/upload-declaration.js.map +1 -0
  80. package/dist/check/files/upload-declarations.d.ts +9 -0
  81. package/dist/check/files/upload-declarations.d.ts.map +1 -0
  82. package/dist/check/files/upload-declarations.js +41 -0
  83. package/dist/check/files/upload-declarations.js.map +1 -0
  84. package/dist/check/fixtures/alias-declared-fixtures.d.ts.map +1 -1
  85. package/dist/check/fixtures/alias-declared-fixtures.js +95 -1
  86. package/dist/check/fixtures/alias-declared-fixtures.js.map +1 -1
  87. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  88. package/dist/check/fixtures/fixtures.js +2 -0
  89. package/dist/check/fixtures/fixtures.js.map +1 -1
  90. package/dist/check/fixtures/imports-fixtures.d.ts.map +1 -1
  91. package/dist/check/fixtures/imports-fixtures.js +97 -0
  92. package/dist/check/fixtures/imports-fixtures.js.map +1 -1
  93. package/dist/check/fixtures/standard-fixtures.d.ts.map +1 -1
  94. package/dist/check/fixtures/standard-fixtures.js +42 -0
  95. package/dist/check/fixtures/standard-fixtures.js.map +1 -1
  96. package/dist/check/fixtures/tenancy-advisory-lock-fixtures.d.ts +9 -0
  97. package/dist/check/fixtures/tenancy-advisory-lock-fixtures.d.ts.map +1 -0
  98. package/dist/check/fixtures/tenancy-advisory-lock-fixtures.js +45 -0
  99. package/dist/check/fixtures/tenancy-advisory-lock-fixtures.js.map +1 -0
  100. package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
  101. package/dist/check/fixtures/tenancy-fixtures.js +2 -0
  102. package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
  103. package/dist/check/fixtures/upload-fixtures.d.ts +3 -0
  104. package/dist/check/fixtures/upload-fixtures.d.ts.map +1 -0
  105. package/dist/check/fixtures/upload-fixtures.js +94 -0
  106. package/dist/check/fixtures/upload-fixtures.js.map +1 -0
  107. package/dist/check/migrations/is-working-migration.d.ts +6 -0
  108. package/dist/check/migrations/is-working-migration.d.ts.map +1 -0
  109. package/dist/check/migrations/is-working-migration.js +8 -0
  110. package/dist/check/migrations/is-working-migration.js.map +1 -0
  111. package/dist/check/migrations/journal-entries.d.ts +4 -0
  112. package/dist/check/migrations/journal-entries.d.ts.map +1 -0
  113. package/dist/check/migrations/journal-entries.js +21 -0
  114. package/dist/check/migrations/journal-entries.js.map +1 -0
  115. package/dist/check/migrations/read-drizzle-migrations.d.ts.map +1 -1
  116. package/dist/check/migrations/read-drizzle-migrations.js +4 -9
  117. package/dist/check/migrations/read-drizzle-migrations.js.map +1 -1
  118. package/dist/check/modules/imported-modules.d.ts +4 -0
  119. package/dist/check/modules/imported-modules.d.ts.map +1 -0
  120. package/dist/check/modules/imported-modules.js +5 -0
  121. package/dist/check/modules/imported-modules.js.map +1 -0
  122. package/dist/check/modules/module-imports.d.ts +17 -0
  123. package/dist/check/modules/module-imports.d.ts.map +1 -0
  124. package/dist/check/modules/module-imports.js +23 -0
  125. package/dist/check/modules/module-imports.js.map +1 -0
  126. package/dist/check/project/assemble-project.d.ts.map +1 -1
  127. package/dist/check/project/assemble-project.js +1 -8
  128. package/dist/check/project/assemble-project.js.map +1 -1
  129. package/dist/check/project/file-severity.d.ts +4 -0
  130. package/dist/check/project/file-severity.d.ts.map +1 -0
  131. package/dist/check/project/file-severity.js +11 -0
  132. package/dist/check/project/file-severity.js.map +1 -0
  133. package/dist/check/project/load-project.js +1 -10
  134. package/dist/check/project/load-project.js.map +1 -1
  135. package/dist/check/project/not-in-the-tree.d.ts +10 -0
  136. package/dist/check/project/not-in-the-tree.d.ts.map +1 -0
  137. package/dist/check/project/not-in-the-tree.js +17 -0
  138. package/dist/check/project/not-in-the-tree.js.map +1 -0
  139. package/dist/check/project/skipped-directories.d.ts +3 -0
  140. package/dist/check/project/skipped-directories.d.ts.map +1 -0
  141. package/dist/check/project/skipped-directories.js +3 -0
  142. package/dist/check/project/skipped-directories.js.map +1 -0
  143. package/dist/check/project/walk-directory.d.ts.map +1 -1
  144. package/dist/check/project/walk-directory.js +1 -1
  145. package/dist/check/project/walk-directory.js.map +1 -1
  146. package/dist/check/rules/aspects-timeout-covers-delegate.d.ts +3 -0
  147. package/dist/check/rules/aspects-timeout-covers-delegate.d.ts.map +1 -0
  148. package/dist/check/rules/aspects-timeout-covers-delegate.js +179 -0
  149. package/dist/check/rules/aspects-timeout-covers-delegate.js.map +1 -0
  150. package/dist/check/rules/files-upload-content-rule.d.ts +3 -0
  151. package/dist/check/rules/files-upload-content-rule.d.ts.map +1 -0
  152. package/dist/check/rules/files-upload-content-rule.js +25 -0
  153. package/dist/check/rules/files-upload-content-rule.js.map +1 -0
  154. package/dist/check/rules/imports-alias-declared.d.ts.map +1 -1
  155. package/dist/check/rules/imports-alias-declared.js +3 -1
  156. package/dist/check/rules/imports-alias-declared.js.map +1 -1
  157. package/dist/check/rules/imports-alias-only.d.ts.map +1 -1
  158. package/dist/check/rules/imports-alias-only.js +86 -7
  159. package/dist/check/rules/imports-alias-only.js.map +1 -1
  160. package/dist/check/rules/module-no-cycle.d.ts.map +1 -1
  161. package/dist/check/rules/module-no-cycle.js +12 -34
  162. package/dist/check/rules/module-no-cycle.js.map +1 -1
  163. package/dist/check/rules/privacy-declared-field.js +1 -1
  164. package/dist/check/rules/privacy-declared-field.js.map +1 -1
  165. package/dist/check/rules/tenancy-scoped-statement.d.ts.map +1 -1
  166. package/dist/check/rules/tenancy-scoped-statement.js +11 -3
  167. package/dist/check/rules/tenancy-scoped-statement.js.map +1 -1
  168. package/dist/cli-error.d.ts +7 -2
  169. package/dist/cli-error.d.ts.map +1 -1
  170. package/dist/cli-error.js +8 -2
  171. package/dist/cli-error.js.map +1 -1
  172. package/dist/commands/generate.js +3 -0
  173. package/dist/commands/generate.js.map +1 -1
  174. package/dist/commands/knex-generate.d.ts.map +1 -1
  175. package/dist/commands/knex-generate.js +2 -1
  176. package/dist/commands/knex-generate.js.map +1 -1
  177. package/dist/commands/move-to-module.d.ts +6 -1
  178. package/dist/commands/move-to-module.d.ts.map +1 -1
  179. package/dist/commands/move-to-module.js +28 -3
  180. package/dist/commands/move-to-module.js.map +1 -1
  181. package/dist/commands/prisma-generate.d.ts.map +1 -1
  182. package/dist/commands/prisma-generate.js +2 -1
  183. package/dist/commands/prisma-generate.js.map +1 -1
  184. package/dist/commands/typeorm-generate.d.ts.map +1 -1
  185. package/dist/commands/typeorm-generate.js +2 -1
  186. package/dist/commands/typeorm-generate.js.map +1 -1
  187. package/dist/commands/verify-merge.d.ts +4 -2
  188. package/dist/commands/verify-merge.d.ts.map +1 -1
  189. package/dist/commands/verify-merge.js +8 -5
  190. package/dist/commands/verify-merge.js.map +1 -1
  191. package/dist/context-layout/context-layout.d.ts.map +1 -1
  192. package/dist/context-layout/context-layout.js +6 -0
  193. package/dist/context-layout/context-layout.js.map +1 -1
  194. package/dist/context-layout/module-moves.d.ts +8 -0
  195. package/dist/context-layout/module-moves.d.ts.map +1 -1
  196. package/dist/context-layout/module-moves.js +14 -3
  197. package/dist/context-layout/module-moves.js.map +1 -1
  198. package/dist/context-layout/runner-configs-by-hand.d.ts.map +1 -1
  199. package/dist/context-layout/runner-configs-by-hand.js +12 -0
  200. package/dist/context-layout/runner-configs-by-hand.js.map +1 -1
  201. package/dist/context-layout/settle.d.ts +9 -0
  202. package/dist/context-layout/settle.d.ts.map +1 -1
  203. package/dist/context-layout/settle.js +25 -3
  204. package/dist/context-layout/settle.js.map +1 -1
  205. package/dist/describe/read-adapters.d.ts.map +1 -1
  206. package/dist/describe/read-adapters.js +5 -1
  207. package/dist/describe/read-adapters.js.map +1 -1
  208. package/dist/describe/read-ports.js +8 -1
  209. package/dist/describe/read-ports.js.map +1 -1
  210. package/dist/generate/generate-options.d.ts +10 -0
  211. package/dist/generate/generate-options.d.ts.map +1 -1
  212. package/dist/generate/generate-options.js +3 -0
  213. package/dist/generate/generate-options.js.map +1 -1
  214. package/dist/generate/kind.d.ts +6 -0
  215. package/dist/generate/kind.d.ts.map +1 -1
  216. package/dist/generate/kinds/adapter-kind.d.ts.map +1 -1
  217. package/dist/generate/kinds/adapter-kind.js +12 -0
  218. package/dist/generate/kinds/adapter-kind.js.map +1 -1
  219. package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
  220. package/dist/generate/kinds/declare-storage.js +3 -57
  221. package/dist/generate/kinds/declare-storage.js.map +1 -1
  222. package/dist/generate/kinds/declare-table.d.ts +14 -0
  223. package/dist/generate/kinds/declare-table.d.ts.map +1 -0
  224. package/dist/generate/kinds/declare-table.js +72 -0
  225. package/dist/generate/kinds/declare-table.js.map +1 -0
  226. package/dist/generate/kinds/e2e/job-slug.d.ts +3 -0
  227. package/dist/generate/kinds/e2e/job-slug.d.ts.map +1 -0
  228. package/dist/generate/kinds/e2e/job-slug.js +8 -0
  229. package/dist/generate/kinds/e2e/job-slug.js.map +1 -0
  230. package/dist/generate/kinds/e2e/job-spec.d.ts +16 -0
  231. package/dist/generate/kinds/e2e/job-spec.d.ts.map +1 -0
  232. package/dist/generate/kinds/e2e/job-spec.js +54 -0
  233. package/dist/generate/kinds/e2e/job-spec.js.map +1 -0
  234. package/dist/generate/kinds/e2e/jobs-sending.d.ts +17 -5
  235. package/dist/generate/kinds/e2e/jobs-sending.d.ts.map +1 -1
  236. package/dist/generate/kinds/e2e/jobs-sending.js +15 -6
  237. package/dist/generate/kinds/e2e/jobs-sending.js.map +1 -1
  238. package/dist/generate/kinds/e2e/reaction-of.d.ts +5 -5
  239. package/dist/generate/kinds/e2e/reaction-of.d.ts.map +1 -1
  240. package/dist/generate/kinds/e2e/reaction-of.js +15 -8
  241. package/dist/generate/kinds/e2e/reaction-of.js.map +1 -1
  242. package/dist/generate/kinds/e2e/starting-jobs.d.ts +10 -0
  243. package/dist/generate/kinds/e2e/starting-jobs.d.ts.map +1 -0
  244. package/dist/generate/kinds/e2e/starting-jobs.js +33 -0
  245. package/dist/generate/kinds/e2e/starting-jobs.js.map +1 -0
  246. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  247. package/dist/generate/kinds/e2e-kind.js +47 -35
  248. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  249. package/dist/generate/kinds/file-upload/upload-file-vars.d.ts +9 -0
  250. package/dist/generate/kinds/file-upload/upload-file-vars.d.ts.map +1 -0
  251. package/dist/generate/kinds/file-upload/upload-file-vars.js +39 -0
  252. package/dist/generate/kinds/file-upload/upload-file-vars.js.map +1 -0
  253. package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts.map +1 -1
  254. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js +2 -1
  255. package/dist/generate/kinds/file-upload/write-nest-upload-controller.js.map +1 -1
  256. package/dist/generate/kinds/file-upload/write-upload-controller.d.ts.map +1 -1
  257. package/dist/generate/kinds/file-upload/write-upload-controller.js +2 -1
  258. package/dist/generate/kinds/file-upload/write-upload-controller.js.map +1 -1
  259. package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -1
  260. package/dist/generate/kinds/file-upload-kind.js +5 -3
  261. package/dist/generate/kinds/file-upload-kind.js.map +1 -1
  262. package/dist/generate/kinds/generate-repository.d.ts +8 -0
  263. package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
  264. package/dist/generate/kinds/generate-repository.js +2 -13
  265. package/dist/generate/kinds/generate-repository.js.map +1 -1
  266. package/dist/generate/kinds/note-the-migration.d.ts +4 -0
  267. package/dist/generate/kinds/note-the-migration.d.ts.map +1 -0
  268. package/dist/generate/kinds/note-the-migration.js +13 -0
  269. package/dist/generate/kinds/note-the-migration.js.map +1 -0
  270. package/dist/generate/kinds/personal-data/columns-of-table.d.ts +18 -0
  271. package/dist/generate/kinds/personal-data/columns-of-table.d.ts.map +1 -0
  272. package/dist/generate/kinds/personal-data/columns-of-table.js +31 -0
  273. package/dist/generate/kinds/personal-data/columns-of-table.js.map +1 -0
  274. package/dist/generate/kinds/personal-data/declare-personal-data.d.ts.map +1 -1
  275. package/dist/generate/kinds/personal-data/declare-personal-data.js +7 -52
  276. package/dist/generate/kinds/personal-data/declare-personal-data.js.map +1 -1
  277. package/dist/generate/kinds/personal-data/declare-table-personal-fields.d.ts +11 -0
  278. package/dist/generate/kinds/personal-data/declare-table-personal-fields.d.ts.map +1 -0
  279. package/dist/generate/kinds/personal-data/declare-table-personal-fields.js +71 -0
  280. package/dist/generate/kinds/personal-data/declare-table-personal-fields.js.map +1 -0
  281. package/dist/generate/kinds/personal-data/personal-request-of-table.d.ts +11 -0
  282. package/dist/generate/kinds/personal-data/personal-request-of-table.d.ts.map +1 -0
  283. package/dist/generate/kinds/personal-data/personal-request-of-table.js +20 -0
  284. package/dist/generate/kinds/personal-data/personal-request-of-table.js.map +1 -0
  285. package/dist/generate/kinds/personal-data/personal-vars.d.ts +7 -0
  286. package/dist/generate/kinds/personal-data/personal-vars.d.ts.map +1 -1
  287. package/dist/generate/kinds/personal-data/personal-vars.js +14 -11
  288. package/dist/generate/kinds/personal-data/personal-vars.js.map +1 -1
  289. package/dist/generate/kinds/personal-data/schema-table.d.ts +13 -0
  290. package/dist/generate/kinds/personal-data/schema-table.d.ts.map +1 -0
  291. package/dist/generate/kinds/personal-data/schema-table.js +2 -0
  292. package/dist/generate/kinds/personal-data/schema-table.js.map +1 -0
  293. package/dist/generate/kinds/personal-data/schema-tables-of.d.ts +9 -0
  294. package/dist/generate/kinds/personal-data/schema-tables-of.d.ts.map +1 -0
  295. package/dist/generate/kinds/personal-data/schema-tables-of.js +78 -0
  296. package/dist/generate/kinds/personal-data/schema-tables-of.js.map +1 -0
  297. package/dist/generate/kinds/personal-data/table-of-schema.d.ts +15 -0
  298. package/dist/generate/kinds/personal-data/table-of-schema.d.ts.map +1 -0
  299. package/dist/generate/kinds/personal-data/table-of-schema.js +39 -0
  300. package/dist/generate/kinds/personal-data/table-of-schema.js.map +1 -0
  301. package/dist/generate/kinds/personal-data/write-personal-declaration.d.ts +20 -0
  302. package/dist/generate/kinds/personal-data/write-personal-declaration.d.ts.map +1 -0
  303. package/dist/generate/kinds/personal-data/write-personal-declaration.js +63 -0
  304. package/dist/generate/kinds/personal-data/write-personal-declaration.js.map +1 -0
  305. package/dist/generate/kinds/personal-fields-kind.d.ts +3 -0
  306. package/dist/generate/kinds/personal-fields-kind.d.ts.map +1 -0
  307. package/dist/generate/kinds/personal-fields-kind.js +15 -0
  308. package/dist/generate/kinds/personal-fields-kind.js.map +1 -0
  309. package/dist/generate/kinds/projection-kind.d.ts.map +1 -1
  310. package/dist/generate/kinds/projection-kind.js +2 -1
  311. package/dist/generate/kinds/projection-kind.js.map +1 -1
  312. package/dist/generate/kinds/read-model/field-lines.d.ts +11 -0
  313. package/dist/generate/kinds/read-model/field-lines.d.ts.map +1 -0
  314. package/dist/generate/kinds/read-model/field-lines.js +85 -0
  315. package/dist/generate/kinds/read-model/field-lines.js.map +1 -0
  316. package/dist/generate/kinds/read-model/list-read-model.d.ts +17 -0
  317. package/dist/generate/kinds/read-model/list-read-model.d.ts.map +1 -0
  318. package/dist/generate/kinds/read-model/list-read-model.js +22 -0
  319. package/dist/generate/kinds/read-model/list-read-model.js.map +1 -0
  320. package/dist/generate/kinds/read-model/live-rows-check.d.ts +22 -0
  321. package/dist/generate/kinds/read-model/live-rows-check.d.ts.map +1 -0
  322. package/dist/generate/kinds/read-model/live-rows-check.js +47 -0
  323. package/dist/generate/kinds/read-model/live-rows-check.js.map +1 -0
  324. package/dist/generate/kinds/read-model/read-model-fields.d.ts +19 -0
  325. package/dist/generate/kinds/read-model/read-model-fields.d.ts.map +1 -0
  326. package/dist/generate/kinds/read-model/read-model-fields.js +31 -0
  327. package/dist/generate/kinds/read-model/read-model-fields.js.map +1 -0
  328. package/dist/generate/kinds/read-model/read-model-store.d.ts +24 -0
  329. package/dist/generate/kinds/read-model/read-model-store.d.ts.map +1 -0
  330. package/dist/generate/kinds/read-model/read-model-store.js +39 -0
  331. package/dist/generate/kinds/read-model/read-model-store.js.map +1 -0
  332. package/dist/generate/kinds/read-model/read-model-table.d.ts +11 -0
  333. package/dist/generate/kinds/read-model/read-model-table.d.ts.map +1 -0
  334. package/dist/generate/kinds/read-model/read-model-table.js +2 -0
  335. package/dist/generate/kinds/read-model/read-model-table.js.map +1 -0
  336. package/dist/generate/kinds/read-model-kind.d.ts +3 -0
  337. package/dist/generate/kinds/read-model-kind.d.ts.map +1 -0
  338. package/dist/generate/kinds/read-model-kind.js +103 -0
  339. package/dist/generate/kinds/read-model-kind.js.map +1 -0
  340. package/dist/generate/kinds/service-kind.d.ts.map +1 -1
  341. package/dist/generate/kinds/service-kind.js +8 -0
  342. package/dist/generate/kinds/service-kind.js.map +1 -1
  343. package/dist/generate/kinds/wire-context.d.ts.map +1 -1
  344. package/dist/generate/kinds/wire-context.js +4 -0
  345. package/dist/generate/kinds/wire-context.js.map +1 -1
  346. package/dist/generate/kinds.d.ts.map +1 -1
  347. package/dist/generate/kinds.js +4 -0
  348. package/dist/generate/kinds.js.map +1 -1
  349. package/dist/generate/shared-writes.d.ts.map +1 -1
  350. package/dist/generate/shared-writes.js +9 -0
  351. package/dist/generate/shared-writes.js.map +1 -1
  352. package/dist/help/tool-notes.d.ts.map +1 -1
  353. package/dist/help/tool-notes.js +7 -2
  354. package/dist/help/tool-notes.js.map +1 -1
  355. package/dist/help/usage.js +1 -1
  356. package/dist/help/work-notes.d.ts.map +1 -1
  357. package/dist/help/work-notes.js +9 -2
  358. package/dist/help/work-notes.js.map +1 -1
  359. package/dist/init/files/end-to-end-files.d.ts.map +1 -1
  360. package/dist/init/files/end-to-end-files.js +3 -0
  361. package/dist/init/files/end-to-end-files.js.map +1 -1
  362. package/dist/init/files/persistence-files.d.ts.map +1 -1
  363. package/dist/init/files/persistence-files.js +8 -0
  364. package/dist/init/files/persistence-files.js.map +1 -1
  365. package/dist/init/files/script-files.d.ts +2 -1
  366. package/dist/init/files/script-files.d.ts.map +1 -1
  367. package/dist/init/files/script-files.js +6 -1
  368. package/dist/init/files/script-files.js.map +1 -1
  369. package/dist/init/is-team-file.d.ts +2 -2
  370. package/dist/init/is-team-file.d.ts.map +1 -1
  371. package/dist/init/is-team-file.js +5 -4
  372. package/dist/init/is-team-file.js.map +1 -1
  373. package/dist/init/list-read-models.d.ts +17 -0
  374. package/dist/init/list-read-models.d.ts.map +1 -0
  375. package/dist/init/list-read-models.js +74 -0
  376. package/dist/init/list-read-models.js.map +1 -0
  377. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  378. package/dist/init/manifest/database-scripts.js +8 -0
  379. package/dist/init/manifest/database-scripts.js.map +1 -1
  380. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  381. package/dist/init/manifest/dependencies-for.js +10 -7
  382. package/dist/init/manifest/dependencies-for.js.map +1 -1
  383. package/dist/init/manifest/versions.js +25 -25
  384. package/dist/init/rewire-contexts.d.ts +4 -2
  385. package/dist/init/rewire-contexts.d.ts.map +1 -1
  386. package/dist/init/rewire-contexts.js +10 -2
  387. package/dist/init/rewire-contexts.js.map +1 -1
  388. package/dist/init/run-init.js +1 -1
  389. package/dist/init/run-init.js.map +1 -1
  390. package/dist/init/wiring-notes.js +1 -1
  391. package/dist/init/wiring-notes.js.map +1 -1
  392. package/dist/init/write-type-script-configs.d.ts +3 -1
  393. package/dist/init/write-type-script-configs.d.ts.map +1 -1
  394. package/dist/init/write-type-script-configs.js +14 -2
  395. package/dist/init/write-type-script-configs.js.map +1 -1
  396. package/dist/layout/fit-block.js +4 -0
  397. package/dist/layout/fit-block.js.map +1 -1
  398. package/dist/merge/format-merge-report.js +5 -2
  399. package/dist/merge/format-merge-report.js.map +1 -1
  400. package/dist/merge/land-drizzle.d.ts +4 -0
  401. package/dist/merge/land-drizzle.d.ts.map +1 -1
  402. package/dist/merge/land-drizzle.js +6 -1
  403. package/dist/merge/land-drizzle.js.map +1 -1
  404. package/dist/merge/land-up-to-date.d.ts +15 -0
  405. package/dist/merge/land-up-to-date.d.ts.map +1 -0
  406. package/dist/merge/land-up-to-date.js +76 -0
  407. package/dist/merge/land-up-to-date.js.map +1 -0
  408. package/dist/merge/lost/format-merge-verification.d.ts +2 -1
  409. package/dist/merge/lost/format-merge-verification.d.ts.map +1 -1
  410. package/dist/merge/lost/format-merge-verification.js +13 -2
  411. package/dist/merge/lost/format-merge-verification.js.map +1 -1
  412. package/dist/merge/lost/merge-verification.d.ts +4 -0
  413. package/dist/merge/lost/merge-verification.d.ts.map +1 -1
  414. package/dist/merge/lost/verify-merges.d.ts +2 -1
  415. package/dist/merge/lost/verify-merges.d.ts.map +1 -1
  416. package/dist/merge/lost/verify-merges.js +10 -4
  417. package/dist/merge/lost/verify-merges.js.map +1 -1
  418. package/dist/merge/merge-trunk.d.ts +2 -1
  419. package/dist/merge/merge-trunk.d.ts.map +1 -1
  420. package/dist/merge/merge-trunk.js +5 -2
  421. package/dist/merge/merge-trunk.js.map +1 -1
  422. package/dist/merge/next-steps.d.ts +3 -0
  423. package/dist/merge/next-steps.d.ts.map +1 -1
  424. package/dist/merge/next-steps.js +3 -0
  425. package/dist/merge/next-steps.js.map +1 -1
  426. package/dist/merge/order/applied-under-old-name.d.ts +13 -0
  427. package/dist/merge/order/applied-under-old-name.d.ts.map +1 -0
  428. package/dist/merge/order/applied-under-old-name.js +14 -0
  429. package/dist/merge/order/applied-under-old-name.js.map +1 -0
  430. package/dist/merge/order/comes-after.d.ts +8 -0
  431. package/dist/merge/order/comes-after.d.ts.map +1 -0
  432. package/dist/merge/order/comes-after.js +9 -0
  433. package/dist/merge/order/comes-after.js.map +1 -0
  434. package/dist/merge/order/drizzle-order.d.ts +11 -0
  435. package/dist/merge/order/drizzle-order.d.ts.map +1 -0
  436. package/dist/merge/order/drizzle-order.js +64 -0
  437. package/dist/merge/order/drizzle-order.js.map +1 -0
  438. package/dist/merge/order/in-order.d.ts +4 -0
  439. package/dist/merge/order/in-order.d.ts.map +1 -0
  440. package/dist/merge/order/in-order.js +6 -0
  441. package/dist/merge/order/in-order.js.map +1 -0
  442. package/dist/merge/order/migration-order-finding.d.ts +18 -0
  443. package/dist/merge/order/migration-order-finding.d.ts.map +1 -0
  444. package/dist/merge/order/migration-order-finding.js +2 -0
  445. package/dist/merge/order/migration-order-finding.js.map +1 -0
  446. package/dist/merge/order/migration-order.d.ts +12 -0
  447. package/dist/merge/order/migration-order.d.ts.map +1 -0
  448. package/dist/merge/order/migration-order.js +21 -0
  449. package/dist/merge/order/migration-order.js.map +1 -0
  450. package/dist/merge/order/migrations-of-commit.d.ts +7 -0
  451. package/dist/merge/order/migrations-of-commit.d.ts.map +1 -0
  452. package/dist/merge/order/migrations-of-commit.js +43 -0
  453. package/dist/merge/order/migrations-of-commit.js.map +1 -0
  454. package/dist/merge/order/migrations-of-tree.d.ts +9 -0
  455. package/dist/merge/order/migrations-of-tree.d.ts.map +1 -0
  456. package/dist/merge/order/migrations-of-tree.js +25 -0
  457. package/dist/merge/order/migrations-of-tree.js.map +1 -0
  458. package/dist/merge/order/named-order.d.ts +11 -0
  459. package/dist/merge/order/named-order.d.ts.map +1 -0
  460. package/dist/merge/order/named-order.js +36 -0
  461. package/dist/merge/order/named-order.js.map +1 -0
  462. package/dist/merge/order/ordered-migration.d.ts +12 -0
  463. package/dist/merge/order/ordered-migration.d.ts.map +1 -0
  464. package/dist/merge/order/ordered-migration.js +2 -0
  465. package/dist/merge/order/ordered-migration.js.map +1 -0
  466. package/dist/merge/order/trunk-to-follow.d.ts +9 -0
  467. package/dist/merge/order/trunk-to-follow.d.ts.map +1 -0
  468. package/dist/merge/order/trunk-to-follow.js +2 -0
  469. package/dist/merge/order/trunk-to-follow.js.map +1 -0
  470. package/dist/merge/renumber-migrations.d.ts +14 -5
  471. package/dist/merge/renumber-migrations.d.ts.map +1 -1
  472. package/dist/merge/renumber-migrations.js +141 -60
  473. package/dist/merge/renumber-migrations.js.map +1 -1
  474. package/dist/merge/restamp-class.d.ts +9 -0
  475. package/dist/merge/restamp-class.d.ts.map +1 -0
  476. package/dist/merge/restamp-class.js +30 -0
  477. package/dist/merge/restamp-class.js.map +1 -0
  478. package/dist/migration/index.d.ts +1 -0
  479. package/dist/migration/index.d.ts.map +1 -1
  480. package/dist/migration/index.js +1 -0
  481. package/dist/migration/index.js.map +1 -1
  482. package/dist/migration/plan-replay.d.ts.map +1 -1
  483. package/dist/migration/plan-replay.js +2 -1
  484. package/dist/migration/plan-replay.js.map +1 -1
  485. package/dist/migration/refuse-taken-migration-name.d.ts +8 -0
  486. package/dist/migration/refuse-taken-migration-name.d.ts.map +1 -0
  487. package/dist/migration/refuse-taken-migration-name.js +22 -0
  488. package/dist/migration/refuse-taken-migration-name.js.map +1 -0
  489. package/dist/migration/replay-drizzle-migrations.d.ts +5 -0
  490. package/dist/migration/replay-drizzle-migrations.d.ts.map +1 -1
  491. package/dist/migration/replay-drizzle-migrations.js +10 -2
  492. package/dist/migration/replay-drizzle-migrations.js.map +1 -1
  493. package/dist/migration/replay-plan.d.ts +2 -2
  494. package/dist/migration/replay-plan.d.ts.map +1 -1
  495. package/dist/migration/restore-migration-folder.d.ts +6 -2
  496. package/dist/migration/restore-migration-folder.d.ts.map +1 -1
  497. package/dist/migration/restore-migration-folder.js +14 -7
  498. package/dist/migration/restore-migration-folder.js.map +1 -1
  499. package/dist/migration/snapshot-migration-folder.d.ts +7 -0
  500. package/dist/migration/snapshot-migration-folder.d.ts.map +1 -0
  501. package/dist/migration/snapshot-migration-folder.js +12 -0
  502. package/dist/migration/snapshot-migration-folder.js.map +1 -0
  503. package/dist/move-to-module/before-the-move.d.ts +5 -0
  504. package/dist/move-to-module/before-the-move.d.ts.map +1 -0
  505. package/dist/move-to-module/before-the-move.js +13 -0
  506. package/dist/move-to-module/before-the-move.js.map +1 -0
  507. package/dist/move-to-module/closed-cycles.d.ts +21 -0
  508. package/dist/move-to-module/closed-cycles.d.ts.map +1 -0
  509. package/dist/move-to-module/closed-cycles.js +66 -0
  510. package/dist/move-to-module/closed-cycles.js.map +1 -0
  511. package/dist/move-to-module/cycle-lines.d.ts +7 -0
  512. package/dist/move-to-module/cycle-lines.d.ts.map +1 -0
  513. package/dist/move-to-module/cycle-lines.js +22 -0
  514. package/dist/move-to-module/cycle-lines.js.map +1 -0
  515. package/dist/move-to-module/cycle-refusal.d.ts +17 -0
  516. package/dist/move-to-module/cycle-refusal.d.ts.map +1 -0
  517. package/dist/move-to-module/cycle-refusal.js +25 -0
  518. package/dist/move-to-module/cycle-refusal.js.map +1 -0
  519. package/dist/move-to-module/index.d.ts +5 -0
  520. package/dist/move-to-module/index.d.ts.map +1 -1
  521. package/dist/move-to-module/index.js +4 -0
  522. package/dist/move-to-module/index.js.map +1 -1
  523. package/dist/move-to-module/module-imports-in.d.ts +11 -0
  524. package/dist/move-to-module/module-imports-in.d.ts.map +1 -0
  525. package/dist/move-to-module/module-imports-in.js +32 -0
  526. package/dist/move-to-module/module-imports-in.js.map +1 -0
  527. package/dist/move-to-module/moves-into-module.d.ts.map +1 -1
  528. package/dist/move-to-module/moves-into-module.js +6 -18
  529. package/dist/move-to-module/moves-into-module.js.map +1 -1
  530. package/dist/move-to-module/place-in-module.d.ts +13 -0
  531. package/dist/move-to-module/place-in-module.d.ts.map +1 -0
  532. package/dist/move-to-module/place-in-module.js +24 -0
  533. package/dist/move-to-module/place-in-module.js.map +1 -0
  534. package/dist/move-to-module/watch-cycles.d.ts +19 -0
  535. package/dist/move-to-module/watch-cycles.d.ts.map +1 -0
  536. package/dist/move-to-module/watch-cycles.js +51 -0
  537. package/dist/move-to-module/watch-cycles.js.map +1 -0
  538. package/dist/presets/no-flags.d.ts.map +1 -1
  539. package/dist/presets/no-flags.js +1 -0
  540. package/dist/presets/no-flags.js.map +1 -1
  541. package/dist/run.js +1 -1
  542. package/dist/run.js.map +1 -1
  543. package/dist/slice/format-slice-verification.d.ts.map +1 -1
  544. package/dist/slice/format-slice-verification.js +11 -5
  545. package/dist/slice/format-slice-verification.js.map +1 -1
  546. package/dist/stack/alias-vars.d.ts +3 -1
  547. package/dist/stack/alias-vars.d.ts.map +1 -1
  548. package/dist/stack/alias-vars.js +5 -2
  549. package/dist/stack/alias-vars.js.map +1 -1
  550. package/dist/stack/end-to-end-vars.d.ts +9 -0
  551. package/dist/stack/end-to-end-vars.d.ts.map +1 -0
  552. package/dist/stack/end-to-end-vars.js +32 -0
  553. package/dist/stack/end-to-end-vars.js.map +1 -0
  554. package/dist/stack/stack-vars.d.ts.map +1 -1
  555. package/dist/stack/stack-vars.js +2 -0
  556. package/dist/stack/stack-vars.js.map +1 -1
  557. package/dist/version.d.ts +1 -1
  558. package/dist/version.js +1 -1
  559. package/dist/worker/briefing-of.js +2 -2
  560. package/dist/worker/briefing-of.js.map +1 -1
  561. package/package.json +6 -6
  562. package/templates/e2e/e2e-background-job-case.ts.tpl +12 -0
  563. package/templates/e2e/e2e-job.spec.ts.tpl +3 -3
  564. package/templates/file-upload/controller.spec.ts.tpl +66 -2
  565. package/templates/file-upload/controller.ts.tpl +12 -0
  566. package/templates/file-upload/handler.spec.ts.tpl +3 -3
  567. package/templates/init/README.md.tpl +20 -1
  568. package/templates/init/e2e/jest.e2e.config.js.tpl +29 -5
  569. package/templates/init/e2e/start-application.database.ts.tpl +40 -2
  570. package/templates/init/e2e/start-application.memory.ts.tpl +36 -0
  571. package/templates/init/e2e/test-database-setup.ts.tpl +120 -0
  572. package/templates/init/e2e/vitest.e2e.config.ts.tpl +14 -4
  573. package/templates/init/platform/composition/compose-application.container.ts.tpl +5 -0
  574. package/templates/init/platform/composition/compose-application.manual.ts.tpl +20 -3
  575. package/templates/init/platform/composition/create-platform.manual.ts.tpl +6 -0
  576. package/templates/init/platform/composition/platform-options.manual.ts.tpl +11 -0
  577. package/templates/init/platform/composition/platform.manual.ts.tpl +7 -0
  578. package/templates/init/platform/composition/platform.module.container.ts.tpl +34 -0
  579. package/templates/init/platform/database/connect-to-database.drizzle.ts.tpl +7 -2
  580. package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +27 -4
  581. package/templates/init/platform/database/open-test-database.knex.ts.tpl +26 -3
  582. package/templates/init/platform/database/open-test-database.prisma.ts.tpl +27 -3
  583. package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +27 -3
  584. package/templates/init/platform/database/read-model-tables.ts.tpl +67 -0
  585. package/templates/init/platform/database/test-database-budget.ts.tpl +108 -0
  586. package/templates/init/platform/database/test-database-clone.ts.tpl +75 -0
  587. package/templates/init/platform/database/test-database-copy.ts.tpl +76 -0
  588. package/templates/init/platform/database/test-database-emptying.ts.tpl +209 -0
  589. package/templates/init/platform/database/test-database-kept.ts.tpl +32 -0
  590. package/templates/init/platform/database/test-database-leftovers.ts.tpl +52 -0
  591. package/templates/init/platform/database/test-database-run.ts.tpl +99 -0
  592. package/templates/init/platform/database/test-database-server.ts.tpl +140 -0
  593. package/templates/init/platform/database/test-database-session.ts.tpl +141 -0
  594. package/templates/init/platform/database/test-database-teardown.ts.tpl +11 -1
  595. package/templates/init/platform/jobs/background-jobs.ts.tpl +4 -0
  596. package/templates/init/platform/jobs/create-background-work.ts.tpl +1 -0
  597. package/templates/init/platform/resilience/default-policy.ts.tpl +8 -1
  598. package/templates/init/rules/infrastructure.md.tpl +3 -3
  599. package/templates/init/scripts/read-model-tables.ts.tpl +83 -0
  600. package/templates/nest-controller/upload.spec.ts.tpl +67 -2
  601. package/templates/nest-controller/upload.ts.tpl +12 -0
  602. package/templates/personal-data/declaration.drizzle.ts.tpl +6 -1
  603. package/templates/personal-data/declaration.knex.ts.tpl +14 -1
  604. package/templates/personal-data/declaration.prisma.ts.tpl +6 -1
  605. package/templates/personal-data/declaration.typeorm.ts.tpl +21 -1
  606. package/templates/personal-data/spec.table.ts.tpl +39 -0
  607. package/templates/pipeline/package-scripts.json +1 -1
  608. package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +5 -9
  609. package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +5 -9
  610. package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +5 -9
  611. package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +5 -9
  612. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +5 -9
  613. package/templates/projection/projection.manual.ts.tpl +2 -2
  614. package/templates/projection/projection.ts.tpl +2 -2
  615. package/templates/read-model/contract.spec.ts.tpl +95 -0
  616. package/templates/read-model/drizzle/schema.ts.tpl +8 -0
  617. package/templates/read-model/drizzle/store.ts.tpl +41 -0
  618. package/templates/read-model/drizzle/table.tpl +38 -0
  619. package/templates/read-model/fake.ts.tpl +8 -0
  620. package/templates/read-model/knex/store.ts.tpl +41 -0
  621. package/templates/read-model/knex/table.tpl +26 -0
  622. package/templates/read-model/none/store.ts.tpl +17 -0
  623. package/templates/read-model/port.ts.tpl +24 -0
  624. package/templates/read-model/prisma/model.tpl +25 -0
  625. package/templates/read-model/prisma/store.ts.tpl +43 -0
  626. package/templates/read-model/typeorm/schema-export.tpl +4 -0
  627. package/templates/read-model/typeorm/schema.ts.tpl +9 -0
  628. package/templates/read-model/typeorm/store.ts.tpl +30 -0
  629. package/templates/read-model/typeorm/table.tpl +54 -0
  630. package/templates/read-model/wiring.container.tpl +21 -0
  631. package/templates/repository/drizzle/repository.ts.tpl +6 -9
  632. package/templates/repository/drizzle/table.tpl +1 -0
  633. package/templates/repository/typeorm/table.tpl +1 -0
@@ -1,5 +1,5 @@
1
1
  import { and, eq, isNull, or } from 'drizzle-orm';
2
- import { optimisticUpdate, primaryKeyOf } from '@ddd-ts-kit/drizzle/postgres';
2
+ import { insertIgnoringConflict, optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
3
3
  import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
4
4
  {{#if style.declared}}
5
5
  import { Repository } from '@ddd-ts-kit/kernel/declarations';
@@ -50,20 +50,16 @@ export class DrizzleDelegationRepository implements DelegationRepository {
50
50
  async save(saved: Delegation): Promise<void> {
51
51
  await optimisticUpdate(saved, async ({ expected, next }) => {
52
52
  const state = { ...DelegationMapper.toRow(saved), version: next };
53
- const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
54
53
 
55
- return written.length;
54
+ return expected === 0 ? this.insert(state) : (await this.update(state, expected)).length;
56
55
  });
57
56
  }
58
57
 
59
- private insert(state: VersionedDelegation) {
58
+ private async insert(state: VersionedDelegation): Promise<number> {
60
59
  const row = { ...state, ...stampCreation(this.scope, this.clock) };
60
+ const insertion = () => executorOf(this.database).insert(delegations).values(row);
61
61
 
62
- return executorOf(this.database)
63
- .insert(delegations)
64
- .values(row)
65
- .onConflictDoNothing({ target: primaryKeyOf(delegations) })
66
- .returning({ id: delegations.id });
62
+ return (await insertIgnoringConflict(insertion, delegations)) ? 1 : 0;
67
63
  }
68
64
 
69
65
  private update(state: VersionedDelegation, expected: number) {
@@ -1,5 +1,5 @@
1
1
  import { and, eq } from 'drizzle-orm';
2
- import { optimisticUpdate, primaryKeyOf } from '@ddd-ts-kit/drizzle/postgres';
2
+ import { insertIgnoringConflict, optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
3
3
  import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
4
4
  {{#if style.declared}}
5
5
  import { Repository } from '@ddd-ts-kit/kernel/declarations';
@@ -42,20 +42,16 @@ export class DrizzleInvitationRepository implements InvitationRepository {
42
42
  async save(saved: Invitation): Promise<void> {
43
43
  await optimisticUpdate(saved, async ({ expected, next }) => {
44
44
  const state = { ...InvitationMapper.toRow(saved), version: next };
45
- const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
46
45
 
47
- return written.length;
46
+ return expected === 0 ? this.insert(state) : (await this.update(state, expected)).length;
48
47
  });
49
48
  }
50
49
 
51
- private insert(state: VersionedInvitation) {
50
+ private async insert(state: VersionedInvitation): Promise<number> {
52
51
  const row = { ...state, ...stampCreation(this.scope, this.clock) };
52
+ const insertion = () => executorOf(this.database).insert(invitations).values(row);
53
53
 
54
- return executorOf(this.database)
55
- .insert(invitations)
56
- .values(row)
57
- .onConflictDoNothing({ target: primaryKeyOf(invitations) })
58
- .returning({ id: invitations.id });
54
+ return (await insertIgnoringConflict(insertion, invitations)) ? 1 : 0;
59
55
  }
60
56
 
61
57
  private update(state: VersionedInvitation, expected: number) {
@@ -1,5 +1,5 @@
1
1
  import { and, count, eq, isNull } from 'drizzle-orm';
2
- import { optimisticUpdate, primaryKeyOf } from '@ddd-ts-kit/drizzle/postgres';
2
+ import { insertIgnoringConflict, optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
3
3
  import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
4
4
  {{#if style.declared}}
5
5
  import { Repository } from '@ddd-ts-kit/kernel/declarations';
@@ -57,20 +57,16 @@ export class DrizzleMemberRepository implements MemberRepository {
57
57
  async save(saved: Member): Promise<void> {
58
58
  await optimisticUpdate(saved, async ({ expected, next }) => {
59
59
  const state = { ...MemberMapper.toRow(saved), version: next };
60
- const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
61
60
 
62
- return written.length;
61
+ return expected === 0 ? this.insert(state) : (await this.update(state, expected)).length;
63
62
  });
64
63
  }
65
64
 
66
- private insert(state: VersionedMember) {
65
+ private async insert(state: VersionedMember): Promise<number> {
67
66
  const row = { ...state, ...stampCreation(this.scope, this.clock) };
67
+ const insertion = () => executorOf(this.database).insert(members).values(row);
68
68
 
69
- return executorOf(this.database)
70
- .insert(members)
71
- .values(row)
72
- .onConflictDoNothing({ target: primaryKeyOf(members) })
73
- .returning({ id: members.id });
69
+ return (await insertIgnoringConflict(insertion, members)) ? 1 : 0;
74
70
  }
75
71
 
76
72
  private update(state: VersionedMember, expected: number) {
@@ -1,5 +1,5 @@
1
1
  import { and, eq } from 'drizzle-orm';
2
- import { optimisticUpdate, primaryKeyOf } from '@ddd-ts-kit/drizzle/postgres';
2
+ import { insertIgnoringConflict, optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
3
3
  import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
4
4
  {{#if style.declared}}
5
5
  import { Repository } from '@ddd-ts-kit/kernel/declarations';
@@ -36,20 +36,16 @@ export class DrizzleOrganisationRepository implements OrganisationRepository {
36
36
  async save(saved: Organisation): Promise<void> {
37
37
  await optimisticUpdate(saved, async ({ expected, next }) => {
38
38
  const state = { ...OrganisationMapper.toRow(saved), version: next };
39
- const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
40
39
 
41
- return written.length;
40
+ return expected === 0 ? this.insert(state) : (await this.update(state, expected)).length;
42
41
  });
43
42
  }
44
43
 
45
- private insert(state: VersionedOrganisation) {
44
+ private async insert(state: VersionedOrganisation): Promise<number> {
46
45
  const row = { ...state, ...stampCreation(this.scope, this.clock) };
46
+ const insertion = () => executorOf(this.database).insert(organisations).values(row);
47
47
 
48
- return executorOf(this.database)
49
- .insert(organisations)
50
- .values(row)
51
- .onConflictDoNothing({ target: primaryKeyOf(organisations) })
52
- .returning({ id: organisations.id });
48
+ return (await insertIgnoringConflict(insertion, organisations)) ? 1 : 0;
53
49
  }
54
50
 
55
51
  private update(state: VersionedOrganisation, expected: number) {
@@ -1,8 +1,8 @@
1
1
  import { type {{event.typeName}} } from '{{alias.contexts}}/{{publisher.kebab}}/published-language{{alias.index}}';
2
2
 
3
- // TODO(domain): receive the port of the read model "{{name.words}}" keeps in the constructor, typed by that port (an abstract class of application/ports that extends `ReadModelStore<Row>` of the kernel: `ddd-ts-kit generate port {{context.kebab}} <Name>`), and pass the adapter (or its fake) where the module file of the context builds the projection.
3
+ // TODO(domain): receive the port of the read model "{{name.words}}" keeps in the constructor, typed by that port (`ddd-ts-kit generate read-model {{context.kebab}} <Name> --field <name>:<type>` writes it with its table, its store adapter and its fake), and pass the adapter (or its fake) where the module file of the context builds the projection.
4
4
  export class {{name.pascal}}Projection {
5
5
  async {{event.method}}(event: {{event.typeName}}): Promise<void> {
6
- // TODO(domain): write what {{event.type}} says into the read model through its port and answer what the store answers, `return this.<port>.upsertIfNewer(<id>, stampOf(event), () => ({ ... }))` with `stampOf` of the kernel: the stamp keeps a replay or a late delivery from undoing a newer line, and the answer is how the application counts what was applied.
6
+ // TODO(domain): write what {{event.type}} says into the read model through its port and answer what the store answers, `return this.<port>.upsertIfNewer(<id>, stampOf(event), () => ({ ... }))` with `stampOf` of the kernel when the event says the whole line (right in any order of delivery), or `this.<port>.updateIfNewer(<id>, stampOf(event), (line) => ({ ...line, ... }))` when it changes part of a line another event created, which answers `'missing'` when that line is not there. The stamp keeps a replay or a late delivery from undoing a newer line, and the answer is how the application counts what was applied.
7
7
  }
8
8
  }
@@ -1,11 +1,11 @@
1
1
  import { On, Projection } from '@ddd-ts-kit/kernel/declarations';
2
2
  import { {{event.definition}}, type {{event.typeName}} } from '{{alias.contexts}}/{{publisher.kebab}}/published-language{{alias.index}}';
3
3
 
4
- // TODO(domain): receive the port of the read model "{{name.words}}" keeps in the constructor, typed by that port (an abstract class of application/ports that extends `ReadModelStore<Row>` of the kernel: `ddd-ts-kit generate port {{context.kebab}} <Name>`); its adapter and its fake are bound to it like any other port.
4
+ // TODO(domain): receive the port of the read model "{{name.words}}" keeps in the constructor, typed by that port (`ddd-ts-kit generate read-model {{context.kebab}} <Name> --field <name>:<type>` writes it with its table, its store adapter and its fake); its adapter and its fake are bound to it like any other port.
5
5
  @Projection('{{context.kebab}}.{{name.kebab}}')
6
6
  export class {{name.pascal}}Projection {
7
7
  @On({{event.definition}})
8
8
  async {{event.method}}(event: {{event.typeName}}): Promise<void> {
9
- // TODO(domain): write what {{event.type}} says into the read model through its port and answer what the store answers, `return this.<port>.upsertIfNewer(<id>, stampOf(event), () => ({ ... }))` with `stampOf` of the kernel: the stamp keeps a replay or a late delivery from undoing a newer line, and the answer is how the application counts what was applied.
9
+ // TODO(domain): write what {{event.type}} says into the read model through its port and answer what the store answers, `return this.<port>.upsertIfNewer(<id>, stampOf(event), () => ({ ... }))` with `stampOf` of the kernel when the event says the whole line (right in any order of delivery), or `this.<port>.updateIfNewer(<id>, stampOf(event), (line) => ({ ...line, ... }))` when it changes part of a line another event created, which answers `'missing'` when that line is not there. The stamp keeps a replay or a late delivery from undoing a newer line, and the answer is how the application counts what was applied.
10
10
  }
11
11
  }
@@ -0,0 +1,95 @@
1
+ {{#if adapter.needsDatabase}}
2
+ {{#if tenant.scoped}}
3
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '{{tests.module}}';
4
+ import { FixedExecutionScope, executionContext, type Actor, type ExecutionContext } from '@ddd-ts-kit/kernel';
5
+ {{/if}}
6
+ {{#unless tenant.scoped}}
7
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '{{tests.module}}';
8
+ {{/unless}}
9
+ {{/if}}
10
+ {{#unless adapter.needsDatabase}}
11
+ import { afterEach, beforeEach, describe, expect, it } from '{{tests.module}}';
12
+ {{/unless}}
13
+ import { readModelContract } from '@ddd-ts-kit/testing/contracts';
14
+ import type { {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
15
+ import { {{adapter.pascal}} } from '{{alias.context}}/infrastructure/persistence/{{adapter.kebab}}{{alias.ext}}';
16
+ {{#if adapter.needsDatabase}}
17
+ import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
18
+ {{/if}}
19
+ import { Fake{{name.pascal}} } from '{{alias.context}}/test/fakes/{{name.kebab}}.fake{{alias.ext}}';
20
+
21
+ const runner = { describe, it, expect, beforeEach, afterEach };
22
+
23
+ const expectations = {
24
+ createRow: (key: string): {{name.pascal}}Row => ({
25
+ id: key,
26
+ {{#if fields.any}}
27
+ {{fields.sample}}
28
+ {{/if}}
29
+ }),
30
+ // TODO(domain): add `change: (row: {{name.pascal}}Row) => ({ ...row, <a field>: <another value> })`, so that the suite proves a later event replaces what the row holds; the case stays pending until then.
31
+ };
32
+
33
+ readModelContract<{{name.pascal}}Row>(runner, {
34
+ ...expectations,
35
+ name: 'Fake{{name.pascal}}',
36
+ createStore: () => new Fake{{name.pascal}}(),
37
+ });
38
+
39
+ {{#if adapter.needsDatabase}}
40
+ let database: TestDatabase;
41
+
42
+ beforeAll(async () => {
43
+ database = await openTestDatabase();
44
+ });
45
+
46
+ afterAll(async () => {
47
+ await database.close();
48
+ });
49
+
50
+ readModelContract<{{name.pascal}}Row>(runner, {
51
+ ...expectations,
52
+ name: '{{adapter.pascal}}',
53
+ createStore: async () => {
54
+ await database.reset();
55
+
56
+ {{#if tenant.scoped}}
57
+ return new {{adapter.pascal}}(database.persistence.database, new FixedExecutionScope(workOf('acme')));
58
+ {{/if}}
59
+ {{#unless tenant.scoped}}
60
+ return new {{adapter.pascal}}(database.persistence.database);
61
+ {{/unless}}
62
+ },
63
+ });
64
+ {{#if tenant.scoped}}
65
+
66
+ describe('{{adapter.pascal}}, tenant by tenant', () => {
67
+ it('hides from a tenant what another tenant wrote', async () => {
68
+ await database.reset();
69
+
70
+ const scope = new FixedExecutionScope(workOf('acme'));
71
+ const store = new {{adapter.pascal}}(database.persistence.database, scope);
72
+ const stamp = { eventId: 'event-1', occurredAt: new Date('2026-01-01T00:00:00.000Z') };
73
+
74
+ await store.upsertIfNewer('row-1', stamp, () => expectations.createRow('row-1'));
75
+
76
+ scope.enter(workOf('globex'));
77
+
78
+ expect(await store.get('row-1')).toBeUndefined();
79
+ });
80
+ });
81
+
82
+ function workOf(tenantId: string): ExecutionContext {
83
+ const actor: Actor = { id: 'member-of-' + tenantId, type: 'user', tenantId, roles: [], attributes: {} };
84
+
85
+ return executionContext({ correlationId: 'contract-spec', actor, origin: 'test' });
86
+ }
87
+ {{/if}}
88
+ {{/if}}
89
+ {{#unless adapter.needsDatabase}}
90
+ readModelContract<{{name.pascal}}Row>(runner, {
91
+ ...expectations,
92
+ name: '{{adapter.pascal}}',
93
+ createStore: () => new {{adapter.pascal}}(),
94
+ });
95
+ {{/unless}}
@@ -0,0 +1,8 @@
1
+ // ddd-ts-kit:imports
2
+ import { contextSchema } from '@ddd-ts-kit/drizzle/postgres';
3
+ // /ddd-ts-kit:imports
4
+
5
+ export const {{context.camel}}Schema = contextSchema('{{context.kebab}}');
6
+
7
+ // ddd-ts-kit:tables
8
+ // /ddd-ts-kit:tables
@@ -0,0 +1,41 @@
1
+ import type { PgQueryResultHKT } from 'drizzle-orm/pg-core';
2
+ import { DrizzleReadModelStore } from '@ddd-ts-kit/drizzle/postgres';
3
+ {{#if tenant.scoped}}
4
+ import type { ExecutionScope } from '@ddd-ts-kit/kernel';
5
+ {{/if}}
6
+ {{#if style.declared}}
7
+ import { Repository } from '@ddd-ts-kit/kernel/declarations';
8
+ import { {{name.pascal}}, {{name.camel}}Criteria, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
9
+ {{/if}}
10
+ {{#unless style.declared}}
11
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
12
+ {{/unless}}
13
+ {{storage.adapterImport}}
14
+ import { {{name.camel}} } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
15
+
16
+ {{#if style.declared}}
17
+ @Repository({{name.pascal}})
18
+ {{/if}}
19
+ export class {{adapter.pascal}} extends DrizzleReadModelStore<{{name.pascal}}Row, PgQueryResultHKT> implements {{name.pascal}} {
20
+ {{#if tenant.scoped}}
21
+ constructor(database: Database, scope: ExecutionScope) {
22
+ {{/if}}
23
+ {{#unless tenant.scoped}}
24
+ constructor(database: Database) {
25
+ {{/unless}}
26
+ super(database, {
27
+ table: {{name.camel}},
28
+ key: {{name.camel}}.id,
29
+ columns: {
30
+ id: {{name.camel}}.id,
31
+ {{#if fields.any}}
32
+ {{fields.drizzleColumns}}
33
+ {{/if}}
34
+ },
35
+ {{#if tenant.scoped}}
36
+ tenant: { scope, column: {{name.camel}}.tenantId },
37
+ {{/if}}
38
+ definition: {{name.camel}}Criteria,
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,38 @@
1
+ @@imports
2
+ {{#if fields.checked}}
3
+ import { sql } from 'drizzle-orm';
4
+ {{/if}}
5
+ {{#if tenant.scoped}}
6
+ import { index, {{fields.drizzleImports}} } from 'drizzle-orm/pg-core';
7
+ import { readModelColumns, tenantColumn } from '@ddd-ts-kit/drizzle/postgres';
8
+ {{/if}}
9
+ {{#unless tenant.scoped}}
10
+ import { {{fields.drizzleImports}} } from 'drizzle-orm/pg-core';
11
+ import { readModelColumns } from '@ddd-ts-kit/drizzle/postgres';
12
+ {{/unless}}
13
+ @@tables
14
+ {{#if fields.drizzleWide}}
15
+ export const {{name.camel}} = {{context.camel}}Schema.table(
16
+ '{{table}}',
17
+ {
18
+ id: text('id').primaryKey(),
19
+ {{#if fields.any}}
20
+ {{fields.drizzleTable}}
21
+ {{/if}}
22
+ {{#if tenant.scoped}}
23
+ ...tenantColumn(),
24
+ {{/if}}
25
+ ...readModelColumns(),
26
+ },
27
+ {{fields.drizzleExtras}}
28
+ );
29
+ {{/if}}
30
+ {{#unless fields.drizzleWide}}
31
+ export const {{name.camel}} = {{context.camel}}Schema.table('{{table}}', {
32
+ id: text('id').primaryKey(),
33
+ {{#if fields.any}}
34
+ {{fields.drizzleTable}}
35
+ {{/if}}
36
+ ...readModelColumns(),
37
+ });
38
+ {{/unless}}
@@ -0,0 +1,8 @@
1
+ import { InMemoryReadModelStore } from '@ddd-ts-kit/kernel';
2
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
3
+
4
+ export class Fake{{name.pascal}} extends InMemoryReadModelStore<{{name.pascal}}Row> implements {{name.pascal}} {
5
+ constructor() {
6
+ super({{name.camel}}Criteria);
7
+ }
8
+ }
@@ -0,0 +1,41 @@
1
+ {{#if tenant.scoped}}
2
+ import type { ExecutionScope } from '@ddd-ts-kit/kernel';
3
+ {{/if}}
4
+ {{#if style.declared}}
5
+ import { Repository } from '@ddd-ts-kit/kernel/declarations';
6
+ {{/if}}
7
+ import { type KnexContext, KnexReadModelStore } from '@ddd-ts-kit/knex';
8
+ {{#if style.declared}}
9
+ import { {{name.pascal}}, {{name.camel}}Criteria, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
10
+ {{/if}}
11
+ {{#unless style.declared}}
12
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
13
+ {{/unless}}
14
+ import { {{context.constant}}_SCHEMA } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
15
+
16
+ {{#if style.declared}}
17
+ @Repository({{name.pascal}})
18
+ {{/if}}
19
+ export class {{adapter.pascal}} extends KnexReadModelStore<{{name.pascal}}Row> implements {{name.pascal}} {
20
+ {{#if tenant.scoped}}
21
+ constructor(database: KnexContext, scope: ExecutionScope) {
22
+ {{/if}}
23
+ {{#unless tenant.scoped}}
24
+ constructor(database: KnexContext) {
25
+ {{/unless}}
26
+ super(database, {
27
+ {{#if tenant.scoped}}
28
+ tenant: scope,
29
+ {{/if}}
30
+ schema: {{context.constant}}_SCHEMA,
31
+ table: '{{table}}',
32
+ columns: {
33
+ id: 'id',
34
+ {{#if fields.any}}
35
+ {{fields.names}}
36
+ {{/if}}
37
+ },
38
+ definition: {{name.camel}}Criteria,
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,26 @@
1
+ @@imports
2
+ {{#if tenant.scoped}}
3
+ import { readModelColumns, tenantColumn } from '@ddd-ts-kit/knex';
4
+ {{/if}}
5
+ {{#unless tenant.scoped}}
6
+ import { readModelColumns } from '@ddd-ts-kit/knex';
7
+ {{/unless}}
8
+ @@tables
9
+ await create{{name.pascal}}Table(knex);
10
+ @@definitions
11
+ function create{{name.pascal}}Table(knex: Knex): Promise<void> {
12
+ return knex.schema.withSchema({{context.constant}}_SCHEMA).createTable('{{table}}', (table) => {
13
+ table.text('id').primary();
14
+ {{#if fields.any}}
15
+ {{fields.knexTable}}
16
+ {{/if}}
17
+ {{#if tenant.scoped}}
18
+ tenantColumn(table);
19
+ table.index(['tenant_id', 'id'], '{{table}}_tenant_idx');
20
+ {{/if}}
21
+ readModelColumns(table);
22
+ {{#if fields.checked}}
23
+ {{fields.knexCheck}}
24
+ {{/if}}
25
+ });
26
+ }
@@ -0,0 +1,17 @@
1
+ import { InMemoryReadModelStore } from '@ddd-ts-kit/kernel';
2
+ {{#if style.declared}}
3
+ import { Repository } from '@ddd-ts-kit/kernel/declarations';
4
+ import { {{name.pascal}}, {{name.camel}}Criteria, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
5
+ {{/if}}
6
+ {{#unless style.declared}}
7
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
8
+ {{/unless}}
9
+
10
+ {{#if style.declared}}
11
+ @Repository({{name.pascal}})
12
+ {{/if}}
13
+ export class {{adapter.pascal}} extends InMemoryReadModelStore<{{name.pascal}}Row> implements {{name.pascal}} {
14
+ constructor() {
15
+ super({{name.camel}}Criteria);
16
+ }
17
+ }
@@ -0,0 +1,24 @@
1
+ import { ReadModelStore, defineCriteria } from '@ddd-ts-kit/kernel';
2
+
3
+ export type {{name.pascal}}Row = {
4
+ readonly id: string;
5
+ {{#if fields.any}}
6
+ {{fields.row}}
7
+ {{/if}}
8
+ {{#unless fields.any}}
9
+ // TODO(domain): add one field per thing a read of "{{name.words}}" shows or filters by, with its line in the criteria below, its column in the table and its entry in the columns of the store adapter (`--field <name>:<type>` writes the four).
10
+ {{/unless}}
11
+ };
12
+
13
+ export const {{name.camel}}Criteria = defineCriteria<{{name.pascal}}Row>({
14
+ fields: {
15
+ // TODO(domain): open to the readers only what a screen needs: `filter: ['eq']` on a field it filters by, `sortable: true` on a field it sorts by, then a `defaultSort`.
16
+ id: { type: 'string' },
17
+ {{#if fields.any}}
18
+ {{fields.criteria}}
19
+ {{/if}}
20
+ },
21
+ tieBreaker: 'id',
22
+ });
23
+
24
+ export abstract class {{name.pascal}} extends ReadModelStore<{{name.pascal}}Row> {}
@@ -0,0 +1,25 @@
1
+ @@models
2
+ model {{context.pascal}}{{name.pascal}} {
3
+ id String @id
4
+ {{#if fields.any}}
5
+ {{fields.prismaModel}}
6
+ {{/if}}
7
+ {{#if fields.checked}}
8
+ // TODO(domain): the schema language has no check constraint. Add to the migration that creates this table, after its CREATE TABLE, what keeps the rows that are not removed whole: {{fields.prismaCheck}}
9
+ {{/if}}
10
+ {{#if tenant.scoped}}
11
+ tenantId String @map("tenant_id")
12
+ {{/if}}
13
+ /// The event that last changed the row: an older one changes nothing.
14
+ lastEventId String @map("last_event_id")
15
+ lastEventAt DateTime @map("last_event_at") @db.Timestamptz(3)
16
+ lastEventVersion BigInt? @map("last_event_version")
17
+ /// The trace of a removed row, so that a late event does not bring it back.
18
+ deleted Boolean @default(false)
19
+
20
+ {{#if tenant.scoped}}
21
+ @@index([tenantId, id], map: "{{table}}_tenant_idx")
22
+ {{/if}}
23
+ @@map("{{table}}")
24
+ @@schema("{{context.schema}}")
25
+ }
@@ -0,0 +1,43 @@
1
+ {{#if tenant.scoped}}
2
+ import type { ExecutionScope } from '@ddd-ts-kit/kernel';
3
+ {{/if}}
4
+ {{#if style.declared}}
5
+ import { Repository } from '@ddd-ts-kit/kernel/declarations';
6
+ {{/if}}
7
+ import { PrismaReadModelStore } from '@ddd-ts-kit/prisma';
8
+ {{#if style.declared}}
9
+ import { {{name.pascal}}, {{name.camel}}Criteria, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
10
+ {{/if}}
11
+ {{#unless style.declared}}
12
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
13
+ {{/unless}}
14
+ {{storage.adapterImport}}
15
+ import type { Prisma } from '{{alias.generated}}/prisma/client{{alias.ext}}';
16
+
17
+ {{#if style.declared}}
18
+ @Repository({{name.pascal}})
19
+ {{/if}}
20
+ export class {{adapter.pascal}} extends PrismaReadModelStore<{{name.pascal}}Row, Prisma.TransactionClient> implements {{name.pascal}} {
21
+ {{#if tenant.scoped}}
22
+ constructor(database: Database, scope: ExecutionScope) {
23
+ {{/if}}
24
+ {{#unless tenant.scoped}}
25
+ constructor(database: Database) {
26
+ {{/unless}}
27
+ super(database, {
28
+ delegate: (client) => client.{{context.camel}}{{name.pascal}},
29
+ schema: '{{context.schema}}',
30
+ table: '{{table}}',
31
+ columns: {
32
+ id: 'id',
33
+ {{#if fields.any}}
34
+ {{fields.names}}
35
+ {{/if}}
36
+ },
37
+ {{#if tenant.scoped}}
38
+ tenant: { scope },
39
+ {{/if}}
40
+ definition: {{name.camel}}Criteria,
41
+ });
42
+ }
43
+ }
@@ -0,0 +1,4 @@
1
+ @@imports
2
+ import { {{name.camel}} } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
3
+ @@schemas
4
+ {{name.camel}},
@@ -0,0 +1,9 @@
1
+ // ddd-ts-kit:imports
2
+ import { EntitySchema } from 'typeorm';
3
+ import { schemaNameOf } from '@ddd-ts-kit/typeorm';
4
+ // /ddd-ts-kit:imports
5
+
6
+ const {{context.constant}}_SCHEMA = schemaNameOf('{{context.kebab}}');
7
+
8
+ // ddd-ts-kit:tables
9
+ // /ddd-ts-kit:tables
@@ -0,0 +1,30 @@
1
+ {{#if tenant.scoped}}
2
+ import type { ExecutionScope } from '@ddd-ts-kit/kernel';
3
+ {{/if}}
4
+ {{#if style.declared}}
5
+ import { Repository } from '@ddd-ts-kit/kernel/declarations';
6
+ {{/if}}
7
+ import { type TypeOrmContext, TypeOrmReadModelStore } from '@ddd-ts-kit/typeorm';
8
+ {{#if style.declared}}
9
+ import { {{name.pascal}}, {{name.camel}}Criteria, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
10
+ {{/if}}
11
+ {{#unless style.declared}}
12
+ import { {{name.camel}}Criteria, type {{name.pascal}}, type {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
13
+ {{/unless}}
14
+ import { {{name.camel}} } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
15
+
16
+ {{#if style.declared}}
17
+ @Repository({{name.pascal}})
18
+ {{/if}}
19
+ export class {{adapter.pascal}} extends TypeOrmReadModelStore<{{name.pascal}}Row> implements {{name.pascal}} {
20
+ {{#if tenant.scoped}}
21
+ constructor(database: TypeOrmContext, scope: ExecutionScope) {
22
+ super(database, { entity: {{name.camel}}, tenant: { scope }, definition: {{name.camel}}Criteria });
23
+ }
24
+ {{/if}}
25
+ {{#unless tenant.scoped}}
26
+ constructor(database: TypeOrmContext) {
27
+ super(database, { entity: {{name.camel}}, definition: {{name.camel}}Criteria });
28
+ }
29
+ {{/unless}}
30
+ }
@@ -0,0 +1,54 @@
1
+ @@imports
2
+ {{#if tenant.scoped}}
3
+ import type { TenantScoped } from '@ddd-ts-kit/kernel';
4
+ import { readModelColumns, tenantColumn, type ReadModelStamps } from '@ddd-ts-kit/typeorm';
5
+ {{/if}}
6
+ {{#unless tenant.scoped}}
7
+ import { readModelColumns, type ReadModelStamps } from '@ddd-ts-kit/typeorm';
8
+ {{/unless}}
9
+ import type { {{name.pascal}}Row } from '{{alias.context}}/application/ports/{{name.kebab}}.port{{alias.ext}}';
10
+ @@tables
11
+ {{#if tenant.scoped}}
12
+ export const {{name.camel}} = new EntitySchema<{{name.pascal}}Row & TenantScoped & ReadModelStamps>({
13
+ name: '{{context.pascal}}{{name.pascal}}',
14
+ tableName: '{{table}}',
15
+ schema: {{context.constant}}_SCHEMA,
16
+ columns: {
17
+ id: { type: 'text', primary: true },
18
+ {{#if fields.any}}
19
+ {{fields.typeormTable}}
20
+ {{/if}}
21
+ tenantId: { ...tenantColumn().tenantId, select: false },
22
+ ...readModelColumns(),
23
+ },
24
+ indices: [{ name: '{{table}}_tenant_idx', columns: ['tenantId', 'id'] }],
25
+ {{#if fields.checked}}
26
+ checks: [
27
+ {
28
+ {{fields.typeormCheck}}
29
+ },
30
+ ],
31
+ {{/if}}
32
+ });
33
+ {{/if}}
34
+ {{#unless tenant.scoped}}
35
+ export const {{name.camel}} = new EntitySchema<{{name.pascal}}Row & ReadModelStamps>({
36
+ name: '{{context.pascal}}{{name.pascal}}',
37
+ tableName: '{{table}}',
38
+ schema: {{context.constant}}_SCHEMA,
39
+ columns: {
40
+ id: { type: 'text', primary: true },
41
+ {{#if fields.any}}
42
+ {{fields.typeormTable}}
43
+ {{/if}}
44
+ ...readModelColumns(),
45
+ },
46
+ {{#if fields.checked}}
47
+ checks: [
48
+ {
49
+ {{fields.typeormCheck}}
50
+ },
51
+ ],
52
+ {{/if}}
53
+ });
54
+ {{/unless}}