@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,15 +0,0 @@
1
- import { ImmutableDate } from './immutable-date.js';
2
- export class Immutable {
3
- static freeze(value) {
4
- if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
5
- Object.freeze(value);
6
- for (const child of Object.values(value)) {
7
- Immutable.freeze(child);
8
- }
9
- }
10
- return value;
11
- }
12
- static date(date) {
13
- return new ImmutableDate(date);
14
- }
15
- }
@@ -1,66 +0,0 @@
1
- import { DomainException, InternalErrorException, ValidationException, } from '../../../exceptions/index.js';
2
- export class ValueObjects {
3
- static build(factories) {
4
- const built = {};
5
- const issues = [];
6
- for (const [field, factory] of Object.entries(factories)) {
7
- try {
8
- Object.defineProperty(built, field, {
9
- value: ValueObjects.synchronous(field, factory()),
10
- enumerable: true,
11
- writable: true,
12
- configurable: true,
13
- });
14
- }
15
- catch (error) {
16
- issues.push(...ValueObjects.issuesOf(field, error));
17
- }
18
- }
19
- ValueObjects.assertNoIssues(issues);
20
- return built;
21
- }
22
- static buildList(values, factory) {
23
- const built = [];
24
- const issues = [];
25
- values.forEach((value, index) => {
26
- try {
27
- built.push(ValueObjects.synchronous(String(index), factory(value, index)));
28
- }
29
- catch (error) {
30
- issues.push(...ValueObjects.issuesOf(String(index), error));
31
- }
32
- });
33
- ValueObjects.assertNoIssues(issues);
34
- return built;
35
- }
36
- static synchronous(field, result) {
37
- if (!ValueObjects.isThenable(result)) {
38
- return result;
39
- }
40
- result.then(undefined, () => undefined);
41
- throw new InternalErrorException(`ValueObjects: the factory of "${field}" returned a Promise; build value objects synchronously`);
42
- }
43
- static isThenable(result) {
44
- return ((typeof result === 'object' || typeof result === 'function') &&
45
- result !== null &&
46
- typeof result.then === 'function');
47
- }
48
- static issuesOf(field, error) {
49
- if (error instanceof ValidationException) {
50
- return error.errors.map((issue) => ({
51
- field: issue.field === null ? field : `${field}.${issue.field}`,
52
- code: issue.code,
53
- message: issue.message,
54
- }));
55
- }
56
- if (error instanceof DomainException) {
57
- return [{ field, code: error.code, message: error.message }];
58
- }
59
- throw error;
60
- }
61
- static assertNoIssues(issues) {
62
- if (issues.length > 0) {
63
- throw new ValidationException(issues);
64
- }
65
- }
66
- }
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { ApplicationException } from './application.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class AggregateNotFoundException extends ApplicationException {
6
- constructor(entity, id, options = {}) {
7
- super(`${entity} with ID ${id} not found.`, [ExceptionCode.AggregateNotFound], options);
8
- }
9
- }
10
- _a = AggregateNotFoundException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.AggregateNotFound);
13
- })();
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception.js';
2
- import type { ExceptionOptions } from '../abstract.exception.js';
3
- import { ExceptionCode } from '../exception-code.js';
4
- export declare class ApplicationException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { AbstractException } from '../abstract.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class ApplicationException extends AbstractException {
6
- constructor(message, exceptionCodes = [], options = {}) {
7
- super(message, [ExceptionCode.ApplicationException, ...exceptionCodes], options);
8
- }
9
- }
10
- _a = ApplicationException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.ApplicationException);
13
- })();
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { ApplicationException } from './application.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class NotAllowedException extends ApplicationException {
6
- constructor(message, options = {}) {
7
- super(message, [ExceptionCode.NotAllowed], options);
8
- }
9
- }
10
- _a = NotAllowedException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.NotAllowed);
13
- })();
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception.js';
2
- import type { ExceptionOptions } from '../abstract.exception.js';
3
- import { ExceptionCode } from '../exception-code.js';
4
- export declare class DomainException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { AbstractException } from '../abstract.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class DomainException extends AbstractException {
6
- constructor(message, exceptionCodes = [], options = {}) {
7
- super(message, [ExceptionCode.DomainException, ...exceptionCodes], options);
8
- }
9
- }
10
- _a = DomainException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.DomainException);
13
- })();
@@ -1,15 +0,0 @@
1
- export declare enum ExceptionCode {
2
- DomainException = "DOM000",
3
- ValidationFailed = "DOM001",
4
- TypeFailed = "DOM003",
5
- RequiredValue = "DOM004",
6
- ApplicationException = "APP000",
7
- ConcurrencyConflict = "APP001",
8
- AggregateNotFound = "APP002",
9
- NotAllowed = "APP003",
10
- InfrastructureException = "INF000",
11
- InternalError = "INF001",
12
- UnknownEvent = "INF002",
13
- EventDelivery = "INF003",
14
- ErrorException = "E000"
15
- }
@@ -1,16 +0,0 @@
1
- export var ExceptionCode;
2
- (function (ExceptionCode) {
3
- ExceptionCode["DomainException"] = "DOM000";
4
- ExceptionCode["ValidationFailed"] = "DOM001";
5
- ExceptionCode["TypeFailed"] = "DOM003";
6
- ExceptionCode["RequiredValue"] = "DOM004";
7
- ExceptionCode["ApplicationException"] = "APP000";
8
- ExceptionCode["ConcurrencyConflict"] = "APP001";
9
- ExceptionCode["AggregateNotFound"] = "APP002";
10
- ExceptionCode["NotAllowed"] = "APP003";
11
- ExceptionCode["InfrastructureException"] = "INF000";
12
- ExceptionCode["InternalError"] = "INF001";
13
- ExceptionCode["UnknownEvent"] = "INF002";
14
- ExceptionCode["EventDelivery"] = "INF003";
15
- ExceptionCode["ErrorException"] = "E000";
16
- })(ExceptionCode || (ExceptionCode = {}));
@@ -1,14 +0,0 @@
1
- export * from './abstract.exception.js';
2
- export * from './exception-code.js';
3
- export * from './application/application.exception.js';
4
- export * from './application/concurrency.exception.js';
5
- export * from './application/aggregate-not-found.exception.js';
6
- export * from './application/not-allowed.exception.js';
7
- export * from './infrastructure/infrastructure.exception.js';
8
- export * from './infrastructure/internal-error.exception.js';
9
- export * from './infrastructure/unknown-event.exception.js';
10
- export * from './infrastructure/event-delivery.exception.js';
11
- export * from './domain/validation.exception.js';
12
- export * from './domain/domain.exception.js';
13
- export * from './domain/required-value.exception.js';
14
- export * from './domain/type-primitive.exception.js';
@@ -1,14 +0,0 @@
1
- export * from './abstract.exception.js';
2
- export * from './exception-code.js';
3
- export * from './application/application.exception.js';
4
- export * from './application/concurrency.exception.js';
5
- export * from './application/aggregate-not-found.exception.js';
6
- export * from './application/not-allowed.exception.js';
7
- export * from './infrastructure/infrastructure.exception.js';
8
- export * from './infrastructure/internal-error.exception.js';
9
- export * from './infrastructure/unknown-event.exception.js';
10
- export * from './infrastructure/event-delivery.exception.js';
11
- export * from './domain/validation.exception.js';
12
- export * from './domain/domain.exception.js';
13
- export * from './domain/required-value.exception.js';
14
- export * from './domain/type-primitive.exception.js';
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception.js';
2
- import type { ExceptionOptions } from '../abstract.exception.js';
3
- import { ExceptionCode } from '../exception-code.js';
4
- export declare class InfrastructureException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { AbstractException } from '../abstract.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class InfrastructureException extends AbstractException {
6
- constructor(message, exceptionCodes = [], options = {}) {
7
- super(message, [ExceptionCode.InfrastructureException, ...exceptionCodes], options);
8
- }
9
- }
10
- _a = InfrastructureException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.InfrastructureException);
13
- })();
@@ -1,13 +0,0 @@
1
- var _a;
2
- import { InfrastructureException } from './infrastructure.exception.js';
3
- import { ExceptionBrand } from '../brand/exception-brand.js';
4
- import { ExceptionCode } from '../exception-code.js';
5
- export class InternalErrorException extends InfrastructureException {
6
- constructor(message, options = {}) {
7
- super(`Failed, internal error: ${message}`, [ExceptionCode.InternalError], options);
8
- }
9
- }
10
- _a = InternalErrorException;
11
- (() => {
12
- ExceptionBrand.brandClass(_a, ExceptionCode.InternalError);
13
- })();
@@ -1,23 +0,0 @@
1
- import type { ValidationIssue } from '../../exceptions/index.js';
2
- import type { Logger } from '../../application/index.js';
3
- export interface HttpErrorBody {
4
- code: string;
5
- message: string;
6
- errors?: readonly ValidationIssue[];
7
- }
8
- export interface HttpError {
9
- status: number;
10
- body: HttpErrorBody;
11
- }
12
- export interface HttpErrorMapperOptions {
13
- readonly statusByCode?: Readonly<Record<string, number>>;
14
- readonly logger?: Logger;
15
- }
16
- export declare class HttpErrorMapper {
17
- private readonly statusByCode;
18
- private readonly logger;
19
- constructor({ statusByCode, logger }?: HttpErrorMapperOptions);
20
- map(error: unknown): HttpError;
21
- private toHttpError;
22
- private static defaultStatus;
23
- }
@@ -1,59 +0,0 @@
1
- import { AbstractException, AggregateNotFoundException, ApplicationException, ConcurrencyException, DomainException, ExceptionCode, NotAllowedException, RequiredValueException, TypePrimitiveException, ValidationException, } from '../../exceptions/index.js';
2
- import { SilentLogger } from '../logging/silent-logger.js';
3
- const INTERNAL_MESSAGE = 'Internal server error';
4
- export class HttpErrorMapper {
5
- constructor({ statusByCode = {}, logger = new SilentLogger() } = {}) {
6
- this.statusByCode = statusByCode;
7
- this.logger = logger;
8
- }
9
- map(error) {
10
- const mapped = this.toHttpError(error);
11
- const { status, body } = mapped;
12
- if (status >= 500) {
13
- this.logger.error('http_request_failed', { status, code: body.code, error });
14
- }
15
- else {
16
- this.logger.debug('http_request_rejected', { status, code: body.code });
17
- }
18
- return mapped;
19
- }
20
- toHttpError(error) {
21
- if (!(error instanceof AbstractException)) {
22
- return {
23
- status: 500,
24
- body: { code: ExceptionCode.ErrorException, message: INTERNAL_MESSAGE },
25
- };
26
- }
27
- const status = Object.prototype.hasOwnProperty.call(this.statusByCode, error.code)
28
- ? this.statusByCode[error.code]
29
- : HttpErrorMapper.defaultStatus(error);
30
- if (status >= 500) {
31
- return { status, body: { code: error.code, message: INTERNAL_MESSAGE } };
32
- }
33
- if (error instanceof ValidationException) {
34
- return { status, body: { code: error.code, message: error.message, errors: error.errors } };
35
- }
36
- return { status, body: { code: error.code, message: error.message } };
37
- }
38
- static defaultStatus(error) {
39
- if (error instanceof AggregateNotFoundException) {
40
- return 404;
41
- }
42
- if (error instanceof NotAllowedException) {
43
- return 403;
44
- }
45
- if (error instanceof ConcurrencyException) {
46
- return 409;
47
- }
48
- if (error instanceof TypePrimitiveException || error instanceof RequiredValueException) {
49
- return 400;
50
- }
51
- if (error instanceof DomainException) {
52
- return 422;
53
- }
54
- if (error instanceof ApplicationException) {
55
- return 400;
56
- }
57
- return 500;
58
- }
59
- }