@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,33 @@
1
+ import { InternalErrorException } from '../exceptions/internal-error.exception.js';
2
+ import { SystemClock } from '../clock/system-clock.js';
3
+ import { LogSerializer } from './log-serializer.js';
4
+ export class ConsoleLogger {
5
+ constructor({ level = 'info', clock = new SystemClock() } = {}) {
6
+ this.output = console;
7
+ this.minimum = ConsoleLogger.levels.indexOf(level);
8
+ if (this.minimum === -1) {
9
+ throw new InternalErrorException(`unknown log level "${String(level)}": use ${ConsoleLogger.levels.join(', ')}`);
10
+ }
11
+ this.clock = clock;
12
+ }
13
+ debug(message, context) {
14
+ this.write('debug', message, context);
15
+ }
16
+ info(message, context) {
17
+ this.write('info', message, context);
18
+ }
19
+ warn(message, context) {
20
+ this.write('warn', message, context);
21
+ }
22
+ error(message, context) {
23
+ this.write('error', message, context);
24
+ }
25
+ write(level, message, context) {
26
+ if (ConsoleLogger.levels.indexOf(level) < this.minimum) {
27
+ return;
28
+ }
29
+ const entry = { time: this.clock.now().toISOString(), level, message };
30
+ this.output[level](LogSerializer.line(entry, context));
31
+ }
32
+ }
33
+ ConsoleLogger.levels = ['debug', 'info', 'warn', 'error'];
@@ -0,0 +1,15 @@
1
+ import type { LogContext, Logger, LogLevel } from '../../application/index.js';
2
+ export interface LogEntry {
3
+ readonly level: LogLevel;
4
+ readonly message: string;
5
+ readonly context?: LogContext;
6
+ }
7
+ export declare class InMemoryLogger implements Logger {
8
+ private readonly recorded;
9
+ get entries(): readonly LogEntry[];
10
+ debug(message: string, context?: LogContext): void;
11
+ info(message: string, context?: LogContext): void;
12
+ warn(message: string, context?: LogContext): void;
13
+ error(message: string, context?: LogContext): void;
14
+ private record;
15
+ }
@@ -0,0 +1,23 @@
1
+ export class InMemoryLogger {
2
+ constructor() {
3
+ this.recorded = [];
4
+ }
5
+ get entries() {
6
+ return [...this.recorded];
7
+ }
8
+ debug(message, context) {
9
+ this.record('debug', message, context);
10
+ }
11
+ info(message, context) {
12
+ this.record('info', message, context);
13
+ }
14
+ warn(message, context) {
15
+ this.record('warn', message, context);
16
+ }
17
+ error(message, context) {
18
+ this.record('error', message, context);
19
+ }
20
+ record(level, message, context) {
21
+ this.recorded.push(context === undefined ? { level, message } : { level, message, context });
22
+ }
23
+ }
@@ -0,0 +1,7 @@
1
+ import type { LogContext } from '../../application/index.js';
2
+ export declare class LogSerializer {
3
+ static line(entry: Readonly<Record<string, string>>, context: LogContext | undefined): string;
4
+ private static plain;
5
+ private static plainObject;
6
+ private static plainError;
7
+ }
@@ -0,0 +1,55 @@
1
+ export class LogSerializer {
2
+ static line(entry, context) {
3
+ if (context === undefined) {
4
+ return JSON.stringify(entry);
5
+ }
6
+ try {
7
+ return JSON.stringify({ ...entry, context: LogSerializer.plain(context, new Set()) });
8
+ }
9
+ catch {
10
+ return JSON.stringify({ ...entry, context: '[Unserializable]' });
11
+ }
12
+ }
13
+ static plain(value, ancestors) {
14
+ if (typeof value === 'bigint') {
15
+ return value.toString();
16
+ }
17
+ if (typeof value !== 'object' || value === null) {
18
+ return value;
19
+ }
20
+ if (ancestors.has(value)) {
21
+ return '[Circular]';
22
+ }
23
+ ancestors.add(value);
24
+ try {
25
+ return LogSerializer.plainObject(value, ancestors);
26
+ }
27
+ finally {
28
+ ancestors.delete(value);
29
+ }
30
+ }
31
+ static plainObject(value, ancestors) {
32
+ if (value instanceof Error) {
33
+ return LogSerializer.plainError(value, ancestors);
34
+ }
35
+ if (Array.isArray(value)) {
36
+ return value.map((item) => LogSerializer.plain(item, ancestors));
37
+ }
38
+ const { toJSON } = value;
39
+ if (typeof toJSON === 'function') {
40
+ return LogSerializer.plain(toJSON.call(value), ancestors);
41
+ }
42
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, LogSerializer.plain(item, ancestors)]));
43
+ }
44
+ static plainError(error, ancestors) {
45
+ const { code, errors, cause } = error;
46
+ return {
47
+ name: error.name,
48
+ message: error.message,
49
+ ...(typeof code === 'string' ? { code } : {}),
50
+ ...(Array.isArray(errors) ? { errors: LogSerializer.plain(errors, ancestors) } : {}),
51
+ ...(error.stack === undefined ? {} : { stack: error.stack }),
52
+ ...(cause === undefined ? {} : { cause: LogSerializer.plain(cause, ancestors) }),
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,7 @@
1
+ import type { Logger } from '../../application/index.js';
2
+ export declare class SilentLogger implements Logger {
3
+ debug(): void;
4
+ info(): void;
5
+ warn(): void;
6
+ error(): void;
7
+ }
@@ -0,0 +1,14 @@
1
+ export class SilentLogger {
2
+ debug() {
3
+ return undefined;
4
+ }
5
+ info() {
6
+ return undefined;
7
+ }
8
+ warn() {
9
+ return undefined;
10
+ }
11
+ error() {
12
+ return undefined;
13
+ }
14
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,25 @@
1
+ export interface ExceptionOptions {
2
+ cause?: unknown;
3
+ }
4
+ export type ExceptionCodeNames = Readonly<Record<string, string>>;
5
+ export declare abstract class AbstractException extends Error {
6
+ private static readonly fallbackCode;
7
+ readonly cause?: unknown;
8
+ private readonly exceptionCodes;
9
+ private readonly codeNames;
10
+ readonly code: string;
11
+ private readonly createdAt;
12
+ static [Symbol.hasInstance](candidate: unknown): boolean;
13
+ constructor(message: string, exceptionCodes: string[], options?: ExceptionOptions, codeNames?: ExceptionCodeNames);
14
+ get timestamp(): Date;
15
+ get description(): string;
16
+ private labelOf;
17
+ print(): string;
18
+ toJSON(): {
19
+ name: string;
20
+ message: string;
21
+ code: string;
22
+ description: string;
23
+ timestamp: string;
24
+ };
25
+ }
@@ -0,0 +1,55 @@
1
+ var _a;
2
+ import { ExceptionBrand } from './brand/exception-brand.js';
3
+ export class AbstractException extends Error {
4
+ static [Symbol.hasInstance](candidate) {
5
+ return (Function.prototype[Symbol.hasInstance].call(this, candidate) ||
6
+ ExceptionBrand.matches(this, candidate));
7
+ }
8
+ constructor(message, exceptionCodes, options = {}, codeNames = {}) {
9
+ super(message);
10
+ this.name = this.constructor.name;
11
+ this.exceptionCodes = exceptionCodes;
12
+ this.codeNames = codeNames;
13
+ this.code =
14
+ exceptionCodes.length > 0
15
+ ? exceptionCodes[exceptionCodes.length - 1]
16
+ : _a.fallbackCode;
17
+ this.createdAt = Date.now();
18
+ if ('cause' in options) {
19
+ Object.defineProperty(this, 'cause', {
20
+ value: options.cause,
21
+ writable: true,
22
+ configurable: true,
23
+ });
24
+ }
25
+ ExceptionBrand.brandInstance(this, exceptionCodes);
26
+ Error.captureStackTrace?.(this, this.constructor);
27
+ }
28
+ get timestamp() {
29
+ return new Date(this.createdAt);
30
+ }
31
+ get description() {
32
+ return this.exceptionCodes.map((code) => `${this.labelOf(code)} (${code})`).join(', ');
33
+ }
34
+ labelOf(code) {
35
+ const name = Object.keys(this.codeNames).find((key) => this.codeNames[key] === code);
36
+ return name === undefined ? this.name : name.replace(/([A-Z])/g, ' $1').trim();
37
+ }
38
+ print() {
39
+ return `[${this.description}]: ${this.message}, ${this.timestamp.toISOString()}`;
40
+ }
41
+ toJSON() {
42
+ return {
43
+ name: this.name,
44
+ message: this.message,
45
+ code: this.code,
46
+ description: this.description,
47
+ timestamp: this.timestamp.toISOString(),
48
+ };
49
+ }
50
+ }
51
+ _a = AbstractException;
52
+ AbstractException.fallbackCode = 'E000';
53
+ (() => {
54
+ ExceptionBrand.brandClass(_a, ExceptionBrand.anyCode);
55
+ })();
@@ -0,0 +1,6 @@
1
+ export declare class ExceptionBrand {
2
+ static readonly anyCode = "*";
3
+ static brandClass(exceptionClass: object, code: string): void;
4
+ static brandInstance(exception: object, codes: readonly string[]): void;
5
+ static matches(exceptionClass: object, candidate: unknown): boolean;
6
+ }
@@ -0,0 +1,25 @@
1
+ const INSTANCE_CODES = Symbol.for('@archi-code/ddd/exception-codes.v1');
2
+ const CLASS_CODE = Symbol.for('@archi-code/ddd/exception-class-code.v1');
3
+ export class ExceptionBrand {
4
+ static brandClass(exceptionClass, code) {
5
+ Object.defineProperty(exceptionClass, CLASS_CODE, { value: code });
6
+ }
7
+ static brandInstance(exception, codes) {
8
+ Object.defineProperty(exception, INSTANCE_CODES, { value: Object.freeze([...codes]) });
9
+ }
10
+ static matches(exceptionClass, candidate) {
11
+ if (!Object.prototype.hasOwnProperty.call(exceptionClass, CLASS_CODE)) {
12
+ return false;
13
+ }
14
+ if (typeof candidate !== 'object' || candidate === null) {
15
+ return false;
16
+ }
17
+ const codes = candidate[INSTANCE_CODES];
18
+ if (!Array.isArray(codes)) {
19
+ return false;
20
+ }
21
+ const code = exceptionClass[CLASS_CODE];
22
+ return code === ExceptionBrand.anyCode || codes.includes(code);
23
+ }
24
+ }
25
+ ExceptionBrand.anyCode = '*';
@@ -0,0 +1,4 @@
1
+ export declare class ReceivedValue {
2
+ static readonly maxLength = 64;
3
+ static describe(value: unknown): string;
4
+ }
@@ -0,0 +1,9 @@
1
+ import { anyToString } from '@archi-code/validation';
2
+ export class ReceivedValue {
3
+ static describe(value) {
4
+ const text = typeof value === 'string' ? value : anyToString(value);
5
+ const shown = text.length > ReceivedValue.maxLength ? `${text.slice(0, ReceivedValue.maxLength)}…` : text;
6
+ return typeof value === 'string' ? `"${shown}"` : shown;
7
+ }
8
+ }
9
+ ReceivedValue.maxLength = 64;
@@ -0,0 +1,8 @@
1
+ export { AbstractException } from './exceptions/abstract.exception.js';
2
+ export type { ExceptionCodeNames, ExceptionOptions } from './exceptions/abstract.exception.js';
3
+ export { ExceptionBrand } from './exceptions/brand/exception-brand.js';
4
+ export { ReceivedValue } from './exceptions/received/received-value.js';
5
+ export { IssueCollector } from './issue-collector.js';
6
+ export type { IssueReader } from './issue-collector.js';
7
+ export { IssueCollectionError } from './issue-collection-error.js';
8
+ export type { CollectedIssue } from './issue-collection-error.js';
@@ -0,0 +1,5 @@
1
+ export { AbstractException } from './exceptions/abstract.exception.js';
2
+ export { ExceptionBrand } from './exceptions/brand/exception-brand.js';
3
+ export { ReceivedValue } from './exceptions/received/received-value.js';
4
+ export { IssueCollector } from './issue-collector.js';
5
+ export { IssueCollectionError } from './issue-collection-error.js';
@@ -0,0 +1,9 @@
1
+ export interface CollectedIssue {
2
+ readonly field: string | null;
3
+ readonly code: string;
4
+ readonly message: string;
5
+ }
6
+ export declare class IssueCollectionError extends Error {
7
+ readonly issues: readonly CollectedIssue[];
8
+ constructor(issues: readonly CollectedIssue[]);
9
+ }
@@ -0,0 +1,7 @@
1
+ export class IssueCollectionError extends Error {
2
+ constructor(issues) {
3
+ super(`${issues.length} issues collected`);
4
+ this.name = 'IssueCollectionError';
5
+ this.issues = Object.freeze([...issues]);
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { CollectedIssue } from './issue-collection-error.js';
2
+ export type IssueReader = (error: unknown) => readonly CollectedIssue[] | null;
3
+ export declare class IssueCollector {
4
+ static collectFields(builds: Readonly<Record<string, () => unknown>>, readIssues: IssueReader): Record<string, unknown>;
5
+ static collectItems<Item, Built>(items: readonly Item[], build: (item: Item, index: number) => Built, readIssues: IssueReader): Built[];
6
+ private static collect;
7
+ private static issuesAt;
8
+ }
@@ -0,0 +1,37 @@
1
+ import { IssueCollectionError } from './issue-collection-error.js';
2
+ export class IssueCollector {
3
+ static collectFields(builds, readIssues) {
4
+ return Object.fromEntries(IssueCollector.collect(Object.entries(builds), readIssues));
5
+ }
6
+ static collectItems(items, build, readIssues) {
7
+ const builds = items.map((item, index) => [String(index), () => build(item, index)]);
8
+ return IssueCollector.collect(builds, readIssues).map(([, built]) => built);
9
+ }
10
+ static collect(builds, readIssues) {
11
+ const built = [];
12
+ const issues = [];
13
+ for (const [path, build] of builds) {
14
+ try {
15
+ built.push([path, build()]);
16
+ }
17
+ catch (error) {
18
+ issues.push(...IssueCollector.issuesAt(path, error, readIssues));
19
+ }
20
+ }
21
+ if (issues.length > 0) {
22
+ throw new IssueCollectionError(issues);
23
+ }
24
+ return built;
25
+ }
26
+ static issuesAt(path, error, readIssues) {
27
+ const issues = readIssues(error);
28
+ if (issues === null) {
29
+ throw error;
30
+ }
31
+ return issues.map((issue) => ({
32
+ field: issue.field === null ? path : `${path}.${issue.field}`,
33
+ code: issue.code,
34
+ message: issue.message,
35
+ }));
36
+ }
37
+ }
package/package.json CHANGED
@@ -1,6 +1,97 @@
1
1
  {
2
2
  "name": "@archi-code/ddd",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.0-alpha.2",
4
+ "keywords": [
5
+ "DDD",
6
+ "domain-driven design",
7
+ "hexagonal",
8
+ "clean architecture",
9
+ "value object",
10
+ "aggregate",
11
+ "domain events",
12
+ "use case",
13
+ "repository",
14
+ "node",
15
+ "browser"
16
+ ],
17
+ "author": "Jose Guillermo",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/jguillermo/archi-code-core"
22
+ },
23
+ "engines": {
24
+ "node": ">=24"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "exports": {
30
+ "./domain": {
31
+ "import": {
32
+ "types": "./dist/esm/domain/index.d.ts",
33
+ "default": "./dist/esm/domain/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/cjs/domain/index.d.ts",
37
+ "default": "./dist/cjs/domain/index.js"
38
+ }
39
+ },
40
+ "./application": {
41
+ "import": {
42
+ "types": "./dist/esm/application/index.d.ts",
43
+ "default": "./dist/esm/application/index.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/cjs/application/index.d.ts",
47
+ "default": "./dist/cjs/application/index.js"
48
+ }
49
+ },
50
+ "./infrastructure": {
51
+ "import": {
52
+ "types": "./dist/esm/infrastructure/index.d.ts",
53
+ "default": "./dist/esm/infrastructure/index.js"
54
+ },
55
+ "require": {
56
+ "types": "./dist/cjs/infrastructure/index.d.ts",
57
+ "default": "./dist/cjs/infrastructure/index.js"
58
+ }
59
+ },
60
+ "./package.json": "./package.json"
61
+ },
62
+ "typesVersions": {
63
+ "*": {
64
+ "domain": [
65
+ "./dist/cjs/domain/index.d.ts"
66
+ ],
67
+ "application": [
68
+ "./dist/cjs/application/index.d.ts"
69
+ ],
70
+ "infrastructure": [
71
+ "./dist/cjs/infrastructure/index.d.ts"
72
+ ]
73
+ }
74
+ },
75
+ "files": [
76
+ "dist/",
77
+ "SKILL.md",
78
+ "ddd-skills/"
79
+ ],
80
+ "sideEffects": false,
81
+ "scripts": {
82
+ "prebuild": "rm -rf dist || true",
83
+ "build:cjs": "tsc -p tsconfig.cjs.json",
84
+ "build:esm": "tsc -p tsconfig.esm.json && node ../../scripts/fix-esm.js",
85
+ "build": "npm run build:cjs && npm run build:esm",
86
+ "test": "vitest run",
87
+ "test:coverage": "vitest run --coverage",
88
+ "check:types": "tsc -p tsconfig.json --noEmit --incremental false",
89
+ "check:dist": "node ../../scripts/check-dist.js && attw --pack . && node ../../scripts/check-browser.js",
90
+ "check:all": "npm run check:types && npm run test:coverage && npm run build && npm run check:dist"
91
+ },
92
+ "dependencies": {
93
+ "@archi-code/validation": "3.0.0-alpha.6",
94
+ "uuid": "^11.1.1"
95
+ },
96
+ "releaseCommit": "90204648d023639e296f0946e2c715b8a32a47ef"
97
+ }