@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,8 +1,40 @@
|
|
|
1
1
|
import { toDate } from '@archi-code/validation';
|
|
2
2
|
import { AbstractType } from './abstract-type.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { Required } from './required/required-type.js';
|
|
4
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
5
|
+
class ImmutableDate extends Date {
|
|
6
|
+
constructor(date) {
|
|
7
|
+
super(date.getTime());
|
|
8
|
+
Object.freeze(this);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
ImmutableDate.setters = [
|
|
12
|
+
'setDate',
|
|
13
|
+
'setFullYear',
|
|
14
|
+
'setHours',
|
|
15
|
+
'setMilliseconds',
|
|
16
|
+
'setMinutes',
|
|
17
|
+
'setMonth',
|
|
18
|
+
'setSeconds',
|
|
19
|
+
'setTime',
|
|
20
|
+
'setUTCDate',
|
|
21
|
+
'setUTCFullYear',
|
|
22
|
+
'setUTCHours',
|
|
23
|
+
'setUTCMilliseconds',
|
|
24
|
+
'setUTCMinutes',
|
|
25
|
+
'setUTCMonth',
|
|
26
|
+
'setUTCSeconds',
|
|
27
|
+
'setYear',
|
|
28
|
+
];
|
|
29
|
+
(() => {
|
|
30
|
+
for (const setter of ImmutableDate.setters) {
|
|
31
|
+
Object.defineProperty(ImmutableDate.prototype, setter, {
|
|
32
|
+
value() {
|
|
33
|
+
throw new TypeError(`Cannot call ${setter}: the date is immutable`);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
6
38
|
const TIME_WITHOUT_ZONE = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/;
|
|
7
39
|
export class DateType extends AbstractType {
|
|
8
40
|
filter(value) {
|
|
@@ -10,11 +42,14 @@ export class DateType extends AbstractType {
|
|
|
10
42
|
if (!converted.ok || (typeof value === 'string' && TIME_WITHOUT_ZONE.test(value))) {
|
|
11
43
|
throw new TypePrimitiveException('Date', value);
|
|
12
44
|
}
|
|
13
|
-
return
|
|
45
|
+
return new ImmutableDate(converted.value);
|
|
14
46
|
}
|
|
15
47
|
toString() {
|
|
16
48
|
return this._value === null ? '' : this._value.toISOString();
|
|
17
49
|
}
|
|
50
|
+
hasSameValue(other) {
|
|
51
|
+
return this._value?.getTime() === other._value?.getTime();
|
|
52
|
+
}
|
|
18
53
|
}
|
|
19
54
|
const SYSTEM_TIME = { now: () => new Date() };
|
|
20
55
|
export class CreatedAt extends Required(DateType) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractType } from './abstract-type.js';
|
|
2
|
-
import { TypePrimitiveException } from '
|
|
2
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
3
3
|
const NUMERIC_TEXT = /^-?\d+(?:\.\d+)?$/;
|
|
4
4
|
export class EnumType extends AbstractType {
|
|
5
5
|
filter(value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UuidType } from './uuid-type.js';
|
|
2
|
-
declare const IdType_base: import("./required/required.js").RequiredType<typeof UuidType>;
|
|
2
|
+
declare const IdType_base: import("./required/required-type.js").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,6 +1,6 @@
|
|
|
1
|
-
import { Required } from './required/required.js';
|
|
1
|
+
import { Required } from './required/required-type.js';
|
|
2
2
|
import { UuidType } from './uuid-type.js';
|
|
3
|
-
import { TypePrimitiveException } from '
|
|
3
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
4
4
|
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;
|
|
5
5
|
export class IdType extends Required(UuidType) {
|
|
6
6
|
filter(value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AbstractType } from './abstract-type.js';
|
|
2
|
-
export { Required } from './required/required.js';
|
|
3
|
-
export type { RequiredType } from './required/required.js';
|
|
2
|
+
export { Required } from './required/required-type.js';
|
|
3
|
+
export type { RequiredType } from './required/required-type.js';
|
|
4
4
|
export { ArrayType } from './array-type.js';
|
|
5
5
|
export { BooleanType } from './boolean-type.js';
|
|
6
6
|
export { CreatedAt, DateType, UpdatedAt } from './date-type.js';
|
|
@@ -11,7 +11,5 @@ export { NumberType } from './number-type.js';
|
|
|
11
11
|
export { StringType } from './string-type.js';
|
|
12
12
|
export { IdType } from './id-type.js';
|
|
13
13
|
export { UuidType } from './uuid-type.js';
|
|
14
|
-
export { Immutable } from './immutable/immutable.js';
|
|
15
|
-
export { ValueObjects } from './value-objects/value-objects.js';
|
|
16
14
|
export { Composite } from './composite/composite.js';
|
|
17
15
|
export type { CompositeInput, CompositePrimitives, CompositeProps, CompositeSchema, CompositeType, CompositeValue, } from './composite/composite.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AbstractType } from './abstract-type.js';
|
|
2
|
-
export { Required } from './required/required.js';
|
|
2
|
+
export { Required } from './required/required-type.js';
|
|
3
3
|
export { ArrayType } from './array-type.js';
|
|
4
4
|
export { BooleanType } from './boolean-type.js';
|
|
5
5
|
export { CreatedAt, DateType, UpdatedAt } from './date-type.js';
|
|
@@ -9,6 +9,4 @@ export { NumberType } from './number-type.js';
|
|
|
9
9
|
export { StringType } from './string-type.js';
|
|
10
10
|
export { IdType } from './id-type.js';
|
|
11
11
|
export { UuidType } from './uuid-type.js';
|
|
12
|
-
export { Immutable } from './immutable/immutable.js';
|
|
13
|
-
export { ValueObjects } from './value-objects/value-objects.js';
|
|
14
12
|
export { Composite } from './composite/composite.js';
|
|
@@ -2,4 +2,8 @@ import { AbstractType } from './abstract-type.js';
|
|
|
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
|
}
|
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
import { toJson } from '@archi-code/validation';
|
|
2
2
|
import { AbstractType } from './abstract-type.js';
|
|
3
|
-
import {
|
|
4
|
-
import { TypePrimitiveException } from '../../exceptions/index.js';
|
|
3
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
5
4
|
export class JsonType extends AbstractType {
|
|
6
5
|
filter(value) {
|
|
7
6
|
const converted = toJson(value);
|
|
8
7
|
if (!converted.ok) {
|
|
9
8
|
throw new TypePrimitiveException('Json', value);
|
|
10
9
|
}
|
|
11
|
-
return
|
|
10
|
+
return JsonType.deepFreeze(JSON.parse(JSON.stringify(converted.value)));
|
|
11
|
+
}
|
|
12
|
+
hasSameValue(other) {
|
|
13
|
+
return JsonType.sameJson(this._value, other._value);
|
|
14
|
+
}
|
|
15
|
+
static sameJson(left, right) {
|
|
16
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
17
|
+
return (Array.isArray(left) &&
|
|
18
|
+
Array.isArray(right) &&
|
|
19
|
+
left.length === right.length &&
|
|
20
|
+
left.every((item, index) => JsonType.sameJson(item, right[index])));
|
|
21
|
+
}
|
|
22
|
+
if (JsonType.isObject(left) && JsonType.isObject(right)) {
|
|
23
|
+
const keys = Object.keys(left);
|
|
24
|
+
return (keys.length === Object.keys(right).length &&
|
|
25
|
+
keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
|
|
26
|
+
JsonType.sameJson(left[key], right[key])));
|
|
27
|
+
}
|
|
28
|
+
return left === right;
|
|
29
|
+
}
|
|
30
|
+
static deepFreeze(value) {
|
|
31
|
+
if (JsonType.isObject(value)) {
|
|
32
|
+
Object.freeze(value);
|
|
33
|
+
for (const child of Object.values(value)) {
|
|
34
|
+
JsonType.deepFreeze(child);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
static isObject(value) {
|
|
40
|
+
return typeof value === 'object' && value !== null;
|
|
12
41
|
}
|
|
13
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toFloat } from '@archi-code/validation';
|
|
2
2
|
import { AbstractType } from './abstract-type.js';
|
|
3
|
-
import { TypePrimitiveException } from '
|
|
3
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
4
4
|
export class NumberType extends AbstractType {
|
|
5
5
|
filter(value) {
|
|
6
6
|
const converted = toFloat(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toString as convertToString } from '@archi-code/validation';
|
|
2
2
|
import { AbstractType } from './abstract-type.js';
|
|
3
|
-
import { TypePrimitiveException } from '
|
|
3
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
4
4
|
export class StringType extends AbstractType {
|
|
5
5
|
filter(value) {
|
|
6
6
|
const converted = convertToString(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
|
|
2
2
|
import { isUUID, toString as convertToString } from '@archi-code/validation';
|
|
3
3
|
import { AbstractType } from './abstract-type.js';
|
|
4
|
-
import { TypePrimitiveException } from '
|
|
4
|
+
import { TypePrimitiveException } from '../exceptions/type-primitive.exception.js';
|
|
5
5
|
const DNS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
6
6
|
export class UuidType extends AbstractType {
|
|
7
7
|
static random() {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ApplicationException
|
|
1
|
+
import { ApplicationException } from '../../application/index.js';
|
|
2
|
+
import { DomainException } from '../../domain/index.js';
|
|
3
|
+
import { UnknownEventException } from '../exceptions/unknown-event.exception.js';
|
|
2
4
|
import { ListensTo } from '../../application/index.js';
|
|
3
5
|
import { SilentLogger } from '../logging/silent-logger.js';
|
|
4
6
|
export class DomainEventBus {
|
|
@@ -8,12 +10,11 @@ export class DomainEventBus {
|
|
|
8
10
|
this.logger = logger;
|
|
9
11
|
}
|
|
10
12
|
async publish(events) {
|
|
11
|
-
await this.channel.send(events.map((event) => event
|
|
13
|
+
await this.channel.send(events.map((event) => ({ ...event })));
|
|
12
14
|
this.logger.debug('domain_events_published', {
|
|
13
15
|
events: events.map((event) => ({
|
|
14
|
-
eventName: event.eventName
|
|
16
|
+
eventName: event.eventName,
|
|
15
17
|
eventId: event.eventId,
|
|
16
|
-
aggregateId: event.aggregateId,
|
|
17
18
|
})),
|
|
18
19
|
});
|
|
19
20
|
}
|
|
@@ -41,7 +42,6 @@ export class DomainEventBus {
|
|
|
41
42
|
eventName,
|
|
42
43
|
consumer,
|
|
43
44
|
eventId: serialized.eventId,
|
|
44
|
-
aggregateId: serialized.aggregateId,
|
|
45
45
|
error,
|
|
46
46
|
};
|
|
47
47
|
if (error instanceof DomainException || error instanceof ApplicationException) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InternalErrorException
|
|
2
|
-
import {
|
|
1
|
+
import { InternalErrorException } from '../exceptions/internal-error.exception.js';
|
|
2
|
+
import { UnknownEventException } from '../exceptions/unknown-event.exception.js';
|
|
3
3
|
export class EventRegistry {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.factories = new Map();
|
|
@@ -28,11 +28,11 @@ export class EventRegistry {
|
|
|
28
28
|
}
|
|
29
29
|
const rebuilt = factory(event);
|
|
30
30
|
EventRegistry.assertSameIdentity(event, rebuilt);
|
|
31
|
-
return
|
|
31
|
+
return rebuilt;
|
|
32
32
|
}
|
|
33
33
|
static assertSameIdentity(serialized, rebuilt) {
|
|
34
34
|
if (rebuilt.eventId !== String(serialized.eventId).toLowerCase() ||
|
|
35
|
-
rebuilt.occurredOn
|
|
35
|
+
Date.parse(rebuilt.occurredOn) !== Date.parse(serialized.occurredOn)) {
|
|
36
36
|
throw new InternalErrorException(`the factory of "${serialized.eventName}" must pass the serialized event as metadata, so it keeps its eventId and occurredOn`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -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,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InfrastructureException } from '../../../exceptions/index.js';
|
|
1
|
+
import { InfrastructureException } from '../../exceptions/infrastructure.exception.js';
|
|
3
2
|
import { Emitter } from './emitter.js';
|
|
4
3
|
export class InMemoryEventChannel {
|
|
5
4
|
constructor({ delivery = 'serial' } = {}) {
|
|
@@ -13,7 +12,7 @@ export class InMemoryEventChannel {
|
|
|
13
12
|
}
|
|
14
13
|
async send(events) {
|
|
15
14
|
for (const event of events) {
|
|
16
|
-
const copy = InMemoryEventChannel.
|
|
15
|
+
const copy = InMemoryEventChannel.copy(event);
|
|
17
16
|
this.sentEvents.push(copy);
|
|
18
17
|
if (this.delivery === 'parallel') {
|
|
19
18
|
await this.emitter.emit(copy.eventName, copy);
|
|
@@ -29,7 +28,7 @@ export class InMemoryEventChannel {
|
|
|
29
28
|
throw new InfrastructureException(`${consumer} already receives "${eventName}": close its subscription first.`);
|
|
30
29
|
}
|
|
31
30
|
this.receivers.add(receiver);
|
|
32
|
-
const off = this.emitter.on(eventName, (event) => handler(event));
|
|
31
|
+
const off = this.emitter.on(eventName, (event) => handler(InMemoryEventChannel.copy(event)));
|
|
33
32
|
let open = true;
|
|
34
33
|
return {
|
|
35
34
|
close: async () => {
|
|
@@ -41,7 +40,7 @@ export class InMemoryEventChannel {
|
|
|
41
40
|
},
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
static
|
|
45
|
-
return
|
|
43
|
+
static copy(event) {
|
|
44
|
+
return JSON.parse(JSON.stringify(event));
|
|
46
45
|
}
|
|
47
46
|
}
|
package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/event-delivery.exception.js
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
|
|
2
4
|
import { InfrastructureException } from './infrastructure.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
5
|
export class EventDeliveryException extends InfrastructureException {
|
|
6
6
|
constructor(eventName, errors, consumers) {
|
|
7
7
|
super(`${errors.length} of ${consumers} consumers of "${eventName}" failed.`, [
|
|
8
|
-
|
|
8
|
+
InfrastructureExceptionCode.EventDelivery,
|
|
9
9
|
]);
|
|
10
10
|
this.errors = Object.freeze([...errors]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
_a = EventDeliveryException;
|
|
14
14
|
(() => {
|
|
15
|
-
ExceptionBrand.brandClass(_a,
|
|
15
|
+
ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.EventDelivery);
|
|
16
16
|
})();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var InfrastructureExceptionCode;
|
|
2
|
+
(function (InfrastructureExceptionCode) {
|
|
3
|
+
InfrastructureExceptionCode["InfrastructureException"] = "INF000";
|
|
4
|
+
InfrastructureExceptionCode["InternalError"] = "INF001";
|
|
5
|
+
InfrastructureExceptionCode["UnknownEvent"] = "INF002";
|
|
6
|
+
InfrastructureExceptionCode["EventDelivery"] = "INF003";
|
|
7
|
+
})(InfrastructureExceptionCode || (InfrastructureExceptionCode = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractException } from '../../shared/index.js';
|
|
2
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
|
|
4
|
+
export declare class InfrastructureException extends AbstractException {
|
|
5
|
+
constructor(message: string, exceptionCodes?: (InfrastructureExceptionCode | string)[], options?: ExceptionOptions);
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { AbstractException, ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
|
|
4
|
+
export class InfrastructureException extends AbstractException {
|
|
5
|
+
constructor(message, exceptionCodes = [], options = {}) {
|
|
6
|
+
super(message, [InfrastructureExceptionCode.InfrastructureException, ...exceptionCodes], options, InfrastructureExceptionCode);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
_a = InfrastructureException;
|
|
10
|
+
(() => {
|
|
11
|
+
ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.InfrastructureException);
|
|
12
|
+
})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ExceptionOptions } from '../../shared/index.js';
|
|
1
2
|
import { InfrastructureException } from './infrastructure.exception.js';
|
|
2
|
-
import type { ExceptionOptions } from '../abstract.exception.js';
|
|
3
3
|
export declare class InternalErrorException extends InfrastructureException {
|
|
4
4
|
constructor(message: string, options?: ExceptionOptions);
|
|
5
5
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
|
|
4
|
+
import { InfrastructureException } from './infrastructure.exception.js';
|
|
5
|
+
export class InternalErrorException extends InfrastructureException {
|
|
6
|
+
constructor(message, options = {}) {
|
|
7
|
+
super(`Failed, internal error: ${message}`, [InfrastructureExceptionCode.InternalError], options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
_a = InternalErrorException;
|
|
11
|
+
(() => {
|
|
12
|
+
ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.InternalError);
|
|
13
|
+
})();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApplicationException, AggregateNotFoundException, ConcurrencyException, NotAllowedException, UnexpectedErrorException, } from '../../../application/index.js';
|
|
2
|
+
import { DomainException, InvalidEventDefinitionException, RequiredValueException, TypePrimitiveException, } from '../../../domain/index.js';
|
|
3
|
+
import { ExceptionKind } from './exception-kind.js';
|
|
4
|
+
export class ExceptionClassifier {
|
|
5
|
+
static classify(error) {
|
|
6
|
+
if (error instanceof AggregateNotFoundException) {
|
|
7
|
+
return ExceptionKind.NotFound;
|
|
8
|
+
}
|
|
9
|
+
if (error instanceof NotAllowedException) {
|
|
10
|
+
return ExceptionKind.NotAllowed;
|
|
11
|
+
}
|
|
12
|
+
if (error instanceof ConcurrencyException) {
|
|
13
|
+
return ExceptionKind.Conflict;
|
|
14
|
+
}
|
|
15
|
+
if (error instanceof UnexpectedErrorException ||
|
|
16
|
+
error instanceof InvalidEventDefinitionException) {
|
|
17
|
+
return ExceptionKind.Internal;
|
|
18
|
+
}
|
|
19
|
+
if (error instanceof TypePrimitiveException || error instanceof RequiredValueException) {
|
|
20
|
+
return ExceptionKind.Malformed;
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof DomainException) {
|
|
23
|
+
return ExceptionKind.Invalid;
|
|
24
|
+
}
|
|
25
|
+
if (error instanceof ApplicationException) {
|
|
26
|
+
return ExceptionKind.Rejected;
|
|
27
|
+
}
|
|
28
|
+
return ExceptionKind.Internal;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var ExceptionKind;
|
|
2
|
+
(function (ExceptionKind) {
|
|
3
|
+
ExceptionKind["NotFound"] = "not_found";
|
|
4
|
+
ExceptionKind["NotAllowed"] = "not_allowed";
|
|
5
|
+
ExceptionKind["Conflict"] = "conflict";
|
|
6
|
+
ExceptionKind["Malformed"] = "malformed";
|
|
7
|
+
ExceptionKind["Invalid"] = "invalid";
|
|
8
|
+
ExceptionKind["Rejected"] = "rejected";
|
|
9
|
+
ExceptionKind["Internal"] = "internal";
|
|
10
|
+
})(ExceptionKind || (ExceptionKind = {}));
|
package/dist/esm/{exceptions/infrastructure → infrastructure/exceptions}/unknown-event.exception.js
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { ExceptionBrand } from '../../shared/index.js';
|
|
3
|
+
import { InfrastructureExceptionCode } from './infrastructure-exception-code.js';
|
|
2
4
|
import { InfrastructureException } from './infrastructure.exception.js';
|
|
3
|
-
import { ExceptionBrand } from '../brand/exception-brand.js';
|
|
4
|
-
import { ExceptionCode } from '../exception-code.js';
|
|
5
5
|
export class UnknownEventException extends InfrastructureException {
|
|
6
6
|
constructor(eventName) {
|
|
7
7
|
super(`Unknown event "${eventName}": register it before reading it.`, [
|
|
8
|
-
|
|
8
|
+
InfrastructureExceptionCode.UnknownEvent,
|
|
9
9
|
]);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
_a = UnknownEventException;
|
|
13
13
|
(() => {
|
|
14
|
-
ExceptionBrand.brandClass(_a,
|
|
14
|
+
ExceptionBrand.brandClass(_a, InfrastructureExceptionCode.UnknownEvent);
|
|
15
15
|
})();
|
|
@@ -7,10 +7,15 @@ export type { EventFactory } from './event/event-registry.js';
|
|
|
7
7
|
export type { ChannelHandler, ChannelSubscription, EventChannel } from './event/event-channel.js';
|
|
8
8
|
export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel.js';
|
|
9
9
|
export type { InMemoryEventChannelOptions } from './event/in-memory/in-memory-event-channel.js';
|
|
10
|
-
export { HttpErrorMapper } from './http/http-error-mapper.js';
|
|
11
|
-
export type { HttpError, HttpErrorBody, HttpErrorMapperOptions } from './http/http-error-mapper.js';
|
|
12
10
|
export { ConsoleLogger } from './logging/console-logger.js';
|
|
13
11
|
export type { ConsoleLoggerOptions } from './logging/console-logger.js';
|
|
14
12
|
export { InMemoryLogger } from './logging/in-memory-logger.js';
|
|
15
13
|
export type { LogEntry } from './logging/in-memory-logger.js';
|
|
16
14
|
export { SilentLogger } from './logging/silent-logger.js';
|
|
15
|
+
export { InfrastructureException } from './exceptions/infrastructure.exception.js';
|
|
16
|
+
export { InternalErrorException } from './exceptions/internal-error.exception.js';
|
|
17
|
+
export { UnknownEventException } from './exceptions/unknown-event.exception.js';
|
|
18
|
+
export { EventDeliveryException } from './exceptions/event-delivery.exception.js';
|
|
19
|
+
export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code.js';
|
|
20
|
+
export { ExceptionClassifier } from './exceptions/kind/exception-classifier.js';
|
|
21
|
+
export { ExceptionKind } from './exceptions/kind/exception-kind.js';
|
|
@@ -3,7 +3,13 @@ export { FixedClock } from './clock/fixed-clock.js';
|
|
|
3
3
|
export { DomainEventBus } from './event/domain-event-bus.js';
|
|
4
4
|
export { EventRegistry } from './event/event-registry.js';
|
|
5
5
|
export { InMemoryEventChannel } from './event/in-memory/in-memory-event-channel.js';
|
|
6
|
-
export { HttpErrorMapper } from './http/http-error-mapper.js';
|
|
7
6
|
export { ConsoleLogger } from './logging/console-logger.js';
|
|
8
7
|
export { InMemoryLogger } from './logging/in-memory-logger.js';
|
|
9
8
|
export { SilentLogger } from './logging/silent-logger.js';
|
|
9
|
+
export { InfrastructureException } from './exceptions/infrastructure.exception.js';
|
|
10
|
+
export { InternalErrorException } from './exceptions/internal-error.exception.js';
|
|
11
|
+
export { UnknownEventException } from './exceptions/unknown-event.exception.js';
|
|
12
|
+
export { EventDeliveryException } from './exceptions/event-delivery.exception.js';
|
|
13
|
+
export { InfrastructureExceptionCode } from './exceptions/infrastructure-exception-code.js';
|
|
14
|
+
export { ExceptionClassifier } from './exceptions/kind/exception-classifier.js';
|
|
15
|
+
export { ExceptionKind } from './exceptions/kind/exception-kind.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InternalErrorException } from '
|
|
1
|
+
import { InternalErrorException } from '../exceptions/internal-error.exception.js';
|
|
2
2
|
import { SystemClock } from '../clock/system-clock.js';
|
|
3
3
|
import { LogSerializer } from './log-serializer.js';
|
|
4
4
|
export class ConsoleLogger {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { ExceptionCode } from './exception-code';
|
|
2
1
|
export interface ExceptionOptions {
|
|
3
2
|
cause?: unknown;
|
|
4
3
|
}
|
|
4
|
+
export type ExceptionCodeNames = Readonly<Record<string, string>>;
|
|
5
5
|
export declare abstract class AbstractException extends Error {
|
|
6
|
+
private static readonly fallbackCode;
|
|
6
7
|
readonly cause?: unknown;
|
|
7
8
|
private readonly exceptionCodes;
|
|
8
|
-
readonly
|
|
9
|
+
private readonly codeNames;
|
|
10
|
+
readonly code: string;
|
|
9
11
|
private readonly createdAt;
|
|
10
12
|
static [Symbol.hasInstance](candidate: unknown): boolean;
|
|
11
|
-
constructor(message: string, exceptionCodes:
|
|
12
|
-
static readonly ExceptionCodeStrings: Record<ExceptionCode, string>;
|
|
13
|
+
constructor(message: string, exceptionCodes: string[], options?: ExceptionOptions, codeNames?: ExceptionCodeNames);
|
|
13
14
|
get timestamp(): Date;
|
|
14
15
|
get description(): string;
|
|
16
|
+
private labelOf;
|
|
15
17
|
print(): string;
|
|
16
18
|
toJSON(): {
|
|
17
19
|
name: string;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import { ExceptionCode } from './exception-code.js';
|
|
3
2
|
import { ExceptionBrand } from './brand/exception-brand.js';
|
|
4
3
|
export class AbstractException extends Error {
|
|
5
4
|
static [Symbol.hasInstance](candidate) {
|
|
6
5
|
return (Function.prototype[Symbol.hasInstance].call(this, candidate) ||
|
|
7
6
|
ExceptionBrand.matches(this, candidate));
|
|
8
7
|
}
|
|
9
|
-
constructor(message, exceptionCodes, options = {}) {
|
|
8
|
+
constructor(message, exceptionCodes, options = {}, codeNames = {}) {
|
|
10
9
|
super(message);
|
|
11
10
|
this.name = this.constructor.name;
|
|
12
11
|
this.exceptionCodes = exceptionCodes;
|
|
12
|
+
this.codeNames = codeNames;
|
|
13
13
|
this.code =
|
|
14
14
|
exceptionCodes.length > 0
|
|
15
15
|
? exceptionCodes[exceptionCodes.length - 1]
|
|
16
|
-
:
|
|
16
|
+
: _a.fallbackCode;
|
|
17
17
|
this.createdAt = Date.now();
|
|
18
18
|
if ('cause' in options) {
|
|
19
19
|
Object.defineProperty(this, 'cause', {
|
|
@@ -29,12 +29,11 @@ export class AbstractException extends Error {
|
|
|
29
29
|
return new Date(this.createdAt);
|
|
30
30
|
}
|
|
31
31
|
get description() {
|
|
32
|
-
return this.exceptionCodes
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.join(', ');
|
|
32
|
+
return this.exceptionCodes.map((code) => `${this.labelOf(code)} (${code})`).join(', ');
|
|
33
|
+
}
|
|
34
|
+
labelOf(code) {
|
|
35
|
+
const name = Object.keys(this.codeNames).find((key) => this.codeNames[key] === code);
|
|
36
|
+
return name === undefined ? this.name : name.replace(/([A-Z])/g, ' $1').trim();
|
|
38
37
|
}
|
|
39
38
|
print() {
|
|
40
39
|
return `[${this.description}]: ${this.message}, ${this.timestamp.toISOString()}`;
|
|
@@ -50,13 +49,7 @@ export class AbstractException extends Error {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
_a = AbstractException;
|
|
52
|
+
AbstractException.fallbackCode = 'E000';
|
|
53
53
|
(() => {
|
|
54
54
|
ExceptionBrand.brandClass(_a, ExceptionBrand.anyCode);
|
|
55
55
|
})();
|
|
56
|
-
AbstractException.ExceptionCodeStrings = Object.keys(ExceptionCode)
|
|
57
|
-
.filter((key) => isNaN(Number(key)))
|
|
58
|
-
.reduce((acc, key) => {
|
|
59
|
-
const value = ExceptionCode[key];
|
|
60
|
-
acc[value] = key.replace(/([A-Z])/g, ' $1').trim();
|
|
61
|
-
return acc;
|
|
62
|
-
}, {});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AbstractException } from './exceptions/abstract.exception.js';
|
|
2
|
+
export type { ExceptionCodeNames, ExceptionOptions } from './exceptions/abstract.exception.js';
|
|
3
|
+
export { ExceptionBrand } from './exceptions/brand/exception-brand.js';
|
|
4
|
+
export { ReceivedValue } from './exceptions/received/received-value.js';
|
|
5
|
+
export { IssueCollector } from './issue-collector.js';
|
|
6
|
+
export type { IssueReader } from './issue-collector.js';
|
|
7
|
+
export { IssueCollectionError } from './issue-collection-error.js';
|
|
8
|
+
export type { CollectedIssue } from './issue-collection-error.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AbstractException } from './exceptions/abstract.exception.js';
|
|
2
|
+
export { ExceptionBrand } from './exceptions/brand/exception-brand.js';
|
|
3
|
+
export { ReceivedValue } from './exceptions/received/received-value.js';
|
|
4
|
+
export { IssueCollector } from './issue-collector.js';
|
|
5
|
+
export { IssueCollectionError } from './issue-collection-error.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CollectedIssue {
|
|
2
|
+
readonly field: string | null;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class IssueCollectionError extends Error {
|
|
7
|
+
readonly issues: readonly CollectedIssue[];
|
|
8
|
+
constructor(issues: readonly CollectedIssue[]);
|
|
9
|
+
}
|