@ddd-ts-kit/kernel 0.16.1 → 0.18.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.
Files changed (26) hide show
  1. package/README.fr.md +13 -11
  2. package/README.md +10 -7
  3. package/dist/declarations/decorators/domain-event-handler.d.ts +8 -10
  4. package/dist/declarations/decorators/domain-event-handler.d.ts.map +1 -1
  5. package/dist/declarations/decorators/domain-event-handler.js +6 -12
  6. package/dist/declarations/decorators/domain-event-handler.js.map +1 -1
  7. package/dist/declarations/decorators/event-name-of.d.ts +5 -0
  8. package/dist/declarations/decorators/event-name-of.d.ts.map +1 -0
  9. package/dist/declarations/decorators/event-name-of.js +10 -0
  10. package/dist/declarations/decorators/event-name-of.js.map +1 -0
  11. package/dist/declarations/decorators/on.d.ts +5 -8
  12. package/dist/declarations/decorators/on.d.ts.map +1 -1
  13. package/dist/declarations/decorators/on.js +5 -7
  14. package/dist/declarations/decorators/on.js.map +1 -1
  15. package/dist/declarations/model/named-domain-event-type.d.ts +11 -0
  16. package/dist/declarations/model/named-domain-event-type.d.ts.map +1 -0
  17. package/dist/declarations/model/named-domain-event-type.js +2 -0
  18. package/dist/declarations/model/named-domain-event-type.js.map +1 -0
  19. package/dist/declarations.d.ts +1 -0
  20. package/dist/declarations.d.ts.map +1 -1
  21. package/dist/declarations.js.map +1 -1
  22. package/dist/infrastructure/in-memory/in-process-bus.d.ts +7 -0
  23. package/dist/infrastructure/in-memory/in-process-bus.d.ts.map +1 -1
  24. package/dist/infrastructure/in-memory/in-process-bus.js +11 -1
  25. package/dist/infrastructure/in-memory/in-process-bus.js.map +1 -1
  26. package/package.json +15 -2
package/README.fr.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:0f2ab9b4e83a48cd -->
2
+ <!-- translation-of: README.md sha256:f823ab9a2902ff87 -->
3
3
 
4
4
  # @ddd-ts-kit/kernel
5
5
 
@@ -509,7 +509,7 @@ aussi.
509
509
  | `after-commit` | `dispatcher.on(name, callback, { phase: 'after-commit' })` | une fois la transaction validée, jamais quand elle a été annulée, dans l'ordre de distribution, attendue avant que la commande réponde | ne fait jamais échouer la commande : remonté, et les autres gestionnaires s'exécutent quand même |
510
510
 
511
511
  Avec les déclarations, la phase est une option du décorateur :
512
- `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName, phase: 'after-commit' })`.
512
+ `@DomainEventHandler(OrderPaid, { phase: 'after-commit' })`.
513
513
 
514
514
  La phase `after-commit` vaut au plus une fois : un crash entre la validation et l'exécution la
515
515
  perd. Ce qui ne doit pas se perdre passe par l'outbox sous forme d'événement d'intégration. Un
@@ -863,7 +863,7 @@ port et n'est pas vérifiée.
863
863
  | `CommandHandler(Message)` | l'unique gestionnaire d'une commande | `@CommandHandler(PlaceOrder)` |
864
864
  | `QueryHandler(Message)` | l'unique gestionnaire d'une requête | `@QueryHandler(GetOrder)` |
865
865
  | `IntegrationEventHandler(definition, { consumer, actorOf? })` | le gestionnaire d'un événement d'intégration d'un autre contexte | `@IntegrationEventHandler(OrderPlaced, { consumer: 'billing.invoice-on-order-placed' })` |
866
- | `DomainEventHandler(Event, { name })` | un gestionnaire d'un événement du domaine de son propre contexte | `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName })`, le nom que la classe de l'événement déclare une fois dans `static readonly eventName` |
866
+ | `DomainEventHandler(Event)` | un gestionnaire d'un événement du domaine de son propre contexte | `@DomainEventHandler(OrderPaid)`, rattaché au nom que la classe de l'événement déclare une fois dans `static readonly eventName` |
867
867
  | `Scheduled(name, schedule and options)` | un *job* déclenché par le temps, qui déclenche des cas d'usage | `@Scheduled('billing.send-reminders', { cron: '0 7 * * 1-5', timeZone: 'Europe/Paris' })` |
868
868
  | `Projection(name)` avec `On(definition)` sur ses méthodes | un projecteur : la classe qui tient un modèle de lecture à jour | `@Projection('scheduling.appointment-list')`, `@On(PaymentCaptured)` |
869
869
  | `Repository(Port, options?)` | l'adaptateur d'un *repository* du domaine | `@Repository(OrderRepository)` |
@@ -894,7 +894,9 @@ port et n'est pas vérifiée.
894
894
  `implements IntegrationEventHandler<OrderPlacedPayload>`. Un *job* implémente `ScheduledJob`.
895
895
  - **Les noms sont écrits, pas déduits** : le nom du consommateur, celui de la politique, celui du
896
896
  *job* et celui de l'événement du domaine survivent au renommage d'une classe, et la chaîne
897
- vide est refusée.
897
+ vide est refusée. Le nom d'un événement du domaine s'écrit une fois, dans
898
+ `static readonly eventName` sur sa classe : ses gestionnaires et ses projections l'y lisent
899
+ (`NamedDomainEventType`), et une classe qui ne le déclare pas est refusée par le compilateur.
898
900
  - **Une classe déclarée est son propre jeton** : `@ddd-ts-kit/di` lie un gestionnaire, un *job*
899
901
  ou une politique sous sa classe.
900
902
 
@@ -1872,7 +1874,7 @@ import { On, Projection } from '@ddd-ts-kit/kernel/declarations';
1872
1874
  export class AppointmentListProjection {
1873
1875
  constructor(private readonly appointments: AppointmentList) {}
1874
1876
 
1875
- @On(AppointmentBooked, { name: 'scheduling.appointment.booked' })
1877
+ @On(AppointmentBooked)
1876
1878
  booked(event: AppointmentBooked) {
1877
1879
  return this.appointments.upsertIfNewer(event.aggregateId, stampOf(event), () => rowOf(event));
1878
1880
  }
@@ -1884,7 +1886,7 @@ export class AppointmentListProjection {
1884
1886
  );
1885
1887
  }
1886
1888
 
1887
- @On(AppointmentCancelled, { name: 'scheduling.appointment.cancelled' })
1889
+ @On(AppointmentCancelled)
1888
1890
  cancelled(event: AppointmentCancelled) {
1889
1891
  return this.appointments.delete(event.aggregateId, stampOf(event));
1890
1892
  }
@@ -1894,11 +1896,11 @@ export class AppointmentListProjection {
1894
1896
  `@Projection('<context>.<name>')` est une déclaration comme les autres : les deux modes de
1895
1897
  décorateurs, ses dépendances dites par son constructeur, une classe par fichier, dans
1896
1898
  `application/projections/`, dans un fichier `*.projection.ts`. `@On(definition)` sur une méthode
1897
- dit « cette méthode applique cet événement d'intégration » ; `@On(EventClass, { name })` le dit
1898
- pour un événement du domaine du contexte propre de la projection. Une méthode qui prend un autre
1899
- événement est refusée par le compilateur, une projection sans aucun `@On` et un `@On` sur une
1900
- classe sans `@Projection` lèvent au chargement du fichier. Une méthode renvoie ce qu'a renvoyé son
1901
- store, ce qui permet à l'application de compter ce qui a été appliqué et ce qui était périmé.
1899
+ dit « cette méthode applique cet événement d'intégration » ; `@On(EventClass)` le dit pour un
1900
+ événement du domaine du contexte propre de la projection, sous le nom que sa classe déclare une
1901
+ fois, `static readonly eventName`. Une méthode qui prend un autre événement est refusée par le
1902
+ compilateur, une projection sans aucun `@On` et un `@On` sur une classe sans `@Projection`
1903
+ lèvent au chargement du fichier. Une méthode renvoie ce qu'a renvoyé son store, ce qui permet à l'application de compter ce qui a été appliqué et ce qui était périmé.
1902
1904
 
1903
1905
  **Un rôle de la CLI.** `application/projections/` est un répertoire de l'arborescence canonique,
1904
1906
  `ddd-ts-kit generate projection <context> <Name> <event-type>` écrit un projecteur avec sa spec,
package/README.md CHANGED
@@ -499,7 +499,7 @@ a repository adapter never call it. An aggregate is recognised by what it does (
499
499
  | `after-commit` | `dispatcher.on(name, callback, { phase: 'after-commit' })` | once the transaction has committed, never when it rolled back, in dispatch order, awaited before the command answers | never fails the command: reported, and the other handlers still run |
500
500
 
501
501
  With declarations the phase is an option of the decorator:
502
- `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName, phase: 'after-commit' })`.
502
+ `@DomainEventHandler(OrderPaid, { phase: 'after-commit' })`.
503
503
 
504
504
  The `after-commit` phase is at most once: a crash between the commit and the run loses it. What
505
505
  must not be lost goes through the outbox as an integration event. A `before-commit` handler
@@ -838,7 +838,7 @@ left alone.
838
838
  | `CommandHandler(Message)` | the one handler of a command | `@CommandHandler(PlaceOrder)` |
839
839
  | `QueryHandler(Message)` | the one handler of a query | `@QueryHandler(GetOrder)` |
840
840
  | `IntegrationEventHandler(definition, { consumer, actorOf? })` | the handler of an integration event of another context | `@IntegrationEventHandler(OrderPlaced, { consumer: 'billing.invoice-on-order-placed' })` |
841
- | `DomainEventHandler(Event, { name })` | a handler of a domain event of its own context | `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName })`, the name the event class declares once in `static readonly eventName` |
841
+ | `DomainEventHandler(Event)` | a handler of a domain event of its own context | `@DomainEventHandler(OrderPaid)`, attached under the name the event class declares once in `static readonly eventName` |
842
842
  | `Scheduled(name, schedule and options)` | a job run by time, which triggers use cases | `@Scheduled('billing.send-reminders', { cron: '0 7 * * 1-5', timeZone: 'Europe/Paris' })` |
843
843
  | `Projection(name)` with `On(definition)` on its methods | a projector: the class that keeps one read model up to date | `@Projection('scheduling.appointment-list')`, `@On(PaymentCaptured)` |
844
844
  | `Repository(Port, options?)` | the adapter of a repository of the domain | `@Repository(OrderRepository)` |
@@ -866,6 +866,9 @@ left alone.
866
866
  `implements IntegrationEventHandler<OrderPlacedPayload>`. A job implements `ScheduledJob`.
867
867
  - **Names are written, not derived**: the consumer name, the policy name, the job name and the
868
868
  name of the domain event survive the renaming of a class, and the empty string is refused.
869
+ The name of a domain event is written once, in `static readonly eventName` on its class: its
870
+ handlers and projections read it there (`NamedDomainEventType`), and a class without it is
871
+ refused by the compiler.
869
872
  - **A declared class is its own token**: `@ddd-ts-kit/di` binds a handler, a job or a policy
870
873
  under its class.
871
874
 
@@ -1792,7 +1795,7 @@ import { On, Projection } from '@ddd-ts-kit/kernel/declarations';
1792
1795
  export class AppointmentListProjection {
1793
1796
  constructor(private readonly appointments: AppointmentList) {}
1794
1797
 
1795
- @On(AppointmentBooked, { name: 'scheduling.appointment.booked' })
1798
+ @On(AppointmentBooked)
1796
1799
  booked(event: AppointmentBooked) {
1797
1800
  return this.appointments.upsertIfNewer(event.aggregateId, stampOf(event), () => rowOf(event));
1798
1801
  }
@@ -1804,7 +1807,7 @@ export class AppointmentListProjection {
1804
1807
  );
1805
1808
  }
1806
1809
 
1807
- @On(AppointmentCancelled, { name: 'scheduling.appointment.cancelled' })
1810
+ @On(AppointmentCancelled)
1808
1811
  cancelled(event: AppointmentCancelled) {
1809
1812
  return this.appointments.delete(event.aggregateId, stampOf(event));
1810
1813
  }
@@ -1814,9 +1817,9 @@ export class AppointmentListProjection {
1814
1817
  `@Projection('<context>.<name>')` is a declaration like the others: both decorator
1815
1818
  modes, its dependencies stated by its constructor, one class per file, in
1816
1819
  `application/projections/`, in a `*.projection.ts` file. `@On(definition)` on a method says
1817
- "this method applies that integration event"; `@On(EventClass, { name })` says it for a domain
1818
- event of the projection's own context. A method that takes another event is refused by the
1819
- compiler, a projection without any `@On` and an `@On` on a class without `@Projection` throw
1820
+ "this method applies that integration event"; `@On(EventClass)` says it for a domain event of the
1821
+ projection's own context, under the name its class declares once, `static readonly eventName`.
1822
+ A method that takes another event is refused by the compiler, a projection without any `@On` and an `@On` on a class without `@Projection` throw
1820
1823
  when the file loads. A method answers what its store answered, which is how the application
1821
1824
  counts what was applied and what was stale.
1822
1825
 
@@ -4,11 +4,9 @@ import type { ClassDeclarator } from '../dependencies/class-declarator.js';
4
4
  import type { DeclaredDependencies } from '../dependencies/declared-dependencies.js';
5
5
  import type { DependenciesFromSignature } from '../dependencies/dependencies-from-signature.js';
6
6
  import type { DomainEventHandler as DomainEventHandlerShape } from '../model/domain-event-handler.js';
7
- import type { DomainEventType } from '../model/domain-event-type.js';
7
+ import type { NamedDomainEventType } from '../model/named-domain-event-type.js';
8
8
  import type { Named } from './named.js';
9
- export interface DomainEventHandlerOptions<Name extends string = string> {
10
- /** The `name` the events of this type carry, `<context>.<aggregate>.<fact>`: what the dispatcher routes by. */
11
- readonly name: Name;
9
+ export interface DomainEventHandlerOptions {
12
10
  /**
13
11
  * `before-commit`, the default: at the end of the unit of work, inside its transaction.
14
12
  * `after-commit`: once it has committed, for an effect no transaction covers; at most once.
@@ -22,11 +20,11 @@ export interface DomainEventHandlerOptions<Name extends string = string> {
22
20
  export type DomainEventHandler<E extends DomainEvent> = DomainEventHandlerShape<E>;
23
21
  /**
24
22
  * A handler of a domain event of its own context, run at the end of the unit of work that
25
- * recorded the event, before the commit:
26
- * `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName })`, the name the event class
27
- * declares once (`static readonly eventName = 'ordering.order.paid'`). One whose
28
- * effect is outside the transaction runs after it:
29
- * `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName, phase: 'after-commit' })`.
23
+ * recorded the event, before the commit: `@DomainEventHandler(OrderPaid)`. It is attached under
24
+ * the name the event class declares once (`static readonly eventName = 'ordering.order.paid'`).
25
+ * One whose effect is outside the transaction runs after it:
26
+ * `@DomainEventHandler(OrderPaid, { phase: 'after-commit' })`.
30
27
  */
31
- export declare function DomainEventHandler<E extends DomainEvent, const Name extends string, const D extends DeclaredDependencies = DependenciesFromSignature>(event: DomainEventType<E>, options: DomainEventHandlerOptions<Name> & Named<Name, 'name'>, dependencies?: D): ClassDeclarator<DomainEventHandlerShape<E>, D>;
28
+ export declare function DomainEventHandler<E extends DomainEvent, const Name extends string, const D extends DeclaredDependencies = DependenciesFromSignature>(event: NamedDomainEventType<E, Name> & Named<Name, 'eventName'>, dependencies?: D): ClassDeclarator<DomainEventHandlerShape<E>, D>;
29
+ export declare function DomainEventHandler<E extends DomainEvent, const Name extends string, const D extends DeclaredDependencies = DependenciesFromSignature>(event: NamedDomainEventType<E, Name> & Named<Name, 'eventName'>, options: DomainEventHandlerOptions, dependencies?: D): ClassDeclarator<DomainEventHandlerShape<E>, D>;
32
30
  //# sourceMappingURL=domain-event-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-event-handler.d.ts","sourceRoot":"","sources":["../../../src/declarations/decorators/domain-event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,KAAK,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,yBAAyB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IACrE,+GAA+G;IAC/G,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAEnF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,WAAW,EACrB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,CAAC,CAAC,SAAS,oBAAoB,GAAG,yBAAyB,EAEhE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,OAAO,EAAE,yBAAyB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,EAC9D,YAAY,CAAC,EAAE,CAAC,GACf,eAAe,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAehD"}
1
+ {"version":3,"file":"domain-event-handler.d.ts","sourceRoot":"","sources":["../../../src/declarations/decorators/domain-event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,oBA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.js';
2
- import { assertNamed } from './assert-named.js';
3
- /**
4
- * A handler of a domain event of its own context, run at the end of the unit of work that
5
- * recorded the event, before the commit:
6
- * `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName })`, the name the event class
7
- * declares once (`static readonly eventName = 'ordering.order.paid'`). One whose
8
- * effect is outside the transaction runs after it:
9
- * `@DomainEventHandler(OrderPaid, { name: OrderPaid.eventName, phase: 'after-commit' })`.
10
- */
11
- export function DomainEventHandler(event, options, dependencies) {
12
- const { name, phase = 'before-commit' } = options;
13
- assertNamed(name, `A handler of ${event.name} needs the name its events carry`);
2
+ import { eventNameOf } from './event-name-of.js';
3
+ import { isDependencies } from './is-dependencies.js';
4
+ export function DomainEventHandler(event, ...[first, second]) {
5
+ const name = eventNameOf(event, 'A handler');
6
+ const phase = (isDependencies(first) ? undefined : first?.phase) ?? 'before-commit';
7
+ const dependencies = isDependencies(first) ? first : second;
14
8
  return (target) => {
15
9
  record(target, {
16
10
  role: 'domain-event-handler',
@@ -1 +1 @@
1
- {"version":3,"file":"domain-event-handler.js","sourceRoot":"","sources":["../../../src/declarations/decorators/domain-event-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmBhD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAKhC,KAAyB,EACzB,OAA8D,EAC9D,YAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IAElD,WAAW,CAAC,IAAI,EAAE,gBAAgB,KAAK,CAAC,IAAI,kCAAkC,CAAC,CAAC;IAEhF,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,CAAC,MAAM,EAAE;YACb,IAAI,EAAE,sBAAsB;YAC5B,IAAI;YACJ,KAAK;YACL,KAAK;YACL,YAAY;YACZ,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"domain-event-handler.js","sourceRoot":"","sources":["../../../src/declarations/decorators/domain-event-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA2CtD,MAAM,UAAU,kBAAkB,CAChC,KAA8B,EAC9B,GAAG,CAAC,KAAK,EAAE,MAAM,CAAyC;IAE1D,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,eAAe,CAAC;IACpF,MAAM,YAAY,GAAyB,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAElF,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,CAAC,MAAM,EAAE;YACb,IAAI,EAAE,sBAAsB;YAC5B,IAAI;YACJ,KAAK;YACL,KAAK;YACL,YAAY;YACZ,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DomainEvent } from '../../domain/domain-event.js';
2
+ import type { NamedDomainEventType } from '../model/named-domain-event-type.js';
3
+ /** The name the event class declares, read once by the decorator that attaches a reader to its events. */
4
+ export declare function eventNameOf(event: NamedDomainEventType<DomainEvent>, reader: string): string;
5
+ //# sourceMappingURL=event-name-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-name-of.d.ts","sourceRoot":"","sources":["../../../src/declarations/decorators/event-name-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAGhF,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5F"}
@@ -0,0 +1,10 @@
1
+ import { DeclarationError } from '../registry/declaration-error.js';
2
+ /** The name the event class declares, read once by the decorator that attaches a reader to its events. */
3
+ export function eventNameOf(event, reader) {
4
+ const name = event.eventName;
5
+ if (typeof name !== 'string' || name.trim() === '') {
6
+ throw new DeclarationError(`${reader} of ${event.name} is attached under the name its events carry: declare it once on the event class, static readonly eventName = '<context>.<aggregate>.<fact>'.`);
7
+ }
8
+ return name;
9
+ }
10
+ //# sourceMappingURL=event-name-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-name-of.js","sourceRoot":"","sources":["../../../src/declarations/decorators/event-name-of.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,0GAA0G;AAC1G,MAAM,UAAU,WAAW,CAAC,KAAwC,EAAE,MAAc;IAClF,MAAM,IAAI,GAAY,KAAK,CAAC,SAAS,CAAC;IAEtC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,gBAAgB,CACxB,GAAG,MAAM,OAAO,KAAK,CAAC,IAAI,+IAA+I,CAC1K,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,19 +1,16 @@
1
1
  import type { IntegrationEvent } from '../../application/events/integration-event.js';
2
2
  import type { DomainEvent } from '../../domain/domain-event.js';
3
- import type { DomainEventType } from '../model/domain-event-type.js';
4
3
  import type { EventContract } from '../model/event-contract.js';
5
- import type { DomainEventHandlerOptions } from './domain-event-handler.js';
4
+ import type { NamedDomainEventType } from '../model/named-domain-event-type.js';
6
5
  import type { Named } from './named.js';
7
6
  import type { ProjectionMethodDecorator } from './projection-method-decorator.js';
8
- type DomainEventName<Name extends string = string> = Pick<DomainEventHandlerOptions<Name>, 'name'>;
9
7
  /**
10
8
  * On a method of a `@Projection` class: this method applies that event.
11
9
  * `@On(PractitionerRenamed)` for an integration event of an upstream context,
12
- * `@On(AppointmentBooked, { name: AppointmentBooked.eventName })` for a domain event of
13
- * the projection's own context. The method receives the event and answers what its store
14
- * answered.
10
+ * `@On(AppointmentBooked)` for a domain event of the projection's own context, applied under
11
+ * the name its class declares once (`static readonly eventName`). The method receives the event
12
+ * and answers what its store answered.
15
13
  */
16
14
  export declare function On<Payload>(contract: EventContract<Payload>): ProjectionMethodDecorator<IntegrationEvent<Payload>>;
17
- export declare function On<E extends DomainEvent, const Name extends string>(event: DomainEventType<E>, options: DomainEventName<Name> & Named<Name, 'name'>): ProjectionMethodDecorator<E>;
18
- export {};
15
+ export declare function On<E extends DomainEvent, const Name extends string>(event: NamedDomainEventType<E, Name> & Named<Name, 'eventName'>): ProjectionMethodDecorator<E>;
19
16
  //# sourceMappingURL=on.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../../../src/declarations/decorators/on.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,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B,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,CAAC,IAAI,SAAS,MAAM,EACjE,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9D,yBAAyB,CAAC,CAAC,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { DeclarationError } from '../registry/declaration-error.js';
2
- import { assertNamed } from './assert-named.js';
2
+ import { eventNameOf } from './event-name-of.js';
3
3
  import { pendingApplications } from './pending-applications.js';
4
- export function On(source, options) {
5
- const applied = appliedOf(source, options);
4
+ export function On(source) {
5
+ const applied = appliedOf(source);
6
6
  return (target, second) => {
7
7
  const standard = typeof second === 'object' && second !== null;
8
8
  const name = standard && 'name' in second ? second.name : second;
@@ -15,13 +15,11 @@ export function On(source, options) {
15
15
  });
16
16
  };
17
17
  }
18
- function appliedOf(source, options) {
18
+ function appliedOf(source) {
19
19
  if (typeof source !== 'function') {
20
20
  return { kind: 'integration', contract: source };
21
21
  }
22
- const name = options?.name ?? '';
23
- assertNamed(name, `A projection of ${source.name} needs the name its events carry`);
24
- return { kind: 'domain', event: source, name };
22
+ return { kind: 'domain', event: source, name: eventNameOf(source, 'A projection') };
25
23
  }
26
24
  function isHidden(context) {
27
25
  return ('static' in context && context.static === true) || ('private' in context && context.private === true);
@@ -1 +1 @@
1
- {"version":3,"file":"on.js","sourceRoot":"","sources":["../../../src/declarations/decorators/on.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAsBhE,MAAM,UAAU,EAAE,CAChB,MAA6D,EAC7D,OAAyB;IAEzB,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,CAAC,MAA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,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,CAAC,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;AAChH,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,IAAI,gBAAgB,CAAC,gEAAgE,CAAC,CAAC;AAChG,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { DomainEvent } from '../../domain/domain-event.js';
2
+ import type { DomainEventType } from './domain-event-type.js';
3
+ /**
4
+ * A domain event class that declares once the name its events carry,
5
+ * `static readonly eventName = 'billing.invoice.issued'`: what its handlers and projections are
6
+ * attached under.
7
+ */
8
+ export type NamedDomainEventType<E extends DomainEvent, Name extends string = string> = DomainEventType<E> & {
9
+ readonly eventName: Name;
10
+ };
11
+ //# sourceMappingURL=named-domain-event-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named-domain-event-type.d.ts","sourceRoot":"","sources":["../../../src/declarations/model/named-domain-event-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG;IAC3G,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=named-domain-event-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named-domain-event-type.js","sourceRoot":"","sources":["../../../src/declarations/model/named-domain-event-type.ts"],"names":[],"mappings":""}
@@ -41,6 +41,7 @@ export type { DeclaredPolicy } from './declarations/model/declared-policy.js';
41
41
  export type { DomainEventHandlerDeclaration } from './declarations/model/domain-event-handler-declaration.js';
42
42
  export type { DomainEventHandlerUse } from './declarations/model/domain-event-handler-use.js';
43
43
  export type { DomainEventType } from './declarations/model/domain-event-type.js';
44
+ export type { NamedDomainEventType } from './declarations/model/named-domain-event-type.js';
44
45
  export type { EdgeDeclaration } from './declarations/model/edge-declaration.js';
45
46
  export type { EventContract } from './declarations/model/event-contract.js';
46
47
  export type { HandlerDeclaration } from './declarations/model/handler-declaration.js';
@@ -1 +1 @@
1
- {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,KAAK,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvH,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EACL,KAAK,8BAA8B,EACnC,uBAAuB,GACxB,MAAM,wDAAwD,CAAC;AAChE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AACrD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE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AqC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAyB,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAyB,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAW1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAiChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC"}
@@ -10,8 +10,15 @@ export declare class InProcessBus {
10
10
  private readonly handlers;
11
11
  private readonly contexts;
12
12
  private readonly middlewares;
13
+ private readonly aroundHandlers;
13
14
  constructor(kind: MessageInfo['kind']);
14
15
  use(middleware: BusMiddleware): this;
16
+ /**
17
+ * Runs `middleware` right around the handler, inside every middleware given to `use`, whenever
18
+ * those were added: what has to see the handler itself run, never a middleware that answers
19
+ * in its place.
20
+ */
21
+ aroundHandler(middleware: BusMiddleware): this;
15
22
  protected add(type: MessageType<Message>, handler: AnyHandler, registration?: HandlerRegistration): void;
16
23
  protected dispatch<M extends Message>(message: M): Promise<ResultOf<M>>;
17
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"in-process-bus.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-process-bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAGnF,OAAO,KAAK,EAAE,m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,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,YAAY;IASX,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IAEvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IAEnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IAEtD,YAA6B,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAI;IAE1D,GAAG,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CAInC;IAED;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CAI7C;IAED,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,GAAE,mBAAwB,GAAG,IAAI,CAU3G;IAED,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAiBtE;CACF"}
@@ -5,6 +5,7 @@ export class InProcessBus {
5
5
  handlers = new Map();
6
6
  contexts = new Map();
7
7
  middlewares = [];
8
+ aroundHandlers = [];
8
9
  constructor(kind) {
9
10
  this.kind = kind;
10
11
  }
@@ -12,6 +13,15 @@ export class InProcessBus {
12
13
  this.middlewares.push(middleware);
13
14
  return this;
14
15
  }
16
+ /**
17
+ * Runs `middleware` right around the handler, inside every middleware given to `use`, whenever
18
+ * those were added: what has to see the handler itself run, never a middleware that answers
19
+ * in its place.
20
+ */
21
+ aroundHandler(middleware) {
22
+ this.aroundHandlers.push(middleware);
23
+ return this;
24
+ }
15
25
  add(type, handler, registration = {}) {
16
26
  if (this.handlers.has(type)) {
17
27
  throw new DuplicateHandlerError({ kind: this.kind, name: type.name });
@@ -29,7 +39,7 @@ export class InProcessBus {
29
39
  if (!handler) {
30
40
  return Promise.reject(new HandlerNotFoundError(info));
31
41
  }
32
- const run = this.middlewares.reduceRight((next, middleware) => () => middleware(message, next, info), () => handler.execute(message));
42
+ const run = [...this.middlewares, ...this.aroundHandlers].reduceRight((next, middleware) => () => middleware(message, next, info), () => handler.execute(message));
33
43
  // eslint-disable-next-line ddd-ts-kit/clean-no-escape-hatch -- handlers of every message type share one map and middlewares answer unknown: the link between a message and its result is only known to register()
34
44
  return run();
35
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"in-process-bus.js","sourceRoot":"","sources":["../../../src/infrastructure/in-memory/in-process-bus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAQ9F,MAAM,OAAO,YAAY;IAOM,IAAI;IANhB,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE1C,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEtC,WAAW,GAAoB,EAAE,CAAC;IAEnD,YAA6B,IAAyB;oBAAzB,IAAI;IAAwB,CAAC;IAE1D,GAAG,CAAC,UAAyB;QAC3B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElC,OAAO,IAAI,CAAC;IACd,CAAC;IAES,GAAG,CAAC,IAA0B,EAAE,OAAmB,EAAE,YAAY,GAAwB,EAAE;QACnG,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,qBAAqB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAA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D,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;QACtC,MAAM,IAAI,GAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QACnG,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEvD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,WAAW,CACnE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAC3D,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/B,CAAC;QAEF,kNAAkN;QAClN,OAAO,GAAG,EAA0B,CAAC;IACvC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/kernel",
3
- "version": "0.16.1",
4
- "description": "Framework-agnostic DDD building blocks, application ports and an in-memory event bus.",
3
+ "version": "0.18.0",
4
+ "description": "Framework-agnostic Domain-Driven Design (DDD) building blocks for TypeScript: aggregates, entities, value objects, domain events, CQRS command and query buses, unit of work and application ports, with an in-memory event bus.",
5
+ "keywords": [
6
+ "ddd",
7
+ "domain-driven-design",
8
+ "clean-architecture",
9
+ "hexagonal-architecture",
10
+ "typescript",
11
+ "aggregate",
12
+ "value-object",
13
+ "domain-events",
14
+ "cqrs",
15
+ "unit-of-work",
16
+ "ports-and-adapters"
17
+ ],
5
18
  "license": "MIT",
6
19
  "repository": {
7
20
  "type": "git",