@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
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnumType = void 0;
4
4
  const abstract_type_1 = require("./abstract-type");
5
- const index_1 = require("../../exceptions/index");
5
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
6
6
  const NUMERIC_TEXT = /^-?\d+(?:\.\d+)?$/;
7
7
  class EnumType extends abstract_type_1.AbstractType {
8
8
  filter(value) {
9
9
  const options = this.options();
10
10
  const option = options.find((candidate) => EnumType.matches(candidate, value));
11
11
  if (option === undefined) {
12
- throw new index_1.TypePrimitiveException(`Expected one of [${options.join(', ')}]`, value, '');
12
+ throw new type_primitive_exception_1.TypePrimitiveException(`Expected one of [${options.join(', ')}]`, value, '');
13
13
  }
14
14
  return option;
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import { UuidType } from './uuid-type';
2
- declare const IdType_base: import("./required/required").RequiredType<typeof UuidType>;
2
+ declare const IdType_base: import("./required/required-type").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,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IdType = void 0;
4
- const required_1 = require("./required/required");
4
+ const required_type_1 = require("./required/required-type");
5
5
  const uuid_type_1 = require("./uuid-type");
6
- const index_1 = require("../../exceptions/index");
6
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
7
7
  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;
8
- class IdType extends (0, required_1.Required)(uuid_type_1.UuidType) {
8
+ class IdType extends (0, required_type_1.Required)(uuid_type_1.UuidType) {
9
9
  filter(value) {
10
10
  const id = super.filter(value);
11
11
  if (NIL_OR_MAX_UUID.test(id)) {
12
- throw new index_1.TypePrimitiveException('Id', value);
12
+ throw new type_primitive_exception_1.TypePrimitiveException('Id', value);
13
13
  }
14
14
  return id;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  export { AbstractType } from './abstract-type';
2
- export { Required } from './required/required';
3
- export type { RequiredType } from './required/required';
2
+ export { Required } from './required/required-type';
3
+ export type { RequiredType } from './required/required-type';
4
4
  export { ArrayType } from './array-type';
5
5
  export { BooleanType } from './boolean-type';
6
6
  export { CreatedAt, DateType, UpdatedAt } from './date-type';
@@ -11,7 +11,5 @@ export { NumberType } from './number-type';
11
11
  export { StringType } from './string-type';
12
12
  export { IdType } from './id-type';
13
13
  export { UuidType } from './uuid-type';
14
- export { Immutable } from './immutable/immutable';
15
- export { ValueObjects } from './value-objects/value-objects';
16
14
  export { Composite } from './composite/composite';
17
15
  export type { CompositeInput, CompositePrimitives, CompositeProps, CompositeSchema, CompositeType, CompositeValue, } from './composite/composite';
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Composite = exports.ValueObjects = exports.Immutable = exports.UuidType = exports.IdType = exports.StringType = exports.NumberType = exports.JsonType = exports.EnumType = exports.UpdatedAt = exports.DateType = exports.CreatedAt = exports.BooleanType = exports.ArrayType = exports.Required = exports.AbstractType = void 0;
3
+ exports.Composite = exports.UuidType = exports.IdType = exports.StringType = exports.NumberType = exports.JsonType = exports.EnumType = exports.UpdatedAt = exports.DateType = exports.CreatedAt = exports.BooleanType = exports.ArrayType = exports.Required = exports.AbstractType = void 0;
4
4
  var abstract_type_1 = require("./abstract-type");
5
5
  Object.defineProperty(exports, "AbstractType", { enumerable: true, get: function () { return abstract_type_1.AbstractType; } });
6
- var required_1 = require("./required/required");
7
- Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return required_1.Required; } });
6
+ var required_type_1 = require("./required/required-type");
7
+ Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return required_type_1.Required; } });
8
8
  var array_type_1 = require("./array-type");
9
9
  Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return array_type_1.ArrayType; } });
10
10
  var boolean_type_1 = require("./boolean-type");
@@ -25,9 +25,5 @@ var id_type_1 = require("./id-type");
25
25
  Object.defineProperty(exports, "IdType", { enumerable: true, get: function () { return id_type_1.IdType; } });
26
26
  var uuid_type_1 = require("./uuid-type");
27
27
  Object.defineProperty(exports, "UuidType", { enumerable: true, get: function () { return uuid_type_1.UuidType; } });
28
- var immutable_1 = require("./immutable/immutable");
29
- Object.defineProperty(exports, "Immutable", { enumerable: true, get: function () { return immutable_1.Immutable; } });
30
- var value_objects_1 = require("./value-objects/value-objects");
31
- Object.defineProperty(exports, "ValueObjects", { enumerable: true, get: function () { return value_objects_1.ValueObjects; } });
32
28
  var composite_1 = require("./composite/composite");
33
29
  Object.defineProperty(exports, "Composite", { enumerable: true, get: function () { return composite_1.Composite; } });
@@ -2,4 +2,8 @@ import { AbstractType } from './abstract-type';
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
  }
@@ -3,15 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonType = void 0;
4
4
  const validation_1 = require("@archi-code/validation");
5
5
  const abstract_type_1 = require("./abstract-type");
6
- const immutable_1 = require("./immutable/immutable");
7
- const index_1 = require("../../exceptions/index");
6
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
8
7
  class JsonType extends abstract_type_1.AbstractType {
9
8
  filter(value) {
10
9
  const converted = (0, validation_1.toJson)(value);
11
10
  if (!converted.ok) {
12
- throw new index_1.TypePrimitiveException('Json', value);
11
+ throw new type_primitive_exception_1.TypePrimitiveException('Json', value);
13
12
  }
14
- return immutable_1.Immutable.freeze(JSON.parse(JSON.stringify(converted.value)));
13
+ return JsonType.deepFreeze(JSON.parse(JSON.stringify(converted.value)));
14
+ }
15
+ hasSameValue(other) {
16
+ return JsonType.sameJson(this._value, other._value);
17
+ }
18
+ static sameJson(left, right) {
19
+ if (Array.isArray(left) || Array.isArray(right)) {
20
+ return (Array.isArray(left) &&
21
+ Array.isArray(right) &&
22
+ left.length === right.length &&
23
+ left.every((item, index) => JsonType.sameJson(item, right[index])));
24
+ }
25
+ if (JsonType.isObject(left) && JsonType.isObject(right)) {
26
+ const keys = Object.keys(left);
27
+ return (keys.length === Object.keys(right).length &&
28
+ keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
29
+ JsonType.sameJson(left[key], right[key])));
30
+ }
31
+ return left === right;
32
+ }
33
+ static deepFreeze(value) {
34
+ if (JsonType.isObject(value)) {
35
+ Object.freeze(value);
36
+ for (const child of Object.values(value)) {
37
+ JsonType.deepFreeze(child);
38
+ }
39
+ }
40
+ return value;
41
+ }
42
+ static isObject(value) {
43
+ return typeof value === 'object' && value !== null;
15
44
  }
16
45
  }
17
46
  exports.JsonType = JsonType;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumberType = void 0;
4
4
  const validation_1 = require("@archi-code/validation");
5
5
  const abstract_type_1 = require("./abstract-type");
6
- const index_1 = require("../../exceptions/index");
6
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
7
7
  class NumberType extends abstract_type_1.AbstractType {
8
8
  filter(value) {
9
9
  const converted = (0, validation_1.toFloat)(value);
10
10
  if (!converted.ok) {
11
- throw new index_1.TypePrimitiveException('Number', value);
11
+ throw new type_primitive_exception_1.TypePrimitiveException('Number', value);
12
12
  }
13
13
  return converted.value;
14
14
  }
@@ -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;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringType = void 0;
4
4
  const validation_1 = require("@archi-code/validation");
5
5
  const abstract_type_1 = require("./abstract-type");
6
- const index_1 = require("../../exceptions/index");
6
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
7
7
  class StringType extends abstract_type_1.AbstractType {
8
8
  filter(value) {
9
9
  const converted = (0, validation_1.toString)(value);
10
10
  if (!converted.ok) {
11
- throw new index_1.TypePrimitiveException('String', value);
11
+ throw new type_primitive_exception_1.TypePrimitiveException('String', value);
12
12
  }
13
13
  return converted.value;
14
14
  }
@@ -4,7 +4,7 @@ exports.UuidType = void 0;
4
4
  const uuid_1 = require("uuid");
5
5
  const validation_1 = require("@archi-code/validation");
6
6
  const abstract_type_1 = require("./abstract-type");
7
- const index_1 = require("../../exceptions/index");
7
+ const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
8
8
  const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
9
9
  class UuidType extends abstract_type_1.AbstractType {
10
10
  static random() {
@@ -19,7 +19,7 @@ class UuidType extends abstract_type_1.AbstractType {
19
19
  filter(value) {
20
20
  const converted = (0, validation_1.toString)(value);
21
21
  if (!converted.ok || !(0, validation_1.isUUID)(converted.value)) {
22
- throw new index_1.TypePrimitiveException('UUID', value);
22
+ throw new type_primitive_exception_1.TypePrimitiveException('UUID', value);
23
23
  }
24
24
  return converted.value.toLowerCase();
25
25
  }
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DomainEventBus = void 0;
4
- const index_1 = require("../../exceptions/index");
5
- const index_2 = require("../../application/index");
4
+ const index_1 = require("../../application/index");
5
+ const index_2 = require("../../domain/index");
6
+ const unknown_event_exception_1 = require("../exceptions/unknown-event.exception");
7
+ const index_3 = require("../../application/index");
6
8
  const silent_logger_1 = require("../logging/silent-logger");
7
9
  class DomainEventBus {
8
10
  constructor(channel, registry, logger = new silent_logger_1.SilentLogger()) {
@@ -11,20 +13,19 @@ class DomainEventBus {
11
13
  this.logger = logger;
12
14
  }
13
15
  async publish(events) {
14
- await this.channel.send(events.map((event) => event.toJSON()));
16
+ await this.channel.send(events.map((event) => ({ ...event })));
15
17
  this.logger.debug('domain_events_published', {
16
18
  events: events.map((event) => ({
17
- eventName: event.eventName(),
19
+ eventName: event.eventName,
18
20
  eventId: event.eventId,
19
- aggregateId: event.aggregateId,
20
21
  })),
21
22
  });
22
23
  }
23
24
  async subscribe(listener) {
24
- const subscription = index_2.ListensTo.subscriptionOf(listener);
25
+ const subscription = index_3.ListensTo.subscriptionOf(listener);
25
26
  const { eventName, consumer } = subscription;
26
27
  if (!this.registry.has(eventName)) {
27
- throw new index_1.UnknownEventException(eventName);
28
+ throw new unknown_event_exception_1.UnknownEventException(eventName);
28
29
  }
29
30
  const channelSubscription = await this.channel.receive(eventName, consumer, (serialized) => this.deliver(listener, subscription, serialized));
30
31
  this.logger.info('event_listener_subscribed', { eventName, consumer });
@@ -44,10 +45,9 @@ class DomainEventBus {
44
45
  eventName,
45
46
  consumer,
46
47
  eventId: serialized.eventId,
47
- aggregateId: serialized.aggregateId,
48
48
  error,
49
49
  };
50
- if (error instanceof index_1.DomainException || error instanceof index_1.ApplicationException) {
50
+ if (error instanceof index_2.DomainException || error instanceof index_1.ApplicationException) {
51
51
  this.logger.warn('event_listener_rejected', context);
52
52
  }
53
53
  else {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventRegistry = void 0;
4
- const index_1 = require("../../exceptions/index");
5
- const index_2 = require("../../domain/index");
4
+ const internal_error_exception_1 = require("../exceptions/internal-error.exception");
5
+ const unknown_event_exception_1 = require("../exceptions/unknown-event.exception");
6
6
  class EventRegistry {
7
7
  constructor() {
8
8
  this.factories = new Map();
@@ -10,7 +10,7 @@ class EventRegistry {
10
10
  register(event, factory) {
11
11
  const { eventName } = event;
12
12
  if (this.factories.has(eventName)) {
13
- throw new index_1.InternalErrorException(`event "${eventName}" is already registered`);
13
+ throw new internal_error_exception_1.InternalErrorException(`event "${eventName}" is already registered`);
14
14
  }
15
15
  this.factories.set(eventName, factory);
16
16
  return this;
@@ -20,23 +20,23 @@ class EventRegistry {
20
20
  }
21
21
  fromJSON(event) {
22
22
  if (typeof event !== 'object' || event === null) {
23
- throw new index_1.InternalErrorException('a serialized event must be a JSON object');
23
+ throw new internal_error_exception_1.InternalErrorException('a serialized event must be a JSON object');
24
24
  }
25
25
  if (typeof event.eventName !== 'string') {
26
- throw new index_1.InternalErrorException('a serialized event needs its eventName');
26
+ throw new internal_error_exception_1.InternalErrorException('a serialized event needs its eventName');
27
27
  }
28
28
  const factory = this.factories.get(event.eventName);
29
29
  if (factory === undefined) {
30
- throw new index_1.UnknownEventException(event.eventName);
30
+ throw new unknown_event_exception_1.UnknownEventException(event.eventName);
31
31
  }
32
32
  const rebuilt = factory(event);
33
33
  EventRegistry.assertSameIdentity(event, rebuilt);
34
- return index_2.Immutable.freeze(rebuilt);
34
+ return rebuilt;
35
35
  }
36
36
  static assertSameIdentity(serialized, rebuilt) {
37
37
  if (rebuilt.eventId !== String(serialized.eventId).toLowerCase() ||
38
- rebuilt.occurredOn.getTime() !== new Date(serialized.occurredOn).getTime()) {
39
- throw new index_1.InternalErrorException(`the factory of "${serialized.eventName}" must pass the serialized event as metadata, so it keeps its eventId and occurredOn`);
38
+ Date.parse(rebuilt.occurredOn) !== Date.parse(serialized.occurredOn)) {
39
+ throw new internal_error_exception_1.InternalErrorException(`the factory of "${serialized.eventName}" must pass the serialized event as metadata, so it keeps its eventId and occurredOn`);
40
40
  }
41
41
  }
42
42
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Emitter = void 0;
4
- const index_1 = require("../../../exceptions/index");
4
+ const event_delivery_exception_1 = require("../../exceptions/event-delivery.exception");
5
5
  class Emitter {
6
6
  constructor() {
7
7
  this.events = new Map();
@@ -33,7 +33,7 @@ class Emitter {
33
33
  }));
34
34
  const errors = results.flatMap((result) => result.status === 'rejected' ? [result.reason] : []);
35
35
  if (errors.length > 0) {
36
- throw new index_1.EventDeliveryException(eventName, errors, snapshot.length);
36
+ throw new event_delivery_exception_1.EventDeliveryException(eventName, errors, snapshot.length);
37
37
  }
38
38
  }
39
39
  async emitSerial(eventName, data) {
@@ -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,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryEventChannel = void 0;
4
- const index_1 = require("../../../domain/index");
5
- const index_2 = require("../../../exceptions/index");
4
+ const infrastructure_exception_1 = require("../../exceptions/infrastructure.exception");
6
5
  const emitter_1 = require("./emitter");
7
6
  class InMemoryEventChannel {
8
7
  constructor({ delivery = 'serial' } = {}) {
@@ -16,7 +15,7 @@ class InMemoryEventChannel {
16
15
  }
17
16
  async send(events) {
18
17
  for (const event of events) {
19
- const copy = InMemoryEventChannel.frozenCopy(event);
18
+ const copy = InMemoryEventChannel.copy(event);
20
19
  this.sentEvents.push(copy);
21
20
  if (this.delivery === 'parallel') {
22
21
  await this.emitter.emit(copy.eventName, copy);
@@ -29,10 +28,10 @@ class InMemoryEventChannel {
29
28
  async receive(eventName, consumer, handler) {
30
29
  const receiver = JSON.stringify([eventName, consumer]);
31
30
  if (this.receivers.has(receiver)) {
32
- throw new index_2.InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
31
+ throw new infrastructure_exception_1.InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
33
32
  }
34
33
  this.receivers.add(receiver);
35
- const off = this.emitter.on(eventName, (event) => handler(event));
34
+ const off = this.emitter.on(eventName, (event) => handler(InMemoryEventChannel.copy(event)));
36
35
  let open = true;
37
36
  return {
38
37
  close: async () => {
@@ -44,8 +43,8 @@ class InMemoryEventChannel {
44
43
  },
45
44
  };
46
45
  }
47
- static frozenCopy(event) {
48
- return index_1.Immutable.freeze(JSON.parse(JSON.stringify(event)));
46
+ static copy(event) {
47
+ return JSON.parse(JSON.stringify(event));
49
48
  }
50
49
  }
51
50
  exports.InMemoryEventChannel = InMemoryEventChannel;
@@ -2,13 +2,13 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.EventDeliveryException = void 0;
5
+ const index_1 = require("../../shared/index");
6
+ const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
5
7
  const infrastructure_exception_1 = require("./infrastructure.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
8
  class EventDeliveryException extends infrastructure_exception_1.InfrastructureException {
9
9
  constructor(eventName, errors, consumers) {
10
10
  super(`${errors.length} of ${consumers} consumers of "${eventName}" failed.`, [
11
- exception_code_1.ExceptionCode.EventDelivery,
11
+ infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery,
12
12
  ]);
13
13
  this.errors = Object.freeze([...errors]);
14
14
  }
@@ -16,5 +16,5 @@ class EventDeliveryException extends infrastructure_exception_1.InfrastructureEx
16
16
  exports.EventDeliveryException = EventDeliveryException;
17
17
  _a = EventDeliveryException;
18
18
  (() => {
19
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.EventDelivery);
19
+ index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery);
20
20
  })();
@@ -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,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InfrastructureExceptionCode = void 0;
4
+ var InfrastructureExceptionCode;
5
+ (function (InfrastructureExceptionCode) {
6
+ InfrastructureExceptionCode["InfrastructureException"] = "INF000";
7
+ InfrastructureExceptionCode["InternalError"] = "INF001";
8
+ InfrastructureExceptionCode["UnknownEvent"] = "INF002";
9
+ InfrastructureExceptionCode["EventDelivery"] = "INF003";
10
+ })(InfrastructureExceptionCode || (exports.InfrastructureExceptionCode = InfrastructureExceptionCode = {}));
@@ -0,0 +1,6 @@
1
+ import { AbstractException } from '../../shared/index';
2
+ import type { ExceptionOptions } from '../../shared/index';
3
+ import { InfrastructureExceptionCode } from './infrastructure-exception-code';
4
+ export declare class InfrastructureException extends AbstractException {
5
+ constructor(message: string, exceptionCodes?: (InfrastructureExceptionCode | string)[], options?: ExceptionOptions);
6
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.InfrastructureException = void 0;
5
+ const index_1 = require("../../shared/index");
6
+ const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
7
+ class InfrastructureException extends index_1.AbstractException {
8
+ constructor(message, exceptionCodes = [], options = {}) {
9
+ super(message, [infrastructure_exception_code_1.InfrastructureExceptionCode.InfrastructureException, ...exceptionCodes], options, infrastructure_exception_code_1.InfrastructureExceptionCode);
10
+ }
11
+ }
12
+ exports.InfrastructureException = InfrastructureException;
13
+ _a = InfrastructureException;
14
+ (() => {
15
+ index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.InfrastructureException);
16
+ })();
@@ -1,5 +1,5 @@
1
+ import type { ExceptionOptions } from '../../shared/index';
1
2
  import { InfrastructureException } from './infrastructure.exception';
2
- import type { ExceptionOptions } from '../abstract.exception';
3
3
  export declare class InternalErrorException extends InfrastructureException {
4
4
  constructor(message: string, options?: ExceptionOptions);
5
5
  }
@@ -2,16 +2,16 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.InternalErrorException = void 0;
5
+ const index_1 = require("../../shared/index");
6
+ const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
5
7
  const infrastructure_exception_1 = require("./infrastructure.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
8
  class InternalErrorException extends infrastructure_exception_1.InfrastructureException {
9
9
  constructor(message, options = {}) {
10
- super(`Failed, internal error: ${message}`, [exception_code_1.ExceptionCode.InternalError], options);
10
+ super(`Failed, internal error: ${message}`, [infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError], options);
11
11
  }
12
12
  }
13
13
  exports.InternalErrorException = InternalErrorException;
14
14
  _a = InternalErrorException;
15
15
  (() => {
16
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.InternalError);
16
+ index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError);
17
17
  })();
@@ -0,0 +1,4 @@
1
+ import { ExceptionKind } from './exception-kind';
2
+ export declare class ExceptionClassifier {
3
+ static classify(error: unknown): ExceptionKind;
4
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionClassifier = void 0;
4
+ const index_1 = require("../../../application/index");
5
+ const index_2 = require("../../../domain/index");
6
+ const exception_kind_1 = require("./exception-kind");
7
+ class ExceptionClassifier {
8
+ static classify(error) {
9
+ if (error instanceof index_1.AggregateNotFoundException) {
10
+ return exception_kind_1.ExceptionKind.NotFound;
11
+ }
12
+ if (error instanceof index_1.NotAllowedException) {
13
+ return exception_kind_1.ExceptionKind.NotAllowed;
14
+ }
15
+ if (error instanceof index_1.ConcurrencyException) {
16
+ return exception_kind_1.ExceptionKind.Conflict;
17
+ }
18
+ if (error instanceof index_1.UnexpectedErrorException ||
19
+ error instanceof index_2.InvalidEventDefinitionException) {
20
+ return exception_kind_1.ExceptionKind.Internal;
21
+ }
22
+ if (error instanceof index_2.TypePrimitiveException || error instanceof index_2.RequiredValueException) {
23
+ return exception_kind_1.ExceptionKind.Malformed;
24
+ }
25
+ if (error instanceof index_2.DomainException) {
26
+ return exception_kind_1.ExceptionKind.Invalid;
27
+ }
28
+ if (error instanceof index_1.ApplicationException) {
29
+ return exception_kind_1.ExceptionKind.Rejected;
30
+ }
31
+ return exception_kind_1.ExceptionKind.Internal;
32
+ }
33
+ }
34
+ exports.ExceptionClassifier = ExceptionClassifier;
@@ -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,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionKind = void 0;
4
+ var ExceptionKind;
5
+ (function (ExceptionKind) {
6
+ ExceptionKind["NotFound"] = "not_found";
7
+ ExceptionKind["NotAllowed"] = "not_allowed";
8
+ ExceptionKind["Conflict"] = "conflict";
9
+ ExceptionKind["Malformed"] = "malformed";
10
+ ExceptionKind["Invalid"] = "invalid";
11
+ ExceptionKind["Rejected"] = "rejected";
12
+ ExceptionKind["Internal"] = "internal";
13
+ })(ExceptionKind || (exports.ExceptionKind = ExceptionKind = {}));
@@ -2,18 +2,18 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.UnknownEventException = void 0;
5
+ const index_1 = require("../../shared/index");
6
+ const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
5
7
  const infrastructure_exception_1 = require("./infrastructure.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
8
  class UnknownEventException extends infrastructure_exception_1.InfrastructureException {
9
9
  constructor(eventName) {
10
10
  super(`Unknown event "${eventName}": register it before reading it.`, [
11
- exception_code_1.ExceptionCode.UnknownEvent,
11
+ infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent,
12
12
  ]);
13
13
  }
14
14
  }
15
15
  exports.UnknownEventException = UnknownEventException;
16
16
  _a = UnknownEventException;
17
17
  (() => {
18
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.UnknownEvent);
18
+ index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent);
19
19
  })();
@@ -7,10 +7,15 @@ export type { EventFactory } from './event/event-registry';
7
7
  export type { ChannelHandler, ChannelSubscription, EventChannel } from './event/event-channel';
8
8
  export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel';
9
9
  export type { InMemoryEventChannelOptions } from './event/in-memory/in-memory-event-channel';
10
- export { HttpErrorMapper } from './http/http-error-mapper';
11
- export type { HttpError, HttpErrorBody, HttpErrorMapperOptions } from './http/http-error-mapper';
12
10
  export { ConsoleLogger } from './logging/console-logger';
13
11
  export type { ConsoleLoggerOptions } from './logging/console-logger';
14
12
  export { InMemoryLogger } from './logging/in-memory-logger';
15
13
  export type { LogEntry } from './logging/in-memory-logger';
16
14
  export { SilentLogger } from './logging/silent-logger';
15
+ export { InfrastructureException } from './exceptions/infrastructure.exception';
16
+ export { InternalErrorException } from './exceptions/internal-error.exception';
17
+ export { UnknownEventException } from './exceptions/unknown-event.exception';
18
+ export { EventDeliveryException } from './exceptions/event-delivery.exception';
19
+ export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code';
20
+ export { ExceptionClassifier } from './exceptions/kind/exception-classifier';
21
+ export { ExceptionKind } from './exceptions/kind/exception-kind';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SilentLogger = exports.InMemoryLogger = exports.ConsoleLogger = exports.HttpErrorMapper = exports.InMemoryEventChannel = exports.EventRegistry = exports.DomainEventBus = exports.FixedClock = exports.SystemClock = void 0;
3
+ exports.ExceptionKind = exports.ExceptionClassifier = exports.InfrastructureExceptionCode = exports.EventDeliveryException = exports.UnknownEventException = exports.InternalErrorException = exports.InfrastructureException = exports.SilentLogger = exports.InMemoryLogger = exports.ConsoleLogger = exports.InMemoryEventChannel = exports.EventRegistry = exports.DomainEventBus = exports.FixedClock = exports.SystemClock = void 0;
4
4
  var system_clock_1 = require("./clock/system-clock");
5
5
  Object.defineProperty(exports, "SystemClock", { enumerable: true, get: function () { return system_clock_1.SystemClock; } });
6
6
  var fixed_clock_1 = require("./clock/fixed-clock");
@@ -11,11 +11,23 @@ var event_registry_1 = require("./event/event-registry");
11
11
  Object.defineProperty(exports, "EventRegistry", { enumerable: true, get: function () { return event_registry_1.EventRegistry; } });
12
12
  var in_memory_event_channel_1 = require("./event/in-memory/in-memory-event-channel");
13
13
  Object.defineProperty(exports, "InMemoryEventChannel", { enumerable: true, get: function () { return in_memory_event_channel_1.InMemoryEventChannel; } });
14
- var http_error_mapper_1 = require("./http/http-error-mapper");
15
- Object.defineProperty(exports, "HttpErrorMapper", { enumerable: true, get: function () { return http_error_mapper_1.HttpErrorMapper; } });
16
14
  var console_logger_1 = require("./logging/console-logger");
17
15
  Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return console_logger_1.ConsoleLogger; } });
18
16
  var in_memory_logger_1 = require("./logging/in-memory-logger");
19
17
  Object.defineProperty(exports, "InMemoryLogger", { enumerable: true, get: function () { return in_memory_logger_1.InMemoryLogger; } });
20
18
  var silent_logger_1 = require("./logging/silent-logger");
21
19
  Object.defineProperty(exports, "SilentLogger", { enumerable: true, get: function () { return silent_logger_1.SilentLogger; } });
20
+ var infrastructure_exception_1 = require("./exceptions/infrastructure.exception");
21
+ Object.defineProperty(exports, "InfrastructureException", { enumerable: true, get: function () { return infrastructure_exception_1.InfrastructureException; } });
22
+ var internal_error_exception_1 = require("./exceptions/internal-error.exception");
23
+ Object.defineProperty(exports, "InternalErrorException", { enumerable: true, get: function () { return internal_error_exception_1.InternalErrorException; } });
24
+ var unknown_event_exception_1 = require("./exceptions/unknown-event.exception");
25
+ Object.defineProperty(exports, "UnknownEventException", { enumerable: true, get: function () { return unknown_event_exception_1.UnknownEventException; } });
26
+ var event_delivery_exception_1 = require("./exceptions/event-delivery.exception");
27
+ Object.defineProperty(exports, "EventDeliveryException", { enumerable: true, get: function () { return event_delivery_exception_1.EventDeliveryException; } });
28
+ var infrastructure_exception_code_1 = require("./exceptions/infrastructure-exception-code");
29
+ Object.defineProperty(exports, "InfrastructureExceptionCode", { enumerable: true, get: function () { return infrastructure_exception_code_1.InfrastructureExceptionCode; } });
30
+ var exception_classifier_1 = require("./exceptions/kind/exception-classifier");
31
+ Object.defineProperty(exports, "ExceptionClassifier", { enumerable: true, get: function () { return exception_classifier_1.ExceptionClassifier; } });
32
+ var exception_kind_1 = require("./exceptions/kind/exception-kind");
33
+ Object.defineProperty(exports, "ExceptionKind", { enumerable: true, get: function () { return exception_kind_1.ExceptionKind; } });