@archi-code/ddd 3.0.0-alpha.1 → 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 (282) hide show
  1. package/README.md +478 -376
  2. package/SKILL.md +10 -8
  3. package/ddd-skills/archi-code-ddd/imports.md +28 -18
  4. package/ddd-skills/archi-code-ddd/layers.md +68 -53
  5. package/ddd-skills/archi-code-ddd/patterns.md +50 -43
  6. package/ddd-skills/archi-code-ddd/what-not-to-do.md +25 -18
  7. package/ddd-skills/archi-code-ddd/where-each-class-goes.md +11 -10
  8. package/ddd-skills/ddd-agregados/GUIA.md +2 -2
  9. package/ddd-skills/ddd-agregados/references/consistencia-eventual.md +5 -6
  10. package/ddd-skills/ddd-agregados/references/fabricas.md +5 -8
  11. package/ddd-skills/ddd-agregados/references/implementacion-ts.md +22 -27
  12. package/ddd-skills/ddd-arquitectura/GUIA.md +4 -4
  13. package/ddd-skills/ddd-arquitectura/assets/dependency-cruiser.cjs +13 -6
  14. package/ddd-skills/ddd-arquitectura/references/estilos-adicionales.md +2 -2
  15. package/ddd-skills/ddd-arquitectura/references/estructura-hexagonal-ts.md +70 -16
  16. package/ddd-skills/ddd-auditoria-refactorizacion/GUIA.md +1 -1
  17. package/ddd-skills/ddd-auditoria-refactorizacion/references/ejemplo-auditoria.md +9 -11
  18. package/ddd-skills/ddd-auditoria-refactorizacion/references/lista-comprobacion.md +4 -4
  19. package/ddd-skills/ddd-auditoria-refactorizacion/references/plan-migracion.md +2 -2
  20. package/ddd-skills/ddd-context-mapping/GUIA.md +5 -5
  21. package/ddd-skills/ddd-context-mapping/references/anticorrupcion-ts.md +33 -18
  22. package/ddd-skills/ddd-context-mapping/references/estilos-integracion.md +4 -7
  23. package/ddd-skills/ddd-event-sourcing-cqrs/GUIA.md +2 -2
  24. package/ddd-skills/ddd-event-sourcing-cqrs/references/event-sourcing-ts.md +32 -27
  25. package/ddd-skills/ddd-event-sourcing-cqrs/references/proyecciones-cqrs-ts.md +7 -7
  26. package/ddd-skills/ddd-eventos-dominio/GUIA.md +3 -3
  27. package/ddd-skills/ddd-eventos-dominio/references/diseno-eventos.md +15 -16
  28. package/ddd-skills/ddd-eventos-dominio/references/ejemplo-ecommerce.md +11 -11
  29. package/ddd-skills/ddd-eventos-dominio/references/publicacion-ts.md +34 -31
  30. package/ddd-skills/ddd-repositorios-persistencia/GUIA.md +7 -7
  31. package/ddd-skills/ddd-repositorios-persistencia/references/implementacion-ts.md +50 -32
  32. package/ddd-skills/ddd-repositorios-persistencia/references/tests-repositorios.md +31 -17
  33. package/ddd-skills/ddd-repositorios-persistencia/references/transacciones-ts.md +21 -14
  34. package/ddd-skills/ddd-servicios-capa-aplicacion/GUIA.md +2 -2
  35. package/ddd-skills/ddd-servicios-capa-aplicacion/references/capa-aplicacion-ts.md +19 -19
  36. package/ddd-skills/ddd-servicios-capa-aplicacion/references/ejemplo-ecommerce.md +12 -15
  37. package/ddd-skills/ddd-servicios-capa-aplicacion/references/servicios-dominio-ts.md +5 -6
  38. package/ddd-skills/ddd-value-objects-entidades/GUIA.md +3 -3
  39. package/ddd-skills/ddd-value-objects-entidades/references/entidades-ts.md +7 -9
  40. package/ddd-skills/ddd-value-objects-entidades/references/persistencia-valores.md +5 -5
  41. package/ddd-skills/ddd-value-objects-entidades/references/validacion.md +9 -9
  42. package/ddd-skills/ddd-value-objects-entidades/references/value-objects-ts.md +2 -3
  43. package/dist/cjs/application/event/listens-to.js +4 -4
  44. package/dist/cjs/{exceptions/application → application/exceptions}/aggregate-not-found.exception.d.ts +1 -1
  45. package/dist/cjs/{exceptions/application → application/exceptions}/aggregate-not-found.exception.js +4 -4
  46. package/dist/cjs/application/exceptions/application-exception-code.d.ts +7 -0
  47. package/dist/cjs/application/exceptions/application-exception-code.js +11 -0
  48. package/dist/cjs/application/exceptions/application.exception.d.ts +6 -0
  49. package/dist/cjs/application/exceptions/application.exception.js +16 -0
  50. package/dist/cjs/{exceptions/application → application/exceptions}/concurrency.exception.d.ts +1 -1
  51. package/dist/cjs/{exceptions/application → application/exceptions}/concurrency.exception.js +4 -4
  52. package/dist/cjs/{exceptions/application → application/exceptions}/not-allowed.exception.d.ts +1 -1
  53. package/dist/cjs/{exceptions/application → application/exceptions}/not-allowed.exception.js +4 -4
  54. package/dist/cjs/application/exceptions/unexpected-error.exception.d.ts +5 -0
  55. package/dist/cjs/application/exceptions/unexpected-error.exception.js +17 -0
  56. package/dist/cjs/application/index.d.ts +7 -0
  57. package/dist/cjs/application/index.js +15 -1
  58. package/dist/cjs/application/use-case/use-case.js +3 -2
  59. package/dist/{esm/domain/type/value-objects/value-objects.d.ts → cjs/application/value-object-builder/value-object-builder.d.ts} +3 -3
  60. package/dist/cjs/application/value-object-builder/value-object-builder.js +51 -0
  61. package/dist/cjs/domain/aggregate/aggregate-root.d.ts +0 -5
  62. package/dist/cjs/domain/aggregate/aggregate-root.js +4 -20
  63. package/dist/cjs/domain/entity/entity.js +2 -2
  64. package/dist/cjs/domain/event/event-base.d.ts +3 -9
  65. package/dist/cjs/domain/event/event-base.js +8 -38
  66. package/dist/cjs/domain/exceptions/domain-exception-code.d.ts +7 -0
  67. package/dist/cjs/domain/exceptions/domain-exception-code.js +11 -0
  68. package/dist/cjs/domain/exceptions/domain.exception.d.ts +6 -0
  69. package/dist/cjs/domain/exceptions/domain.exception.js +16 -0
  70. package/dist/cjs/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
  71. package/dist/cjs/domain/exceptions/invalid-event-definition.exception.js +19 -0
  72. package/dist/cjs/{exceptions/domain → domain/exceptions}/required-value.exception.js +5 -6
  73. package/dist/cjs/{exceptions/domain → domain/exceptions}/type-primitive.exception.js +5 -6
  74. package/dist/cjs/{exceptions/domain → domain/exceptions}/validation.exception.js +5 -5
  75. package/dist/cjs/domain/index.d.ts +8 -1
  76. package/dist/cjs/domain/index.js +14 -2
  77. package/dist/cjs/domain/primitive/primitive-types.d.ts +1 -3
  78. package/dist/cjs/domain/type/abstract-type.d.ts +6 -8
  79. package/dist/cjs/domain/type/abstract-type.js +15 -23
  80. package/dist/cjs/domain/type/array-type.d.ts +2 -1
  81. package/dist/cjs/domain/type/array-type.js +17 -18
  82. package/dist/cjs/domain/type/boolean-type.js +2 -2
  83. package/dist/cjs/domain/type/composite/composite-brand.d.ts +4 -0
  84. package/dist/cjs/domain/type/composite/composite-brand.js +15 -0
  85. package/dist/cjs/domain/type/composite/composite-field.d.ts +7 -8
  86. package/dist/cjs/domain/type/composite/composite-field.js +70 -47
  87. package/dist/cjs/domain/type/composite/composite-issues.d.ts +6 -0
  88. package/dist/cjs/domain/type/composite/composite-issues.js +35 -0
  89. package/dist/cjs/domain/type/composite/composite.js +15 -19
  90. package/dist/cjs/domain/type/date-type.d.ts +3 -2
  91. package/dist/cjs/domain/type/date-type.js +42 -7
  92. package/dist/cjs/domain/type/enum-type.js +2 -2
  93. package/dist/cjs/domain/type/id-type.d.ts +1 -1
  94. package/dist/cjs/domain/type/id-type.js +4 -4
  95. package/dist/cjs/domain/type/index.d.ts +2 -4
  96. package/dist/cjs/domain/type/index.js +3 -7
  97. package/dist/cjs/domain/type/json-type.d.ts +4 -0
  98. package/dist/cjs/domain/type/json-type.js +33 -4
  99. package/dist/cjs/domain/type/number-type.js +2 -2
  100. package/dist/cjs/domain/type/required/required-mark.d.ts +0 -1
  101. package/dist/cjs/domain/type/string-type.js +2 -2
  102. package/dist/cjs/domain/type/uuid-type.js +2 -2
  103. package/dist/cjs/infrastructure/event/domain-event-bus.js +9 -9
  104. package/dist/cjs/infrastructure/event/event-registry.js +9 -9
  105. package/dist/cjs/infrastructure/event/in-memory/emitter.js +2 -2
  106. package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.d.ts +1 -1
  107. package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.js +6 -7
  108. package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js +4 -4
  109. package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
  110. package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.js +10 -0
  111. package/dist/cjs/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
  112. package/dist/cjs/infrastructure/exceptions/infrastructure.exception.js +16 -0
  113. package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.d.ts +1 -1
  114. package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.js +4 -4
  115. package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
  116. package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.js +34 -0
  117. package/dist/cjs/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
  118. package/dist/cjs/infrastructure/exceptions/kind/exception-kind.js +13 -0
  119. package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js +4 -4
  120. package/dist/cjs/infrastructure/index.d.ts +7 -2
  121. package/dist/cjs/infrastructure/index.js +15 -3
  122. package/dist/cjs/infrastructure/logging/console-logger.js +2 -2
  123. package/dist/{esm → cjs/shared}/exceptions/abstract.exception.d.ts +6 -4
  124. package/dist/cjs/{exceptions → shared/exceptions}/abstract.exception.js +9 -16
  125. package/dist/cjs/shared/index.d.ts +8 -0
  126. package/dist/cjs/shared/index.js +13 -0
  127. package/dist/cjs/shared/issue-collection-error.d.ts +9 -0
  128. package/dist/cjs/shared/issue-collection-error.js +11 -0
  129. package/dist/cjs/shared/issue-collector.d.ts +8 -0
  130. package/dist/cjs/shared/issue-collector.js +41 -0
  131. package/dist/esm/application/event/listens-to.js +1 -1
  132. package/dist/esm/{exceptions/application → application/exceptions}/aggregate-not-found.exception.d.ts +1 -1
  133. package/dist/esm/application/exceptions/aggregate-not-found.exception.js +13 -0
  134. package/dist/esm/application/exceptions/application-exception-code.d.ts +7 -0
  135. package/dist/esm/application/exceptions/application-exception-code.js +8 -0
  136. package/dist/esm/application/exceptions/application.exception.d.ts +6 -0
  137. package/dist/esm/application/exceptions/application.exception.js +12 -0
  138. package/dist/esm/{exceptions/application → application/exceptions}/concurrency.exception.d.ts +1 -1
  139. package/dist/esm/{exceptions/application → application/exceptions}/concurrency.exception.js +4 -4
  140. package/dist/esm/{exceptions/application → application/exceptions}/not-allowed.exception.d.ts +1 -1
  141. package/dist/esm/application/exceptions/not-allowed.exception.js +13 -0
  142. package/dist/esm/application/exceptions/unexpected-error.exception.d.ts +5 -0
  143. package/dist/esm/application/exceptions/unexpected-error.exception.js +13 -0
  144. package/dist/esm/application/index.d.ts +7 -0
  145. package/dist/esm/application/index.js +7 -0
  146. package/dist/esm/application/use-case/use-case.js +3 -2
  147. package/dist/{cjs/domain/type/value-objects/value-objects.d.ts → esm/application/value-object-builder/value-object-builder.d.ts} +3 -3
  148. package/dist/esm/application/value-object-builder/value-object-builder.js +47 -0
  149. package/dist/esm/domain/aggregate/aggregate-root.d.ts +0 -5
  150. package/dist/esm/domain/aggregate/aggregate-root.js +4 -20
  151. package/dist/esm/domain/entity/entity.js +1 -1
  152. package/dist/esm/domain/event/event-base.d.ts +3 -9
  153. package/dist/esm/domain/event/event-base.js +8 -38
  154. package/dist/esm/domain/exceptions/domain-exception-code.d.ts +7 -0
  155. package/dist/esm/domain/exceptions/domain-exception-code.js +8 -0
  156. package/dist/esm/domain/exceptions/domain.exception.d.ts +6 -0
  157. package/dist/esm/domain/exceptions/domain.exception.js +12 -0
  158. package/dist/esm/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
  159. package/dist/esm/domain/exceptions/invalid-event-definition.exception.js +15 -0
  160. package/dist/esm/{exceptions/domain → domain/exceptions}/required-value.exception.js +4 -5
  161. package/dist/esm/{exceptions/domain → domain/exceptions}/type-primitive.exception.js +4 -5
  162. package/dist/esm/{exceptions/domain → domain/exceptions}/validation.exception.js +5 -5
  163. package/dist/esm/domain/index.d.ts +7 -0
  164. package/dist/esm/domain/index.js +6 -0
  165. package/dist/esm/domain/primitive/primitive-types.d.ts +1 -3
  166. package/dist/esm/domain/type/abstract-type.d.ts +6 -8
  167. package/dist/esm/domain/type/abstract-type.js +14 -22
  168. package/dist/esm/domain/type/array-type.d.ts +2 -1
  169. package/dist/esm/domain/type/array-type.js +16 -17
  170. package/dist/esm/domain/type/boolean-type.js +1 -1
  171. package/dist/esm/domain/type/composite/composite-brand.d.ts +4 -0
  172. package/dist/esm/domain/type/composite/composite-brand.js +11 -0
  173. package/dist/esm/domain/type/composite/composite-field.d.ts +7 -8
  174. package/dist/esm/domain/type/composite/composite-field.js +69 -46
  175. package/dist/esm/domain/type/composite/composite-issues.d.ts +6 -0
  176. package/dist/esm/domain/type/composite/composite-issues.js +31 -0
  177. package/dist/esm/domain/type/composite/composite.js +13 -17
  178. package/dist/esm/domain/type/date-type.d.ts +3 -2
  179. package/dist/esm/domain/type/date-type.js +39 -4
  180. package/dist/esm/domain/type/enum-type.js +1 -1
  181. package/dist/esm/domain/type/id-type.d.ts +1 -1
  182. package/dist/esm/domain/type/id-type.js +2 -2
  183. package/dist/esm/domain/type/index.d.ts +2 -4
  184. package/dist/esm/domain/type/index.js +1 -3
  185. package/dist/esm/domain/type/json-type.d.ts +4 -0
  186. package/dist/esm/domain/type/json-type.js +32 -3
  187. package/dist/esm/domain/type/number-type.js +1 -1
  188. package/dist/esm/domain/type/required/required-mark.d.ts +0 -1
  189. package/dist/esm/domain/type/string-type.js +1 -1
  190. package/dist/esm/domain/type/uuid-type.js +1 -1
  191. package/dist/esm/infrastructure/event/domain-event-bus.js +5 -5
  192. package/dist/esm/infrastructure/event/event-registry.js +4 -4
  193. package/dist/esm/infrastructure/event/in-memory/emitter.js +1 -1
  194. package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.d.ts +1 -1
  195. package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.js +5 -6
  196. package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js +4 -4
  197. package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
  198. package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.js +7 -0
  199. package/dist/esm/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
  200. package/dist/esm/infrastructure/exceptions/infrastructure.exception.js +12 -0
  201. package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.d.ts +1 -1
  202. package/dist/esm/infrastructure/exceptions/internal-error.exception.js +13 -0
  203. package/dist/esm/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
  204. package/dist/esm/infrastructure/exceptions/kind/exception-classifier.js +30 -0
  205. package/dist/esm/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
  206. package/dist/esm/infrastructure/exceptions/kind/exception-kind.js +10 -0
  207. package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js +4 -4
  208. package/dist/esm/infrastructure/index.d.ts +7 -2
  209. package/dist/esm/infrastructure/index.js +7 -1
  210. package/dist/esm/infrastructure/logging/console-logger.js +1 -1
  211. package/dist/{cjs → esm/shared}/exceptions/abstract.exception.d.ts +6 -4
  212. package/dist/esm/{exceptions → shared/exceptions}/abstract.exception.js +9 -16
  213. package/dist/esm/shared/index.d.ts +8 -0
  214. package/dist/esm/shared/index.js +5 -0
  215. package/dist/esm/shared/issue-collection-error.d.ts +9 -0
  216. package/dist/esm/shared/issue-collection-error.js +7 -0
  217. package/dist/esm/shared/issue-collector.d.ts +8 -0
  218. package/dist/esm/shared/issue-collector.js +37 -0
  219. package/package.json +7 -18
  220. package/dist/cjs/domain/type/equality/value-equality.d.ts +0 -7
  221. package/dist/cjs/domain/type/equality/value-equality.js +0 -41
  222. package/dist/cjs/domain/type/immutable/immutable-date.d.ts +0 -4
  223. package/dist/cjs/domain/type/immutable/immutable-date.js +0 -37
  224. package/dist/cjs/domain/type/immutable/immutable.d.ts +0 -4
  225. package/dist/cjs/domain/type/immutable/immutable.js +0 -19
  226. package/dist/cjs/domain/type/value-objects/value-objects.js +0 -70
  227. package/dist/cjs/exceptions/application/application.exception.d.ts +0 -6
  228. package/dist/cjs/exceptions/application/application.exception.js +0 -17
  229. package/dist/cjs/exceptions/domain/domain.exception.d.ts +0 -6
  230. package/dist/cjs/exceptions/domain/domain.exception.js +0 -17
  231. package/dist/cjs/exceptions/exception-code.d.ts +0 -15
  232. package/dist/cjs/exceptions/exception-code.js +0 -19
  233. package/dist/cjs/exceptions/index.d.ts +0 -14
  234. package/dist/cjs/exceptions/index.js +0 -30
  235. package/dist/cjs/exceptions/infrastructure/infrastructure.exception.d.ts +0 -6
  236. package/dist/cjs/exceptions/infrastructure/infrastructure.exception.js +0 -17
  237. package/dist/cjs/infrastructure/http/http-error-mapper.d.ts +0 -23
  238. package/dist/cjs/infrastructure/http/http-error-mapper.js +0 -63
  239. package/dist/esm/domain/type/equality/value-equality.d.ts +0 -7
  240. package/dist/esm/domain/type/equality/value-equality.js +0 -37
  241. package/dist/esm/domain/type/immutable/immutable-date.d.ts +0 -4
  242. package/dist/esm/domain/type/immutable/immutable-date.js +0 -33
  243. package/dist/esm/domain/type/immutable/immutable.d.ts +0 -4
  244. package/dist/esm/domain/type/immutable/immutable.js +0 -15
  245. package/dist/esm/domain/type/value-objects/value-objects.js +0 -66
  246. package/dist/esm/exceptions/application/aggregate-not-found.exception.js +0 -13
  247. package/dist/esm/exceptions/application/application.exception.d.ts +0 -6
  248. package/dist/esm/exceptions/application/application.exception.js +0 -13
  249. package/dist/esm/exceptions/application/not-allowed.exception.js +0 -13
  250. package/dist/esm/exceptions/domain/domain.exception.d.ts +0 -6
  251. package/dist/esm/exceptions/domain/domain.exception.js +0 -13
  252. package/dist/esm/exceptions/exception-code.d.ts +0 -15
  253. package/dist/esm/exceptions/exception-code.js +0 -16
  254. package/dist/esm/exceptions/index.d.ts +0 -14
  255. package/dist/esm/exceptions/index.js +0 -14
  256. package/dist/esm/exceptions/infrastructure/infrastructure.exception.d.ts +0 -6
  257. package/dist/esm/exceptions/infrastructure/infrastructure.exception.js +0 -13
  258. package/dist/esm/exceptions/infrastructure/internal-error.exception.js +0 -13
  259. package/dist/esm/infrastructure/http/http-error-mapper.d.ts +0 -23
  260. package/dist/esm/infrastructure/http/http-error-mapper.js +0 -59
  261. /package/dist/cjs/{exceptions/domain → domain/exceptions}/required-value.exception.d.ts +0 -0
  262. /package/dist/cjs/{exceptions/domain → domain/exceptions}/type-primitive.exception.d.ts +0 -0
  263. /package/dist/cjs/{exceptions/domain → domain/exceptions}/validation.exception.d.ts +0 -0
  264. /package/dist/cjs/domain/type/required/{required.d.ts → required-type.d.ts} +0 -0
  265. /package/dist/cjs/domain/type/required/{required.js → required-type.js} +0 -0
  266. /package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.d.ts +0 -0
  267. /package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.d.ts +0 -0
  268. /package/dist/cjs/{exceptions → shared/exceptions}/brand/exception-brand.d.ts +0 -0
  269. /package/dist/cjs/{exceptions → shared/exceptions}/brand/exception-brand.js +0 -0
  270. /package/dist/cjs/{exceptions → shared/exceptions}/received/received-value.d.ts +0 -0
  271. /package/dist/cjs/{exceptions → shared/exceptions}/received/received-value.js +0 -0
  272. /package/dist/esm/{exceptions/domain → domain/exceptions}/required-value.exception.d.ts +0 -0
  273. /package/dist/esm/{exceptions/domain → domain/exceptions}/type-primitive.exception.d.ts +0 -0
  274. /package/dist/esm/{exceptions/domain → domain/exceptions}/validation.exception.d.ts +0 -0
  275. /package/dist/esm/domain/type/required/{required.d.ts → required-type.d.ts} +0 -0
  276. /package/dist/esm/domain/type/required/{required.js → required-type.js} +0 -0
  277. /package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.d.ts +0 -0
  278. /package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.d.ts +0 -0
  279. /package/dist/esm/{exceptions → shared/exceptions}/brand/exception-brand.d.ts +0 -0
  280. /package/dist/esm/{exceptions → shared/exceptions}/brand/exception-brand.js +0 -0
  281. /package/dist/esm/{exceptions → shared/exceptions}/received/received-value.d.ts +0 -0
  282. /package/dist/esm/{exceptions → shared/exceptions}/received/received-value.js +0 -0
@@ -1,8 +1,40 @@
1
1
  import { toDate } from '@archi-code/validation';
2
2
  import { AbstractType } from './abstract-type.js';
3
- import { Immutable } from './immutable/immutable.js';
4
- import { Required } from './required/required.js';
5
- import { TypePrimitiveException } from '../../exceptions/index.js';
3
+ import { Required } from './required/required-type.js';
4
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
5
+ class ImmutableDate extends Date {
6
+ constructor(date) {
7
+ super(date.getTime());
8
+ Object.freeze(this);
9
+ }
10
+ }
11
+ ImmutableDate.setters = [
12
+ 'setDate',
13
+ 'setFullYear',
14
+ 'setHours',
15
+ 'setMilliseconds',
16
+ 'setMinutes',
17
+ 'setMonth',
18
+ 'setSeconds',
19
+ 'setTime',
20
+ 'setUTCDate',
21
+ 'setUTCFullYear',
22
+ 'setUTCHours',
23
+ 'setUTCMilliseconds',
24
+ 'setUTCMinutes',
25
+ 'setUTCMonth',
26
+ 'setUTCSeconds',
27
+ 'setYear',
28
+ ];
29
+ (() => {
30
+ for (const setter of ImmutableDate.setters) {
31
+ Object.defineProperty(ImmutableDate.prototype, setter, {
32
+ value() {
33
+ throw new TypeError(`Cannot call ${setter}: the date is immutable`);
34
+ },
35
+ });
36
+ }
37
+ })();
6
38
  const TIME_WITHOUT_ZONE = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/;
7
39
  export class DateType extends AbstractType {
8
40
  filter(value) {
@@ -10,11 +42,14 @@ export class DateType extends AbstractType {
10
42
  if (!converted.ok || (typeof value === 'string' && TIME_WITHOUT_ZONE.test(value))) {
11
43
  throw new TypePrimitiveException('Date', value);
12
44
  }
13
- return Immutable.date(converted.value);
45
+ return new ImmutableDate(converted.value);
14
46
  }
15
47
  toString() {
16
48
  return this._value === null ? '' : this._value.toISOString();
17
49
  }
50
+ hasSameValue(other) {
51
+ return this._value?.getTime() === other._value?.getTime();
52
+ }
18
53
  }
19
54
  const SYSTEM_TIME = { now: () => new Date() };
20
55
  export class CreatedAt extends Required(DateType) {
@@ -1,5 +1,5 @@
1
1
  import { AbstractType } from './abstract-type.js';
2
- import { TypePrimitiveException } from '../../exceptions/index.js';
2
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
3
3
  const NUMERIC_TEXT = /^-?\d+(?:\.\d+)?$/;
4
4
  export class EnumType extends AbstractType {
5
5
  filter(value) {
@@ -1,5 +1,5 @@
1
1
  import { UuidType } from './uuid-type.js';
2
- declare const IdType_base: import("./required/required.js").RequiredType<typeof UuidType>;
2
+ declare const IdType_base: import("./required/required-type.js").RequiredType<typeof UuidType>;
3
3
  export declare class IdType<Brand extends string = string> extends IdType_base {
4
4
  protected readonly idBrand: Brand;
5
5
  protected filter(value: unknown): string;
@@ -1,6 +1,6 @@
1
- import { Required } from './required/required.js';
1
+ import { Required } from './required/required-type.js';
2
2
  import { UuidType } from './uuid-type.js';
3
- import { TypePrimitiveException } from '../../exceptions/index.js';
3
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
4
4
  const NIL_OR_MAX_UUID = /^(?:0{8}-0{4}-0{4}-0{4}-0{12}|f{8}-f{4}-f{4}-f{4}-f{12})$/i;
5
5
  export class IdType extends Required(UuidType) {
6
6
  filter(value) {
@@ -1,6 +1,6 @@
1
1
  export { AbstractType } from './abstract-type.js';
2
- export { Required } from './required/required.js';
3
- export type { RequiredType } from './required/required.js';
2
+ export { Required } from './required/required-type.js';
3
+ export type { RequiredType } from './required/required-type.js';
4
4
  export { ArrayType } from './array-type.js';
5
5
  export { BooleanType } from './boolean-type.js';
6
6
  export { CreatedAt, DateType, UpdatedAt } from './date-type.js';
@@ -11,7 +11,5 @@ export { NumberType } from './number-type.js';
11
11
  export { StringType } from './string-type.js';
12
12
  export { IdType } from './id-type.js';
13
13
  export { UuidType } from './uuid-type.js';
14
- export { Immutable } from './immutable/immutable.js';
15
- export { ValueObjects } from './value-objects/value-objects.js';
16
14
  export { Composite } from './composite/composite.js';
17
15
  export type { CompositeInput, CompositePrimitives, CompositeProps, CompositeSchema, CompositeType, CompositeValue, } from './composite/composite.js';
@@ -1,5 +1,5 @@
1
1
  export { AbstractType } from './abstract-type.js';
2
- export { Required } from './required/required.js';
2
+ export { Required } from './required/required-type.js';
3
3
  export { ArrayType } from './array-type.js';
4
4
  export { BooleanType } from './boolean-type.js';
5
5
  export { CreatedAt, DateType, UpdatedAt } from './date-type.js';
@@ -9,6 +9,4 @@ export { NumberType } from './number-type.js';
9
9
  export { StringType } from './string-type.js';
10
10
  export { IdType } from './id-type.js';
11
11
  export { UuidType } from './uuid-type.js';
12
- export { Immutable } from './immutable/immutable.js';
13
- export { ValueObjects } from './value-objects/value-objects.js';
14
12
  export { Composite } from './composite/composite.js';
@@ -2,4 +2,8 @@ import { AbstractType } from './abstract-type.js';
2
2
  export type JsonTypeValue = Record<string, any>;
3
3
  export declare class JsonType<T extends JsonTypeValue = JsonTypeValue> extends AbstractType<T> {
4
4
  protected filter(value: unknown): T;
5
+ protected hasSameValue(other: this): boolean;
6
+ private static sameJson;
7
+ private static deepFreeze;
8
+ private static isObject;
5
9
  }
@@ -1,13 +1,42 @@
1
1
  import { toJson } from '@archi-code/validation';
2
2
  import { AbstractType } from './abstract-type.js';
3
- import { Immutable } from './immutable/immutable.js';
4
- import { TypePrimitiveException } from '../../exceptions/index.js';
3
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
5
4
  export class JsonType extends AbstractType {
6
5
  filter(value) {
7
6
  const converted = toJson(value);
8
7
  if (!converted.ok) {
9
8
  throw new TypePrimitiveException('Json', value);
10
9
  }
11
- return Immutable.freeze(JSON.parse(JSON.stringify(converted.value)));
10
+ return JsonType.deepFreeze(JSON.parse(JSON.stringify(converted.value)));
11
+ }
12
+ hasSameValue(other) {
13
+ return JsonType.sameJson(this._value, other._value);
14
+ }
15
+ static sameJson(left, right) {
16
+ if (Array.isArray(left) || Array.isArray(right)) {
17
+ return (Array.isArray(left) &&
18
+ Array.isArray(right) &&
19
+ left.length === right.length &&
20
+ left.every((item, index) => JsonType.sameJson(item, right[index])));
21
+ }
22
+ if (JsonType.isObject(left) && JsonType.isObject(right)) {
23
+ const keys = Object.keys(left);
24
+ return (keys.length === Object.keys(right).length &&
25
+ keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
26
+ JsonType.sameJson(left[key], right[key])));
27
+ }
28
+ return left === right;
29
+ }
30
+ static deepFreeze(value) {
31
+ if (JsonType.isObject(value)) {
32
+ Object.freeze(value);
33
+ for (const child of Object.values(value)) {
34
+ JsonType.deepFreeze(child);
35
+ }
36
+ }
37
+ return value;
38
+ }
39
+ static isObject(value) {
40
+ return typeof value === 'object' && value !== null;
12
41
  }
13
42
  }
@@ -1,6 +1,6 @@
1
1
  import { toFloat } from '@archi-code/validation';
2
2
  import { AbstractType } from './abstract-type.js';
3
- import { TypePrimitiveException } from '../../exceptions/index.js';
3
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
4
4
  export class NumberType extends AbstractType {
5
5
  filter(value) {
6
6
  const converted = toFloat(value);
@@ -6,4 +6,3 @@ export declare class RequiredMark {
6
6
  export interface RequiredMarked {
7
7
  readonly [RequiredMark.symbol]: true;
8
8
  }
9
- export type ValueOf<T, I> = I extends RequiredMarked ? T : T | null;
@@ -1,6 +1,6 @@
1
1
  import { toString as convertToString } from '@archi-code/validation';
2
2
  import { AbstractType } from './abstract-type.js';
3
- import { TypePrimitiveException } from '../../exceptions/index.js';
3
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
4
4
  export class StringType extends AbstractType {
5
5
  filter(value) {
6
6
  const converted = convertToString(value);
@@ -1,7 +1,7 @@
1
1
  import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
2
2
  import { isUUID, toString as convertToString } from '@archi-code/validation';
3
3
  import { AbstractType } from './abstract-type.js';
4
- import { TypePrimitiveException } from '../../exceptions/index.js';
4
+ import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
5
5
  const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
6
6
  export class UuidType extends AbstractType {
7
7
  static random() {
@@ -1,4 +1,6 @@
1
- import { ApplicationException, DomainException, UnknownEventException, } from '../../exceptions/index.js';
1
+ import { ApplicationException } from '../../application/index.js';
2
+ import { DomainException } from '../../domain/index.js';
3
+ import { UnknownEventException } from '../exceptions/unknown-event.exception.js';
2
4
  import { ListensTo } from '../../application/index.js';
3
5
  import { SilentLogger } from '../logging/silent-logger.js';
4
6
  export class DomainEventBus {
@@ -8,12 +10,11 @@ export class DomainEventBus {
8
10
  this.logger = logger;
9
11
  }
10
12
  async publish(events) {
11
- await this.channel.send(events.map((event) => event.toJSON()));
13
+ await this.channel.send(events.map((event) => ({ ...event })));
12
14
  this.logger.debug('domain_events_published', {
13
15
  events: events.map((event) => ({
14
- eventName: event.eventName(),
16
+ eventName: event.eventName,
15
17
  eventId: event.eventId,
16
- aggregateId: event.aggregateId,
17
18
  })),
18
19
  });
19
20
  }
@@ -41,7 +42,6 @@ export class DomainEventBus {
41
42
  eventName,
42
43
  consumer,
43
44
  eventId: serialized.eventId,
44
- aggregateId: serialized.aggregateId,
45
45
  error,
46
46
  };
47
47
  if (error instanceof DomainException || error instanceof ApplicationException) {
@@ -1,5 +1,5 @@
1
- import { InternalErrorException, UnknownEventException } from '../../exceptions/index.js';
2
- import { Immutable } from '../../domain/index.js';
1
+ import { InternalErrorException } from '../exceptions/internal-error.exception.js';
2
+ import { UnknownEventException } from '../exceptions/unknown-event.exception.js';
3
3
  export class EventRegistry {
4
4
  constructor() {
5
5
  this.factories = new Map();
@@ -28,11 +28,11 @@ export class EventRegistry {
28
28
  }
29
29
  const rebuilt = factory(event);
30
30
  EventRegistry.assertSameIdentity(event, rebuilt);
31
- return Immutable.freeze(rebuilt);
31
+ return rebuilt;
32
32
  }
33
33
  static assertSameIdentity(serialized, rebuilt) {
34
34
  if (rebuilt.eventId !== String(serialized.eventId).toLowerCase() ||
35
- rebuilt.occurredOn.getTime() !== new Date(serialized.occurredOn).getTime()) {
35
+ Date.parse(rebuilt.occurredOn) !== Date.parse(serialized.occurredOn)) {
36
36
  throw new InternalErrorException(`the factory of "${serialized.eventName}" must pass the serialized event as metadata, so it keeps its eventId and occurredOn`);
37
37
  }
38
38
  }
@@ -1,4 +1,4 @@
1
- import { EventDeliveryException } from '../../../exceptions/index.js';
1
+ import { EventDeliveryException } from '../../exceptions/event-delivery.exception.js';
2
2
  export class Emitter {
3
3
  constructor() {
4
4
  this.events = new Map();
@@ -12,5 +12,5 @@ export declare class InMemoryEventChannel implements EventChannel {
12
12
  get sent(): readonly SerializedEvent[];
13
13
  send(events: readonly SerializedEvent[]): Promise<void>;
14
14
  receive(eventName: string, consumer: string, handler: ChannelHandler): Promise<ChannelSubscription>;
15
- private static frozenCopy;
15
+ private static copy;
16
16
  }
@@ -1,5 +1,4 @@
1
- import { Immutable } from '../../../domain/index.js';
2
- import { InfrastructureException } from '../../../exceptions/index.js';
1
+ import { InfrastructureException } from '../../exceptions/infrastructure.exception.js';
3
2
  import { Emitter } from './emitter.js';
4
3
  export class InMemoryEventChannel {
5
4
  constructor({ delivery = 'serial' } = {}) {
@@ -13,7 +12,7 @@ export class InMemoryEventChannel {
13
12
  }
14
13
  async send(events) {
15
14
  for (const event of events) {
16
- const copy = InMemoryEventChannel.frozenCopy(event);
15
+ const copy = InMemoryEventChannel.copy(event);
17
16
  this.sentEvents.push(copy);
18
17
  if (this.delivery === 'parallel') {
19
18
  await this.emitter.emit(copy.eventName, copy);
@@ -29,7 +28,7 @@ export class InMemoryEventChannel {
29
28
  throw new InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
30
29
  }
31
30
  this.receivers.add(receiver);
32
- const off = this.emitter.on(eventName, (event) => handler(event));
31
+ const off = this.emitter.on(eventName, (event) => handler(InMemoryEventChannel.copy(event)));
33
32
  let open = true;
34
33
  return {
35
34
  close: async () => {
@@ -41,7 +40,7 @@ export class InMemoryEventChannel {
41
40
  },
42
41
  };
43
42
  }
44
- static frozenCopy(event) {
45
- return Immutable.freeze(JSON.parse(JSON.stringify(event)));
43
+ static copy(event) {
44
+ return JSON.parse(JSON.stringify(event));
46
45
  }
47
46
  }
@@ -1,16 +1,16 @@
1
1
  var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
2
4
  import { InfrastructureException } from './infrastructure.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
5
  export class EventDeliveryException extends InfrastructureException {
6
6
  constructor(eventName, errors, consumers) {
7
7
  super(`${errors.length} of ${consumers} consumers of "${eventName}" failed.`, [
8
- ExceptionCode.EventDelivery,
8
+ InfrastructureExceptionCode.EventDelivery,
9
9
  ]);
10
10
  this.errors = Object.freeze([...errors]);
11
11
  }
12
12
  }
13
13
  _a = EventDeliveryException;
14
14
  (() => {
15
- ExceptionBrand.brandClass(_a, ExceptionCode.EventDelivery);
15
+ ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.EventDelivery);
16
16
  })();
@@ -0,0 +1,6 @@
1
+ export declare enum InfrastructureExceptionCode {
2
+ InfrastructureException = "INF000",
3
+ InternalError = "INF001",
4
+ UnknownEvent = "INF002",
5
+ EventDelivery = "INF003"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var InfrastructureExceptionCode;
2
+ (function (InfrastructureExceptionCode) {
3
+ InfrastructureExceptionCode["InfrastructureException"] = "INF000";
4
+ InfrastructureExceptionCode["InternalError"] = "INF001";
5
+ InfrastructureExceptionCode["UnknownEvent"] = "INF002";
6
+ InfrastructureExceptionCode["EventDelivery"] = "INF003";
7
+ })(InfrastructureExceptionCode || (InfrastructureExceptionCode = {}));
@@ -0,0 +1,6 @@
1
+ import { AbstractException } from '../../shared/index.js';
2
+ import type { ExceptionOptions } from '../../shared/index.js';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
4
+ export declare class InfrastructureException extends AbstractException {
5
+ constructor(message: string, exceptionCodes?: (InfrastructureExceptionCode | string)[], options?: ExceptionOptions);
6
+ }
@@ -0,0 +1,12 @@
1
+ var _a;
2
+ import { AbstractException, ExceptionBrand } from '../../shared/index.js';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
4
+ export class InfrastructureException extends AbstractException {
5
+ constructor(message, exceptionCodes = [], options = {}) {
6
+ super(message, [InfrastructureExceptionCode.InfrastructureException, ...exceptionCodes], options, InfrastructureExceptionCode);
7
+ }
8
+ }
9
+ _a = InfrastructureException;
10
+ (() => {
11
+ ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.InfrastructureException);
12
+ })();
@@ -1,5 +1,5 @@
1
+ import type { ExceptionOptions } from '../../shared/index.js';
1
2
  import { InfrastructureException } from './infrastructure.exception.js';
2
- import type { ExceptionOptions } from '../abstract.exception.js';
3
3
  export declare class InternalErrorException extends InfrastructureException {
4
4
  constructor(message: string, options?: ExceptionOptions);
5
5
  }
@@ -0,0 +1,13 @@
1
+ var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
4
+ import { InfrastructureException } from './infrastructure.exception.js';
5
+ export class InternalErrorException extends InfrastructureException {
6
+ constructor(message, options = {}) {
7
+ super(`Failed, internal error: ${message}`, [InfrastructureExceptionCode.InternalError], options);
8
+ }
9
+ }
10
+ _a = InternalErrorException;
11
+ (() => {
12
+ ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.InternalError);
13
+ })();
@@ -0,0 +1,4 @@
1
+ import { ExceptionKind } from './exception-kind.js';
2
+ export declare class ExceptionClassifier {
3
+ static classify(error: unknown): ExceptionKind;
4
+ }
@@ -0,0 +1,30 @@
1
+ import { ApplicationException, AggregateNotFoundException, ConcurrencyException, NotAllowedException, UnexpectedErrorException, } from '../../../application/index.js';
2
+ import { DomainException, InvalidEventDefinitionException, RequiredValueException, TypePrimitiveException, } from '../../../domain/index.js';
3
+ import { ExceptionKind } from './exception-kind.js';
4
+ export class ExceptionClassifier {
5
+ static classify(error) {
6
+ if (error instanceof AggregateNotFoundException) {
7
+ return ExceptionKind.NotFound;
8
+ }
9
+ if (error instanceof NotAllowedException) {
10
+ return ExceptionKind.NotAllowed;
11
+ }
12
+ if (error instanceof ConcurrencyException) {
13
+ return ExceptionKind.Conflict;
14
+ }
15
+ if (error instanceof UnexpectedErrorException ||
16
+ error instanceof InvalidEventDefinitionException) {
17
+ return ExceptionKind.Internal;
18
+ }
19
+ if (error instanceof TypePrimitiveException || error instanceof RequiredValueException) {
20
+ return ExceptionKind.Malformed;
21
+ }
22
+ if (error instanceof DomainException) {
23
+ return ExceptionKind.Invalid;
24
+ }
25
+ if (error instanceof ApplicationException) {
26
+ return ExceptionKind.Rejected;
27
+ }
28
+ return ExceptionKind.Internal;
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ export declare enum ExceptionKind {
2
+ NotFound = "not_found",
3
+ NotAllowed = "not_allowed",
4
+ Conflict = "conflict",
5
+ Malformed = "malformed",
6
+ Invalid = "invalid",
7
+ Rejected = "rejected",
8
+ Internal = "internal"
9
+ }
@@ -0,0 +1,10 @@
1
+ export var ExceptionKind;
2
+ (function (ExceptionKind) {
3
+ ExceptionKind["NotFound"] = "not_found";
4
+ ExceptionKind["NotAllowed"] = "not_allowed";
5
+ ExceptionKind["Conflict"] = "conflict";
6
+ ExceptionKind["Malformed"] = "malformed";
7
+ ExceptionKind["Invalid"] = "invalid";
8
+ ExceptionKind["Rejected"] = "rejected";
9
+ ExceptionKind["Internal"] = "internal";
10
+ })(ExceptionKind || (ExceptionKind = {}));
@@ -1,15 +1,15 @@
1
1
  var _a;
2
+ import { ExceptionBrand } from '../../shared/index.js';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
2
4
  import { InfrastructureException } from './infrastructure.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
5
  export class UnknownEventException extends InfrastructureException {
6
6
  constructor(eventName) {
7
7
  super(`Unknown event "${eventName}": register it before reading it.`, [
8
- ExceptionCode.UnknownEvent,
8
+ InfrastructureExceptionCode.UnknownEvent,
9
9
  ]);
10
10
  }
11
11
  }
12
12
  _a = UnknownEventException;
13
13
  (() => {
14
- ExceptionBrand.brandClass(_a, ExceptionCode.UnknownEvent);
14
+ ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.UnknownEvent);
15
15
  })();
@@ -7,10 +7,15 @@ export type { EventFactory } from './event/event-registry.js';
7
7
  export type { ChannelHandler, ChannelSubscription, EventChannel } from './event/event-channel.js';
8
8
  export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel.js';
9
9
  export type { InMemoryEventChannelOptions } from './event/in-memory/in-memory-event-channel.js';
10
- export { HttpErrorMapper } from './http/http-error-mapper.js';
11
- export type { HttpError, HttpErrorBody, HttpErrorMapperOptions } from './http/http-error-mapper.js';
12
10
  export { ConsoleLogger } from './logging/console-logger.js';
13
11
  export type { ConsoleLoggerOptions } from './logging/console-logger.js';
14
12
  export { InMemoryLogger } from './logging/in-memory-logger.js';
15
13
  export type { LogEntry } from './logging/in-memory-logger.js';
16
14
  export { SilentLogger } from './logging/silent-logger.js';
15
+ export { InfrastructureException } from './exceptions/infrastructure.exception.js';
16
+ export { InternalErrorException } from './exceptions/internal-error.exception.js';
17
+ export { UnknownEventException } from './exceptions/unknown-event.exception.js';
18
+ export { EventDeliveryException } from './exceptions/event-delivery.exception.js';
19
+ export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code.js';
20
+ export { ExceptionClassifier } from './exceptions/kind/exception-classifier.js';
21
+ export { ExceptionKind } from './exceptions/kind/exception-kind.js';
@@ -3,7 +3,13 @@ export { FixedClock } from './clock/fixed-clock.js';
3
3
  export { DomainEventBus } from './event/domain-event-bus.js';
4
4
  export { EventRegistry } from './event/event-registry.js';
5
5
  export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel.js';
6
- export { HttpErrorMapper } from './http/http-error-mapper.js';
7
6
  export { ConsoleLogger } from './logging/console-logger.js';
8
7
  export { InMemoryLogger } from './logging/in-memory-logger.js';
9
8
  export { SilentLogger } from './logging/silent-logger.js';
9
+ export { InfrastructureException } from './exceptions/infrastructure.exception.js';
10
+ export { InternalErrorException } from './exceptions/internal-error.exception.js';
11
+ export { UnknownEventException } from './exceptions/unknown-event.exception.js';
12
+ export { EventDeliveryException } from './exceptions/event-delivery.exception.js';
13
+ export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code.js';
14
+ export { ExceptionClassifier } from './exceptions/kind/exception-classifier.js';
15
+ export { ExceptionKind } from './exceptions/kind/exception-kind.js';
@@ -1,4 +1,4 @@
1
- import { InternalErrorException } from '../../exceptions/index.js';
1
+ import { InternalErrorException } from '../exceptions/internal-error.exception.js';
2
2
  import { SystemClock } from '../clock/system-clock.js';
3
3
  import { LogSerializer } from './log-serializer.js';
4
4
  export class ConsoleLogger {
@@ -1,17 +1,19 @@
1
- import { ExceptionCode } from './exception-code';
2
1
  export interface ExceptionOptions {
3
2
  cause?: unknown;
4
3
  }
4
+ export type ExceptionCodeNames = Readonly<Record<string, string>>;
5
5
  export declare abstract class AbstractException extends Error {
6
+ private static readonly fallbackCode;
6
7
  readonly cause?: unknown;
7
8
  private readonly exceptionCodes;
8
- readonly code: ExceptionCode | string;
9
+ private readonly codeNames;
10
+ readonly code: string;
9
11
  private readonly createdAt;
10
12
  static [Symbol.hasInstance](candidate: unknown): boolean;
11
- constructor(message: string, exceptionCodes: (ExceptionCode | string)[], options?: ExceptionOptions);
12
- static readonly ExceptionCodeStrings: Record<ExceptionCode, string>;
13
+ constructor(message: string, exceptionCodes: string[], options?: ExceptionOptions, codeNames?: ExceptionCodeNames);
13
14
  get timestamp(): Date;
14
15
  get description(): string;
16
+ private labelOf;
15
17
  print(): string;
16
18
  toJSON(): {
17
19
  name: string;
@@ -1,19 +1,19 @@
1
1
  var _a;
2
- import { ExceptionCode } from './exception-code.js';
3
2
  import { ExceptionBrand } from './brand/exception-brand.js';
4
3
  export class AbstractException extends Error {
5
4
  static [Symbol.hasInstance](candidate) {
6
5
  return (Function.prototype[Symbol.hasInstance].call(this, candidate) ||
7
6
  ExceptionBrand.matches(this, candidate));
8
7
  }
9
- constructor(message, exceptionCodes, options = {}) {
8
+ constructor(message, exceptionCodes, options = {}, codeNames = {}) {
10
9
  super(message);
11
10
  this.name = this.constructor.name;
12
11
  this.exceptionCodes = exceptionCodes;
12
+ this.codeNames = codeNames;
13
13
  this.code =
14
14
  exceptionCodes.length > 0
15
15
  ? exceptionCodes[exceptionCodes.length - 1]
16
- : ExceptionCode.ErrorException;
16
+ : _a.fallbackCode;
17
17
  this.createdAt = Date.now();
18
18
  if ('cause' in options) {
19
19
  Object.defineProperty(this, 'cause', {
@@ -29,12 +29,11 @@ export class AbstractException extends Error {
29
29
  return new Date(this.createdAt);
30
30
  }
31
31
  get description() {
32
- return this.exceptionCodes
33
- .map((code) => {
34
- const codeString = _a.ExceptionCodeStrings[code] ?? this.name;
35
- return `${codeString} (${code})`;
36
- })
37
- .join(', ');
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();
38
37
  }
39
38
  print() {
40
39
  return `[${this.description}]: ${this.message}, ${this.timestamp.toISOString()}`;
@@ -50,13 +49,7 @@ export class AbstractException extends Error {
50
49
  }
51
50
  }
52
51
  _a = AbstractException;
52
+ AbstractException.fallbackCode = 'E000';
53
53
  (() => {
54
54
  ExceptionBrand.brandClass(_a, ExceptionBrand.anyCode);
55
55
  })();
56
- AbstractException.ExceptionCodeStrings = Object.keys(ExceptionCode)
57
- .filter((key) => isNaN(Number(key)))
58
- .reduce((acc, key) => {
59
- const value = ExceptionCode[key];
60
- acc[value] = key.replace(/([A-Z])/g, ' $1').trim();
61
- return acc;
62
- }, {});
@@ -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
+ }