@cqrs-ddd/core 0.2.1 → 0.4.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 (179) hide show
  1. package/README.md +32 -13
  2. package/dist/application/base.command.d.ts.map +1 -1
  3. package/dist/application/base.command.js +5 -9
  4. package/dist/application/base.command.js.map +1 -1
  5. package/dist/application/base.query.d.ts +1 -1
  6. package/dist/application/base.query.d.ts.map +1 -1
  7. package/dist/application/base.query.js +7 -11
  8. package/dist/application/base.query.js.map +1 -1
  9. package/dist/application/command-base.handler.d.ts +18 -8
  10. package/dist/application/command-base.handler.d.ts.map +1 -1
  11. package/dist/application/command-base.handler.js +19 -12
  12. package/dist/application/command-base.handler.js.map +1 -1
  13. package/dist/application/index.d.ts +10 -10
  14. package/dist/application/index.d.ts.map +1 -1
  15. package/dist/application/index.js +10 -26
  16. package/dist/application/index.js.map +1 -1
  17. package/dist/application/ports/cache.port.js +1 -4
  18. package/dist/application/ports/cache.port.js.map +1 -1
  19. package/dist/application/ports/command-repository.port.js +1 -2
  20. package/dist/application/ports/command-repository.port.js.map +1 -1
  21. package/dist/application/ports/domain-event-publisher.port.d.ts +4 -2
  22. package/dist/application/ports/domain-event-publisher.port.d.ts.map +1 -1
  23. package/dist/application/ports/domain-event-publisher.port.js +1 -2
  24. package/dist/application/ports/domain-event-publisher.port.js.map +1 -1
  25. package/dist/application/ports/query-repository.port.d.ts +1 -1
  26. package/dist/application/ports/query-repository.port.d.ts.map +1 -1
  27. package/dist/application/ports/query-repository.port.js +1 -2
  28. package/dist/application/ports/query-repository.port.js.map +1 -1
  29. package/dist/application/ports/write-side-aggregate-repository.port.d.ts +1 -1
  30. package/dist/application/ports/write-side-aggregate-repository.port.d.ts.map +1 -1
  31. package/dist/application/ports/write-side-aggregate-repository.port.js +1 -2
  32. package/dist/application/ports/write-side-aggregate-repository.port.js.map +1 -1
  33. package/dist/application/query.options.js +1 -2
  34. package/dist/application/query.options.js.map +1 -1
  35. package/dist/application/request-fields.helper.js +2 -6
  36. package/dist/application/request-fields.helper.js.map +1 -1
  37. package/dist/application/tenant-resolver.js +5 -10
  38. package/dist/application/tenant-resolver.js.map +1 -1
  39. package/dist/domain/decorators/apply-mutation.decorator.d.ts +1 -1
  40. package/dist/domain/decorators/apply-mutation.decorator.d.ts.map +1 -1
  41. package/dist/domain/decorators/apply-mutation.decorator.js +1 -4
  42. package/dist/domain/decorators/apply-mutation.decorator.js.map +1 -1
  43. package/dist/domain/decorators/mutable.decorator.js +2 -6
  44. package/dist/domain/decorators/mutable.decorator.js.map +1 -1
  45. package/dist/domain/events/domain.event.d.ts +1 -1
  46. package/dist/domain/events/domain.event.d.ts.map +1 -1
  47. package/dist/domain/events/domain.event.js +3 -7
  48. package/dist/domain/events/domain.event.js.map +1 -1
  49. package/dist/domain/events/event.interface.js +1 -2
  50. package/dist/domain/events/event.interface.js.map +1 -1
  51. package/dist/domain/events/root-domain.event.d.ts +3 -3
  52. package/dist/domain/events/root-domain.event.d.ts.map +1 -1
  53. package/dist/domain/events/root-domain.event.js +3 -8
  54. package/dist/domain/events/root-domain.event.js.map +1 -1
  55. package/dist/domain/exceptions/concurrency-conflict.error.d.ts +1 -1
  56. package/dist/domain/exceptions/concurrency-conflict.error.d.ts.map +1 -1
  57. package/dist/domain/exceptions/concurrency-conflict.error.js +2 -6
  58. package/dist/domain/exceptions/concurrency-conflict.error.js.map +1 -1
  59. package/dist/domain/exceptions/domain.exception.d.ts.map +1 -1
  60. package/dist/domain/exceptions/domain.exception.js +1 -5
  61. package/dist/domain/exceptions/domain.exception.js.map +1 -1
  62. package/dist/domain/exceptions/entity-not-found.exception.d.ts +1 -1
  63. package/dist/domain/exceptions/entity-not-found.exception.d.ts.map +1 -1
  64. package/dist/domain/exceptions/entity-not-found.exception.js +2 -6
  65. package/dist/domain/exceptions/entity-not-found.exception.js.map +1 -1
  66. package/dist/domain/exceptions/invalid-value.exception.d.ts +2 -2
  67. package/dist/domain/exceptions/invalid-value.exception.d.ts.map +1 -1
  68. package/dist/domain/exceptions/invalid-value.exception.js +2 -6
  69. package/dist/domain/exceptions/invalid-value.exception.js.map +1 -1
  70. package/dist/domain/exceptions/missing-tenant-context.exception.d.ts +1 -1
  71. package/dist/domain/exceptions/missing-tenant-context.exception.d.ts.map +1 -1
  72. package/dist/domain/exceptions/missing-tenant-context.exception.js +2 -6
  73. package/dist/domain/exceptions/missing-tenant-context.exception.js.map +1 -1
  74. package/dist/domain/exceptions/transient-operation.error.d.ts.map +1 -1
  75. package/dist/domain/exceptions/transient-operation.error.js +2 -7
  76. package/dist/domain/exceptions/transient-operation.error.js.map +1 -1
  77. package/dist/domain/exceptions/unknown-mutable-field.error.d.ts.map +1 -1
  78. package/dist/domain/exceptions/unknown-mutable-field.error.js +1 -5
  79. package/dist/domain/exceptions/unknown-mutable-field.error.js.map +1 -1
  80. package/dist/domain/index.d.ts +19 -18
  81. package/dist/domain/index.d.ts.map +1 -1
  82. package/dist/domain/index.js +19 -34
  83. package/dist/domain/index.js.map +1 -1
  84. package/dist/domain/interfaces/aggregate-root.interface.d.ts +41 -0
  85. package/dist/domain/interfaces/aggregate-root.interface.d.ts.map +1 -0
  86. package/dist/domain/interfaces/aggregate-root.interface.js +3 -0
  87. package/dist/domain/interfaces/aggregate-root.interface.js.map +1 -0
  88. package/dist/domain/interfaces/root-entity-snapshot.interface.js +1 -2
  89. package/dist/domain/interfaces/root-entity-snapshot.interface.js.map +1 -1
  90. package/dist/domain/models/aggregate-root.d.ts +34 -22
  91. package/dist/domain/models/aggregate-root.d.ts.map +1 -1
  92. package/dist/domain/models/aggregate-root.js +38 -12
  93. package/dist/domain/models/aggregate-root.js.map +1 -1
  94. package/dist/domain/models/root.entity.d.ts +3 -3
  95. package/dist/domain/models/root.entity.d.ts.map +1 -1
  96. package/dist/domain/models/root.entity.js +9 -13
  97. package/dist/domain/models/root.entity.js.map +1 -1
  98. package/dist/domain/rules/number.rule.d.ts +1 -1
  99. package/dist/domain/rules/number.rule.d.ts.map +1 -1
  100. package/dist/domain/rules/number.rule.js +4 -7
  101. package/dist/domain/rules/number.rule.js.map +1 -1
  102. package/dist/domain/rules/rule-support.d.ts +1 -1
  103. package/dist/domain/rules/rule-support.d.ts.map +1 -1
  104. package/dist/domain/rules/rule-support.js +3 -7
  105. package/dist/domain/rules/rule-support.js.map +1 -1
  106. package/dist/domain/rules/text.rule.d.ts +1 -1
  107. package/dist/domain/rules/text.rule.d.ts.map +1 -1
  108. package/dist/domain/rules/text.rule.js +4 -7
  109. package/dist/domain/rules/text.rule.js.map +1 -1
  110. package/dist/domain/rules/value-violation.js +1 -2
  111. package/dist/domain/rules/value-violation.js.map +1 -1
  112. package/dist/http/domain-error-http-status.d.ts +1 -1
  113. package/dist/http/domain-error-http-status.d.ts.map +1 -1
  114. package/dist/http/domain-error-http-status.js +9 -12
  115. package/dist/http/domain-error-http-status.js.map +1 -1
  116. package/dist/http/index.d.ts +1 -1
  117. package/dist/http/index.d.ts.map +1 -1
  118. package/dist/http/index.js +1 -17
  119. package/dist/http/index.js.map +1 -1
  120. package/dist/index.d.ts +5 -5
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js +5 -21
  123. package/dist/index.js.map +1 -1
  124. package/dist/persistence/cache/cache-logger.js +2 -6
  125. package/dist/persistence/cache/cache-logger.js.map +1 -1
  126. package/dist/persistence/cache/memory.cache.d.ts +1 -1
  127. package/dist/persistence/cache/memory.cache.d.ts.map +1 -1
  128. package/dist/persistence/cache/memory.cache.js +4 -8
  129. package/dist/persistence/cache/memory.cache.js.map +1 -1
  130. package/dist/persistence/command-repository.abstract.d.ts +2 -2
  131. package/dist/persistence/command-repository.abstract.d.ts.map +1 -1
  132. package/dist/persistence/command-repository.abstract.js +1 -5
  133. package/dist/persistence/command-repository.abstract.js.map +1 -1
  134. package/dist/persistence/decorators/acknowledge-persisted.decorator.d.ts.map +1 -1
  135. package/dist/persistence/decorators/acknowledge-persisted.decorator.js +1 -4
  136. package/dist/persistence/decorators/acknowledge-persisted.decorator.js.map +1 -1
  137. package/dist/persistence/decorators/cache.decorator.d.ts +1 -1
  138. package/dist/persistence/decorators/cache.decorator.d.ts.map +1 -1
  139. package/dist/persistence/decorators/cache.decorator.js +22 -26
  140. package/dist/persistence/decorators/cache.decorator.js.map +1 -1
  141. package/dist/persistence/decorators/from-cache.decorator.d.ts +3 -3
  142. package/dist/persistence/decorators/from-cache.decorator.d.ts.map +1 -1
  143. package/dist/persistence/decorators/from-cache.decorator.js +16 -20
  144. package/dist/persistence/decorators/from-cache.decorator.js.map +1 -1
  145. package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts +1 -1
  146. package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts.map +1 -1
  147. package/dist/persistence/decorators/map-persistence-errors.decorator.js +3 -6
  148. package/dist/persistence/decorators/map-persistence-errors.decorator.js.map +1 -1
  149. package/dist/persistence/decorators/persisted-write.decorator.d.ts +4 -4
  150. package/dist/persistence/decorators/persisted-write.decorator.d.ts.map +1 -1
  151. package/dist/persistence/decorators/persisted-write.decorator.js +7 -10
  152. package/dist/persistence/decorators/persisted-write.decorator.js.map +1 -1
  153. package/dist/persistence/helpers/cache-barrier.helper.js +4 -8
  154. package/dist/persistence/helpers/cache-barrier.helper.js.map +1 -1
  155. package/dist/persistence/helpers/cache-key.helper.d.ts +1 -1
  156. package/dist/persistence/helpers/cache-key.helper.d.ts.map +1 -1
  157. package/dist/persistence/helpers/cache-key.helper.js +11 -15
  158. package/dist/persistence/helpers/cache-key.helper.js.map +1 -1
  159. package/dist/persistence/helpers/cache-owner.helper.d.ts +1 -1
  160. package/dist/persistence/helpers/cache-owner.helper.d.ts.map +1 -1
  161. package/dist/persistence/helpers/cache-owner.helper.js +4 -7
  162. package/dist/persistence/helpers/cache-owner.helper.js.map +1 -1
  163. package/dist/persistence/helpers/cache-snapshot.helper.js +1 -4
  164. package/dist/persistence/helpers/cache-snapshot.helper.js.map +1 -1
  165. package/dist/persistence/helpers/cache-version.helper.js +5 -8
  166. package/dist/persistence/helpers/cache-version.helper.js.map +1 -1
  167. package/dist/persistence/index.d.ts +14 -14
  168. package/dist/persistence/index.d.ts.map +1 -1
  169. package/dist/persistence/index.js +14 -30
  170. package/dist/persistence/index.js.map +1 -1
  171. package/dist/persistence/persistence-dialect.js +2 -6
  172. package/dist/persistence/persistence-dialect.js.map +1 -1
  173. package/dist/persistence/query-repository.abstract.d.ts +3 -3
  174. package/dist/persistence/query-repository.abstract.d.ts.map +1 -1
  175. package/dist/persistence/query-repository.abstract.js +1 -5
  176. package/dist/persistence/query-repository.abstract.js.map +1 -1
  177. package/dist/types/Method.type.js +1 -2
  178. package/dist/types/Method.type.js.map +1 -1
  179. package/package.json +10 -8
package/README.md CHANGED
@@ -38,10 +38,13 @@ pnpm add @cqrs-ddd/core
38
38
  npm install @cqrs-ddd/core
39
39
  ```
40
40
 
41
- Requires Node.js 22 or later. It installs `@cqrs-ddd/uuidv7` and
41
+ Requires Node.js 22.12 or later. It installs `@cqrs-ddd/uuidv7` and
42
42
  `@cqrs-ddd/safe-stringify`, which have no dependencies. To persist with MikroORM, add
43
43
  `@cqrs-ddd/mikro-orm` and `@mikro-orm/core` 7.
44
44
 
45
+ Published as an ES module; a CommonJS application loads it with `require()`. Coming from
46
+ 0.3.x, see [Upgrading from 0.3.x](https://github.com/aristoteliss/nestjs-pipeline#upgrading-from-03x).
47
+
45
48
  ## Entry points
46
49
 
47
50
  Import from the entry point for the layer you are writing. Each one loads only what it
@@ -49,7 +52,7 @@ needs.
49
52
 
50
53
  | Entry | Holds |
51
54
  | --- | --- |
52
- | `@cqrs-ddd/core/domain` | `AggregateRoot`, `RootEntity`, `RootEntitySnapshot`, `@Mutable`, `getMutableFields`, `@ApplyMutation`, `IEvent`, `DomainEvent`, `RootDomainEvent`, `deepCloneAndFreeze`, `textRule`, `numberRule`, `ValueViolation`, and the errors `DomainException`, `InvalidValueException`, `EntityNotFoundException`, `ConcurrencyConflictError`, `TransientOperationError` (with `isTransientOperationError`), `MissingTenantContextError`, `UnknownMutableFieldError` |
55
+ | `@cqrs-ddd/core/domain` | `AggregateRoot`, `IAggregateRoot`, `ApplyEventOptions`, `RootEntity`, `RootEntitySnapshot`, `@Mutable`, `getMutableFields`, `@ApplyMutation`, `IEvent`, `DomainEvent`, `RootDomainEvent`, `deepCloneAndFreeze`, `textRule`, `numberRule`, `ValueViolation`, and the errors `DomainException`, `InvalidValueException`, `EntityNotFoundException`, `ConcurrencyConflictError`, `TransientOperationError` (with `isTransientOperationError`), `MissingTenantContextError`, `UnknownMutableFieldError` |
53
56
  | `@cqrs-ddd/core/application` | `BaseCommand`, `BaseQuery`, `IQueryOptions`, `CommandBaseHandler`, the ports (`IDomainEventPublisher`, `ICommandRepository`, `IQueryRepository`, `IWriteSideAggregateRepository`, `ICache`, `IVersionedCache`, `isVersionedCache`), `requireTenant`, `setTenantResolver`, and the deprecated `requireTenantId` |
54
57
  | `@cqrs-ddd/core/persistence` | the lifecycle decorators (`@PersistedWrite`, `@Cache`, `@AcknowledgePersisted`, `@MapPersistenceErrors`, `@FromCache`), `QueryRepository`, `CommandRepository`, `MemoryCache` and its injection token `CACHE_TOKEN`, `cacheKey`, `cacheKeyTemplate`, `isCacheNewer`, `toCacheSnapshot`, the mutation-barrier helpers, `consoleCacheLogger`, `safeWarn`, and the persistence dialect contract (`IPersistenceDialect`, `setPersistenceDialect`, `persistenceDialect`) |
55
58
  | `@cqrs-ddd/core/http` | `domainErrorHttpStatus` |
@@ -338,19 +341,29 @@ const handler = new UpdateUserHandler(users, {
338
341
  await handler.execute(new UpdateUserCommand(id, 'bob'));
339
342
  ```
340
343
 
341
- - `handle()` returns the aggregate, or a result carrying it as `aggregate`.
342
- `execute()` calls it, publishes the buffered events once with
343
- `eventBus.publishAll(events)`, clears the buffer and returns the result unchanged.
344
+ - `handle()` returns the aggregate, or a result carrying it as `aggregate`; any
345
+ `IAggregateRoot` qualifies. `execute()` calls it, publishes the buffered events once
346
+ with `eventBus.publishAll(events, aggregate)` (the aggregate is the dispatcher context),
347
+ clears the buffer and returns the result unchanged.
344
348
  - A rejected `handle()` publishes nothing. If `publishAll()` throws, the error
345
349
  propagates and the events stay buffered.
350
+ - If `publishAll()` returns a promise, `execute()` waits for it after clearing the buffer.
351
+ Its rejection rejects the command, although the aggregate is already persisted; the
352
+ events are not published a second time.
346
353
  - Any object with `publishAll(events)` is an `IDomainEventPublisher`.
347
354
 
348
- **`AggregateRoot.commit()` publishes nothing by default.** It hands the buffer to the
349
- aggregate's own `publish`/`publishAll` hooks, which do nothing until a publisher is
350
- connected by overriding them, and then clears the buffer. Calling `commit()` without a
351
- connected publisher therefore drops the events; so does `autoCommit`. Let
352
- `CommandBaseHandler` publish, or read `getUncommittedEvents()` and call `uncommit()`
353
- yourself.
355
+ **`AggregateRoot.commit()` publishes nothing by default.** It hands a copy of the
356
+ buffer to the aggregate's own `publishAll` hook (`apply()` calls `publish` while
357
+ `autoCommit` is on), which does nothing until a publisher is connected, then clears the
358
+ buffer. Calling `commit()` without a connected publisher therefore drops the events; so
359
+ does `autoCommit`. Let `CommandBaseHandler` publish, or read `getUncommittedEvents()` and
360
+ call `uncommit()` yourself.
361
+
362
+ `commit(dispatcherContext?)` passes the context, such as `{ transaction }`, to
363
+ `publishAll` and returns what it returns. The buffer is cleared once `publishAll`
364
+ returns, before an asynchronous publisher settles, so `await aggregate.commit()` waits
365
+ for the publisher and receives its error without risking a second publication; if
366
+ `publishAll` throws, the events stay buffered.
354
367
 
355
368
  ## Write-side repositories
356
369
 
@@ -622,8 +635,14 @@ rest to it.
622
635
 
623
636
  Nothing in this package imports NestJS; the fit is structural.
624
637
 
625
- - The NestJS CQRS `EventBus` has `publishAll(events)`, so it is an
626
- `IDomainEventPublisher`: a handler passes its injected bus to `super(eventBus)`.
638
+ - The NestJS CQRS `EventBus` has `publishAll(events, dispatcherContext)`, so it is an
639
+ `IDomainEventPublisher`: a handler passes its injected bus to `super(eventBus)`, and
640
+ the bus hands the aggregate to its configured publisher as the dispatcher context.
641
+ - `AggregateRoot` satisfies NestJS's `IAggregateRoot`, and a NestJS `AggregateRoot`
642
+ satisfies this package's `IAggregateRoot`. `EventPublisher.mergeObjectContext(aggregate)`
643
+ connects an aggregate to the `EventBus`: `commit()` then publishes with the aggregate as
644
+ the context, `commit({ transaction })` with that context, and both return the bus's
645
+ result.
627
646
  - `CommandBaseHandler.execute(command)` is the method the NestJS command bus calls, so a
628
647
  class decorated with `@CommandHandler` extends it directly.
629
648
  - `BaseCommand`, `BaseQuery` and the domain events are plain classes that NestJS
@@ -1 +1 @@
1
- {"version":3,"file":"base.command.d.ts","sourceRoot":"","sources":["../../application/base.command.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,8BAAsB,WAAW,CAAC,iBAAiB,GAAG,GAAG;IACvD,SAAwB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAC7D,SAAwB,WAAW,CAAC,EAAE,iBAAiB,CAAC;gBAE5C,gBAAgB,CAAC,EAAE,iBAAiB;IAOhD;;;;;;;;OAQG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE;CAK9D"}
1
+ {"version":3,"file":"base.command.d.ts","sourceRoot":"","sources":["../../application/base.command.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,8BAAsB,WAAW,CAAC,iBAAiB,GAAG,GAAG;IACvD,SAAwB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAC7D,SAAwB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAExD,YAAY,gBAAgB,CAAC,EAAE,iBAAiB,EAK/C;IAED;;;;;;;;OAQG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAI5D;CACF"}
@@ -1,8 +1,5 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.BaseCommand = void 0;
5
- const request_fields_helper_1 = require("./request-fields.helper");
2
+ import { definedFields, defineHidden } from './request-fields.helper.js';
6
3
  /**
7
4
  * Base class for application CQRS commands.
8
5
  *
@@ -11,11 +8,11 @@ const request_fields_helper_1 = require("./request-fields.helper");
11
8
  * {@link getUpdateFields}.
12
9
  */
13
10
  // biome-ignore lint/suspicious/noExplicitAny: generic session principal default
14
- class BaseCommand {
11
+ export class BaseCommand {
15
12
  constructor(sessionPrincipal) {
16
13
  if (sessionPrincipal !== undefined) {
17
- (0, request_fields_helper_1.defineHidden)(this, 'sessionPrincipal', sessionPrincipal);
18
- (0, request_fields_helper_1.defineHidden)(this, 'sessionUser', sessionPrincipal);
14
+ defineHidden(this, 'sessionPrincipal', sessionPrincipal);
15
+ defineHidden(this, 'sessionUser', sessionPrincipal);
19
16
  }
20
17
  }
21
18
  /**
@@ -28,7 +25,7 @@ class BaseCommand {
28
25
  * @returns The command payload without pipeline/session metadata.
29
26
  */
30
27
  toJSON() {
31
- return (0, request_fields_helper_1.definedFields)(this);
28
+ return definedFields(this);
32
29
  }
33
30
  /**
34
31
  * Returns the declared updatable fields that are actually present on this command.
@@ -54,5 +51,4 @@ class BaseCommand {
54
51
  return updatableFields.filter((field) => this[field] !== undefined);
55
52
  }
56
53
  }
57
- exports.BaseCommand = BaseCommand;
58
54
  //# sourceMappingURL=base.command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.command.js","sourceRoot":"","sources":["../../application/base.command.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,mEAAsE;AAEtE;;;;;;GAMG;AACH,gFAAgF;AAChF,MAAsB,WAAW;IAI/B,YAAY,gBAAoC;QAC9C,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,IAAA,oCAAY,EAAC,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;YACzD,IAAA,oCAAY,EAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM;QACJ,OAAO,IAAA,qCAAa,EAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,eAAkC;QAChD,OAAO,eAAe,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAE,IAAgC,CAAC,KAAK,CAAC,KAAK,SAAS,CAClE,CAAC;IACJ,CAAC;CACF;AAjDD,kCAiDC"}
1
+ {"version":3,"file":"base.command.js","sourceRoot":"","sources":["../../application/base.command.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEzE;;;;;;GAMG;AACH,gFAAgF;AAChF,MAAM,OAAgB,WAAW;IAI/B,YAAY,gBAAoC;QAC9C,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;YACzD,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM;QACJ,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,eAAkC;QAChD,OAAO,eAAe,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAE,IAAgC,CAAC,KAAK,CAAC,KAAK,SAAS,CAClE,CAAC;IACJ,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import type { IQueryOptions } from './query.options';
1
+ import type { IQueryOptions } from './query.options.js';
2
2
  /**
3
3
  * Base class for application CQRS queries.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"base.query.d.ts","sourceRoot":"","sources":["../../application/base.query.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,SAAS,CAAC,iBAAiB,GAAG,OAAO,CACzD,YAAW,aAAa;IAExB,SAAwB,OAAO,CAAC,EAAE,OAAO,CAAC;IAC1C,SAAwB,OAAO,CAAC,EAAE,OAAO,CAAC;IAC1C,SAAwB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAC7D,SAAwB,WAAW,CAAC,EAAE,iBAAiB,CAAC;gBAGtD,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,EAChC,gBAAgB,CAAC,EAAE,iBAAiB;IAUtC;;;;;;;OAOG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGlC"}
1
+ {"version":3,"file":"base.query.d.ts","sourceRoot":"","sources":["../../application/base.query.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,SAAS,CAAC,iBAAiB,GAAG,OAAO,CACzD,YAAW,aAAa;IAExB,SAAwB,OAAO,CAAC,EAAE,OAAO,CAAC;IAC1C,SAAwB,OAAO,CAAC,EAAE,OAAO,CAAC;IAC1C,SAAwB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IAC7D,SAAwB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAExD,YACE,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,EAChC,gBAAgB,CAAC,EAAE,iBAAiB,EAQrC;IAED;;;;;;;OAOG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhC;CACF"}
@@ -1,8 +1,5 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.BaseQuery = void 0;
5
- const request_fields_helper_1 = require("./request-fields.helper");
2
+ import { definedFields, defineHidden } from './request-fields.helper.js';
6
3
  /**
7
4
  * Base class for application CQRS queries.
8
5
  *
@@ -27,13 +24,13 @@ const request_fields_helper_1 = require("./request-fields.helper");
27
24
  * const query = new GetUserQuery(userId, { hydrate: true }, sessionUser);
28
25
  * ```
29
26
  */
30
- class BaseQuery {
27
+ export class BaseQuery {
31
28
  constructor(options, sessionPrincipal) {
32
- (0, request_fields_helper_1.defineHidden)(this, 'hydrate', options?.hydrate ?? false);
33
- (0, request_fields_helper_1.defineHidden)(this, 'refresh', options?.refresh ?? false);
29
+ defineHidden(this, 'hydrate', options?.hydrate ?? false);
30
+ defineHidden(this, 'refresh', options?.refresh ?? false);
34
31
  if (sessionPrincipal !== undefined) {
35
- (0, request_fields_helper_1.defineHidden)(this, 'sessionPrincipal', sessionPrincipal);
36
- (0, request_fields_helper_1.defineHidden)(this, 'sessionUser', sessionPrincipal);
32
+ defineHidden(this, 'sessionPrincipal', sessionPrincipal);
33
+ defineHidden(this, 'sessionUser', sessionPrincipal);
37
34
  }
38
35
  }
39
36
  /**
@@ -45,8 +42,7 @@ class BaseQuery {
45
42
  * @returns The query payload with `undefined` fields omitted.
46
43
  */
47
44
  toJSON() {
48
- return (0, request_fields_helper_1.definedFields)(this);
45
+ return definedFields(this);
49
46
  }
50
47
  }
51
- exports.BaseQuery = BaseQuery;
52
48
  //# sourceMappingURL=base.query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.query.js","sourceRoot":"","sources":["../../application/base.query.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAGtE,mEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAsB,SAAS;IAQ7B,YACE,OAAgC,EAChC,gBAAoC;QAEpC,IAAA,oCAAY,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;QACzD,IAAA,oCAAY,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;QACzD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,IAAA,oCAAY,EAAC,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;YACzD,IAAA,oCAAY,EAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM;QACJ,OAAO,IAAA,qCAAa,EAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AA/BD,8BA+BC"}
1
+ {"version":3,"file":"base.query.js","sourceRoot":"","sources":["../../application/base.query.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAgB,SAAS;IAQ7B,YACE,OAAgC,EAChC,gBAAoC;QAEpC,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;QACzD,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;QACzD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;YACzD,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM;QACJ,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -1,20 +1,21 @@
1
- import { AggregateRoot } from '../domain/models/aggregate-root';
2
- import type { IDomainEventPublisher } from './ports/domain-event-publisher.port';
1
+ import type { IAggregateRoot } from '../domain/interfaces/aggregate-root.interface.js';
2
+ import type { IDomainEventPublisher } from './ports/domain-event-publisher.port.js';
3
3
  /**
4
4
  * Result shapes that allow `CommandBaseHandler` to publish buffered aggregate events.
5
5
  * Return either the aggregate itself or an application result with an `aggregate` field.
6
6
  */
7
- export type AggregateBearingResult = AggregateRoot | {
8
- readonly aggregate: AggregateRoot;
7
+ export type AggregateBearingResult = IAggregateRoot | {
8
+ readonly aggregate: IAggregateRoot;
9
9
  };
10
10
  /**
11
11
  * Base class for all CQRS command handlers.
12
12
  *
13
13
  * Wraps every concrete command handler with shared lifecycle behavior:
14
14
  * 1. Executes command logic via the abstract {@link handle} method.
15
- * 2. If the result is an {@link AggregateRoot} (or an object containing `aggregate: AggregateRoot`),
16
- * its buffered uncommitted domain events are automatically published through the
17
- * {@link IDomainEventPublisher} and cleared after publication.
15
+ * 2. If the result is an aggregate root ({@link IAggregateRoot}, such as an
16
+ * {@link AggregateRoot}) or an object containing one as `aggregate`, its buffered
17
+ * uncommitted domain events are published through the {@link IDomainEventPublisher},
18
+ * with the aggregate as the dispatcher context, and cleared after publication.
18
19
  *
19
20
  * It is framework-neutral. With NestJS CQRS, decorate the subclass with
20
21
  * `@CommandHandler` and pass the injected `EventBus`, which satisfies
@@ -93,13 +94,22 @@ export declare abstract class CommandBaseHandler<TCommand = unknown, TResult ext
93
94
  * `CommandBus`).
94
95
  *
95
96
  * Delegates to {@link handle} and automatically publishes any uncommitted domain
96
- * events if the result is an {@link AggregateRoot} (or an object containing `aggregate: AggregateRoot`).
97
+ * events if the result is an aggregate root (or an object containing one as
98
+ * `aggregate`). The publisher receives the aggregate as its dispatcher context,
99
+ * as NestJS's `EventPublisher` passes it on `commit()`.
100
+ *
101
+ * The events are handed to the publisher and cleared from the aggregate, then
102
+ * `execute()` awaits what `publishAll()` returned: an asynchronous publisher
103
+ * delays the result, and its rejection rejects the command, although the
104
+ * aggregate is already persisted. A publisher that throws synchronously leaves
105
+ * the events buffered.
97
106
  *
98
107
  * Persistence and in-memory event publication are not atomic. A crash after
99
108
  * persistence can lose events; durable delivery requires an explicit outbox.
100
109
  *
101
110
  * @param command - The command dispatched through the command bus.
102
111
  * @returns The result produced by {@link handle}.
112
+ * @throws The error of {@link handle}, or of a publisher that throws or rejects.
103
113
  */
104
114
  execute(command: TCommand): Promise<TResult>;
105
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command-base.handler.d.ts","sourceRoot":"","sources":["../../application/command-base.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,aAAa,GACb;IAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;CAAE,CAAC;AAY1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,8BAAsB,kBAAkB,CACtC,QAAQ,GAAG,OAAO,EAClB,OAAO,SAAS,sBAAsB,GAAG,sBAAsB;IAQzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB;IANxE;;;;;OAKG;IACH,SAAS,aAAgC,QAAQ,EAAE,qBAAqB;IAExE;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAEpD;;;;;;;;;;;;OAYG;IACG,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;CAsBnD"}
1
+ {"version":3,"file":"command-base.handler.d.ts","sourceRoot":"","sources":["../../application/command-base.handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAEvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAEpF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd;IAAE,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;CAAE,CAAC;AAY3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,8BAAsB,kBAAkB,CACtC,QAAQ,GAAG,OAAO,EAClB,OAAO,SAAS,sBAAsB,GAAG,sBAAsB;IAQzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB;IANxE;;;;;OAKG;IACH,SAAS,aAAgC,QAAQ,EAAE,qBAAqB,EAAI;IAE5E;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBjD;CACF"}
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CommandBaseHandler = void 0;
5
- const aggregate_root_1 = require("../domain/models/aggregate-root");
2
+ import { AggregateRoot } from '../domain/models/aggregate-root.js';
6
3
  function isAggregate(obj) {
7
- return (obj instanceof aggregate_root_1.AggregateRoot ||
4
+ return (obj instanceof AggregateRoot ||
8
5
  (typeof obj === 'object' &&
9
6
  obj !== null &&
10
7
  typeof obj.getUncommittedEvents === 'function' &&
@@ -15,9 +12,10 @@ function isAggregate(obj) {
15
12
  *
16
13
  * Wraps every concrete command handler with shared lifecycle behavior:
17
14
  * 1. Executes command logic via the abstract {@link handle} method.
18
- * 2. If the result is an {@link AggregateRoot} (or an object containing `aggregate: AggregateRoot`),
19
- * its buffered uncommitted domain events are automatically published through the
20
- * {@link IDomainEventPublisher} and cleared after publication.
15
+ * 2. If the result is an aggregate root ({@link IAggregateRoot}, such as an
16
+ * {@link AggregateRoot}) or an object containing one as `aggregate`, its buffered
17
+ * uncommitted domain events are published through the {@link IDomainEventPublisher},
18
+ * with the aggregate as the dispatcher context, and cleared after publication.
21
19
  *
22
20
  * It is framework-neutral. With NestJS CQRS, decorate the subclass with
23
21
  * `@CommandHandler` and pass the injected `EventBus`, which satisfies
@@ -71,7 +69,7 @@ function isAggregate(obj) {
71
69
  * }
72
70
  * ```
73
71
  */
74
- class CommandBaseHandler {
72
+ export class CommandBaseHandler {
75
73
  eventBus;
76
74
  /**
77
75
  * Constructs the handler with the publisher of domain events.
@@ -87,13 +85,22 @@ class CommandBaseHandler {
87
85
  * `CommandBus`).
88
86
  *
89
87
  * Delegates to {@link handle} and automatically publishes any uncommitted domain
90
- * events if the result is an {@link AggregateRoot} (or an object containing `aggregate: AggregateRoot`).
88
+ * events if the result is an aggregate root (or an object containing one as
89
+ * `aggregate`). The publisher receives the aggregate as its dispatcher context,
90
+ * as NestJS's `EventPublisher` passes it on `commit()`.
91
+ *
92
+ * The events are handed to the publisher and cleared from the aggregate, then
93
+ * `execute()` awaits what `publishAll()` returned: an asynchronous publisher
94
+ * delays the result, and its rejection rejects the command, although the
95
+ * aggregate is already persisted. A publisher that throws synchronously leaves
96
+ * the events buffered.
91
97
  *
92
98
  * Persistence and in-memory event publication are not atomic. A crash after
93
99
  * persistence can lose events; durable delivery requires an explicit outbox.
94
100
  *
95
101
  * @param command - The command dispatched through the command bus.
96
102
  * @returns The result produced by {@link handle}.
103
+ * @throws The error of {@link handle}, or of a publisher that throws or rejects.
97
104
  */
98
105
  async execute(command) {
99
106
  const commandResult = await this.handle(command);
@@ -108,12 +115,12 @@ class CommandBaseHandler {
108
115
  if (aggregate) {
109
116
  const events = [...aggregate.getUncommittedEvents()];
110
117
  if (events.length > 0) {
111
- this.eventBus.publishAll(events);
118
+ const published = this.eventBus.publishAll(events, aggregate);
112
119
  aggregate.uncommit();
120
+ await published;
113
121
  }
114
122
  }
115
123
  return commandResult;
116
124
  }
117
125
  }
118
- exports.CommandBaseHandler = CommandBaseHandler;
119
126
  //# sourceMappingURL=command-base.handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-base.handler.js","sourceRoot":"","sources":["../../application/command-base.handler.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,oEAAgE;AAWhE,SAAS,WAAW,CAAC,GAAY;IAC/B,OAAO,CACL,GAAG,YAAY,8BAAa;QAC5B,CAAC,OAAO,GAAG,KAAK,QAAQ;YACtB,GAAG,KAAK,IAAI;YACZ,OAAQ,GAAqB,CAAC,oBAAoB,KAAK,UAAU;YACjE,OAAQ,GAAqB,CAAC,QAAQ,KAAK,UAAU,CAAC,CACzD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAsB,kBAAkB;IAUG;IANzC;;;;;OAKG;IACH,YAAyC,QAA+B;QAA/B,aAAQ,GAAR,QAAQ,CAAuB;IAAG,CAAC;IAc5E;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,OAAO,CAAC,OAAiB;QAC7B,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEjD,MAAM,SAAS,GAAG,WAAW,CAAC,aAAa,CAAC;YAC1C,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,aAAa;gBACX,OAAO,aAAa,KAAK,QAAQ;gBACjC,WAAW,IAAI,aAAa;gBAC5B,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC;gBACtC,CAAC,CAAC,aAAa,CAAC,SAAS;gBACzB,CAAC,CAAC,SAAS,CAAC;QAEhB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,CAAC;YACrD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACjC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA3DD,gDA2DC"}
1
+ {"version":3,"file":"command-base.handler.js","sourceRoot":"","sources":["../../application/command-base.handler.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAWnE,SAAS,WAAW,CAAC,GAAY;IAC/B,OAAO,CACL,GAAG,YAAY,aAAa;QAC5B,CAAC,OAAO,GAAG,KAAK,QAAQ;YACtB,GAAG,KAAK,IAAI;YACZ,OAAQ,GAAsB,CAAC,oBAAoB,KAAK,UAAU;YAClE,OAAQ,GAAsB,CAAC,QAAQ,KAAK,UAAU,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,OAAgB,kBAAkB;IAUG,QAAQ;IANjD;;;;;OAKG;IACH,YAAyC,QAA+B;wBAA/B,QAAQ;IAA0B,CAAC;IAc5E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,OAAO,CAAC,OAAiB;QAC7B,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEjD,MAAM,SAAS,GAAG,WAAW,CAAC,aAAa,CAAC;YAC1C,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,aAAa;gBACX,OAAO,aAAa,KAAK,QAAQ;gBACjC,WAAW,IAAI,aAAa;gBAC5B,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC;gBACtC,CAAC,CAAC,aAAa,CAAC,SAAS;gBACzB,CAAC,CAAC,SAAS,CAAC;QAEhB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,CAAC;YACrD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAC9D,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACrB,MAAM,SAAS,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
@@ -3,14 +3,14 @@
3
3
  * `ports/`, are the contracts a CQRS handler depends on; their adapters stay
4
4
  * behind `@cqrs-ddd/core/persistence` or in an adapter package.
5
5
  */
6
- export * from './base.command';
7
- export * from './base.query';
8
- export * from './command-base.handler';
9
- export * from './ports/cache.port';
10
- export * from './ports/command-repository.port';
11
- export * from './ports/domain-event-publisher.port';
12
- export * from './ports/query-repository.port';
13
- export * from './ports/write-side-aggregate-repository.port';
14
- export * from './query.options';
15
- export * from './tenant-resolver';
6
+ export * from './base.command.js';
7
+ export * from './base.query.js';
8
+ export * from './command-base.handler.js';
9
+ export * from './ports/cache.port.js';
10
+ export * from './ports/command-repository.port.js';
11
+ export * from './ports/domain-event-publisher.port.js';
12
+ export * from './ports/query-repository.port.js';
13
+ export * from './ports/write-side-aggregate-repository.port.js';
14
+ export * from './query.options.js';
15
+ export * from './tenant-resolver.js';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../application/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8CAA8C,CAAC;AAC7D,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../application/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iDAAiD,CAAC;AAChE,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
@@ -1,33 +1,17 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
2
  /**
19
3
  * Application-layer primitives and the ports handlers depend on. The ports, in
20
4
  * `ports/`, are the contracts a CQRS handler depends on; their adapters stay
21
5
  * behind `@cqrs-ddd/core/persistence` or in an adapter package.
22
6
  */
23
- __exportStar(require("./base.command"), exports);
24
- __exportStar(require("./base.query"), exports);
25
- __exportStar(require("./command-base.handler"), exports);
26
- __exportStar(require("./ports/cache.port"), exports);
27
- __exportStar(require("./ports/command-repository.port"), exports);
28
- __exportStar(require("./ports/domain-event-publisher.port"), exports);
29
- __exportStar(require("./ports/query-repository.port"), exports);
30
- __exportStar(require("./ports/write-side-aggregate-repository.port"), exports);
31
- __exportStar(require("./query.options"), exports);
32
- __exportStar(require("./tenant-resolver"), exports);
7
+ export * from './base.command.js';
8
+ export * from './base.query.js';
9
+ export * from './command-base.handler.js';
10
+ export * from './ports/cache.port.js';
11
+ export * from './ports/command-repository.port.js';
12
+ export * from './ports/domain-event-publisher.port.js';
13
+ export * from './ports/query-repository.port.js';
14
+ export * from './ports/write-side-aggregate-repository.port.js';
15
+ export * from './query.options.js';
16
+ export * from './tenant-resolver.js';
33
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../application/index.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;;;;;;;;;;;;;;AAEtE;;;;GAIG;AAEH,iDAA+B;AAC/B,+CAA6B;AAC7B,yDAAuC;AACvC,qDAAmC;AACnC,kEAAgD;AAChD,sEAAoD;AACpD,gEAA8C;AAC9C,+EAA6D;AAC7D,kDAAgC;AAChC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../application/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE;;;;GAIG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iDAAiD,CAAC;AAChE,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isVersionedCache = isVersionedCache;
5
2
  /**
6
3
  * Capability guard verifying whether an adapter supports versioned coordination.
7
4
  */
8
- function isVersionedCache(cache) {
5
+ export function isVersionedCache(cache) {
9
6
  return (typeof cache === 'object' &&
10
7
  cache !== null &&
11
8
  (('isVersioned' in cache &&
@@ -1 +1 @@
1
- {"version":3,"file":"cache.port.js","sourceRoot":"","sources":["../../../application/ports/cache.port.ts"],"names":[],"mappings":";AAAA,sEAAsE;;AA2HtE,4CAYC;AAfD;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,CAAC,aAAa,IAAI,KAAK;YACrB,KAA4B,CAAC,WAAW,KAAK,IAAI,CAAC;YACnD,CAAC,OAAQ,KAA4B,CAAC,SAAS,KAAK,UAAU;gBAC5D,OAAQ,KAA4B,CAAC,UAAU,KAAK,UAAU;gBAC9D,OAAQ,KAA4B,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAClE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"cache.port.js","sourceRoot":"","sources":["../../../application/ports/cache.port.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAwHtE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,CAAC,aAAa,IAAI,KAAK;YACrB,KAA4B,CAAC,WAAW,KAAK,IAAI,CAAC;YACnD,CAAC,OAAQ,KAA4B,CAAC,SAAS,KAAK,UAAU;gBAC5D,OAAQ,KAA4B,CAAC,UAAU,KAAK,UAAU;gBAC9D,OAAQ,KAA4B,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAClE,CAAC;AACJ,CAAC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=command-repository.port.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-repository.port.js","sourceRoot":"","sources":["../../../application/ports/command-repository.port.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"command-repository.port.js","sourceRoot":"","sources":["../../../application/ports/command-repository.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,9 +1,11 @@
1
- import type { IEvent } from '../../domain/events/event.interface';
1
+ import type { IEvent } from '../../domain/events/event.interface.js';
2
2
  /**
3
3
  * Publishes the buffered domain events of an aggregate after a command succeeds.
4
4
  *
5
5
  * Any bus with a `publishAll(events)` method fits, including the NestJS CQRS
6
6
  * `EventBus`, so a Nest handler passes its injected `EventBus` unchanged.
7
+ * `CommandBaseHandler` passes the aggregate as `dispatcherContext`, which the
8
+ * NestJS `EventBus` hands to its configured publisher.
7
9
  *
8
10
  * @example
9
11
  * ```ts
@@ -13,6 +15,6 @@ import type { IEvent } from '../../domain/events/event.interface';
13
15
  * ```
14
16
  */
15
17
  export interface IDomainEventPublisher {
16
- publishAll(events: IEvent[]): unknown;
18
+ publishAll(events: IEvent[], dispatcherContext?: unknown): unknown;
17
19
  }
18
20
  //# sourceMappingURL=domain-event-publisher.port.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-event-publisher.port.d.ts","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;CACvC"}
1
+ {"version":3,"file":"domain-event-publisher.port.d.ts","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CACpE"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=domain-event-publisher.port.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-event-publisher.port.js","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"domain-event-publisher.port.js","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,4 @@
1
- import { IQueryOptions } from '../query.options';
1
+ import { IQueryOptions } from '../query.options.js';
2
2
  /**
3
3
  * Application-facing read repository contract.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"query-repository.port.d.ts","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,GAAG,aAAa,EAAE,OAAO,GAAG,OAAO;IACzE,sCAAsC;IACtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC"}
1
+ {"version":3,"file":"query-repository.port.d.ts","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,GAAG,aAAa,EAAE,OAAO,GAAG,OAAO;IACzE,sCAAsC;IACtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=query-repository.port.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-repository.port.js","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"query-repository.port.js","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,4 @@
1
- import type { ICommandRepository } from './command-repository.port';
1
+ import type { ICommandRepository } from './command-repository.port.js';
2
2
  /**
3
3
  * Write-side repository contract for commands that mutate an existing aggregate.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"write-side-aggregate-repository.port.d.ts","sourceRoot":"","sources":["../../../application/ports/write-side-aggregate-repository.port.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,6BAA6B,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAClE,SAAQ,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC5C"}
1
+ {"version":3,"file":"write-side-aggregate-repository.port.d.ts","sourceRoot":"","sources":["../../../application/ports/write-side-aggregate-repository.port.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,6BAA6B,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAClE,SAAQ,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC5C"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=write-side-aggregate-repository.port.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"write-side-aggregate-repository.port.js","sourceRoot":"","sources":["../../../application/ports/write-side-aggregate-repository.port.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"write-side-aggregate-repository.port.js","sourceRoot":"","sources":["../../../application/ports/write-side-aggregate-repository.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
4
3
  //# sourceMappingURL=query.options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.options.js","sourceRoot":"","sources":["../../application/query.options.ts"],"names":[],"mappings":";AAAA,sEAAsE"}
1
+ {"version":3,"file":"query.options.js","sourceRoot":"","sources":["../../application/query.options.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
@@ -1,14 +1,10 @@
1
- "use strict";
2
1
  /* Copyright (C) 2026-present Aristotelis — see repository license. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.defineHidden = defineHidden;
5
- exports.definedFields = definedFields;
6
2
  /** Defines a non-enumerable property, excluded from `toJSON()` and payload spreads. */
7
- function defineHidden(target, key, value) {
3
+ export function defineHidden(target, key, value) {
8
4
  Object.defineProperty(target, key, { value, enumerable: false });
9
5
  }
10
6
  /** Returns the enumerable own fields of a request whose value is not `undefined`. */
11
- function definedFields(request) {
7
+ export function definedFields(request) {
12
8
  const json = {};
13
9
  for (const [key, value] of Object.entries(request)) {
14
10
  if (value !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"request-fields.helper.js","sourceRoot":"","sources":["../../application/request-fields.helper.ts"],"names":[],"mappings":";AAAA,sEAAsE;;AAGtE,oCAMC;AAGD,sCAQC;AAlBD,uFAAuF;AACvF,SAAgB,YAAY,CAC1B,MAAc,EACd,GAAW,EACX,KAAc;IAEd,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,qFAAqF;AACrF,SAAgB,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"request-fields.helper.js","sourceRoot":"","sources":["../../application/request-fields.helper.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,uFAAuF;AACvF,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,GAAW,EACX,KAAc;IAEd,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}