@archi-code/ddd 3.0.0-alpha.1 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +478 -376
- package/SKILL.md +10 -8
- package/ddd-skills/archi-code-ddd/imports.md +28 -18
- package/ddd-skills/archi-code-ddd/layers.md +68 -53
- package/ddd-skills/archi-code-ddd/patterns.md +50 -43
- package/ddd-skills/archi-code-ddd/what-not-to-do.md +25 -18
- package/ddd-skills/archi-code-ddd/where-each-class-goes.md +11 -10
- package/ddd-skills/ddd-agregados/GUIA.md +2 -2
- package/ddd-skills/ddd-agregados/references/consistencia-eventual.md +5 -6
- package/ddd-skills/ddd-agregados/references/fabricas.md +5 -8
- package/ddd-skills/ddd-agregados/references/implementacion-ts.md +22 -27
- package/ddd-skills/ddd-arquitectura/GUIA.md +4 -4
- package/ddd-skills/ddd-arquitectura/assets/dependency-cruiser.cjs +13 -6
- package/ddd-skills/ddd-arquitectura/references/estilos-adicionales.md +2 -2
- package/ddd-skills/ddd-arquitectura/references/estructura-hexagonal-ts.md +70 -16
- package/ddd-skills/ddd-auditoria-refactorizacion/GUIA.md +1 -1
- package/ddd-skills/ddd-auditoria-refactorizacion/references/ejemplo-auditoria.md +9 -11
- package/ddd-skills/ddd-auditoria-refactorizacion/references/lista-comprobacion.md +4 -4
- package/ddd-skills/ddd-auditoria-refactorizacion/references/plan-migracion.md +2 -2
- package/ddd-skills/ddd-context-mapping/GUIA.md +5 -5
- package/ddd-skills/ddd-context-mapping/references/anticorrupcion-ts.md +33 -18
- package/ddd-skills/ddd-context-mapping/references/estilos-integracion.md +4 -7
- package/ddd-skills/ddd-event-sourcing-cqrs/GUIA.md +2 -2
- package/ddd-skills/ddd-event-sourcing-cqrs/references/event-sourcing-ts.md +32 -27
- package/ddd-skills/ddd-event-sourcing-cqrs/references/proyecciones-cqrs-ts.md +7 -7
- package/ddd-skills/ddd-eventos-dominio/GUIA.md +3 -3
- package/ddd-skills/ddd-eventos-dominio/references/diseno-eventos.md +15 -16
- package/ddd-skills/ddd-eventos-dominio/references/ejemplo-ecommerce.md +11 -11
- package/ddd-skills/ddd-eventos-dominio/references/publicacion-ts.md +34 -31
- package/ddd-skills/ddd-repositorios-persistencia/GUIA.md +7 -7
- package/ddd-skills/ddd-repositorios-persistencia/references/implementacion-ts.md +50 -32
- package/ddd-skills/ddd-repositorios-persistencia/references/tests-repositorios.md +31 -17
- package/ddd-skills/ddd-repositorios-persistencia/references/transacciones-ts.md +21 -14
- package/ddd-skills/ddd-servicios-capa-aplicacion/GUIA.md +2 -2
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/capa-aplicacion-ts.md +19 -19
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/ejemplo-ecommerce.md +12 -15
- package/ddd-skills/ddd-servicios-capa-aplicacion/references/servicios-dominio-ts.md +5 -6
- package/ddd-skills/ddd-value-objects-entidades/GUIA.md +3 -3
- package/ddd-skills/ddd-value-objects-entidades/references/entidades-ts.md +7 -9
- package/ddd-skills/ddd-value-objects-entidades/references/persistencia-valores.md +5 -5
- package/ddd-skills/ddd-value-objects-entidades/references/validacion.md +9 -9
- package/ddd-skills/ddd-value-objects-entidades/references/value-objects-ts.md +2 -3
- package/dist/cjs/application/event/listens-to.js +4 -4
- package/dist/cjs/{exceptions/application → application/exceptions}/aggregate-not-found.exception.d.ts +1 -1
- package/dist/cjs/{exceptions/application → application/exceptions}/aggregate-not-found.exception.js +4 -4
- 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/{exceptions/application → application/exceptions}/concurrency.exception.d.ts +1 -1
- package/dist/cjs/{exceptions/application → application/exceptions}/concurrency.exception.js +4 -4
- package/dist/cjs/{exceptions/application → application/exceptions}/not-allowed.exception.d.ts +1 -1
- package/dist/cjs/{exceptions/application → application/exceptions}/not-allowed.exception.js +4 -4
- 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 +7 -0
- package/dist/cjs/application/index.js +15 -1
- package/dist/cjs/application/use-case/use-case.js +3 -2
- package/dist/{esm/domain/type/value-objects/value-objects.d.ts → cjs/application/value-object-builder/value-object-builder.d.ts} +3 -3
- package/dist/cjs/application/value-object-builder/value-object-builder.js +51 -0
- package/dist/cjs/domain/aggregate/aggregate-root.d.ts +0 -5
- package/dist/cjs/domain/aggregate/aggregate-root.js +4 -20
- package/dist/cjs/domain/entity/entity.js +2 -2
- package/dist/cjs/domain/event/event-base.d.ts +3 -9
- package/dist/cjs/domain/event/event-base.js +8 -38
- 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/{exceptions/domain → domain/exceptions}/required-value.exception.js +5 -6
- package/dist/cjs/{exceptions/domain → domain/exceptions}/type-primitive.exception.js +5 -6
- package/dist/cjs/{exceptions/domain → domain/exceptions}/validation.exception.js +5 -5
- package/dist/cjs/domain/index.d.ts +8 -1
- package/dist/cjs/domain/index.js +14 -2
- package/dist/cjs/domain/primitive/primitive-types.d.ts +1 -3
- package/dist/cjs/domain/type/abstract-type.d.ts +6 -8
- package/dist/cjs/domain/type/abstract-type.js +15 -23
- package/dist/cjs/domain/type/array-type.d.ts +2 -1
- package/dist/cjs/domain/type/array-type.js +17 -18
- package/dist/cjs/domain/type/boolean-type.js +2 -2
- 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 +7 -8
- package/dist/cjs/domain/type/composite/composite-field.js +70 -47
- 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.js +15 -19
- package/dist/cjs/domain/type/date-type.d.ts +3 -2
- package/dist/cjs/domain/type/date-type.js +42 -7
- package/dist/cjs/domain/type/enum-type.js +2 -2
- package/dist/cjs/domain/type/id-type.d.ts +1 -1
- package/dist/cjs/domain/type/id-type.js +4 -4
- package/dist/cjs/domain/type/index.d.ts +2 -4
- package/dist/cjs/domain/type/index.js +3 -7
- package/dist/cjs/domain/type/json-type.d.ts +4 -0
- package/dist/cjs/domain/type/json-type.js +33 -4
- package/dist/cjs/domain/type/number-type.js +2 -2
- package/dist/cjs/domain/type/required/required-mark.d.ts +0 -1
- package/dist/cjs/domain/type/string-type.js +2 -2
- package/dist/cjs/domain/type/uuid-type.js +2 -2
- package/dist/cjs/infrastructure/event/domain-event-bus.js +9 -9
- package/dist/cjs/infrastructure/event/event-registry.js +9 -9
- package/dist/cjs/infrastructure/event/in-memory/emitter.js +2 -2
- package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.d.ts +1 -1
- package/dist/cjs/infrastructure/event/in-memory/in-memory-event-channel.js +6 -7
- package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js +4 -4
- 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/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.d.ts +1 -1
- package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.js +4 -4
- 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/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js +4 -4
- package/dist/cjs/infrastructure/index.d.ts +7 -2
- package/dist/cjs/infrastructure/index.js +15 -3
- package/dist/cjs/infrastructure/logging/console-logger.js +2 -2
- package/dist/{esm → cjs/shared}/exceptions/abstract.exception.d.ts +6 -4
- package/dist/cjs/{exceptions → shared/exceptions}/abstract.exception.js +9 -16
- 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/listens-to.js +1 -1
- package/dist/esm/{exceptions/application → application/exceptions}/aggregate-not-found.exception.d.ts +1 -1
- 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/{exceptions/application → application/exceptions}/concurrency.exception.d.ts +1 -1
- package/dist/esm/{exceptions/application → application/exceptions}/concurrency.exception.js +4 -4
- package/dist/esm/{exceptions/application → application/exceptions}/not-allowed.exception.d.ts +1 -1
- 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 +7 -0
- package/dist/esm/application/index.js +7 -0
- package/dist/esm/application/use-case/use-case.js +3 -2
- package/dist/{cjs/domain/type/value-objects/value-objects.d.ts → esm/application/value-object-builder/value-object-builder.d.ts} +3 -3
- package/dist/esm/application/value-object-builder/value-object-builder.js +47 -0
- package/dist/esm/domain/aggregate/aggregate-root.d.ts +0 -5
- package/dist/esm/domain/aggregate/aggregate-root.js +4 -20
- package/dist/esm/domain/entity/entity.js +1 -1
- package/dist/esm/domain/event/event-base.d.ts +3 -9
- package/dist/esm/domain/event/event-base.js +8 -38
- 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/{exceptions/domain → domain/exceptions}/required-value.exception.js +4 -5
- package/dist/esm/{exceptions/domain → domain/exceptions}/type-primitive.exception.js +4 -5
- package/dist/esm/{exceptions/domain → domain/exceptions}/validation.exception.js +5 -5
- package/dist/esm/domain/index.d.ts +7 -0
- package/dist/esm/domain/index.js +6 -0
- package/dist/esm/domain/primitive/primitive-types.d.ts +1 -3
- package/dist/esm/domain/type/abstract-type.d.ts +6 -8
- package/dist/esm/domain/type/abstract-type.js +14 -22
- package/dist/esm/domain/type/array-type.d.ts +2 -1
- package/dist/esm/domain/type/array-type.js +16 -17
- package/dist/esm/domain/type/boolean-type.js +1 -1
- 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 +7 -8
- package/dist/esm/domain/type/composite/composite-field.js +69 -46
- 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.js +13 -17
- package/dist/esm/domain/type/date-type.d.ts +3 -2
- package/dist/esm/domain/type/date-type.js +39 -4
- package/dist/esm/domain/type/enum-type.js +1 -1
- package/dist/esm/domain/type/id-type.d.ts +1 -1
- package/dist/esm/domain/type/id-type.js +2 -2
- package/dist/esm/domain/type/index.d.ts +2 -4
- package/dist/esm/domain/type/index.js +1 -3
- package/dist/esm/domain/type/json-type.d.ts +4 -0
- package/dist/esm/domain/type/json-type.js +32 -3
- package/dist/esm/domain/type/number-type.js +1 -1
- package/dist/esm/domain/type/required/required-mark.d.ts +0 -1
- package/dist/esm/domain/type/string-type.js +1 -1
- package/dist/esm/domain/type/uuid-type.js +1 -1
- package/dist/esm/infrastructure/event/domain-event-bus.js +5 -5
- package/dist/esm/infrastructure/event/event-registry.js +4 -4
- package/dist/esm/infrastructure/event/in-memory/emitter.js +1 -1
- package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.d.ts +1 -1
- package/dist/esm/infrastructure/event/in-memory/in-memory-event-channel.js +5 -6
- package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js +4 -4
- 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/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.d.ts +1 -1
- 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/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js +4 -4
- package/dist/esm/infrastructure/index.d.ts +7 -2
- package/dist/esm/infrastructure/index.js +7 -1
- package/dist/esm/infrastructure/logging/console-logger.js +1 -1
- package/dist/{cjs → esm/shared}/exceptions/abstract.exception.d.ts +6 -4
- package/dist/esm/{exceptions → shared/exceptions}/abstract.exception.js +9 -16
- 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 +7 -18
- package/dist/cjs/domain/type/equality/value-equality.d.ts +0 -7
- package/dist/cjs/domain/type/equality/value-equality.js +0 -41
- package/dist/cjs/domain/type/immutable/immutable-date.d.ts +0 -4
- package/dist/cjs/domain/type/immutable/immutable-date.js +0 -37
- package/dist/cjs/domain/type/immutable/immutable.d.ts +0 -4
- package/dist/cjs/domain/type/immutable/immutable.js +0 -19
- package/dist/cjs/domain/type/value-objects/value-objects.js +0 -70
- package/dist/cjs/exceptions/application/application.exception.d.ts +0 -6
- package/dist/cjs/exceptions/application/application.exception.js +0 -17
- package/dist/cjs/exceptions/domain/domain.exception.d.ts +0 -6
- package/dist/cjs/exceptions/domain/domain.exception.js +0 -17
- package/dist/cjs/exceptions/exception-code.d.ts +0 -15
- package/dist/cjs/exceptions/exception-code.js +0 -19
- package/dist/cjs/exceptions/index.d.ts +0 -14
- package/dist/cjs/exceptions/index.js +0 -30
- package/dist/cjs/exceptions/infrastructure/infrastructure.exception.d.ts +0 -6
- package/dist/cjs/exceptions/infrastructure/infrastructure.exception.js +0 -17
- package/dist/cjs/infrastructure/http/http-error-mapper.d.ts +0 -23
- package/dist/cjs/infrastructure/http/http-error-mapper.js +0 -63
- package/dist/esm/domain/type/equality/value-equality.d.ts +0 -7
- package/dist/esm/domain/type/equality/value-equality.js +0 -37
- package/dist/esm/domain/type/immutable/immutable-date.d.ts +0 -4
- package/dist/esm/domain/type/immutable/immutable-date.js +0 -33
- package/dist/esm/domain/type/immutable/immutable.d.ts +0 -4
- package/dist/esm/domain/type/immutable/immutable.js +0 -15
- package/dist/esm/domain/type/value-objects/value-objects.js +0 -66
- package/dist/esm/exceptions/application/aggregate-not-found.exception.js +0 -13
- package/dist/esm/exceptions/application/application.exception.d.ts +0 -6
- package/dist/esm/exceptions/application/application.exception.js +0 -13
- package/dist/esm/exceptions/application/not-allowed.exception.js +0 -13
- package/dist/esm/exceptions/domain/domain.exception.d.ts +0 -6
- package/dist/esm/exceptions/domain/domain.exception.js +0 -13
- package/dist/esm/exceptions/exception-code.d.ts +0 -15
- package/dist/esm/exceptions/exception-code.js +0 -16
- package/dist/esm/exceptions/index.d.ts +0 -14
- package/dist/esm/exceptions/index.js +0 -14
- package/dist/esm/exceptions/infrastructure/infrastructure.exception.d.ts +0 -6
- package/dist/esm/exceptions/infrastructure/infrastructure.exception.js +0 -13
- package/dist/esm/exceptions/infrastructure/internal-error.exception.js +0 -13
- package/dist/esm/infrastructure/http/http-error-mapper.d.ts +0 -23
- package/dist/esm/infrastructure/http/http-error-mapper.js +0 -59
- /package/dist/cjs/{exceptions/domain → domain/exceptions}/required-value.exception.d.ts +0 -0
- /package/dist/cjs/{exceptions/domain → domain/exceptions}/type-primitive.exception.d.ts +0 -0
- /package/dist/cjs/{exceptions/domain → domain/exceptions}/validation.exception.d.ts +0 -0
- /package/dist/cjs/domain/type/required/{required.d.ts → required-type.d.ts} +0 -0
- /package/dist/cjs/domain/type/required/{required.js → required-type.js} +0 -0
- /package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.d.ts +0 -0
- /package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.d.ts +0 -0
- /package/dist/cjs/{exceptions → shared/exceptions}/brand/exception-brand.d.ts +0 -0
- /package/dist/cjs/{exceptions → shared/exceptions}/brand/exception-brand.js +0 -0
- /package/dist/cjs/{exceptions → shared/exceptions}/received/received-value.d.ts +0 -0
- /package/dist/cjs/{exceptions → shared/exceptions}/received/received-value.js +0 -0
- /package/dist/esm/{exceptions/domain → domain/exceptions}/required-value.exception.d.ts +0 -0
- /package/dist/esm/{exceptions/domain → domain/exceptions}/type-primitive.exception.d.ts +0 -0
- /package/dist/esm/{exceptions/domain → domain/exceptions}/validation.exception.d.ts +0 -0
- /package/dist/esm/domain/type/required/{required.d.ts → required-type.d.ts} +0 -0
- /package/dist/esm/domain/type/required/{required.js → required-type.js} +0 -0
- /package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.d.ts +0 -0
- /package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.d.ts +0 -0
- /package/dist/esm/{exceptions → shared/exceptions}/brand/exception-brand.d.ts +0 -0
- /package/dist/esm/{exceptions → shared/exceptions}/brand/exception-brand.js +0 -0
- /package/dist/esm/{exceptions → shared/exceptions}/received/received-value.d.ts +0 -0
- /package/dist/esm/{exceptions → shared/exceptions}/received/received-value.js +0 -0
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumType = void 0;
|
|
4
4
|
const abstract_type_1 = require("./abstract-type");
|
|
5
|
-
const
|
|
5
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
6
6
|
const NUMERIC_TEXT = /^-?\d+(?:\.\d+)?$/;
|
|
7
7
|
class EnumType extends abstract_type_1.AbstractType {
|
|
8
8
|
filter(value) {
|
|
9
9
|
const options = this.options();
|
|
10
10
|
const option = options.find((candidate) => EnumType.matches(candidate, value));
|
|
11
11
|
if (option === undefined) {
|
|
12
|
-
throw new
|
|
12
|
+
throw new type_primitive_exception_1.TypePrimitiveException(`Expected one of [${options.join(', ')}]`, value, '');
|
|
13
13
|
}
|
|
14
14
|
return option;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UuidType } from './uuid-type';
|
|
2
|
-
declare const IdType_base: import("./required/required").RequiredType<typeof UuidType>;
|
|
2
|
+
declare const IdType_base: import("./required/required-type").RequiredType<typeof UuidType>;
|
|
3
3
|
export declare class IdType<Brand extends string = string> extends IdType_base {
|
|
4
4
|
protected readonly idBrand: Brand;
|
|
5
5
|
protected filter(value: unknown): string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IdType = void 0;
|
|
4
|
-
const
|
|
4
|
+
const required_type_1 = require("./required/required-type");
|
|
5
5
|
const uuid_type_1 = require("./uuid-type");
|
|
6
|
-
const
|
|
6
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
7
7
|
const NIL_OR_MAX_UUID = /^(?:0{8}-0{4}-0{4}-0{4}-0{12}|f{8}-f{4}-f{4}-f{4}-f{12})$/i;
|
|
8
|
-
class IdType extends (0,
|
|
8
|
+
class IdType extends (0, required_type_1.Required)(uuid_type_1.UuidType) {
|
|
9
9
|
filter(value) {
|
|
10
10
|
const id = super.filter(value);
|
|
11
11
|
if (NIL_OR_MAX_UUID.test(id)) {
|
|
12
|
-
throw new
|
|
12
|
+
throw new type_primitive_exception_1.TypePrimitiveException('Id', value);
|
|
13
13
|
}
|
|
14
14
|
return id;
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AbstractType } from './abstract-type';
|
|
2
|
-
export { Required } from './required/required';
|
|
3
|
-
export type { RequiredType } from './required/required';
|
|
2
|
+
export { Required } from './required/required-type';
|
|
3
|
+
export type { RequiredType } from './required/required-type';
|
|
4
4
|
export { ArrayType } from './array-type';
|
|
5
5
|
export { BooleanType } from './boolean-type';
|
|
6
6
|
export { CreatedAt, DateType, UpdatedAt } from './date-type';
|
|
@@ -11,7 +11,5 @@ export { NumberType } from './number-type';
|
|
|
11
11
|
export { StringType } from './string-type';
|
|
12
12
|
export { IdType } from './id-type';
|
|
13
13
|
export { UuidType } from './uuid-type';
|
|
14
|
-
export { Immutable } from './immutable/immutable';
|
|
15
|
-
export { ValueObjects } from './value-objects/value-objects';
|
|
16
14
|
export { Composite } from './composite/composite';
|
|
17
15
|
export type { CompositeInput, CompositePrimitives, CompositeProps, CompositeSchema, CompositeType, CompositeValue, } from './composite/composite';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Composite = exports.
|
|
3
|
+
exports.Composite = exports.UuidType = exports.IdType = exports.StringType = exports.NumberType = exports.JsonType = exports.EnumType = exports.UpdatedAt = exports.DateType = exports.CreatedAt = exports.BooleanType = exports.ArrayType = exports.Required = exports.AbstractType = void 0;
|
|
4
4
|
var abstract_type_1 = require("./abstract-type");
|
|
5
5
|
Object.defineProperty(exports, "AbstractType", { enumerable: true, get: function () { return abstract_type_1.AbstractType; } });
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return
|
|
6
|
+
var required_type_1 = require("./required/required-type");
|
|
7
|
+
Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return required_type_1.Required; } });
|
|
8
8
|
var array_type_1 = require("./array-type");
|
|
9
9
|
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return array_type_1.ArrayType; } });
|
|
10
10
|
var boolean_type_1 = require("./boolean-type");
|
|
@@ -25,9 +25,5 @@ var id_type_1 = require("./id-type");
|
|
|
25
25
|
Object.defineProperty(exports, "IdType", { enumerable: true, get: function () { return id_type_1.IdType; } });
|
|
26
26
|
var uuid_type_1 = require("./uuid-type");
|
|
27
27
|
Object.defineProperty(exports, "UuidType", { enumerable: true, get: function () { return uuid_type_1.UuidType; } });
|
|
28
|
-
var immutable_1 = require("./immutable/immutable");
|
|
29
|
-
Object.defineProperty(exports, "Immutable", { enumerable: true, get: function () { return immutable_1.Immutable; } });
|
|
30
|
-
var value_objects_1 = require("./value-objects/value-objects");
|
|
31
|
-
Object.defineProperty(exports, "ValueObjects", { enumerable: true, get: function () { return value_objects_1.ValueObjects; } });
|
|
32
28
|
var composite_1 = require("./composite/composite");
|
|
33
29
|
Object.defineProperty(exports, "Composite", { enumerable: true, get: function () { return composite_1.Composite; } });
|
|
@@ -2,4 +2,8 @@ import { AbstractType } from './abstract-type';
|
|
|
2
2
|
export type JsonTypeValue = Record<string, any>;
|
|
3
3
|
export declare class JsonType<T extends JsonTypeValue = JsonTypeValue> extends AbstractType<T> {
|
|
4
4
|
protected filter(value: unknown): T;
|
|
5
|
+
protected hasSameValue(other: this): boolean;
|
|
6
|
+
private static sameJson;
|
|
7
|
+
private static deepFreeze;
|
|
8
|
+
private static isObject;
|
|
5
9
|
}
|
|
@@ -3,15 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonType = void 0;
|
|
4
4
|
const validation_1 = require("@archi-code/validation");
|
|
5
5
|
const abstract_type_1 = require("./abstract-type");
|
|
6
|
-
const
|
|
7
|
-
const index_1 = require("../../exceptions/index");
|
|
6
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
8
7
|
class JsonType extends abstract_type_1.AbstractType {
|
|
9
8
|
filter(value) {
|
|
10
9
|
const converted = (0, validation_1.toJson)(value);
|
|
11
10
|
if (!converted.ok) {
|
|
12
|
-
throw new
|
|
11
|
+
throw new type_primitive_exception_1.TypePrimitiveException('Json', value);
|
|
13
12
|
}
|
|
14
|
-
return
|
|
13
|
+
return JsonType.deepFreeze(JSON.parse(JSON.stringify(converted.value)));
|
|
14
|
+
}
|
|
15
|
+
hasSameValue(other) {
|
|
16
|
+
return JsonType.sameJson(this._value, other._value);
|
|
17
|
+
}
|
|
18
|
+
static sameJson(left, right) {
|
|
19
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
20
|
+
return (Array.isArray(left) &&
|
|
21
|
+
Array.isArray(right) &&
|
|
22
|
+
left.length === right.length &&
|
|
23
|
+
left.every((item, index) => JsonType.sameJson(item, right[index])));
|
|
24
|
+
}
|
|
25
|
+
if (JsonType.isObject(left) && JsonType.isObject(right)) {
|
|
26
|
+
const keys = Object.keys(left);
|
|
27
|
+
return (keys.length === Object.keys(right).length &&
|
|
28
|
+
keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
|
|
29
|
+
JsonType.sameJson(left[key], right[key])));
|
|
30
|
+
}
|
|
31
|
+
return left === right;
|
|
32
|
+
}
|
|
33
|
+
static deepFreeze(value) {
|
|
34
|
+
if (JsonType.isObject(value)) {
|
|
35
|
+
Object.freeze(value);
|
|
36
|
+
for (const child of Object.values(value)) {
|
|
37
|
+
JsonType.deepFreeze(child);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
static isObject(value) {
|
|
43
|
+
return typeof value === 'object' && value !== null;
|
|
15
44
|
}
|
|
16
45
|
}
|
|
17
46
|
exports.JsonType = JsonType;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NumberType = void 0;
|
|
4
4
|
const validation_1 = require("@archi-code/validation");
|
|
5
5
|
const abstract_type_1 = require("./abstract-type");
|
|
6
|
-
const
|
|
6
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
7
7
|
class NumberType extends abstract_type_1.AbstractType {
|
|
8
8
|
filter(value) {
|
|
9
9
|
const converted = (0, validation_1.toFloat)(value);
|
|
10
10
|
if (!converted.ok) {
|
|
11
|
-
throw new
|
|
11
|
+
throw new type_primitive_exception_1.TypePrimitiveException('Number', value);
|
|
12
12
|
}
|
|
13
13
|
return converted.value;
|
|
14
14
|
}
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StringType = void 0;
|
|
4
4
|
const validation_1 = require("@archi-code/validation");
|
|
5
5
|
const abstract_type_1 = require("./abstract-type");
|
|
6
|
-
const
|
|
6
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
7
7
|
class StringType extends abstract_type_1.AbstractType {
|
|
8
8
|
filter(value) {
|
|
9
9
|
const converted = (0, validation_1.toString)(value);
|
|
10
10
|
if (!converted.ok) {
|
|
11
|
-
throw new
|
|
11
|
+
throw new type_primitive_exception_1.TypePrimitiveException('String', value);
|
|
12
12
|
}
|
|
13
13
|
return converted.value;
|
|
14
14
|
}
|
|
@@ -4,7 +4,7 @@ exports.UuidType = void 0;
|
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const validation_1 = require("@archi-code/validation");
|
|
6
6
|
const abstract_type_1 = require("./abstract-type");
|
|
7
|
-
const
|
|
7
|
+
const type_primitive_exception_1 = require("../exceptions/type-primitive.exception");
|
|
8
8
|
const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
9
9
|
class UuidType extends abstract_type_1.AbstractType {
|
|
10
10
|
static random() {
|
|
@@ -19,7 +19,7 @@ class UuidType extends abstract_type_1.AbstractType {
|
|
|
19
19
|
filter(value) {
|
|
20
20
|
const converted = (0, validation_1.toString)(value);
|
|
21
21
|
if (!converted.ok || !(0, validation_1.isUUID)(converted.value)) {
|
|
22
|
-
throw new
|
|
22
|
+
throw new type_primitive_exception_1.TypePrimitiveException('UUID', value);
|
|
23
23
|
}
|
|
24
24
|
return converted.value.toLowerCase();
|
|
25
25
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DomainEventBus = void 0;
|
|
4
|
-
const index_1 = require("../../
|
|
5
|
-
const index_2 = require("../../
|
|
4
|
+
const index_1 = require("../../application/index");
|
|
5
|
+
const index_2 = require("../../domain/index");
|
|
6
|
+
const unknown_event_exception_1 = require("../exceptions/unknown-event.exception");
|
|
7
|
+
const index_3 = require("../../application/index");
|
|
6
8
|
const silent_logger_1 = require("../logging/silent-logger");
|
|
7
9
|
class DomainEventBus {
|
|
8
10
|
constructor(channel, registry, logger = new silent_logger_1.SilentLogger()) {
|
|
@@ -11,20 +13,19 @@ class DomainEventBus {
|
|
|
11
13
|
this.logger = logger;
|
|
12
14
|
}
|
|
13
15
|
async publish(events) {
|
|
14
|
-
await this.channel.send(events.map((event) => event
|
|
16
|
+
await this.channel.send(events.map((event) => ({ ...event })));
|
|
15
17
|
this.logger.debug('domain_events_published', {
|
|
16
18
|
events: events.map((event) => ({
|
|
17
|
-
eventName: event.eventName
|
|
19
|
+
eventName: event.eventName,
|
|
18
20
|
eventId: event.eventId,
|
|
19
|
-
aggregateId: event.aggregateId,
|
|
20
21
|
})),
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
async subscribe(listener) {
|
|
24
|
-
const subscription =
|
|
25
|
+
const subscription = index_3.ListensTo.subscriptionOf(listener);
|
|
25
26
|
const { eventName, consumer } = subscription;
|
|
26
27
|
if (!this.registry.has(eventName)) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new unknown_event_exception_1.UnknownEventException(eventName);
|
|
28
29
|
}
|
|
29
30
|
const channelSubscription = await this.channel.receive(eventName, consumer, (serialized) => this.deliver(listener, subscription, serialized));
|
|
30
31
|
this.logger.info('event_listener_subscribed', { eventName, consumer });
|
|
@@ -44,10 +45,9 @@ class DomainEventBus {
|
|
|
44
45
|
eventName,
|
|
45
46
|
consumer,
|
|
46
47
|
eventId: serialized.eventId,
|
|
47
|
-
aggregateId: serialized.aggregateId,
|
|
48
48
|
error,
|
|
49
49
|
};
|
|
50
|
-
if (error instanceof
|
|
50
|
+
if (error instanceof index_2.DomainException || error instanceof index_1.ApplicationException) {
|
|
51
51
|
this.logger.warn('event_listener_rejected', context);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventRegistry = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const internal_error_exception_1 = require("../exceptions/internal-error.exception");
|
|
5
|
+
const unknown_event_exception_1 = require("../exceptions/unknown-event.exception");
|
|
6
6
|
class EventRegistry {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.factories = new Map();
|
|
@@ -10,7 +10,7 @@ class EventRegistry {
|
|
|
10
10
|
register(event, factory) {
|
|
11
11
|
const { eventName } = event;
|
|
12
12
|
if (this.factories.has(eventName)) {
|
|
13
|
-
throw new
|
|
13
|
+
throw new internal_error_exception_1.InternalErrorException(`event "${eventName}" is already registered`);
|
|
14
14
|
}
|
|
15
15
|
this.factories.set(eventName, factory);
|
|
16
16
|
return this;
|
|
@@ -20,23 +20,23 @@ class EventRegistry {
|
|
|
20
20
|
}
|
|
21
21
|
fromJSON(event) {
|
|
22
22
|
if (typeof event !== 'object' || event === null) {
|
|
23
|
-
throw new
|
|
23
|
+
throw new internal_error_exception_1.InternalErrorException('a serialized event must be a JSON object');
|
|
24
24
|
}
|
|
25
25
|
if (typeof event.eventName !== 'string') {
|
|
26
|
-
throw new
|
|
26
|
+
throw new internal_error_exception_1.InternalErrorException('a serialized event needs its eventName');
|
|
27
27
|
}
|
|
28
28
|
const factory = this.factories.get(event.eventName);
|
|
29
29
|
if (factory === undefined) {
|
|
30
|
-
throw new
|
|
30
|
+
throw new unknown_event_exception_1.UnknownEventException(event.eventName);
|
|
31
31
|
}
|
|
32
32
|
const rebuilt = factory(event);
|
|
33
33
|
EventRegistry.assertSameIdentity(event, rebuilt);
|
|
34
|
-
return
|
|
34
|
+
return rebuilt;
|
|
35
35
|
}
|
|
36
36
|
static assertSameIdentity(serialized, rebuilt) {
|
|
37
37
|
if (rebuilt.eventId !== String(serialized.eventId).toLowerCase() ||
|
|
38
|
-
rebuilt.occurredOn
|
|
39
|
-
throw new
|
|
38
|
+
Date.parse(rebuilt.occurredOn) !== Date.parse(serialized.occurredOn)) {
|
|
39
|
+
throw new internal_error_exception_1.InternalErrorException(`the factory of "${serialized.eventName}" must pass the serialized event as metadata, so it keeps its eventId and occurredOn`);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Emitter = void 0;
|
|
4
|
-
const
|
|
4
|
+
const event_delivery_exception_1 = require("../../exceptions/event-delivery.exception");
|
|
5
5
|
class Emitter {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.events = new Map();
|
|
@@ -33,7 +33,7 @@ class Emitter {
|
|
|
33
33
|
}));
|
|
34
34
|
const errors = results.flatMap((result) => result.status === 'rejected' ? [result.reason] : []);
|
|
35
35
|
if (errors.length > 0) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new event_delivery_exception_1.EventDeliveryException(eventName, errors, snapshot.length);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
async emitSerial(eventName, data) {
|
|
@@ -12,5 +12,5 @@ export declare class InMemoryEventChannel implements EventChannel {
|
|
|
12
12
|
get sent(): readonly SerializedEvent[];
|
|
13
13
|
send(events: readonly SerializedEvent[]): Promise<void>;
|
|
14
14
|
receive(eventName: string, consumer: string, handler: ChannelHandler): Promise<ChannelSubscription>;
|
|
15
|
-
private static
|
|
15
|
+
private static copy;
|
|
16
16
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InMemoryEventChannel = void 0;
|
|
4
|
-
const
|
|
5
|
-
const index_2 = require("../../../exceptions/index");
|
|
4
|
+
const infrastructure_exception_1 = require("../../exceptions/infrastructure.exception");
|
|
6
5
|
const emitter_1 = require("./emitter");
|
|
7
6
|
class InMemoryEventChannel {
|
|
8
7
|
constructor({ delivery = 'serial' } = {}) {
|
|
@@ -16,7 +15,7 @@ class InMemoryEventChannel {
|
|
|
16
15
|
}
|
|
17
16
|
async send(events) {
|
|
18
17
|
for (const event of events) {
|
|
19
|
-
const copy = InMemoryEventChannel.
|
|
18
|
+
const copy = InMemoryEventChannel.copy(event);
|
|
20
19
|
this.sentEvents.push(copy);
|
|
21
20
|
if (this.delivery === 'parallel') {
|
|
22
21
|
await this.emitter.emit(copy.eventName, copy);
|
|
@@ -29,10 +28,10 @@ class InMemoryEventChannel {
|
|
|
29
28
|
async receive(eventName, consumer, handler) {
|
|
30
29
|
const receiver = JSON.stringify([eventName, consumer]);
|
|
31
30
|
if (this.receivers.has(receiver)) {
|
|
32
|
-
throw new
|
|
31
|
+
throw new infrastructure_exception_1.InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
|
|
33
32
|
}
|
|
34
33
|
this.receivers.add(receiver);
|
|
35
|
-
const off = this.emitter.on(eventName, (event) => handler(event));
|
|
34
|
+
const off = this.emitter.on(eventName, (event) => handler(InMemoryEventChannel.copy(event)));
|
|
36
35
|
let open = true;
|
|
37
36
|
return {
|
|
38
37
|
close: async () => {
|
|
@@ -44,8 +43,8 @@ class InMemoryEventChannel {
|
|
|
44
43
|
},
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
static
|
|
48
|
-
return
|
|
46
|
+
static copy(event) {
|
|
47
|
+
return JSON.parse(JSON.stringify(event));
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
exports.InMemoryEventChannel = InMemoryEventChannel;
|
package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js
RENAMED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.EventDeliveryException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
5
7
|
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
6
|
-
const exception_brand_1 = require("../brand/exception-brand");
|
|
7
|
-
const exception_code_1 = require("../exception-code");
|
|
8
8
|
class EventDeliveryException extends infrastructure_exception_1.InfrastructureException {
|
|
9
9
|
constructor(eventName, errors, consumers) {
|
|
10
10
|
super(`${errors.length} of ${consumers} consumers of "${eventName}" failed.`, [
|
|
11
|
-
|
|
11
|
+
infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery,
|
|
12
12
|
]);
|
|
13
13
|
this.errors = Object.freeze([...errors]);
|
|
14
14
|
}
|
|
@@ -16,5 +16,5 @@ class EventDeliveryException extends infrastructure_exception_1.InfrastructureEx
|
|
|
16
16
|
exports.EventDeliveryException = EventDeliveryException;
|
|
17
17
|
_a = EventDeliveryException;
|
|
18
18
|
(() => {
|
|
19
|
-
|
|
19
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.EventDelivery);
|
|
20
20
|
})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfrastructureExceptionCode = void 0;
|
|
4
|
+
var InfrastructureExceptionCode;
|
|
5
|
+
(function (InfrastructureExceptionCode) {
|
|
6
|
+
InfrastructureExceptionCode["InfrastructureException"] = "INF000";
|
|
7
|
+
InfrastructureExceptionCode["InternalError"] = "INF001";
|
|
8
|
+
InfrastructureExceptionCode["UnknownEvent"] = "INF002";
|
|
9
|
+
InfrastructureExceptionCode["EventDelivery"] = "INF003";
|
|
10
|
+
})(InfrastructureExceptionCode || (exports.InfrastructureExceptionCode = InfrastructureExceptionCode = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractException } from '../../shared/index';
|
|
2
|
+
import type { ExceptionOptions } from '../../shared/index';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code';
|
|
4
|
+
export declare class InfrastructureException extends AbstractException {
|
|
5
|
+
constructor(message: string, exceptionCodes?: (InfrastructureExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InfrastructureException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
7
|
+
class InfrastructureException extends index_1.AbstractException {
|
|
8
|
+
constructor(message, exceptionCodes = [], options = {}) {
|
|
9
|
+
super(message, [infrastructure_exception_code_1.InfrastructureExceptionCode.InfrastructureException, ...exceptionCodes], options, infrastructure_exception_code_1.InfrastructureExceptionCode);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.InfrastructureException = InfrastructureException;
|
|
13
|
+
_a = InfrastructureException;
|
|
14
|
+
(() => {
|
|
15
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.InfrastructureException);
|
|
16
|
+
})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index';
|
|
1
2
|
import { InfrastructureException } from './infrastructure.exception';
|
|
2
|
-
import type { ExceptionOptions } from '../abstract.exception';
|
|
3
3
|
export declare class InternalErrorException extends InfrastructureException {
|
|
4
4
|
constructor(message: string, options?: ExceptionOptions);
|
|
5
5
|
}
|
package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/internal-error.exception.js
RENAMED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.InternalErrorException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
5
7
|
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
6
|
-
const exception_brand_1 = require("../brand/exception-brand");
|
|
7
|
-
const exception_code_1 = require("../exception-code");
|
|
8
8
|
class InternalErrorException extends infrastructure_exception_1.InfrastructureException {
|
|
9
9
|
constructor(message, options = {}) {
|
|
10
|
-
super(`Failed, internal error: ${message}`, [
|
|
10
|
+
super(`Failed, internal error: ${message}`, [infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError], options);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
exports.InternalErrorException = InternalErrorException;
|
|
14
14
|
_a = InternalErrorException;
|
|
15
15
|
(() => {
|
|
16
|
-
|
|
16
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.InternalError);
|
|
17
17
|
})();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionClassifier = void 0;
|
|
4
|
+
const index_1 = require("../../../application/index");
|
|
5
|
+
const index_2 = require("../../../domain/index");
|
|
6
|
+
const exception_kind_1 = require("./exception-kind");
|
|
7
|
+
class ExceptionClassifier {
|
|
8
|
+
static classify(error) {
|
|
9
|
+
if (error instanceof index_1.AggregateNotFoundException) {
|
|
10
|
+
return exception_kind_1.ExceptionKind.NotFound;
|
|
11
|
+
}
|
|
12
|
+
if (error instanceof index_1.NotAllowedException) {
|
|
13
|
+
return exception_kind_1.ExceptionKind.NotAllowed;
|
|
14
|
+
}
|
|
15
|
+
if (error instanceof index_1.ConcurrencyException) {
|
|
16
|
+
return exception_kind_1.ExceptionKind.Conflict;
|
|
17
|
+
}
|
|
18
|
+
if (error instanceof index_1.UnexpectedErrorException ||
|
|
19
|
+
error instanceof index_2.InvalidEventDefinitionException) {
|
|
20
|
+
return exception_kind_1.ExceptionKind.Internal;
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof index_2.TypePrimitiveException || error instanceof index_2.RequiredValueException) {
|
|
23
|
+
return exception_kind_1.ExceptionKind.Malformed;
|
|
24
|
+
}
|
|
25
|
+
if (error instanceof index_2.DomainException) {
|
|
26
|
+
return exception_kind_1.ExceptionKind.Invalid;
|
|
27
|
+
}
|
|
28
|
+
if (error instanceof index_1.ApplicationException) {
|
|
29
|
+
return exception_kind_1.ExceptionKind.Rejected;
|
|
30
|
+
}
|
|
31
|
+
return exception_kind_1.ExceptionKind.Internal;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ExceptionClassifier = ExceptionClassifier;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionKind = void 0;
|
|
4
|
+
var ExceptionKind;
|
|
5
|
+
(function (ExceptionKind) {
|
|
6
|
+
ExceptionKind["NotFound"] = "not_found";
|
|
7
|
+
ExceptionKind["NotAllowed"] = "not_allowed";
|
|
8
|
+
ExceptionKind["Conflict"] = "conflict";
|
|
9
|
+
ExceptionKind["Malformed"] = "malformed";
|
|
10
|
+
ExceptionKind["Invalid"] = "invalid";
|
|
11
|
+
ExceptionKind["Rejected"] = "rejected";
|
|
12
|
+
ExceptionKind["Internal"] = "internal";
|
|
13
|
+
})(ExceptionKind || (exports.ExceptionKind = ExceptionKind = {}));
|
package/dist/cjs/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js
RENAMED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.UnknownEventException = void 0;
|
|
5
|
+
const index_1 = require("../../shared/index");
|
|
6
|
+
const infrastructure_exception_code_1 = require("./infrastructure-exception-code");
|
|
5
7
|
const infrastructure_exception_1 = require("./infrastructure.exception");
|
|
6
|
-
const exception_brand_1 = require("../brand/exception-brand");
|
|
7
|
-
const exception_code_1 = require("../exception-code");
|
|
8
8
|
class UnknownEventException extends infrastructure_exception_1.InfrastructureException {
|
|
9
9
|
constructor(eventName) {
|
|
10
10
|
super(`Unknown event "${eventName}": register it before reading it.`, [
|
|
11
|
-
|
|
11
|
+
infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent,
|
|
12
12
|
]);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.UnknownEventException = UnknownEventException;
|
|
16
16
|
_a = UnknownEventException;
|
|
17
17
|
(() => {
|
|
18
|
-
|
|
18
|
+
index_1.ExceptionBrand.brandClass(_a, infrastructure_exception_code_1.InfrastructureExceptionCode.UnknownEvent);
|
|
19
19
|
})();
|
|
@@ -7,10 +7,15 @@ export type { EventFactory } from './event/event-registry';
|
|
|
7
7
|
export type { ChannelHandler, ChannelSubscription, EventChannel } from './event/event-channel';
|
|
8
8
|
export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel';
|
|
9
9
|
export type { InMemoryEventChannelOptions } from './event/in-memory/in-memory-event-channel';
|
|
10
|
-
export { HttpErrorMapper } from './http/http-error-mapper';
|
|
11
|
-
export type { HttpError, HttpErrorBody, HttpErrorMapperOptions } from './http/http-error-mapper';
|
|
12
10
|
export { ConsoleLogger } from './logging/console-logger';
|
|
13
11
|
export type { ConsoleLoggerOptions } from './logging/console-logger';
|
|
14
12
|
export { InMemoryLogger } from './logging/in-memory-logger';
|
|
15
13
|
export type { LogEntry } from './logging/in-memory-logger';
|
|
16
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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
4
|
var system_clock_1 = require("./clock/system-clock");
|
|
5
5
|
Object.defineProperty(exports, "SystemClock", { enumerable: true, get: function () { return system_clock_1.SystemClock; } });
|
|
6
6
|
var fixed_clock_1 = require("./clock/fixed-clock");
|
|
@@ -11,11 +11,23 @@ var event_registry_1 = require("./event/event-registry");
|
|
|
11
11
|
Object.defineProperty(exports, "EventRegistry", { enumerable: true, get: function () { return event_registry_1.EventRegistry; } });
|
|
12
12
|
var in_memory_event_channel_1 = require("./event/in-memory/in-memory-event-channel");
|
|
13
13
|
Object.defineProperty(exports, "InMemoryEventChannel", { enumerable: true, get: function () { return in_memory_event_channel_1.InMemoryEventChannel; } });
|
|
14
|
-
var http_error_mapper_1 = require("./http/http-error-mapper");
|
|
15
|
-
Object.defineProperty(exports, "HttpErrorMapper", { enumerable: true, get: function () { return http_error_mapper_1.HttpErrorMapper; } });
|
|
16
14
|
var console_logger_1 = require("./logging/console-logger");
|
|
17
15
|
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return console_logger_1.ConsoleLogger; } });
|
|
18
16
|
var in_memory_logger_1 = require("./logging/in-memory-logger");
|
|
19
17
|
Object.defineProperty(exports, "InMemoryLogger", { enumerable: true, get: function () { return in_memory_logger_1.InMemoryLogger; } });
|
|
20
18
|
var silent_logger_1 = require("./logging/silent-logger");
|
|
21
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; } });
|