@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
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ImmutableDate } from './immutable-date.js';
|
|
2
|
-
export class Immutable {
|
|
3
|
-
static freeze(value) {
|
|
4
|
-
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
5
|
-
Object.freeze(value);
|
|
6
|
-
for (const child of Object.values(value)) {
|
|
7
|
-
Immutable.freeze(child);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
static date(date) {
|
|
13
|
-
return new ImmutableDate(date);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { DomainException, InternalErrorException, ValidationException, } from '../../../exceptions/index.js';
|
|
2
|
-
export class ValueObjects {
|
|
3
|
-
static build(factories) {
|
|
4
|
-
const built = {};
|
|
5
|
-
const issues = [];
|
|
6
|
-
for (const [field, factory] of Object.entries(factories)) {
|
|
7
|
-
try {
|
|
8
|
-
Object.defineProperty(built, field, {
|
|
9
|
-
value: ValueObjects.synchronous(field, factory()),
|
|
10
|
-
enumerable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
issues.push(...ValueObjects.issuesOf(field, error));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
ValueObjects.assertNoIssues(issues);
|
|
20
|
-
return built;
|
|
21
|
-
}
|
|
22
|
-
static buildList(values, factory) {
|
|
23
|
-
const built = [];
|
|
24
|
-
const issues = [];
|
|
25
|
-
values.forEach((value, index) => {
|
|
26
|
-
try {
|
|
27
|
-
built.push(ValueObjects.synchronous(String(index), factory(value, index)));
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
issues.push(...ValueObjects.issuesOf(String(index), error));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
ValueObjects.assertNoIssues(issues);
|
|
34
|
-
return built;
|
|
35
|
-
}
|
|
36
|
-
static synchronous(field, result) {
|
|
37
|
-
if (!ValueObjects.isThenable(result)) {
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
result.then(undefined, () => undefined);
|
|
41
|
-
throw new InternalErrorException(`ValueObjects: the factory of "${field}" returned a Promise; build value objects synchronously`);
|
|
42
|
-
}
|
|
43
|
-
static isThenable(result) {
|
|
44
|
-
return ((typeof result === 'object' || typeof result === 'function') &&
|
|
45
|
-
result !== null &&
|
|
46
|
-
typeof result.then === 'function');
|
|
47
|
-
}
|
|
48
|
-
static issuesOf(field, error) {
|
|
49
|
-
if (error instanceof ValidationException) {
|
|
50
|
-
return error.errors.map((issue) => ({
|
|
51
|
-
field: issue.field === null ? field : `${field}.${issue.field}`,
|
|
52
|
-
code: issue.code,
|
|
53
|
-
message: issue.message,
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
if (error instanceof DomainException) {
|
|
57
|
-
return [{ field, code: error.code, message: error.message }];
|
|
58
|
-
}
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
static assertNoIssues(issues) {
|
|
62
|
-
if (issues.length > 0) {
|
|
63
|
-
throw new ValidationException(issues);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { ApplicationException } from './application.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class AggregateNotFoundException extends ApplicationException {
|
|
6
|
-
constructor(entity, id, options = {}) {
|
|
7
|
-
super(`${entity} with ID ${id} not found.`, [ExceptionCode.AggregateNotFound], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = AggregateNotFoundException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.AggregateNotFound);
|
|
13
|
-
})();
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
2
|
-
import type { ExceptionOptions } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
4
|
-
export declare class ApplicationException extends AbstractException {
|
|
5
|
-
constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class ApplicationException extends AbstractException {
|
|
6
|
-
constructor(message, exceptionCodes = [], options = {}) {
|
|
7
|
-
super(message, [ExceptionCode.ApplicationException, ...exceptionCodes], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = ApplicationException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.ApplicationException);
|
|
13
|
-
})();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { ApplicationException } from './application.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class NotAllowedException extends ApplicationException {
|
|
6
|
-
constructor(message, options = {}) {
|
|
7
|
-
super(message, [ExceptionCode.NotAllowed], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = NotAllowedException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.NotAllowed);
|
|
13
|
-
})();
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
2
|
-
import type { ExceptionOptions } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
4
|
-
export declare class DomainException extends AbstractException {
|
|
5
|
-
constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class DomainException extends AbstractException {
|
|
6
|
-
constructor(message, exceptionCodes = [], options = {}) {
|
|
7
|
-
super(message, [ExceptionCode.DomainException, ...exceptionCodes], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = DomainException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.DomainException);
|
|
13
|
-
})();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare enum ExceptionCode {
|
|
2
|
-
DomainException = "DOM000",
|
|
3
|
-
ValidationFailed = "DOM001",
|
|
4
|
-
TypeFailed = "DOM003",
|
|
5
|
-
RequiredValue = "DOM004",
|
|
6
|
-
ApplicationException = "APP000",
|
|
7
|
-
ConcurrencyConflict = "APP001",
|
|
8
|
-
AggregateNotFound = "APP002",
|
|
9
|
-
NotAllowed = "APP003",
|
|
10
|
-
InfrastructureException = "INF000",
|
|
11
|
-
InternalError = "INF001",
|
|
12
|
-
UnknownEvent = "INF002",
|
|
13
|
-
EventDelivery = "INF003",
|
|
14
|
-
ErrorException = "E000"
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export var ExceptionCode;
|
|
2
|
-
(function (ExceptionCode) {
|
|
3
|
-
ExceptionCode["DomainException"] = "DOM000";
|
|
4
|
-
ExceptionCode["ValidationFailed"] = "DOM001";
|
|
5
|
-
ExceptionCode["TypeFailed"] = "DOM003";
|
|
6
|
-
ExceptionCode["RequiredValue"] = "DOM004";
|
|
7
|
-
ExceptionCode["ApplicationException"] = "APP000";
|
|
8
|
-
ExceptionCode["ConcurrencyConflict"] = "APP001";
|
|
9
|
-
ExceptionCode["AggregateNotFound"] = "APP002";
|
|
10
|
-
ExceptionCode["NotAllowed"] = "APP003";
|
|
11
|
-
ExceptionCode["InfrastructureException"] = "INF000";
|
|
12
|
-
ExceptionCode["InternalError"] = "INF001";
|
|
13
|
-
ExceptionCode["UnknownEvent"] = "INF002";
|
|
14
|
-
ExceptionCode["EventDelivery"] = "INF003";
|
|
15
|
-
ExceptionCode["ErrorException"] = "E000";
|
|
16
|
-
})(ExceptionCode || (ExceptionCode = {}));
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './abstract.exception.js';
|
|
2
|
-
export * from './exception-code.js';
|
|
3
|
-
export * from './application/application.exception.js';
|
|
4
|
-
export * from './application/concurrency.exception.js';
|
|
5
|
-
export * from './application/aggregate-not-found.exception.js';
|
|
6
|
-
export * from './application/not-allowed.exception.js';
|
|
7
|
-
export * from './infrastructure/infrastructure.exception.js';
|
|
8
|
-
export * from './infrastructure/internal-error.exception.js';
|
|
9
|
-
export * from './infrastructure/unknown-event.exception.js';
|
|
10
|
-
export * from './infrastructure/event-delivery.exception.js';
|
|
11
|
-
export * from './domain/validation.exception.js';
|
|
12
|
-
export * from './domain/domain.exception.js';
|
|
13
|
-
export * from './domain/required-value.exception.js';
|
|
14
|
-
export * from './domain/type-primitive.exception.js';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './abstract.exception.js';
|
|
2
|
-
export * from './exception-code.js';
|
|
3
|
-
export * from './application/application.exception.js';
|
|
4
|
-
export * from './application/concurrency.exception.js';
|
|
5
|
-
export * from './application/aggregate-not-found.exception.js';
|
|
6
|
-
export * from './application/not-allowed.exception.js';
|
|
7
|
-
export * from './infrastructure/infrastructure.exception.js';
|
|
8
|
-
export * from './infrastructure/internal-error.exception.js';
|
|
9
|
-
export * from './infrastructure/unknown-event.exception.js';
|
|
10
|
-
export * from './infrastructure/event-delivery.exception.js';
|
|
11
|
-
export * from './domain/validation.exception.js';
|
|
12
|
-
export * from './domain/domain.exception.js';
|
|
13
|
-
export * from './domain/required-value.exception.js';
|
|
14
|
-
export * from './domain/type-primitive.exception.js';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
2
|
-
import type { ExceptionOptions } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
4
|
-
export declare class InfrastructureException extends AbstractException {
|
|
5
|
-
constructor(message: string, exceptionCodes?: (ExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { AbstractException } from '../abstract.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class InfrastructureException extends AbstractException {
|
|
6
|
-
constructor(message, exceptionCodes = [], options = {}) {
|
|
7
|
-
super(message, [ExceptionCode.InfrastructureException, ...exceptionCodes], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = InfrastructureException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.InfrastructureException);
|
|
13
|
-
})();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { InfrastructureException } from './infrastructure.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
|
-
export class InternalErrorException extends InfrastructureException {
|
|
6
|
-
constructor(message, options = {}) {
|
|
7
|
-
super(`Failed, internal error: ${message}`, [ExceptionCode.InternalError], options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
_a = InternalErrorException;
|
|
11
|
-
(() => {
|
|
12
|
-
ExceptionBrand.brandClass(_a, ExceptionCode.InternalError);
|
|
13
|
-
})();
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ValidationIssue } from '../../exceptions/index.js';
|
|
2
|
-
import type { Logger } from '../../application/index.js';
|
|
3
|
-
export interface HttpErrorBody {
|
|
4
|
-
code: string;
|
|
5
|
-
message: string;
|
|
6
|
-
errors?: readonly ValidationIssue[];
|
|
7
|
-
}
|
|
8
|
-
export interface HttpError {
|
|
9
|
-
status: number;
|
|
10
|
-
body: HttpErrorBody;
|
|
11
|
-
}
|
|
12
|
-
export interface HttpErrorMapperOptions {
|
|
13
|
-
readonly statusByCode?: Readonly<Record<string, number>>;
|
|
14
|
-
readonly logger?: Logger;
|
|
15
|
-
}
|
|
16
|
-
export declare class HttpErrorMapper {
|
|
17
|
-
private readonly statusByCode;
|
|
18
|
-
private readonly logger;
|
|
19
|
-
constructor({ statusByCode, logger }?: HttpErrorMapperOptions);
|
|
20
|
-
map(error: unknown): HttpError;
|
|
21
|
-
private toHttpError;
|
|
22
|
-
private static defaultStatus;
|
|
23
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { AbstractException, AggregateNotFoundException, ApplicationException, ConcurrencyException, DomainException, ExceptionCode, NotAllowedException, RequiredValueException, TypePrimitiveException, ValidationException, } from '../../exceptions/index.js';
|
|
2
|
-
import { SilentLogger } from '../logging/silent-logger.js';
|
|
3
|
-
const INTERNAL_MESSAGE = 'Internal server error';
|
|
4
|
-
export class HttpErrorMapper {
|
|
5
|
-
constructor({ statusByCode = {}, logger = new SilentLogger() } = {}) {
|
|
6
|
-
this.statusByCode = statusByCode;
|
|
7
|
-
this.logger = logger;
|
|
8
|
-
}
|
|
9
|
-
map(error) {
|
|
10
|
-
const mapped = this.toHttpError(error);
|
|
11
|
-
const { status, body } = mapped;
|
|
12
|
-
if (status >= 500) {
|
|
13
|
-
this.logger.error('http_request_failed', { status, code: body.code, error });
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
this.logger.debug('http_request_rejected', { status, code: body.code });
|
|
17
|
-
}
|
|
18
|
-
return mapped;
|
|
19
|
-
}
|
|
20
|
-
toHttpError(error) {
|
|
21
|
-
if (!(error instanceof AbstractException)) {
|
|
22
|
-
return {
|
|
23
|
-
status: 500,
|
|
24
|
-
body: { code: ExceptionCode.ErrorException, message: INTERNAL_MESSAGE },
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const status = Object.prototype.hasOwnProperty.call(this.statusByCode, error.code)
|
|
28
|
-
? this.statusByCode[error.code]
|
|
29
|
-
: HttpErrorMapper.defaultStatus(error);
|
|
30
|
-
if (status >= 500) {
|
|
31
|
-
return { status, body: { code: error.code, message: INTERNAL_MESSAGE } };
|
|
32
|
-
}
|
|
33
|
-
if (error instanceof ValidationException) {
|
|
34
|
-
return { status, body: { code: error.code, message: error.message, errors: error.errors } };
|
|
35
|
-
}
|
|
36
|
-
return { status, body: { code: error.code, message: error.message } };
|
|
37
|
-
}
|
|
38
|
-
static defaultStatus(error) {
|
|
39
|
-
if (error instanceof AggregateNotFoundException) {
|
|
40
|
-
return 404;
|
|
41
|
-
}
|
|
42
|
-
if (error instanceof NotAllowedException) {
|
|
43
|
-
return 403;
|
|
44
|
-
}
|
|
45
|
-
if (error instanceof ConcurrencyException) {
|
|
46
|
-
return 409;
|
|
47
|
-
}
|
|
48
|
-
if (error instanceof TypePrimitiveException || error instanceof RequiredValueException) {
|
|
49
|
-
return 400;
|
|
50
|
-
}
|
|
51
|
-
if (error instanceof DomainException) {
|
|
52
|
-
return 422;
|
|
53
|
-
}
|
|
54
|
-
if (error instanceof ApplicationException) {
|
|
55
|
-
return 400;
|
|
56
|
-
}
|
|
57
|
-
return 500;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|