ddd-ts-kit 0.108.1 → 0.110.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 (559) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/README.fr.md +33 -14
  3. package/README.md +28 -14
  4. package/dist/affected/reach-of.d.ts.map +1 -1
  5. package/dist/affected/reach-of.js +4 -1
  6. package/dist/affected/reach-of.js.map +1 -1
  7. package/dist/check/canonical/holds-shared-files.d.ts +3 -0
  8. package/dist/check/canonical/holds-shared-files.d.ts.map +1 -0
  9. package/dist/check/canonical/holds-shared-files.js +7 -0
  10. package/dist/check/canonical/holds-shared-files.js.map +1 -0
  11. package/dist/check/canonical/is-shared-directory.d.ts +7 -0
  12. package/dist/check/canonical/is-shared-directory.d.ts.map +1 -0
  13. package/dist/check/canonical/is-shared-directory.js +13 -0
  14. package/dist/check/canonical/is-shared-directory.js.map +1 -0
  15. package/dist/check/canonical/role.d.ts +2 -0
  16. package/dist/check/canonical/role.d.ts.map +1 -1
  17. package/dist/check/canonical/roles.d.ts.map +1 -1
  18. package/dist/check/canonical/roles.js +10 -5
  19. package/dist/check/canonical/roles.js.map +1 -1
  20. package/dist/check/canonical/shared-directories.d.ts +3 -0
  21. package/dist/check/canonical/shared-directories.d.ts.map +1 -0
  22. package/dist/check/canonical/shared-directories.js +8 -0
  23. package/dist/check/canonical/shared-directories.js.map +1 -0
  24. package/dist/check/canonical/stray-entry.d.ts.map +1 -1
  25. package/dist/check/canonical/stray-entry.js +43 -4
  26. package/dist/check/canonical/stray-entry.js.map +1 -1
  27. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  28. package/dist/check/catalogue/architecture-rules.js +2 -0
  29. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  30. package/dist/check/configuration/module-problems.js +20 -16
  31. package/dist/check/configuration/module-problems.js.map +1 -1
  32. package/dist/check/errors/code-reference.d.ts +7 -0
  33. package/dist/check/errors/code-reference.d.ts.map +1 -0
  34. package/dist/check/errors/code-reference.js +2 -0
  35. package/dist/check/errors/code-reference.js.map +1 -0
  36. package/dist/check/errors/code-references.d.ts +7 -0
  37. package/dist/check/errors/code-references.d.ts.map +1 -0
  38. package/dist/check/errors/code-references.js +13 -0
  39. package/dist/check/errors/code-references.js.map +1 -0
  40. package/dist/check/errors/kit-code-keys.d.ts +3 -0
  41. package/dist/check/errors/kit-code-keys.d.ts.map +1 -0
  42. package/dist/check/errors/kit-code-keys.js +5 -0
  43. package/dist/check/errors/kit-code-keys.js.map +1 -0
  44. package/dist/check/errors/kit-codes-list.d.ts +3 -0
  45. package/dist/check/errors/kit-codes-list.d.ts.map +1 -0
  46. package/dist/check/errors/kit-codes-list.js +3 -0
  47. package/dist/check/errors/kit-codes-list.js.map +1 -0
  48. package/dist/check/explain/errors-docs.d.ts.map +1 -1
  49. package/dist/check/explain/errors-docs.js +5 -2
  50. package/dist/check/explain/errors-docs.js.map +1 -1
  51. package/dist/check/explain/module-docs.d.ts.map +1 -1
  52. package/dist/check/explain/module-docs.js +9 -6
  53. package/dist/check/explain/module-docs.js.map +1 -1
  54. package/dist/check/explain/persistence-docs.d.ts.map +1 -1
  55. package/dist/check/explain/persistence-docs.js +18 -0
  56. package/dist/check/explain/persistence-docs.js.map +1 -1
  57. package/dist/check/explain/tree-docs.d.ts.map +1 -1
  58. package/dist/check/explain/tree-docs.js +3 -1
  59. package/dist/check/explain/tree-docs.js.map +1 -1
  60. package/dist/check/fixtures/errors-route.d.ts +1 -1
  61. package/dist/check/fixtures/errors-route.d.ts.map +1 -1
  62. package/dist/check/fixtures/errors-route.js +2 -2
  63. package/dist/check/fixtures/errors-route.js.map +1 -1
  64. package/dist/check/fixtures/files-fixtures.d.ts.map +1 -1
  65. package/dist/check/fixtures/files-fixtures.js +77 -0
  66. package/dist/check/fixtures/files-fixtures.js.map +1 -1
  67. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  68. package/dist/check/fixtures/fixtures.js +2 -0
  69. package/dist/check/fixtures/fixtures.js.map +1 -1
  70. package/dist/check/fixtures/module-fixtures.d.ts.map +1 -1
  71. package/dist/check/fixtures/module-fixtures.js +27 -31
  72. package/dist/check/fixtures/module-fixtures.js.map +1 -1
  73. package/dist/check/fixtures/named-refusal-fixtures.d.ts.map +1 -1
  74. package/dist/check/fixtures/named-refusal-fixtures.js +40 -0
  75. package/dist/check/fixtures/named-refusal-fixtures.js.map +1 -1
  76. package/dist/check/fixtures/shared-folder-fixtures.d.ts +7 -0
  77. package/dist/check/fixtures/shared-folder-fixtures.d.ts.map +1 -0
  78. package/dist/check/fixtures/shared-folder-fixtures.js +176 -0
  79. package/dist/check/fixtures/shared-folder-fixtures.js.map +1 -0
  80. package/dist/check/fixtures/shared-kernel-fixtures.d.ts.map +1 -1
  81. package/dist/check/fixtures/shared-kernel-fixtures.js +11 -0
  82. package/dist/check/fixtures/shared-kernel-fixtures.js.map +1 -1
  83. package/dist/check/fixtures/with-modules.d.ts +4 -0
  84. package/dist/check/fixtures/with-modules.d.ts.map +1 -0
  85. package/dist/check/fixtures/with-modules.js +22 -0
  86. package/dist/check/fixtures/with-modules.js.map +1 -0
  87. package/dist/check/model/context-location.d.ts +5 -0
  88. package/dist/check/model/context-location.d.ts.map +1 -1
  89. package/dist/check/project/locate.js +12 -5
  90. package/dist/check/project/locate.js.map +1 -1
  91. package/dist/check/rules/errors-known-code.d.ts.map +1 -1
  92. package/dist/check/rules/errors-known-code.js +60 -9
  93. package/dist/check/rules/errors-known-code.js.map +1 -1
  94. package/dist/check/rules/module-complete.d.ts.map +1 -1
  95. package/dist/check/rules/module-complete.js +19 -20
  96. package/dist/check/rules/module-complete.js.map +1 -1
  97. package/dist/check/rules/module-declared.js +5 -1
  98. package/dist/check/rules/module-declared.js.map +1 -1
  99. package/dist/check/rules/search-store-from-platform.d.ts +3 -0
  100. package/dist/check/rules/search-store-from-platform.d.ts.map +1 -0
  101. package/dist/check/rules/search-store-from-platform.js +93 -0
  102. package/dist/check/rules/search-store-from-platform.js.map +1 -0
  103. package/dist/check/rules/test-acceptance-black-box.d.ts.map +1 -1
  104. package/dist/check/rules/test-acceptance-black-box.js +6 -7
  105. package/dist/check/rules/test-acceptance-black-box.js.map +1 -1
  106. package/dist/check/rules/test-builder-required.d.ts.map +1 -1
  107. package/dist/check/rules/test-builder-required.js +15 -12
  108. package/dist/check/rules/test-builder-required.js.map +1 -1
  109. package/dist/check/rules/test-spec-required.d.ts.map +1 -1
  110. package/dist/check/rules/test-spec-required.js +12 -11
  111. package/dist/check/rules/test-spec-required.js.map +1 -1
  112. package/dist/check/rules/tree-closed.js +1 -1
  113. package/dist/check/rules/tree-closed.js.map +1 -1
  114. package/dist/check/support/path-in-context.d.ts +1 -1
  115. package/dist/check/support/path-in-context.d.ts.map +1 -1
  116. package/dist/check/support/path-in-context.js +6 -3
  117. package/dist/check/support/path-in-context.js.map +1 -1
  118. package/dist/check/support/test-folder-of.d.ts +11 -0
  119. package/dist/check/support/test-folder-of.d.ts.map +1 -0
  120. package/dist/check/support/test-folder-of.js +12 -0
  121. package/dist/check/support/test-folder-of.js.map +1 -0
  122. package/dist/commands/drizzle-generate.d.ts.map +1 -1
  123. package/dist/commands/drizzle-generate.js +9 -0
  124. package/dist/commands/drizzle-generate.js.map +1 -1
  125. package/dist/commands/generate.js +9 -1
  126. package/dist/commands/generate.js.map +1 -1
  127. package/dist/commands/init.d.ts.map +1 -1
  128. package/dist/commands/init.js +1 -0
  129. package/dist/commands/init.js.map +1 -1
  130. package/dist/commands/lint.d.ts +2 -1
  131. package/dist/commands/lint.d.ts.map +1 -1
  132. package/dist/commands/lint.js +4 -1
  133. package/dist/commands/lint.js.map +1 -1
  134. package/dist/commands/move-to-module.d.ts.map +1 -1
  135. package/dist/commands/move-to-module.js +0 -2
  136. package/dist/commands/move-to-module.js.map +1 -1
  137. package/dist/config/index.d.ts +1 -1
  138. package/dist/config/index.d.ts.map +1 -1
  139. package/dist/config/index.js +1 -1
  140. package/dist/config/index.js.map +1 -1
  141. package/dist/config/known-stack-keys.d.ts +1 -1
  142. package/dist/config/known-stack-keys.d.ts.map +1 -1
  143. package/dist/config/known-stack-keys.js +1 -0
  144. package/dist/config/known-stack-keys.js.map +1 -1
  145. package/dist/config/parse-stack.d.ts.map +1 -1
  146. package/dist/config/parse-stack.js +2 -1
  147. package/dist/config/parse-stack.js.map +1 -1
  148. package/dist/config/stack.d.ts +9 -0
  149. package/dist/config/stack.d.ts.map +1 -1
  150. package/dist/config/stack.js +1 -0
  151. package/dist/config/stack.js.map +1 -1
  152. package/dist/context-layout/context-layout.d.ts +3 -2
  153. package/dist/context-layout/context-layout.d.ts.map +1 -1
  154. package/dist/context-layout/context-layout.js +18 -8
  155. package/dist/context-layout/context-layout.js.map +1 -1
  156. package/dist/context-layout/imports-of.d.ts +11 -0
  157. package/dist/context-layout/imports-of.d.ts.map +1 -0
  158. package/dist/context-layout/imports-of.js +20 -0
  159. package/dist/context-layout/imports-of.js.map +1 -0
  160. package/dist/context-layout/module-moves.d.ts +10 -7
  161. package/dist/context-layout/module-moves.d.ts.map +1 -1
  162. package/dist/context-layout/module-moves.js +65 -122
  163. package/dist/context-layout/module-moves.js.map +1 -1
  164. package/dist/context-layout/runner-configs-by-hand.d.ts +11 -0
  165. package/dist/context-layout/runner-configs-by-hand.d.ts.map +1 -0
  166. package/dist/context-layout/runner-configs-by-hand.js +23 -0
  167. package/dist/context-layout/runner-configs-by-hand.js.map +1 -0
  168. package/dist/context-layout/settle.d.ts +20 -0
  169. package/dist/context-layout/settle.d.ts.map +1 -0
  170. package/dist/context-layout/settle.js +58 -0
  171. package/dist/context-layout/settle.js.map +1 -0
  172. package/dist/controllers/declared-code.d.ts +3 -0
  173. package/dist/controllers/declared-code.d.ts.map +1 -0
  174. package/dist/controllers/declared-code.js +8 -0
  175. package/dist/controllers/declared-code.js.map +1 -0
  176. package/dist/controllers/finish-migration.d.ts.map +1 -1
  177. package/dist/controllers/finish-migration.js +5 -3
  178. package/dist/controllers/finish-migration.js.map +1 -1
  179. package/dist/controllers/migrate-context.js +3 -2
  180. package/dist/controllers/migrate-context.js.map +1 -1
  181. package/dist/controllers/plan-context.d.ts +1 -1
  182. package/dist/controllers/plan-context.d.ts.map +1 -1
  183. package/dist/controllers/plan-context.js +11 -6
  184. package/dist/controllers/plan-context.js.map +1 -1
  185. package/dist/controllers/render-controller.d.ts.map +1 -1
  186. package/dist/controllers/render-controller.js +20 -4
  187. package/dist/controllers/render-controller.js.map +1 -1
  188. package/dist/depcruise/hygiene-rules.js +2 -2
  189. package/dist/depcruise/hygiene-rules.js.map +1 -1
  190. package/dist/depcruise/test-files.d.ts +4 -1
  191. package/dist/depcruise/test-files.d.ts.map +1 -1
  192. package/dist/depcruise/test-files.js +5 -2
  193. package/dist/depcruise/test-files.js.map +1 -1
  194. package/dist/describe/codes-named-in.d.ts +8 -0
  195. package/dist/describe/codes-named-in.d.ts.map +1 -0
  196. package/dist/describe/codes-named-in.js +33 -0
  197. package/dist/describe/codes-named-in.js.map +1 -0
  198. package/dist/describe/read-controllers.js +2 -2
  199. package/dist/describe/read-controllers.js.map +1 -1
  200. package/dist/describe/read-route-groups.d.ts +6 -2
  201. package/dist/describe/read-route-groups.d.ts.map +1 -1
  202. package/dist/describe/read-route-groups.js +8 -4
  203. package/dist/describe/read-route-groups.js.map +1 -1
  204. package/dist/describe/read-routes.d.ts.map +1 -1
  205. package/dist/describe/read-routes.js +7 -2
  206. package/dist/describe/read-routes.js.map +1 -1
  207. package/dist/docs/spec-heading.d.ts +5 -4
  208. package/dist/docs/spec-heading.d.ts.map +1 -1
  209. package/dist/docs/spec-heading.js +4 -6
  210. package/dist/docs/spec-heading.js.map +1 -1
  211. package/dist/docs/spec-of-page.d.ts +7 -2
  212. package/dist/docs/spec-of-page.d.ts.map +1 -1
  213. package/dist/docs/spec-of-page.js +8 -3
  214. package/dist/docs/spec-of-page.js.map +1 -1
  215. package/dist/docs/specs-by-directory.d.ts +2 -2
  216. package/dist/docs/specs-by-directory.d.ts.map +1 -1
  217. package/dist/docs/specs-by-directory.js +4 -5
  218. package/dist/docs/specs-by-directory.js.map +1 -1
  219. package/dist/docs/write-behaviour.d.ts +1 -1
  220. package/dist/docs/write-behaviour.d.ts.map +1 -1
  221. package/dist/docs/write-behaviour.js +17 -2
  222. package/dist/docs/write-behaviour.js.map +1 -1
  223. package/dist/file-moves/follow-in-migrations.d.ts +10 -0
  224. package/dist/file-moves/follow-in-migrations.d.ts.map +1 -0
  225. package/dist/file-moves/follow-in-migrations.js +30 -0
  226. package/dist/file-moves/follow-in-migrations.js.map +1 -0
  227. package/dist/file-moves/move-files.d.ts +2 -1
  228. package/dist/file-moves/move-files.d.ts.map +1 -1
  229. package/dist/file-moves/move-files.js +4 -2
  230. package/dist/file-moves/move-files.js.map +1 -1
  231. package/dist/generate/errors/write-named-refusal.d.ts.map +1 -1
  232. package/dist/generate/errors/write-named-refusal.js +6 -2
  233. package/dist/generate/errors/write-named-refusal.js.map +1 -1
  234. package/dist/generate/kinds/builder-kind.js +1 -1
  235. package/dist/generate/kinds/builder-kind.js.map +1 -1
  236. package/dist/generate/kinds/declarations-of.js +1 -1
  237. package/dist/generate/kinds/declarations-of.js.map +1 -1
  238. package/dist/generate/kinds/declare-storage.d.ts +2 -1
  239. package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
  240. package/dist/generate/kinds/declare-storage.js +19 -5
  241. package/dist/generate/kinds/declare-storage.js.map +1 -1
  242. package/dist/generate/kinds/e2e/acting-role.d.ts +15 -0
  243. package/dist/generate/kinds/e2e/acting-role.d.ts.map +1 -0
  244. package/dist/generate/kinds/e2e/acting-role.js +19 -0
  245. package/dist/generate/kinds/e2e/acting-role.js.map +1 -0
  246. package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
  247. package/dist/generate/kinds/e2e-kind.js +5 -1
  248. package/dist/generate/kinds/e2e-kind.js.map +1 -1
  249. package/dist/generate/kinds/gateway-kind.d.ts.map +1 -1
  250. package/dist/generate/kinds/gateway-kind.js +14 -2
  251. package/dist/generate/kinds/gateway-kind.js.map +1 -1
  252. package/dist/generate/kinds/generate-repository.js +1 -1
  253. package/dist/generate/kinds/generate-repository.js.map +1 -1
  254. package/dist/generate/kinds/module-kind.d.ts.map +1 -1
  255. package/dist/generate/kinds/module-kind.js +9 -1
  256. package/dist/generate/kinds/module-kind.js.map +1 -1
  257. package/dist/generate/kinds/route/group-vars.d.ts.map +1 -1
  258. package/dist/generate/kinds/route/group-vars.js +5 -3
  259. package/dist/generate/kinds/route/group-vars.js.map +1 -1
  260. package/dist/generate/kinds/route/route-vars.js +1 -1
  261. package/dist/generate/kinds/route/route-vars.js.map +1 -1
  262. package/dist/generate/kinds/world/context-fakes.d.ts +1 -1
  263. package/dist/generate/kinds/world/context-fakes.d.ts.map +1 -1
  264. package/dist/generate/kinds/world/context-fakes.js +8 -7
  265. package/dist/generate/kinds/world/context-fakes.js.map +1 -1
  266. package/dist/generate/kinds/world/context-world.d.ts +1 -1
  267. package/dist/generate/kinds/world/context-world.d.ts.map +1 -1
  268. package/dist/generate/kinds/world/context-world.js +3 -1
  269. package/dist/generate/kinds/world/context-world.js.map +1 -1
  270. package/dist/generate/place-generated-files.d.ts +2 -0
  271. package/dist/generate/place-generated-files.d.ts.map +1 -1
  272. package/dist/generate/place-generated-files.js +13 -13
  273. package/dist/generate/place-generated-files.js.map +1 -1
  274. package/dist/generate/refresh-docs.d.ts +1 -1
  275. package/dist/generate/refresh-docs.d.ts.map +1 -1
  276. package/dist/generate/refresh-docs.js +3 -1
  277. package/dist/generate/refresh-docs.js.map +1 -1
  278. package/dist/generate/refuse-earlier-layout.d.ts +4 -3
  279. package/dist/generate/refuse-earlier-layout.d.ts.map +1 -1
  280. package/dist/generate/refuse-earlier-layout.js +9 -6
  281. package/dist/generate/refuse-earlier-layout.js.map +1 -1
  282. package/dist/help/flag-notes.d.ts.map +1 -1
  283. package/dist/help/flag-notes.js +8 -7
  284. package/dist/help/flag-notes.js.map +1 -1
  285. package/dist/help/tool-notes.d.ts.map +1 -1
  286. package/dist/help/tool-notes.js +23 -17
  287. package/dist/help/tool-notes.js.map +1 -1
  288. package/dist/help/usage.js +2 -2
  289. package/dist/help/work-notes.d.ts.map +1 -1
  290. package/dist/help/work-notes.js +4 -3
  291. package/dist/help/work-notes.js.map +1 -1
  292. package/dist/init/files/platform-files.d.ts.map +1 -1
  293. package/dist/init/files/platform-files.js +11 -0
  294. package/dist/init/files/platform-files.js.map +1 -1
  295. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  296. package/dist/init/manifest/dependencies-for.js +2 -0
  297. package/dist/init/manifest/dependencies-for.js.map +1 -1
  298. package/dist/init/manifest/versions.d.ts.map +1 -1
  299. package/dist/init/manifest/versions.js +25 -24
  300. package/dist/init/manifest/versions.js.map +1 -1
  301. package/dist/init/rewire-personal-data.d.ts.map +1 -1
  302. package/dist/init/rewire-personal-data.js +4 -2
  303. package/dist/init/rewire-personal-data.js.map +1 -1
  304. package/dist/init/rewire-tables.d.ts.map +1 -1
  305. package/dist/init/rewire-tables.js +4 -2
  306. package/dist/init/rewire-tables.js.map +1 -1
  307. package/dist/init/stack/resolve-operations.d.ts +12 -0
  308. package/dist/init/stack/resolve-operations.d.ts.map +1 -0
  309. package/dist/init/stack/resolve-operations.js +23 -0
  310. package/dist/init/stack/resolve-operations.js.map +1 -0
  311. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  312. package/dist/init/stack/resolve-stack.js +2 -19
  313. package/dist/init/stack/resolve-stack.js.map +1 -1
  314. package/dist/init/stack/stack-options.d.ts +2 -0
  315. package/dist/init/stack/stack-options.d.ts.map +1 -1
  316. package/dist/init/template-vars.d.ts.map +1 -1
  317. package/dist/init/template-vars.js +6 -4
  318. package/dist/init/template-vars.js.map +1 -1
  319. package/dist/init/with-held-imports.d.ts +9 -0
  320. package/dist/init/with-held-imports.d.ts.map +1 -0
  321. package/dist/init/with-held-imports.js +15 -0
  322. package/dist/init/with-held-imports.js.map +1 -0
  323. package/dist/knip/enter-module-test-folders.d.ts +10 -0
  324. package/dist/knip/enter-module-test-folders.d.ts.map +1 -0
  325. package/dist/knip/enter-module-test-folders.js +42 -0
  326. package/dist/knip/enter-module-test-folders.js.map +1 -0
  327. package/dist/knip/index.d.ts +1 -0
  328. package/dist/knip/index.d.ts.map +1 -1
  329. package/dist/knip/index.js +1 -0
  330. package/dist/knip/index.js.map +1 -1
  331. package/dist/lint/eslint-in-project.d.ts +1 -1
  332. package/dist/lint/eslint-in-project.d.ts.map +1 -1
  333. package/dist/lint/eslint-in-project.js +3 -2
  334. package/dist/lint/eslint-in-project.js.map +1 -1
  335. package/dist/lint/lint-run.d.ts +2 -0
  336. package/dist/lint/lint-run.d.ts.map +1 -1
  337. package/dist/merge/landed-commit.js +14 -2
  338. package/dist/merge/landed-commit.js.map +1 -1
  339. package/dist/merge/landed-point.js +3 -0
  340. package/dist/merge/landed-point.js.map +1 -1
  341. package/dist/merge/lost/dropped-additions.d.ts +20 -0
  342. package/dist/merge/lost/dropped-additions.d.ts.map +1 -0
  343. package/dist/merge/lost/dropped-additions.js +42 -0
  344. package/dist/merge/lost/dropped-additions.js.map +1 -0
  345. package/dist/merge/lost/expected-over.d.ts +13 -0
  346. package/dist/merge/lost/expected-over.d.ts.map +1 -0
  347. package/dist/merge/lost/expected-over.js +16 -0
  348. package/dist/merge/lost/expected-over.js.map +1 -0
  349. package/dist/merge/lost/kept-rows.d.ts +4 -2
  350. package/dist/merge/lost/kept-rows.d.ts.map +1 -1
  351. package/dist/merge/lost/kept-rows.js +10 -7
  352. package/dist/merge/lost/kept-rows.js.map +1 -1
  353. package/dist/merge/lost/lost-lines.d.ts +2 -2
  354. package/dist/merge/lost/lost-lines.d.ts.map +1 -1
  355. package/dist/merge/lost/lost-lines.js +5 -3
  356. package/dist/merge/lost/lost-lines.js.map +1 -1
  357. package/dist/merge/lost/lost-tests.d.ts +2 -2
  358. package/dist/merge/lost/lost-tests.d.ts.map +1 -1
  359. package/dist/merge/lost/lost-tests.js +5 -3
  360. package/dist/merge/lost/lost-tests.js.map +1 -1
  361. package/dist/merge/lost/verify-merge.d.ts.map +1 -1
  362. package/dist/merge/lost/verify-merge.js +12 -5
  363. package/dist/merge/lost/verify-merge.js.map +1 -1
  364. package/dist/merge/merge-trunk.d.ts.map +1 -1
  365. package/dist/merge/merge-trunk.js +35 -7
  366. package/dist/merge/merge-trunk.js.map +1 -1
  367. package/dist/merge/slices-from-fork.d.ts +20 -0
  368. package/dist/merge/slices-from-fork.d.ts.map +1 -0
  369. package/dist/merge/slices-from-fork.js +27 -0
  370. package/dist/merge/slices-from-fork.js.map +1 -0
  371. package/dist/merge/trunk-of.d.ts +4 -2
  372. package/dist/merge/trunk-of.d.ts.map +1 -1
  373. package/dist/merge/trunk-of.js +4 -2
  374. package/dist/merge/trunk-of.js.map +1 -1
  375. package/dist/migration/warn-dropped-context-tables.d.ts.map +1 -1
  376. package/dist/migration/warn-dropped-context-tables.js +6 -4
  377. package/dist/migration/warn-dropped-context-tables.js.map +1 -1
  378. package/dist/model-modules/context-level-folder-of.d.ts +9 -0
  379. package/dist/model-modules/context-level-folder-of.d.ts.map +1 -0
  380. package/dist/model-modules/context-level-folder-of.js +11 -0
  381. package/dist/model-modules/context-level-folder-of.js.map +1 -0
  382. package/dist/model-modules/earlier-folders.d.ts +10 -0
  383. package/dist/model-modules/earlier-folders.d.ts.map +1 -0
  384. package/dist/model-modules/earlier-folders.js +20 -0
  385. package/dist/model-modules/earlier-folders.js.map +1 -0
  386. package/dist/model-modules/folders-of-context.d.ts +8 -0
  387. package/dist/model-modules/folders-of-context.d.ts.map +1 -0
  388. package/dist/model-modules/folders-of-context.js +11 -0
  389. package/dist/model-modules/folders-of-context.js.map +1 -0
  390. package/dist/model-modules/held-file-of.d.ts +10 -0
  391. package/dist/model-modules/held-file-of.d.ts.map +1 -0
  392. package/dist/model-modules/held-file-of.js +18 -0
  393. package/dist/model-modules/held-file-of.js.map +1 -0
  394. package/dist/model-modules/index.d.ts +8 -1
  395. package/dist/model-modules/index.d.ts.map +1 -1
  396. package/dist/model-modules/index.js +8 -1
  397. package/dist/model-modules/index.js.map +1 -1
  398. package/dist/model-modules/into-module.d.ts +3 -3
  399. package/dist/model-modules/into-module.d.ts.map +1 -1
  400. package/dist/model-modules/into-module.js +9 -12
  401. package/dist/model-modules/into-module.js.map +1 -1
  402. package/dist/model-modules/is-context-level.d.ts +4 -5
  403. package/dist/model-modules/is-context-level.d.ts.map +1 -1
  404. package/dist/model-modules/is-context-level.js +6 -16
  405. package/dist/model-modules/is-context-level.js.map +1 -1
  406. package/dist/model-modules/is-held-by-shared.d.ts +8 -0
  407. package/dist/model-modules/is-held-by-shared.d.ts.map +1 -0
  408. package/dist/model-modules/is-held-by-shared.js +20 -0
  409. package/dist/model-modules/is-held-by-shared.js.map +1 -0
  410. package/dist/model-modules/module-layers.d.ts +9 -2
  411. package/dist/model-modules/module-layers.d.ts.map +1 -1
  412. package/dist/model-modules/module-layers.js +10 -3
  413. package/dist/model-modules/module-layers.js.map +1 -1
  414. package/dist/model-modules/module-name-flaw.d.ts +4 -1
  415. package/dist/model-modules/module-name-flaw.d.ts.map +1 -1
  416. package/dist/model-modules/module-name-flaw.js +6 -2
  417. package/dist/model-modules/module-name-flaw.js.map +1 -1
  418. package/dist/model-modules/module-placement.d.ts +8 -6
  419. package/dist/model-modules/module-placement.d.ts.map +1 -1
  420. package/dist/model-modules/module-placement.js +32 -30
  421. package/dist/model-modules/module-placement.js.map +1 -1
  422. package/dist/model-modules/module-split.d.ts +7 -5
  423. package/dist/model-modules/module-split.d.ts.map +1 -1
  424. package/dist/model-modules/module-split.js +18 -17
  425. package/dist/model-modules/module-split.js.map +1 -1
  426. package/dist/model-modules/module-test-folder-of.d.ts +8 -0
  427. package/dist/model-modules/module-test-folder-of.d.ts.map +1 -0
  428. package/dist/model-modules/module-test-folder-of.js +11 -0
  429. package/dist/model-modules/module-test-folder-of.js.map +1 -0
  430. package/dist/model-modules/role-folders-of.d.ts +5 -3
  431. package/dist/model-modules/role-folders-of.d.ts.map +1 -1
  432. package/dist/model-modules/role-folders-of.js +19 -11
  433. package/dist/model-modules/role-folders-of.js.map +1 -1
  434. package/dist/model-modules/role-folders.d.ts +1 -1
  435. package/dist/model-modules/role-folders.js +1 -1
  436. package/dist/model-modules/subject-module.d.ts +13 -0
  437. package/dist/model-modules/subject-module.d.ts.map +1 -0
  438. package/dist/model-modules/subject-module.js +34 -0
  439. package/dist/model-modules/subject-module.js.map +1 -0
  440. package/dist/move-to-module/moves-into-module.d.ts.map +1 -1
  441. package/dist/move-to-module/moves-into-module.js +29 -16
  442. package/dist/move-to-module/moves-into-module.js.map +1 -1
  443. package/dist/naming/plural.d.ts.map +1 -1
  444. package/dist/naming/plural.js +5 -0
  445. package/dist/naming/plural.js.map +1 -1
  446. package/dist/plan/format-plan.js +1 -1
  447. package/dist/plan/format-plan.js.map +1 -1
  448. package/dist/progress/build-next-of.d.ts.map +1 -1
  449. package/dist/progress/build-next-of.js +8 -3
  450. package/dist/progress/build-next-of.js.map +1 -1
  451. package/dist/refusals/apply-plan.d.ts.map +1 -1
  452. package/dist/refusals/apply-plan.js +8 -4
  453. package/dist/refusals/apply-plan.js.map +1 -1
  454. package/dist/refusals/move-named-specs.d.ts.map +1 -1
  455. package/dist/refusals/move-named-specs.js +7 -4
  456. package/dist/refusals/move-named-specs.js.map +1 -1
  457. package/dist/refusals/unit-folder-of.d.ts +9 -0
  458. package/dist/refusals/unit-folder-of.d.ts.map +1 -0
  459. package/dist/refusals/unit-folder-of.js +15 -0
  460. package/dist/refusals/unit-folder-of.js.map +1 -0
  461. package/dist/slice/plan-staging.d.ts +2 -1
  462. package/dist/slice/plan-staging.d.ts.map +1 -1
  463. package/dist/slice/plan-staging.js +3 -1
  464. package/dist/slice/plan-staging.js.map +1 -1
  465. package/dist/stack/declares-roles.d.ts +8 -0
  466. package/dist/stack/declares-roles.d.ts.map +1 -0
  467. package/dist/stack/declares-roles.js +11 -0
  468. package/dist/stack/declares-roles.js.map +1 -0
  469. package/dist/stack/stack-vars.d.ts.map +1 -1
  470. package/dist/stack/stack-vars.js +7 -4
  471. package/dist/stack/stack-vars.js.map +1 -1
  472. package/dist/version.d.ts +1 -1
  473. package/dist/version.js +1 -1
  474. package/dist/worker/progress-of.js +12 -1
  475. package/dist/worker/progress-of.js.map +1 -1
  476. package/dist/worker/row-commits.js +7 -1
  477. package/dist/worker/row-commits.js.map +1 -1
  478. package/package.json +6 -5
  479. package/templates/command/handler.spec.buses.ts.tpl +4 -1
  480. package/templates/command/handler.spec.container.ts.tpl +6 -1
  481. package/templates/controller/controller.spec.ts.tpl +4 -1
  482. package/templates/controller/guard.spec.ts.tpl +2 -2
  483. package/templates/controller/guard.ts.tpl +2 -1
  484. package/templates/e2e/e2e.spec.ts.tpl +5 -2
  485. package/templates/error/codes-import.ts.tpl +1 -0
  486. package/templates/error/refusal-case.spec.ts.tpl +1 -1
  487. package/templates/error/refusal.spec.ts.tpl +1 -0
  488. package/templates/file-upload/handler.spec.ts.tpl +4 -1
  489. package/templates/init/README.md.tpl +20 -0
  490. package/templates/init/docker/docker-compose.yml.tpl +24 -0
  491. package/templates/init/docker/env.example.tpl +9 -0
  492. package/templates/init/e2e/create-credentials.jwt.ts.tpl +13 -0
  493. package/templates/init/e2e/create-credentials.keycloak.ts.tpl +13 -0
  494. package/templates/init/e2e/create-credentials.none.ts.tpl +13 -0
  495. package/templates/init/e2e/create-credentials.passport.ts.tpl +13 -0
  496. package/templates/init/e2e/test-environment.ts.tpl +4 -0
  497. package/templates/init/main.ts.tpl +3 -0
  498. package/templates/init/platform/audit/search-audit-entries/search-audit-entries.controller.ts.tpl +2 -2
  499. package/templates/init/platform/audit/search-audit-entries/search-audit-entries.route.ts.tpl +2 -2
  500. package/templates/init/platform/composition/compose-application.container.ts.tpl +13 -0
  501. package/templates/init/platform/composition/compose-application.manual.ts.tpl +4 -0
  502. package/templates/init/platform/composition/create-platform.manual.ts.tpl +14 -4
  503. package/templates/init/platform/composition/lay-foundations.container.ts.tpl +30 -0
  504. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +11 -0
  505. package/templates/init/platform/composition/platform-options.manual.ts.tpl +7 -0
  506. package/templates/init/platform/composition/platform.manual.ts.tpl +7 -0
  507. package/templates/init/platform/config/app-config.ts.tpl +13 -0
  508. package/templates/init/platform/config/load-config.ts.tpl +38 -3
  509. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +8 -2
  510. package/templates/init/platform/search/open-search.ts.tpl +88 -0
  511. package/templates/init/platform/search/provisioned-indexes.ts.tpl +134 -0
  512. package/templates/init/platform/search/search-indexes.ts.tpl +23 -0
  513. package/templates/init/platform/search/search-name-taken-error.ts.tpl +10 -0
  514. package/templates/init/platform/search/search.module.container.ts.tpl +17 -0
  515. package/templates/init/platform/search/store-index.ts.tpl +49 -0
  516. package/templates/init/rules/infrastructure.md.tpl +3 -0
  517. package/templates/init/rules/platform.md.tpl +3 -0
  518. package/templates/init/rules/presentation.md.tpl +2 -2
  519. package/templates/init/rules/tests.md.tpl +1 -0
  520. package/templates/init/scripts/privacy-erase.container.ts.tpl +9 -0
  521. package/templates/init/scripts/privacy-erase.manual.ts.tpl +9 -0
  522. package/templates/init/scripts/privacy-export.container.ts.tpl +9 -0
  523. package/templates/init/scripts/privacy-export.manual.ts.tpl +9 -0
  524. package/templates/init/scripts/privacy-purge.container.ts.tpl +9 -0
  525. package/templates/init/scripts/privacy-purge.manual.ts.tpl +9 -0
  526. package/templates/nest-controller/controller.spec.ts.tpl +4 -1
  527. package/templates/pipeline/biome.json.tpl +1 -1
  528. package/templates/pipeline/jest.mutation.config.js.tpl +1 -1
  529. package/templates/pipeline/knip.json.tpl +2 -0
  530. package/templates/pipeline/package-scripts.json +2 -2
  531. package/templates/pipeline/vitest.config.ts.tpl +11 -6
  532. package/templates/pipeline/vitest.mutation.config.ts.tpl +1 -1
  533. package/templates/presets/identity/context/presentation/http/accounts.routes.ts.tpl +2 -1
  534. package/templates/presets/identity/context/presentation/http/invitations.routes.ts.tpl +2 -1
  535. package/templates/presets/identity/context/presentation/http/organisations.routes.ts.tpl +2 -1
  536. package/templates/presets/identity/context/test/unit/change-member-role.handler.spec.ts.tpl +2 -1
  537. package/templates/presets/identity/context/test/unit/deactivate-account.handler.spec.ts.tpl +4 -4
  538. package/templates/presets/identity/context/test/unit/grant-delegation.handler.spec.ts.tpl +2 -1
  539. package/templates/presets/identity/context/test/unit/invite-member.handler.spec.ts.tpl +3 -3
  540. package/templates/presets/identity/context/test/unit/provision-account.handler.spec.ts.tpl +2 -1
  541. package/templates/presets/identity/context/test/unit/remove-member.handler.spec.ts.tpl +2 -1
  542. package/templates/presets/identity/context/test/unit/revoke-delegation.handler.spec.ts.tpl +2 -1
  543. package/templates/presets/identity/context/test/unit/revoke-invitation.handler.spec.ts.tpl +2 -1
  544. package/templates/presets/identity/context/test/unit/search-members.handler.spec.ts.tpl +2 -2
  545. package/templates/query/handler.spec.buses.ts.tpl +4 -1
  546. package/templates/query/handler.spec.container.ts.tpl +6 -1
  547. package/templates/query/search.handler.spec.buses.ts.tpl +2 -2
  548. package/templates/query/search.handler.spec.container.ts.tpl +2 -2
  549. package/templates/query/search.reader.spec.ts.tpl +2 -2
  550. package/templates/route/route.class-validator.ts.tpl +5 -0
  551. package/templates/route/route.none.ts.tpl +6 -1
  552. package/templates/route/route.search.ts.tpl +3 -3
  553. package/templates/route/route.spec.ts.tpl +4 -1
  554. package/templates/route/route.standard-schema.ts.tpl +5 -0
  555. package/templates/route/route.typebox.ts.tpl +5 -0
  556. package/templates/route/route.zod.ts.tpl +5 -0
  557. package/templates/service/main.ts.tpl +3 -0
  558. package/templates/value-object/value-object.spec.ts.tpl +6 -3
  559. package/templates/worker/main.ts.tpl +3 -0
@@ -30,6 +30,10 @@ export function testEnvironment(overrides: Variables = {}): Variables {
30
30
  VARNISH_URL: (process.env['VARNISH_URL'] ?? '') || 'http://varnish.e2e.test',
31
31
  VARNISH_PURGE_KEY: (process.env['VARNISH_PURGE_KEY'] ?? '') || 'e2e-purge-key',
32
32
  {{/if}}
33
+ {{#if search.opensearch}}
34
+ // The configuration asks for a node; the application of the tests is given none, so no store reaches it.
35
+ OPENSEARCH_URL: (process.env['OPENSEARCH_URL'] ?? '') || 'http://localhost:9200',
36
+ {{/if}}
33
37
  {{#if cache.rateLimit}}
34
38
  RATE_LIMIT_MAX: process.env['RATE_LIMIT_MAX'] ?? '1000000',
35
39
  {{/if}}
@@ -66,6 +66,9 @@ const application = composeApplication(
66
66
  {{#if files.any}}
67
67
  files: openFiles(config.files),
68
68
  {{/if}}
69
+ {{#if search.opensearch}}
70
+ search: config.search,
71
+ {{/if}}
69
72
  },
70
73
  hostedContexts,
71
74
  );
@@ -7,7 +7,7 @@ import {
7
7
  type HttpRequest,
8
8
  type PageBody,
9
9
  } from '@ddd-ts-kit/http';
10
- import type { QueryBus } from '@ddd-ts-kit/kernel';
10
+ import { KitCodes, type QueryBus } from '@ddd-ts-kit/kernel';
11
11
  import { auditEntriesFilterOf } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-filter-of{{alias.ext}}';
12
12
  import {
13
13
  auditEntriesParameters,
@@ -27,7 +27,7 @@ import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-e
27
27
  guards: [Authenticated],
28
28
  query: auditEntriesParameters,
29
29
  response: { status: 200, description: 'A page of entries.', body: pageSchemaOf(auditEntrySchema) },
30
- errors: ['FORBIDDEN'],
30
+ errors: [KitCodes.Forbidden],
31
31
  })
32
32
  export class SearchAuditEntriesController {
33
33
  constructor(private readonly queries: QueryBus) {}
@@ -1,6 +1,6 @@
1
1
  import { actorOf } from '@ddd-ts-kit/auth';
2
2
  import { defineRoute, pageRequestFrom, pageResponse, pageSchemaOf, type Route } from '@ddd-ts-kit/http';
3
- import type { QueryBus } from '@ddd-ts-kit/kernel';
3
+ import { KitCodes, type QueryBus } from '@ddd-ts-kit/kernel';
4
4
  import { auditEntriesFilterOf } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-filter-of{{alias.ext}}';
5
5
  import { auditEntriesParameters, auditPageLimits } from '{{alias.platform}}/audit/search-audit-entries/audit-entries-parameters{{alias.ext}}';
6
6
  import { auditEntrySchema } from '{{alias.platform}}/audit/search-audit-entries/audit-entry-view{{alias.ext}}';
@@ -18,7 +18,7 @@ export function searchAuditEntriesRoute(queries: QueryBus): Route {
18
18
  tags: ['audit'],
19
19
  request: { query: auditEntriesParameters },
20
20
  responses: { 200: { description: 'A page of entries.', body: pageSchemaOf(auditEntrySchema) } },
21
- errors: ['UNAUTHORIZED', 'FORBIDDEN'],
21
+ errors: [KitCodes.Unauthorized, KitCodes.Forbidden],
22
22
  security: ['{{authn.scheme}}'],
23
23
  },
24
24
  async (input) => {
@@ -73,6 +73,9 @@ import { relateSystemActors } from '{{alias.platform}}/auth/relationships/relate
73
73
  {{/if}}
74
74
  import { createCommandBus } from '{{alias.platform}}/buses/create-command-bus{{alias.ext}}';
75
75
  import { createQueryBus } from '{{alias.platform}}/buses/create-query-bus{{alias.ext}}';
76
+ {{#if search.opensearch}}
77
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
78
+ {{/if}}
76
79
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
77
80
  {{#if eventSourcing.on}}
78
81
  import { eventSourcingModule } from '{{alias.platform}}/event-sourcing/event-sourcing.module{{alias.ext}}';
@@ -87,6 +90,9 @@ import { filesModule } from '{{alias.platform}}/files/files.module{{alias.ext}}'
87
90
  import { DEFAULT_HOUSEKEEPING } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
88
91
  import { housekeepingModule } from '{{alias.platform}}/jobs/housekeeping.module{{alias.ext}}';
89
92
  {{/if}}
93
+ {{#if search.opensearch}}
94
+ import { searchModule } from '{{alias.platform}}/search/search.module{{alias.ext}}';
95
+ {{/if}}
90
96
  {{#if privacy.on}}
91
97
  import { privacyModule } from '{{alias.platform}}/privacy/privacy.module{{alias.ext}}';
92
98
  {{/if}}
@@ -115,6 +121,10 @@ export interface ApplicationOptions extends PlatformOptions {
115
121
  /** Where the content of files lives: the storage of `main.ts`; left out (the tools, the tests), the memory of the process. */
116
122
  readonly files?: FileStorage;
117
123
  {{/if}}
124
+ {{#if search.opensearch}}
125
+ /** Where the read models of OpenSearch live: the configuration of `main.ts`; left out (the tools, the tests), no node, and a store built then is refused at its first request. */
126
+ readonly search?: AppConfig['search'];
127
+ {{/if}}
118
128
  }
119
129
 
120
130
  export interface Application {
@@ -220,6 +230,9 @@ export function composeApplication(
220
230
  {{#if files.any}}
221
231
  filesModule(options.files ?? new InMemoryFileStorage(), { jobs: options.platformJobs !== false }),
222
232
  {{/if}}
233
+ {{#if search.opensearch}}
234
+ searchModule(foundations.search),
235
+ {{/if}}
223
236
  {{#if privacy.on}}
224
237
  privacyModule({ jobs: options.platformJobs !== false }),
225
238
  {{/if}}
@@ -289,6 +289,10 @@ async function start(platform: Platform, options: ApplicationOptions): Promise<v
289
289
  {{#unless broker.external}}
290
290
  subscribeAll(platform.subscriber, platform.audit.subscriptions);
291
291
  {{/unless}}
292
+ {{/if}}
293
+ {{#if search.opensearch}}
294
+ // The index of every read model of OpenSearch the contexts built, before an event reaches its projection.
295
+ await platform.search.provision();
292
296
  {{/if}}
293
297
  await options.events.start();
294
298
 
@@ -11,6 +11,7 @@ import {
11
11
  dispatchingOnSave,
12
12
  reportAfterCommitFailures,
13
13
  type DomainEventDispatcher,
14
+ type ExecutionScope,
14
15
  } from '@ddd-ts-kit/kernel';
15
16
  import type { TracedApplication } from '@ddd-ts-kit/tracing';
16
17
  import { accessPolicies } from '{{alias.platform}}/auth/authorization/access-policies{{alias.ext}}';
@@ -62,7 +63,7 @@ export function createPlatform(persistence: Persistence, options: PlatformOption
62
63
  const domainEvents = traced.domainEvents(new InMemoryDomainEventDispatcher(afterCommitFailed));
63
64
  const authorizer = createAuthorizer();
64
65
  const protection = new UseCaseProtection(authorizer, onDecision);
65
- const adapter = adapterOf(options.resilience ?? defaultResilienceSettings, { traced, domainEvents });
66
+ const adapter = adapterOf(options.resilience ?? defaultResilienceSettings, { traced, domainEvents, scope });
66
67
  {{#if files.any}}
67
68
  const files = filesOf(options, foundations);
68
69
  {{/if}}
@@ -103,19 +104,28 @@ function filesOf(options: PlatformOptions, foundations: Foundations): Files {
103
104
  interface Outside {
104
105
  readonly traced: TracedApplication;
105
106
  readonly domainEvents: DomainEventDispatcher;
107
+ readonly scope: ExecutionScope;
106
108
  }
107
109
 
108
110
  /**
109
111
  * Around every adapter, outermost first: its span, for a repository the dispatch of the domain
110
- * events of what it saves (handlers only save), then the retries and the time limit of what
112
+ * events of what it saves (handlers only save, and run in the execution context of the save), then the retries and the time limit of what
111
113
  * leaves the process.
112
114
  */
113
- function adapterOf(settings: ResilienceSettings, { traced, domainEvents }: Outside): Platform['adapter'] {
115
+ function adapterOf(settings: ResilienceSettings, { traced, domainEvents, scope }: Outside): Platform['adapter'] {
114
116
  const governed = defaultPolicy(settings);
115
117
 
116
118
  return (instance, info) => {
117
119
  const resilient = governed(instance, info);
118
- const saving = info.kind === 'repository' ? dispatchingOnSave(resilient, () => domainEvents) : resilient;
120
+
121
+ const saving =
122
+ info.kind === 'repository'
123
+ ? dispatchingOnSave(
124
+ resilient,
125
+ () => domainEvents,
126
+ () => scope,
127
+ )
128
+ : resilient;
119
129
 
120
130
  return traced.binding(saving, { ...info, context: info.context ?? 'platform' });
121
131
  };
@@ -18,12 +18,22 @@ import { createAudit, type Audit } from '{{alias.platform}}/audit/create-audit{{
18
18
  {{#unless audit.on}}
19
19
  import { logDecisions } from '{{alias.platform}}/auth/authorization/log-decisions{{alias.ext}}';
20
20
  {{/unless}}
21
+ {{#if search.opensearch}}
22
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
23
+ {{/if}}
21
24
  import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
22
25
  {{#if eventSourcing.on}}
23
26
  import { createEventSourcing, type EventSourcing } from '{{alias.platform}}/event-sourcing/create-event-sourcing{{alias.ext}}';
24
27
  {{/if}}
25
28
  import { createLogger, type LogSettings } from '{{alias.platform}}/observability/create-logger{{alias.ext}}';
26
29
  import { createMetrics } from '{{alias.platform}}/observability/create-metrics{{alias.ext}}';
30
+ {{#if search.opensearch}}
31
+ {{#if tenancy.any}}
32
+ import { tenantDirectory } from '{{alias.platform}}/composition/tenant-directory{{alias.ext}}';
33
+ {{/if}}
34
+ import { openSearch } from '{{alias.platform}}/search/open-search{{alias.ext}}';
35
+ import type { SearchIndexes } from '{{alias.platform}}/search/search-indexes{{alias.ext}}';
36
+ {{/if}}
27
37
 
28
38
  /**
29
39
  * What exists before any module: built once and handed to the kernel module, so that the buses,
@@ -49,6 +59,10 @@ export interface Foundations {
49
59
  /** The event store, the keys of the data subjects{{#if audit.on}}, audited,{{/if}} and the cipher of the personal values of the stored events. */
50
60
  readonly eventSourcing: EventSourcing;
51
61
  {{/if}}
62
+ {{#if search.opensearch}}
63
+ /** The read models of OpenSearch, with the transport and the tenancy of the platform: what the adapter of a read model port is built from. */
64
+ readonly search: SearchIndexes;
65
+ {{/if}}
52
66
  }
53
67
 
54
68
  interface Observed {
@@ -56,6 +70,14 @@ interface Observed {
56
70
  readonly log?: LogSettings;
57
71
  /** Whether a consumed event continues the trace of its publication (the default) or starts one linked to it. */
58
72
  readonly traceConsumers?: ConsumerTrace;
73
+ {{#if search.opensearch}}
74
+ /** Where the read models of OpenSearch live: the configuration in `main.ts`; left out (the tools, the tests), no node. */
75
+ readonly search?: AppConfig['search'];
76
+ {{#if tenancy.any}}
77
+ /** The tenants whose read models are provisioned. */
78
+ readonly tenants?: readonly string[];
79
+ {{/if}}
80
+ {{/if}}
59
81
  }
60
82
 
61
83
  export function layFoundations(persistence: Persistence, options: Observed): Foundations {
@@ -74,6 +96,14 @@ export function layFoundations(persistence: Persistence, options: Observed): Fou
74
96
  logger,
75
97
  metrics: createMetrics(),
76
98
  traced: traceApplication({ consumers: options.traceConsumers ?? 'continue' }),
99
+ {{#if search.opensearch}}
100
+ {{#if tenancy.any}}
101
+ search: openSearch(options.search, { logger, scope, directory: tenantDirectory(persistence, options.tenants) }),
102
+ {{/if}}
103
+ {{#unless tenancy.any}}
104
+ search: openSearch(options.search, { logger }),
105
+ {{/unless}}
106
+ {{/if}}
77
107
  {{#if audit.on}}
78
108
  audit,
79
109
  {{#if eventSourcing.on}}
@@ -40,6 +40,9 @@ import { createEventSourcing } from '{{alias.platform}}/event-sourcing/create-ev
40
40
  import { ConfiguredJobScheduler } from '{{alias.platform}}/jobs/configured-job-scheduler{{alias.ext}}';
41
41
  import { createLogger } from '{{alias.platform}}/observability/create-logger{{alias.ext}}';
42
42
  import { createMetrics } from '{{alias.platform}}/observability/create-metrics{{alias.ext}}';
43
+ {{#if search.opensearch}}
44
+ import { openSearch } from '{{alias.platform}}/search/open-search{{alias.ext}}';
45
+ {{/if}}
43
46
 
44
47
  {{foundations.founded}}
45
48
 
@@ -109,6 +112,14 @@ export function layFoundations(persistence: Persistence, options: PlatformOption
109
112
  {{#if cache.rateLimit}}
110
113
  rateLimiter: options.redis?.rateLimiter ?? new InMemoryRateLimiter(clock),
111
114
  {{/if}}
115
+ {{#if search.opensearch}}
116
+ {{#if tenancy.any}}
117
+ search: openSearch(options.search, { logger, scope, directory: parts.tenants }),
118
+ {{/if}}
119
+ {{#unless tenancy.any}}
120
+ search: openSearch(options.search, { logger }),
121
+ {{/unless}}
122
+ {{/if}}
112
123
  {{#if errors.none}}
113
124
  jobs: schedulerOf(options, traced, parts),
114
125
  {{/if}}
@@ -16,6 +16,9 @@ import type { JobSettings } from '@ddd-ts-kit/kernel';
16
16
  {{/unless}}
17
17
  import type { QueueWorkerOptions } from '@ddd-ts-kit/scheduling';
18
18
  import type { ConsumerTrace } from '@ddd-ts-kit/tracing';
19
+ {{#if search.opensearch}}
20
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
21
+ {{/if}}
19
22
  import type { EventProvider } from '{{alias.platform}}/events/event-provider{{alias.ext}}';
20
23
  {{#if housekeeping.any}}
21
24
  import type { Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
@@ -71,4 +74,8 @@ export interface PlatformOptions {
71
74
  /** Where the content of files lives: the storage of `main.ts`; left out (the tools, the tests), the memory of the process. */
72
75
  readonly files?: FileStorage;
73
76
  {{/if}}
77
+ {{#if search.opensearch}}
78
+ /** Where the read models of OpenSearch live: the configuration of `main.ts`; left out (the tools, the tests), no node, and a store built then is refused at its first request. */
79
+ readonly search?: AppConfig['search'];
80
+ {{/if}}
74
81
  }
@@ -41,6 +41,9 @@ import type { EventSourcing } from '{{alias.platform}}/event-sourcing/create-eve
41
41
  import type { Files } from '{{alias.platform}}/files/create-files{{alias.ext}}';
42
42
  {{/if}}
43
43
  import type { BackgroundJobs } from '{{alias.platform}}/jobs/background-jobs{{alias.ext}}';
44
+ {{#if search.opensearch}}
45
+ import type { SearchIndexes } from '{{alias.platform}}/search/search-indexes{{alias.ext}}';
46
+ {{/if}}
44
47
 
45
48
  /** Wraps an adapter from outside: a span for its kind and, for what leaves the process, the default policy unless it states its own. */
46
49
  type Adapt = <T extends object>(instance: T, info: AspectInfo) => T;
@@ -115,4 +118,8 @@ export interface Platform {
115
118
  /** Where files live, the keys they are stored under and the staging that keeps them consistent with the database: never their content in a table. */
116
119
  readonly files: Files;
117
120
  {{/if}}
121
+ {{#if search.opensearch}}
122
+ /** The read models of OpenSearch, with the transport and the tenancy of the platform: what the adapter of a read model port is built from. */
123
+ readonly search: SearchIndexes;
124
+ {{/if}}
118
125
  }
@@ -100,6 +100,10 @@ export interface AppConfig {
100
100
  /** Where the content of files lives (`files/open-files.ts`), never in the database. */
101
101
  readonly files: FilesConfig;
102
102
  {{/if}}
103
+ {{#if search.opensearch}}
104
+ /** Where the read models of OpenSearch live (`search/open-search.ts`): a copy for search, never the source of truth. */
105
+ readonly search: SearchConfig;
106
+ {{/if}}
103
107
  }
104
108
 
105
109
  /** `LOG_LEVEL`, `LOG_FORMAT` and `LOG_SCRUB_MESSAGES`. */
@@ -137,6 +141,15 @@ interface KeycloakConfig {
137
141
  readonly clientId?: string;
138
142
  }
139
143
  {{/if}}
144
+ {{#if search.opensearch}}
145
+
146
+ /** `OPENSEARCH_URL`, and `OPENSEARCH_USERNAME` with `OPENSEARCH_PASSWORD` when the security plugin asks for a user (both or neither). */
147
+ interface SearchConfig {
148
+ readonly node: string;
149
+ readonly username?: string;
150
+ readonly password?: string;
151
+ }
152
+ {{/if}}
140
153
  {{#if authn.jwks}}
141
154
 
142
155
  /** Where tokens come from and whom they are for: the issuer, the audience this service answers to, the keys of the issuer. */
@@ -55,9 +55,7 @@ export function loadConfig(variables: Variables): AppConfig {
55
55
  {{/if}}
56
56
 
57
57
  const config: AppConfig = {
58
- serviceName: env.optional('OTEL_SERVICE_NAME') ?? '{{project.name}}',
59
- deploymentName: env.optional('DEPLOYMENT_NAME') ?? '{{project.name}}',
60
- serviceVersion: env.optional('SERVICE_VERSION') ?? '0.0.0',
58
+ ...readIdentity(env),
61
59
  environment,
62
60
  port: env.integer('PORT', { fallback: 3000, min: 0, max: 65535 }),
63
61
  log: readLog(env),
@@ -120,6 +118,9 @@ export function loadConfig(variables: Variables): AppConfig {
120
118
  {{#if files.s3}}
121
119
  files: readFiles(env),
122
120
  {{/if}}
121
+ {{#if search.opensearch}}
122
+ search: readSearch(env),
123
+ {{/if}}
123
124
  };
124
125
 
125
126
  env.assertValid();
@@ -127,6 +128,15 @@ export function loadConfig(variables: Variables): AppConfig {
127
128
  return config;
128
129
  }
129
130
 
131
+ /** What this process is called, in its deployment and in its version. */
132
+ function readIdentity(env: Environment): Pick<AppConfig, 'serviceName' | 'deploymentName' | 'serviceVersion'> {
133
+ return {
134
+ serviceName: env.optional('OTEL_SERVICE_NAME') ?? '{{project.name}}',
135
+ deploymentName: env.optional('DEPLOYMENT_NAME') ?? '{{project.name}}',
136
+ serviceVersion: env.optional('SERVICE_VERSION') ?? '0.0.0',
137
+ };
138
+ }
139
+
130
140
  {{#if authn.none}}
131
141
  /** The development header is believed where NODE_ENV says so, never by default. */
132
142
  function requireEnvironmentForTheDevelopmentHeader(env: Environment): void {
@@ -191,6 +201,13 @@ function readTenants(env: Environment): readonly string[] {
191
201
  if (!tenants.every(isTenantId)) {
192
202
  env.problem('TENANTS must list tenant ids: letters, digits, _ and -, at most 63 characters each');
193
203
  }
204
+ {{#if search.opensearch}}
205
+
206
+ // A tenant is part of the name of its search index, which OpenSearch keeps in lower case.
207
+ if (tenants.some((tenant) => tenant !== tenant.toLowerCase())) {
208
+ env.problem('TENANTS must be lower case: each tenant names a search index of OpenSearch');
209
+ }
210
+ {{/if}}
194
211
 
195
212
  return tenants;
196
213
  }
@@ -220,6 +237,24 @@ function readLogFormat(env: Environment): AppConfig['log']['format'] {
220
237
  }
221
238
  {{/if}}
222
239
 
240
+ {{#if search.opensearch}}
241
+ /** The node of OpenSearch, and the user of its security plugin: both or neither. */
242
+ function readSearch(env: Environment): AppConfig['search'] {
243
+ const username = env.optional('OPENSEARCH_USERNAME');
244
+ const password = env.optional('OPENSEARCH_PASSWORD');
245
+
246
+ if ((username === undefined) !== (password === undefined)) {
247
+ env.problem('OPENSEARCH_USERNAME and OPENSEARCH_PASSWORD must be set together, or neither');
248
+ }
249
+
250
+ return {
251
+ node: env.url('OPENSEARCH_URL'),
252
+ ...(username === undefined ? {} : { username }),
253
+ ...(password === undefined ? {} : { password }),
254
+ };
255
+ }
256
+
257
+ {{/if}}
223
258
  function readResilience(env: Environment): AppConfig['resilience'] {
224
259
  return {
225
260
  retryAttempts: env.integer('OUTBOUND_RETRY_ATTEMPTS', { fallback: 3, min: 1, max: 10 }),
@@ -65,9 +65,15 @@ export async function startHttpServer(served: Served, config: AppConfig): Promis
65
65
  {{/if}}
66
66
  await app.listen({ port: config.port, host: '0.0.0.0' });
67
67
 
68
- const [address] = app.addresses();
68
+ return { port: boundPort(app.addresses()), close: () => app.close() };
69
+ }
70
+
71
+ // A server bound to a pipe gives its path, a string, where one bound to a port gives the port.
72
+ function boundPort(addresses: readonly unknown[]): number {
73
+ const [address] = addresses;
74
+ const port: unknown = typeof address === 'object' && address !== null && 'port' in address ? address.port : 0;
69
75
 
70
- return { port: address?.port ?? 0, close: () => app.close() };
76
+ return typeof port === 'number' ? port : 0;
71
77
  }
72
78
 
73
79
  /** TRUST_PROXY as Fastify takes it: a number of hops as the test of each hop. */
@@ -0,0 +1,88 @@
1
+ {{#if tenancy.any}}
2
+ import type { ExecutionScope, Logger, TenantDirectory } from '@ddd-ts-kit/kernel';
3
+ {{/if}}
4
+ {{#unless tenancy.any}}
5
+ import type { Logger } from '@ddd-ts-kit/kernel';
6
+ {{/unless}}
7
+ import {
8
+ OpenSearchUnavailableError,
9
+ fetchTransport,
10
+ type FetchTransportOptions,
11
+ type OpenSearchTransport,
12
+ } from '@ddd-ts-kit/opensearch';
13
+ import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
14
+ import { ProvisionedIndexes } from '{{alias.platform}}/search/provisioned-indexes{{alias.ext}}';
15
+ import type { SearchIndexes } from '{{alias.platform}}/search/search-indexes{{alias.ext}}';
16
+
17
+ /** What the read models of OpenSearch are built on: the logger of the platform{{#if tenancy.any}}, the tenant of the work and the tenants that exist{{/if}}. */
18
+ interface Grounds {
19
+ /** Where a provisioning of the start that failed is told, as a warning: the start goes on. */
20
+ readonly logger: Logger;
21
+ {{#if tenancy.any}}
22
+ readonly scope: ExecutionScope;
23
+ /** The tenants that exist, the same directory the jobs read: only a tenant it lists is ever provisioned. */
24
+ readonly directory: TenantDirectory;
25
+ {{/if}}
26
+ }
27
+
28
+ /** No node, for the tools and the tests that give none: the start provisions nothing, and a store is refused at its first request. */
29
+ const NO_NODE: OpenSearchTransport = {
30
+ request: ({ method, path }) =>
31
+ Promise.reject(
32
+ new OpenSearchUnavailableError(method, path, { cause: new Error('no OpenSearch node: pass `search` to the application') }),
33
+ ),
34
+ };
35
+
36
+ /**
37
+ * The read models of OpenSearch on the node of `config.search` (`OPENSEARCH_URL`); left out,
38
+ * none.
39
+ {{#if tenancy.any}}
40
+ * Shared tables keep the tenants of a store in one index, each document holding its
41
+ * tenant and each tenant read through a filtered alias: `{ strategy: 'attribute', scope }`. For
42
+ * an index per tenant (a tenant whose data must stay apart, dropped with its index when it leaves),
43
+ * write `{ strategy: 'index', scope }` instead.
44
+ {{/if}}
45
+ {{#unless tenancy.any}}
46
+ * Without tenancy a store is one index: `{ strategy: 'none' }`. Once the project has tenants
47
+ * (`init --force --tenancy shared-table`), this file keeps them apart.
48
+ {{/unless}}
49
+ */
50
+ {{#if tenancy.any}}
51
+ export function openSearch(config: AppConfig['search'] | undefined, { logger, scope, directory }: Grounds): SearchIndexes {
52
+ return new ProvisionedIndexes({
53
+ transport: transportOf(config),
54
+ tenancy: { strategy: 'attribute', scope },
55
+ logger,
56
+ reachable: config !== undefined,
57
+ tenants: { ofWork: () => tenantOfWork(scope), listed: () => directory.tenants() },
58
+ });
59
+ }
60
+ {{/if}}
61
+ {{#unless tenancy.any}}
62
+ export function openSearch(config: AppConfig['search'] | undefined, { logger }: Grounds): SearchIndexes {
63
+ return new ProvisionedIndexes({
64
+ transport: transportOf(config),
65
+ tenancy: { strategy: 'none' },
66
+ logger,
67
+ reachable: config !== undefined,
68
+ });
69
+ }
70
+ {{/unless}}
71
+
72
+ function transportOf(config: AppConfig['search'] | undefined): OpenSearchTransport {
73
+ return config === undefined ? NO_NODE : fetchTransport({ node: config.node, ...authOf(config) });
74
+ }
75
+
76
+ /** The user of the security plugin, when the configuration names one. */
77
+ function authOf({ username, password }: AppConfig['search']): Pick<FetchTransportOptions, 'auth'> {
78
+ return username === undefined || password === undefined ? {} : { auth: { username, password } };
79
+ }
80
+ {{#if tenancy.any}}
81
+
82
+ /** The tenant a request is provisioned for: none for work with no tenant, nor under an elevation, which reads across tenants. */
83
+ function tenantOfWork(scope: ExecutionScope): string | undefined {
84
+ const work = scope.current();
85
+
86
+ return work?.elevation === undefined ? work?.tenantId : undefined;
87
+ }
88
+ {{/if}}
@@ -0,0 +1,134 @@
1
+ import type { CriteriaDefinition, Logger } from '@ddd-ts-kit/kernel';
2
+ import {
3
+ OpenSearchReadModelStore,
4
+ type OpenSearchReadModelOptions,
5
+ type OpenSearchTenancy,
6
+ type OpenSearchTransport,
7
+ } from '@ddd-ts-kit/opensearch';
8
+ import { SearchIndexes, type SearchStoreSettings } from '{{alias.platform}}/search/search-indexes{{alias.ext}}';
9
+ import { SearchNameTakenError } from '{{alias.platform}}/search/search-name-taken-error{{alias.ext}}';
10
+ import { StoreIndex } from '{{alias.platform}}/search/store-index{{alias.ext}}';
11
+
12
+ /** The tenants a store is provisioned for, under a tenant strategy. */
13
+ interface Tenants {
14
+ /** The tenant of the work a request is sent for; none for work with no tenant or under an elevation. */
15
+ readonly ofWork: () => string | undefined;
16
+ /** The tenants that exist: a tenant it does not list is never provisioned, and its store refuses it. */
17
+ readonly listed: () => Promise<readonly string[]>;
18
+ }
19
+
20
+ /** What every store is built and provisioned with. */
21
+ interface IndexSettings {
22
+ readonly transport: OpenSearchTransport;
23
+ readonly tenancy: OpenSearchTenancy;
24
+ readonly logger: Logger;
25
+ /** `false` without a node: the start provisions nothing, and the transport refuses each request. */
26
+ readonly reachable: boolean;
27
+ /** Left out without tenancy: the index of a store is then provisioned once, by `ensureMapping`. */
28
+ readonly tenants?: Tenants;
29
+ }
30
+
31
+ /** A store built under a name: what it was built from, and its index. */
32
+ interface Built {
33
+ readonly definition: unknown;
34
+ readonly fields: unknown;
35
+ readonly index: StoreIndex;
36
+ }
37
+
38
+ /**
39
+ * The stores built from the platform, one index each, provisioned before a request: once without
40
+ * tenancy, for each tenant of the work the directory lists otherwise. A tenant whose provisioning
41
+ * failed is tried again at its next request, the others untouched.
42
+ */
43
+ export class ProvisionedIndexes extends SearchIndexes {
44
+ private readonly stores = new Map<string, Built>();
45
+
46
+ constructor(private readonly settings: IndexSettings) {
47
+ super();
48
+ }
49
+
50
+ options<Row extends object>(
51
+ name: string,
52
+ definition: CriteriaDefinition<Row>,
53
+ settings: SearchStoreSettings<Row> = {},
54
+ ): OpenSearchReadModelOptions<Row> {
55
+ const { transport, tenancy } = this.settings;
56
+ const options = { ...settings, transport, name, definition, tenancy };
57
+ const built = { definition, fields: settings.fields };
58
+ const index = this.indexOf(name, built, () => new StoreIndex(new OpenSearchReadModelStore(options)));
59
+
60
+ return { ...options, transport: { request: (request) => this.ready(index).then(() => transport.request(request)) } };
61
+ }
62
+
63
+ /** At the start, best effort: every tenant the directory lists, for each store built by then; a failure is a warning. */
64
+ async provision(): Promise<void> {
65
+ if (!this.settings.reachable) {
66
+ return;
67
+ }
68
+
69
+ await Promise.all([...this.stores].map(([name, { index }]) => this.provisionAtStart(name, index)));
70
+ }
71
+
72
+ private indexOf(name: string, built: Omit<Built, 'index'>, created: () => StoreIndex): StoreIndex {
73
+ const known = this.stores.get(name);
74
+
75
+ if (known === undefined) {
76
+ const index = created();
77
+
78
+ this.stores.set(name, { ...built, index });
79
+
80
+ return index;
81
+ }
82
+
83
+ if (known.definition !== built.definition || !sameFields(known.fields, built.fields)) {
84
+ throw new SearchNameTakenError(name);
85
+ }
86
+
87
+ return known.index;
88
+ }
89
+
90
+ private async ready(index: StoreIndex): Promise<void> {
91
+ const { tenants } = this.settings;
92
+
93
+ if (tenants === undefined) {
94
+ return index.mapped();
95
+ }
96
+
97
+ const tenant = tenants.ofWork();
98
+
99
+ if (tenant !== undefined && (index.has(tenant) || (await tenants.listed()).includes(tenant))) {
100
+ await index.provisioned(tenant);
101
+ }
102
+ }
103
+
104
+ private async provisionAtStart(name: string, index: StoreIndex): Promise<void> {
105
+ const { tenants } = this.settings;
106
+
107
+ if (tenants === undefined) {
108
+ return index.mapped().catch((error: unknown) => this.warn(error, name));
109
+ }
110
+
111
+ const listed = await tenants.listed().catch((error: unknown) => {
112
+ this.warn(error, name);
113
+
114
+ return [];
115
+ });
116
+
117
+ await Promise.all(
118
+ listed.map((tenant) => index.provisioned(tenant).catch((error: unknown) => this.warn(error, name, tenant))),
119
+ );
120
+ }
121
+
122
+ private warn(error: unknown, store: string, tenant?: string): void {
123
+ this.settings.logger.warn('search index not provisioned', {
124
+ store,
125
+ ...(tenant === undefined ? {} : { tenant }),
126
+ error: error instanceof Error ? error : String(error),
127
+ });
128
+ }
129
+ }
130
+
131
+ /** The same fields kept with the rows: the same names with the same types. */
132
+ function sameFields(known: unknown, asked: unknown): boolean {
133
+ return JSON.stringify(known ?? {}) === JSON.stringify(asked ?? {});
134
+ }
@@ -0,0 +1,23 @@
1
+ import type { CriteriaDefinition } from '@ddd-ts-kit/kernel';
2
+ import type { OpenSearchReadModelOptions } from '@ddd-ts-kit/opensearch';
3
+
4
+ /** What a store may add to its name and its definition: the other fields of its rows, a write seen by the next search, the settings of its index. */
5
+ export type SearchStoreSettings<Row> = Pick<OpenSearchReadModelOptions<Row>, 'fields' | 'refresh' | 'settings'>;
6
+
7
+ /**
8
+ * The read models kept in OpenSearch, as a capability of the platform. The adapter of a read
9
+ * model port extends `OpenSearchReadModelStore` and passes to it what `options` answers: the
10
+ * transport and the tenancy of the project are set here, never in a context. The platform
11
+ * provisions the index of every store built so, before its first request.
12
+ */
13
+ export abstract class SearchIndexes {
14
+ /** The options of the store `name`: lower case letters, digits and `_`, prefixed by its context (`billing_invoices`). */
15
+ abstract options<Row extends object>(
16
+ name: string,
17
+ definition: CriteriaDefinition<Row>,
18
+ settings?: SearchStoreSettings<Row>,
19
+ ): OpenSearchReadModelOptions<Row>;
20
+
21
+ /** Provisions the index of every store built so far: at the start of the application, and again at will, since it is idempotent. */
22
+ abstract provision(): Promise<void>;
23
+ }