ddd-ts-kit 0.8.0 → 0.10.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 (317) hide show
  1. package/README.md +12 -2
  2. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  3. package/dist/check/catalogue/architecture-rules.js +14 -0
  4. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  5. package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
  6. package/dist/check/errors/kit-error-codes.js +5 -0
  7. package/dist/check/errors/kit-error-codes.js.map +1 -1
  8. package/dist/check/event-sourcing/declared-shape.d.ts +13 -0
  9. package/dist/check/event-sourcing/declared-shape.d.ts.map +1 -0
  10. package/dist/check/event-sourcing/declared-shape.js +100 -0
  11. package/dist/check/event-sourcing/declared-shape.js.map +1 -0
  12. package/dist/check/event-sourcing/event-sourced-classes.d.ts +5 -0
  13. package/dist/check/event-sourcing/event-sourced-classes.d.ts.map +1 -0
  14. package/dist/check/event-sourcing/event-sourced-classes.js +13 -0
  15. package/dist/check/event-sourcing/event-sourced-classes.js.map +1 -0
  16. package/dist/check/event-sourcing/fact-words.d.ts +6 -0
  17. package/dist/check/event-sourcing/fact-words.d.ts.map +1 -0
  18. package/dist/check/event-sourcing/fact-words.js +10 -0
  19. package/dist/check/event-sourcing/fact-words.js.map +1 -0
  20. package/dist/check/event-sourcing/is-apply-method.d.ts +3 -0
  21. package/dist/check/event-sourcing/is-apply-method.d.ts.map +1 -0
  22. package/dist/check/event-sourcing/is-apply-method.js +6 -0
  23. package/dist/check/event-sourcing/is-apply-method.js.map +1 -0
  24. package/dist/check/event-sourcing/kernel-names.d.ts +8 -0
  25. package/dist/check/event-sourcing/kernel-names.d.ts.map +1 -0
  26. package/dist/check/event-sourcing/kernel-names.js +7 -0
  27. package/dist/check/event-sourcing/kernel-names.js.map +1 -0
  28. package/dist/check/event-sourcing/read-stored-events-lock.d.ts +5 -0
  29. package/dist/check/event-sourcing/read-stored-events-lock.d.ts.map +1 -0
  30. package/dist/check/event-sourcing/read-stored-events-lock.js +25 -0
  31. package/dist/check/event-sourcing/read-stored-events-lock.js.map +1 -0
  32. package/dist/check/event-sourcing/read-stored-shape.d.ts +12 -0
  33. package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -0
  34. package/dist/check/event-sourcing/read-stored-shape.js +46 -0
  35. package/dist/check/event-sourcing/read-stored-shape.js.map +1 -0
  36. package/dist/check/event-sourcing/state-writes.d.ts +3 -0
  37. package/dist/check/event-sourcing/state-writes.d.ts.map +1 -0
  38. package/dist/check/event-sourcing/state-writes.js +11 -0
  39. package/dist/check/event-sourcing/state-writes.js.map +1 -0
  40. package/dist/check/event-sourcing/stored-event-declaration.d.ts +18 -0
  41. package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -0
  42. package/dist/check/event-sourcing/stored-event-declaration.js +2 -0
  43. package/dist/check/event-sourcing/stored-event-declaration.js.map +1 -0
  44. package/dist/check/event-sourcing/stored-event-declarations.d.ts +9 -0
  45. package/dist/check/event-sourcing/stored-event-declarations.d.ts.map +1 -0
  46. package/dist/check/event-sourcing/stored-event-declarations.js +64 -0
  47. package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -0
  48. package/dist/check/event-sourcing/stored-events-lock-file.d.ts +3 -0
  49. package/dist/check/event-sourcing/stored-events-lock-file.d.ts.map +1 -0
  50. package/dist/check/event-sourcing/stored-events-lock-file.js +3 -0
  51. package/dist/check/event-sourcing/stored-events-lock-file.js.map +1 -0
  52. package/dist/check/event-sourcing/stored-shape.d.ts +7 -0
  53. package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -0
  54. package/dist/check/event-sourcing/stored-shape.js +2 -0
  55. package/dist/check/event-sourcing/stored-shape.js.map +1 -0
  56. package/dist/check/event-sourcing/words-of.d.ts +3 -0
  57. package/dist/check/event-sourcing/words-of.d.ts.map +1 -0
  58. package/dist/check/event-sourcing/words-of.js +9 -0
  59. package/dist/check/event-sourcing/words-of.js.map +1 -0
  60. package/dist/check/events/event-name-resolver.d.ts +6 -0
  61. package/dist/check/events/event-name-resolver.d.ts.map +1 -0
  62. package/dist/check/events/event-name-resolver.js +21 -0
  63. package/dist/check/events/event-name-resolver.js.map +1 -0
  64. package/dist/check/explain/errors-docs.js +1 -1
  65. package/dist/check/explain/errors-docs.js.map +1 -1
  66. package/dist/check/explain/event-sourcing-docs.d.ts +3 -0
  67. package/dist/check/explain/event-sourcing-docs.d.ts.map +1 -0
  68. package/dist/check/explain/event-sourcing-docs.js +62 -0
  69. package/dist/check/explain/event-sourcing-docs.js.map +1 -0
  70. package/dist/check/explain/persistence-docs.d.ts.map +1 -1
  71. package/dist/check/explain/persistence-docs.js +26 -0
  72. package/dist/check/explain/persistence-docs.js.map +1 -1
  73. package/dist/check/explain/rule-docs.d.ts.map +1 -1
  74. package/dist/check/explain/rule-docs.js +2 -0
  75. package/dist/check/explain/rule-docs.js.map +1 -1
  76. package/dist/check/files/file-content-findings.d.ts +4 -0
  77. package/dist/check/files/file-content-findings.d.ts.map +1 -0
  78. package/dist/check/files/file-content-findings.js +29 -0
  79. package/dist/check/files/file-content-findings.js.map +1 -0
  80. package/dist/check/files/file-content-pattern.d.ts +7 -0
  81. package/dist/check/files/file-content-pattern.d.ts.map +1 -0
  82. package/dist/check/files/file-content-pattern.js +17 -0
  83. package/dist/check/files/file-content-pattern.js.map +1 -0
  84. package/dist/check/files/schema-sources.d.ts +13 -0
  85. package/dist/check/files/schema-sources.d.ts.map +1 -0
  86. package/dist/check/files/schema-sources.js +37 -0
  87. package/dist/check/files/schema-sources.js.map +1 -0
  88. package/dist/check/fixtures/event-sourcing-fixtures.d.ts +3 -0
  89. package/dist/check/fixtures/event-sourcing-fixtures.d.ts.map +1 -0
  90. package/dist/check/fixtures/event-sourcing-fixtures.js +199 -0
  91. package/dist/check/fixtures/event-sourcing-fixtures.js.map +1 -0
  92. package/dist/check/fixtures/event-sourcing-projection-fixtures.d.ts +3 -0
  93. package/dist/check/fixtures/event-sourcing-projection-fixtures.d.ts.map +1 -0
  94. package/dist/check/fixtures/event-sourcing-projection-fixtures.js +48 -0
  95. package/dist/check/fixtures/event-sourcing-projection-fixtures.js.map +1 -0
  96. package/dist/check/fixtures/files-fixtures.d.ts +3 -0
  97. package/dist/check/fixtures/files-fixtures.d.ts.map +1 -0
  98. package/dist/check/fixtures/files-fixtures.js +92 -0
  99. package/dist/check/fixtures/files-fixtures.js.map +1 -0
  100. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  101. package/dist/check/fixtures/fixtures.js +4 -0
  102. package/dist/check/fixtures/fixtures.js.map +1 -1
  103. package/dist/check/layers/outside-concern.d.ts.map +1 -1
  104. package/dist/check/layers/outside-concern.js +4 -0
  105. package/dist/check/layers/outside-concern.js.map +1 -1
  106. package/dist/check/rules/event-sourcing-past-tense.d.ts +3 -0
  107. package/dist/check/rules/event-sourcing-past-tense.d.ts.map +1 -0
  108. package/dist/check/rules/event-sourcing-past-tense.js +31 -0
  109. package/dist/check/rules/event-sourcing-past-tense.js.map +1 -0
  110. package/dist/check/rules/event-sourcing-projection-never-appends.d.ts +3 -0
  111. package/dist/check/rules/event-sourcing-projection-never-appends.d.ts.map +1 -0
  112. package/dist/check/rules/event-sourcing-projection-never-appends.js +54 -0
  113. package/dist/check/rules/event-sourcing-projection-never-appends.js.map +1 -0
  114. package/dist/check/rules/event-sourcing-state-in-apply.d.ts +3 -0
  115. package/dist/check/rules/event-sourcing-state-in-apply.d.ts.map +1 -0
  116. package/dist/check/rules/event-sourcing-state-in-apply.js +34 -0
  117. package/dist/check/rules/event-sourcing-state-in-apply.js.map +1 -0
  118. package/dist/check/rules/event-sourcing-store-behind-repository.d.ts +3 -0
  119. package/dist/check/rules/event-sourcing-store-behind-repository.d.ts.map +1 -0
  120. package/dist/check/rules/event-sourcing-store-behind-repository.js +34 -0
  121. package/dist/check/rules/event-sourcing-store-behind-repository.js.map +1 -0
  122. package/dist/check/rules/event-sourcing-upcaster-required.d.ts +3 -0
  123. package/dist/check/rules/event-sourcing-upcaster-required.d.ts.map +1 -0
  124. package/dist/check/rules/event-sourcing-upcaster-required.js +79 -0
  125. package/dist/check/rules/event-sourcing-upcaster-required.js.map +1 -0
  126. package/dist/check/rules/files-port-not-connector.d.ts +3 -0
  127. package/dist/check/rules/files-port-not-connector.d.ts.map +1 -0
  128. package/dist/check/rules/files-port-not-connector.js +28 -0
  129. package/dist/check/rules/files-port-not-connector.js.map +1 -0
  130. package/dist/check/rules/persistence-no-file-content.d.ts +3 -0
  131. package/dist/check/rules/persistence-no-file-content.d.ts.map +1 -0
  132. package/dist/check/rules/persistence-no-file-content.js +14 -0
  133. package/dist/check/rules/persistence-no-file-content.js.map +1 -0
  134. package/dist/commands/docs.d.ts.map +1 -1
  135. package/dist/commands/docs.js +44 -11
  136. package/dist/commands/docs.js.map +1 -1
  137. package/dist/commands/format-context.d.ts.map +1 -1
  138. package/dist/commands/format-context.js +1 -1
  139. package/dist/commands/format-context.js.map +1 -1
  140. package/dist/commands/generate.js +2 -0
  141. package/dist/commands/generate.js.map +1 -1
  142. package/dist/commands/init.d.ts.map +1 -1
  143. package/dist/commands/init.js +1 -0
  144. package/dist/commands/init.js.map +1 -1
  145. package/dist/config/index.d.ts +1 -1
  146. package/dist/config/index.d.ts.map +1 -1
  147. package/dist/config/index.js +1 -1
  148. package/dist/config/index.js.map +1 -1
  149. package/dist/config/parse-stack.d.ts.map +1 -1
  150. package/dist/config/parse-stack.js +2 -1
  151. package/dist/config/parse-stack.js.map +1 -1
  152. package/dist/config/stack.d.ts +8 -0
  153. package/dist/config/stack.d.ts.map +1 -1
  154. package/dist/config/stack.js +1 -0
  155. package/dist/config/stack.js.map +1 -1
  156. package/dist/describe/context-description.d.ts +2 -0
  157. package/dist/describe/context-description.d.ts.map +1 -1
  158. package/dist/describe/describe-context.js +1 -0
  159. package/dist/describe/describe-context.js.map +1 -1
  160. package/dist/describe/format-description.d.ts.map +1 -1
  161. package/dist/describe/format-description.js +4 -1
  162. package/dist/describe/format-description.js.map +1 -1
  163. package/dist/docs/context-facts.d.ts +2 -0
  164. package/dist/docs/context-facts.d.ts.map +1 -1
  165. package/dist/docs/declared-stored-events.d.ts +9 -0
  166. package/dist/docs/declared-stored-events.d.ts.map +1 -0
  167. package/dist/docs/declared-stored-events.js +22 -0
  168. package/dist/docs/declared-stored-events.js.map +1 -0
  169. package/dist/docs/read-context.js +10 -0
  170. package/dist/docs/read-context.js.map +1 -1
  171. package/dist/docs/refresh-context-doc.js +1 -1
  172. package/dist/docs/refresh-context-doc.js.map +1 -1
  173. package/dist/docs/unrecorded-stored-events.d.ts +9 -0
  174. package/dist/docs/unrecorded-stored-events.d.ts.map +1 -0
  175. package/dist/docs/unrecorded-stored-events.js +17 -0
  176. package/dist/docs/unrecorded-stored-events.js.map +1 -0
  177. package/dist/docs/write-docs.d.ts +1 -2
  178. package/dist/docs/write-docs.d.ts.map +1 -1
  179. package/dist/docs/write-docs.js +1 -2
  180. package/dist/docs/write-docs.js.map +1 -1
  181. package/dist/docs/write-stored-events-lock.d.ts +12 -0
  182. package/dist/docs/write-stored-events-lock.d.ts.map +1 -0
  183. package/dist/docs/write-stored-events-lock.js +41 -0
  184. package/dist/docs/write-stored-events-lock.js.map +1 -0
  185. package/dist/generate/event-names.d.ts +2 -0
  186. package/dist/generate/event-names.d.ts.map +1 -1
  187. package/dist/generate/event-names.js +1 -0
  188. package/dist/generate/event-names.js.map +1 -1
  189. package/dist/generate/kind.d.ts +2 -0
  190. package/dist/generate/kind.d.ts.map +1 -1
  191. package/dist/generate/kinds/aggregate-kind.d.ts.map +1 -1
  192. package/dist/generate/kinds/aggregate-kind.js +8 -2
  193. package/dist/generate/kinds/aggregate-kind.js.map +1 -1
  194. package/dist/generate/kinds/domain-event-kind.d.ts.map +1 -1
  195. package/dist/generate/kinds/domain-event-kind.js +5 -2
  196. package/dist/generate/kinds/domain-event-kind.js.map +1 -1
  197. package/dist/generate/kinds/event-vars.d.ts.map +1 -1
  198. package/dist/generate/kinds/event-vars.js +6 -1
  199. package/dist/generate/kinds/event-vars.js.map +1 -1
  200. package/dist/generate/kinds/extend-event-sourced-aggregate.d.ts +9 -0
  201. package/dist/generate/kinds/extend-event-sourced-aggregate.d.ts.map +1 -0
  202. package/dist/generate/kinds/extend-event-sourced-aggregate.js +67 -0
  203. package/dist/generate/kinds/extend-event-sourced-aggregate.js.map +1 -0
  204. package/dist/generate/kinds/file-upload/write-upload-controller.d.ts +5 -0
  205. package/dist/generate/kinds/file-upload/write-upload-controller.d.ts.map +1 -0
  206. package/dist/generate/kinds/file-upload/write-upload-controller.js +42 -0
  207. package/dist/generate/kinds/file-upload/write-upload-controller.js.map +1 -0
  208. package/dist/generate/kinds/file-upload-kind.d.ts +3 -0
  209. package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -0
  210. package/dist/generate/kinds/file-upload-kind.js +55 -0
  211. package/dist/generate/kinds/file-upload-kind.js.map +1 -0
  212. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts +8 -0
  213. package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -0
  214. package/dist/generate/kinds/write-event-sourced-aggregate.js +24 -0
  215. package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -0
  216. package/dist/generate/kinds.d.ts.map +1 -1
  217. package/dist/generate/kinds.js +2 -0
  218. package/dist/generate/kinds.js.map +1 -1
  219. package/dist/help/notes.d.ts +1 -1
  220. package/dist/help/notes.d.ts.map +1 -1
  221. package/dist/help/notes.js +3 -0
  222. package/dist/help/notes.js.map +1 -1
  223. package/dist/help/usage.d.ts +1 -1
  224. package/dist/help/usage.d.ts.map +1 -1
  225. package/dist/help/usage.js +3 -2
  226. package/dist/help/usage.js.map +1 -1
  227. package/dist/init/files/platform-files.d.ts.map +1 -1
  228. package/dist/init/files/platform-files.js +22 -0
  229. package/dist/init/files/platform-files.js.map +1 -1
  230. package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
  231. package/dist/init/manifest/dependencies-for.js +7 -1
  232. package/dist/init/manifest/dependencies-for.js.map +1 -1
  233. package/dist/init/manifest/versions.d.ts.map +1 -1
  234. package/dist/init/manifest/versions.js +28 -23
  235. package/dist/init/manifest/versions.js.map +1 -1
  236. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  237. package/dist/init/stack/resolve-stack.js +11 -2
  238. package/dist/init/stack/resolve-stack.js.map +1 -1
  239. package/dist/init/stack/stack-options.d.ts +1 -0
  240. package/dist/init/stack/stack-options.d.ts.map +1 -1
  241. package/dist/init/template-vars.d.ts.map +1 -1
  242. package/dist/init/template-vars.js +3 -2
  243. package/dist/init/template-vars.js.map +1 -1
  244. package/dist/naming/index.d.ts +2 -0
  245. package/dist/naming/index.d.ts.map +1 -1
  246. package/dist/naming/index.js +2 -0
  247. package/dist/naming/index.js.map +1 -1
  248. package/dist/naming/is-past-fact.d.ts +7 -0
  249. package/dist/naming/is-past-fact.d.ts.map +1 -0
  250. package/dist/naming/is-past-fact.js +18 -0
  251. package/dist/naming/is-past-fact.js.map +1 -0
  252. package/dist/naming/is-past-word.d.ts +3 -0
  253. package/dist/naming/is-past-word.d.ts.map +1 -0
  254. package/dist/naming/is-past-word.js +113 -0
  255. package/dist/naming/is-past-word.js.map +1 -0
  256. package/dist/naming/looks-like-past-fact.d.ts +1 -1
  257. package/dist/naming/looks-like-past-fact.d.ts.map +1 -1
  258. package/dist/naming/looks-like-past-fact.js +3 -66
  259. package/dist/naming/looks-like-past-fact.js.map +1 -1
  260. package/dist/stack/files-vars.d.ts +5 -0
  261. package/dist/stack/files-vars.d.ts.map +1 -0
  262. package/dist/stack/files-vars.js +11 -0
  263. package/dist/stack/files-vars.js.map +1 -0
  264. package/dist/stack/stack-vars.d.ts.map +1 -1
  265. package/dist/stack/stack-vars.js +13 -4
  266. package/dist/stack/stack-vars.js.map +1 -1
  267. package/dist/version.d.ts +1 -1
  268. package/dist/version.d.ts.map +1 -1
  269. package/dist/version.js +1 -1
  270. package/dist/version.js.map +1 -1
  271. package/package.json +3 -3
  272. package/templates/aggregate/event-sourced.aggregate.spec.ts.tpl +26 -0
  273. package/templates/aggregate/event-sourced.aggregate.ts.tpl +61 -0
  274. package/templates/aggregate/event-sourced.events.mapper.ts.tpl +15 -0
  275. package/templates/builder/event-sourced.builder.ts.tpl +36 -0
  276. package/templates/file-upload/command.ts.tpl +41 -0
  277. package/templates/file-upload/controller.spec.ts.tpl +46 -0
  278. package/templates/file-upload/controller.ts.tpl +23 -0
  279. package/templates/file-upload/handler.declared.ts.tpl +18 -0
  280. package/templates/file-upload/handler.spec.ts.tpl +79 -0
  281. package/templates/file-upload/handler.ts.tpl +16 -0
  282. package/templates/file-upload/wiring.manual.tpl +9 -0
  283. package/templates/file-upload/wiring.tsyringe.tpl +7 -0
  284. package/templates/init/CLAUDE.md.tpl +1 -1
  285. package/templates/init/README.md.tpl +22 -0
  286. package/templates/init/docker/docker-compose.yml.tpl +25 -0
  287. package/templates/init/docker/env.example.tpl +21 -0
  288. package/templates/init/gitignore.tpl +3 -0
  289. package/templates/init/main.ts.tpl +6 -0
  290. package/templates/init/platform/auth/http-boundary.ts.tpl +25 -1
  291. package/templates/init/platform/buses/create-command-bus.ts.tpl +7 -1
  292. package/templates/init/platform/compose-application.manual.ts.tpl +25 -0
  293. package/templates/init/platform/compose-application.tsyringe.ts.tpl +31 -0
  294. package/templates/init/platform/config/app-config.ts.tpl +7 -0
  295. package/templates/init/platform/config/load-config.ts.tpl +9 -0
  296. package/templates/init/platform/config/read-files.local.ts.tpl +39 -0
  297. package/templates/init/platform/config/read-files.s3.ts.tpl +42 -0
  298. package/templates/init/platform/create-platform.manual.ts.tpl +38 -1
  299. package/templates/init/platform/files/bind-files.tsyringe.ts.tpl +32 -0
  300. package/templates/init/platform/files/create-files.ts.tpl +34 -0
  301. package/templates/init/platform/files/file-routes.ts.tpl +10 -0
  302. package/templates/init/platform/files/files.module.tsyringe.ts.tpl +18 -0
  303. package/templates/init/platform/files/open-files.local.ts.tpl +13 -0
  304. package/templates/init/platform/files/open-files.s3.ts.tpl +10 -0
  305. package/templates/init/platform/files/staging-uploads.tsyringe.ts.tpl +11 -0
  306. package/templates/init/platform/http/start-http-server.express.ts.tpl +5 -1
  307. package/templates/init/platform/http/start-http-server.fastify.ts.tpl +4 -1
  308. package/templates/init/platform/http/start-http-server.nest.ts.tpl +12 -1
  309. package/templates/init/platform/platform-test.module.tsyringe.ts.tpl +11 -0
  310. package/templates/init/platform/platform.manual.ts.tpl +7 -0
  311. package/templates/init/rules/application.md.tpl +4 -0
  312. package/templates/init/rules/domain.md.tpl +1 -0
  313. package/templates/init/rules/infrastructure.md.tpl +2 -0
  314. package/templates/init/rules/platform.md.tpl +3 -0
  315. package/templates/pipeline/package-scripts.json +1 -1
  316. package/templates/service/main.ts.tpl +6 -0
  317. package/templates/worker/main.ts.tpl +6 -0
@@ -0,0 +1,64 @@
1
+ import { callArguments } from '../text/call-arguments.js';
2
+ import { splitTopLevel } from '../text/split-top-level.js';
3
+ import { readStoredShape } from './read-stored-shape.js';
4
+ const CALL = /(?<![\w$.])defineStoredEvent\s*(?:<[^()]*>)?\s*\(/g;
5
+ const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
6
+ const VERSION = /^version\s*:\s*(\d+)$/;
7
+ const UPCASTERS = /^upcasters\s*:\s*\{/;
8
+ const UPCASTER_KEY = /^['"]?(\d+)['"]?\s*:/;
9
+ const COMPUTED_NAME = /\[\s*([A-Za-z_$][\w$]*)\.eventName\s*\]\s*:\s*$/;
10
+ const ENCODE = /^encode\s*(?::\s*(?:async\s*)?(?:function\s*)?)?\([^()]*\)\s*:\s*([A-Za-z_$][\w$]*)/;
11
+ /**
12
+ * The stored events a file declares with `defineStoredEvent`, outside tests. A key written
13
+ * `[InvoiceIssued.eventName]` is read through `eventNameOf`, as the name the class declares.
14
+ */
15
+ export function storedEventDeclarations(file, eventNameOf = () => undefined) {
16
+ if (file.isTest) {
17
+ return [];
18
+ }
19
+ const { code } = file.scan;
20
+ return [...code.matchAll(CALL)].flatMap((match) => {
21
+ const [type, spec] = callArguments(code, match.index + match[0].length - 1);
22
+ if (type === undefined || !IDENTIFIER.test(type.code) || spec?.code.startsWith('{') !== true) {
23
+ return [];
24
+ }
25
+ return [declarationOf(file, { at: match.index, eventClass: type.code, spec }, eventNameOf)];
26
+ });
27
+ }
28
+ function declarationOf(file, { at, eventClass, spec }, eventNameOf) {
29
+ const properties = splitTopLevel(spec.code.slice(1, spec.code.lastIndexOf('}'))).map((part) => part.code);
30
+ const payloadType = properties.map((property) => ENCODE.exec(property)?.[1]).find((name) => name !== undefined);
31
+ const version = properties.map((property) => VERSION.exec(property)?.[1]).find((value) => value !== undefined);
32
+ const shape = payloadType === undefined ? undefined : readStoredShape(file.scan, payloadType);
33
+ return {
34
+ name: keyBefore(file, at) ?? computedKeyBefore(file, at, eventNameOf),
35
+ eventClass,
36
+ line: file.scan.lineAt(at),
37
+ version: version === undefined ? undefined : Number(version),
38
+ upcasters: upcastersOf(properties),
39
+ payloadType,
40
+ fingerprint: shape?.fingerprint,
41
+ unresolved: shape?.unresolved ?? [],
42
+ };
43
+ }
44
+ /** The string literal the call is the value of, as in `'billing.invoice.issued': defineStoredEvent(...)`. */
45
+ function keyBefore(file, at) {
46
+ const { code, strings } = file.scan;
47
+ return strings.find((literal) => literal.end <= at && /^\s*:\s*$/.test(code.slice(literal.end, at)))?.value;
48
+ }
49
+ /** The name read by a computed key, as in `[InvoiceIssued.eventName]: defineStoredEvent(...)`. */
50
+ function computedKeyBefore(file, at, eventNameOf) {
51
+ const eventClass = COMPUTED_NAME.exec(file.scan.code.slice(Math.max(0, at - 200), at))?.[1];
52
+ return eventClass === undefined ? undefined : eventNameOf(eventClass);
53
+ }
54
+ function upcastersOf(properties) {
55
+ const upcasters = properties.find((property) => UPCASTERS.test(property));
56
+ if (upcasters === undefined) {
57
+ return [];
58
+ }
59
+ return splitTopLevel(upcasters.slice(upcasters.indexOf('{') + 1, upcasters.lastIndexOf('}'))).flatMap((part) => {
60
+ const key = UPCASTER_KEY.exec(part.code)?.[1];
61
+ return key === undefined ? [] : [Number(key)];
62
+ });
63
+ }
64
+ //# sourceMappingURL=stored-event-declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-event-declarations.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-event-declarations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,IAAI,GAAG,oDAAoD,CAAC;AAClE,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC,MAAM,OAAO,GAAG,uBAAuB,CAAC;AACxC,MAAM,SAAS,GAAG,qBAAqB,CAAC;AACxC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAC5C,MAAM,aAAa,GAAG,iDAAiD,CAAC;AACxE,MAAM,MAAM,GAAG,qFAAqF,CAAC;AAErG;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAgB,EAChB,WAAW,GAAsB,GAAG,EAAE,CAAC,SAAS;IAEhD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;IAE3B,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAChD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE5E,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,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W,CAAC,UAA6B;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE1E,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7G,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAE9C,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The lock of stored shapes, at the root of the project, committed: once a version is in it, its shape is the one stored. */
2
+ export declare const STORED_EVENTS_LOCK = "stored-events.lock.json";
3
+ //# sourceMappingURL=stored-events-lock-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-events-lock-file.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-events-lock-file.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,eAAO,MAAM,kBAAkB,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The lock of stored shapes, at the root of the project, committed: once a version is in it, its shape is the one stored. */
2
+ export const STORED_EVENTS_LOCK = 'stored-events.lock.json';
3
+ //# sourceMappingURL=stored-events-lock-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-events-lock-file.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-events-lock-file.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** What `readStoredShape` reads of the data type of a stored event. */
2
+ export interface StoredShape {
3
+ readonly fingerprint: string;
4
+ /** The named types the shape reaches that the file does not declare, in the order met. */
5
+ readonly unresolved: readonly string[];
6
+ }
7
+ //# sourceMappingURL=stored-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-shape.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-shape.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stored-shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-shape.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-shape.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** The words of a PascalCase or kebab-case name, in lower case. */
2
+ export declare function wordsOf(name: string): string[];
3
+ //# sourceMappingURL=words-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words-of.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/words-of.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9C"}
@@ -0,0 +1,9 @@
1
+ /** The words of a PascalCase or kebab-case name, in lower case. */
2
+ export function wordsOf(name) {
3
+ return name
4
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
5
+ .split(/[\s\-_.]+/)
6
+ .filter((word) => word !== '')
7
+ .map((word) => word.toLowerCase());
8
+ }
9
+ //# sourceMappingURL=words-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words-of.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/words-of.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;SAC7B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SourceFile } from '../model/source-file.js';
2
+ /** The name an event class declares, found by the name of the class. */
3
+ export type EventNameResolver = (eventClass: string) => string | undefined;
4
+ /** Reads `<Event>.eventName` among these files: the name the class `<Event>` declares once. */
5
+ export declare function eventNameResolver(files: readonly SourceFile[]): EventNameResolver;
6
+ //# sourceMappingURL=event-name-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-name-resolver.d.ts","sourceRoot":"","sources":["../../../src/check/events/event-name-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAE3E,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,iBAAiB,CAUjF"}
@@ -0,0 +1,21 @@
1
+ import { nameOfEventClass } from './name-of-event-class.js';
2
+ /** Reads `<Event>.eventName` among these files: the name the class `<Event>` declares once. */
3
+ export function eventNameResolver(files) {
4
+ const known = new Map();
5
+ return (eventClass) => {
6
+ if (!known.has(eventClass)) {
7
+ known.set(eventClass, firstName(files, eventClass));
8
+ }
9
+ return known.get(eventClass);
10
+ };
11
+ }
12
+ function firstName(files, eventClass) {
13
+ for (const file of files) {
14
+ const name = nameOfEventClass(file, eventClass);
15
+ if (name !== undefined) {
16
+ return name;
17
+ }
18
+ }
19
+ return undefined;
20
+ }
21
+ //# sourceMappingURL=event-name-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-name-resolver.js","sourceRoot":"","sources":["../../../src/check/events/event-name-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5D,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,KAA4B;IAC5D,MAAM,KAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEpD,OAAO,CAAC,UAAU,EAAE,EAAE;QACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B,EAAE,UAAkB;IACjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEhD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -21,7 +21,7 @@ export const ERRORS_DOCS = {
21
21
  }`,
22
22
  },
23
23
  'errors/known-code': {
24
- why: 'The `errors` list of a route is what the OpenAPI document promises: one problem response per status of the codes it names. A code written there that no refusal sets, misspelled or left behind by a renamed factory, is a response the contract documents and the API never gives, while the refusal really raised is missing from it. A code exists when a factory or an error class of the context of the route sets it, when a class outside the contexts (the platform, the shared kernel) does, or when it is a code of the kit: VALIDATION_FAILED, NOT_FOUND, CONFLICT, INVARIANT_VIOLATION, UNAUTHORIZED, FORBIDDEN, CONCURRENCY_CONFLICT, INVALID_CRITERIA, INVALID_PAGE_REQUEST, TIMEOUT, CIRCUIT_OPEN, BULKHEAD_FULL, ATTEMPTS_EXHAUSTED. A code another context sets does not count: a context answers with its own language. Judged under "stack.refusals": "factories" only.',
24
+ why: 'The `errors` list of a route is what the OpenAPI document promises: one problem response per status of the codes it names. A code written there that no refusal sets, misspelled or left behind by a renamed factory, is a response the contract documents and the API never gives, while the refusal really raised is missing from it. A code exists when a factory or an error class of the context of the route sets it, when a class outside the contexts (the platform, the shared kernel) does, or when it is a code of the kit: VALIDATION_FAILED, NOT_FOUND, CONFLICT, INVARIANT_VIOLATION, UNAUTHORIZED, FORBIDDEN, CONCURRENCY_CONFLICT, INVALID_CRITERIA, INVALID_PAGE_REQUEST, TIMEOUT, CIRCUIT_OPEN, BULKHEAD_FULL, ATTEMPTS_EXHAUSTED, and the refusals of a file: FILE_TOO_LARGE, UNSUPPORTED_MEDIA_TYPE, FILE_NOT_FOUND, FILE_REJECTED, INVALID_FILE_KEY. A code another context sets does not count: a context answers with its own language. Judged under "stack.refusals": "factories" only.',
25
25
  bad: `// domain/errors/appointment.error.ts sets 'SLOT_TAKEN'
26
26
  defineRoute({ method: 'POST', path: '/appointments', errors: ['FORBIDDEN', 'SLOT_ALREADY_TAKEN'], security: ['bearer'] }, book);`,
27
27
  good: `defineRoute({ method: 'POST', path: '/appointments', errors: ['FORBIDDEN', 'SLOT_TAKEN'], security: ['bearer'] }, book);`,
@@ -1 +1 @@
1
- {"version":3,"file":"errors-docs.js","sourceRoot":"","sources":["../../../src/check/explain/errors-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,oBAAoB,EAAE;QACpB,GAAG,EAAE,y1BAAy1B;QAC91B,GAAG,EAAE;;;;;;;;EAQP;QACE,IAAI,EAAE;;;;;;;;EAQR;KACC;IACD,mBAAmB,EAAE;QACnB,GAAG,EAAE,41BAA41B;QACj2B,GAAG,EAAE;iIACwH;QAC7H,IAAI,EAAE,0HAA0H;KACjI;CACF,CAAC"}
1
+ {"version":3,"file":"errors-docs.js","sourceRoot":"","sources":["../../../src/check/explain/errors-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAsC;IAC5D,oBAAoB,EAAE;QACpB,GAAG,EAAE,y1BAAy1B;QAC91B,GAAG,EAAE;;;;;;;;EAQP;QACE,IAAI,EAAE;;;;;;;;EAQR;KACC;IACD,mBAAmB,EAAE;QACnB,GAAG,EAAE,i9BAAi9B;QACt9B,GAAG,EAAE;iIACwH;QAC7H,IAAI,EAAE,0HAA0H;KACjI;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RuleDoc } from '../model/rule-doc.js';
2
+ export declare const EVENT_SOURCING_DOCS: Readonly<Record<string, RuleDoc>>;
3
+ //# sourceMappingURL=event-sourcing-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-sourcing-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/event-sourcing-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4DjE,CAAC"}
@@ -0,0 +1,62 @@
1
+ export const EVENT_SOURCING_DOCS = {
2
+ 'event-sourcing/state-in-apply': {
3
+ why: 'An event-sourced aggregate is rebuilt by replaying its events through its apply methods, so the state a command leaves must be exactly what those methods make of the events it recorded. A command that also writes the state directly produces a state no replay will ever rebuild: the aggregate behaves one way just after the command and another way once loaded. Judged: every class of domain/aggregates/ that extends EventSourcedAggregate; outside the constructor, the static methods and the apply methods (a method named apply followed by an upper-case letter, and restore, which takes the state of a snapshot), an assignment, an increment or a mutating call (push, splice, set, add, delete...) on something of this is reported, and so is this.record(..) inside an apply method, which would record the event again at each replay.',
4
+ bad: `// domain/aggregates/attendance-record.aggregate.ts
5
+ noteNoShow(appointmentId: string, now: Date): void {
6
+ this.state = { noShows: this.state.noShows + 1 }; // written twice: here and by the replay
7
+ this.record(new NoShowNoted(this.id, now, appointmentId));
8
+ }`,
9
+ good: `// domain/aggregates/attendance-record.aggregate.ts
10
+ noteNoShow(appointmentId: string, now: Date): void {
11
+ this.record(new NoShowNoted(this.id, now, appointmentId));
12
+ }
13
+
14
+ private applyNoShowNoted(event: NoShowNoted): void {
15
+ this.state = { noShows: this.state.noShows + 1 };
16
+ }`,
17
+ },
18
+ 'event-sourcing/past-tense': {
19
+ why: 'A stored event is a fact that is kept and replayed for as long as the aggregate lives, read by people and by projections that were not written yet. A name in the present or the imperative (BookAppointment, Cancel) reads as a request that may still be refused; a name in the past tense says it happened. Judged: in a file of domain/aggregates/ holding a class that extends EventSourcedAggregate, every name imported from domain/events/. Its fact is judged, the words after the name of the aggregate when it starts with it (InvoiceIssued of Invoice: Issued), the whole name otherwise: one word of it must read as a past participle (ending in -ed, or a common irregular one such as paid, held, taken, withdrawn, sent, set, made, done, lost, won), and a participle spelled like its imperative (set, put, read, run, cut, found, left...) does not count at the head of the fact, where it reads as a command (SetPrice, ReadInvoice). The same words generate domain-event accepts.',
20
+ bad: `// domain/aggregates/attendance-record.aggregate.ts
21
+ import { NoteNoShow } from '@/contexts/scheduling/domain/events/note-no-show.event';`,
22
+ good: `// domain/aggregates/attendance-record.aggregate.ts
23
+ import { NoShowNoted } from '@/contexts/scheduling/domain/events/no-show-noted.event';`,
24
+ },
25
+ 'event-sourcing/store-behind-repository': {
26
+ why: "The domain and the use cases see an event-sourced aggregate exactly as they see any other: loaded by its repository port, changed by its methods, saved by the same port. A handler that reads a stream itself decides how events become state, which is the aggregate's job, and binds the use case to a storage technique the next aggregate may not use. Judged: production files of domain/ and application/ of a context; importing EventStore, SnapshotStore, CheckpointStore, EventSourcedRepository, EventSerializer, CatchUpSubscription or InMemoryEventStore from @ddd-ts-kit/kernel is reported. Infrastructure, the module file and the platform are left alone.",
27
+ bad: `// application/commands/note-no-show/note-no-show.handler.ts
28
+ constructor(private readonly store: EventStore) {}
29
+ const events = await this.store.readStream(\`scheduling.attendance-record-\${command.patientId}\`);`,
30
+ good: `// application/commands/note-no-show/note-no-show.handler.ts
31
+ constructor(private readonly records: AttendanceRecordRepository) {}
32
+ const record = await this.records.findById(command.patientId);`,
33
+ },
34
+ 'event-sourcing/projection-never-appends': {
35
+ why: "A projection turns facts into a read model; it is replayed from position zero whenever its read model is rebuilt. A projection that appends to a stream would append again at every rebuild, and makes the read side decide facts. Judged: production files of application/projections/ and any file declaring a class with @Projection; naming EventStore or EventSourcedRepository of @ddd-ts-kit/kernel is reported, and so is anything imported from domain/repositories/ in a projection declared @Projection(name, { feed: 'event-store' }). A projection fed by the dispatcher keeps the imports it had before event sourcing.",
36
+ bad: `// application/projections/attendance-history.projection.ts
37
+ @Projection('scheduling.attendance-history', { feed: 'event-store' })
38
+ export class AttendanceHistoryProjection {
39
+ constructor(private readonly history: AttendanceHistory, private readonly records: AttendanceRecordRepository) {}
40
+ }`,
41
+ good: `// application/projections/attendance-history.projection.ts
42
+ @Projection('scheduling.attendance-history', { feed: 'event-store' })
43
+ export class AttendanceHistoryProjection {
44
+ constructor(private readonly history: AttendanceHistory) {}
45
+ }`,
46
+ },
47
+ 'event-sourcing/upcaster-required': {
48
+ why: "Stored events are never rewritten: an event stored years ago is read by today's code. Changing the type of the data of an event that is already stored breaks every replay of it, silently when the fields keep their names. The checkable criterion: the data of a stored event is a named type declared in its codec file with every named type it reaches (the kit's own PersonalValue aside), `encode` answers it, and its fingerprint (its fields and their types, the types it reaches included, layout and order aside) is recorded per version in stored-events.lock.json by `ddd-ts-kit docs --stored-events`, which never rewrites a recorded version. `ddd-ts-kit docs --check`, in the pipeline, fails while a declared version is not recorded, so no version reaches the main branch unrecorded. Reported: an encode that names no type, a type not declared in the file, a type it reaches that the file does not declare, a version above 1 without an upcaster from each version below it, a version below the last one recorded, and a recorded version whose shape changed. The lock is committed; until a version is recorded, its shape is free to change.",
49
+ bad: `// infrastructure/persistence/attendance-record-events.mapper.ts
50
+ interface NoShowNotedData { readonly appointmentId: string; readonly reason: string } // a field added in place
51
+ [NoShowNoted.eventName]: defineStoredEvent(NoShowNoted, { version: 1, encode: (event): NoShowNotedData => ({ ... }), decode }),`,
52
+ good: `// infrastructure/persistence/attendance-record-events.mapper.ts
53
+ interface NoShowNotedData { readonly appointmentId: string; readonly reason: string }
54
+ [NoShowNoted.eventName]: defineStoredEvent(NoShowNoted, {
55
+ version: 2,
56
+ encode: (event): NoShowNotedData => ({ ... }),
57
+ decode,
58
+ upcasters: { 1: (data) => ({ ...data, reason: '' }) },
59
+ }),`,
60
+ },
61
+ };
62
+ //# sourceMappingURL=event-sourcing-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-sourcing-docs.js","sourceRoot":"","sources":["../../../src/check/explain/event-sourcing-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAsC;IACpE,+BAA+B,EAAE;QAC/B,GAAG,EAAE,8zBAA8zB;QACn0B,GAAG,EAAE;;;;EAIP;QACE,IAAI,EAAE;;;;;;;EAOR;KACC;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,48BAA48B;QACj9B,GAAG,EAAE;qFAC4E;QACjF,IAAI,EAAE;uFAC6E;KACpF;IACD,wCAAwC,EAAE;QACxC,GAAG,EAAE,+oBAA+oB;QACppB,GAAG,EAAE;;oGAE2F;QAChG,IAAI,EAAE;;+DAEqD;KAC5D;IACD,yCAAyC,EAAE;QACzC,GAAG,EAAE,umBAAumB;QAC5mB,GAAG,EAAE;;;;EAIP;QACE,IAAI,EAAE;;;;EAIR;KACC;IACD,kCAAkC,EAAE;QAClC,GAAG,EAAE,inCAAinC;QACtnC,GAAG,EAAE;;gIAEuH;QAC5H,IAAI,EAAE;;;;;;;IAON;KACD;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"persistence-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/persistence-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY9D,CAAC"}
1
+ {"version":3,"file":"persistence-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/persistence-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsC9D,CAAC"}
@@ -10,5 +10,31 @@ export const PERSISTENCE_DOCS = {
10
10
  20261012093000_add-payments.sql # generated again after main took add-invoices
11
11
  meta/_journal.json # one entry each, in order, each snapshot from the one before`,
12
12
  },
13
+ 'persistence/no-file-content': {
14
+ why: 'A file in a column is read whole into the memory of the application and of the database, travels in every backup, every replica and every dump, swells the table its rows share pages with, and cannot be handed out by a short signed link: an upload of a few megabytes becomes a transaction, a replication lag and a backup to restore. An object store is made for it: it streams, it is cheap per gigabyte, it has lifecycle rules and signed links. The row keeps what the domain needs to know about the file, its reference.',
15
+ bad: `export const invoices = pgTable('invoices', {
16
+ receipt: bytea('receipt'), // the content of the file
17
+ receiptBase64: text('receipt_base64'), // the same, as text
18
+ });`,
19
+ good: `export const invoices = pgTable('invoices', {
20
+ receiptKey: text('receipt_key'), // where the file storage keeps it
21
+ receiptSize: integer('receipt_size'),
22
+ receiptMediaType: text('receipt_media_type'),
23
+ receiptChecksum: text('receipt_checksum'), // sha256 of the content
24
+ });`,
25
+ },
26
+ 'files/port-not-connector': {
27
+ why: 'Where files live is a choice of the platform: a directory in development, the memory in the tests, a bucket in a deployment. A handler or an aggregate that names a connector has made that choice for every environment, and its tests no longer run on the memory connector. The port says what is needed, streams in and out, signed links, and the platform binds the connector of each environment.',
28
+ bad: `import { LocalFileStorage } from '@ddd-ts-kit/kernel';
29
+
30
+ export class AttachReceiptHandler {
31
+ private readonly files = new LocalFileStorage({ directory: 'files' });
32
+ }`,
33
+ good: `import type { FileKeys, FileStaging } from '@ddd-ts-kit/kernel';
34
+
35
+ export class AttachReceiptHandler {
36
+ constructor(private readonly staging: FileStaging, private readonly keys: FileKeys) {}
37
+ }`,
38
+ },
13
39
  };
14
40
  //# sourceMappingURL=persistence-docs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"persistence-docs.js","sourceRoot":"","sources":["../../../src/check/explain/persistence-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,+BAA+B,EAAE;QAC/B,GAAG,EAAE,ytBAAytB;QAC9tB,GAAG,EAAE;;;wFAG+E;QACpF,IAAI,EAAE;;;kGAGwF;KAC/F;CACF,CAAC"}
1
+ {"version":3,"file":"persistence-docs.js","sourceRoot":"","sources":["../../../src/check/explain/persistence-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,+BAA+B,EAAE;QAC/B,GAAG,EAAE,ytBAAytB;QAC9tB,GAAG,EAAE;;;wFAG+E;QACpF,IAAI,EAAE;;;kGAGwF;KAC/F;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,ugBAAugB;QAC5gB,GAAG,EAAE;;;IAGL;QACA,IAAI,EAAE;;;;;IAKN;KACD;IACD,0BAA0B,EAAE;QAC1B,GAAG,EAAE,0YAA0Y;QAC/Y,GAAG,EAAE;;;;EAIP;QACE,IAAI,EAAE;;;;EAIR;KACC;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAkBpD,oGAAoG;AACpG,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBvD,CAAC"}
1
+ {"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAmBpD,oGAAoG;AACpG,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkBvD,CAAC"}
@@ -2,6 +2,7 @@ import { AUTHZ_DOCS } from './authz-docs.js';
2
2
  import { CLEAN_DOCS } from './clean-docs.js';
3
3
  import { CONTEXT_DOCS } from './context-docs.js';
4
4
  import { ERRORS_DOCS } from './errors-docs.js';
5
+ import { EVENT_SOURCING_DOCS } from './event-sourcing-docs.js';
5
6
  import { EVENTS_DOCS } from './events-docs.js';
6
7
  import { IMPORTS_DOCS } from './imports-docs.js';
7
8
  import { LANGUAGE_DOCS } from './language-docs.js';
@@ -20,6 +21,7 @@ export const RULE_DOCS = {
20
21
  ...CLEAN_DOCS,
21
22
  ...CONTEXT_DOCS,
22
23
  ...ERRORS_DOCS,
24
+ ...EVENT_SOURCING_DOCS,
23
25
  ...EVENTS_DOCS,
24
26
  ...IMPORTS_DOCS,
25
27
  ...LANGUAGE_DOCS,
@@ -1 +1 @@
1
- {"version":3,"file":"rule-docs.js","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EA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AAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oGAAoG;AACpG,MAAM,CAAC,MAAM,SAAS,GAAsC;IAC1D,GAAG,UAAU;IACb,GAAG,UAAU;IACb,GAAG,YAAY;IACf,GAAG,WAAW;IACd,GAAG,mBAAmB;IACtB,GAAG,WAAW;IACd,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,gBAAgB;IACnB,GAAG,UAAU;IACb,GAAG,eAAe;IAClB,GAAG,aAAa;IAChB,GAAG,YAAY;IACf,GAAG,SAAS;IACZ,GAAG,WAAW;CACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Finding } from '../model/finding.js';
2
+ /** The lines of a schema or a migration that declare a column of file content; comments are not read. */
3
+ export declare function fileContentFindings(text: string): Finding[];
4
+ //# sourceMappingURL=file-content-findings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-content-findings.d.ts","sourceRoot":"","sources":["../../../src/check/files/file-content-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAYnD,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAgB3D"}
@@ -0,0 +1,29 @@
1
+ import { FILE_CONTENT_PATTERNS } from './file-content-pattern.js';
2
+ const COMMENT = /^\s*(?:\/\/|\/\*|\*|--|#)/;
3
+ /** A comment that ends a line of code: `//` not part of a URL, or `--` of SQL. */
4
+ const TRAILING_COMMENT = /(?:(?<!:)\/\/|\s--\s).*$/;
5
+ /** A URL written as a string, such as a link to a repository (`.../blob/main/...`). */
6
+ const URL_STRING = /(['"`])[a-z][\w+.-]*:\/\/[^'"`]*\1/gi;
7
+ const FIX = 'Keep the content in the `FileStorage` port of @ddd-ts-kit/kernel (`ddd-ts-kit generate file-upload` writes the use case) and store in the row the reference `put` answers, a `StoredFile`: key, size, media type, checksum. A small binary value that is not a file (a hash, a key) is a decision: record it as a deviation of this rule.';
8
+ /** The lines of a schema or a migration that declare a column of file content; comments are not read. */
9
+ export function fileContentFindings(text) {
10
+ return text.split('\n').flatMap((content, index) => {
11
+ const matched = COMMENT.test(content)
12
+ ? undefined
13
+ : FILE_CONTENT_PATTERNS.map((pattern) => pattern.exec(codeOf(content))?.[0]).find(Boolean);
14
+ return matched === undefined
15
+ ? []
16
+ : [
17
+ {
18
+ line: index + 1,
19
+ message: `A column of file content ("${matched.trim()}"): files are kept in a storage, never in the database, whose backups, replicas and memory are sized for rows.`,
20
+ fix: FIX,
21
+ },
22
+ ];
23
+ });
24
+ }
25
+ /** The line without its trailing comment and its URLs, which mention words without declaring anything. */
26
+ function codeOf(line) {
27
+ return line.replace(URL_STRING, '""').replace(TRAILING_COMMENT, '');
28
+ }
29
+ //# sourceMappingURL=file-content-findings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-content-findings.js","sourceRoot":"","sources":["../../../src/check/files/file-content-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAC5C,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,uFAAuF;AACvF,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAE1D,MAAM,GAAG,GACP,2UAA2U,CAAC;AAE9U,yGAAyG;AACzG,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;YACnC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE7F,OAAO,OAAO,KAAK,SAAS;YAC1B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,KAAK,GAAG,CAAC;oBACf,OAAO,EAAE,8BAA8B,OAAO,CAAC,IAAI,EAAE,gHAAgH;oBACrK,GAAG,EAAE,GAAG;iBACT;aACF,CAAC;IACR,CAAC,CAAC,CAAC;AACL,CAAC;AAED,0GAA0G;AAC1G,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * What declares a column of file content: a binary type of an ORM, of SQL or of Prisma, or a
3
+ * column of text whose name says base64. A word base64 elsewhere (an encoded cursor, an ETag)
4
+ * declares no column and is not matched.
5
+ */
6
+ export declare const FILE_CONTENT_PATTERNS: readonly RegExp[];
7
+ //# sourceMappingURL=file-content-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-content-pattern.d.ts","sourceRoot":"","sources":["../../../src/check/files/file-content-pattern.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EASlD,CAAC"}
@@ -0,0 +1,17 @@
1
+ const TEXT_TYPES = '(?:text|varchar|char|string|json|jsonb|clob|longtext|mediumtext|character varying)';
2
+ /**
3
+ * What declares a column of file content: a binary type of an ORM, of SQL or of Prisma, or a
4
+ * column of text whose name says base64. A word base64 elsewhere (an encoded cursor, an ETag)
5
+ * declares no column and is not matched.
6
+ */
7
+ export const FILE_CONTENT_PATTERNS = [
8
+ /\b(?:bytea|(?:tiny|medium|long)?blob|varbinary)\b/i,
9
+ /\.binary\s*\(/,
10
+ /customType\s*<\s*\{\s*data\s*:\s*(?:Buffer|Uint8Array)/,
11
+ /^\s*\w+\s+Bytes\b/,
12
+ new RegExp(`\\b${TEXT_TYPES}\\s*\\(\\s*['"\`]\\w*base_?64\\w*['"\`]`, 'i'),
13
+ new RegExp(`\\b\\w*base_?64\\w*\\s*:\\s*${TEXT_TYPES}\\s*\\(`, 'i'),
14
+ new RegExp(`["\`]?\\b\\w*base_?64\\w*\\b["\`]?\\s+${TEXT_TYPES}\\b`, 'i'),
15
+ /^\s*\w*base_?64\w*\s+String\b/i,
16
+ ];
17
+ //# sourceMappingURL=file-content-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-content-pattern.js","sourceRoot":"","sources":["../../../src/check/files/file-content-pattern.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,oFAAoF,CAAC;AAExG;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,oDAAoD;IACpD,eAAe;IACf,wDAAwD;IACxD,mBAAmB;IACnB,IAAI,MAAM,CAAC,MAAM,UAAU,yCAAyC,EAAE,GAAG,CAAC;IAC1E,IAAI,MAAM,CAAC,+BAA+B,UAAU,SAAS,EAAE,GAAG,CAAC;IACnE,IAAI,MAAM,CAAC,yCAAyC,UAAU,KAAK,EAAE,GAAG,CAAC;IACzE,gCAAgC;CACjC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Project } from '../model/project.js';
2
+ /** A file that declares tables, by its path from the root, with its text. */
3
+ export interface SchemaSource {
4
+ readonly file: string;
5
+ readonly text: string;
6
+ }
7
+ /**
8
+ * What declares the tables of a project: the persistence sources of the contexts and of the
9
+ * platform database, the migrations (`migrations/`, `drizzle/`, `prisma/migrations/`) and the
10
+ * Prisma schema. Specs are not read.
11
+ */
12
+ export declare function schemaSources(project: Project): SchemaSource[];
13
+ //# sourceMappingURL=schema-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-sources.d.ts","sourceRoot":"","sources":["../../../src/check/files/schema-sources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,EAAE,CAQ9D"}
@@ -0,0 +1,37 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ const MIGRATION_EXTENSIONS = new Set(['.sql', '.js', '.ts', '.mjs', '.cjs']);
4
+ /**
5
+ * What declares the tables of a project: the persistence sources of the contexts and of the
6
+ * platform database, the migrations (`migrations/`, `drizzle/`, `prisma/migrations/`) and the
7
+ * Prisma schema. Specs are not read.
8
+ */
9
+ export function schemaSources(project) {
10
+ const database = `${project.config.platformDir}/database/`;
11
+ const sources = project.files
12
+ .filter((file) => !file.isTest && (persistenceOfAContext(file.location) || file.path.startsWith(database)))
13
+ .map(({ path: file, text }) => ({ file, text }));
14
+ return [...sources, ...['migrations', 'drizzle', 'prisma'].flatMap((folder) => filesUnder(project.root, folder))];
15
+ }
16
+ function persistenceOfAContext(location) {
17
+ return location.area === 'context' && location.layer === 'infrastructure' && location.inside[0] === 'persistence';
18
+ }
19
+ function filesUnder(root, folder) {
20
+ const entries = readTree(path.join(root, folder));
21
+ return entries
22
+ .filter((entry) => entry.isFile() && (MIGRATION_EXTENSIONS.has(path.extname(entry.name)) || entry.name.endsWith('.prisma')))
23
+ .filter((entry) => !entry.name.endsWith('.d.ts'))
24
+ .map((entry) => {
25
+ const absolute = path.join(entry.parentPath, entry.name);
26
+ return { file: path.relative(root, absolute).split(path.sep).join('/'), text: fs.readFileSync(absolute, 'utf8') };
27
+ });
28
+ }
29
+ function readTree(directory) {
30
+ try {
31
+ return fs.readdirSync(directory, { recursive: true, withFileTypes: true });
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ //# sourceMappingURL=schema-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-sources.js","sourceRoot":"","sources":["../../../src/check/files/schema-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,YAAY,CAAC;IAE3D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK;SAC1B,MAAM,C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C,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;IACpH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,QAAQ,CAAC,SAAiB;IACjC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Fixture } from './fixture.js';
2
+ export declare const EVENT_SOURCING_FIXTURES: readonly Fixture[];
3
+ //# sourceMappingURL=event-sourcing-fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-sourcing-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/event-sourcing-fixtures.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAqO5C,eAAO,MAAM,uBAAuB,EAAE,SAAS,OAAO,EAMrD,CAAC"}