@archi-code/ddd 0.0.0-stage → 3.0.0-alpha.2

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 (336) hide show
  1. package/LICENSE +46 -0
  2. package/README.md +2795 -2
  3. package/SKILL.md +106 -0
  4. package/ddd-skills/archi-code-ddd/imports.md +94 -0
  5. package/ddd-skills/archi-code-ddd/layers.md +314 -0
  6. package/ddd-skills/archi-code-ddd/patterns.md +683 -0
  7. package/ddd-skills/archi-code-ddd/what-not-to-do.md +196 -0
  8. package/ddd-skills/archi-code-ddd/where-each-class-goes.md +64 -0
  9. package/ddd-skills/ddd-agregados/GUIA.md +114 -0
  10. package/ddd-skills/ddd-agregados/references/consistencia-eventual.md +158 -0
  11. package/ddd-skills/ddd-agregados/references/ejemplo-ecommerce.md +52 -0
  12. package/ddd-skills/ddd-agregados/references/fabricas.md +193 -0
  13. package/ddd-skills/ddd-agregados/references/implementacion-ts.md +706 -0
  14. package/ddd-skills/ddd-arquitectura/GUIA.md +80 -0
  15. package/ddd-skills/ddd-arquitectura/assets/dependency-cruiser.cjs +99 -0
  16. package/ddd-skills/ddd-arquitectura/references/estilos-adicionales.md +51 -0
  17. package/ddd-skills/ddd-arquitectura/references/estructura-hexagonal-ts.md +406 -0
  18. package/ddd-skills/ddd-arquitectura/references/modulos.md +48 -0
  19. package/ddd-skills/ddd-auditoria-refactorizacion/GUIA.md +85 -0
  20. package/ddd-skills/ddd-auditoria-refactorizacion/references/ejemplo-auditoria.md +314 -0
  21. package/ddd-skills/ddd-auditoria-refactorizacion/references/lista-comprobacion.md +54 -0
  22. package/ddd-skills/ddd-auditoria-refactorizacion/references/plan-migracion.md +73 -0
  23. package/ddd-skills/ddd-auditoria-refactorizacion/scripts/scan_ddd_smells.py +264 -0
  24. package/ddd-skills/ddd-context-mapping/GUIA.md +83 -0
  25. package/ddd-skills/ddd-context-mapping/references/anticorrupcion-ts.md +419 -0
  26. package/ddd-skills/ddd-context-mapping/references/estilos-integracion.md +152 -0
  27. package/ddd-skills/ddd-event-sourcing-cqrs/GUIA.md +92 -0
  28. package/ddd-skills/ddd-event-sourcing-cqrs/references/event-sourcing-ts.md +476 -0
  29. package/ddd-skills/ddd-event-sourcing-cqrs/references/proyecciones-cqrs-ts.md +285 -0
  30. package/ddd-skills/ddd-eventos-dominio/GUIA.md +106 -0
  31. package/ddd-skills/ddd-eventos-dominio/references/diseno-eventos.md +130 -0
  32. package/ddd-skills/ddd-eventos-dominio/references/ejemplo-ecommerce.md +240 -0
  33. package/ddd-skills/ddd-eventos-dominio/references/publicacion-ts.md +529 -0
  34. package/ddd-skills/ddd-orquestador/GUIA.md +40 -0
  35. package/ddd-skills/ddd-orquestador/references/chuleta-reglas.md +35 -0
  36. package/ddd-skills/ddd-repositorios-persistencia/GUIA.md +121 -0
  37. package/ddd-skills/ddd-repositorios-persistencia/references/implementacion-ts.md +314 -0
  38. package/ddd-skills/ddd-repositorios-persistencia/references/tests-repositorios.md +191 -0
  39. package/ddd-skills/ddd-repositorios-persistencia/references/transacciones-ts.md +301 -0
  40. package/ddd-skills/ddd-servicios-capa-aplicacion/GUIA.md +99 -0
  41. package/ddd-skills/ddd-servicios-capa-aplicacion/references/capa-aplicacion-ts.md +264 -0
  42. package/ddd-skills/ddd-servicios-capa-aplicacion/references/ejemplo-ecommerce.md +321 -0
  43. package/ddd-skills/ddd-servicios-capa-aplicacion/references/servicios-dominio-ts.md +190 -0
  44. package/ddd-skills/ddd-value-objects-entidades/GUIA.md +118 -0
  45. package/ddd-skills/ddd-value-objects-entidades/references/ejemplo-ecommerce.md +87 -0
  46. package/ddd-skills/ddd-value-objects-entidades/references/entidades-ts.md +218 -0
  47. package/ddd-skills/ddd-value-objects-entidades/references/persistencia-valores.md +88 -0
  48. package/ddd-skills/ddd-value-objects-entidades/references/specification-y-diseno-flexible.md +119 -0
  49. package/ddd-skills/ddd-value-objects-entidades/references/validacion.md +96 -0
  50. package/ddd-skills/ddd-value-objects-entidades/references/value-objects-ts.md +376 -0
  51. package/dist/cjs/application/event/event-bus.d.ts +4 -0
  52. package/dist/cjs/application/event/event-bus.js +2 -0
  53. package/dist/cjs/application/event/event-listener.d.ts +4 -0
  54. package/dist/cjs/application/event/event-listener.js +6 -0
  55. package/dist/cjs/application/event/listens-to.d.ts +15 -0
  56. package/dist/cjs/application/event/listens-to.js +28 -0
  57. package/dist/cjs/application/exceptions/aggregate-not-found.exception.d.ts +5 -0
  58. package/dist/cjs/application/exceptions/aggregate-not-found.exception.js +17 -0
  59. package/dist/cjs/application/exceptions/application-exception-code.d.ts +7 -0
  60. package/dist/cjs/application/exceptions/application-exception-code.js +11 -0
  61. package/dist/cjs/application/exceptions/application.exception.d.ts +6 -0
  62. package/dist/cjs/application/exceptions/application.exception.js +16 -0
  63. package/dist/cjs/application/exceptions/concurrency.exception.d.ts +5 -0
  64. package/dist/cjs/application/exceptions/concurrency.exception.js +17 -0
  65. package/dist/cjs/application/exceptions/not-allowed.exception.d.ts +5 -0
  66. package/dist/cjs/application/exceptions/not-allowed.exception.js +17 -0
  67. package/dist/cjs/application/exceptions/unexpected-error.exception.d.ts +5 -0
  68. package/dist/cjs/application/exceptions/unexpected-error.exception.js +17 -0
  69. package/dist/cjs/application/index.d.ts +14 -0
  70. package/dist/cjs/application/index.js +23 -0
  71. package/dist/cjs/application/ports/clock.d.ts +3 -0
  72. package/dist/cjs/application/ports/clock.js +2 -0
  73. package/dist/cjs/application/ports/logger.d.ts +8 -0
  74. package/dist/cjs/application/ports/logger.js +2 -0
  75. package/dist/cjs/application/use-case/use-case.d.ts +6 -0
  76. package/dist/cjs/application/use-case/use-case.js +25 -0
  77. package/dist/cjs/application/value-object-builder/value-object-builder.d.ts +16 -0
  78. package/dist/cjs/application/value-object-builder/value-object-builder.js +51 -0
  79. package/dist/cjs/domain/aggregate/aggregate-root.d.ts +9 -0
  80. package/dist/cjs/domain/aggregate/aggregate-root.js +17 -0
  81. package/dist/cjs/domain/entity/entity.d.ts +9 -0
  82. package/dist/cjs/domain/entity/entity.js +19 -0
  83. package/dist/cjs/domain/event/event-base.d.ts +23 -0
  84. package/dist/cjs/domain/event/event-base.js +21 -0
  85. package/dist/cjs/domain/exceptions/domain-exception-code.d.ts +7 -0
  86. package/dist/cjs/domain/exceptions/domain-exception-code.js +11 -0
  87. package/dist/cjs/domain/exceptions/domain.exception.d.ts +6 -0
  88. package/dist/cjs/domain/exceptions/domain.exception.js +16 -0
  89. package/dist/cjs/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
  90. package/dist/cjs/domain/exceptions/invalid-event-definition.exception.js +19 -0
  91. package/dist/cjs/domain/exceptions/required-value.exception.d.ts +4 -0
  92. package/dist/cjs/domain/exceptions/required-value.exception.js +20 -0
  93. package/dist/cjs/domain/exceptions/type-primitive.exception.d.ts +4 -0
  94. package/dist/cjs/domain/exceptions/type-primitive.exception.js +20 -0
  95. package/dist/cjs/domain/exceptions/validation.exception.d.ts +14 -0
  96. package/dist/cjs/domain/exceptions/validation.exception.js +23 -0
  97. package/dist/cjs/domain/index.d.ts +17 -0
  98. package/dist/cjs/domain/index.js +36 -0
  99. package/dist/cjs/domain/primitive/primitive-types.d.ts +20 -0
  100. package/dist/cjs/domain/primitive/primitive-types.js +2 -0
  101. package/dist/cjs/domain/repository/aggregate-finder.d.ts +4 -0
  102. package/dist/cjs/domain/repository/aggregate-finder.js +2 -0
  103. package/dist/cjs/domain/repository/aggregate-remover.d.ts +4 -0
  104. package/dist/cjs/domain/repository/aggregate-remover.js +2 -0
  105. package/dist/cjs/domain/repository/aggregate-saver.d.ts +4 -0
  106. package/dist/cjs/domain/repository/aggregate-saver.js +2 -0
  107. package/dist/cjs/domain/specification/specification.d.ts +9 -0
  108. package/dist/cjs/domain/specification/specification.js +44 -0
  109. package/dist/cjs/domain/type/abstract-type.d.ts +18 -0
  110. package/dist/cjs/domain/type/abstract-type.js +61 -0
  111. package/dist/cjs/domain/type/array-type.d.ts +17 -0
  112. package/dist/cjs/domain/type/array-type.js +64 -0
  113. package/dist/cjs/domain/type/boolean-type.d.ts +4 -0
  114. package/dist/cjs/domain/type/boolean-type.js +16 -0
  115. package/dist/cjs/domain/type/composite/composite-brand.d.ts +4 -0
  116. package/dist/cjs/domain/type/composite/composite-brand.js +15 -0
  117. package/dist/cjs/domain/type/composite/composite-field.d.ts +18 -0
  118. package/dist/cjs/domain/type/composite/composite-field.js +86 -0
  119. package/dist/cjs/domain/type/composite/composite-issues.d.ts +6 -0
  120. package/dist/cjs/domain/type/composite/composite-issues.js +35 -0
  121. package/dist/cjs/domain/type/composite/composite.d.ts +26 -0
  122. package/dist/cjs/domain/type/composite/composite.js +51 -0
  123. package/dist/cjs/domain/type/date-type.d.ts +19 -0
  124. package/dist/cjs/domain/type/date-type.js +70 -0
  125. package/dist/cjs/domain/type/enum-type.d.ts +7 -0
  126. package/dist/cjs/domain/type/enum-type.js +30 -0
  127. package/dist/cjs/domain/type/id-type.d.ts +7 -0
  128. package/dist/cjs/domain/type/id-type.js +17 -0
  129. package/dist/cjs/domain/type/index.d.ts +15 -0
  130. package/dist/cjs/domain/type/index.js +29 -0
  131. package/dist/cjs/domain/type/json-type.d.ts +9 -0
  132. package/dist/cjs/domain/type/json-type.js +46 -0
  133. package/dist/cjs/domain/type/number-type.d.ts +4 -0
  134. package/dist/cjs/domain/type/number-type.js +16 -0
  135. package/dist/cjs/domain/type/required/required-mark.d.ts +8 -0
  136. package/dist/cjs/domain/type/required/required-mark.js +13 -0
  137. package/dist/cjs/domain/type/required/required-type.d.ts +7 -0
  138. package/dist/cjs/domain/type/required/required-type.js +21 -0
  139. package/dist/cjs/domain/type/string-type.d.ts +4 -0
  140. package/dist/cjs/domain/type/string-type.js +16 -0
  141. package/dist/cjs/domain/type/uuid-type.d.ts +7 -0
  142. package/dist/cjs/domain/type/uuid-type.js +27 -0
  143. package/dist/cjs/infrastructure/clock/fixed-clock.d.ts +8 -0
  144. package/dist/cjs/infrastructure/clock/fixed-clock.js +19 -0
  145. package/dist/cjs/infrastructure/clock/system-clock.d.ts +4 -0
  146. package/dist/cjs/infrastructure/clock/system-clock.js +9 -0
  147. package/dist/cjs/infrastructure/event/domain-event-bus.d.ts +16 -0
  148. package/dist/cjs/infrastructure/event/domain-event-bus.js +60 -0
  149. package/dist/cjs/infrastructure/event/event-channel.d.ts +9 -0
  150. package/dist/cjs/infrastructure/event/event-channel.js +2 -0
  151. package/dist/cjs/infrastructure/event/event-registry.d.ts +9 -0
  152. package/dist/cjs/infrastructure/event/event-registry.js +43 -0
  153. package/dist/cjs/infrastructure/event/in-memory/emitter.d.ts +11 -0
  154. package/dist/cjs/infrastructure/event/in-memory/emitter.js +54 -0
  155. package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.d.ts +16 -0
  156. package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.js +50 -0
  157. package/dist/cjs/infrastructure/exceptions/event-delivery.exception.d.ts +5 -0
  158. package/dist/cjs/infrastructure/exceptions/event-delivery.exception.js +20 -0
  159. package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
  160. package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.js +10 -0
  161. package/dist/cjs/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
  162. package/dist/cjs/infrastructure/exceptions/infrastructure.exception.js +16 -0
  163. package/dist/cjs/infrastructure/exceptions/internal-error.exception.d.ts +5 -0
  164. package/dist/cjs/infrastructure/exceptions/internal-error.exception.js +17 -0
  165. package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
  166. package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.js +34 -0
  167. package/dist/cjs/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
  168. package/dist/cjs/infrastructure/exceptions/kind/exception-kind.js +13 -0
  169. package/dist/cjs/infrastructure/exceptions/unknown-event.exception.d.ts +4 -0
  170. package/dist/cjs/infrastructure/exceptions/unknown-event.exception.js +19 -0
  171. package/dist/cjs/infrastructure/index.d.ts +21 -0
  172. package/dist/cjs/infrastructure/index.js +33 -0
  173. package/dist/cjs/infrastructure/logging/console-logger.d.ts +17 -0
  174. package/dist/cjs/infrastructure/logging/console-logger.js +37 -0
  175. package/dist/cjs/infrastructure/logging/in-memory-logger.d.ts +15 -0
  176. package/dist/cjs/infrastructure/logging/in-memory-logger.js +27 -0
  177. package/dist/cjs/infrastructure/logging/log-serializer.d.ts +7 -0
  178. package/dist/cjs/infrastructure/logging/log-serializer.js +59 -0
  179. package/dist/cjs/infrastructure/logging/silent-logger.d.ts +7 -0
  180. package/dist/cjs/infrastructure/logging/silent-logger.js +18 -0
  181. package/dist/cjs/shared/exceptions/abstract.exception.d.ts +25 -0
  182. package/dist/cjs/shared/exceptions/abstract.exception.js +59 -0
  183. package/dist/cjs/shared/exceptions/brand/exception-brand.d.ts +6 -0
  184. package/dist/cjs/shared/exceptions/brand/exception-brand.js +29 -0
  185. package/dist/cjs/shared/exceptions/received/received-value.d.ts +4 -0
  186. package/dist/cjs/shared/exceptions/received/received-value.js +13 -0
  187. package/dist/cjs/shared/index.d.ts +8 -0
  188. package/dist/cjs/shared/index.js +13 -0
  189. package/dist/cjs/shared/issue-collection-error.d.ts +9 -0
  190. package/dist/cjs/shared/issue-collection-error.js +11 -0
  191. package/dist/cjs/shared/issue-collector.d.ts +8 -0
  192. package/dist/cjs/shared/issue-collector.js +41 -0
  193. package/dist/esm/application/event/event-bus.d.ts +4 -0
  194. package/dist/esm/application/event/event-bus.js +1 -0
  195. package/dist/esm/application/event/event-listener.d.ts +4 -0
  196. package/dist/esm/application/event/event-listener.js +2 -0
  197. package/dist/esm/application/event/listens-to.d.ts +15 -0
  198. package/dist/esm/application/event/listens-to.js +25 -0
  199. package/dist/esm/application/exceptions/aggregate-not-found.exception.d.ts +5 -0
  200. package/dist/esm/application/exceptions/aggregate-not-found.exception.js +13 -0
  201. package/dist/esm/application/exceptions/application-exception-code.d.ts +7 -0
  202. package/dist/esm/application/exceptions/application-exception-code.js +8 -0
  203. package/dist/esm/application/exceptions/application.exception.d.ts +6 -0
  204. package/dist/esm/application/exceptions/application.exception.js +12 -0
  205. package/dist/esm/application/exceptions/concurrency.exception.d.ts +5 -0
  206. package/dist/esm/application/exceptions/concurrency.exception.js +13 -0
  207. package/dist/esm/application/exceptions/not-allowed.exception.d.ts +5 -0
  208. package/dist/esm/application/exceptions/not-allowed.exception.js +13 -0
  209. package/dist/esm/application/exceptions/unexpected-error.exception.d.ts +5 -0
  210. package/dist/esm/application/exceptions/unexpected-error.exception.js +13 -0
  211. package/dist/esm/application/index.d.ts +14 -0
  212. package/dist/esm/application/index.js +10 -0
  213. package/dist/esm/application/ports/clock.d.ts +3 -0
  214. package/dist/esm/application/ports/clock.js +1 -0
  215. package/dist/esm/application/ports/logger.d.ts +8 -0
  216. package/dist/esm/application/ports/logger.js +1 -0
  217. package/dist/esm/application/use-case/use-case.d.ts +6 -0
  218. package/dist/esm/application/use-case/use-case.js +21 -0
  219. package/dist/esm/application/value-object-builder/value-object-builder.d.ts +16 -0
  220. package/dist/esm/application/value-object-builder/value-object-builder.js +47 -0
  221. package/dist/esm/domain/aggregate/aggregate-root.d.ts +9 -0
  222. package/dist/esm/domain/aggregate/aggregate-root.js +13 -0
  223. package/dist/esm/domain/entity/entity.d.ts +9 -0
  224. package/dist/esm/domain/entity/entity.js +15 -0
  225. package/dist/esm/domain/event/event-base.d.ts +23 -0
  226. package/dist/esm/domain/event/event-base.js +17 -0
  227. package/dist/esm/domain/exceptions/domain-exception-code.d.ts +7 -0
  228. package/dist/esm/domain/exceptions/domain-exception-code.js +8 -0
  229. package/dist/esm/domain/exceptions/domain.exception.d.ts +6 -0
  230. package/dist/esm/domain/exceptions/domain.exception.js +12 -0
  231. package/dist/esm/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
  232. package/dist/esm/domain/exceptions/invalid-event-definition.exception.js +15 -0
  233. package/dist/esm/domain/exceptions/required-value.exception.d.ts +4 -0
  234. package/dist/esm/domain/exceptions/required-value.exception.js +16 -0
  235. package/dist/esm/domain/exceptions/type-primitive.exception.d.ts +4 -0
  236. package/dist/esm/domain/exceptions/type-primitive.exception.js +16 -0
  237. package/dist/esm/domain/exceptions/validation.exception.d.ts +14 -0
  238. package/dist/esm/domain/exceptions/validation.exception.js +19 -0
  239. package/dist/esm/domain/index.d.ts +17 -0
  240. package/dist/esm/domain/index.js +12 -0
  241. package/dist/esm/domain/primitive/primitive-types.d.ts +20 -0
  242. package/dist/esm/domain/primitive/primitive-types.js +1 -0
  243. package/dist/esm/domain/repository/aggregate-finder.d.ts +4 -0
  244. package/dist/esm/domain/repository/aggregate-finder.js +1 -0
  245. package/dist/esm/domain/repository/aggregate-remover.d.ts +4 -0
  246. package/dist/esm/domain/repository/aggregate-remover.js +1 -0
  247. package/dist/esm/domain/repository/aggregate-saver.d.ts +4 -0
  248. package/dist/esm/domain/repository/aggregate-saver.js +1 -0
  249. package/dist/esm/domain/specification/specification.d.ts +9 -0
  250. package/dist/esm/domain/specification/specification.js +40 -0
  251. package/dist/esm/domain/type/abstract-type.d.ts +18 -0
  252. package/dist/esm/domain/type/abstract-type.js +57 -0
  253. package/dist/esm/domain/type/array-type.d.ts +17 -0
  254. package/dist/esm/domain/type/array-type.js +60 -0
  255. package/dist/esm/domain/type/boolean-type.d.ts +4 -0
  256. package/dist/esm/domain/type/boolean-type.js +12 -0
  257. package/dist/esm/domain/type/composite/composite-brand.d.ts +4 -0
  258. package/dist/esm/domain/type/composite/composite-brand.js +11 -0
  259. package/dist/esm/domain/type/composite/composite-field.d.ts +18 -0
  260. package/dist/esm/domain/type/composite/composite-field.js +82 -0
  261. package/dist/esm/domain/type/composite/composite-issues.d.ts +6 -0
  262. package/dist/esm/domain/type/composite/composite-issues.js +31 -0
  263. package/dist/esm/domain/type/composite/composite.d.ts +26 -0
  264. package/dist/esm/domain/type/composite/composite.js +48 -0
  265. package/dist/esm/domain/type/date-type.d.ts +19 -0
  266. package/dist/esm/domain/type/date-type.js +64 -0
  267. package/dist/esm/domain/type/enum-type.d.ts +7 -0
  268. package/dist/esm/domain/type/enum-type.js +26 -0
  269. package/dist/esm/domain/type/id-type.d.ts +7 -0
  270. package/dist/esm/domain/type/id-type.js +13 -0
  271. package/dist/esm/domain/type/index.d.ts +15 -0
  272. package/dist/esm/domain/type/index.js +12 -0
  273. package/dist/esm/domain/type/json-type.d.ts +9 -0
  274. package/dist/esm/domain/type/json-type.js +42 -0
  275. package/dist/esm/domain/type/number-type.d.ts +4 -0
  276. package/dist/esm/domain/type/number-type.js +12 -0
  277. package/dist/esm/domain/type/required/required-mark.d.ts +8 -0
  278. package/dist/esm/domain/type/required/required-mark.js +9 -0
  279. package/dist/esm/domain/type/required/required-type.d.ts +7 -0
  280. package/dist/esm/domain/type/required/required-type.js +18 -0
  281. package/dist/esm/domain/type/string-type.d.ts +4 -0
  282. package/dist/esm/domain/type/string-type.js +12 -0
  283. package/dist/esm/domain/type/uuid-type.d.ts +7 -0
  284. package/dist/esm/domain/type/uuid-type.js +23 -0
  285. package/dist/esm/infrastructure/clock/fixed-clock.d.ts +8 -0
  286. package/dist/esm/infrastructure/clock/fixed-clock.js +15 -0
  287. package/dist/esm/infrastructure/clock/system-clock.d.ts +4 -0
  288. package/dist/esm/infrastructure/clock/system-clock.js +5 -0
  289. package/dist/esm/infrastructure/event/domain-event-bus.d.ts +16 -0
  290. package/dist/esm/infrastructure/event/domain-event-bus.js +56 -0
  291. package/dist/esm/infrastructure/event/event-channel.d.ts +9 -0
  292. package/dist/esm/infrastructure/event/event-channel.js +1 -0
  293. package/dist/esm/infrastructure/event/event-registry.d.ts +9 -0
  294. package/dist/esm/infrastructure/event/event-registry.js +39 -0
  295. package/dist/esm/infrastructure/event/in-memory/emitter.d.ts +11 -0
  296. package/dist/esm/infrastructure/event/in-memory/emitter.js +50 -0
  297. package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.d.ts +16 -0
  298. package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.js +46 -0
  299. package/dist/esm/infrastructure/exceptions/event-delivery.exception.d.ts +5 -0
  300. package/dist/esm/infrastructure/exceptions/event-delivery.exception.js +16 -0
  301. package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
  302. package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.js +7 -0
  303. package/dist/esm/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
  304. package/dist/esm/infrastructure/exceptions/infrastructure.exception.js +12 -0
  305. package/dist/esm/infrastructure/exceptions/internal-error.exception.d.ts +5 -0
  306. package/dist/esm/infrastructure/exceptions/internal-error.exception.js +13 -0
  307. package/dist/esm/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
  308. package/dist/esm/infrastructure/exceptions/kind/exception-classifier.js +30 -0
  309. package/dist/esm/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
  310. package/dist/esm/infrastructure/exceptions/kind/exception-kind.js +10 -0
  311. package/dist/esm/infrastructure/exceptions/unknown-event.exception.d.ts +4 -0
  312. package/dist/esm/infrastructure/exceptions/unknown-event.exception.js +15 -0
  313. package/dist/esm/infrastructure/index.d.ts +21 -0
  314. package/dist/esm/infrastructure/index.js +15 -0
  315. package/dist/esm/infrastructure/logging/console-logger.d.ts +17 -0
  316. package/dist/esm/infrastructure/logging/console-logger.js +33 -0
  317. package/dist/esm/infrastructure/logging/in-memory-logger.d.ts +15 -0
  318. package/dist/esm/infrastructure/logging/in-memory-logger.js +23 -0
  319. package/dist/esm/infrastructure/logging/log-serializer.d.ts +7 -0
  320. package/dist/esm/infrastructure/logging/log-serializer.js +55 -0
  321. package/dist/esm/infrastructure/logging/silent-logger.d.ts +7 -0
  322. package/dist/esm/infrastructure/logging/silent-logger.js +14 -0
  323. package/dist/esm/package.json +3 -0
  324. package/dist/esm/shared/exceptions/abstract.exception.d.ts +25 -0
  325. package/dist/esm/shared/exceptions/abstract.exception.js +55 -0
  326. package/dist/esm/shared/exceptions/brand/exception-brand.d.ts +6 -0
  327. package/dist/esm/shared/exceptions/brand/exception-brand.js +25 -0
  328. package/dist/esm/shared/exceptions/received/received-value.d.ts +4 -0
  329. package/dist/esm/shared/exceptions/received/received-value.js +9 -0
  330. package/dist/esm/shared/index.d.ts +8 -0
  331. package/dist/esm/shared/index.js +5 -0
  332. package/dist/esm/shared/issue-collection-error.d.ts +9 -0
  333. package/dist/esm/shared/issue-collection-error.js +7 -0
  334. package/dist/esm/shared/issue-collector.d.ts +8 -0
  335. package/dist/esm/shared/issue-collector.js +37 -0
  336. package/package.json +95 -4
@@ -0,0 +1,13 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { ApplicationExceptionCode } from './application-exception-code.js';
4
+ import { ApplicationException } from './application.exception.js';
5
+ export class ConcurrencyException extends ApplicationException {
6
+ constructor(aggregateName, id, expectedVersion, options = {}) {
7
+ super(`${aggregateName} with ID ${id} was changed by someone else: expected version ${expectedVersion}.`, [ApplicationExceptionCode.ConcurrencyConflict], options);
8
+ }
9
+ }
10
+ _a = ConcurrencyException;
11
+ (() => {
12
+ ExceptionBrand.brandClass(_a, ApplicationExceptionCode.ConcurrencyConflict);
13
+ })();
@@ -0,0 +1,5 @@
1
+ import type { ExceptionOptions } from '../../shared/index.js';
2
+ import { ApplicationException } from './application.exception.js';
3
+ export declare class NotAllowedException extends ApplicationException {
4
+ constructor(message: string, options?: ExceptionOptions);
5
+ }
@@ -0,0 +1,13 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { ApplicationExceptionCode } from './application-exception-code.js';
4
+ import { ApplicationException } from './application.exception.js';
5
+ export class NotAllowedException extends ApplicationException {
6
+ constructor(message, options = {}) {
7
+ super(message, [ApplicationExceptionCode.NotAllowed], options);
8
+ }
9
+ }
10
+ _a = NotAllowedException;
11
+ (() => {
12
+ ExceptionBrand.brandClass(_a, ApplicationExceptionCode.NotAllowed);
13
+ })();
@@ -0,0 +1,5 @@
1
+ import type { ExceptionOptions } from '../../shared/index.js';
2
+ import { ApplicationException } from './application.exception.js';
3
+ export declare class UnexpectedErrorException extends ApplicationException {
4
+ constructor(message: string, options?: ExceptionOptions);
5
+ }
@@ -0,0 +1,13 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { ApplicationExceptionCode } from './application-exception-code.js';
4
+ import { ApplicationException } from './application.exception.js';
5
+ export class UnexpectedErrorException extends ApplicationException {
6
+ constructor(message, options = {}) {
7
+ super(`Failed, unexpected error: ${message}`, [ApplicationExceptionCode.UnexpectedError], options);
8
+ }
9
+ }
10
+ _a = UnexpectedErrorException;
11
+ (() => {
12
+ ExceptionBrand.brandClass(_a, ApplicationExceptionCode.UnexpectedError);
13
+ })();
@@ -0,0 +1,14 @@
1
+ export { UseCase } from './use-case/use-case.js';
2
+ export { ValueObjectBuilder } from './value-object-builder/value-object-builder.js';
3
+ export { EventListener } from './event/event-listener.js';
4
+ export { ListensTo } from './event/listens-to.js';
5
+ export type { ListenerSubscription, ListensToOptions } from './event/listens-to.js';
6
+ export type { EventBus } from './event/event-bus.js';
7
+ export type { Clock } from './ports/clock.js';
8
+ export type { LogContext, Logger, LogLevel } from './ports/logger.js';
9
+ export { ApplicationException } from './exceptions/application.exception.js';
10
+ export { ConcurrencyException } from './exceptions/concurrency.exception.js';
11
+ export { AggregateNotFoundException } from './exceptions/aggregate-not-found.exception.js';
12
+ export { NotAllowedException } from './exceptions/not-allowed.exception.js';
13
+ export { UnexpectedErrorException } from './exceptions/unexpected-error.exception.js';
14
+ export { ApplicationExceptionCode } from './exceptions/application-exception-code.js';
@@ -0,0 +1,10 @@
1
+ export { UseCase } from './use-case/use-case.js';
2
+ export { ValueObjectBuilder } from './value-object-builder/value-object-builder.js';
3
+ export { EventListener } from './event/event-listener.js';
4
+ export { ListensTo } from './event/listens-to.js';
5
+ export { ApplicationException } from './exceptions/application.exception.js';
6
+ export { ConcurrencyException } from './exceptions/concurrency.exception.js';
7
+ export { AggregateNotFoundException } from './exceptions/aggregate-not-found.exception.js';
8
+ export { NotAllowedException } from './exceptions/not-allowed.exception.js';
9
+ export { UnexpectedErrorException } from './exceptions/unexpected-error.exception.js';
10
+ export { ApplicationExceptionCode } from './exceptions/application-exception-code.js';
@@ -0,0 +1,3 @@
1
+ export interface Clock {
2
+ now(): Date;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
2
+ export type LogContext = Readonly<Record<string, unknown>>;
3
+ export interface Logger {
4
+ debug(message: string, context?: LogContext): void;
5
+ info(message: string, context?: LogContext): void;
6
+ warn(message: string, context?: LogContext): void;
7
+ error(message: string, context?: LogContext): void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare abstract class UseCase<Input, Command, Output> {
2
+ execute(input: Input): Promise<Output>;
3
+ protected abstract toCommand(input: Input): Command;
4
+ protected abstract handle(command: Command): Promise<Output> | Output;
5
+ private static describe;
6
+ }
@@ -0,0 +1,21 @@
1
+ import { anyToString } from '@archi-code/validation';
2
+ import { AbstractException } from '../../shared/index.js';
3
+ import { UnexpectedErrorException } from '../exceptions/unexpected-error.exception.js';
4
+ export class UseCase {
5
+ async execute(input) {
6
+ try {
7
+ return await this.handle(this.toCommand(input));
8
+ }
9
+ catch (error) {
10
+ if (error instanceof AbstractException) {
11
+ throw error;
12
+ }
13
+ throw new UnexpectedErrorException(`${this.constructor.name}: ${UseCase.describe(error)}`, {
14
+ cause: error,
15
+ });
16
+ }
17
+ }
18
+ static describe(error) {
19
+ return error instanceof Error ? error.message : anyToString(error);
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ type Factories = Record<string, () => unknown>;
2
+ type Built<F extends Factories> = {
3
+ [Field in keyof F]: ReturnType<F[Field]>;
4
+ };
5
+ type Synchronous<F extends Factories> = {
6
+ [Field in keyof F]: [ReturnType<F[Field]>] extends [never] ? F[Field] : [ReturnType<F[Field]>] extends [PromiseLike<unknown>] ? never : F[Field];
7
+ };
8
+ export declare class ValueObjectBuilder {
9
+ static build<F extends Factories>(factories: F & Synchronous<F>): Built<F>;
10
+ static buildList<Value, Item>(values: readonly Value[], factory: (value: Value, index: number) => Item): Item[];
11
+ private static synchronous;
12
+ private static validated;
13
+ private static read;
14
+ private static isThenable;
15
+ }
16
+ export {};
@@ -0,0 +1,47 @@
1
+ import { DomainException, ValidationException } from '../../domain/index.js';
2
+ import { IssueCollectionError, IssueCollector } from '../../shared/index.js';
3
+ import { UnexpectedErrorException } from '../exceptions/unexpected-error.exception.js';
4
+ export class ValueObjectBuilder {
5
+ static build(factories) {
6
+ const builds = Object.fromEntries(Object.entries(factories).map(([field, factory]) => [
7
+ field,
8
+ () => ValueObjectBuilder.synchronous(field, factory()),
9
+ ]));
10
+ return ValueObjectBuilder.validated(() => IssueCollector.collectFields(builds, ValueObjectBuilder.read));
11
+ }
12
+ static buildList(values, factory) {
13
+ return ValueObjectBuilder.validated(() => IssueCollector.collectItems(values, (value, index) => ValueObjectBuilder.synchronous(String(index), factory(value, index)), ValueObjectBuilder.read));
14
+ }
15
+ static synchronous(field, result) {
16
+ if (!ValueObjectBuilder.isThenable(result)) {
17
+ return result;
18
+ }
19
+ result.then(undefined, () => undefined);
20
+ throw new UnexpectedErrorException(`ValueObjectBuilder: the factory of "${field}" returned a Promise; build value objects synchronously`);
21
+ }
22
+ static validated(collect) {
23
+ try {
24
+ return collect();
25
+ }
26
+ catch (error) {
27
+ if (error instanceof IssueCollectionError) {
28
+ throw new ValidationException(error.issues);
29
+ }
30
+ throw error;
31
+ }
32
+ }
33
+ static read(error) {
34
+ if (error instanceof ValidationException) {
35
+ return error.errors;
36
+ }
37
+ if (error instanceof DomainException) {
38
+ return [{ field: null, code: error.code, message: error.message }];
39
+ }
40
+ return null;
41
+ }
42
+ static isThenable(result) {
43
+ return ((typeof result === 'object' || typeof result === 'function') &&
44
+ result !== null &&
45
+ typeof result.then === 'function');
46
+ }
47
+ }
@@ -0,0 +1,9 @@
1
+ import { Entity } from '../entity/entity.js';
2
+ import type { EntityId } from '../entity/entity.js';
3
+ import type { EventBase } from '../event/event-base.js';
4
+ import type { IdType } from '../type/id-type.js';
5
+ export declare abstract class AggregateRoot<Id extends EntityId = IdType, Event extends EventBase = EventBase> extends Entity<Id> {
6
+ private readonly domainEvents;
7
+ protected record(event: Event): void;
8
+ pullDomainEvents(): Event[];
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Entity } from '../entity/entity.js';
2
+ export class AggregateRoot extends Entity {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.domainEvents = [];
6
+ }
7
+ record(event) {
8
+ this.domainEvents.push(event);
9
+ }
10
+ pullDomainEvents() {
11
+ return this.domainEvents.splice(0);
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ import type { AbstractType } from '../type/abstract-type.js';
2
+ import type { IdType } from '../type/id-type.js';
3
+ import type { RequiredMarked } from '../type/required/required-mark.js';
4
+ export type EntityId = AbstractType<any> & RequiredMarked;
5
+ export declare abstract class Entity<Id extends EntityId = IdType> {
6
+ readonly id: Id;
7
+ constructor(id: Id);
8
+ equals(other: unknown): boolean;
9
+ }
@@ -0,0 +1,15 @@
1
+ import { RequiredValueException } from '../exceptions/required-value.exception.js';
2
+ export class Entity {
3
+ constructor(id) {
4
+ this.id = id;
5
+ if (id?.isNull !== false) {
6
+ throw new RequiredValueException(`${new.target.name}.id`, id?.value);
7
+ }
8
+ }
9
+ equals(other) {
10
+ return (typeof other === 'object' &&
11
+ other !== null &&
12
+ other.constructor === this.constructor &&
13
+ this.id.equals(other.id));
14
+ }
15
+ }
@@ -0,0 +1,23 @@
1
+ export interface EventMetadata {
2
+ eventId?: string;
3
+ occurredOn?: Date | string;
4
+ clock?: {
5
+ now(): Date;
6
+ };
7
+ }
8
+ export interface SerializedEvent {
9
+ eventName: string;
10
+ eventId: string;
11
+ occurredOn: string;
12
+ [payload: string]: unknown;
13
+ }
14
+ export interface EventClass<Event extends EventBase = EventBase> {
15
+ readonly eventName: string;
16
+ new (...args: any[]): Event;
17
+ }
18
+ export declare abstract class EventBase {
19
+ readonly eventName: string;
20
+ readonly eventId: string;
21
+ readonly occurredOn: string;
22
+ constructor(metadata?: EventMetadata);
23
+ }
@@ -0,0 +1,17 @@
1
+ import { CreatedAt } from '../type/date-type.js';
2
+ import { IdType } from '../type/id-type.js';
3
+ import { UuidType } from '../type/uuid-type.js';
4
+ import { InvalidEventDefinitionException } from '../exceptions/invalid-event-definition.exception.js';
5
+ export class EventBase {
6
+ constructor(metadata = {}) {
7
+ const { eventName } = this.constructor;
8
+ if (typeof eventName !== 'string' || eventName.trim() === '') {
9
+ throw new InvalidEventDefinitionException(this.constructor.name);
10
+ }
11
+ this.eventName = eventName;
12
+ this.eventId = new IdType(metadata.eventId ?? UuidType.random()).value;
13
+ this.occurredOn = (metadata.occurredOn === undefined
14
+ ? CreatedAt.now(metadata.clock)
15
+ : new CreatedAt(metadata.occurredOn)).value.toISOString();
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum DomainExceptionCode {
2
+ DomainException = "DOM000",
3
+ ValidationFailed = "DOM001",
4
+ TypeFailed = "DOM003",
5
+ RequiredValue = "DOM004",
6
+ InvalidEventDefinition = "DOM005"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var DomainExceptionCode;
2
+ (function (DomainExceptionCode) {
3
+ DomainExceptionCode["DomainException"] = "DOM000";
4
+ DomainExceptionCode["ValidationFailed"] = "DOM001";
5
+ DomainExceptionCode["TypeFailed"] = "DOM003";
6
+ DomainExceptionCode["RequiredValue"] = "DOM004";
7
+ DomainExceptionCode["InvalidEventDefinition"] = "DOM005";
8
+ })(DomainExceptionCode || (DomainExceptionCode = {}));
@@ -0,0 +1,6 @@
1
+ import { AbstractException } from '../../shared/index.js';
2
+ import type { ExceptionOptions } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ export declare class DomainException extends AbstractException {
5
+ constructor(message: string, exceptionCodes?: (DomainExceptionCode | string)[], options?: ExceptionOptions);
6
+ }
@@ -0,0 +1,12 @@
1
+ var _a;
2
+ import { AbstractException, ExceptionBrand } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ export class DomainException extends AbstractException {
5
+ constructor(message, exceptionCodes = [], options = {}) {
6
+ super(message, [DomainExceptionCode.DomainException, ...exceptionCodes], options, DomainExceptionCode);
7
+ }
8
+ }
9
+ _a = DomainException;
10
+ (() => {
11
+ ExceptionBrand.brandClass(_a, DomainExceptionCode.DomainException);
12
+ })();
@@ -0,0 +1,4 @@
1
+ import { DomainException } from './domain.exception.js';
2
+ export declare class InvalidEventDefinitionException extends DomainException {
3
+ constructor(eventClassName: string);
4
+ }
@@ -0,0 +1,15 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ import { DomainException } from './domain.exception.js';
5
+ export class InvalidEventDefinitionException extends DomainException {
6
+ constructor(eventClassName) {
7
+ super(`${eventClassName} must declare a static eventName`, [
8
+ DomainExceptionCode.InvalidEventDefinition,
9
+ ]);
10
+ }
11
+ }
12
+ _a = InvalidEventDefinitionException;
13
+ (() => {
14
+ ExceptionBrand.brandClass(_a, DomainExceptionCode.InvalidEventDefinition);
15
+ })();
@@ -0,0 +1,4 @@
1
+ import { DomainException } from './domain.exception.js';
2
+ export declare class RequiredValueException extends DomainException {
3
+ constructor(typeName: string, receivedValue: unknown);
4
+ }
@@ -0,0 +1,16 @@
1
+ var _a;
2
+ import { ExceptionBrand, ReceivedValue } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ import { DomainException } from './domain.exception.js';
5
+ export class RequiredValueException extends DomainException {
6
+ constructor(typeName, receivedValue) {
7
+ const received = ReceivedValue.describe(receivedValue);
8
+ super(`Validation Error: ${typeName} is required, but received ${received}.`, [
9
+ DomainExceptionCode.RequiredValue,
10
+ ]);
11
+ }
12
+ }
13
+ _a = RequiredValueException;
14
+ (() => {
15
+ ExceptionBrand.brandClass(_a, DomainExceptionCode.RequiredValue);
16
+ })();
@@ -0,0 +1,4 @@
1
+ import { DomainException } from './domain.exception.js';
2
+ export declare class TypePrimitiveException extends DomainException {
3
+ constructor(expectedType: string, receivedValue: unknown, template?: string);
4
+ }
@@ -0,0 +1,16 @@
1
+ var _a;
2
+ import { ExceptionBrand, ReceivedValue } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ import { DomainException } from './domain.exception.js';
5
+ export class TypePrimitiveException extends DomainException {
6
+ constructor(expectedType, receivedValue, template = 'Expected a valid ') {
7
+ const received = ReceivedValue.describe(receivedValue);
8
+ super(`Validation Error: ${template}${expectedType}, but received ${received}.`, [
9
+ DomainExceptionCode.TypeFailed,
10
+ ]);
11
+ }
12
+ }
13
+ _a = TypePrimitiveException;
14
+ (() => {
15
+ ExceptionBrand.brandClass(_a, DomainExceptionCode.TypeFailed);
16
+ })();
@@ -0,0 +1,14 @@
1
+ import { DomainException } from './domain.exception.js';
2
+ export interface ValidationIssue {
3
+ readonly field: string | null;
4
+ readonly code: string;
5
+ readonly message: string;
6
+ }
7
+ export type ValidationIssueInput = Omit<ValidationIssue, 'code'> & {
8
+ readonly code?: string;
9
+ };
10
+ export declare class ValidationException extends DomainException {
11
+ readonly errors: readonly ValidationIssue[];
12
+ constructor(errors: readonly ValidationIssueInput[]);
13
+ private static describe;
14
+ }
@@ -0,0 +1,19 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { DomainExceptionCode } from './domain-exception-code.js';
4
+ import { DomainException } from './domain.exception.js';
5
+ export class ValidationException extends DomainException {
6
+ constructor(errors) {
7
+ super(`Validation failed, ${errors.map(_a.describe).join(', ')}`, [
8
+ DomainExceptionCode.ValidationFailed,
9
+ ]);
10
+ this.errors = Object.freeze(errors.map(({ field, code = DomainExceptionCode.ValidationFailed, message }) => Object.freeze({ field, code, message })));
11
+ }
12
+ static describe(issue) {
13
+ return issue.field === null ? issue.message : `${issue.field}: ${issue.message}`;
14
+ }
15
+ }
16
+ _a = ValidationException;
17
+ (() => {
18
+ ExceptionBrand.brandClass(_a, DomainExceptionCode.ValidationFailed);
19
+ })();
@@ -0,0 +1,17 @@
1
+ export * from './event/event-base.js';
2
+ export * from './entity/entity.js';
3
+ export * from './aggregate/aggregate-root.js';
4
+ export * from './type/index.js';
5
+ export * from './primitive/primitive-types.js';
6
+ export type { AggregateFinder } from './repository/aggregate-finder.js';
7
+ export type { AggregateSaver } from './repository/aggregate-saver.js';
8
+ export type { AggregateRemover } from './repository/aggregate-remover.js';
9
+ export { Specification } from './specification/specification.js';
10
+ export type { SatisfiedBy } from './specification/specification.js';
11
+ export { DomainException } from './exceptions/domain.exception.js';
12
+ export { ValidationException } from './exceptions/validation.exception.js';
13
+ export type { ValidationIssue, ValidationIssueInput } from './exceptions/validation.exception.js';
14
+ export { TypePrimitiveException } from './exceptions/type-primitive.exception.js';
15
+ export { RequiredValueException } from './exceptions/required-value.exception.js';
16
+ export { InvalidEventDefinitionException } from './exceptions/invalid-event-definition.exception.js';
17
+ export { DomainExceptionCode } from './exceptions/domain-exception-code.js';
@@ -0,0 +1,12 @@
1
+ export * from './event/event-base.js';
2
+ export * from './entity/entity.js';
3
+ export * from './aggregate/aggregate-root.js';
4
+ export * from './type/index.js';
5
+ export * from './primitive/primitive-types.js';
6
+ export { Specification } from './specification/specification.js';
7
+ export { DomainException } from './exceptions/domain.exception.js';
8
+ export { ValidationException } from './exceptions/validation.exception.js';
9
+ export { TypePrimitiveException } from './exceptions/type-primitive.exception.js';
10
+ export { RequiredValueException } from './exceptions/required-value.exception.js';
11
+ export { InvalidEventDefinitionException } from './exceptions/invalid-event-definition.exception.js';
12
+ export { DomainExceptionCode } from './exceptions/domain-exception-code.js';
@@ -0,0 +1,20 @@
1
+ import type { AbstractType } from '../type/abstract-type.js';
2
+ export type Methods<T> = {
3
+ [P in keyof T]-?: T[P] extends Function ? P : never;
4
+ }[keyof T];
5
+ export type MethodsAndProperties<T> = {
6
+ [key in keyof T]: T[key];
7
+ };
8
+ export type Properties<T> = Omit<MethodsAndProperties<T>, Methods<T>>;
9
+ export type MutablePropertiesData<T> = Mutable<Required<Properties<T>>>;
10
+ export type PropertiesData<T> = Required<Properties<T>>;
11
+ type RemoveUnderscore<S extends string> = S extends `_${infer R}` ? R : S;
12
+ type Mutable<T> = {
13
+ -readonly [P in keyof T]: T[P];
14
+ };
15
+ export type PrimitiveTypes<T> = {
16
+ [key in keyof Mutable<Properties<T>> as RemoveUnderscore<string & key>]: PrimitiveType<T[key]>;
17
+ };
18
+ export type DataTypes<T> = Partial<PrimitiveTypes<T>>;
19
+ export type PrimitiveType<T> = T extends (infer U)[] ? PrimitiveType<U>[] : T extends AbstractType<any> ? T['value'] : T extends null ? null : T extends Date ? never : T extends object ? PrimitiveTypes<T> : never;
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { AggregateRoot } from '../aggregate/aggregate-root.js';
2
+ export interface AggregateFinder<Aggregate extends AggregateRoot<any, any>> {
3
+ findById(id: Aggregate['id']): Promise<Aggregate | null>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { AggregateRoot } from '../aggregate/aggregate-root.js';
2
+ export interface AggregateRemover<Aggregate extends AggregateRoot<any, any>> {
3
+ remove(aggregate: Aggregate): Promise<void>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { AggregateRoot } from '../aggregate/aggregate-root.js';
2
+ export interface AggregateSaver<Aggregate extends AggregateRoot<any, any>> {
3
+ save(aggregate: Aggregate): Promise<void>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface SatisfiedBy<Candidate> {
2
+ isSatisfiedBy(candidate: Candidate): boolean;
3
+ }
4
+ export declare abstract class Specification<Candidate> implements SatisfiedBy<Candidate> {
5
+ abstract isSatisfiedBy(candidate: Candidate): boolean;
6
+ and(other: SatisfiedBy<Candidate>): Specification<Candidate>;
7
+ or(other: SatisfiedBy<Candidate>): Specification<Candidate>;
8
+ not(): Specification<Candidate>;
9
+ }
@@ -0,0 +1,40 @@
1
+ export class Specification {
2
+ and(other) {
3
+ return new BothSpecification(this, other);
4
+ }
5
+ or(other) {
6
+ return new EitherSpecification(this, other);
7
+ }
8
+ not() {
9
+ return new NegatedSpecification(this);
10
+ }
11
+ }
12
+ class BothSpecification extends Specification {
13
+ constructor(left, right) {
14
+ super();
15
+ this.left = left;
16
+ this.right = right;
17
+ }
18
+ isSatisfiedBy(candidate) {
19
+ return this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate);
20
+ }
21
+ }
22
+ class EitherSpecification extends Specification {
23
+ constructor(left, right) {
24
+ super();
25
+ this.left = left;
26
+ this.right = right;
27
+ }
28
+ isSatisfiedBy(candidate) {
29
+ return this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate);
30
+ }
31
+ }
32
+ class NegatedSpecification extends Specification {
33
+ constructor(negated) {
34
+ super();
35
+ this.negated = negated;
36
+ }
37
+ isSatisfiedBy(candidate) {
38
+ return !this.negated.isSatisfiedBy(candidate);
39
+ }
40
+ }
@@ -0,0 +1,18 @@
1
+ import type { Validatable, ValidationResult } from '@archi-code/validation';
2
+ import type { RequiredMarked } from './required/required-mark.js';
3
+ import type { ValidationIssue } from '../exceptions/validation.exception.js';
4
+ export type ValueOf<T, I> = I extends RequiredMarked ? T : T | null;
5
+ export declare abstract class AbstractType<T, Input = T> implements Validatable<T | null> {
6
+ protected readonly _value: T | null;
7
+ static [Symbol.hasInstance](candidate: unknown): boolean;
8
+ constructor(value?: Input | null);
9
+ get value(): ValueOf<T, this>;
10
+ get isNull(): boolean;
11
+ toString(): string;
12
+ equals<E extends AbstractType<any>>(other: E): boolean;
13
+ protected hasSameValue(other: this): boolean;
14
+ validate(): ValidationResult<ValueOf<T, this>>;
15
+ protected brokenRules(value: unknown): ValidationIssue[];
16
+ protected abstract filter(value: unknown): T | null;
17
+ private runRules;
18
+ }