@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
|
+
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 ConcurrencyException extends ApplicationException {
|
|
6
|
+
constructor(aggregateName, id, expectedVersion, options = {}) {
|
|
7
|
+
super(`${aggregateName} with ID ${id} was changed by someone else: expected version ${expectedVersion}.`, [ApplicationExceptionCode.ConcurrencyConflict], options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = ConcurrencyException;
|
|
11
|
+
(() => {
|
|
12
|
+
ExceptionBrand.brandClass(_a, ApplicationExceptionCode.ConcurrencyConflict);
|
|
13
|
+
})();
|
|
@@ -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 NotAllowedException extends ApplicationException {
|
|
6
|
+
constructor(message, options = {}) {
|
|
7
|
+
super(message, [ApplicationExceptionCode.NotAllowed], options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = NotAllowedException;
|
|
11
|
+
(() => {
|
|
12
|
+
ExceptionBrand.brandClass(_a, ApplicationExceptionCode.NotAllowed);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
2
|
+
import { ApplicationException } from './application.exception.js';
|
|
3
|
+
export declare class UnexpectedErrorException extends ApplicationException {
|
|
4
|
+
constructor(message: 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 UnexpectedErrorException extends ApplicationException {
|
|
6
|
+
constructor(message, options = {}) {
|
|
7
|
+
super(`Failed, unexpected error: ${message}`, [ApplicationExceptionCode.UnexpectedError], options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = UnexpectedErrorException;
|
|
11
|
+
(() => {
|
|
12
|
+
ExceptionBrand.brandClass(_a, ApplicationExceptionCode.UnexpectedError);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { UseCase } from './use-case/use-case.js';
|
|
2
|
+
export { ValueObjectBuilder } from './value-object-builder/value-object-builder.js';
|
|
3
|
+
export { EventListener } from './event/event-listener.js';
|
|
4
|
+
export { ListensTo } from './event/listens-to.js';
|
|
5
|
+
export type { ListenerSubscription, ListensToOptions } from './event/listens-to.js';
|
|
6
|
+
export type { EventBus } from './event/event-bus.js';
|
|
7
|
+
export type { Clock } from './ports/clock.js';
|
|
8
|
+
export type { LogContext, Logger, LogLevel } from './ports/logger.js';
|
|
9
|
+
export { ApplicationException } from './exceptions/application.exception.js';
|
|
10
|
+
export { ConcurrencyException } from './exceptions/concurrency.exception.js';
|
|
11
|
+
export { AggregateNotFoundException } from './exceptions/aggregate-not-found.exception.js';
|
|
12
|
+
export { NotAllowedException } from './exceptions/not-allowed.exception.js';
|
|
13
|
+
export { UnexpectedErrorException } from './exceptions/unexpected-error.exception.js';
|
|
14
|
+
export { ApplicationExceptionCode } from './exceptions/application-exception-code.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { UseCase } from './use-case/use-case.js';
|
|
2
|
+
export { ValueObjectBuilder } from './value-object-builder/value-object-builder.js';
|
|
3
|
+
export { EventListener } from './event/event-listener.js';
|
|
4
|
+
export { ListensTo } from './event/listens-to.js';
|
|
5
|
+
export { ApplicationException } from './exceptions/application.exception.js';
|
|
6
|
+
export { ConcurrencyException } from './exceptions/concurrency.exception.js';
|
|
7
|
+
export { AggregateNotFoundException } from './exceptions/aggregate-not-found.exception.js';
|
|
8
|
+
export { NotAllowedException } from './exceptions/not-allowed.exception.js';
|
|
9
|
+
export { UnexpectedErrorException } from './exceptions/unexpected-error.exception.js';
|
|
10
|
+
export { ApplicationExceptionCode } from './exceptions/application-exception-code.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export type LogContext = Readonly<Record<string, unknown>>;
|
|
3
|
+
export interface Logger {
|
|
4
|
+
debug(message: string, context?: LogContext): void;
|
|
5
|
+
info(message: string, context?: LogContext): void;
|
|
6
|
+
warn(message: string, context?: LogContext): void;
|
|
7
|
+
error(message: string, context?: LogContext): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { anyToString } from '@archi-code/validation';
|
|
2
|
+
import { AbstractException } from '../../shared/index.js';
|
|
3
|
+
import { UnexpectedErrorException } from '../exceptions/unexpected-error.exception.js';
|
|
4
|
+
export class UseCase {
|
|
5
|
+
async execute(input) {
|
|
6
|
+
try {
|
|
7
|
+
return await this.handle(this.toCommand(input));
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof AbstractException) {
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
throw new UnexpectedErrorException(`${this.constructor.name}: ${UseCase.describe(error)}`, {
|
|
14
|
+
cause: error,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
static describe(error) {
|
|
19
|
+
return error instanceof Error ? error.message : anyToString(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Factories = Record<string, () => unknown>;
|
|
2
|
+
type Built<F extends Factories> = {
|
|
3
|
+
[Field in keyof F]: ReturnType<F[Field]>;
|
|
4
|
+
};
|
|
5
|
+
type Synchronous<F extends Factories> = {
|
|
6
|
+
[Field in keyof F]: [ReturnType<F[Field]>] extends [never] ? F[Field] : [ReturnType<F[Field]>] extends [PromiseLike<unknown>] ? never : F[Field];
|
|
7
|
+
};
|
|
8
|
+
export declare class ValueObjectBuilder {
|
|
9
|
+
static build<F extends Factories>(factories: F & Synchronous<F>): Built<F>;
|
|
10
|
+
static buildList<Value, Item>(values: readonly Value[], factory: (value: Value, index: number) => Item): Item[];
|
|
11
|
+
private static synchronous;
|
|
12
|
+
private static validated;
|
|
13
|
+
private static read;
|
|
14
|
+
private static isThenable;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DomainException, ValidationException } from '../../domain/index.js';
|
|
2
|
+
import { IssueCollectionError, IssueCollector } from '../../shared/index.js';
|
|
3
|
+
import { UnexpectedErrorException } from '../exceptions/unexpected-error.exception.js';
|
|
4
|
+
export class ValueObjectBuilder {
|
|
5
|
+
static build(factories) {
|
|
6
|
+
const builds = Object.fromEntries(Object.entries(factories).map(([field, factory]) => [
|
|
7
|
+
field,
|
|
8
|
+
() => ValueObjectBuilder.synchronous(field, factory()),
|
|
9
|
+
]));
|
|
10
|
+
return ValueObjectBuilder.validated(() => IssueCollector.collectFields(builds, ValueObjectBuilder.read));
|
|
11
|
+
}
|
|
12
|
+
static buildList(values, factory) {
|
|
13
|
+
return ValueObjectBuilder.validated(() => IssueCollector.collectItems(values, (value, index) => ValueObjectBuilder.synchronous(String(index), factory(value, index)), ValueObjectBuilder.read));
|
|
14
|
+
}
|
|
15
|
+
static synchronous(field, result) {
|
|
16
|
+
if (!ValueObjectBuilder.isThenable(result)) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
result.then(undefined, () => undefined);
|
|
20
|
+
throw new UnexpectedErrorException(`ValueObjectBuilder: the factory of "${field}" returned a Promise; build value objects synchronously`);
|
|
21
|
+
}
|
|
22
|
+
static validated(collect) {
|
|
23
|
+
try {
|
|
24
|
+
return collect();
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof IssueCollectionError) {
|
|
28
|
+
throw new ValidationException(error.issues);
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static read(error) {
|
|
34
|
+
if (error instanceof ValidationException) {
|
|
35
|
+
return error.errors;
|
|
36
|
+
}
|
|
37
|
+
if (error instanceof DomainException) {
|
|
38
|
+
return [{ field: null, code: error.code, message: error.message }];
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
static isThenable(result) {
|
|
43
|
+
return ((typeof result === 'object' || typeof result === 'function') &&
|
|
44
|
+
result !== null &&
|
|
45
|
+
typeof result.then === 'function');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Entity } from '../entity/entity.js';
|
|
2
|
+
import type { EntityId } from '../entity/entity.js';
|
|
3
|
+
import type { EventBase } from '../event/event-base.js';
|
|
4
|
+
import type { IdType } from '../type/id-type.js';
|
|
5
|
+
export declare abstract class AggregateRoot<Id extends EntityId = IdType, Event extends EventBase = EventBase> extends Entity<Id> {
|
|
6
|
+
private readonly domainEvents;
|
|
7
|
+
protected record(event: Event): void;
|
|
8
|
+
pullDomainEvents(): Event[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Entity } from '../entity/entity.js';
|
|
2
|
+
export class AggregateRoot extends Entity {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.domainEvents = [];
|
|
6
|
+
}
|
|
7
|
+
record(event) {
|
|
8
|
+
this.domainEvents.push(event);
|
|
9
|
+
}
|
|
10
|
+
pullDomainEvents() {
|
|
11
|
+
return this.domainEvents.splice(0);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AbstractType } from '../type/abstract-type.js';
|
|
2
|
+
import type { IdType } from '../type/id-type.js';
|
|
3
|
+
import type { RequiredMarked } from '../type/required/required-mark.js';
|
|
4
|
+
export type EntityId = AbstractType<any> & RequiredMarked;
|
|
5
|
+
export declare abstract class Entity<Id extends EntityId = IdType> {
|
|
6
|
+
readonly id: Id;
|
|
7
|
+
constructor(id: Id);
|
|
8
|
+
equals(other: unknown): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RequiredValueException } from '../exceptions/required-value.exception.js';
|
|
2
|
+
export class Entity {
|
|
3
|
+
constructor(id) {
|
|
4
|
+
this.id = id;
|
|
5
|
+
if (id?.isNull !== false) {
|
|
6
|
+
throw new RequiredValueException(`${new.target.name}.id`, id?.value);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
equals(other) {
|
|
10
|
+
return (typeof other === 'object' &&
|
|
11
|
+
other !== null &&
|
|
12
|
+
other.constructor === this.constructor &&
|
|
13
|
+
this.id.equals(other.id));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface EventMetadata {
|
|
2
|
+
eventId?: string;
|
|
3
|
+
occurredOn?: Date | string;
|
|
4
|
+
clock?: {
|
|
5
|
+
now(): Date;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface SerializedEvent {
|
|
9
|
+
eventName: string;
|
|
10
|
+
eventId: string;
|
|
11
|
+
occurredOn: string;
|
|
12
|
+
[payload: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface EventClass<Event extends EventBase = EventBase> {
|
|
15
|
+
readonly eventName: string;
|
|
16
|
+
new (...args: any[]): Event;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class EventBase {
|
|
19
|
+
readonly eventName: string;
|
|
20
|
+
readonly eventId: string;
|
|
21
|
+
readonly occurredOn: string;
|
|
22
|
+
constructor(metadata?: EventMetadata);
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CreatedAt } from '../type/date-type.js';
|
|
2
|
+
import { IdType } from '../type/id-type.js';
|
|
3
|
+
import { UuidType } from '../type/uuid-type.js';
|
|
4
|
+
import { InvalidEventDefinitionException } from '../exceptions/invalid-event-definition.exception.js';
|
|
5
|
+
export class EventBase {
|
|
6
|
+
constructor(metadata = {}) {
|
|
7
|
+
const { eventName } = this.constructor;
|
|
8
|
+
if (typeof eventName !== 'string' || eventName.trim() === '') {
|
|
9
|
+
throw new InvalidEventDefinitionException(this.constructor.name);
|
|
10
|
+
}
|
|
11
|
+
this.eventName = eventName;
|
|
12
|
+
this.eventId = new IdType(metadata.eventId ?? UuidType.random()).value;
|
|
13
|
+
this.occurredOn = (metadata.occurredOn === undefined
|
|
14
|
+
? CreatedAt.now(metadata.clock)
|
|
15
|
+
: new CreatedAt(metadata.occurredOn)).value.toISOString();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var DomainExceptionCode;
|
|
2
|
+
(function (DomainExceptionCode) {
|
|
3
|
+
DomainExceptionCode["DomainException"] = "DOM000";
|
|
4
|
+
DomainExceptionCode["ValidationFailed"] = "DOM001";
|
|
5
|
+
DomainExceptionCode["TypeFailed"] = "DOM003";
|
|
6
|
+
DomainExceptionCode["RequiredValue"] = "DOM004";
|
|
7
|
+
DomainExceptionCode["InvalidEventDefinition"] = "DOM005";
|
|
8
|
+
})(DomainExceptionCode || (DomainExceptionCode = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractException } from '../../shared/index.js';
|
|
2
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
export declare class DomainException extends AbstractException {
|
|
5
|
+
constructor(message: string, exceptionCodes?: (DomainExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { AbstractException, ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
export class DomainException extends AbstractException {
|
|
5
|
+
constructor(message, exceptionCodes = [], options = {}) {
|
|
6
|
+
super(message, [DomainExceptionCode.DomainException, ...exceptionCodes], options, DomainExceptionCode);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
_a = DomainException;
|
|
10
|
+
(() => {
|
|
11
|
+
ExceptionBrand.brandClass(_a, DomainExceptionCode.DomainException);
|
|
12
|
+
})();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
import { DomainException } from './domain.exception.js';
|
|
5
|
+
export class InvalidEventDefinitionException extends DomainException {
|
|
6
|
+
constructor(eventClassName) {
|
|
7
|
+
super(`${eventClassName} must declare a static eventName`, [
|
|
8
|
+
DomainExceptionCode.InvalidEventDefinition,
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
_a = InvalidEventDefinitionException;
|
|
13
|
+
(() => {
|
|
14
|
+
ExceptionBrand.brandClass(_a, DomainExceptionCode.InvalidEventDefinition);
|
|
15
|
+
})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand, ReceivedValue } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
import { DomainException } from './domain.exception.js';
|
|
5
|
+
export class RequiredValueException extends DomainException {
|
|
6
|
+
constructor(typeName, receivedValue) {
|
|
7
|
+
const received = ReceivedValue.describe(receivedValue);
|
|
8
|
+
super(`Validation Error: ${typeName} is required, but received ${received}.`, [
|
|
9
|
+
DomainExceptionCode.RequiredValue,
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
_a = RequiredValueException;
|
|
14
|
+
(() => {
|
|
15
|
+
ExceptionBrand.brandClass(_a, DomainExceptionCode.RequiredValue);
|
|
16
|
+
})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand, ReceivedValue } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
import { DomainException } from './domain.exception.js';
|
|
5
|
+
export class TypePrimitiveException extends DomainException {
|
|
6
|
+
constructor(expectedType, receivedValue, template = 'Expected a valid ') {
|
|
7
|
+
const received = ReceivedValue.describe(receivedValue);
|
|
8
|
+
super(`Validation Error: ${template}${expectedType}, but received ${received}.`, [
|
|
9
|
+
DomainExceptionCode.TypeFailed,
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
_a = TypePrimitiveException;
|
|
14
|
+
(() => {
|
|
15
|
+
ExceptionBrand.brandClass(_a, DomainExceptionCode.TypeFailed);
|
|
16
|
+
})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DomainException } from './domain.exception.js';
|
|
2
|
+
export interface ValidationIssue {
|
|
3
|
+
readonly field: string | null;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
}
|
|
7
|
+
export type ValidationIssueInput = Omit<ValidationIssue, 'code'> & {
|
|
8
|
+
readonly code?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class ValidationException extends DomainException {
|
|
11
|
+
readonly errors: readonly ValidationIssue[];
|
|
12
|
+
constructor(errors: readonly ValidationIssueInput[]);
|
|
13
|
+
private static describe;
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { DomainExceptionCode } from './domain-exception-code.js';
|
|
4
|
+
import { DomainException } from './domain.exception.js';
|
|
5
|
+
export class ValidationException extends DomainException {
|
|
6
|
+
constructor(errors) {
|
|
7
|
+
super(`Validation failed, ${errors.map(_a.describe).join(', ')}`, [
|
|
8
|
+
DomainExceptionCode.ValidationFailed,
|
|
9
|
+
]);
|
|
10
|
+
this.errors = Object.freeze(errors.map(({ field, code = DomainExceptionCode.ValidationFailed, message }) => Object.freeze({ field, code, message })));
|
|
11
|
+
}
|
|
12
|
+
static describe(issue) {
|
|
13
|
+
return issue.field === null ? issue.message : `${issue.field}: ${issue.message}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
_a = ValidationException;
|
|
17
|
+
(() => {
|
|
18
|
+
ExceptionBrand.brandClass(_a, DomainExceptionCode.ValidationFailed);
|
|
19
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './event/event-base.js';
|
|
2
|
+
export * from './entity/entity.js';
|
|
3
|
+
export * from './aggregate/aggregate-root.js';
|
|
4
|
+
export * from './type/index.js';
|
|
5
|
+
export * from './primitive/primitive-types.js';
|
|
6
|
+
export type { AggregateFinder } from './repository/aggregate-finder.js';
|
|
7
|
+
export type { AggregateSaver } from './repository/aggregate-saver.js';
|
|
8
|
+
export type { AggregateRemover } from './repository/aggregate-remover.js';
|
|
9
|
+
export { Specification } from './specification/specification.js';
|
|
10
|
+
export type { SatisfiedBy } from './specification/specification.js';
|
|
11
|
+
export { DomainException } from './exceptions/domain.exception.js';
|
|
12
|
+
export { ValidationException } from './exceptions/validation.exception.js';
|
|
13
|
+
export type { ValidationIssue, ValidationIssueInput } from './exceptions/validation.exception.js';
|
|
14
|
+
export { TypePrimitiveException } from './exceptions/type-primitive.exception.js';
|
|
15
|
+
export { RequiredValueException } from './exceptions/required-value.exception.js';
|
|
16
|
+
export { InvalidEventDefinitionException } from './exceptions/invalid-event-definition.exception.js';
|
|
17
|
+
export { DomainExceptionCode } from './exceptions/domain-exception-code.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './event/event-base.js';
|
|
2
|
+
export * from './entity/entity.js';
|
|
3
|
+
export * from './aggregate/aggregate-root.js';
|
|
4
|
+
export * from './type/index.js';
|
|
5
|
+
export * from './primitive/primitive-types.js';
|
|
6
|
+
export { Specification } from './specification/specification.js';
|
|
7
|
+
export { DomainException } from './exceptions/domain.exception.js';
|
|
8
|
+
export { ValidationException } from './exceptions/validation.exception.js';
|
|
9
|
+
export { TypePrimitiveException } from './exceptions/type-primitive.exception.js';
|
|
10
|
+
export { RequiredValueException } from './exceptions/required-value.exception.js';
|
|
11
|
+
export { InvalidEventDefinitionException } from './exceptions/invalid-event-definition.exception.js';
|
|
12
|
+
export { DomainExceptionCode } from './exceptions/domain-exception-code.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AbstractType } from '../type/abstract-type.js';
|
|
2
|
+
export type Methods<T> = {
|
|
3
|
+
[P in keyof T]-?: T[P] extends Function ? P : never;
|
|
4
|
+
}[keyof T];
|
|
5
|
+
export type MethodsAndProperties<T> = {
|
|
6
|
+
[key in keyof T]: T[key];
|
|
7
|
+
};
|
|
8
|
+
export type Properties<T> = Omit<MethodsAndProperties<T>, Methods<T>>;
|
|
9
|
+
export type MutablePropertiesData<T> = Mutable<Required<Properties<T>>>;
|
|
10
|
+
export type PropertiesData<T> = Required<Properties<T>>;
|
|
11
|
+
type RemoveUnderscore<S extends string> = S extends `_${infer R}` ? R : S;
|
|
12
|
+
type Mutable<T> = {
|
|
13
|
+
-readonly [P in keyof T]: T[P];
|
|
14
|
+
};
|
|
15
|
+
export type PrimitiveTypes<T> = {
|
|
16
|
+
[key in keyof Mutable<Properties<T>> as RemoveUnderscore<string & key>]: PrimitiveType<T[key]>;
|
|
17
|
+
};
|
|
18
|
+
export type DataTypes<T> = Partial<PrimitiveTypes<T>>;
|
|
19
|
+
export type PrimitiveType<T> = T extends (infer U)[] ? PrimitiveType<U>[] : T extends AbstractType<any> ? T['value'] : T extends null ? null : T extends Date ? never : T extends object ? PrimitiveTypes<T> : never;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SatisfiedBy<Candidate> {
|
|
2
|
+
isSatisfiedBy(candidate: Candidate): boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare abstract class Specification<Candidate> implements SatisfiedBy<Candidate> {
|
|
5
|
+
abstract isSatisfiedBy(candidate: Candidate): boolean;
|
|
6
|
+
and(other: SatisfiedBy<Candidate>): Specification<Candidate>;
|
|
7
|
+
or(other: SatisfiedBy<Candidate>): Specification<Candidate>;
|
|
8
|
+
not(): Specification<Candidate>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class Specification {
|
|
2
|
+
and(other) {
|
|
3
|
+
return new BothSpecification(this, other);
|
|
4
|
+
}
|
|
5
|
+
or(other) {
|
|
6
|
+
return new EitherSpecification(this, other);
|
|
7
|
+
}
|
|
8
|
+
not() {
|
|
9
|
+
return new NegatedSpecification(this);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class BothSpecification extends Specification {
|
|
13
|
+
constructor(left, right) {
|
|
14
|
+
super();
|
|
15
|
+
this.left = left;
|
|
16
|
+
this.right = right;
|
|
17
|
+
}
|
|
18
|
+
isSatisfiedBy(candidate) {
|
|
19
|
+
return this.left.isSatisfiedBy(candidate) && this.right.isSatisfiedBy(candidate);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class EitherSpecification extends Specification {
|
|
23
|
+
constructor(left, right) {
|
|
24
|
+
super();
|
|
25
|
+
this.left = left;
|
|
26
|
+
this.right = right;
|
|
27
|
+
}
|
|
28
|
+
isSatisfiedBy(candidate) {
|
|
29
|
+
return this.left.isSatisfiedBy(candidate) || this.right.isSatisfiedBy(candidate);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class NegatedSpecification extends Specification {
|
|
33
|
+
constructor(negated) {
|
|
34
|
+
super();
|
|
35
|
+
this.negated = negated;
|
|
36
|
+
}
|
|
37
|
+
isSatisfiedBy(candidate) {
|
|
38
|
+
return !this.negated.isSatisfiedBy(candidate);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Validatable, ValidationResult } from '@archi-code/validation';
|
|
2
|
+
import type { RequiredMarked } from './required/required-mark.js';
|
|
3
|
+
import type { ValidationIssue } from '../exceptions/validation.exception.js';
|
|
4
|
+
export type ValueOf<T, I> = I extends RequiredMarked ? T : T | null;
|
|
5
|
+
export declare abstract class AbstractType<T, Input = T> implements Validatable<T | null> {
|
|
6
|
+
protected readonly _value: T | null;
|
|
7
|
+
static [Symbol.hasInstance](candidate: unknown): boolean;
|
|
8
|
+
constructor(value?: Input | null);
|
|
9
|
+
get value(): ValueOf<T, this>;
|
|
10
|
+
get isNull(): boolean;
|
|
11
|
+
toString(): string;
|
|
12
|
+
equals<E extends AbstractType<any>>(other: E): boolean;
|
|
13
|
+
protected hasSameValue(other: this): boolean;
|
|
14
|
+
validate(): ValidationResult<ValueOf<T, this>>;
|
|
15
|
+
protected brokenRules(value: unknown): ValidationIssue[];
|
|
16
|
+
protected abstract filter(value: unknown): T | null;
|
|
17
|
+
private runRules;
|
|
18
|
+
}
|