@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
@@ -0,0 +1,7 @@
1
+ export class IssueCollectionError extends Error {
2
+ constructor(issues) {
3
+ super(`${issues.length} issues collected`);
4
+ this.name = 'IssueCollectionError';
5
+ this.issues = Object.freeze([...issues]);
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { CollectedIssue } from './issue-collection-error.js';
2
+ export type IssueReader = (error: unknown) => readonly CollectedIssue[] | null;
3
+ export declare class IssueCollector {
4
+ static collectFields(builds: Readonly<Record<string, () => unknown>>, readIssues: IssueReader): Record<string, unknown>;
5
+ static collectItems<Item, Built>(items: readonly Item[], build: (item: Item, index: number) => Built, readIssues: IssueReader): Built[];
6
+ private static collect;
7
+ private static issuesAt;
8
+ }
@@ -0,0 +1,37 @@
1
+ import { IssueCollectionError } from './issue-collection-error.js';
2
+ export class IssueCollector {
3
+ static collectFields(builds, readIssues) {
4
+ return Object.fromEntries(IssueCollector.collect(Object.entries(builds), readIssues));
5
+ }
6
+ static collectItems(items, build, readIssues) {
7
+ const builds = items.map((item, index) => [String(index), () => build(item, index)]);
8
+ return IssueCollector.collect(builds, readIssues).map(([, built]) => built);
9
+ }
10
+ static collect(builds, readIssues) {
11
+ const built = [];
12
+ const issues = [];
13
+ for (const [path, build] of builds) {
14
+ try {
15
+ built.push([path, build()]);
16
+ }
17
+ catch (error) {
18
+ issues.push(...IssueCollector.issuesAt(path, error, readIssues));
19
+ }
20
+ }
21
+ if (issues.length > 0) {
22
+ throw new IssueCollectionError(issues);
23
+ }
24
+ return built;
25
+ }
26
+ static issuesAt(path, error, readIssues) {
27
+ const issues = readIssues(error);
28
+ if (issues === null) {
29
+ throw error;
30
+ }
31
+ return issues.map((issue) => ({
32
+ field: issue.field === null ? path : `${path}.${issue.field}`,
33
+ code: issue.code,
34
+ message: issue.message,
35
+ }));
36
+ }
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archi-code/ddd",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.2",
4
4
  "keywords": [
5
5
  "DDD",
6
6
  "domain-driven design",
@@ -11,7 +11,8 @@
11
11
  "domain events",
12
12
  "use case",
13
13
  "repository",
14
- "node"
14
+ "node",
15
+ "browser"
15
16
  ],
16
17
  "author": "Jose Guillermo",
17
18
  "license": "MIT",
@@ -26,16 +27,6 @@
26
27
  "access": "public"
27
28
  },
28
29
  "exports": {
29
- "./exceptions": {
30
- "import": {
31
- "types": "./dist/esm/exceptions/index.d.ts",
32
- "default": "./dist/esm/exceptions/index.js"
33
- },
34
- "require": {
35
- "types": "./dist/cjs/exceptions/index.d.ts",
36
- "default": "./dist/cjs/exceptions/index.js"
37
- }
38
- },
39
30
  "./domain": {
40
31
  "import": {
41
32
  "types": "./dist/esm/domain/index.d.ts",
@@ -70,9 +61,6 @@
70
61
  },
71
62
  "typesVersions": {
72
63
  "*": {
73
- "exceptions": [
74
- "./dist/cjs/exceptions/index.d.ts"
75
- ],
76
64
  "domain": [
77
65
  "./dist/cjs/domain/index.d.ts"
78
66
  ],
@@ -89,6 +77,7 @@
89
77
  "SKILL.md",
90
78
  "ddd-skills/"
91
79
  ],
80
+ "sideEffects": false,
92
81
  "scripts": {
93
82
  "prebuild": "rm -rf dist || true",
94
83
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -97,12 +86,12 @@
97
86
  "test": "vitest run",
98
87
  "test:coverage": "vitest run --coverage",
99
88
  "check:types": "tsc -p tsconfig.json --noEmit --incremental false",
100
- "check:dist": "node ../../scripts/check-dist.js && attw --pack .",
89
+ "check:dist": "node ../../scripts/check-dist.js && attw --pack . && node ../../scripts/check-browser.js",
101
90
  "check:all": "npm run check:types && npm run test:coverage && npm run build && npm run check:dist"
102
91
  },
103
92
  "dependencies": {
104
- "@archi-code/validation": "3.0.0-alpha.5",
93
+ "@archi-code/validation": "3.0.0-alpha.6",
105
94
  "uuid": "^11.1.1"
106
95
  },
107
- "releaseCommit": "bc311704e70020684524c1243de19329cb5c4511"
96
+ "releaseCommit": "90204648d023639e296f0946e2c715b8a32a47ef"
108
97
  }
@@ -1,7 +0,0 @@
1
- export declare class ValueEquality {
2
- static equals(left: unknown, right: unknown): boolean;
3
- private static sameInstant;
4
- private static sameItems;
5
- private static sameEntries;
6
- private static isRecord;
7
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValueEquality = void 0;
4
- class ValueEquality {
5
- static equals(left, right) {
6
- if (left === right || (Number.isNaN(left) && Number.isNaN(right))) {
7
- return true;
8
- }
9
- if (left instanceof Date || right instanceof Date) {
10
- return ValueEquality.sameInstant(left, right);
11
- }
12
- if (Array.isArray(left) || Array.isArray(right)) {
13
- return ValueEquality.sameItems(left, right);
14
- }
15
- if (ValueEquality.isRecord(left) && ValueEquality.isRecord(right)) {
16
- return ValueEquality.sameEntries(left, right);
17
- }
18
- return false;
19
- }
20
- static sameInstant(left, right) {
21
- return (left instanceof Date &&
22
- right instanceof Date &&
23
- ValueEquality.equals(left.getTime(), right.getTime()));
24
- }
25
- static sameItems(left, right) {
26
- return (Array.isArray(left) &&
27
- Array.isArray(right) &&
28
- left.length === right.length &&
29
- left.every((item, index) => ValueEquality.equals(item, right[index])));
30
- }
31
- static sameEntries(left, right) {
32
- const keys = Object.keys(left);
33
- return (keys.length === Object.keys(right).length &&
34
- keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
35
- ValueEquality.equals(left[key], right[key])));
36
- }
37
- static isRecord(value) {
38
- return typeof value === 'object' && value !== null;
39
- }
40
- }
41
- exports.ValueEquality = ValueEquality;
@@ -1,4 +0,0 @@
1
- export declare class ImmutableDate extends Date {
2
- private static readonly setters;
3
- constructor(date: Date);
4
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImmutableDate = void 0;
4
- class ImmutableDate extends Date {
5
- constructor(date) {
6
- super(date.getTime());
7
- Object.freeze(this);
8
- }
9
- }
10
- exports.ImmutableDate = ImmutableDate;
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
- })();
@@ -1,4 +0,0 @@
1
- export declare class Immutable {
2
- static freeze<T>(value: T): T;
3
- static date(date: Date): Date;
4
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Immutable = void 0;
4
- const immutable_date_1 = require("./immutable-date");
5
- class Immutable {
6
- static freeze(value) {
7
- if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
8
- Object.freeze(value);
9
- for (const child of Object.values(value)) {
10
- Immutable.freeze(child);
11
- }
12
- }
13
- return value;
14
- }
15
- static date(date) {
16
- return new immutable_date_1.ImmutableDate(date);
17
- }
18
- }
19
- exports.Immutable = Immutable;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValueObjects = void 0;
4
- const index_1 = require("../../../exceptions/index");
5
- class ValueObjects {
6
- static build(factories) {
7
- const built = {};
8
- const issues = [];
9
- for (const [field, factory] of Object.entries(factories)) {
10
- try {
11
- Object.defineProperty(built, field, {
12
- value: ValueObjects.synchronous(field, factory()),
13
- enumerable: true,
14
- writable: true,
15
- configurable: true,
16
- });
17
- }
18
- catch (error) {
19
- issues.push(...ValueObjects.issuesOf(field, error));
20
- }
21
- }
22
- ValueObjects.assertNoIssues(issues);
23
- return built;
24
- }
25
- static buildList(values, factory) {
26
- const built = [];
27
- const issues = [];
28
- values.forEach((value, index) => {
29
- try {
30
- built.push(ValueObjects.synchronous(String(index), factory(value, index)));
31
- }
32
- catch (error) {
33
- issues.push(...ValueObjects.issuesOf(String(index), error));
34
- }
35
- });
36
- ValueObjects.assertNoIssues(issues);
37
- return built;
38
- }
39
- static synchronous(field, result) {
40
- if (!ValueObjects.isThenable(result)) {
41
- return result;
42
- }
43
- result.then(undefined, () => undefined);
44
- throw new index_1.InternalErrorException(`ValueObjects: the factory of "${field}" returned a Promise; build value objects synchronously`);
45
- }
46
- static isThenable(result) {
47
- return ((typeof result === 'object' || typeof result === 'function') &&
48
- result !== null &&
49
- typeof result.then === 'function');
50
- }
51
- static issuesOf(field, error) {
52
- if (error instanceof index_1.ValidationException) {
53
- return error.errors.map((issue) => ({
54
- field: issue.field === null ? field : `${field}.${issue.field}`,
55
- code: issue.code,
56
- message: issue.message,
57
- }));
58
- }
59
- if (error instanceof index_1.DomainException) {
60
- return [{ field, code: error.code, message: error.message }];
61
- }
62
- throw error;
63
- }
64
- static assertNoIssues(issues) {
65
- if (issues.length > 0) {
66
- throw new index_1.ValidationException(issues);
67
- }
68
- }
69
- }
70
- exports.ValueObjects = ValueObjects;
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception';
2
- import type { ExceptionOptions } from '../abstract.exception';
3
- import { ExceptionCode } from '../exception-code';
4
- export declare class ApplicationException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ApplicationException = void 0;
5
- const abstract_exception_1 = require("../abstract.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
- class ApplicationException extends abstract_exception_1.AbstractException {
9
- constructor(message, exceptionCodes = [], options = {}) {
10
- super(message, [exception_code_1.ExceptionCode.ApplicationException, ...exceptionCodes], options);
11
- }
12
- }
13
- exports.ApplicationException = ApplicationException;
14
- _a = ApplicationException;
15
- (() => {
16
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.ApplicationException);
17
- })();
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception';
2
- import type { ExceptionOptions } from '../abstract.exception';
3
- import { ExceptionCode } from '../exception-code';
4
- export declare class DomainException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DomainException = void 0;
5
- const abstract_exception_1 = require("../abstract.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
- class DomainException extends abstract_exception_1.AbstractException {
9
- constructor(message, exceptionCodes = [], options = {}) {
10
- super(message, [exception_code_1.ExceptionCode.DomainException, ...exceptionCodes], options);
11
- }
12
- }
13
- exports.DomainException = DomainException;
14
- _a = DomainException;
15
- (() => {
16
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.DomainException);
17
- })();
@@ -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,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExceptionCode = void 0;
4
- var ExceptionCode;
5
- (function (ExceptionCode) {
6
- ExceptionCode["DomainException"] = "DOM000";
7
- ExceptionCode["ValidationFailed"] = "DOM001";
8
- ExceptionCode["TypeFailed"] = "DOM003";
9
- ExceptionCode["RequiredValue"] = "DOM004";
10
- ExceptionCode["ApplicationException"] = "APP000";
11
- ExceptionCode["ConcurrencyConflict"] = "APP001";
12
- ExceptionCode["AggregateNotFound"] = "APP002";
13
- ExceptionCode["NotAllowed"] = "APP003";
14
- ExceptionCode["InfrastructureException"] = "INF000";
15
- ExceptionCode["InternalError"] = "INF001";
16
- ExceptionCode["UnknownEvent"] = "INF002";
17
- ExceptionCode["EventDelivery"] = "INF003";
18
- ExceptionCode["ErrorException"] = "E000";
19
- })(ExceptionCode || (exports.ExceptionCode = ExceptionCode = {}));
@@ -1,14 +0,0 @@
1
- export * from './abstract.exception';
2
- export * from './exception-code';
3
- export * from './application/application.exception';
4
- export * from './application/concurrency.exception';
5
- export * from './application/aggregate-not-found.exception';
6
- export * from './application/not-allowed.exception';
7
- export * from './infrastructure/infrastructure.exception';
8
- export * from './infrastructure/internal-error.exception';
9
- export * from './infrastructure/unknown-event.exception';
10
- export * from './infrastructure/event-delivery.exception';
11
- export * from './domain/validation.exception';
12
- export * from './domain/domain.exception';
13
- export * from './domain/required-value.exception';
14
- export * from './domain/type-primitive.exception';
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./abstract.exception"), exports);
18
- __exportStar(require("./exception-code"), exports);
19
- __exportStar(require("./application/application.exception"), exports);
20
- __exportStar(require("./application/concurrency.exception"), exports);
21
- __exportStar(require("./application/aggregate-not-found.exception"), exports);
22
- __exportStar(require("./application/not-allowed.exception"), exports);
23
- __exportStar(require("./infrastructure/infrastructure.exception"), exports);
24
- __exportStar(require("./infrastructure/internal-error.exception"), exports);
25
- __exportStar(require("./infrastructure/unknown-event.exception"), exports);
26
- __exportStar(require("./infrastructure/event-delivery.exception"), exports);
27
- __exportStar(require("./domain/validation.exception"), exports);
28
- __exportStar(require("./domain/domain.exception"), exports);
29
- __exportStar(require("./domain/required-value.exception"), exports);
30
- __exportStar(require("./domain/type-primitive.exception"), exports);
@@ -1,6 +0,0 @@
1
- import { AbstractException } from '../abstract.exception';
2
- import type { ExceptionOptions } from '../abstract.exception';
3
- import { ExceptionCode } from '../exception-code';
4
- export declare class InfrastructureException extends AbstractException {
5
- constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
6
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InfrastructureException = void 0;
5
- const abstract_exception_1 = require("../abstract.exception");
6
- const exception_brand_1 = require("../brand/exception-brand");
7
- const exception_code_1 = require("../exception-code");
8
- class InfrastructureException extends abstract_exception_1.AbstractException {
9
- constructor(message, exceptionCodes = [], options = {}) {
10
- super(message, [exception_code_1.ExceptionCode.InfrastructureException, ...exceptionCodes], options);
11
- }
12
- }
13
- exports.InfrastructureException = InfrastructureException;
14
- _a = InfrastructureException;
15
- (() => {
16
- exception_brand_1.ExceptionBrand.brandClass(_a, exception_code_1.ExceptionCode.InfrastructureException);
17
- })();
@@ -1,23 +0,0 @@
1
- import type { ValidationIssue } from '../../exceptions';
2
- import type { Logger } from '../../application/index';
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,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpErrorMapper = void 0;
4
- const exceptions_1 = require("../../exceptions");
5
- const silent_logger_1 = require("../logging/silent-logger");
6
- const INTERNAL_MESSAGE = 'Internal server error';
7
- class HttpErrorMapper {
8
- constructor({ statusByCode = {}, logger = new silent_logger_1.SilentLogger() } = {}) {
9
- this.statusByCode = statusByCode;
10
- this.logger = logger;
11
- }
12
- map(error) {
13
- const mapped = this.toHttpError(error);
14
- const { status, body } = mapped;
15
- if (status >= 500) {
16
- this.logger.error('http_request_failed', { status, code: body.code, error });
17
- }
18
- else {
19
- this.logger.debug('http_request_rejected', { status, code: body.code });
20
- }
21
- return mapped;
22
- }
23
- toHttpError(error) {
24
- if (!(error instanceof exceptions_1.AbstractException)) {
25
- return {
26
- status: 500,
27
- body: { code: exceptions_1.ExceptionCode.ErrorException, message: INTERNAL_MESSAGE },
28
- };
29
- }
30
- const status = Object.prototype.hasOwnProperty.call(this.statusByCode, error.code)
31
- ? this.statusByCode[error.code]
32
- : HttpErrorMapper.defaultStatus(error);
33
- if (status >= 500) {
34
- return { status, body: { code: error.code, message: INTERNAL_MESSAGE } };
35
- }
36
- if (error instanceof exceptions_1.ValidationException) {
37
- return { status, body: { code: error.code, message: error.message, errors: error.errors } };
38
- }
39
- return { status, body: { code: error.code, message: error.message } };
40
- }
41
- static defaultStatus(error) {
42
- if (error instanceof exceptions_1.AggregateNotFoundException) {
43
- return 404;
44
- }
45
- if (error instanceof exceptions_1.NotAllowedException) {
46
- return 403;
47
- }
48
- if (error instanceof exceptions_1.ConcurrencyException) {
49
- return 409;
50
- }
51
- if (error instanceof exceptions_1.TypePrimitiveException || error instanceof exceptions_1.RequiredValueException) {
52
- return 400;
53
- }
54
- if (error instanceof exceptions_1.DomainException) {
55
- return 422;
56
- }
57
- if (error instanceof exceptions_1.ApplicationException) {
58
- return 400;
59
- }
60
- return 500;
61
- }
62
- }
63
- exports.HttpErrorMapper = HttpErrorMapper;
@@ -1,7 +0,0 @@
1
- export declare class ValueEquality {
2
- static equals(left: unknown, right: unknown): boolean;
3
- private static sameInstant;
4
- private static sameItems;
5
- private static sameEntries;
6
- private static isRecord;
7
- }
@@ -1,37 +0,0 @@
1
- export class ValueEquality {
2
- static equals(left, right) {
3
- if (left === right || (Number.isNaN(left) && Number.isNaN(right))) {
4
- return true;
5
- }
6
- if (left instanceof Date || right instanceof Date) {
7
- return ValueEquality.sameInstant(left, right);
8
- }
9
- if (Array.isArray(left) || Array.isArray(right)) {
10
- return ValueEquality.sameItems(left, right);
11
- }
12
- if (ValueEquality.isRecord(left) && ValueEquality.isRecord(right)) {
13
- return ValueEquality.sameEntries(left, right);
14
- }
15
- return false;
16
- }
17
- static sameInstant(left, right) {
18
- return (left instanceof Date &&
19
- right instanceof Date &&
20
- ValueEquality.equals(left.getTime(), right.getTime()));
21
- }
22
- static sameItems(left, right) {
23
- return (Array.isArray(left) &&
24
- Array.isArray(right) &&
25
- left.length === right.length &&
26
- left.every((item, index) => ValueEquality.equals(item, right[index])));
27
- }
28
- static sameEntries(left, right) {
29
- const keys = Object.keys(left);
30
- return (keys.length === Object.keys(right).length &&
31
- keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
32
- ValueEquality.equals(left[key], right[key])));
33
- }
34
- static isRecord(value) {
35
- return typeof value === 'object' && value !== null;
36
- }
37
- }
@@ -1,4 +0,0 @@
1
- export declare class ImmutableDate extends Date {
2
- private static readonly setters;
3
- constructor(date: Date);
4
- }
@@ -1,33 +0,0 @@
1
- export class ImmutableDate extends Date {
2
- constructor(date) {
3
- super(date.getTime());
4
- Object.freeze(this);
5
- }
6
- }
7
- ImmutableDate.setters = [
8
- 'setDate',
9
- 'setFullYear',
10
- 'setHours',
11
- 'setMilliseconds',
12
- 'setMinutes',
13
- 'setMonth',
14
- 'setSeconds',
15
- 'setTime',
16
- 'setUTCDate',
17
- 'setUTCFullYear',
18
- 'setUTCHours',
19
- 'setUTCMilliseconds',
20
- 'setUTCMinutes',
21
- 'setUTCMonth',
22
- 'setUTCSeconds',
23
- 'setYear',
24
- ];
25
- (() => {
26
- for (const setter of ImmutableDate.setters) {
27
- Object.defineProperty(ImmutableDate.prototype, setter, {
28
- value() {
29
- throw new TypeError(`Cannot call ${setter}: the date is immutable`);
30
- },
31
- });
32
- }
33
- })();
@@ -1,4 +0,0 @@
1
- export declare class Immutable {
2
- static freeze<T>(value: T): T;
3
- static date(date: Date): Date;
4
- }