@archi-code/ddd 0.0.0-stage → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +46 -0
- package/README.md +2795 -2
- package/SKILL.md +106 -0
- package/ddd-skills/archi-code-ddd/imports.md +94 -0
- package/ddd-skills/archi-code-ddd/layers.md +314 -0
- package/ddd-skills/archi-code-ddd/patterns.md +683 -0
- package/ddd-skills/archi-code-ddd/what-not-to-do.md +196 -0
- package/ddd-skills/archi-code-ddd/where-each-class-goes.md +64 -0
- package/ddd-skills/ddd-agregados/GUIA.md +114 -0
- package/ddd-skills/ddd-agregados/references/consistencia-eventual.md +158 -0
- package/ddd-skills/ddd-agregados/references/ejemplo-ecommerce.md +52 -0
- package/ddd-skills/ddd-agregados/references/fabricas.md +193 -0
- package/ddd-skills/ddd-agregados/references/implementacion-ts.md +706 -0
- package/ddd-skills/ddd-arquitectura/GUIA.md +80 -0
- package/ddd-skills/ddd-arquitectura/assets/dependency-cruiser.cjs +99 -0
- package/ddd-skills/ddd-arquitectura/references/estilos-adicionales.md +51 -0
- package/ddd-skills/ddd-arquitectura/references/estructura-hexagonal-ts.md +406 -0
- package/ddd-skills/ddd-arquitectura/references/modulos.md +48 -0
- package/ddd-skills/ddd-auditoria-refactorizacion/GUIA.md +85 -0
- package/ddd-skills/ddd-auditoria-refactorizacion/references/ejemplo-auditoria.md +314 -0
- package/ddd-skills/ddd-auditoria-refactorizacion/references/lista-comprobacion.md +54 -0
- package/ddd-skills/ddd-auditoria-refactorizacion/references/plan-migracion.md +73 -0
- package/ddd-skills/ddd-auditoria-refactorizacion/scripts/scan_ddd_smells.py +264 -0
- package/ddd-skills/ddd-context-mapping/GUIA.md +83 -0
- package/ddd-skills/ddd-context-mapping/references/anticorrupcion-ts.md +419 -0
- package/ddd-skills/ddd-context-mapping/references/estilos-integracion.md +152 -0
- package/ddd-skills/ddd-event-sourcing-cqrs/GUIA.md +92 -0
- package/ddd-skills/ddd-event-sourcing-cqrs/references/event-sourcing-ts.md +476 -0
- package/ddd-skills/ddd-event-sourcing-cqrs/references/proyecciones-cqrs-ts.md +285 -0
- package/ddd-skills/ddd-eventos-dominio/GUIA.md +106 -0
- package/ddd-skills/ddd-eventos-dominio/references/diseno-eventos.md +130 -0
- package/ddd-skills/ddd-eventos-dominio/references/ejemplo-ecommerce.md +240 -0
- package/ddd-skills/ddd-eventos-dominio/references/publicacion-ts.md +529 -0
- package/ddd-skills/ddd-orquestador/GUIA.md +40 -0
- package/ddd-skills/ddd-orquestador/references/chuleta-reglas.md +35 -0
- package/ddd-skills/ddd-repositorios-persistencia/GUIA.md +121 -0
- package/ddd-skills/ddd-repositorios-persistencia/references/implementacion-ts.md +314 -0
- package/ddd-skills/ddd-repositorios-persistencia/references/tests-repositorios.md +191 -0
- package/ddd-skills/ddd-repositorios-persistencia/references/transacciones-ts.md +301 -0
- package/ddd-skills/ddd-servicios-capa-aplicacion/GUIA.md +99 -0
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/capa-aplicacion-ts.md +264 -0
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/ejemplo-ecommerce.md +321 -0
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/servicios-dominio-ts.md +190 -0
- package/ddd-skills/ddd-value-objects-entidades/GUIA.md +118 -0
- package/ddd-skills/ddd-value-objects-entidades/references/ejemplo-ecommerce.md +87 -0
- package/ddd-skills/ddd-value-objects-entidades/references/entidades-ts.md +218 -0
- package/ddd-skills/ddd-value-objects-entidades/references/persistencia-valores.md +88 -0
- package/ddd-skills/ddd-value-objects-entidades/references/specification-y-diseno-flexible.md +119 -0
- package/ddd-skills/ddd-value-objects-entidades/references/validacion.md +96 -0
- package/ddd-skills/ddd-value-objects-entidades/references/value-objects-ts.md +376 -0
- package/dist/cjs/application/event/event-bus.d.ts +4 -0
- package/dist/cjs/application/event/event-bus.js +2 -0
- package/dist/cjs/application/event/event-listener.d.ts +4 -0
- package/dist/cjs/application/event/event-listener.js +6 -0
- package/dist/cjs/application/event/listens-to.d.ts +15 -0
- package/dist/cjs/application/event/listens-to.js +28 -0
- package/dist/cjs/application/exceptions/aggregate-not-found.exception.d.ts +5 -0
- package/dist/cjs/application/exceptions/aggregate-not-found.exception.js +17 -0
- package/dist/cjs/application/exceptions/application-exception-code.d.ts +7 -0
- package/dist/cjs/application/exceptions/application-exception-code.js +11 -0
- package/dist/cjs/application/exceptions/application.exception.d.ts +6 -0
- package/dist/cjs/application/exceptions/application.exception.js +16 -0
- package/dist/cjs/application/exceptions/concurrency.exception.d.ts +5 -0
- package/dist/cjs/application/exceptions/concurrency.exception.js +17 -0
- package/dist/cjs/application/exceptions/not-allowed.exception.d.ts +5 -0
- package/dist/cjs/application/exceptions/not-allowed.exception.js +17 -0
- package/dist/cjs/application/exceptions/unexpected-error.exception.d.ts +5 -0
- package/dist/cjs/application/exceptions/unexpected-error.exception.js +17 -0
- package/dist/cjs/application/index.d.ts +14 -0
- package/dist/cjs/application/index.js +23 -0
- package/dist/cjs/application/ports/clock.d.ts +3 -0
- package/dist/cjs/application/ports/clock.js +2 -0
- package/dist/cjs/application/ports/logger.d.ts +8 -0
- package/dist/cjs/application/ports/logger.js +2 -0
- package/dist/cjs/application/use-case/use-case.d.ts +6 -0
- package/dist/cjs/application/use-case/use-case.js +25 -0
- package/dist/cjs/application/value-object-builder/value-object-builder.d.ts +16 -0
- package/dist/cjs/application/value-object-builder/value-object-builder.js +51 -0
- package/dist/cjs/domain/aggregate/aggregate-root.d.ts +9 -0
- package/dist/cjs/domain/aggregate/aggregate-root.js +17 -0
- package/dist/cjs/domain/entity/entity.d.ts +9 -0
- package/dist/cjs/domain/entity/entity.js +19 -0
- package/dist/cjs/domain/event/event-base.d.ts +23 -0
- package/dist/cjs/domain/event/event-base.js +21 -0
- package/dist/cjs/domain/exceptions/domain-exception-code.d.ts +7 -0
- package/dist/cjs/domain/exceptions/domain-exception-code.js +11 -0
- package/dist/cjs/domain/exceptions/domain.exception.d.ts +6 -0
- package/dist/cjs/domain/exceptions/domain.exception.js +16 -0
- package/dist/cjs/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
- package/dist/cjs/domain/exceptions/invalid-event-definition.exception.js +19 -0
- package/dist/cjs/domain/exceptions/required-value.exception.d.ts +4 -0
- package/dist/cjs/domain/exceptions/required-value.exception.js +20 -0
- package/dist/cjs/domain/exceptions/type-primitive.exception.d.ts +4 -0
- package/dist/cjs/domain/exceptions/type-primitive.exception.js +20 -0
- package/dist/cjs/domain/exceptions/validation.exception.d.ts +14 -0
- package/dist/cjs/domain/exceptions/validation.exception.js +23 -0
- package/dist/cjs/domain/index.d.ts +17 -0
- package/dist/cjs/domain/index.js +36 -0
- package/dist/cjs/domain/primitive/primitive-types.d.ts +20 -0
- package/dist/cjs/domain/primitive/primitive-types.js +2 -0
- package/dist/cjs/domain/repository/aggregate-finder.d.ts +4 -0
- package/dist/cjs/domain/repository/aggregate-finder.js +2 -0
- package/dist/cjs/domain/repository/aggregate-remover.d.ts +4 -0
- package/dist/cjs/domain/repository/aggregate-remover.js +2 -0
- package/dist/cjs/domain/repository/aggregate-saver.d.ts +4 -0
- package/dist/cjs/domain/repository/aggregate-saver.js +2 -0
- package/dist/cjs/domain/specification/specification.d.ts +9 -0
- package/dist/cjs/domain/specification/specification.js +44 -0
- package/dist/cjs/domain/type/abstract-type.d.ts +18 -0
- package/dist/cjs/domain/type/abstract-type.js +61 -0
- package/dist/cjs/domain/type/array-type.d.ts +17 -0
- package/dist/cjs/domain/type/array-type.js +64 -0
- package/dist/cjs/domain/type/boolean-type.d.ts +4 -0
- package/dist/cjs/domain/type/boolean-type.js +16 -0
- package/dist/cjs/domain/type/composite/composite-brand.d.ts +4 -0
- package/dist/cjs/domain/type/composite/composite-brand.js +15 -0
- package/dist/cjs/domain/type/composite/composite-field.d.ts +18 -0
- package/dist/cjs/domain/type/composite/composite-field.js +86 -0
- package/dist/cjs/domain/type/composite/composite-issues.d.ts +6 -0
- package/dist/cjs/domain/type/composite/composite-issues.js +35 -0
- package/dist/cjs/domain/type/composite/composite.d.ts +26 -0
- package/dist/cjs/domain/type/composite/composite.js +51 -0
- package/dist/cjs/domain/type/date-type.d.ts +19 -0
- package/dist/cjs/domain/type/date-type.js +70 -0
- package/dist/cjs/domain/type/enum-type.d.ts +7 -0
- package/dist/cjs/domain/type/enum-type.js +30 -0
- package/dist/cjs/domain/type/id-type.d.ts +7 -0
- package/dist/cjs/domain/type/id-type.js +17 -0
- package/dist/cjs/domain/type/index.d.ts +15 -0
- package/dist/cjs/domain/type/index.js +29 -0
- package/dist/cjs/domain/type/json-type.d.ts +9 -0
- package/dist/cjs/domain/type/json-type.js +46 -0
- package/dist/cjs/domain/type/number-type.d.ts +4 -0
- package/dist/cjs/domain/type/number-type.js +16 -0
- package/dist/cjs/domain/type/required/required-mark.d.ts +8 -0
- package/dist/cjs/domain/type/required/required-mark.js +13 -0
- package/dist/cjs/domain/type/required/required-type.d.ts +7 -0
- package/dist/cjs/domain/type/required/required-type.js +21 -0
- package/dist/cjs/domain/type/string-type.d.ts +4 -0
- package/dist/cjs/domain/type/string-type.js +16 -0
- package/dist/cjs/domain/type/uuid-type.d.ts +7 -0
- package/dist/cjs/domain/type/uuid-type.js +27 -0
- package/dist/cjs/infrastructure/clock/fixed-clock.d.ts +8 -0
- package/dist/cjs/infrastructure/clock/fixed-clock.js +19 -0
- package/dist/cjs/infrastructure/clock/system-clock.d.ts +4 -0
- package/dist/cjs/infrastructure/clock/system-clock.js +9 -0
- package/dist/cjs/infrastructure/event/domain-event-bus.d.ts +16 -0
- package/dist/cjs/infrastructure/event/domain-event-bus.js +60 -0
- package/dist/cjs/infrastructure/event/event-channel.d.ts +9 -0
- package/dist/cjs/infrastructure/event/event-channel.js +2 -0
- package/dist/cjs/infrastructure/event/event-registry.d.ts +9 -0
- package/dist/cjs/infrastructure/event/event-registry.js +43 -0
- package/dist/cjs/infrastructure/event/in-memory/emitter.d.ts +11 -0
- package/dist/cjs/infrastructure/event/in-memory/emitter.js +54 -0
- package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.d.ts +16 -0
- package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.js +50 -0
- package/dist/cjs/infrastructure/exceptions/event-delivery.exception.d.ts +5 -0
- package/dist/cjs/infrastructure/exceptions/event-delivery.exception.js +20 -0
- package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
- package/dist/cjs/infrastructure/exceptions/infrastructure-exception-code.js +10 -0
- package/dist/cjs/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
- package/dist/cjs/infrastructure/exceptions/infrastructure.exception.js +16 -0
- package/dist/cjs/infrastructure/exceptions/internal-error.exception.d.ts +5 -0
- package/dist/cjs/infrastructure/exceptions/internal-error.exception.js +17 -0
- package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
- package/dist/cjs/infrastructure/exceptions/kind/exception-classifier.js +34 -0
- package/dist/cjs/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
- package/dist/cjs/infrastructure/exceptions/kind/exception-kind.js +13 -0
- package/dist/cjs/infrastructure/exceptions/unknown-event.exception.d.ts +4 -0
- package/dist/cjs/infrastructure/exceptions/unknown-event.exception.js +19 -0
- package/dist/cjs/infrastructure/index.d.ts +21 -0
- package/dist/cjs/infrastructure/index.js +33 -0
- package/dist/cjs/infrastructure/logging/console-logger.d.ts +17 -0
- package/dist/cjs/infrastructure/logging/console-logger.js +37 -0
- package/dist/cjs/infrastructure/logging/in-memory-logger.d.ts +15 -0
- package/dist/cjs/infrastructure/logging/in-memory-logger.js +27 -0
- package/dist/cjs/infrastructure/logging/log-serializer.d.ts +7 -0
- package/dist/cjs/infrastructure/logging/log-serializer.js +59 -0
- package/dist/cjs/infrastructure/logging/silent-logger.d.ts +7 -0
- package/dist/cjs/infrastructure/logging/silent-logger.js +18 -0
- package/dist/cjs/shared/exceptions/abstract.exception.d.ts +25 -0
- package/dist/cjs/shared/exceptions/abstract.exception.js +59 -0
- package/dist/cjs/shared/exceptions/brand/exception-brand.d.ts +6 -0
- package/dist/cjs/shared/exceptions/brand/exception-brand.js +29 -0
- package/dist/cjs/shared/exceptions/received/received-value.d.ts +4 -0
- package/dist/cjs/shared/exceptions/received/received-value.js +13 -0
- package/dist/cjs/shared/index.d.ts +8 -0
- package/dist/cjs/shared/index.js +13 -0
- package/dist/cjs/shared/issue-collection-error.d.ts +9 -0
- package/dist/cjs/shared/issue-collection-error.js +11 -0
- package/dist/cjs/shared/issue-collector.d.ts +8 -0
- package/dist/cjs/shared/issue-collector.js +41 -0
- package/dist/esm/application/event/event-bus.d.ts +4 -0
- package/dist/esm/application/event/event-bus.js +1 -0
- package/dist/esm/application/event/event-listener.d.ts +4 -0
- package/dist/esm/application/event/event-listener.js +2 -0
- package/dist/esm/application/event/listens-to.d.ts +15 -0
- package/dist/esm/application/event/listens-to.js +25 -0
- package/dist/esm/application/exceptions/aggregate-not-found.exception.d.ts +5 -0
- package/dist/esm/application/exceptions/aggregate-not-found.exception.js +13 -0
- package/dist/esm/application/exceptions/application-exception-code.d.ts +7 -0
- package/dist/esm/application/exceptions/application-exception-code.js +8 -0
- package/dist/esm/application/exceptions/application.exception.d.ts +6 -0
- package/dist/esm/application/exceptions/application.exception.js +12 -0
- package/dist/esm/application/exceptions/concurrency.exception.d.ts +5 -0
- package/dist/esm/application/exceptions/concurrency.exception.js +13 -0
- package/dist/esm/application/exceptions/not-allowed.exception.d.ts +5 -0
- package/dist/esm/application/exceptions/not-allowed.exception.js +13 -0
- package/dist/esm/application/exceptions/unexpected-error.exception.d.ts +5 -0
- package/dist/esm/application/exceptions/unexpected-error.exception.js +13 -0
- package/dist/esm/application/index.d.ts +14 -0
- package/dist/esm/application/index.js +10 -0
- package/dist/esm/application/ports/clock.d.ts +3 -0
- package/dist/esm/application/ports/clock.js +1 -0
- package/dist/esm/application/ports/logger.d.ts +8 -0
- package/dist/esm/application/ports/logger.js +1 -0
- package/dist/esm/application/use-case/use-case.d.ts +6 -0
- package/dist/esm/application/use-case/use-case.js +21 -0
- package/dist/esm/application/value-object-builder/value-object-builder.d.ts +16 -0
- package/dist/esm/application/value-object-builder/value-object-builder.js +47 -0
- package/dist/esm/domain/aggregate/aggregate-root.d.ts +9 -0
- package/dist/esm/domain/aggregate/aggregate-root.js +13 -0
- package/dist/esm/domain/entity/entity.d.ts +9 -0
- package/dist/esm/domain/entity/entity.js +15 -0
- package/dist/esm/domain/event/event-base.d.ts +23 -0
- package/dist/esm/domain/event/event-base.js +17 -0
- package/dist/esm/domain/exceptions/domain-exception-code.d.ts +7 -0
- package/dist/esm/domain/exceptions/domain-exception-code.js +8 -0
- package/dist/esm/domain/exceptions/domain.exception.d.ts +6 -0
- package/dist/esm/domain/exceptions/domain.exception.js +12 -0
- package/dist/esm/domain/exceptions/invalid-event-definition.exception.d.ts +4 -0
- package/dist/esm/domain/exceptions/invalid-event-definition.exception.js +15 -0
- package/dist/esm/domain/exceptions/required-value.exception.d.ts +4 -0
- package/dist/esm/domain/exceptions/required-value.exception.js +16 -0
- package/dist/esm/domain/exceptions/type-primitive.exception.d.ts +4 -0
- package/dist/esm/domain/exceptions/type-primitive.exception.js +16 -0
- package/dist/esm/domain/exceptions/validation.exception.d.ts +14 -0
- package/dist/esm/domain/exceptions/validation.exception.js +19 -0
- package/dist/esm/domain/index.d.ts +17 -0
- package/dist/esm/domain/index.js +12 -0
- package/dist/esm/domain/primitive/primitive-types.d.ts +20 -0
- package/dist/esm/domain/primitive/primitive-types.js +1 -0
- package/dist/esm/domain/repository/aggregate-finder.d.ts +4 -0
- package/dist/esm/domain/repository/aggregate-finder.js +1 -0
- package/dist/esm/domain/repository/aggregate-remover.d.ts +4 -0
- package/dist/esm/domain/repository/aggregate-remover.js +1 -0
- package/dist/esm/domain/repository/aggregate-saver.d.ts +4 -0
- package/dist/esm/domain/repository/aggregate-saver.js +1 -0
- package/dist/esm/domain/specification/specification.d.ts +9 -0
- package/dist/esm/domain/specification/specification.js +40 -0
- package/dist/esm/domain/type/abstract-type.d.ts +18 -0
- package/dist/esm/domain/type/abstract-type.js +57 -0
- package/dist/esm/domain/type/array-type.d.ts +17 -0
- package/dist/esm/domain/type/array-type.js +60 -0
- package/dist/esm/domain/type/boolean-type.d.ts +4 -0
- package/dist/esm/domain/type/boolean-type.js +12 -0
- package/dist/esm/domain/type/composite/composite-brand.d.ts +4 -0
- package/dist/esm/domain/type/composite/composite-brand.js +11 -0
- package/dist/esm/domain/type/composite/composite-field.d.ts +18 -0
- package/dist/esm/domain/type/composite/composite-field.js +82 -0
- package/dist/esm/domain/type/composite/composite-issues.d.ts +6 -0
- package/dist/esm/domain/type/composite/composite-issues.js +31 -0
- package/dist/esm/domain/type/composite/composite.d.ts +26 -0
- package/dist/esm/domain/type/composite/composite.js +48 -0
- package/dist/esm/domain/type/date-type.d.ts +19 -0
- package/dist/esm/domain/type/date-type.js +64 -0
- package/dist/esm/domain/type/enum-type.d.ts +7 -0
- package/dist/esm/domain/type/enum-type.js +26 -0
- package/dist/esm/domain/type/id-type.d.ts +7 -0
- package/dist/esm/domain/type/id-type.js +13 -0
- package/dist/esm/domain/type/index.d.ts +15 -0
- package/dist/esm/domain/type/index.js +12 -0
- package/dist/esm/domain/type/json-type.d.ts +9 -0
- package/dist/esm/domain/type/json-type.js +42 -0
- package/dist/esm/domain/type/number-type.d.ts +4 -0
- package/dist/esm/domain/type/number-type.js +12 -0
- package/dist/esm/domain/type/required/required-mark.d.ts +8 -0
- package/dist/esm/domain/type/required/required-mark.js +9 -0
- package/dist/esm/domain/type/required/required-type.d.ts +7 -0
- package/dist/esm/domain/type/required/required-type.js +18 -0
- package/dist/esm/domain/type/string-type.d.ts +4 -0
- package/dist/esm/domain/type/string-type.js +12 -0
- package/dist/esm/domain/type/uuid-type.d.ts +7 -0
- package/dist/esm/domain/type/uuid-type.js +23 -0
- package/dist/esm/infrastructure/clock/fixed-clock.d.ts +8 -0
- package/dist/esm/infrastructure/clock/fixed-clock.js +15 -0
- package/dist/esm/infrastructure/clock/system-clock.d.ts +4 -0
- package/dist/esm/infrastructure/clock/system-clock.js +5 -0
- package/dist/esm/infrastructure/event/domain-event-bus.d.ts +16 -0
- package/dist/esm/infrastructure/event/domain-event-bus.js +56 -0
- package/dist/esm/infrastructure/event/event-channel.d.ts +9 -0
- package/dist/esm/infrastructure/event/event-channel.js +1 -0
- package/dist/esm/infrastructure/event/event-registry.d.ts +9 -0
- package/dist/esm/infrastructure/event/event-registry.js +39 -0
- package/dist/esm/infrastructure/event/in-memory/emitter.d.ts +11 -0
- package/dist/esm/infrastructure/event/in-memory/emitter.js +50 -0
- package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.d.ts +16 -0
- package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.js +46 -0
- package/dist/esm/infrastructure/exceptions/event-delivery.exception.d.ts +5 -0
- package/dist/esm/infrastructure/exceptions/event-delivery.exception.js +16 -0
- package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.d.ts +6 -0
- package/dist/esm/infrastructure/exceptions/infrastructure-exception-code.js +7 -0
- package/dist/esm/infrastructure/exceptions/infrastructure.exception.d.ts +6 -0
- package/dist/esm/infrastructure/exceptions/infrastructure.exception.js +12 -0
- package/dist/esm/infrastructure/exceptions/internal-error.exception.d.ts +5 -0
- package/dist/esm/infrastructure/exceptions/internal-error.exception.js +13 -0
- package/dist/esm/infrastructure/exceptions/kind/exception-classifier.d.ts +4 -0
- package/dist/esm/infrastructure/exceptions/kind/exception-classifier.js +30 -0
- package/dist/esm/infrastructure/exceptions/kind/exception-kind.d.ts +9 -0
- package/dist/esm/infrastructure/exceptions/kind/exception-kind.js +10 -0
- package/dist/esm/infrastructure/exceptions/unknown-event.exception.d.ts +4 -0
- package/dist/esm/infrastructure/exceptions/unknown-event.exception.js +15 -0
- package/dist/esm/infrastructure/index.d.ts +21 -0
- package/dist/esm/infrastructure/index.js +15 -0
- package/dist/esm/infrastructure/logging/console-logger.d.ts +17 -0
- package/dist/esm/infrastructure/logging/console-logger.js +33 -0
- package/dist/esm/infrastructure/logging/in-memory-logger.d.ts +15 -0
- package/dist/esm/infrastructure/logging/in-memory-logger.js +23 -0
- package/dist/esm/infrastructure/logging/log-serializer.d.ts +7 -0
- package/dist/esm/infrastructure/logging/log-serializer.js +55 -0
- package/dist/esm/infrastructure/logging/silent-logger.d.ts +7 -0
- package/dist/esm/infrastructure/logging/silent-logger.js +14 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/shared/exceptions/abstract.exception.d.ts +25 -0
- package/dist/esm/shared/exceptions/abstract.exception.js +55 -0
- package/dist/esm/shared/exceptions/brand/exception-brand.d.ts +6 -0
- package/dist/esm/shared/exceptions/brand/exception-brand.js +25 -0
- package/dist/esm/shared/exceptions/received/received-value.d.ts +4 -0
- package/dist/esm/shared/exceptions/received/received-value.js +9 -0
- package/dist/esm/shared/index.d.ts +8 -0
- package/dist/esm/shared/index.js +5 -0
- package/dist/esm/shared/issue-collection-error.d.ts +9 -0
- package/dist/esm/shared/issue-collection-error.js +7 -0
- package/dist/esm/shared/issue-collector.d.ts +8 -0
- package/dist/esm/shared/issue-collector.js +37 -0
- package/package.json +95 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiredMark = void 0;
|
|
4
|
+
class RequiredMark {
|
|
5
|
+
static isMarked(instance) {
|
|
6
|
+
return instance[RequiredMark.symbol] === true;
|
|
7
|
+
}
|
|
8
|
+
static mark(prototype) {
|
|
9
|
+
Object.defineProperty(prototype, RequiredMark.symbol, { value: true });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.RequiredMark = RequiredMark;
|
|
13
|
+
RequiredMark.symbol = Symbol.for('@archi-code/ddd/required.v1');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbstractType } from '../abstract-type';
|
|
2
|
+
import type { RequiredMarked } from './required-mark';
|
|
3
|
+
type TypeClass = abstract new (value?: any) => AbstractType<any>;
|
|
4
|
+
type RequiredValueOf<C extends TypeClass> = Exclude<ConstructorParameters<C>[0], null | undefined>;
|
|
5
|
+
export type RequiredType<C extends TypeClass> = Omit<C, 'prototype'> & (abstract new (value: RequiredValueOf<C>) => InstanceType<C> & RequiredMarked);
|
|
6
|
+
export declare function Required<C extends TypeClass>(Base: C): RequiredType<C>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Required = Required;
|
|
10
|
+
const validation_1 = require("@archi-code/validation");
|
|
11
|
+
const required_mark_1 = require("./required-mark");
|
|
12
|
+
function Required(Base) {
|
|
13
|
+
let RequiredValue = class RequiredValue extends Base {
|
|
14
|
+
};
|
|
15
|
+
RequiredValue = __decorate([
|
|
16
|
+
(0, validation_1.Validations)([{ validator: 'isRequired' }])
|
|
17
|
+
], RequiredValue);
|
|
18
|
+
Object.defineProperty(RequiredValue, 'name', { value: `Required(${Base.name})` });
|
|
19
|
+
required_mark_1.RequiredMark.mark(RequiredValue.prototype);
|
|
20
|
+
return RequiredValue;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringType = void 0;
|
|
4
|
+
const validation_1 = require("@archi-code/validation");
|
|
5
|
+
const abstract_type_1 = require("./abstract-type");
|
|
6
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
7
|
+
class StringType extends abstract_type_1.AbstractType {
|
|
8
|
+
filter(value) {
|
|
9
|
+
const converted = (0, validation_1.toString)(value);
|
|
10
|
+
if (!converted.ok) {
|
|
11
|
+
throw new type_primitive_exception_1.TypePrimitiveException('String', value);
|
|
12
|
+
}
|
|
13
|
+
return converted.value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.StringType = StringType;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractType } from './abstract-type';
|
|
2
|
+
export declare class UuidType extends AbstractType<string> {
|
|
3
|
+
static random(): string;
|
|
4
|
+
static generate<T extends AbstractType<string>>(this: new (value: string) => T): T;
|
|
5
|
+
static fromValue(value: string, namespace?: string): string;
|
|
6
|
+
protected filter(value: unknown): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UuidType = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const validation_1 = require("@archi-code/validation");
|
|
6
|
+
const abstract_type_1 = require("./abstract-type");
|
|
7
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
8
|
+
const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
9
|
+
class UuidType extends abstract_type_1.AbstractType {
|
|
10
|
+
static random() {
|
|
11
|
+
return (0, uuid_1.v4)();
|
|
12
|
+
}
|
|
13
|
+
static generate() {
|
|
14
|
+
return new this((0, uuid_1.v4)());
|
|
15
|
+
}
|
|
16
|
+
static fromValue(value, namespace = DNS_NAMESPACE) {
|
|
17
|
+
return (0, uuid_1.v5)(value, namespace);
|
|
18
|
+
}
|
|
19
|
+
filter(value) {
|
|
20
|
+
const converted = (0, validation_1.toString)(value);
|
|
21
|
+
if (!converted.ok || !(0, validation_1.isUUID)(converted.value)) {
|
|
22
|
+
throw new type_primitive_exception_1.TypePrimitiveException('UUID', value);
|
|
23
|
+
}
|
|
24
|
+
return converted.value.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UuidType = UuidType;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FixedClock = void 0;
|
|
4
|
+
const index_1 = require("../../domain/index");
|
|
5
|
+
class FixedClock {
|
|
6
|
+
constructor(at) {
|
|
7
|
+
this.current = new index_1.CreatedAt(at).value;
|
|
8
|
+
}
|
|
9
|
+
now() {
|
|
10
|
+
return new Date(this.current.getTime());
|
|
11
|
+
}
|
|
12
|
+
set(at) {
|
|
13
|
+
this.current = new index_1.CreatedAt(at).value;
|
|
14
|
+
}
|
|
15
|
+
advance(milliseconds) {
|
|
16
|
+
this.current = new index_1.CreatedAt(new Date(this.current.getTime() + milliseconds)).value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FixedClock = FixedClock;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EventBase } from '../../domain/index';
|
|
2
|
+
import type { EventBus, EventListener, Logger } from '../../application/index';
|
|
3
|
+
import type { EventChannel } from './event-channel';
|
|
4
|
+
import type { EventRegistry } from './event-registry';
|
|
5
|
+
export interface Subscription {
|
|
6
|
+
unsubscribe(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class DomainEventBus<Event extends EventBase = EventBase> implements EventBus<Event> {
|
|
9
|
+
private readonly channel;
|
|
10
|
+
private readonly registry;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(channel: EventChannel, registry: EventRegistry<Event>, logger?: Logger);
|
|
13
|
+
publish(events: readonly Event[]): Promise<void>;
|
|
14
|
+
subscribe(listener: EventListener<Event>): Promise<Subscription>;
|
|
15
|
+
private deliver;
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainEventBus = void 0;
|
|
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");
|
|
8
|
+
const silent_logger_1 = require("../logging/silent-logger");
|
|
9
|
+
class DomainEventBus {
|
|
10
|
+
constructor(channel, registry, logger = new silent_logger_1.SilentLogger()) {
|
|
11
|
+
this.channel = channel;
|
|
12
|
+
this.registry = registry;
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
}
|
|
15
|
+
async publish(events) {
|
|
16
|
+
await this.channel.send(events.map((event) => ({ ...event })));
|
|
17
|
+
this.logger.debug('domain_events_published', {
|
|
18
|
+
events: events.map((event) => ({
|
|
19
|
+
eventName: event.eventName,
|
|
20
|
+
eventId: event.eventId,
|
|
21
|
+
})),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async subscribe(listener) {
|
|
25
|
+
const subscription = index_3.ListensTo.subscriptionOf(listener);
|
|
26
|
+
const { eventName, consumer } = subscription;
|
|
27
|
+
if (!this.registry.has(eventName)) {
|
|
28
|
+
throw new unknown_event_exception_1.UnknownEventException(eventName);
|
|
29
|
+
}
|
|
30
|
+
const channelSubscription = await this.channel.receive(eventName, consumer, (serialized) => this.deliver(listener, subscription, serialized));
|
|
31
|
+
this.logger.info('event_listener_subscribed', { eventName, consumer });
|
|
32
|
+
return {
|
|
33
|
+
unsubscribe: async () => {
|
|
34
|
+
await channelSubscription.close();
|
|
35
|
+
this.logger.info('event_listener_unsubscribed', { eventName, consumer });
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async deliver(listener, { eventName, consumer }, serialized) {
|
|
40
|
+
try {
|
|
41
|
+
await listener.handle(this.registry.fromJSON(serialized));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const context = {
|
|
45
|
+
eventName,
|
|
46
|
+
consumer,
|
|
47
|
+
eventId: serialized.eventId,
|
|
48
|
+
error,
|
|
49
|
+
};
|
|
50
|
+
if (error instanceof index_2.DomainException || error instanceof index_1.ApplicationException) {
|
|
51
|
+
this.logger.warn('event_listener_rejected', context);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.logger.error('event_listener_failed', context);
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.DomainEventBus = DomainEventBus;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SerializedEvent } from '../../domain/index';
|
|
2
|
+
export type ChannelHandler = (event: SerializedEvent) => Promise<void>;
|
|
3
|
+
export interface ChannelSubscription {
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export interface EventChannel {
|
|
7
|
+
send(events: readonly SerializedEvent[]): Promise<void>;
|
|
8
|
+
receive(eventName: string, consumer: string, handler: ChannelHandler): Promise<ChannelSubscription>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EventBase, EventClass, SerializedEvent } from '../../domain/index';
|
|
2
|
+
export type EventFactory<Event extends EventBase> = (serialized: SerializedEvent) => Event;
|
|
3
|
+
export declare class EventRegistry<Event extends EventBase = EventBase> {
|
|
4
|
+
private readonly factories;
|
|
5
|
+
register<Registered extends Event>(event: EventClass<Registered>, factory: EventFactory<Registered>): this;
|
|
6
|
+
has(eventName: string): boolean;
|
|
7
|
+
fromJSON(event: SerializedEvent): Event;
|
|
8
|
+
private static assertSameIdentity;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventRegistry = void 0;
|
|
4
|
+
const internal_error_exception_1 = require("../exceptions/internal-error.exception");
|
|
5
|
+
const unknown_event_exception_1 = require("../exceptions/unknown-event.exception");
|
|
6
|
+
class EventRegistry {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.factories = new Map();
|
|
9
|
+
}
|
|
10
|
+
register(event, factory) {
|
|
11
|
+
const { eventName } = event;
|
|
12
|
+
if (this.factories.has(eventName)) {
|
|
13
|
+
throw new internal_error_exception_1.InternalErrorException(`event "${eventName}" is already registered`);
|
|
14
|
+
}
|
|
15
|
+
this.factories.set(eventName, factory);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
has(eventName) {
|
|
19
|
+
return this.factories.has(eventName);
|
|
20
|
+
}
|
|
21
|
+
fromJSON(event) {
|
|
22
|
+
if (typeof event !== 'object' || event === null) {
|
|
23
|
+
throw new internal_error_exception_1.InternalErrorException('a serialized event must be a JSON object');
|
|
24
|
+
}
|
|
25
|
+
if (typeof event.eventName !== 'string') {
|
|
26
|
+
throw new internal_error_exception_1.InternalErrorException('a serialized event needs its eventName');
|
|
27
|
+
}
|
|
28
|
+
const factory = this.factories.get(event.eventName);
|
|
29
|
+
if (factory === undefined) {
|
|
30
|
+
throw new unknown_event_exception_1.UnknownEventException(event.eventName);
|
|
31
|
+
}
|
|
32
|
+
const rebuilt = factory(event);
|
|
33
|
+
EventRegistry.assertSameIdentity(event, rebuilt);
|
|
34
|
+
return rebuilt;
|
|
35
|
+
}
|
|
36
|
+
static assertSameIdentity(serialized, rebuilt) {
|
|
37
|
+
if (rebuilt.eventId !== String(serialized.eventId).toLowerCase() ||
|
|
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
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.EventRegistry = EventRegistry;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type EmitterListener<Data> = (data: Data) => Promise<void> | void;
|
|
2
|
+
export declare class Emitter<Data> {
|
|
3
|
+
private static readonly resolved;
|
|
4
|
+
private readonly events;
|
|
5
|
+
on(eventName: string, listener: EmitterListener<Data>): () => void;
|
|
6
|
+
private off;
|
|
7
|
+
emit(eventName: string, data: Data): Promise<void>;
|
|
8
|
+
emitSerial(eventName: string, data: Data): Promise<void>;
|
|
9
|
+
private listenersOf;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Emitter = void 0;
|
|
4
|
+
const event_delivery_exception_1 = require("../../exceptions/event-delivery.exception");
|
|
5
|
+
class Emitter {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.events = new Map();
|
|
8
|
+
}
|
|
9
|
+
on(eventName, listener) {
|
|
10
|
+
const listeners = this.events.get(eventName) ?? new Set();
|
|
11
|
+
listeners.add(listener);
|
|
12
|
+
this.events.set(eventName, listeners);
|
|
13
|
+
return () => this.off(eventName, listener);
|
|
14
|
+
}
|
|
15
|
+
off(eventName, listener) {
|
|
16
|
+
const listeners = this.events.get(eventName);
|
|
17
|
+
if (listeners === undefined) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
listeners.delete(listener);
|
|
21
|
+
if (listeners.size === 0) {
|
|
22
|
+
this.events.delete(eventName);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async emit(eventName, data) {
|
|
26
|
+
const listeners = this.listenersOf(eventName);
|
|
27
|
+
const snapshot = Array.from(listeners);
|
|
28
|
+
await Emitter.resolved;
|
|
29
|
+
const results = await Promise.allSettled(snapshot.map(async (listener) => {
|
|
30
|
+
if (listeners.has(listener)) {
|
|
31
|
+
await listener(data);
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
const errors = results.flatMap((result) => result.status === 'rejected' ? [result.reason] : []);
|
|
35
|
+
if (errors.length > 0) {
|
|
36
|
+
throw new event_delivery_exception_1.EventDeliveryException(eventName, errors, snapshot.length);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async emitSerial(eventName, data) {
|
|
40
|
+
const listeners = this.listenersOf(eventName);
|
|
41
|
+
const snapshot = Array.from(listeners);
|
|
42
|
+
await Emitter.resolved;
|
|
43
|
+
for (const listener of snapshot) {
|
|
44
|
+
if (listeners.has(listener)) {
|
|
45
|
+
await listener(data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
listenersOf(eventName) {
|
|
50
|
+
return this.events.get(eventName) ?? new Set();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.Emitter = Emitter;
|
|
54
|
+
Emitter.resolved = Promise.resolve();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChannelHandler, ChannelSubscription, EventChannel } from '../event-channel';
|
|
2
|
+
import type { SerializedEvent } from '../../../domain/index';
|
|
3
|
+
export interface InMemoryEventChannelOptions {
|
|
4
|
+
readonly delivery?: 'serial' | 'parallel';
|
|
5
|
+
}
|
|
6
|
+
export declare class InMemoryEventChannel implements EventChannel {
|
|
7
|
+
private readonly emitter;
|
|
8
|
+
private readonly receivers;
|
|
9
|
+
private readonly sentEvents;
|
|
10
|
+
private readonly delivery;
|
|
11
|
+
constructor({ delivery }?: InMemoryEventChannelOptions);
|
|
12
|
+
get sent(): readonly SerializedEvent[];
|
|
13
|
+
send(events: readonly SerializedEvent[]): Promise<void>;
|
|
14
|
+
receive(eventName: string, consumer: string, handler: ChannelHandler): Promise<ChannelSubscription>;
|
|
15
|
+
private static copy;
|
|
16
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryEventChannel = void 0;
|
|
4
|
+
const infrastructure_exception_1 = require("../../exceptions/infrastructure.exception");
|
|
5
|
+
const emitter_1 = require("./emitter");
|
|
6
|
+
class InMemoryEventChannel {
|
|
7
|
+
constructor({ delivery = 'serial' } = {}) {
|
|
8
|
+
this.emitter = new emitter_1.Emitter();
|
|
9
|
+
this.receivers = new Set();
|
|
10
|
+
this.sentEvents = [];
|
|
11
|
+
this.delivery = delivery;
|
|
12
|
+
}
|
|
13
|
+
get sent() {
|
|
14
|
+
return [...this.sentEvents];
|
|
15
|
+
}
|
|
16
|
+
async send(events) {
|
|
17
|
+
for (const event of events) {
|
|
18
|
+
const copy = InMemoryEventChannel.copy(event);
|
|
19
|
+
this.sentEvents.push(copy);
|
|
20
|
+
if (this.delivery === 'parallel') {
|
|
21
|
+
await this.emitter.emit(copy.eventName, copy);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
await this.emitter.emitSerial(copy.eventName, copy);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async receive(eventName, consumer, handler) {
|
|
29
|
+
const receiver = JSON.stringify([eventName, consumer]);
|
|
30
|
+
if (this.receivers.has(receiver)) {
|
|
31
|
+
throw new infrastructure_exception_1.InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
|
|
32
|
+
}
|
|
33
|
+
this.receivers.add(receiver);
|
|
34
|
+
const off = this.emitter.on(eventName, (event) => handler(InMemoryEventChannel.copy(event)));
|
|
35
|
+
let open = true;
|
|
36
|
+
return {
|
|
37
|
+
close: async () => {
|
|
38
|
+
if (open) {
|
|
39
|
+
open = false;
|
|
40
|
+
off();
|
|
41
|
+
this.receivers.delete(receiver);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static copy(event) {
|
|
47
|
+
return JSON.parse(JSON.stringify(event));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.InMemoryEventChannel = InMemoryEventChannel;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InfrastructureException } from './infrastructure.exception';
|
|
2
|
+
export declare class EventDeliveryException extends InfrastructureException {
|
|
3
|
+
readonly errors: readonly unknown[];
|
|
4
|
+
constructor(eventName: string, errors: readonly unknown[], consumers: number);
|
|
5
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EventDeliveryException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
7
|
+
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
8
|
+
class EventDeliveryException extends infrastructure_exception_1.InfrastructureException {
|
|
9
|
+
constructor(eventName, errors, consumers) {
|
|
10
|
+
super(`${errors.length} of ${consumers} consumers of "${eventName}" failed.`, [
|
|
11
|
+
infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery,
|
|
12
|
+
]);
|
|
13
|
+
this.errors = Object.freeze([...errors]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.EventDeliveryException = EventDeliveryException;
|
|
17
|
+
_a = EventDeliveryException;
|
|
18
|
+
(() => {
|
|
19
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery);
|
|
20
|
+
})();
|
|
@@ -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
|
+
})();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index';
|
|
2
|
+
import { InfrastructureException } from './infrastructure.exception';
|
|
3
|
+
export declare class InternalErrorException extends InfrastructureException {
|
|
4
|
+
constructor(message: string, options?: ExceptionOptions);
|
|
5
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InternalErrorException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
7
|
+
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
8
|
+
class InternalErrorException extends infrastructure_exception_1.InfrastructureException {
|
|
9
|
+
constructor(message, options = {}) {
|
|
10
|
+
super(`Failed, internal error: ${message}`, [infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError], options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.InternalErrorException = InternalErrorException;
|
|
14
|
+
_a = InternalErrorException;
|
|
15
|
+
(() => {
|
|
16
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError);
|
|
17
|
+
})();
|
|
@@ -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,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 = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.UnknownEventException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
7
|
+
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
8
|
+
class UnknownEventException extends infrastructure_exception_1.InfrastructureException {
|
|
9
|
+
constructor(eventName) {
|
|
10
|
+
super(`Unknown event "${eventName}": register it before reading it.`, [
|
|
11
|
+
infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent,
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.UnknownEventException = UnknownEventException;
|
|
16
|
+
_a = UnknownEventException;
|
|
17
|
+
(() => {
|
|
18
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent);
|
|
19
|
+
})();
|