@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,21 @@
|
|
|
1
|
+
export { SystemClock } from './clock/system-clock';
|
|
2
|
+
export { FixedClock } from './clock/fixed-clock';
|
|
3
|
+
export { DomainEventBus } from './event/domain-event-bus';
|
|
4
|
+
export type { Subscription } from './event/domain-event-bus';
|
|
5
|
+
export { EventRegistry } from './event/event-registry';
|
|
6
|
+
export type { EventFactory } from './event/event-registry';
|
|
7
|
+
export type { ChannelHandler, ChannelSubscription, EventChannel } from './event/event-channel';
|
|
8
|
+
export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel';
|
|
9
|
+
export type { InMemoryEventChannelOptions } from './event/in-memory/in-memory-event-channel';
|
|
10
|
+
export { ConsoleLogger } from './logging/console-logger';
|
|
11
|
+
export type { ConsoleLoggerOptions } from './logging/console-logger';
|
|
12
|
+
export { InMemoryLogger } from './logging/in-memory-logger';
|
|
13
|
+
export type { LogEntry } from './logging/in-memory-logger';
|
|
14
|
+
export { SilentLogger } from './logging/silent-logger';
|
|
15
|
+
export { InfrastructureException } from './exceptions/infrastructure.exception';
|
|
16
|
+
export { InternalErrorException } from './exceptions/internal-error.exception';
|
|
17
|
+
export { UnknownEventException } from './exceptions/unknown-event.exception';
|
|
18
|
+
export { EventDeliveryException } from './exceptions/event-delivery.exception';
|
|
19
|
+
export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code';
|
|
20
|
+
export { ExceptionClassifier } from './exceptions/kind/exception-classifier';
|
|
21
|
+
export { ExceptionKind } from './exceptions/kind/exception-kind';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionKind = exports.ExceptionClassifier = exports.InfrastructureExceptionCode = exports.EventDeliveryException = exports.UnknownEventException = exports.InternalErrorException = exports.InfrastructureException = exports.SilentLogger = exports.InMemoryLogger = exports.ConsoleLogger = exports.InMemoryEventChannel = exports.EventRegistry = exports.DomainEventBus = exports.FixedClock = exports.SystemClock = void 0;
|
|
4
|
+
var system_clock_1 = require("./clock/system-clock");
|
|
5
|
+
Object.defineProperty(exports, "SystemClock", { enumerable: true, get: function () { return system_clock_1.SystemClock; } });
|
|
6
|
+
var fixed_clock_1 = require("./clock/fixed-clock");
|
|
7
|
+
Object.defineProperty(exports, "FixedClock", { enumerable: true, get: function () { return fixed_clock_1.FixedClock; } });
|
|
8
|
+
var domain_event_bus_1 = require("./event/domain-event-bus");
|
|
9
|
+
Object.defineProperty(exports, "DomainEventBus", { enumerable: true, get: function () { return domain_event_bus_1.DomainEventBus; } });
|
|
10
|
+
var event_registry_1 = require("./event/event-registry");
|
|
11
|
+
Object.defineProperty(exports, "EventRegistry", { enumerable: true, get: function () { return event_registry_1.EventRegistry; } });
|
|
12
|
+
var in_memory_event_channel_1 = require("./event/in-memory/in-memory-event-channel");
|
|
13
|
+
Object.defineProperty(exports, "InMemoryEventChannel", { enumerable: true, get: function () { return in_memory_event_channel_1.InMemoryEventChannel; } });
|
|
14
|
+
var console_logger_1 = require("./logging/console-logger");
|
|
15
|
+
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return console_logger_1.ConsoleLogger; } });
|
|
16
|
+
var in_memory_logger_1 = require("./logging/in-memory-logger");
|
|
17
|
+
Object.defineProperty(exports, "InMemoryLogger", { enumerable: true, get: function () { return in_memory_logger_1.InMemoryLogger; } });
|
|
18
|
+
var silent_logger_1 = require("./logging/silent-logger");
|
|
19
|
+
Object.defineProperty(exports, "SilentLogger", { enumerable: true, get: function () { return silent_logger_1.SilentLogger; } });
|
|
20
|
+
var infrastructure_exception_1 = require("./exceptions/infrastructure.exception");
|
|
21
|
+
Object.defineProperty(exports, "InfrastructureException", { enumerable: true, get: function () { return infrastructure_exception_1.InfrastructureException; } });
|
|
22
|
+
var internal_error_exception_1 = require("./exceptions/internal-error.exception");
|
|
23
|
+
Object.defineProperty(exports, "InternalErrorException", { enumerable: true, get: function () { return internal_error_exception_1.InternalErrorException; } });
|
|
24
|
+
var unknown_event_exception_1 = require("./exceptions/unknown-event.exception");
|
|
25
|
+
Object.defineProperty(exports, "UnknownEventException", { enumerable: true, get: function () { return unknown_event_exception_1.UnknownEventException; } });
|
|
26
|
+
var event_delivery_exception_1 = require("./exceptions/event-delivery.exception");
|
|
27
|
+
Object.defineProperty(exports, "EventDeliveryException", { enumerable: true, get: function () { return event_delivery_exception_1.EventDeliveryException; } });
|
|
28
|
+
var infrastructure_exception_code_1 = require("./exceptions/infrastructure-exception-code");
|
|
29
|
+
Object.defineProperty(exports, "InfrastructureExceptionCode", { enumerable: true, get: function () { return infrastructure_exception_code_1.InfrastructureExceptionCode; } });
|
|
30
|
+
var exception_classifier_1 = require("./exceptions/kind/exception-classifier");
|
|
31
|
+
Object.defineProperty(exports, "ExceptionClassifier", { enumerable: true, get: function () { return exception_classifier_1.ExceptionClassifier; } });
|
|
32
|
+
var exception_kind_1 = require("./exceptions/kind/exception-kind");
|
|
33
|
+
Object.defineProperty(exports, "ExceptionKind", { enumerable: true, get: function () { return exception_kind_1.ExceptionKind; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Clock, LogContext, Logger, LogLevel } from '../../application/index';
|
|
2
|
+
export interface ConsoleLoggerOptions {
|
|
3
|
+
readonly level?: LogLevel;
|
|
4
|
+
readonly clock?: Clock;
|
|
5
|
+
}
|
|
6
|
+
export declare class ConsoleLogger implements Logger {
|
|
7
|
+
private static readonly levels;
|
|
8
|
+
private readonly output;
|
|
9
|
+
private readonly minimum;
|
|
10
|
+
private readonly clock;
|
|
11
|
+
constructor({ level, clock }?: ConsoleLoggerOptions);
|
|
12
|
+
debug(message: string, context?: LogContext): void;
|
|
13
|
+
info(message: string, context?: LogContext): void;
|
|
14
|
+
warn(message: string, context?: LogContext): void;
|
|
15
|
+
error(message: string, context?: LogContext): void;
|
|
16
|
+
private write;
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleLogger = void 0;
|
|
4
|
+
const internal_error_exception_1 = require("../exceptions/internal-error.exception");
|
|
5
|
+
const system_clock_1 = require("../clock/system-clock");
|
|
6
|
+
const log_serializer_1 = require("./log-serializer");
|
|
7
|
+
class ConsoleLogger {
|
|
8
|
+
constructor({ level = 'info', clock = new system_clock_1.SystemClock() } = {}) {
|
|
9
|
+
this.output = console;
|
|
10
|
+
this.minimum = ConsoleLogger.levels.indexOf(level);
|
|
11
|
+
if (this.minimum === -1) {
|
|
12
|
+
throw new internal_error_exception_1.InternalErrorException(`unknown log level "${String(level)}": use ${ConsoleLogger.levels.join(', ')}`);
|
|
13
|
+
}
|
|
14
|
+
this.clock = clock;
|
|
15
|
+
}
|
|
16
|
+
debug(message, context) {
|
|
17
|
+
this.write('debug', message, context);
|
|
18
|
+
}
|
|
19
|
+
info(message, context) {
|
|
20
|
+
this.write('info', message, context);
|
|
21
|
+
}
|
|
22
|
+
warn(message, context) {
|
|
23
|
+
this.write('warn', message, context);
|
|
24
|
+
}
|
|
25
|
+
error(message, context) {
|
|
26
|
+
this.write('error', message, context);
|
|
27
|
+
}
|
|
28
|
+
write(level, message, context) {
|
|
29
|
+
if (ConsoleLogger.levels.indexOf(level) < this.minimum) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const entry = { time: this.clock.now().toISOString(), level, message };
|
|
33
|
+
this.output[level](log_serializer_1.LogSerializer.line(entry, context));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
37
|
+
ConsoleLogger.levels = ['debug', 'info', 'warn', 'error'];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LogContext, Logger, LogLevel } from '../../application/index';
|
|
2
|
+
export interface LogEntry {
|
|
3
|
+
readonly level: LogLevel;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly context?: LogContext;
|
|
6
|
+
}
|
|
7
|
+
export declare class InMemoryLogger implements Logger {
|
|
8
|
+
private readonly recorded;
|
|
9
|
+
get entries(): readonly LogEntry[];
|
|
10
|
+
debug(message: string, context?: LogContext): void;
|
|
11
|
+
info(message: string, context?: LogContext): void;
|
|
12
|
+
warn(message: string, context?: LogContext): void;
|
|
13
|
+
error(message: string, context?: LogContext): void;
|
|
14
|
+
private record;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryLogger = void 0;
|
|
4
|
+
class InMemoryLogger {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.recorded = [];
|
|
7
|
+
}
|
|
8
|
+
get entries() {
|
|
9
|
+
return [...this.recorded];
|
|
10
|
+
}
|
|
11
|
+
debug(message, context) {
|
|
12
|
+
this.record('debug', message, context);
|
|
13
|
+
}
|
|
14
|
+
info(message, context) {
|
|
15
|
+
this.record('info', message, context);
|
|
16
|
+
}
|
|
17
|
+
warn(message, context) {
|
|
18
|
+
this.record('warn', message, context);
|
|
19
|
+
}
|
|
20
|
+
error(message, context) {
|
|
21
|
+
this.record('error', message, context);
|
|
22
|
+
}
|
|
23
|
+
record(level, message, context) {
|
|
24
|
+
this.recorded.push(context === undefined ? { level, message } : { level, message, context });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.InMemoryLogger = InMemoryLogger;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LogContext } from '../../application/index';
|
|
2
|
+
export declare class LogSerializer {
|
|
3
|
+
static line(entry: Readonly<Record<string, string>>, context: LogContext | undefined): string;
|
|
4
|
+
private static plain;
|
|
5
|
+
private static plainObject;
|
|
6
|
+
private static plainError;
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogSerializer = void 0;
|
|
4
|
+
class LogSerializer {
|
|
5
|
+
static line(entry, context) {
|
|
6
|
+
if (context === undefined) {
|
|
7
|
+
return JSON.stringify(entry);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
return JSON.stringify({ ...entry, context: LogSerializer.plain(context, new Set()) });
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return JSON.stringify({ ...entry, context: '[Unserializable]' });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
static plain(value, ancestors) {
|
|
17
|
+
if (typeof value === 'bigint') {
|
|
18
|
+
return value.toString();
|
|
19
|
+
}
|
|
20
|
+
if (typeof value !== 'object' || value === null) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
if (ancestors.has(value)) {
|
|
24
|
+
return '[Circular]';
|
|
25
|
+
}
|
|
26
|
+
ancestors.add(value);
|
|
27
|
+
try {
|
|
28
|
+
return LogSerializer.plainObject(value, ancestors);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
ancestors.delete(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
static plainObject(value, ancestors) {
|
|
35
|
+
if (value instanceof Error) {
|
|
36
|
+
return LogSerializer.plainError(value, ancestors);
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
return value.map((item) => LogSerializer.plain(item, ancestors));
|
|
40
|
+
}
|
|
41
|
+
const { toJSON } = value;
|
|
42
|
+
if (typeof toJSON === 'function') {
|
|
43
|
+
return LogSerializer.plain(toJSON.call(value), ancestors);
|
|
44
|
+
}
|
|
45
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, LogSerializer.plain(item, ancestors)]));
|
|
46
|
+
}
|
|
47
|
+
static plainError(error, ancestors) {
|
|
48
|
+
const { code, errors, cause } = error;
|
|
49
|
+
return {
|
|
50
|
+
name: error.name,
|
|
51
|
+
message: error.message,
|
|
52
|
+
...(typeof code === 'string' ? { code } : {}),
|
|
53
|
+
...(Array.isArray(errors) ? { errors: LogSerializer.plain(errors, ancestors) } : {}),
|
|
54
|
+
...(error.stack === undefined ? {} : { stack: error.stack }),
|
|
55
|
+
...(cause === undefined ? {} : { cause: LogSerializer.plain(cause, ancestors) }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.LogSerializer = LogSerializer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SilentLogger = void 0;
|
|
4
|
+
class SilentLogger {
|
|
5
|
+
debug() {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
info() {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
warn() {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
error() {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SilentLogger = SilentLogger;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ExceptionOptions {
|
|
2
|
+
cause?: unknown;
|
|
3
|
+
}
|
|
4
|
+
export type ExceptionCodeNames = Readonly<Record<string, string>>;
|
|
5
|
+
export declare abstract class AbstractException extends Error {
|
|
6
|
+
private static readonly fallbackCode;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
private readonly exceptionCodes;
|
|
9
|
+
private readonly codeNames;
|
|
10
|
+
readonly code: string;
|
|
11
|
+
private readonly createdAt;
|
|
12
|
+
static [Symbol.hasInstance](candidate: unknown): boolean;
|
|
13
|
+
constructor(message: string, exceptionCodes: string[], options?: ExceptionOptions, codeNames?: ExceptionCodeNames);
|
|
14
|
+
get timestamp(): Date;
|
|
15
|
+
get description(): string;
|
|
16
|
+
private labelOf;
|
|
17
|
+
print(): string;
|
|
18
|
+
toJSON(): {
|
|
19
|
+
name: string;
|
|
20
|
+
message: string;
|
|
21
|
+
code: string;
|
|
22
|
+
description: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AbstractException = void 0;
|
|
5
|
+
const exception_brand_1 = require("./brand/exception-brand");
|
|
6
|
+
class AbstractException extends Error {
|
|
7
|
+
static [Symbol.hasInstance](candidate) {
|
|
8
|
+
return (Function.prototype[Symbol.hasInstance].call(this, candidate) ||
|
|
9
|
+
exception_brand_1.ExceptionBrand.matches(this, candidate));
|
|
10
|
+
}
|
|
11
|
+
constructor(message, exceptionCodes, options = {}, codeNames = {}) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
this.exceptionCodes = exceptionCodes;
|
|
15
|
+
this.codeNames = codeNames;
|
|
16
|
+
this.code =
|
|
17
|
+
exceptionCodes.length > 0
|
|
18
|
+
? exceptionCodes[exceptionCodes.length - 1]
|
|
19
|
+
: _a.fallbackCode;
|
|
20
|
+
this.createdAt = Date.now();
|
|
21
|
+
if ('cause' in options) {
|
|
22
|
+
Object.defineProperty(this, 'cause', {
|
|
23
|
+
value: options.cause,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exception_brand_1.ExceptionBrand.brandInstance(this, exceptionCodes);
|
|
29
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
30
|
+
}
|
|
31
|
+
get timestamp() {
|
|
32
|
+
return new Date(this.createdAt);
|
|
33
|
+
}
|
|
34
|
+
get description() {
|
|
35
|
+
return this.exceptionCodes.map((code) => `${this.labelOf(code)} (${code})`).join(', ');
|
|
36
|
+
}
|
|
37
|
+
labelOf(code) {
|
|
38
|
+
const name = Object.keys(this.codeNames).find((key) => this.codeNames[key] === code);
|
|
39
|
+
return name === undefined ? this.name : name.replace(/([A-Z])/g, ' $1').trim();
|
|
40
|
+
}
|
|
41
|
+
print() {
|
|
42
|
+
return `[${this.description}]: ${this.message}, ${this.timestamp.toISOString()}`;
|
|
43
|
+
}
|
|
44
|
+
toJSON() {
|
|
45
|
+
return {
|
|
46
|
+
name: this.name,
|
|
47
|
+
message: this.message,
|
|
48
|
+
code: this.code,
|
|
49
|
+
description: this.description,
|
|
50
|
+
timestamp: this.timestamp.toISOString(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.AbstractException = AbstractException;
|
|
55
|
+
_a = AbstractException;
|
|
56
|
+
AbstractException.fallbackCode = 'E000';
|
|
57
|
+
(() => {
|
|
58
|
+
exception_brand_1.ExceptionBrand.brandClass(_a, exception_brand_1.ExceptionBrand.anyCode);
|
|
59
|
+
})();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class ExceptionBrand {
|
|
2
|
+
static readonly anyCode = "*";
|
|
3
|
+
static brandClass(exceptionClass: object, code: string): void;
|
|
4
|
+
static brandInstance(exception: object, codes: readonly string[]): void;
|
|
5
|
+
static matches(exceptionClass: object, candidate: unknown): boolean;
|
|
6
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionBrand = void 0;
|
|
4
|
+
const INSTANCE_CODES = Symbol.for('@archi-code/ddd/exception-codes.v1');
|
|
5
|
+
const CLASS_CODE = Symbol.for('@archi-code/ddd/exception-class-code.v1');
|
|
6
|
+
class ExceptionBrand {
|
|
7
|
+
static brandClass(exceptionClass, code) {
|
|
8
|
+
Object.defineProperty(exceptionClass, CLASS_CODE, { value: code });
|
|
9
|
+
}
|
|
10
|
+
static brandInstance(exception, codes) {
|
|
11
|
+
Object.defineProperty(exception, INSTANCE_CODES, { value: Object.freeze([...codes]) });
|
|
12
|
+
}
|
|
13
|
+
static matches(exceptionClass, candidate) {
|
|
14
|
+
if (!Object.prototype.hasOwnProperty.call(exceptionClass, CLASS_CODE)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (typeof candidate !== 'object' || candidate === null) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const codes = candidate[INSTANCE_CODES];
|
|
21
|
+
if (!Array.isArray(codes)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const code = exceptionClass[CLASS_CODE];
|
|
25
|
+
return code === ExceptionBrand.anyCode || codes.includes(code);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ExceptionBrand = ExceptionBrand;
|
|
29
|
+
ExceptionBrand.anyCode = '*';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReceivedValue = void 0;
|
|
4
|
+
const validation_1 = require("@archi-code/validation");
|
|
5
|
+
class ReceivedValue {
|
|
6
|
+
static describe(value) {
|
|
7
|
+
const text = typeof value === 'string' ? value : (0, validation_1.anyToString)(value);
|
|
8
|
+
const shown = text.length > ReceivedValue.maxLength ? `${text.slice(0, ReceivedValue.maxLength)}…` : text;
|
|
9
|
+
return typeof value === 'string' ? `"${shown}"` : shown;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ReceivedValue = ReceivedValue;
|
|
13
|
+
ReceivedValue.maxLength = 64;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AbstractException } from './exceptions/abstract.exception';
|
|
2
|
+
export type { ExceptionCodeNames, ExceptionOptions } from './exceptions/abstract.exception';
|
|
3
|
+
export { ExceptionBrand } from './exceptions/brand/exception-brand';
|
|
4
|
+
export { ReceivedValue } from './exceptions/received/received-value';
|
|
5
|
+
export { IssueCollector } from './issue-collector';
|
|
6
|
+
export type { IssueReader } from './issue-collector';
|
|
7
|
+
export { IssueCollectionError } from './issue-collection-error';
|
|
8
|
+
export type { CollectedIssue } from './issue-collection-error';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IssueCollectionError = exports.IssueCollector = exports.ReceivedValue = exports.ExceptionBrand = exports.AbstractException = void 0;
|
|
4
|
+
var abstract_exception_1 = require("./exceptions/abstract.exception");
|
|
5
|
+
Object.defineProperty(exports, "AbstractException", { enumerable: true, get: function () { return abstract_exception_1.AbstractException; } });
|
|
6
|
+
var exception_brand_1 = require("./exceptions/brand/exception-brand");
|
|
7
|
+
Object.defineProperty(exports, "ExceptionBrand", { enumerable: true, get: function () { return exception_brand_1.ExceptionBrand; } });
|
|
8
|
+
var received_value_1 = require("./exceptions/received/received-value");
|
|
9
|
+
Object.defineProperty(exports, "ReceivedValue", { enumerable: true, get: function () { return received_value_1.ReceivedValue; } });
|
|
10
|
+
var issue_collector_1 = require("./issue-collector");
|
|
11
|
+
Object.defineProperty(exports, "IssueCollector", { enumerable: true, get: function () { return issue_collector_1.IssueCollector; } });
|
|
12
|
+
var issue_collection_error_1 = require("./issue-collection-error");
|
|
13
|
+
Object.defineProperty(exports, "IssueCollectionError", { enumerable: true, get: function () { return issue_collection_error_1.IssueCollectionError; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CollectedIssue {
|
|
2
|
+
readonly field: string | null;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class IssueCollectionError extends Error {
|
|
7
|
+
readonly issues: readonly CollectedIssue[];
|
|
8
|
+
constructor(issues: readonly CollectedIssue[]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IssueCollectionError = void 0;
|
|
4
|
+
class IssueCollectionError extends Error {
|
|
5
|
+
constructor(issues) {
|
|
6
|
+
super(`${issues.length} issues collected`);
|
|
7
|
+
this.name = 'IssueCollectionError';
|
|
8
|
+
this.issues = Object.freeze([...issues]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.IssueCollectionError = IssueCollectionError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CollectedIssue } from './issue-collection-error';
|
|
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,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IssueCollector = void 0;
|
|
4
|
+
const issue_collection_error_1 = require("./issue-collection-error");
|
|
5
|
+
class IssueCollector {
|
|
6
|
+
static collectFields(builds, readIssues) {
|
|
7
|
+
return Object.fromEntries(IssueCollector.collect(Object.entries(builds), readIssues));
|
|
8
|
+
}
|
|
9
|
+
static collectItems(items, build, readIssues) {
|
|
10
|
+
const builds = items.map((item, index) => [String(index), () => build(item, index)]);
|
|
11
|
+
return IssueCollector.collect(builds, readIssues).map(([, built]) => built);
|
|
12
|
+
}
|
|
13
|
+
static collect(builds, readIssues) {
|
|
14
|
+
const built = [];
|
|
15
|
+
const issues = [];
|
|
16
|
+
for (const [path, build] of builds) {
|
|
17
|
+
try {
|
|
18
|
+
built.push([path, build()]);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
issues.push(...IssueCollector.issuesAt(path, error, readIssues));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (issues.length > 0) {
|
|
25
|
+
throw new issue_collection_error_1.IssueCollectionError(issues);
|
|
26
|
+
}
|
|
27
|
+
return built;
|
|
28
|
+
}
|
|
29
|
+
static issuesAt(path, error, readIssues) {
|
|
30
|
+
const issues = readIssues(error);
|
|
31
|
+
if (issues === null) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
return issues.map((issue) => ({
|
|
35
|
+
field: issue.field === null ? path : `${path}.${issue.field}`,
|
|
36
|
+
code: issue.code,
|
|
37
|
+
message: issue.message,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.IssueCollector = IssueCollector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventBase, EventClass } from '../../domain/index.js';
|
|
2
|
+
import type { EventListener } from './event-listener.js';
|
|
3
|
+
type ListenerClass<Event extends EventBase> = abstract new (...args: any[]) => EventListener<Event>;
|
|
4
|
+
export interface ListensToOptions {
|
|
5
|
+
readonly consumer: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ListenerSubscription {
|
|
8
|
+
readonly eventName: string;
|
|
9
|
+
readonly consumer: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function ListensTo<Event extends EventBase>(event: EventClass<Event>, options: ListensToOptions): (listener: ListenerClass<Event>) => void;
|
|
12
|
+
export declare namespace ListensTo {
|
|
13
|
+
var subscriptionOf: (listener: EventListener<any>) => ListenerSubscription;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApplicationException } from '../exceptions/application.exception.js';
|
|
2
|
+
const LISTENED_EVENT = Symbol.for('@archi-code/ddd/listens-to.v1');
|
|
3
|
+
export function ListensTo(event, options) {
|
|
4
|
+
return (listener) => {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(listener, LISTENED_EVENT)) {
|
|
6
|
+
throw new ApplicationException(`${listener.name} already listens to an event`);
|
|
7
|
+
}
|
|
8
|
+
const consumer = options?.consumer;
|
|
9
|
+
if (typeof consumer !== 'string' || consumer.trim() === '') {
|
|
10
|
+
throw new ApplicationException(`${listener.name} needs a consumer name: @ListensTo(<event class>, { consumer: '<name>' })`);
|
|
11
|
+
}
|
|
12
|
+
const subscription = Object.freeze({
|
|
13
|
+
eventName: event.eventName,
|
|
14
|
+
consumer,
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(listener, LISTENED_EVENT, { value: subscription });
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
ListensTo.subscriptionOf = (listener) => {
|
|
20
|
+
const listenerClass = listener.constructor;
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(listenerClass, LISTENED_EVENT)) {
|
|
22
|
+
throw new ApplicationException(`${listenerClass.name} needs @ListensTo(<event class>, { consumer: '<name>' })`);
|
|
23
|
+
}
|
|
24
|
+
return listenerClass[LISTENED_EVENT];
|
|
25
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
2
|
+
import { ApplicationException } from './application.exception.js';
|
|
3
|
+
export declare class AggregateNotFoundException extends ApplicationException {
|
|
4
|
+
constructor(entity: string, id: string, options?: ExceptionOptions);
|
|
5
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { ApplicationExceptionCode } from './application-exception-code.js';
|
|
4
|
+
import { ApplicationException } from './application.exception.js';
|
|
5
|
+
export class AggregateNotFoundException extends ApplicationException {
|
|
6
|
+
constructor(entity, id, options = {}) {
|
|
7
|
+
super(`${entity} with ID ${id} not found.`, [ApplicationExceptionCode.AggregateNotFound], options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = AggregateNotFoundException;
|
|
11
|
+
(() => {
|
|
12
|
+
ExceptionBrand.brandClass(_a, ApplicationExceptionCode.AggregateNotFound);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var ApplicationExceptionCode;
|
|
2
|
+
(function (ApplicationExceptionCode) {
|
|
3
|
+
ApplicationExceptionCode["ApplicationException"] = "APP000";
|
|
4
|
+
ApplicationExceptionCode["ConcurrencyConflict"] = "APP001";
|
|
5
|
+
ApplicationExceptionCode["AggregateNotFound"] = "APP002";
|
|
6
|
+
ApplicationExceptionCode["NotAllowed"] = "APP003";
|
|
7
|
+
ApplicationExceptionCode["UnexpectedError"] = "APP004";
|
|
8
|
+
})(ApplicationExceptionCode || (ApplicationExceptionCode = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractException } from '../../shared/index.js';
|
|
2
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
3
|
+
import { ApplicationExceptionCode } from './application-exception-code.js';
|
|
4
|
+
export declare class ApplicationException extends AbstractException {
|
|
5
|
+
constructor(message: string, exceptionCodes?: (ApplicationExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { AbstractException, ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { ApplicationExceptionCode } from './application-exception-code.js';
|
|
4
|
+
export class ApplicationException extends AbstractException {
|
|
5
|
+
constructor(message, exceptionCodes = [], options = {}) {
|
|
6
|
+
super(message, [ApplicationExceptionCode.ApplicationException, ...exceptionCodes], options, ApplicationExceptionCode);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
_a = ApplicationException;
|
|
10
|
+
(() => {
|
|
11
|
+
ExceptionBrand.brandClass(_a, ApplicationExceptionCode.ApplicationException);
|
|
12
|
+
})();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
2
|
+
import { ApplicationException } from './application.exception.js';
|
|
3
|
+
export declare class ConcurrencyException extends ApplicationException {
|
|
4
|
+
constructor(aggregateName: string, id: string, expectedVersion: number, options?: ExceptionOptions);
|
|
5
|
+
}
|