ddd-ts-kit 0.4.1 → 0.6.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 (485) hide show
  1. package/README.md +41 -10
  2. package/dist/check/alias/build-scripts.d.ts.map +1 -1
  3. package/dist/check/alias/build-scripts.js +3 -1
  4. package/dist/check/alias/build-scripts.js.map +1 -1
  5. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  6. package/dist/check/catalogue/architecture-rules.js +2 -0
  7. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  8. package/dist/check/configuration/config-inspection.d.ts +6 -0
  9. package/dist/check/configuration/config-inspection.d.ts.map +1 -1
  10. package/dist/check/configuration/config-inspection.js +14 -1
  11. package/dist/check/configuration/config-inspection.js.map +1 -1
  12. package/dist/check/explain/persistence-docs.d.ts +3 -0
  13. package/dist/check/explain/persistence-docs.d.ts.map +1 -0
  14. package/dist/check/explain/persistence-docs.js +14 -0
  15. package/dist/check/explain/persistence-docs.js.map +1 -0
  16. package/dist/check/explain/rule-docs.d.ts.map +1 -1
  17. package/dist/check/explain/rule-docs.js +2 -0
  18. package/dist/check/explain/rule-docs.js.map +1 -1
  19. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  20. package/dist/check/fixtures/fixtures.js +2 -0
  21. package/dist/check/fixtures/fixtures.js.map +1 -1
  22. package/dist/check/fixtures/persistence-fixtures.d.ts +3 -0
  23. package/dist/check/fixtures/persistence-fixtures.d.ts.map +1 -0
  24. package/dist/check/fixtures/persistence-fixtures.js +72 -0
  25. package/dist/check/fixtures/persistence-fixtures.js.map +1 -0
  26. package/dist/check/migrations/drizzle-history-findings.d.ts +9 -0
  27. package/dist/check/migrations/drizzle-history-findings.d.ts.map +1 -0
  28. package/dist/check/migrations/drizzle-history-findings.js +70 -0
  29. package/dist/check/migrations/drizzle-history-findings.js.map +1 -0
  30. package/dist/check/migrations/drizzle-migrations.d.ts +23 -0
  31. package/dist/check/migrations/drizzle-migrations.d.ts.map +1 -0
  32. package/dist/check/migrations/drizzle-migrations.js +2 -0
  33. package/dist/check/migrations/drizzle-migrations.js.map +1 -0
  34. package/dist/check/migrations/drizzle-out-folder.d.ts +3 -0
  35. package/dist/check/migrations/drizzle-out-folder.d.ts.map +1 -0
  36. package/dist/check/migrations/drizzle-out-folder.js +18 -0
  37. package/dist/check/migrations/drizzle-out-folder.js.map +1 -0
  38. package/dist/check/migrations/migration-folder.d.ts +13 -0
  39. package/dist/check/migrations/migration-folder.d.ts.map +1 -0
  40. package/dist/check/migrations/migration-folder.js +2 -0
  41. package/dist/check/migrations/migration-folder.js.map +1 -0
  42. package/dist/check/migrations/migration-name-findings.d.ts +9 -0
  43. package/dist/check/migrations/migration-name-findings.d.ts.map +1 -0
  44. package/dist/check/migrations/migration-name-findings.js +32 -0
  45. package/dist/check/migrations/migration-name-findings.js.map +1 -0
  46. package/dist/check/migrations/read-drizzle-migrations.d.ts +4 -0
  47. package/dist/check/migrations/read-drizzle-migrations.d.ts.map +1 -0
  48. package/dist/check/migrations/read-drizzle-migrations.js +67 -0
  49. package/dist/check/migrations/read-drizzle-migrations.js.map +1 -0
  50. package/dist/check/migrations/read-migration-folder.d.ts +5 -0
  51. package/dist/check/migrations/read-migration-folder.d.ts.map +1 -0
  52. package/dist/check/migrations/read-migration-folder.js +38 -0
  53. package/dist/check/migrations/read-migration-folder.js.map +1 -0
  54. package/dist/check/rules/config-valid.d.ts.map +1 -1
  55. package/dist/check/rules/config-valid.js +4 -1
  56. package/dist/check/rules/config-valid.js.map +1 -1
  57. package/dist/check/rules/persistence-migration-history.d.ts +3 -0
  58. package/dist/check/rules/persistence-migration-history.d.ts.map +1 -0
  59. package/dist/check/rules/persistence-migration-history.js +24 -0
  60. package/dist/check/rules/persistence-migration-history.js.map +1 -0
  61. package/dist/commands/init.d.ts.map +1 -1
  62. package/dist/commands/init.js +12 -1
  63. package/dist/commands/init.js.map +1 -1
  64. package/dist/commands/sdk.d.ts +8 -0
  65. package/dist/commands/sdk.d.ts.map +1 -0
  66. package/dist/commands/sdk.js +82 -0
  67. package/dist/commands/sdk.js.map +1 -0
  68. package/dist/commit/is-derived.d.ts.map +1 -1
  69. package/dist/commit/is-derived.js +5 -7
  70. package/dist/commit/is-derived.js.map +1 -1
  71. package/dist/config/ci-extra-problems.d.ts +4 -0
  72. package/dist/config/ci-extra-problems.d.ts.map +1 -0
  73. package/dist/config/ci-extra-problems.js +27 -0
  74. package/dist/config/ci-extra-problems.js.map +1 -0
  75. package/dist/config/ci-extras.d.ts +13 -0
  76. package/dist/config/ci-extras.d.ts.map +1 -0
  77. package/dist/config/ci-extras.js +13 -0
  78. package/dist/config/ci-extras.js.map +1 -0
  79. package/dist/config/config.d.ts +32 -0
  80. package/dist/config/config.d.ts.map +1 -1
  81. package/dist/config/default-sdk-name.d.ts +3 -0
  82. package/dist/config/default-sdk-name.d.ts.map +1 -0
  83. package/dist/config/default-sdk-name.js +3 -0
  84. package/dist/config/default-sdk-name.js.map +1 -0
  85. package/dist/config/index.d.ts +6 -1
  86. package/dist/config/index.d.ts.map +1 -1
  87. package/dist/config/index.js +5 -0
  88. package/dist/config/index.js.map +1 -1
  89. package/dist/config/open-api-problems.d.ts +4 -0
  90. package/dist/config/open-api-problems.d.ts.map +1 -0
  91. package/dist/config/open-api-problems.js +87 -0
  92. package/dist/config/open-api-problems.js.map +1 -0
  93. package/dist/config/openapi-formats.d.ts +3 -0
  94. package/dist/config/openapi-formats.d.ts.map +1 -0
  95. package/dist/config/openapi-formats.js +3 -0
  96. package/dist/config/openapi-formats.js.map +1 -0
  97. package/dist/config/parse-ci.d.ts +4 -0
  98. package/dist/config/parse-ci.d.ts.map +1 -0
  99. package/dist/config/parse-ci.js +7 -0
  100. package/dist/config/parse-ci.js.map +1 -0
  101. package/dist/config/parse-config.d.ts.map +1 -1
  102. package/dist/config/parse-config.js +6 -0
  103. package/dist/config/parse-config.js.map +1 -1
  104. package/dist/config/parse-open-api.d.ts +4 -0
  105. package/dist/config/parse-open-api.d.ts.map +1 -0
  106. package/dist/config/parse-open-api.js +20 -0
  107. package/dist/config/parse-open-api.js.map +1 -0
  108. package/dist/config/parse-sdk.d.ts +4 -0
  109. package/dist/config/parse-sdk.d.ts.map +1 -0
  110. package/dist/config/parse-sdk.js +12 -0
  111. package/dist/config/parse-sdk.js.map +1 -0
  112. package/dist/config/restack-config-text.d.ts +1 -1
  113. package/dist/config/restack-config-text.d.ts.map +1 -1
  114. package/dist/config/restack-config-text.js +12 -2
  115. package/dist/config/restack-config-text.js.map +1 -1
  116. package/dist/config/sdk-accesses.d.ts +3 -0
  117. package/dist/config/sdk-accesses.d.ts.map +1 -0
  118. package/dist/config/sdk-accesses.js +3 -0
  119. package/dist/config/sdk-accesses.js.map +1 -0
  120. package/dist/config/sdk-problems.d.ts +4 -0
  121. package/dist/config/sdk-problems.d.ts.map +1 -0
  122. package/dist/config/sdk-problems.js +55 -0
  123. package/dist/config/sdk-problems.js.map +1 -0
  124. package/dist/config/serialize-config.js +11 -0
  125. package/dist/config/serialize-config.js.map +1 -1
  126. package/dist/contracts/contract-format.d.ts +3 -0
  127. package/dist/contracts/contract-format.d.ts.map +1 -0
  128. package/dist/contracts/contract-format.js +11 -0
  129. package/dist/contracts/contract-format.js.map +1 -0
  130. package/dist/contracts/stringify-contract.d.ts +3 -0
  131. package/dist/contracts/stringify-contract.d.ts.map +1 -0
  132. package/dist/contracts/stringify-contract.js +6 -0
  133. package/dist/contracts/stringify-contract.js.map +1 -0
  134. package/dist/contracts.d.ts +9 -0
  135. package/dist/contracts.d.ts.map +1 -0
  136. package/dist/contracts.js +9 -0
  137. package/dist/contracts.js.map +1 -0
  138. package/dist/describe/describe-context.d.ts.map +1 -1
  139. package/dist/describe/describe-context.js +14 -3
  140. package/dist/describe/describe-context.js.map +1 -1
  141. package/dist/docs/open-api-documents-file.d.ts +4 -0
  142. package/dist/docs/open-api-documents-file.d.ts.map +1 -0
  143. package/dist/docs/open-api-documents-file.js +5 -0
  144. package/dist/docs/open-api-documents-file.js.map +1 -0
  145. package/dist/docs/render-open-api-documents.d.ts +13 -0
  146. package/dist/docs/render-open-api-documents.d.ts.map +1 -0
  147. package/dist/docs/render-open-api-documents.js +42 -0
  148. package/dist/docs/render-open-api-documents.js.map +1 -0
  149. package/dist/docs/write-docs.d.ts.map +1 -1
  150. package/dist/docs/write-docs.js +2 -0
  151. package/dist/docs/write-docs.js.map +1 -1
  152. package/dist/docs/write-open-api-documents.d.ts +9 -0
  153. package/dist/docs/write-open-api-documents.d.ts.map +1 -0
  154. package/dist/docs/write-open-api-documents.js +33 -0
  155. package/dist/docs/write-open-api-documents.js.map +1 -0
  156. package/dist/generate/kinds/declare-context-entries.d.ts.map +1 -1
  157. package/dist/generate/kinds/declare-context-entries.js +3 -1
  158. package/dist/generate/kinds/declare-context-entries.js.map +1 -1
  159. package/dist/generate/kinds/extraction/entry-point.d.ts.map +1 -1
  160. package/dist/generate/kinds/extraction/entry-point.js +3 -1
  161. package/dist/generate/kinds/extraction/entry-point.js.map +1 -1
  162. package/dist/generate/kinds/knip-project.d.ts +7 -0
  163. package/dist/generate/kinds/knip-project.d.ts.map +1 -0
  164. package/dist/generate/kinds/knip-project.js +12 -0
  165. package/dist/generate/kinds/knip-project.js.map +1 -0
  166. package/dist/help/commands-guide-region.d.ts +3 -0
  167. package/dist/help/commands-guide-region.d.ts.map +1 -0
  168. package/dist/help/commands-guide-region.js +12 -0
  169. package/dist/help/commands-guide-region.js.map +1 -0
  170. package/dist/help/notes.d.ts +3 -0
  171. package/dist/help/notes.d.ts.map +1 -0
  172. package/dist/help/notes.js +30 -0
  173. package/dist/help/notes.js.map +1 -0
  174. package/dist/help/reference-text.d.ts +3 -0
  175. package/dist/help/reference-text.d.ts.map +1 -0
  176. package/dist/help/reference-text.js +14 -0
  177. package/dist/help/reference-text.js.map +1 -0
  178. package/dist/help/usage.d.ts +3 -0
  179. package/dist/help/usage.d.ts.map +1 -0
  180. package/dist/help/usage.js +38 -0
  181. package/dist/help/usage.js.map +1 -0
  182. package/dist/index.d.ts +1 -0
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +1 -0
  185. package/dist/index.js.map +1 -1
  186. package/dist/init/files/persistence-files.js +1 -1
  187. package/dist/init/files/persistence-files.js.map +1 -1
  188. package/dist/init/files/pipeline-files.d.ts.map +1 -1
  189. package/dist/init/files/pipeline-files.js +4 -2
  190. package/dist/init/files/pipeline-files.js.map +1 -1
  191. package/dist/init/manifest/database-scripts.d.ts.map +1 -1
  192. package/dist/init/manifest/database-scripts.js +5 -4
  193. package/dist/init/manifest/database-scripts.js.map +1 -1
  194. package/dist/init/manifest/versions.js +23 -23
  195. package/dist/init/run-init.d.ts.map +1 -1
  196. package/dist/init/run-init.js +5 -0
  197. package/dist/init/run-init.js.map +1 -1
  198. package/dist/init/stack/resolve-ci-extras.d.ts +8 -0
  199. package/dist/init/stack/resolve-ci-extras.d.ts.map +1 -0
  200. package/dist/init/stack/resolve-ci-extras.js +31 -0
  201. package/dist/init/stack/resolve-ci-extras.js.map +1 -0
  202. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  203. package/dist/init/stack/resolve-stack.js +15 -3
  204. package/dist/init/stack/resolve-stack.js.map +1 -1
  205. package/dist/init/stack/stack-options.d.ts +4 -0
  206. package/dist/init/stack/stack-options.d.ts.map +1 -1
  207. package/dist/init/template-vars.d.ts.map +1 -1
  208. package/dist/init/template-vars.js +16 -0
  209. package/dist/init/template-vars.js.map +1 -1
  210. package/dist/init/write-agent-settings.js +2 -2
  211. package/dist/init/write-agent-settings.js.map +1 -1
  212. package/dist/init/write-contracts.d.ts.map +1 -1
  213. package/dist/init/write-contracts.js +7 -3
  214. package/dist/init/write-contracts.js.map +1 -1
  215. package/dist/progress/format-progress.d.ts.map +1 -1
  216. package/dist/progress/format-progress.js +3 -1
  217. package/dist/progress/format-progress.js.map +1 -1
  218. package/dist/run.d.ts.map +1 -1
  219. package/dist/run.js +4 -63
  220. package/dist/run.js.map +1 -1
  221. package/dist/sdk/agent-instruction.d.ts +3 -0
  222. package/dist/sdk/agent-instruction.d.ts.map +1 -0
  223. package/dist/sdk/agent-instruction.js +3 -0
  224. package/dist/sdk/agent-instruction.js.map +1 -0
  225. package/dist/sdk/client-document.d.ts +16 -0
  226. package/dist/sdk/client-document.d.ts.map +1 -0
  227. package/dist/sdk/client-document.js +2 -0
  228. package/dist/sdk/client-document.js.map +1 -0
  229. package/dist/sdk/client-files.d.ts +7 -0
  230. package/dist/sdk/client-files.d.ts.map +1 -0
  231. package/dist/sdk/client-files.js +25 -0
  232. package/dist/sdk/client-files.js.map +1 -0
  233. package/dist/sdk/client-manifest.d.ts +14 -0
  234. package/dist/sdk/client-manifest.d.ts.map +1 -0
  235. package/dist/sdk/client-manifest.js +45 -0
  236. package/dist/sdk/client-manifest.js.map +1 -0
  237. package/dist/sdk/client-names.d.ts +7 -0
  238. package/dist/sdk/client-names.d.ts.map +1 -0
  239. package/dist/sdk/client-names.js +30 -0
  240. package/dist/sdk/client-names.js.map +1 -0
  241. package/dist/sdk/client-operation.d.ts +21 -0
  242. package/dist/sdk/client-operation.d.ts.map +1 -0
  243. package/dist/sdk/client-operation.js +2 -0
  244. package/dist/sdk/client-operation.js.map +1 -0
  245. package/dist/sdk/client-package-name.d.ts +3 -0
  246. package/dist/sdk/client-package-name.d.ts.map +1 -0
  247. package/dist/sdk/client-package-name.js +5 -0
  248. package/dist/sdk/client-package-name.js.map +1 -0
  249. package/dist/sdk/client-parameter.d.ts +9 -0
  250. package/dist/sdk/client-parameter.d.ts.map +1 -0
  251. package/dist/sdk/client-parameter.js +2 -0
  252. package/dist/sdk/client-parameter.js.map +1 -0
  253. package/dist/sdk/client-response.d.ts +10 -0
  254. package/dist/sdk/client-response.d.ts.map +1 -0
  255. package/dist/sdk/client-response.js +2 -0
  256. package/dist/sdk/client-response.js.map +1 -0
  257. package/dist/sdk/client-tsconfig.d.ts +7 -0
  258. package/dist/sdk/client-tsconfig.d.ts.map +1 -0
  259. package/dist/sdk/client-tsconfig.js +26 -0
  260. package/dist/sdk/client-tsconfig.js.map +1 -0
  261. package/dist/sdk/clients-directory.d.ts +3 -0
  262. package/dist/sdk/clients-directory.d.ts.map +1 -0
  263. package/dist/sdk/clients-directory.js +3 -0
  264. package/dist/sdk/clients-directory.js.map +1 -0
  265. package/dist/sdk/contract-documents.d.ts +11 -0
  266. package/dist/sdk/contract-documents.d.ts.map +1 -0
  267. package/dist/sdk/contract-documents.js +46 -0
  268. package/dist/sdk/contract-documents.js.map +1 -0
  269. package/dist/sdk/doc-comment.d.ts +3 -0
  270. package/dist/sdk/doc-comment.d.ts.map +1 -0
  271. package/dist/sdk/doc-comment.js +11 -0
  272. package/dist/sdk/doc-comment.js.map +1 -0
  273. package/dist/sdk/document-source.d.ts +6 -0
  274. package/dist/sdk/document-source.d.ts.map +1 -0
  275. package/dist/sdk/document-source.js +2 -0
  276. package/dist/sdk/document-source.js.map +1 -0
  277. package/dist/sdk/edit-json-file.d.ts +9 -0
  278. package/dist/sdk/edit-json-file.d.ts.map +1 -0
  279. package/dist/sdk/edit-json-file.js +31 -0
  280. package/dist/sdk/edit-json-file.js.map +1 -0
  281. package/dist/sdk/error-codes.d.ts +4 -0
  282. package/dist/sdk/error-codes.d.ts.map +1 -0
  283. package/dist/sdk/error-codes.js +6 -0
  284. package/dist/sdk/error-codes.js.map +1 -0
  285. package/dist/sdk/generated-header.d.ts +4 -0
  286. package/dist/sdk/generated-header.d.ts.map +1 -0
  287. package/dist/sdk/generated-header.js +5 -0
  288. package/dist/sdk/generated-header.js.map +1 -0
  289. package/dist/sdk/index.d.ts +3 -0
  290. package/dist/sdk/index.d.ts.map +1 -0
  291. package/dist/sdk/index.js +3 -0
  292. package/dist/sdk/index.js.map +1 -0
  293. package/dist/sdk/instruct-agents.d.ts +8 -0
  294. package/dist/sdk/instruct-agents.d.ts.map +1 -0
  295. package/dist/sdk/instruct-agents.js +19 -0
  296. package/dist/sdk/instruct-agents.js.map +1 -0
  297. package/dist/sdk/is-input-optional.d.ts +4 -0
  298. package/dist/sdk/is-input-optional.d.ts.map +1 -0
  299. package/dist/sdk/is-input-optional.js +5 -0
  300. package/dist/sdk/is-input-optional.js.map +1 -0
  301. package/dist/sdk/is-json.d.ts +3 -0
  302. package/dist/sdk/is-json.d.ts.map +1 -0
  303. package/dist/sdk/is-json.js +5 -0
  304. package/dist/sdk/is-json.js.map +1 -0
  305. package/dist/sdk/manifest-json.d.ts +3 -0
  306. package/dist/sdk/manifest-json.d.ts.map +1 -0
  307. package/dist/sdk/manifest-json.js +5 -0
  308. package/dist/sdk/manifest-json.js.map +1 -0
  309. package/dist/sdk/operation-description.d.ts +4 -0
  310. package/dist/sdk/operation-description.d.ts.map +1 -0
  311. package/dist/sdk/operation-description.js +11 -0
  312. package/dist/sdk/operation-description.js.map +1 -0
  313. package/dist/sdk/operation-names.d.ts +8 -0
  314. package/dist/sdk/operation-names.d.ts.map +1 -0
  315. package/dist/sdk/operation-names.js +35 -0
  316. package/dist/sdk/operation-names.js.map +1 -0
  317. package/dist/sdk/operation-place.d.ts +8 -0
  318. package/dist/sdk/operation-place.d.ts.map +1 -0
  319. package/dist/sdk/operation-place.js +2 -0
  320. package/dist/sdk/operation-place.js.map +1 -0
  321. package/dist/sdk/planned-client.d.ts +8 -0
  322. package/dist/sdk/planned-client.d.ts.map +1 -0
  323. package/dist/sdk/planned-client.js +2 -0
  324. package/dist/sdk/planned-client.js.map +1 -0
  325. package/dist/sdk/planned-clients.d.ts +6 -0
  326. package/dist/sdk/planned-clients.d.ts.map +1 -0
  327. package/dist/sdk/planned-clients.js +30 -0
  328. package/dist/sdk/planned-clients.js.map +1 -0
  329. package/dist/sdk/property-key.d.ts +3 -0
  330. package/dist/sdk/property-key.d.ts.map +1 -0
  331. package/dist/sdk/property-key.js +6 -0
  332. package/dist/sdk/property-key.js.map +1 -0
  333. package/dist/sdk/put-file.d.ts +4 -0
  334. package/dist/sdk/put-file.d.ts.map +1 -0
  335. package/dist/sdk/put-file.js +10 -0
  336. package/dist/sdk/put-file.js.map +1 -0
  337. package/dist/sdk/read-client-document.d.ts +5 -0
  338. package/dist/sdk/read-client-document.d.ts.map +1 -0
  339. package/dist/sdk/read-client-document.js +34 -0
  340. package/dist/sdk/read-client-document.js.map +1 -0
  341. package/dist/sdk/read-operation.d.ts +4 -0
  342. package/dist/sdk/read-operation.d.ts.map +1 -0
  343. package/dist/sdk/read-operation.js +64 -0
  344. package/dist/sdk/read-operation.js.map +1 -0
  345. package/dist/sdk/read-responses.d.ts +4 -0
  346. package/dist/sdk/read-responses.d.ts.map +1 -0
  347. package/dist/sdk/read-responses.js +32 -0
  348. package/dist/sdk/read-responses.js.map +1 -0
  349. package/dist/sdk/read-schemes.d.ts +8 -0
  350. package/dist/sdk/read-schemes.d.ts.map +1 -0
  351. package/dist/sdk/read-schemes.js +37 -0
  352. package/dist/sdk/read-schemes.js.map +1 -0
  353. package/dist/sdk/read-security.d.ts +3 -0
  354. package/dist/sdk/read-security.d.ts.map +1 -0
  355. package/dist/sdk/read-security.js +7 -0
  356. package/dist/sdk/read-security.js.map +1 -0
  357. package/dist/sdk/render-client.d.ts +4 -0
  358. package/dist/sdk/render-client.d.ts.map +1 -0
  359. package/dist/sdk/render-client.js +49 -0
  360. package/dist/sdk/render-client.js.map +1 -0
  361. package/dist/sdk/render-errors.d.ts +4 -0
  362. package/dist/sdk/render-errors.d.ts.map +1 -0
  363. package/dist/sdk/render-errors.js +18 -0
  364. package/dist/sdk/render-errors.js.map +1 -0
  365. package/dist/sdk/render-index.d.ts +4 -0
  366. package/dist/sdk/render-index.d.ts.map +1 -0
  367. package/dist/sdk/render-index.js +22 -0
  368. package/dist/sdk/render-index.js.map +1 -0
  369. package/dist/sdk/render-input.d.ts +4 -0
  370. package/dist/sdk/render-input.d.ts.map +1 -0
  371. package/dist/sdk/render-input.js +31 -0
  372. package/dist/sdk/render-input.js.map +1 -0
  373. package/dist/sdk/render-operation.d.ts +7 -0
  374. package/dist/sdk/render-operation.d.ts.map +1 -0
  375. package/dist/sdk/render-operation.js +46 -0
  376. package/dist/sdk/render-operation.js.map +1 -0
  377. package/dist/sdk/render-operations.d.ts +4 -0
  378. package/dist/sdk/render-operations.d.ts.map +1 -0
  379. package/dist/sdk/render-operations.js +12 -0
  380. package/dist/sdk/render-operations.js.map +1 -0
  381. package/dist/sdk/render-readme.d.ts +9 -0
  382. package/dist/sdk/render-readme.d.ts.map +1 -0
  383. package/dist/sdk/render-readme.js +53 -0
  384. package/dist/sdk/render-readme.js.map +1 -0
  385. package/dist/sdk/render-result.d.ts +4 -0
  386. package/dist/sdk/render-result.d.ts.map +1 -0
  387. package/dist/sdk/render-result.js +26 -0
  388. package/dist/sdk/render-result.js.map +1 -0
  389. package/dist/sdk/render-schemas.d.ts +4 -0
  390. package/dist/sdk/render-schemas.d.ts.map +1 -0
  391. package/dist/sdk/render-schemas.js +15 -0
  392. package/dist/sdk/render-schemas.js.map +1 -0
  393. package/dist/sdk/schema-type-name.d.ts +3 -0
  394. package/dist/sdk/schema-type-name.d.ts.map +1 -0
  395. package/dist/sdk/schema-type-name.js +9 -0
  396. package/dist/sdk/schema-type-name.js.map +1 -0
  397. package/dist/sdk/schema-types.d.ts +17 -0
  398. package/dist/sdk/schema-types.d.ts.map +1 -0
  399. package/dist/sdk/schema-types.js +120 -0
  400. package/dist/sdk/schema-types.js.map +1 -0
  401. package/dist/sdk/scheme-carrier.d.ts +7 -0
  402. package/dist/sdk/scheme-carrier.d.ts.map +1 -0
  403. package/dist/sdk/scheme-carrier.js +2 -0
  404. package/dist/sdk/scheme-carrier.js.map +1 -0
  405. package/dist/sdk/sdk-scripts.d.ts +8 -0
  406. package/dist/sdk/sdk-scripts.d.ts.map +1 -0
  407. package/dist/sdk/sdk-scripts.js +26 -0
  408. package/dist/sdk/sdk-scripts.js.map +1 -0
  409. package/dist/sdk/sdk-set-up.d.ts +8 -0
  410. package/dist/sdk/sdk-set-up.d.ts.map +1 -0
  411. package/dist/sdk/sdk-set-up.js +2 -0
  412. package/dist/sdk/sdk-set-up.js.map +1 -0
  413. package/dist/sdk/set-up-sdk.d.ts +11 -0
  414. package/dist/sdk/set-up-sdk.d.ts.map +1 -0
  415. package/dist/sdk/set-up-sdk.js +19 -0
  416. package/dist/sdk/set-up-sdk.js.map +1 -0
  417. package/dist/sdk/type-name.d.ts +3 -0
  418. package/dist/sdk/type-name.d.ts.map +1 -0
  419. package/dist/sdk/type-name.js +5 -0
  420. package/dist/sdk/type-name.js.map +1 -0
  421. package/dist/sdk/unlocked-clients.d.ts +10 -0
  422. package/dist/sdk/unlocked-clients.d.ts.map +1 -0
  423. package/dist/sdk/unlocked-clients.js +36 -0
  424. package/dist/sdk/unlocked-clients.js.map +1 -0
  425. package/dist/sdk/wire-sdk.d.ts +12 -0
  426. package/dist/sdk/wire-sdk.d.ts.map +1 -0
  427. package/dist/sdk/wire-sdk.js +58 -0
  428. package/dist/sdk/wire-sdk.js.map +1 -0
  429. package/dist/sdk/with-client-paths.d.ts +8 -0
  430. package/dist/sdk/with-client-paths.d.ts.map +1 -0
  431. package/dist/sdk/with-client-paths.js +20 -0
  432. package/dist/sdk/with-client-paths.js.map +1 -0
  433. package/dist/sdk/with-entry.d.ts +3 -0
  434. package/dist/sdk/with-entry.d.ts.map +1 -0
  435. package/dist/sdk/with-entry.js +6 -0
  436. package/dist/sdk/with-entry.js.map +1 -0
  437. package/dist/sdk/with-knip-workspaces.d.ts +7 -0
  438. package/dist/sdk/with-knip-workspaces.d.ts.map +1 -0
  439. package/dist/sdk/with-knip-workspaces.js +40 -0
  440. package/dist/sdk/with-knip-workspaces.js.map +1 -0
  441. package/dist/sdk/write-clients.d.ts +10 -0
  442. package/dist/sdk/write-clients.d.ts.map +1 -0
  443. package/dist/sdk/write-clients.js +32 -0
  444. package/dist/sdk/write-clients.js.map +1 -0
  445. package/dist/version.d.ts +1 -1
  446. package/dist/version.js +1 -1
  447. package/dist/yaml/from-yaml.d.ts +8 -0
  448. package/dist/yaml/from-yaml.d.ts.map +1 -0
  449. package/dist/yaml/from-yaml.js +149 -0
  450. package/dist/yaml/from-yaml.js.map +1 -0
  451. package/dist/yaml/read-scalar.d.ts +7 -0
  452. package/dist/yaml/read-scalar.d.ts.map +1 -0
  453. package/dist/yaml/read-scalar.js +50 -0
  454. package/dist/yaml/read-scalar.js.map +1 -0
  455. package/dist/yaml/to-yaml.d.ts +8 -0
  456. package/dist/yaml/to-yaml.d.ts.map +1 -0
  457. package/dist/yaml/to-yaml.js +132 -0
  458. package/dist/yaml/to-yaml.js.map +1 -0
  459. package/dist/yaml/yaml-shape-error.d.ts +6 -0
  460. package/dist/yaml/yaml-shape-error.d.ts.map +1 -0
  461. package/dist/yaml/yaml-shape-error.js +10 -0
  462. package/dist/yaml/yaml-shape-error.js.map +1 -0
  463. package/package.json +2 -2
  464. package/templates/docs/integration-readme.md.tpl +2 -2
  465. package/templates/init/CLAUDE.md.tpl +5 -1
  466. package/templates/init/README.md.tpl +45 -12
  467. package/templates/init/platform/database/data-source.typeorm.ts.tpl +1 -1
  468. package/templates/init/platform/database/drizzle.config.ts.tpl +2 -0
  469. package/templates/init/platform/database/knexfile.js.tpl +9 -3
  470. package/templates/init/platform/database/schema.drizzle.ts.tpl +1 -1
  471. package/templates/init/platform/database/schema.knex.ts.tpl +2 -2
  472. package/templates/init/platform/http/with-documentation.ts.tpl +13 -9
  473. package/templates/init/rules/presentation.md.tpl +4 -1
  474. package/templates/init/scripts/events.ts.tpl +16 -5
  475. package/templates/init/scripts/openapi.ts.tpl +49 -20
  476. package/templates/pipeline/github/branch-protection.md +8 -7
  477. package/templates/pipeline/github/workflows/{ci.yml → ci.yml.tpl} +3 -0
  478. package/templates/pipeline/gitlab/gitlab-ci.yml.tpl +14 -0
  479. package/templates/pipeline/gitlab/merge-request-settings.md +7 -6
  480. package/templates/pipeline/package-scripts.json +1 -1
  481. package/templates/repository/drizzle/table.tpl +2 -2
  482. package/templates/repository/prisma/model.tpl +1 -1
  483. package/templates/repository/typeorm/table.tpl +1 -1
  484. package/templates/sdk/errors.ts.tpl +30 -0
  485. package/templates/sdk/runtime.ts.tpl +347 -0
@@ -13,7 +13,7 @@ cp .env.example .env
13
13
  npm run infra:up # the database, in Docker; add --profile observability for Jaeger
14
14
  {{/if}}
15
15
  {{#if orm.drizzle}}
16
- npm run db:generate # SQL migrations from the Drizzle schema
16
+ npm run db:generate initial # migrations/<timestamp>_initial.sql, from the Drizzle schema
17
17
  npm run db:migrate
18
18
  {{/if}}
19
19
  {{#if orm.knex}}
@@ -21,16 +21,22 @@ npm run db:migrate # builds, then applies migrations/ (the first one create
21
21
  {{/if}}
22
22
  {{#if orm.prisma}}
23
23
  npm run db:client # the Prisma client and the schema of the tests, from prisma/schema.prisma
24
- npm run db:generate # a migration from the schema
24
+ npm run db:generate initial # prisma/migrations/<timestamp>_initial/, from the schema
25
25
  npm run db:migrate
26
26
  {{/if}}
27
27
  {{#if orm.typeorm}}
28
- npm run build && npm run db:generate # a migration from the entity schemas
28
+ npm run build && npm run db:generate migrations/initial # migrations/<timestamp>-initial.ts, from the entity schemas
29
29
  npm run db:migrate
30
30
  {{/if}}
31
31
  npm run dev
32
32
  ```
33
33
 
34
+ {{#if persistence.hasDatabase}}
35
+ Every migration is named `<timestamp>_<what-it-does>`: `npm run db:generate` refuses to run
36
+ without a name, so two branches never write the same file, and `npm run check:arch` reports
37
+ migrations that a merge left out of order (`npx ddd-ts-kit explain persistence/migration-history`).
38
+
39
+ {{/if}}
34
40
  `npm run dev` restarts the application when a source file changes. It runs `tsx watch`, which
35
41
  executes TypeScript directly and resolves an import alias from the `paths` of `tsconfig.json`;
36
42
  `--env-file-if-exists=.env` gives Node the variables of `.env`
@@ -41,7 +47,16 @@ one is wrong.
41
47
  {{#if docs.any}}
42
48
 
43
49
  The API documentation is served at `/docs` and the contract at `/openapi.json`, outside
44
- production unless `API_DOCS=true`.
50
+ production unless `API_DOCS=true`; a contract split into documents (`openapi.documents` of
51
+ `ddd-ts-kit.config.json`) is served at `/openapi/<name>.json`, and the page offers each one.
52
+ `npm run docs:generate` commits it as `openapi/openapi.yaml` (or one file per document).
53
+ {{/if}}
54
+ {{#if sdk.on}}
55
+
56
+ A typed client of the contract is generated for its callers, one workspace package per document
57
+ under `clients/` (`npx ddd-ts-kit sdk`, run by `npm run docs:generate`): typed errors keyed by
58
+ the error codes of each operation, a credential per security scheme, no runtime dependency.
59
+ `npm run sdk:build` compiles them; publishing one is a manual step, its README says how.
45
60
  {{/if}}
46
61
 
47
62
  ## How it is put together
@@ -250,13 +265,31 @@ The pipeline calls the same `ci:*` scripts; what makes it binding is described i
250
265
  how the editor hook of the ddd-ts-kit plugin reacts when a file just written breaks a rule
251
266
  (refuse it, only say so, or stay silent).
252
267
 
253
- ## Work on it
254
-
255
- 1. Define the vocabulary in the `CONTEXT.md` of the context, with the domain experts.
256
- 2. Model: aggregates, value objects, events, in the words of that glossary.
257
- 3. Scaffold with `npx ddd-ts-kit generate ...` (`command`, `query`, `repository`, `port`, `route`, `job`...) and fill the `TODO(domain)` places it lists.
258
- 4. Test: builders and fakes, no mocks. `npm test`, then `npm run test:e2e`.
259
- 5. Verify: `npm run verify`.
268
+ ## Recommended steps
269
+
270
+ Follow them in order: it is the path the kit supports, and each step leaves what the next one
271
+ reads. With the ddd-ts-kit plugin of Claude Code, `/ddd-ts-kit:start` conducts steps 1 to 7 and
272
+ records them in `docs/architecture/plan.md`; `npx ddd-ts-kit status` says which step is next.
273
+
274
+ 1. **Discover the domain** (`/ddd-ts-kit:discover-domain`): actors, commands, events and
275
+ policies in `docs/architecture/discovery.md`.
276
+ 2. **Find the bounded contexts** (`/ddd-ts-kit:bounded-contexts`): `docs/architecture/contexts.md`.
277
+ 3. **Write the glossaries** (`/ddd-ts-kit:glossary`) before any code: the generators refuse a
278
+ name the glossary of its context does not hold.
279
+ 4. **Draw the context map** (`/ddd-ts-kit:context-map`): who is upstream, by which pattern.
280
+ 5. **Bootstrap**: done by `init`. Declare each context with its language and its upstreams,
281
+ upstreams first: `npx ddd-ts-kit generate context <name> --classification <core|supporting|generic> --term "<Term>=<meaning>" --upstream <context>:<pattern>`.
282
+ 6. **Plan the slices** (`/ddd-ts-kit:plan-slices`): one use case per slice, in
283
+ `docs/architecture/slices.md`.
284
+ 7. **Build slice by slice** (`/ddd-ts-kit:use-case`): `npx ddd-ts-kit generate ...`, then the
285
+ `TODO(domain)` places it lists (`npx ddd-ts-kit todo <context>`); builders and fakes, no mocks.
286
+ 8. **Pass the gate** (`/ddd-ts-kit:quality-gate`): `npm run verify` before each merge.
287
+ 9. **Document** (`/ddd-ts-kit:document`): `npm run docs:generate`, committed with the code.
288
+
289
+ A step skipped costs later: boundaries drawn from the tables, a glossary written after the
290
+ code, a first integration made by a direct import the checker then refuses. The method, step by
291
+ step: https://github.com/gbourgeat/ddd-ts-kit/blob/main/docs/guides/methodology.md; the command
292
+ for each moment of the project: https://github.com/gbourgeat/ddd-ts-kit/blob/main/docs/guides/commands.md.
260
293
 
261
294
  | Script | Does |
262
295
  |---|---|
@@ -264,5 +297,5 @@ how the editor hook of the ddd-ts-kit plugin reacts when a file just written bre
264
297
  | `npm test` | domain, application and adapter specs |
265
298
  | `npm run test:e2e` | the whole application through HTTP, on an in-process database unless `DATABASE_URL` is set |
266
299
  | `npm run check:arch` | `ddd-ts-kit check` |
267
- | `npm run docs:generate` | context map, OpenAPI, AsyncAPI and event catalog |
300
+ | `npm run docs:generate` | context map, OpenAPI, AsyncAPI and event catalog{{#if sdk.on}}, the clients under `clients/`{{/if}} |
268
301
  | `npm run verify` | everything CI runs |
@@ -1,7 +1,7 @@
1
1
  import { DataSource } from 'typeorm';
2
2
  import { entities } from '{{alias.platform}}/database/schema{{alias.ext}}';
3
3
 
4
- // Read by the TypeORM CLI only (`npm run db:generate`, `npm run db:migrate`), once compiled.
4
+ // Read by the TypeORM CLI only (`npm run db:generate migrations/<what-it-does>`, `npm run db:migrate`), once compiled.
5
5
  export default new DataSource({
6
6
  type: 'postgres',
7
7
  url: process.env['DATABASE_URL'] ?? '',
@@ -4,5 +4,7 @@ export default {
4
4
  dialect: 'postgresql',
5
5
  schema: './{{config.platformDir}}/database/schema.ts',
6
6
  out: './migrations',
7
+ // `<timestamp>_<what-it-does>.sql` (`npm run db:generate add-invoices`): two branches never write the same file.
8
+ migrations: { prefix: 'timestamp' },
7
9
  dbCredentials: { url: process.env['DATABASE_URL'] ?? '' },
8
10
  } satisfies Config;
@@ -1,9 +1,15 @@
1
+ import { createRequire } from 'node:module';
1
2
  import process from 'node:process';
2
3
 
3
- // Read by the knex CLI (`npm run db:migrate`, `npm run db:generate <name>`). The migrations
4
- // call the compiled schema of the application: run `npm run build` first.
4
+ // Read by the knex CLI (`npm run db:migrate`, `npm run db:generate <what-it-does>`). The migrations
5
+ // call the compiled schema of the application: run `npm run build` first. A new migration is
6
+ // `<timestamp>_<what-it-does>.js`, written from the ES module stub of knex: the project is ESM.
5
7
  export default {
6
8
  client: 'pg',
7
9
  connection: process.env.DATABASE_URL,
8
- migrations: { directory: './migrations', loadExtensions: ['.js'] },
10
+ migrations: {
11
+ directory: './migrations',
12
+ loadExtensions: ['.js'],
13
+ stub: createRequire(import.meta.url).resolve('knex/lib/migrations/migrate/stub/mjs.stub'),
14
+ },
9
15
  };
@@ -10,7 +10,7 @@ export const processedEvents = processedEventsTable('messaging');
10
10
  /** The schema of the audit trail. */
11
11
  export const AUDIT_SCHEMA = 'audit';
12
12
 
13
- // TODO(platform): drizzle-kit writes no trigger. After `npm run db:generate`, add a custom migration (`npm run db:generate -- --custom --name audit-guard`) holding the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
13
+ // TODO(platform): drizzle-kit writes no trigger. After the first `npm run db:generate <name>`, add a custom migration (`npm run db:generate -- audit-guard --custom`) holding the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
14
14
  export const auditEntries = auditEntriesTable(AUDIT_SCHEMA);
15
15
  export const auditChains = auditChainsTable(AUDIT_SCHEMA);
16
16
  {{/if}}
@@ -13,9 +13,9 @@ export const AUDIT_SCHEMA = 'audit';
13
13
  {{/if}}
14
14
 
15
15
  /**
16
- * Every table of the application. The first migration (migrations/0001_initial.js) and the
16
+ * Every table of the application. The first migration (migrations/00000000000000_initial.js) and the
17
17
  * in-process database of the tests both call it; once a database is shared, a change of an
18
- * existing table goes into a migration of its own (`npm run db:generate <name>`).
18
+ * existing table goes into a migration of its own (`npm run db:generate <what-it-does>`).
19
19
  */
20
20
  export const createTables = async (knex: Knex): Promise<void> => {
21
21
  await createOutboxTables(knex, { schema: MESSAGING });
@@ -1,20 +1,24 @@
1
1
  import type { Route } from '@ddd-ts-kit/http';
2
- import { openApiDocsRoutes } from '@ddd-ts-kit/http/docs';
3
- import { generateOpenApi } from '@ddd-ts-kit/http/openapi';
2
+ import { openApiDocumentsRoutes } from '@ddd-ts-kit/http/docs';
3
+ import { generateOpenApi, routesByDocument } from '@ddd-ts-kit/http/openapi';
4
4
  import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
5
5
  import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
6
+ import { OPENAPI_DOCUMENTS } from '{{alias.platform}}/http/openapi-documents{{alias.ext}}';
6
7
 
7
- /** Adds the contract and its interactive page next to the routes, unless documentation is switched off (API_DOCS, off in production by default). */
8
+ /** Adds the contract and its interactive page next to the routes, one per document of a split contract, unless documentation is switched off (API_DOCS, off in production by default). */
8
9
  export function withDocumentation(routes: readonly Route[], config: AppConfig): readonly Route[] {
9
10
  if (!config.docsEnabled) {
10
11
  return routes;
11
12
  }
12
13
 
13
- const document = generateOpenApi({
14
- info: { title: config.serviceName, version: config.serviceVersion },
15
- routes,
16
- securitySchemes,
17
- });
14
+ const documents = routesByDocument(routes, OPENAPI_DOCUMENTS).map(({ name, title, routes: selected }) => ({
15
+ name,
16
+ document: generateOpenApi({
17
+ info: { title: title ?? config.serviceName, version: config.serviceVersion },
18
+ routes: selected,
19
+ securitySchemes,
20
+ }),
21
+ }));
18
22
 
19
- return [...routes, ...openApiDocsRoutes(document, { ui: '{{docs.ui}}' })];
23
+ return [...routes, ...openApiDocumentsRoutes(documents, { ui: '{{docs.ui}}', title: config.serviceName })];
20
24
  }
@@ -3,6 +3,9 @@ paths:
3
3
  - "{{config.contextsDir}}/*/presentation/**"
4
4
  - "openapi/**"
5
5
  - "scripts/openapi.ts"
6
+ {{#if sdk.on}}
7
+ - "clients/**"
8
+ {{/if}}
6
9
  ---
7
10
 
8
11
  # Presentation layer
@@ -28,5 +31,5 @@ paths:
28
31
  - Request and response types are presentation types, one class or schema per file next to the controller (`*.body.ts`, `*.params.ts`, `*.answer.ts`...; `*.dto.ts` for function routes and under `shared/`): never an aggregate, never a row.
29
32
  - Never put the message of an unexpected failure in a response or a log.
30
33
  - Files: the canonical tree of `presentation/http/` (`naming/suffix`, `tree/closed`): a folder per controller, `*.routes.ts` for the groups, `guards/`, `shared/`; function routes stay flat (`*.route.ts`, `*.dto.ts`).
31
- - After a change, `npm run docs:generate` regenerates `openapi/openapi.json`, committed with the route; CI fails on a difference. Never edit it by hand.
34
+ - After a change, `npm run docs:generate` regenerates the contract, `openapi/openapi.yaml` (one file per document when `openapi.documents` of `ddd-ts-kit.config.json` splits it; JSON under `openapi.format: json`), committed with the route; CI fails on a difference. Never edit it by hand.{{#if sdk.on}} It regenerates the typed clients under `clients/` too (`npx ddd-ts-kit sdk`), committed with it.{{/if}}
32
35
  - Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
@@ -1,18 +1,22 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { createEventRegistry, generateEventCatalog, type AnyIntegrationEventDefinition } from '@ddd-ts-kit/events';
4
- import { generateAsyncApi, stringifyAsyncApi } from '@ddd-ts-kit/events/asyncapi';
4
+ import { generateAsyncApi } from '@ddd-ts-kit/events/asyncapi';
5
+ import { contractFormat, stringifyContract } from 'ddd-ts-kit/dist/contracts.js';
5
6
 
6
- // Generates docs/integration/asyncapi.json and docs/integration/event-catalog.md from the
7
- // declarations of every published language; with --check, fails when a committed file
8
- // differs. Both files are build products: never edit them by hand.
7
+ // Generates docs/integration/asyncapi.yaml (asyncapi.json under "openapi.format": "json" in
8
+ // ddd-ts-kit.config.json) and docs/integration/event-catalog.md from the declarations of every
9
+ // published language; with --check, fails when a committed file differs. Both files are build
10
+ // products: never edit them by hand.
9
11
  const contextsDirectory = '{{config.contextsDir}}';
10
12
  const target = path.resolve('docs/integration');
13
+ const format = contractFormat();
14
+ const other = format === 'yaml' ? 'asyncapi.json' : 'asyncapi.yaml';
11
15
 
12
16
  const registry = createEventRegistry(await declaredEvents());
13
17
 
14
18
  const generated: Readonly<Record<string, string>> = {
15
- 'asyncapi.json': stringifyAsyncApi(
19
+ [`asyncapi.${format}`]: stringifyContract(
16
20
  generateAsyncApi({
17
21
  info: {
18
22
  title: manifestField('name', '{{project.name}}'),
@@ -20,6 +24,7 @@ const generated: Readonly<Record<string, string>> = {
20
24
  },
21
25
  registry,
22
26
  }),
27
+ format,
23
28
  ),
24
29
  'event-catalog.md': generateEventCatalog(registry, { consumers: consumersByEventType() }),
25
30
  };
@@ -28,6 +33,7 @@ if (process.argv.includes('--check')) {
28
33
  reportStale();
29
34
  } else {
30
35
  fs.mkdirSync(target, { recursive: true });
36
+ fs.rmSync(path.join(target, other), { force: true });
31
37
 
32
38
  for (const [file, content] of Object.entries(generated)) {
33
39
  fs.writeFileSync(path.join(target, file), content);
@@ -43,6 +49,11 @@ function reportStale(): void {
43
49
  process.exitCode = 1;
44
50
  }
45
51
  }
52
+
53
+ if (fs.existsSync(path.join(target, other))) {
54
+ console.error('docs/integration/' + other + ' is in the other format: run the script `docs:generate`.');
55
+ process.exitCode = 1;
56
+ }
46
57
  }
47
58
 
48
59
  /** Every declaration exported by a published language. Read from the compiled modules next to this script, so that a new context needs no registration: a path completed at run time cannot be an import alias, which the build rewrites. */
@@ -1,47 +1,76 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { checkOpenApiDrift, generateOpenApi, stringifyOpenApi } from '@ddd-ts-kit/http/openapi';
3
+ import { generateOpenApi, routesByDocument } from '@ddd-ts-kit/http/openapi';
4
+ import { contractFormat, stringifyContract } from 'ddd-ts-kit/dist/contracts.js';
4
5
  import { offlineAuthenticator } from '{{alias.platform}}/auth/offline-authenticator{{alias.ext}}';
5
6
  import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
6
7
  import { composeApplication } from '{{alias.platform}}/compose-application{{alias.ext}}';
7
8
  import { inertPersistence } from '{{alias.platform}}/database/inert-persistence{{alias.ext}}';
8
9
  import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{alias.ext}}';
10
+ import { OPENAPI_DOCUMENTS } from '{{alias.platform}}/http/openapi-documents{{alias.ext}}';
9
11
 
10
- // Generates openapi/openapi.json from the route definitions; with --check, fails when the
11
- // committed file differs. The file is a build product: never edit it by hand.
12
- const target = path.resolve('openapi/openapi.json');
12
+ // Generates the contract from the route definitions: openapi/openapi.yaml, or one file per
13
+ // document of "openapi.documents" in ddd-ts-kit.config.json, in the format of "openapi.format";
14
+ // with --check, fails when a committed file differs. Build products: never edit them by hand.
15
+ const directory = path.resolve('openapi');
16
+ const format = contractFormat();
13
17
 
14
18
  const application = composeApplication(inertPersistence(), {
15
19
  events: inProcessEvents(),
16
20
  authenticator: offlineAuthenticator,
17
21
  });
18
22
 
19
- const document = generateOpenApi({
20
- info: {
21
- title: manifestField('name', '{{project.name}}'),
22
- version: manifestField('version', '0.0.0'),
23
- },
24
- routes: application.routes,
25
- securitySchemes,
26
- errorMapper: application.boundary.errorMapper,
27
- });
23
+ const generated = new Map(
24
+ routesByDocument(application.routes, OPENAPI_DOCUMENTS).map(({ name, title, routes }) => [
25
+ `${name}.${format}`,
26
+ stringifyContract(
27
+ generateOpenApi({
28
+ info: { title: title ?? manifestField('name', '{{project.name}}'), version: manifestField('version', '0.0.0') },
29
+ routes,
30
+ securitySchemes,
31
+ errorMapper: application.boundary.errorMapper,
32
+ }),
33
+ format,
34
+ ),
35
+ ]),
36
+ );
28
37
 
29
38
  if (process.argv.includes('--check')) {
30
39
  reportDrift();
31
40
  } else {
32
- fs.mkdirSync(path.dirname(target), { recursive: true });
33
- fs.writeFileSync(target, stringifyOpenApi(document));
41
+ fs.mkdirSync(directory, { recursive: true });
42
+
43
+ for (const file of staleFiles()) {
44
+ fs.rmSync(path.join(directory, file));
45
+ }
46
+
47
+ for (const [file, content] of generated) {
48
+ fs.writeFileSync(path.join(directory, file), content);
49
+ }
34
50
  }
35
51
 
36
52
  function reportDrift(): void {
37
- const committed = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
53
+ for (const [file, content] of generated) {
54
+ const target = path.join(directory, file);
55
+ const committed = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
38
56
 
39
- if (!checkOpenApiDrift(document, committed).drift) {
40
- return;
57
+ if (committed.replaceAll('\r\n', '\n') !== content) {
58
+ console.error(`openapi/${file} is out of date: run the script \`docs:generate\` and commit it.`);
59
+ process.exitCode = 1;
60
+ }
41
61
  }
42
62
 
43
- console.error('openapi/openapi.json is out of date: run the script `docs:generate` and commit it.');
44
- process.exitCode = 1;
63
+ for (const file of staleFiles()) {
64
+ console.error(`openapi/${file} is no document of the contract any more: run the script \`docs:generate\`.`);
65
+ process.exitCode = 1;
66
+ }
67
+ }
68
+
69
+ /** The contracts left by another format or by a document that is gone. */
70
+ function staleFiles(): string[] {
71
+ const present = fs.existsSync(directory) ? fs.readdirSync(directory) : [];
72
+
73
+ return present.filter((file) => /\.(?:json|yaml)$/.test(file) && !generated.has(file));
45
74
  }
46
75
 
47
76
  function manifestField(name: string, fallback: string): string {
@@ -10,7 +10,7 @@ of `CI` on `main` (GitHub only offers a check as "required" once it has reported
10
10
  |---|---|---|
11
11
  | `gate` | `ci.yml` | Needs every other job of the workflow; a failed, cancelled or skipped job fails it. One required check, so adding a job never needs a settings change. |
12
12
  | `Conventional title` | `pr-title.yml` | The squash commit takes the pull request title. |
13
- | `Analyze` | `codeql.yml` | Optional: require it when code scanning is enabled on the repository. |
13
+ | `Analyze` | `codeql.yml` | Only with `init --ci-extras codeql`: require it when code scanning is enabled on the repository. |
14
14
 
15
15
  ## Protect `main`
16
16
 
@@ -66,12 +66,13 @@ Expected: `{"checks":["gate","Conventional title"],"strict":true,"admins":true}`
66
66
 
67
67
  ## Notes
68
68
 
69
- - Dependency review needs the dependency graph: free on public repositories, GitHub Advanced
70
- Security (or GitHub Code Security) on private ones. Without it the step fails with an explicit
71
- message; remove the step and keep `npm run ci:audit`.
72
- - CodeQL is free on public repositories and needs GitHub Code Security on private ones.
69
+ - Not installed by default, because they need a paid plan on a private repository:
70
+ dependency review (`--ci-extras dependency-review`: free on public repositories, GitHub Code
71
+ Security or GitHub Advanced Security on private ones) and CodeQL (`--ci-extras codeql`: free on
72
+ public repositories, GitHub Code Security on private ones). `npm run ci:audit` and gitleaks
73
+ hold dependencies and secrets on every plan.
73
74
  - Secret scanning in `ci.yml` runs the gitleaks container, which needs no licence. The
74
- `gitleaks/gitleaks-action` wrapper is not used because it requires a licence key for
75
- organization accounts.
75
+ `gitleaks/gitleaks-action` wrapper is not used: it asks organization accounts for a licence
76
+ key (free, by its README) and is no longer MIT.
76
77
  - Dependabot (`dependabot.yml`) is GitHub only. `renovate.json` works on both platforms; keep one
77
78
  of the two, not both.
@@ -173,11 +173,14 @@ jobs:
173
173
  - uses: ./.github/actions/setup
174
174
  - name: Production dependencies audit
175
175
  run: npm run ci:audit
176
+ {{#if extras.dependencyReview}}
177
+ # Opt-in (--ci-extras dependency-review): free on a public repository, GitHub Code Security on a private one.
176
178
  - name: Dependency review
177
179
  if: ${{ github.event_name == 'pull_request' && !cancelled() }}
178
180
  uses: actions/dependency-review-action@v5.0.0
179
181
  with:
180
182
  fail-on-severity: high
183
+ {{/if}}
181
184
  - name: Secrets
182
185
  if: ${{ !cancelled() }}
183
186
  run: docker run --rm --volume "$GITHUB_WORKSPACE:/repo" ghcr.io/gitleaks/gitleaks:v8.30.1 git /repo --redact --no-banner
@@ -7,13 +7,22 @@ workflow:
7
7
  # A pipeline schedule (Build > Pipeline schedules, every night on the default branch) runs everything.
8
8
  - if: $CI_PIPELINE_SOURCE == "schedule"
9
9
 
10
+ {{#if extras.gitlabSecurity}}
11
+ # Opt-in (--ci-extras): these run on every tier, but their findings reach a merge request on Ultimate only.
10
12
  include:
13
+ {{#if extras.gitlabSast}}
11
14
  - template: Jobs/SAST.gitlab-ci.yml
15
+ {{/if}}
16
+ {{#if extras.gitlabSecretDetection}}
12
17
  - template: Jobs/Secret-Detection.gitlab-ci.yml
18
+ {{/if}}
19
+ {{#if extras.gitlabDependencyScanning}}
13
20
  - template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml
14
21
  rules:
15
22
  - if: $GITLAB_FEATURES =~ /\bdependency_scanning\b/
23
+ {{/if}}
16
24
 
25
+ {{/if}}
17
26
  stages:
18
27
  - install
19
28
  - test
@@ -21,7 +30,9 @@ stages:
21
30
  - gate
22
31
 
23
32
  variables:
33
+ {{#if extras.gitlabSecurity}}
24
34
  AST_ENABLE_MR_PIPELINES: 'true'
35
+ {{/if}}
25
36
  NODE_IMAGE: node:24-bookworm-slim
26
37
  # Behind the dependency proxy of a group, a registry that rate-limits is never asked twice:
27
38
  # POSTGRES_IMAGE: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/postgres:18
@@ -194,6 +205,9 @@ build:
194
205
  stage: test
195
206
  needs: [install]
196
207
  script:
208
+ {{#if sdk.on}}
209
+ # The production build, and the clients of the contract (sdk:build).
210
+ {{/if}}
197
211
  - npm run ci:build
198
212
  # The generated documents and contracts, from that build.
199
213
  - npm run ci:docs
@@ -76,14 +76,15 @@ glab api "projects/:id/protected_branches/main" | jq '{name, allow_force_push, p
76
76
 
77
77
  | Piece | Free | Premium | Ultimate |
78
78
  |---|---|---|---|
79
- | SAST template (`Jobs/SAST.gitlab-ci.yml`, Semgrep rules for JavaScript and TypeScript) | job runs, report downloadable as an artifact | same | findings in the merge request, vulnerability management, Advanced SAST |
80
- | Secret Detection template (`Jobs/Secret-Detection.gitlab-ci.yml`) | job runs, report downloadable as an artifact | same | findings in the merge request and the security dashboard |
81
- | Dependency Scanning template (`Jobs/Dependency-Scanning.v2.gitlab-ci.yml`) | not available: the `include` is skipped | not available | available |
79
+ | SAST template (`Jobs/SAST.gitlab-ci.yml`, Semgrep rules for JavaScript and TypeScript), `--ci-extras gitlab-sast` | job runs, report downloadable as an artifact | same | findings in the merge request, vulnerability management, Advanced SAST |
80
+ | Secret Detection template (`Jobs/Secret-Detection.gitlab-ci.yml`), `--ci-extras gitlab-secret-detection` | job runs, report downloadable as an artifact | same | findings in the merge request and the security dashboard |
81
+ | Dependency Scanning template (`Jobs/Dependency-Scanning.v2.gitlab-ci.yml`), `--ci-extras gitlab-dependency-scanning` | not available: the `include` is skipped | not available | available |
82
82
  | Code Quality report (ESLint and architecture) | merge request widget | plus the pipeline report tab | plus inline in the changes view |
83
83
  | JUnit report, coverage percentage, Cobertura coverage in the diff | available | available | available |
84
84
  | Push rules | no | yes | yes |
85
85
  | Required approvals | no | yes | yes |
86
86
 
87
- The template jobs are `allow_failure: true` by design of GitLab: on Free and Premium they never
88
- block a merge. What blocks, on every tier, is the `audit` job (`npm audit`, production
89
- dependencies, high and above) and the `secrets` job (gitleaks).
87
+ The three templates are not in `.gitlab-ci.yml` unless `init --ci-extras` names them: on Free
88
+ and Premium their findings reach no merge request, and their jobs are `allow_failure: true` by
89
+ design of GitLab, so they never block a merge. What blocks, on every tier, is the `audit` job
90
+ (`npm audit`, production dependencies, high and above) and the `secrets` job (gitleaks).
@@ -23,7 +23,7 @@
23
23
  "@biomejs/biome": "2.5.15",
24
24
  "@commitlint/cli": "^21.2.3",
25
25
  "@commitlint/config-conventional": "^21.2.3",
26
- "@ddd-ts-kit/eslint-plugin": "^0.4.1",
26
+ "@ddd-ts-kit/eslint-plugin": "^0.6.0",
27
27
  "@eslint/js": "^10.0.1",
28
28
  "@typescript/native": "npm:typescript@~7.0.2",
29
29
  "@vitest/coverage-v8": "5.0.3",
@@ -13,7 +13,7 @@ export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table(
13
13
  {
14
14
  id: text('id').primaryKey(),
15
15
  registeredAt: timestamp('registered_at', { withTimezone: true, mode: 'date' }).notNull(),
16
- // TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate`.
16
+ // TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate <what-it-does>`.
17
17
  version: integer('version').notNull(),
18
18
  ...tenantColumn(),
19
19
  ...auditColumns(),
@@ -25,7 +25,7 @@ export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table(
25
25
  export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table('{{aggregate.table}}', {
26
26
  id: text('id').primaryKey(),
27
27
  registeredAt: timestamp('registered_at', { withTimezone: true, mode: 'date' }).notNull(),
28
- // TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate`.
28
+ // TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate <what-it-does>`.
29
29
  version: integer('version').notNull(),
30
30
  ...auditColumns(),
31
31
  });
@@ -2,7 +2,7 @@
2
2
  model {{context.pascal}}{{aggregate.pascal}} {
3
3
  id String @id
4
4
  registeredAt DateTime @map("registered_at") @db.Timestamptz(3)
5
- // TODO(domain): add one field per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:client` and `npm run db:generate`.
5
+ // TODO(domain): add one field per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:client` and `npm run db:generate <what-it-does>`.
6
6
  version Int
7
7
  createdAt DateTime @map("created_at") @db.Timestamptz(3)
8
8
  createdBy String @map("created_by")
@@ -8,7 +8,7 @@ export const {{aggregate.tableCamel}} = new EntitySchema<{{aggregate.pascal}}Row
8
8
  columns: {
9
9
  id: { type: 'text', primary: true },
10
10
  registeredAt: { name: 'registered_at', type: 'timestamptz' },
11
- // TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce; then run `npm run db:generate`.
11
+ // TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce; then run `npm run build && npm run db:generate migrations/<what-it-does>`.
12
12
  version: { type: 'int' },
13
13
  ...auditColumns(),
14
14
  },
@@ -0,0 +1,30 @@
1
+ {{header}}
2
+ import { type Failure, ProblemError } from './runtime.js';
3
+ import type * as Schemas from './schemas.js';
4
+
5
+ /** Every error code an operation of the API declares: branch on these, never on a title or a message. */
6
+ export const ERROR_CODES = {{codes}} as const;
7
+
8
+ export type ErrorCode = (typeof ERROR_CODES)[number];
9
+
10
+ /** A problem document of the API with one of its codes. */
11
+ export type ProblemOf<Code extends ErrorCode = ErrorCode> = Failure<number, Code, {{problem}}>['problem'];
12
+
13
+ export function isErrorCode(value: unknown): value is ErrorCode {
14
+ return ERROR_CODES.some((code) => code === value);
15
+ }
16
+
17
+ /**
18
+ * True when `unwrap` threw a refusal of the API with one of the codes, any of its codes when none
19
+ * is given: `if (isProblem(error, 'SOME_CODE')) { ... }`.
20
+ */
21
+ export function isProblem<Code extends ErrorCode>(
22
+ error: unknown,
23
+ ...codes: readonly Code[]
24
+ ): error is ProblemError<Failure<number, Code, {{problem}}>> & { readonly code: Code } {
25
+ if (!(error instanceof ProblemError)) {
26
+ return false;
27
+ }
28
+
29
+ return codes.length === 0 ? isErrorCode(error.code) : codes.some((code) => code === error.code);
30
+ }