@ddd-ts-kit/kernel 0.114.1 → 0.116.0
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.fr.md +74 -60
- package/README.md +68 -55
- package/dist/application/audit/restamped.d.ts +9 -0
- package/dist/application/audit/restamped.d.ts.map +1 -0
- package/dist/application/audit/restamped.js +9 -0
- package/dist/application/audit/restamped.js.map +1 -0
- package/dist/application/audit/stamp-update.d.ts +1 -6
- package/dist/application/audit/stamp-update.d.ts.map +1 -1
- package/dist/application/audit/stamp-update.js +2 -8
- package/dist/application/audit/stamp-update.js.map +1 -1
- package/dist/application/background/enqueued-job.d.ts +1 -1
- package/dist/application/background/enqueued-job.d.ts.map +1 -1
- package/dist/application/error-reporting/report-once.d.ts.map +1 -1
- package/dist/application/error-reporting/report-once.js +2 -6
- package/dist/application/error-reporting/report-once.js.map +1 -1
- package/dist/application/event-sourcing/event-envelope.d.ts +2 -1
- package/dist/application/event-sourcing/event-envelope.d.ts.map +1 -1
- package/dist/application/event-sourcing/event-to-append.d.ts +1 -1
- package/dist/application/event-sourcing/event-to-append.d.ts.map +1 -1
- package/dist/application/execution/with-actor.d.ts +2 -2
- package/dist/application/execution/with-actor.js +3 -3
- package/dist/application/execution/with-actor.js.map +1 -1
- package/dist/application/files/stored-file.d.ts +3 -3
- package/dist/application/files/stored-file.d.ts.map +1 -1
- package/dist/application/hydration/hydration.d.ts.map +1 -1
- package/dist/application/hydration/hydration.js +3 -2
- package/dist/application/hydration/hydration.js.map +1 -1
- package/dist/application/logging/hidden-keys.d.ts +8 -0
- package/dist/application/logging/hidden-keys.d.ts.map +1 -0
- package/dist/application/logging/hidden-keys.js +10 -0
- package/dist/application/logging/hidden-keys.js.map +1 -0
- package/dist/application/logging/index.d.ts +1 -0
- package/dist/application/logging/index.d.ts.map +1 -1
- package/dist/application/logging/index.js +1 -0
- package/dist/application/logging/index.js.map +1 -1
- package/dist/application/observation/safely.d.ts +6 -0
- package/dist/application/observation/safely.d.ts.map +1 -0
- package/dist/application/observation/safely.js +13 -0
- package/dist/application/observation/safely.js.map +1 -0
- package/dist/application/persistence/append-changes.d.ts +1 -0
- package/dist/application/persistence/append-changes.d.ts.map +1 -1
- package/dist/application/persistence/append-changes.js +7 -6
- package/dist/application/persistence/append-changes.js.map +1 -1
- package/dist/application/persistence/optimistic-update.d.ts +6 -2
- package/dist/application/persistence/optimistic-update.d.ts.map +1 -1
- package/dist/application/persistence/optimistic-update.js +11 -3
- package/dist/application/persistence/optimistic-update.js.map +1 -1
- package/dist/application/ports/domain-event-dispatcher.d.ts +1 -1
- package/dist/application/ports/domain-event-dispatcher.js +1 -1
- package/dist/application/ports/logger.d.ts +3 -3
- package/dist/application/ports/unit-of-work.d.ts +1 -1
- package/dist/application/ports/unit-of-work.js +1 -1
- package/dist/application/read-model/stamp-of.d.ts +11 -4
- package/dist/application/read-model/stamp-of.d.ts.map +1 -1
- package/dist/application/read-model/stamp-of.js +10 -8
- package/dist/application/read-model/stamp-of.js.map +1 -1
- package/dist/application/session/anonymous-session.d.ts.map +1 -1
- package/dist/application/session/anonymous-session.js +4 -2
- package/dist/application/session/anonymous-session.js.map +1 -1
- package/dist/application/session/never-issued.d.ts +2 -1
- package/dist/application/session/never-issued.d.ts.map +1 -1
- package/dist/application/session/never-issued.js +4 -1
- package/dist/application/session/never-issued.js.map +1 -1
- package/dist/application/session/system-session.d.ts.map +1 -1
- package/dist/application/session/system-session.js +2 -2
- package/dist/application/session/system-session.js.map +1 -1
- package/dist/application/undecided/index.d.ts +3 -0
- package/dist/application/undecided/index.d.ts.map +1 -0
- package/dist/application/undecided/index.js +3 -0
- package/dist/application/undecided/index.js.map +1 -0
- package/dist/application/undecided/undecided-error.d.ts +12 -0
- package/dist/application/undecided/undecided-error.d.ts.map +1 -0
- package/dist/application/undecided/undecided-error.js +15 -0
- package/dist/application/undecided/undecided-error.js.map +1 -0
- package/dist/application/undecided/undecided.d.ts +7 -0
- package/dist/application/undecided/undecided.d.ts.map +1 -0
- package/dist/application/undecided/undecided.js +9 -0
- package/dist/application/undecided/undecided.js.map +1 -0
- package/dist/domain/aggregate-root.d.ts +6 -13
- package/dist/domain/aggregate-root.d.ts.map +1 -1
- package/dist/domain/aggregate-root.js +10 -16
- package/dist/domain/aggregate-root.js.map +1 -1
- package/dist/domain/aggregate-tracking.d.ts +30 -0
- package/dist/domain/aggregate-tracking.d.ts.map +1 -0
- package/dist/domain/aggregate-tracking.js +48 -0
- package/dist/domain/aggregate-tracking.js.map +1 -0
- package/dist/domain/domain-event.d.ts +4 -0
- package/dist/domain/domain-event.d.ts.map +1 -1
- package/dist/domain/domain-event.js.map +1 -1
- package/dist/domain/errors/domain-error.d.ts.map +1 -1
- package/dist/domain/errors/domain-error.js +2 -1
- package/dist/domain/errors/domain-error.js.map +1 -1
- package/dist/domain/errors/factual-refusal.d.ts.map +1 -1
- package/dist/domain/errors/factual-refusal.js +3 -0
- package/dist/domain/errors/factual-refusal.js.map +1 -1
- package/dist/domain/errors/kit-codes.d.ts +2 -0
- package/dist/domain/errors/kit-codes.d.ts.map +1 -1
- package/dist/domain/errors/kit-codes.js +2 -0
- package/dist/domain/errors/kit-codes.js.map +1 -1
- package/dist/domain/event-id-of.d.ts +8 -0
- package/dist/domain/event-id-of.d.ts.map +1 -0
- package/dist/domain/event-id-of.js +10 -0
- package/dist/domain/event-id-of.js.map +1 -0
- package/dist/domain/event-rank.d.ts +8 -0
- package/dist/domain/event-rank.d.ts.map +1 -0
- package/dist/domain/event-rank.js +8 -0
- package/dist/domain/event-rank.js.map +1 -0
- package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts +0 -1
- package/dist/domain/event-sourcing/event-sourced-aggregate.d.ts.map +1 -1
- package/dist/domain/event-sourcing/event-sourced-aggregate.js +4 -8
- package/dist/domain/event-sourcing/event-sourced-aggregate.js.map +1 -1
- package/dist/domain/named-domain-event.d.ts +11 -4
- package/dist/domain/named-domain-event.d.ts.map +1 -1
- package/dist/domain/named-domain-event.js +14 -3
- package/dist/domain/named-domain-event.js.map +1 -1
- package/dist/domain/rank-of.d.ts +8 -0
- package/dist/domain/rank-of.d.ts.map +1 -0
- package/dist/domain/rank-of.js +14 -0
- package/dist/domain/rank-of.js.map +1 -0
- package/dist/domain/ranked.d.ts +10 -0
- package/dist/domain/ranked.d.ts.map +1 -0
- package/dist/domain/ranked.js +19 -0
- package/dist/domain/ranked.js.map +1 -0
- package/dist/domain/result/unwrap.d.ts +1 -0
- package/dist/domain/result/unwrap.d.ts.map +1 -1
- package/dist/domain/result/unwrap.js +4 -1
- package/dist/domain/result/unwrap.js.map +1 -1
- package/dist/domain/state-machine/state-machine.d.ts +4 -0
- package/dist/domain/state-machine/state-machine.d.ts.map +1 -1
- package/dist/domain/state-machine/state-machine.js +14 -4
- package/dist/domain/state-machine/state-machine.js.map +1 -1
- package/dist/domain/value-object/frozen-copy.d.ts +8 -0
- package/dist/domain/value-object/frozen-copy.d.ts.map +1 -0
- package/dist/domain/value-object/frozen-copy.js +34 -0
- package/dist/domain/value-object/frozen-copy.js.map +1 -0
- package/dist/domain/value-object/index.d.ts +2 -0
- package/dist/domain/value-object/index.d.ts.map +1 -0
- package/dist/domain/value-object/index.js +2 -0
- package/dist/domain/value-object/index.js.map +1 -0
- package/dist/domain/value-object/is-plain-record.d.ts +3 -0
- package/dist/domain/value-object/is-plain-record.d.ts.map +1 -0
- package/dist/domain/value-object/is-plain-record.js +9 -0
- package/dist/domain/value-object/is-plain-record.js.map +1 -0
- package/dist/domain/value-object/same-value.d.ts +8 -0
- package/dist/domain/value-object/same-value.d.ts.map +1 -0
- package/dist/domain/value-object/same-value.js +43 -0
- package/dist/domain/value-object/same-value.js.map +1 -0
- package/dist/domain/value-object/value-object.d.ts +28 -0
- package/dist/domain/value-object/value-object.d.ts.map +1 -0
- package/dist/domain/value-object/value-object.js +24 -0
- package/dist/domain/value-object/value-object.js.map +1 -0
- package/dist/index.d.ts +10 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/aggregates/aggregate-mapper.d.ts +21 -0
- package/dist/infrastructure/aggregates/aggregate-mapper.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/aggregate-mapper.js +18 -0
- package/dist/infrastructure/aggregates/aggregate-mapper.js.map +1 -0
- package/dist/infrastructure/aggregates/aggregate-save.d.ts +22 -0
- package/dist/infrastructure/aggregates/aggregate-save.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/aggregate-save.js +2 -0
- package/dist/infrastructure/aggregates/aggregate-save.js.map +1 -0
- package/dist/infrastructure/aggregates/as-found.d.ts +8 -0
- package/dist/infrastructure/aggregates/as-found.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/as-found.js +2 -0
- package/dist/infrastructure/aggregates/as-found.js.map +1 -0
- package/dist/infrastructure/aggregates/give-back.d.ts +9 -0
- package/dist/infrastructure/aggregates/give-back.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/give-back.js +13 -0
- package/dist/infrastructure/aggregates/give-back.js.map +1 -0
- package/dist/infrastructure/aggregates/index.d.ts +7 -0
- package/dist/infrastructure/aggregates/index.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/index.js +7 -0
- package/dist/infrastructure/aggregates/index.js.map +1 -0
- package/dist/infrastructure/aggregates/loaded-at.d.ts +8 -0
- package/dist/infrastructure/aggregates/loaded-at.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/loaded-at.js +12 -0
- package/dist/infrastructure/aggregates/loaded-at.js.map +1 -0
- package/dist/infrastructure/aggregates/noted-as-found.d.ts +8 -0
- package/dist/infrastructure/aggregates/noted-as-found.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/noted-as-found.js +15 -0
- package/dist/infrastructure/aggregates/noted-as-found.js.map +1 -0
- package/dist/infrastructure/aggregates/recorded-events-of.d.ts +4 -0
- package/dist/infrastructure/aggregates/recorded-events-of.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/recorded-events-of.js +6 -0
- package/dist/infrastructure/aggregates/recorded-events-of.js.map +1 -0
- package/dist/infrastructure/aggregates/save-aggregate-row.d.ts +23 -0
- package/dist/infrastructure/aggregates/save-aggregate-row.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/save-aggregate-row.js +17 -0
- package/dist/infrastructure/aggregates/save-aggregate-row.js.map +1 -0
- package/dist/infrastructure/aggregates/stored-at.d.ts +7 -0
- package/dist/infrastructure/aggregates/stored-at.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/stored-at.js +14 -0
- package/dist/infrastructure/aggregates/stored-at.js.map +1 -0
- package/dist/infrastructure/aggregates/take-recorded-events.d.ts +9 -0
- package/dist/infrastructure/aggregates/take-recorded-events.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/take-recorded-events.js +17 -0
- package/dist/infrastructure/aggregates/take-recorded-events.js.map +1 -0
- package/dist/infrastructure/aggregates/unstored-events-of.d.ts +4 -0
- package/dist/infrastructure/aggregates/unstored-events-of.d.ts.map +1 -0
- package/dist/infrastructure/aggregates/unstored-events-of.js +7 -0
- package/dist/infrastructure/aggregates/unstored-events-of.js.map +1 -0
- package/dist/infrastructure/clock/fixed-clock.d.ts +2 -1
- package/dist/infrastructure/clock/fixed-clock.d.ts.map +1 -1
- package/dist/infrastructure/clock/fixed-clock.js +5 -4
- package/dist/infrastructure/clock/fixed-clock.js.map +1 -1
- package/dist/infrastructure/context/scoped-actor-context.d.ts.map +1 -1
- package/dist/infrastructure/context/scoped-actor-context.js +2 -6
- package/dist/infrastructure/context/scoped-actor-context.js.map +1 -1
- package/dist/infrastructure/domain-events/announce-domain-events.d.ts +1 -1
- package/dist/infrastructure/domain-events/announce-domain-events.js +1 -1
- package/dist/infrastructure/domain-events/dispatching-on-save.d.ts +1 -1
- package/dist/infrastructure/domain-events/dispatching-on-save.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/dispatching-on-save.js +3 -2
- package/dist/infrastructure/domain-events/dispatching-on-save.js.map +1 -1
- package/dist/infrastructure/domain-events/index.d.ts +14 -0
- package/dist/infrastructure/domain-events/index.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/index.js +14 -0
- package/dist/infrastructure/domain-events/index.js.map +1 -0
- package/dist/infrastructure/domain-events/on-rollback.d.ts +10 -0
- package/dist/infrastructure/domain-events/on-rollback.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/on-rollback.js +17 -0
- package/dist/infrastructure/domain-events/on-rollback.js.map +1 -0
- package/dist/infrastructure/domain-events/recorded-aggregates.d.ts +2 -5
- package/dist/infrastructure/domain-events/recorded-aggregates.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/recorded-aggregates.js +3 -5
- package/dist/infrastructure/domain-events/recorded-aggregates.js.map +1 -1
- package/dist/infrastructure/domain-events/unit-of-work-aborted-error.d.ts +10 -0
- package/dist/infrastructure/domain-events/unit-of-work-aborted-error.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/unit-of-work-aborted-error.js +13 -0
- package/dist/infrastructure/domain-events/unit-of-work-aborted-error.js.map +1 -0
- package/dist/infrastructure/domain-events/unit-of-work-over.d.ts +37 -0
- package/dist/infrastructure/domain-events/unit-of-work-over.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/unit-of-work-over.js +146 -0
- package/dist/infrastructure/domain-events/unit-of-work-over.js.map +1 -0
- package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts +11 -1
- package/dist/infrastructure/domain-events/unit-of-work-scope.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/unit-of-work-scope.js.map +1 -1
- package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.d.ts +8 -0
- package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.d.ts.map +1 -0
- package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.js +11 -0
- package/dist/infrastructure/domain-events/unscoped-unit-of-work-error.js.map +1 -0
- package/dist/infrastructure/domain-events/when-committed.d.ts.map +1 -1
- package/dist/infrastructure/domain-events/when-committed.js +2 -9
- package/dist/infrastructure/domain-events/when-committed.js.map +1 -1
- package/dist/infrastructure/event-sourcing/aggregate-id-of.d.ts +4 -0
- package/dist/infrastructure/event-sourcing/aggregate-id-of.d.ts.map +1 -0
- package/dist/infrastructure/event-sourcing/aggregate-id-of.js +6 -0
- package/dist/infrastructure/event-sourcing/aggregate-id-of.js.map +1 -0
- package/dist/infrastructure/event-sourcing/event-serializer.d.ts +3 -4
- package/dist/infrastructure/event-sourcing/event-serializer.d.ts.map +1 -1
- package/dist/infrastructure/event-sourcing/event-serializer.js +10 -12
- package/dist/infrastructure/event-sourcing/event-serializer.js.map +1 -1
- package/dist/infrastructure/event-sourcing/event-store-personal-data-export.d.ts.map +1 -1
- package/dist/infrastructure/event-sourcing/event-store-personal-data-export.js +1 -5
- package/dist/infrastructure/event-sourcing/event-store-personal-data-export.js.map +1 -1
- package/dist/infrastructure/events/idempotent.d.ts.map +1 -1
- package/dist/infrastructure/events/idempotent.js +9 -3
- package/dist/infrastructure/events/idempotent.js.map +1 -1
- package/dist/infrastructure/in-memory/as-json-carries.d.ts +9 -0
- package/dist/infrastructure/in-memory/as-json-carries.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/as-json-carries.js +12 -0
- package/dist/infrastructure/in-memory/as-json-carries.js.map +1 -0
- package/dist/infrastructure/in-memory/composite-key.d.ts +6 -0
- package/dist/infrastructure/in-memory/composite-key.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/composite-key.js +8 -0
- package/dist/infrastructure/in-memory/composite-key.js.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-cache.d.ts +3 -1
- package/dist/infrastructure/in-memory/in-memory-cache.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-cache.js +7 -3
- package/dist/infrastructure/in-memory/in-memory-cache.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts +1 -1
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js +3 -2
- package/dist/infrastructure/in-memory/in-memory-checkpoint-store.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.d.ts +0 -1
- package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.js +2 -9
- package/dist/infrastructure/in-memory/in-memory-domain-event-dispatcher.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-event-bus.d.ts +7 -14
- package/dist/infrastructure/in-memory/in-memory-event-bus.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-event-bus.js +17 -9
- package/dist/infrastructure/in-memory/in-memory-event-bus.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-event-store.d.ts +8 -2
- package/dist/infrastructure/in-memory/in-memory-event-store.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-event-store.js +29 -14
- package/dist/infrastructure/in-memory/in-memory-event-store.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-process-store.d.ts +1 -1
- package/dist/infrastructure/in-memory/in-memory-process-store.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-process-store.js +7 -8
- package/dist/infrastructure/in-memory/in-memory-process-store.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-processed-event-store.d.ts +1 -0
- package/dist/infrastructure/in-memory/in-memory-processed-event-store.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-processed-event-store.js +6 -6
- package/dist/infrastructure/in-memory/in-memory-processed-event-store.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-read-model-table.d.ts +2 -1
- package/dist/infrastructure/in-memory/in-memory-read-model-table.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-read-model-table.js +5 -3
- package/dist/infrastructure/in-memory/in-memory-read-model-table.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts +1 -1
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.js +3 -2
- package/dist/infrastructure/in-memory/in-memory-snapshot-store.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-unit-of-work.d.ts +5 -2
- package/dist/infrastructure/in-memory/in-memory-unit-of-work.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-unit-of-work.js +7 -4
- package/dist/infrastructure/in-memory/in-memory-unit-of-work.js.map +1 -1
- package/dist/infrastructure/in-memory/in-process-bus.d.ts +1 -0
- package/dist/infrastructure/in-memory/in-process-bus.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/in-process-bus.js +4 -3
- package/dist/infrastructure/in-memory/in-process-bus.js.map +1 -1
- package/dist/infrastructure/in-memory/rollback-map.d.ts +15 -0
- package/dist/infrastructure/in-memory/rollback-map.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/rollback-map.js +52 -0
- package/dist/infrastructure/in-memory/rollback-map.js.map +1 -0
- package/dist/infrastructure/in-memory/unit-of-work-middleware.d.ts +5 -5
- package/dist/infrastructure/in-memory/unit-of-work-middleware.d.ts.map +1 -1
- package/dist/infrastructure/in-memory/unit-of-work-middleware.js +13 -4
- package/dist/infrastructure/in-memory/unit-of-work-middleware.js.map +1 -1
- package/package.json +1 -1
- package/dist/domain/event-sourcing/unstored-events.d.ts +0 -8
- package/dist/domain/event-sourcing/unstored-events.d.ts.map +0 -1
- package/dist/domain/event-sourcing/unstored-events.js +0 -7
- package/dist/domain/event-sourcing/unstored-events.js.map +0 -1
- package/dist/domain/value-object.d.ts +0 -12
- package/dist/domain/value-object.d.ts.map +0 -1
- package/dist/domain/value-object.js +0 -40
- package/dist/domain/value-object.js.map +0 -1
- package/dist/infrastructure/domain-events/within-unit-of-work.d.ts +0 -25
- package/dist/infrastructure/domain-events/within-unit-of-work.d.ts.map +0 -1
- package/dist/infrastructure/domain-events/within-unit-of-work.js +0 -85
- package/dist/infrastructure/domain-events/within-unit-of-work.js.map +0 -1
- package/dist/infrastructure/event-sourcing/stored-origins.d.ts +0 -5
- package/dist/infrastructure/event-sourcing/stored-origins.d.ts.map +0 -1
- package/dist/infrastructure/event-sourcing/stored-origins.js +0 -3
- package/dist/infrastructure/event-sourcing/stored-origins.js.map +0 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts +0 -11
- package/dist/infrastructure/event-sourcing/stored-stamp-of.d.ts.map +0 -1
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js +0 -15
- package/dist/infrastructure/event-sourcing/stored-stamp-of.js.map +0 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { anonymousActor } from '../actor/anonymous-actor.js';
|
|
2
|
-
import {
|
|
2
|
+
import { neverIssued } from './never-issued.js';
|
|
3
3
|
const ANONYMOUS_SESSION = Object.freeze({
|
|
4
4
|
id: 'anonymous',
|
|
5
5
|
actor: anonymousActor(),
|
|
6
|
-
issuedAt
|
|
6
|
+
get issuedAt() {
|
|
7
|
+
return neverIssued();
|
|
8
|
+
},
|
|
7
9
|
authenticationMethod: 'none',
|
|
8
10
|
extensions: Object.freeze({}),
|
|
9
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anonymous-session.js","sourceRoot":"","sources":["../../../src/application/session/anonymous-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"anonymous-session.js","sourceRoot":"","sources":["../../../src/application/session/anonymous-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,iBAAiB,GAAY,MAAM,CAAC,MAAM,CAAC;IAC/C,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,cAAc,EAAE;IACvB,IAAI,QAAQ;QACV,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;IACD,oBAAoB,EAAE,MAAM;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CAC9B,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB;IAC9B,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"never-issued.d.ts","sourceRoot":"","sources":["../../../src/application/session/never-issued.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"never-issued.d.ts","sourceRoot":"","sources":["../../../src/application/session/never-issued.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"never-issued.js","sourceRoot":"","sources":["../../../src/application/session/never-issued.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"never-issued.js","sourceRoot":"","sources":["../../../src/application/session/never-issued.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,MAAM,UAAU,WAAW;IACzB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-session.d.ts","sourceRoot":"","sources":["../../../src/application/session/system-session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,
|
|
1
|
+
{"version":3,"file":"system-session.d.ts","sourceRoot":"","sources":["../../../src/application/session/system-session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,IAAoB,GAAG,OAAO,CAUnF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { systemActor } from '../actor/system-actor.js';
|
|
2
|
-
import {
|
|
2
|
+
import { neverIssued } from './never-issued.js';
|
|
3
3
|
/** The session of the system acting on its own behalf: a scheduled job, a consumer. */
|
|
4
|
-
export function systemSession(name, issuedAt =
|
|
4
|
+
export function systemSession(name, issuedAt = neverIssued()) {
|
|
5
5
|
const actor = systemActor(name);
|
|
6
6
|
return Object.freeze({
|
|
7
7
|
id: actor.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-session.js","sourceRoot":"","sources":["../../../src/application/session/system-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"system-session.js","sourceRoot":"","sources":["../../../src/application/session/system-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,uFAAuF;AACvF,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAQ,GAAS,WAAW,EAAE;IACxE,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEhC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK;QACL,QAAQ;QACR,oBAAoB,EAAE,SAAS;QAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/application/undecided/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/application/undecided/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The code of what was generated and is not written yet: answered 501. */
|
|
2
|
+
export declare const NOT_IMPLEMENTED = "NOT_IMPLEMENTED";
|
|
3
|
+
/**
|
|
4
|
+
* What a generated stub answers until its decision is written: it refuses by name, where a
|
|
5
|
+
* success that did nothing would pass for the behaviour. A fault of the software, not a business
|
|
6
|
+
* refusal: a route answers it 501, a reaction or a job fails with it, the error reporting sees it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UndecidedError extends Error {
|
|
9
|
+
readonly code = "NOT_IMPLEMENTED";
|
|
10
|
+
constructor(what: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=undecided-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undecided-error.d.ts","sourceRoot":"","sources":["../../../src/application/undecided/undecided-error.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,qBAAmB;IAEhC,YAAY,IAAI,EAAE,MAAM,EAGvB;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The code of what was generated and is not written yet: answered 501. */
|
|
2
|
+
export const NOT_IMPLEMENTED = 'NOT_IMPLEMENTED';
|
|
3
|
+
/**
|
|
4
|
+
* What a generated stub answers until its decision is written: it refuses by name, where a
|
|
5
|
+
* success that did nothing would pass for the behaviour. A fault of the software, not a business
|
|
6
|
+
* refusal: a route answers it 501, a reaction or a job fails with it, the error reporting sees it.
|
|
7
|
+
*/
|
|
8
|
+
export class UndecidedError extends Error {
|
|
9
|
+
code = NOT_IMPLEMENTED;
|
|
10
|
+
constructor(what) {
|
|
11
|
+
super(`${what} is not decided yet: its TODO says what to write`);
|
|
12
|
+
this.name = 'UndecidedError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=undecided-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undecided-error.js","sourceRoot":"","sources":["../../../src/application/undecided/undecided-error.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,GAAG,eAAe,CAAC;IAEhC,YAAY,IAAY;QACtB,KAAK,CAAC,GAAG,IAAI,kDAAkD,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UndecidedError } from './undecided-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* The refusal of a stub, named after what is left to decide:
|
|
4
|
+
* `throw undecided('what "confirm order" does')`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function undecided(what: string): UndecidedError;
|
|
7
|
+
//# sourceMappingURL=undecided.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undecided.d.ts","sourceRoot":"","sources":["../../../src/application/undecided/undecided.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAEtD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UndecidedError } from './undecided-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* The refusal of a stub, named after what is left to decide:
|
|
4
|
+
* `throw undecided('what "confirm order" does')`.
|
|
5
|
+
*/
|
|
6
|
+
export function undecided(what) {
|
|
7
|
+
return new UndecidedError(what);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=undecided.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undecided.js","sourceRoot":"","sources":["../../../src/application/undecided/undecided.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -4,22 +4,15 @@ import { Entity } from './entity.js';
|
|
|
4
4
|
* Consistency boundary and transaction boundary. Only the root is reachable from
|
|
5
5
|
* outside; state changes go through intention-revealing methods that guard the
|
|
6
6
|
* invariants and record domain events.
|
|
7
|
+
*
|
|
8
|
+
* The model records and reads its version; it moves neither. The repository adapter says at
|
|
9
|
+
* which version it loaded the aggregate (`loadedAt`), the save moves it (`optimisticUpdate`), and
|
|
10
|
+
* the recorded events leave with the save (`dispatchingOnSave`).
|
|
7
11
|
*/
|
|
8
12
|
export declare abstract class AggregateRoot<Id extends string | number = string> extends Entity<Id> {
|
|
9
|
-
/** Optimistic concurrency token, managed by the repository adapter. */
|
|
10
|
-
version: number;
|
|
11
|
-
private readonly events;
|
|
12
|
-
/**
|
|
13
|
-
* The recorded events are no part of the state: they are kept out of enumeration, so that
|
|
14
|
-
* comparing, spreading or serialising an aggregate never sees what it has yet to announce.
|
|
15
|
-
*/
|
|
16
13
|
protected constructor(id: Id);
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
* repository (`dispatchingOnSave`), and by a spec that asserts what an aggregate recorded;
|
|
20
|
-
* never by a use case or a repository adapter.
|
|
21
|
-
*/
|
|
22
|
-
pullEvents(): DomainEvent[];
|
|
14
|
+
/** Optimistic concurrency token: the version the store holds of this aggregate, 0 until its first save. */
|
|
15
|
+
get version(): number;
|
|
23
16
|
protected record(event: DomainEvent): void;
|
|
24
17
|
}
|
|
25
18
|
//# sourceMappingURL=aggregate-root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate-root.d.ts","sourceRoot":"","sources":["../../src/domain/aggregate-root.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aggregate-root.d.ts","sourceRoot":"","sources":["../../src/domain/aggregate-root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;GAQG;AACH,8BAAsB,aAAa,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAE,SAAQ,MAAM,CAAC,EAAE,CAAC;IACzF,SAAS,aAAa,EAAE,EAAE,EAAE,EAG3B;IAED,2GAA2G;IAC3G,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAEzC;CACF"}
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
+
import { AggregateTracking } from './aggregate-tracking.js';
|
|
1
2
|
import { Entity } from './entity.js';
|
|
2
3
|
/**
|
|
3
4
|
* Consistency boundary and transaction boundary. Only the root is reachable from
|
|
4
5
|
* outside; state changes go through intention-revealing methods that guard the
|
|
5
6
|
* invariants and record domain events.
|
|
7
|
+
*
|
|
8
|
+
* The model records and reads its version; it moves neither. The repository adapter says at
|
|
9
|
+
* which version it loaded the aggregate (`loadedAt`), the save moves it (`optimisticUpdate`), and
|
|
10
|
+
* the recorded events leave with the save (`dispatchingOnSave`).
|
|
6
11
|
*/
|
|
7
12
|
export class AggregateRoot extends Entity {
|
|
8
|
-
/** Optimistic concurrency token, managed by the repository adapter. */
|
|
9
|
-
version = 0;
|
|
10
|
-
events = [];
|
|
11
|
-
/**
|
|
12
|
-
* The recorded events are no part of the state: they are kept out of enumeration, so that
|
|
13
|
-
* comparing, spreading or serialising an aggregate never sees what it has yet to announce.
|
|
14
|
-
*/
|
|
15
13
|
constructor(id) {
|
|
16
14
|
super(id);
|
|
17
|
-
|
|
15
|
+
AggregateTracking.start(this);
|
|
18
16
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* never by a use case or a repository adapter.
|
|
23
|
-
*/
|
|
24
|
-
pullEvents() {
|
|
25
|
-
return this.events.splice(0);
|
|
17
|
+
/** Optimistic concurrency token: the version the store holds of this aggregate, 0 until its first save. */
|
|
18
|
+
get version() {
|
|
19
|
+
return AggregateTracking.of(this).version;
|
|
26
20
|
}
|
|
27
21
|
record(event) {
|
|
28
|
-
this.
|
|
22
|
+
AggregateTracking.of(this).record(event);
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
25
|
//# sourceMappingURL=aggregate-root.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate-root.js","sourceRoot":"","sources":["../../src/domain/aggregate-root.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aggregate-root.js","sourceRoot":"","sources":["../../src/domain/aggregate-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,OAAgB,aAAmD,SAAQ,MAAU;IACzF,YAAsB,EAAM;QAC1B,KAAK,CAAC,EAAE,CAAC,CAAC;QACV,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,2GAA2G;IAC3G,IAAI,OAAO;QACT,OAAO,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;IAC5C,CAAC;IAES,MAAM,CAAC,KAAkB;QACjC,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DomainEvent } from './domain-event.js';
|
|
2
|
+
/**
|
|
3
|
+
* What an aggregate carries for the infrastructure and never shows to its model: the version its
|
|
4
|
+
* store holds of it and the events it has yet to announce. The aggregate records; the functions of
|
|
5
|
+
* the infrastructure (`loadedAt`, `optimisticUpdate`, `appendChanges`, `takeRecordedEvents`) move
|
|
6
|
+
* the rest.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AggregateTracking {
|
|
9
|
+
/** The version the store holds: 0 until the first save. */
|
|
10
|
+
version: number;
|
|
11
|
+
/** Recorded and not announced yet, oldest first. */
|
|
12
|
+
readonly recorded: DomainEvent[];
|
|
13
|
+
/** How many of the recorded events, from the oldest, a save already wrote. */
|
|
14
|
+
appended: number;
|
|
15
|
+
/**
|
|
16
|
+
* Starts tracking an aggregate, out of enumeration: comparing, spreading or serialising it never
|
|
17
|
+
* sees a version nor what it has yet to announce.
|
|
18
|
+
*/
|
|
19
|
+
static start(aggregate: object): void;
|
|
20
|
+
/** The tracking of an aggregate, whichever copy of the kernel built it; anything else is refused. */
|
|
21
|
+
static of(aggregate: object): AggregateTracking;
|
|
22
|
+
static follows(value: unknown): value is object;
|
|
23
|
+
/**
|
|
24
|
+
* Keeps an event the aggregate announces, at its rank: one past the last fact the store or the
|
|
25
|
+
* aggregate holds. The version follows the ranks at each save, so a rank is given once in the
|
|
26
|
+
* life of the aggregate.
|
|
27
|
+
*/
|
|
28
|
+
record(event: DomainEvent): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=aggregate-tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate-tracking.d.ts","sourceRoot":"","sources":["../../src/domain/aggregate-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,2DAA2D;IAC3D,OAAO,SAAK;IAEZ,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAM;IAEtC,8EAA8E;IAC9E,QAAQ,SAAK;IAEb;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEpC;IAED,qGAAqG;IACrG,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAU9C;IAED,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9C;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAE/B;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ranked } from './ranked.js';
|
|
2
|
+
// Shared across the copies of the kernel a process loads: an aggregate of a context compiled apart is tracked the same.
|
|
3
|
+
const TRACKING = Symbol.for('@ddd-ts-kit/kernel/aggregate-tracking/v1');
|
|
4
|
+
/**
|
|
5
|
+
* What an aggregate carries for the infrastructure and never shows to its model: the version its
|
|
6
|
+
* store holds of it and the events it has yet to announce. The aggregate records; the functions of
|
|
7
|
+
* the infrastructure (`loadedAt`, `optimisticUpdate`, `appendChanges`, `takeRecordedEvents`) move
|
|
8
|
+
* the rest.
|
|
9
|
+
*/
|
|
10
|
+
export class AggregateTracking {
|
|
11
|
+
/** The version the store holds: 0 until the first save. */
|
|
12
|
+
version = 0;
|
|
13
|
+
/** Recorded and not announced yet, oldest first. */
|
|
14
|
+
recorded = [];
|
|
15
|
+
/** How many of the recorded events, from the oldest, a save already wrote. */
|
|
16
|
+
appended = 0;
|
|
17
|
+
/**
|
|
18
|
+
* Starts tracking an aggregate, out of enumeration: comparing, spreading or serialising it never
|
|
19
|
+
* sees a version nor what it has yet to announce.
|
|
20
|
+
*/
|
|
21
|
+
static start(aggregate) {
|
|
22
|
+
Object.defineProperty(aggregate, TRACKING, { value: new AggregateTracking() });
|
|
23
|
+
}
|
|
24
|
+
/** The tracking of an aggregate, whichever copy of the kernel built it; anything else is refused. */
|
|
25
|
+
static of(aggregate) {
|
|
26
|
+
const tracking = Reflect.get(aggregate, TRACKING);
|
|
27
|
+
if (!isTracking(tracking)) {
|
|
28
|
+
throw new TypeError(`${aggregate.constructor.name} is no aggregate: it extends no AggregateRoot, so nothing keeps its version nor its events`);
|
|
29
|
+
}
|
|
30
|
+
return tracking;
|
|
31
|
+
}
|
|
32
|
+
static follows(value) {
|
|
33
|
+
return typeof value === 'object' && value !== null && isTracking(Reflect.get(value, TRACKING));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Keeps an event the aggregate announces, at its rank: one past the last fact the store or the
|
|
37
|
+
* aggregate holds. The version follows the ranks at each save, so a rank is given once in the
|
|
38
|
+
* life of the aggregate.
|
|
39
|
+
*/
|
|
40
|
+
record(event) {
|
|
41
|
+
this.recorded.push(ranked(event, this.version + this.recorded.length - this.appended + 1));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Read by its shape: the tracking another copy of the kernel started is no instance of this class. */
|
|
45
|
+
function isTracking(value) {
|
|
46
|
+
return typeof value === 'object' && value !== null && 'version' in value && 'recorded' in value;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=aggregate-tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate-tracking.js","sourceRoot":"","sources":["../../src/domain/aggregate-tracking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wHAAwH;AACxH,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,2DAA2D;IAC3D,OAAO,GAAG,CAAC,CAAC;IAEZ,oDAAoD;IAC3C,QAAQ,GAAkB,EAAE,CAAC;IAEtC,8EAA8E;IAC9E,QAAQ,GAAG,CAAC,CAAC;IAEb;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,SAAiB;QAC5B,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,EAAE,CAAC,SAAiB;QACzB,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE3D,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CACjB,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,4FAA4F,CAC1H,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAc;QAC3B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAkB;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;CACF;AAED,uGAAuG;AACvG,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,CAAC;AAClG,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A fact that happened inside one bounded context, named in the past tense.
|
|
3
3
|
* Never leaves the context as is: publish an IntegrationEvent instead.
|
|
4
|
+
*
|
|
5
|
+
* The aggregate that records it gives it its rank in its history (`rankOf`), and its identity
|
|
6
|
+
* follows from both (`eventIdOf`): the event itself says neither.
|
|
4
7
|
*/
|
|
5
8
|
export interface DomainEvent {
|
|
6
9
|
/** Stable name, `<context>.<aggregate>.<fact>`, e.g. `billing.invoice.issued`. */
|
|
7
10
|
readonly name: string;
|
|
8
11
|
readonly occurredAt: Date;
|
|
12
|
+
/** The id of its aggregate, as text whatever the type of that id: a stream, a stamp and a store name the aggregate by it. */
|
|
9
13
|
readonly aggregateId: string;
|
|
10
14
|
}
|
|
11
15
|
export { NamedDomainEvent } from './named-domain-event.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-event.d.ts","sourceRoot":"","sources":["../../src/domain/domain-event.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"domain-event.d.ts","sourceRoot":"","sources":["../../src/domain/domain-event.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,6HAA6H;IAC7H,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-event.js","sourceRoot":"","sources":["../../src/domain/domain-event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"domain-event.js","sourceRoot":"","sources":["../../src/domain/domain-event.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-error.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/domain-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAE/B,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,
|
|
1
|
+
{"version":3,"file":"domain-error.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/domain-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAE/B,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIzD;IAED,yGAAyG;IACzG,MAAM,IAAI,eAAe,CAExB;CACF"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
export class DomainError extends Error {
|
|
6
6
|
constructor(message, options) {
|
|
7
7
|
super(message, options);
|
|
8
|
-
|
|
8
|
+
// Out of enumeration, as the name of an `Error` is: a spread or a structured logger writes the code alone.
|
|
9
|
+
Object.defineProperty(this, 'name', { value: new.target.name, writable: true, configurable: true });
|
|
9
10
|
}
|
|
10
11
|
/** What `JSON.stringify` writes of a refusal: never its stack, its cause or a fact it did not expose. */
|
|
11
12
|
toJSON() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-error.js","sourceRoot":"","sources":["../../../src/domain/errors/domain-error.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,KAAK;IAG7C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,
|
|
1
|
+
{"version":3,"file":"domain-error.js","sourceRoot":"","sources":["../../../src/domain/errors/domain-error.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,KAAK;IAG7C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,2GAA2G;QAC3G,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACtG,CAAC;IAED,yGAAyG;IACzG,MAAM;QACJ,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factual-refusal.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/factual-refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,8BAAsB,cAAe,SAAQ,WAAW;IACtD,yGAAyG;IACzG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAE7B,OAAO,CAAC,YAAY,CAAyB;IAE7C,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"factual-refusal.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/factual-refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,8BAAsB,cAAe,SAAQ,WAAW;IACtD,yGAAyG;IACzG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAE7B,OAAO,CAAC,YAAY,CAAyB;IAE7C,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAMzD;IAED,gFAAgF;IAChF,IAAI,YAAY,IAAI,YAAY,CAE/B;IAEQ,MAAM,IAAI,eAAe,CAEjC;IAED,kGAAkG;IAClG,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI,CAI5E;IAED,8DAA8D;IAC9D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAIvC;CACF"}
|
|
@@ -12,6 +12,9 @@ export class FactualRefusal extends DomainError {
|
|
|
12
12
|
constructor(message, facts) {
|
|
13
13
|
super(message);
|
|
14
14
|
this.facts = facts;
|
|
15
|
+
// Private to the process: neither is written by a spread or a structured logger, `toJSON` says what leaves.
|
|
16
|
+
Object.defineProperty(this, 'facts', { enumerable: false });
|
|
17
|
+
Object.defineProperty(this, 'exposedNames', { enumerable: false });
|
|
15
18
|
}
|
|
16
19
|
/** The facts a client may read: the ones the factory named, none by default. */
|
|
17
20
|
get exposedFacts() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factual-refusal.js","sourceRoot":"","sources":["../../../src/domain/errors/factual-refusal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;;;;GAKG;AACH,MAAM,OAAgB,cAAe,SAAQ,WAAW;IACtD,yGAAyG;IAChG,KAAK,CAAe;IAErB,YAAY,GAAsB,EAAE,CAAC;IAE7C,YAAsB,OAAe,EAAE,KAAmB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"factual-refusal.js","sourceRoot":"","sources":["../../../src/domain/errors/factual-refusal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;;;;GAKG;AACH,MAAM,OAAgB,cAAe,SAAQ,WAAW;IACtD,yGAAyG;IAChG,KAAK,CAAe;IAErB,YAAY,GAAsB,EAAE,CAAC;IAE7C,YAAsB,OAAe,EAAE,KAAmB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,4GAA4G;QAC5G,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,gFAAgF;IAChF,IAAI,YAAY;QACd,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/F,CAAC;IAEQ,MAAM;QACb,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC;IACxG,CAAC;IAED,kGAAkG;IACxF,QAAQ,CAAC,GAAG,KAAgD;QACpE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8DAA8D;IACpD,QAAQ,CAAC,KAAc;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -26,6 +26,8 @@ export declare const KitCodes: {
|
|
|
26
26
|
readonly FileNotFound: 'FILE_NOT_FOUND';
|
|
27
27
|
readonly FileRejected: 'FILE_REJECTED';
|
|
28
28
|
readonly InvalidFileKey: 'INVALID_FILE_KEY';
|
|
29
|
+
readonly InvalidFileUrlExpiry: 'INVALID_FILE_URL_EXPIRY';
|
|
30
|
+
readonly ForbiddenTransition: 'FORBIDDEN_TRANSITION';
|
|
29
31
|
};
|
|
30
32
|
/** One code of the kit: `'FORBIDDEN' | 'NOT_FOUND' | ...`. */
|
|
31
33
|
export type KitCode = (typeof KitCodes)[keyof typeof KitCodes];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit-codes.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/kit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,QAAQ;aACnB,gBAAgB,EAAE,mBAAmB;aACrC,QAAQ,EAAE,WAAW;aACrB,QAAQ,EAAE,UAAU;aACpB,kBAAkB,EAAE,qBAAqB;aACzC,YAAY,EAAE,cAAc;aAC5B,SAAS,EAAE,WAAW;aACtB,aAAa,EAAE,gBAAgB;aAC/B,mBAAmB,EAAE,sBAAsB;aAC3C,eAAe,EAAE,kBAAkB;aACnC,kBAAkB,EAAE,sBAAsB;aAC1C,OAAO,EAAE,SAAS;aAClB,WAAW,EAAE,cAAc;aAC3B,YAAY,EAAE,eAAe;aAC7B,iBAAiB,EAAE,oBAAoB;aACvC,kBAAkB,EAAE,qBAAqB;aACzC,kBAAkB,EAAE,qBAAqB;aACzC,oBAAoB,EAAE,uBAAuB;aAC7C,YAAY,EAAE,gBAAgB;aAC9B,oBAAoB,EAAE,wBAAwB;aAC9C,YAAY,EAAE,gBAAgB;aAC9B,YAAY,EAAE,eAAe;aAC7B,cAAc,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"kit-codes.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/kit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,QAAQ;aACnB,gBAAgB,EAAE,mBAAmB;aACrC,QAAQ,EAAE,WAAW;aACrB,QAAQ,EAAE,UAAU;aACpB,kBAAkB,EAAE,qBAAqB;aACzC,YAAY,EAAE,cAAc;aAC5B,SAAS,EAAE,WAAW;aACtB,aAAa,EAAE,gBAAgB;aAC/B,mBAAmB,EAAE,sBAAsB;aAC3C,eAAe,EAAE,kBAAkB;aACnC,kBAAkB,EAAE,sBAAsB;aAC1C,OAAO,EAAE,SAAS;aAClB,WAAW,EAAE,cAAc;aAC3B,YAAY,EAAE,eAAe;aAC7B,iBAAiB,EAAE,oBAAoB;aACvC,kBAAkB,EAAE,qBAAqB;aACzC,kBAAkB,EAAE,qBAAqB;aACzC,oBAAoB,EAAE,uBAAuB;aAC7C,YAAY,EAAE,gBAAgB;aAC9B,oBAAoB,EAAE,wBAAwB;aAC9C,YAAY,EAAE,gBAAgB;aAC9B,YAAY,EAAE,eAAe;aAC7B,cAAc,EAAE,kBAAkB;aAClC,oBAAoB,EAAE,yBAAyB;aAC/C,mBAAmB,EAAE,sBAAsB;CACnC,CAAC;AAEX,8DAA8D;AAC9D,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -26,5 +26,7 @@ export const KitCodes = {
|
|
|
26
26
|
FileNotFound: 'FILE_NOT_FOUND',
|
|
27
27
|
FileRejected: 'FILE_REJECTED',
|
|
28
28
|
InvalidFileKey: 'INVALID_FILE_KEY',
|
|
29
|
+
InvalidFileUrlExpiry: 'INVALID_FILE_URL_EXPIRY',
|
|
30
|
+
ForbiddenTransition: 'FORBIDDEN_TRANSITION',
|
|
29
31
|
};
|
|
30
32
|
//# sourceMappingURL=kit-codes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit-codes.js","sourceRoot":"","sources":["../../../src/domain/errors/kit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,gBAAgB,EAAE,mBAAmB;IACrC,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,UAAU;IACpB,kBAAkB,EAAE,qBAAqB;IACzC,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,gBAAgB;IAC/B,mBAAmB,EAAE,sBAAsB;IAC3C,eAAe,EAAE,kBAAkB;IACnC,kBAAkB,EAAE,sBAAsB;IAC1C,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,cAAc;IAC3B,YAAY,EAAE,eAAe;IAC7B,iBAAiB,EAAE,oBAAoB;IACvC,kBAAkB,EAAE,qBAAqB;IACzC,kBAAkB,EAAE,qBAAqB;IACzC,oBAAoB,EAAE,uBAAuB;IAC7C,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,wBAAwB;IAC9C,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,eAAe;IAC7B,cAAc,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"kit-codes.js","sourceRoot":"","sources":["../../../src/domain/errors/kit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,gBAAgB,EAAE,mBAAmB;IACrC,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,UAAU;IACpB,kBAAkB,EAAE,qBAAqB;IACzC,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,gBAAgB;IAC/B,mBAAmB,EAAE,sBAAsB;IAC3C,eAAe,EAAE,kBAAkB;IACnC,kBAAkB,EAAE,sBAAsB;IAC1C,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,cAAc;IAC3B,YAAY,EAAE,eAAe;IAC7B,iBAAiB,EAAE,oBAAoB;IACvC,kBAAkB,EAAE,qBAAqB;IACzC,kBAAkB,EAAE,qBAAqB;IACzC,oBAAoB,EAAE,uBAAuB;IAC7C,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,wBAAwB;IAC9C,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,eAAe;IAC7B,cAAc,EAAE,kBAAkB;IAClC,oBAAoB,EAAE,yBAAyB;IAC/C,mBAAmB,EAAE,sBAAsB;CACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DomainEvent } from './domain-event.js';
|
|
2
|
+
/**
|
|
3
|
+
* The identity of a domain event: its name, which says the context and the aggregate, the id of
|
|
4
|
+
* its aggregate and its rank there, `billing.invoice.issued:inv-1:3`. Nothing is drawn: the event
|
|
5
|
+
* dispatched by a save and the same event read back from its stream have one identity.
|
|
6
|
+
*/
|
|
7
|
+
export declare function eventIdOf(event: DomainEvent): string;
|
|
8
|
+
//# sourceMappingURL=event-id-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-id-of.d.ts","sourceRoot":"","sources":["../../src/domain/event-id-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { rankOf } from './rank-of.js';
|
|
2
|
+
/**
|
|
3
|
+
* The identity of a domain event: its name, which says the context and the aggregate, the id of
|
|
4
|
+
* its aggregate and its rank there, `billing.invoice.issued:inv-1:3`. Nothing is drawn: the event
|
|
5
|
+
* dispatched by a save and the same event read back from its stream have one identity.
|
|
6
|
+
*/
|
|
7
|
+
export function eventIdOf(event) {
|
|
8
|
+
return `${event.name}:${event.aggregateId}:${String(rankOf(event))}`;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=event-id-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-id-of.js","sourceRoot":"","sources":["../../src/domain/event-id-of.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAkB;IAC1C,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a domain event carries its rank in the history of its aggregate, out of enumeration:
|
|
3
|
+
* comparing, spreading or serialising an event never sees it. `ranked` gives the rank, `rankOf`
|
|
4
|
+
* reads it. Shared across the copies of the kernel a process loads: an event ranked by one copy is
|
|
5
|
+
* read by another.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EVENT_RANK: unique symbol;
|
|
8
|
+
//# sourceMappingURL=event-rank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-rank.d.ts","sourceRoot":"","sources":["../../src/domain/event-rank.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,eAAiD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a domain event carries its rank in the history of its aggregate, out of enumeration:
|
|
3
|
+
* comparing, spreading or serialising an event never sees it. `ranked` gives the rank, `rankOf`
|
|
4
|
+
* reads it. Shared across the copies of the kernel a process loads: an event ranked by one copy is
|
|
5
|
+
* read by another.
|
|
6
|
+
*/
|
|
7
|
+
export const EVENT_RANK = Symbol.for('@ddd-ts-kit/kernel/event-rank/v1');
|
|
8
|
+
//# sourceMappingURL=event-rank.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-rank.js","sourceRoot":"","sources":["../../src/domain/event-rank.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC"}
|
|
@@ -13,7 +13,6 @@ import type { Appliers } from './appliers.js';
|
|
|
13
13
|
* Chosen per aggregate: the other aggregates of a context keep their state in tables.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class EventSourcedAggregate<E extends DomainEvent, S = never> extends AggregateRoot<string> {
|
|
16
|
-
protected constructor(id: string);
|
|
17
16
|
/** The apply method of each event this aggregate records, by the name the event carries. */
|
|
18
17
|
protected abstract appliers(): Appliers<E>;
|
|
19
18
|
/** Applies the event, then keeps it for the next save, which stores it and dispatches it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-sourced-aggregate.d.ts","sourceRoot":"","sources":["../../../src/domain/event-sourcing/event-sourced-aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-sourced-aggregate.d.ts","sourceRoot":"","sources":["../../../src/domain/event-sourcing/event-sourced-aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;GASG;AACH,8BAAsB,qBAAqB,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,GAAG,KAAK,CAAE,SAAQ,aAAa,CAAC,MAAM,CAAC;IACzG,4FAA4F;IAC5F,SAAS,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE3C,6FAA6F;IAC7F,UAAmB,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAGxC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAmBpF;IAED,OAAO,CAAC,UAAU;CASnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregateRoot } from '../aggregate-root.js';
|
|
2
|
-
import {
|
|
2
|
+
import { AggregateTracking } from '../aggregate-tracking.js';
|
|
3
3
|
/**
|
|
4
4
|
* An aggregate whose state is the sum of its events. A command checks the invariants, then
|
|
5
5
|
* records the event of what it decided; recording applies the event through the apply method
|
|
@@ -11,15 +11,10 @@ import { unstoredEvents } from './unstored-events.js';
|
|
|
11
11
|
* Chosen per aggregate: the other aggregates of a context keep their state in tables.
|
|
12
12
|
*/
|
|
13
13
|
export class EventSourcedAggregate extends AggregateRoot {
|
|
14
|
-
constructor(id) {
|
|
15
|
-
super(id);
|
|
16
|
-
unstoredEvents.set(this, []);
|
|
17
|
-
}
|
|
18
14
|
/** Applies the event, then keeps it for the next save, which stores it and dispatches it. */
|
|
19
15
|
record(event) {
|
|
20
16
|
this.applyEvent(event);
|
|
21
17
|
super.record(event);
|
|
22
|
-
unstoredEvents.get(this)?.push(event);
|
|
23
18
|
}
|
|
24
19
|
/**
|
|
25
20
|
* Rebuilds the state from the history of the stream and records nothing. A history that starts
|
|
@@ -27,16 +22,17 @@ export class EventSourcedAggregate extends AggregateRoot {
|
|
|
27
22
|
*/
|
|
28
23
|
replay(history, restore) {
|
|
29
24
|
const { snapshot, events } = history;
|
|
25
|
+
const tracking = AggregateTracking.of(this);
|
|
30
26
|
if (snapshot !== undefined) {
|
|
31
27
|
if (restore === undefined) {
|
|
32
28
|
throw new TypeError(`${this.constructor.name} was given a snapshot and restores none: pass restore to replay`);
|
|
33
29
|
}
|
|
34
30
|
restore(snapshot.state);
|
|
35
|
-
|
|
31
|
+
tracking.version = snapshot.version;
|
|
36
32
|
}
|
|
37
33
|
for (const event of events) {
|
|
38
34
|
this.applyEvent(event);
|
|
39
|
-
|
|
35
|
+
tracking.version += 1;
|
|
40
36
|
}
|
|
41
37
|
return this;
|
|
42
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-sourced-aggregate.js","sourceRoot":"","sources":["../../../src/domain/event-sourcing/event-sourced-aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-sourced-aggregate.js","sourceRoot":"","sources":["../../../src/domain/event-sourcing/event-sourced-aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK1D;;;;;;;;;GASG;AACH,MAAM,OAAgB,qBAAwD,SAAQ,aAAqB;IAIzG,6FAA6F;IAC1E,MAAM,CAAC,KAAQ;QAChC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED;;;OAGG;IACO,MAAM,CAAC,OAA+B,EAAE,OAA4B;QAC5E,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QACrC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,iEAAiE,CAAC,CAAC;YACjH,CAAC;YAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACxB,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QACtC,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACvB,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,UAAU,CAAC,KAAQ;QACzB,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,6BAA6B,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The base class of a domain event, which gives it its name once
|
|
3
|
-
* `class InvoiceIssued extends NamedDomainEvent('billing.invoice.issued')
|
|
2
|
+
* The base class of a domain event, which gives it its name once and carries what every event
|
|
3
|
+
* says: `class InvoiceIssued extends NamedDomainEvent('billing.invoice.issued') {}` is built with
|
|
4
|
+
* `new InvoiceIssued(invoice.id, clock.now())`. The class carries the name as
|
|
4
5
|
* `InvoiceIssued.eventName`, what handlers and projections are attached under, and every event as
|
|
5
|
-
* `name`, both typed with the literal.
|
|
6
|
+
* `name`, both typed with the literal. An event that says more declares a constructor with its
|
|
7
|
+
* facts and hands the first two to `super`.
|
|
8
|
+
*
|
|
9
|
+
* The id of the aggregate is kept as text, here and nowhere else: an aggregate keyed by a number
|
|
10
|
+
* hands its id as it is.
|
|
6
11
|
*/
|
|
7
|
-
export declare function NamedDomainEvent<const Name extends string>(eventName: Name): (abstract new () => {
|
|
12
|
+
export declare function NamedDomainEvent<const Name extends string>(eventName: Name): (abstract new (aggregateId: string | number, occurredAt: Date) => {
|
|
8
13
|
readonly name: Name;
|
|
14
|
+
readonly aggregateId: string;
|
|
15
|
+
readonly occurredAt: Date;
|
|
9
16
|
}) & {
|
|
10
17
|
readonly eventName: Name;
|
|
11
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"named-domain-event.d.ts","sourceRoot":"","sources":["../../src/domain/named-domain-event.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"named-domain-event.d.ts","sourceRoot":"","sources":["../../src/domain/named-domain-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,SAAS,EAAE,IAAI,+BASxD,MAAM,GAAG,MAAM,cACP,IAAI;mBANZ,IAAI;0BAEG,MAAM;yBAIL,IAAI;;wBARA,IAAI;EAelC"}
|