@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.
- package/README.md +32 -13
- package/dist/application/base.command.d.ts.map +1 -1
- package/dist/application/base.command.js +5 -9
- package/dist/application/base.command.js.map +1 -1
- package/dist/application/base.query.d.ts +1 -1
- package/dist/application/base.query.d.ts.map +1 -1
- package/dist/application/base.query.js +7 -11
- package/dist/application/base.query.js.map +1 -1
- package/dist/application/command-base.handler.d.ts +18 -8
- package/dist/application/command-base.handler.d.ts.map +1 -1
- package/dist/application/command-base.handler.js +19 -12
- package/dist/application/command-base.handler.js.map +1 -1
- package/dist/application/index.d.ts +10 -10
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +10 -26
- package/dist/application/index.js.map +1 -1
- package/dist/application/ports/cache.port.js +1 -4
- package/dist/application/ports/cache.port.js.map +1 -1
- package/dist/application/ports/command-repository.port.js +1 -2
- package/dist/application/ports/command-repository.port.js.map +1 -1
- package/dist/application/ports/domain-event-publisher.port.d.ts +4 -2
- package/dist/application/ports/domain-event-publisher.port.d.ts.map +1 -1
- package/dist/application/ports/domain-event-publisher.port.js +1 -2
- package/dist/application/ports/domain-event-publisher.port.js.map +1 -1
- package/dist/application/ports/query-repository.port.d.ts +1 -1
- package/dist/application/ports/query-repository.port.d.ts.map +1 -1
- package/dist/application/ports/query-repository.port.js +1 -2
- package/dist/application/ports/query-repository.port.js.map +1 -1
- package/dist/application/ports/write-side-aggregate-repository.port.d.ts +1 -1
- package/dist/application/ports/write-side-aggregate-repository.port.d.ts.map +1 -1
- package/dist/application/ports/write-side-aggregate-repository.port.js +1 -2
- package/dist/application/ports/write-side-aggregate-repository.port.js.map +1 -1
- package/dist/application/query.options.js +1 -2
- package/dist/application/query.options.js.map +1 -1
- package/dist/application/request-fields.helper.js +2 -6
- package/dist/application/request-fields.helper.js.map +1 -1
- package/dist/application/tenant-resolver.js +5 -10
- package/dist/application/tenant-resolver.js.map +1 -1
- package/dist/domain/decorators/apply-mutation.decorator.d.ts +1 -1
- package/dist/domain/decorators/apply-mutation.decorator.d.ts.map +1 -1
- package/dist/domain/decorators/apply-mutation.decorator.js +1 -4
- package/dist/domain/decorators/apply-mutation.decorator.js.map +1 -1
- package/dist/domain/decorators/mutable.decorator.js +2 -6
- package/dist/domain/decorators/mutable.decorator.js.map +1 -1
- package/dist/domain/events/domain.event.d.ts +1 -1
- package/dist/domain/events/domain.event.d.ts.map +1 -1
- package/dist/domain/events/domain.event.js +3 -7
- package/dist/domain/events/domain.event.js.map +1 -1
- package/dist/domain/events/event.interface.js +1 -2
- package/dist/domain/events/event.interface.js.map +1 -1
- package/dist/domain/events/root-domain.event.d.ts +3 -3
- package/dist/domain/events/root-domain.event.d.ts.map +1 -1
- package/dist/domain/events/root-domain.event.js +3 -8
- package/dist/domain/events/root-domain.event.js.map +1 -1
- package/dist/domain/exceptions/concurrency-conflict.error.d.ts +1 -1
- package/dist/domain/exceptions/concurrency-conflict.error.d.ts.map +1 -1
- package/dist/domain/exceptions/concurrency-conflict.error.js +2 -6
- package/dist/domain/exceptions/concurrency-conflict.error.js.map +1 -1
- package/dist/domain/exceptions/domain.exception.d.ts.map +1 -1
- package/dist/domain/exceptions/domain.exception.js +1 -5
- package/dist/domain/exceptions/domain.exception.js.map +1 -1
- package/dist/domain/exceptions/entity-not-found.exception.d.ts +1 -1
- package/dist/domain/exceptions/entity-not-found.exception.d.ts.map +1 -1
- package/dist/domain/exceptions/entity-not-found.exception.js +2 -6
- package/dist/domain/exceptions/entity-not-found.exception.js.map +1 -1
- package/dist/domain/exceptions/invalid-value.exception.d.ts +2 -2
- package/dist/domain/exceptions/invalid-value.exception.d.ts.map +1 -1
- package/dist/domain/exceptions/invalid-value.exception.js +2 -6
- package/dist/domain/exceptions/invalid-value.exception.js.map +1 -1
- package/dist/domain/exceptions/missing-tenant-context.exception.d.ts +1 -1
- package/dist/domain/exceptions/missing-tenant-context.exception.d.ts.map +1 -1
- package/dist/domain/exceptions/missing-tenant-context.exception.js +2 -6
- package/dist/domain/exceptions/missing-tenant-context.exception.js.map +1 -1
- package/dist/domain/exceptions/transient-operation.error.d.ts.map +1 -1
- package/dist/domain/exceptions/transient-operation.error.js +2 -7
- package/dist/domain/exceptions/transient-operation.error.js.map +1 -1
- package/dist/domain/exceptions/unknown-mutable-field.error.d.ts.map +1 -1
- package/dist/domain/exceptions/unknown-mutable-field.error.js +1 -5
- package/dist/domain/exceptions/unknown-mutable-field.error.js.map +1 -1
- package/dist/domain/index.d.ts +19 -18
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +19 -34
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/interfaces/aggregate-root.interface.d.ts +41 -0
- package/dist/domain/interfaces/aggregate-root.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/aggregate-root.interface.js +3 -0
- package/dist/domain/interfaces/aggregate-root.interface.js.map +1 -0
- package/dist/domain/interfaces/root-entity-snapshot.interface.js +1 -2
- package/dist/domain/interfaces/root-entity-snapshot.interface.js.map +1 -1
- package/dist/domain/models/aggregate-root.d.ts +34 -22
- package/dist/domain/models/aggregate-root.d.ts.map +1 -1
- package/dist/domain/models/aggregate-root.js +38 -12
- package/dist/domain/models/aggregate-root.js.map +1 -1
- package/dist/domain/models/root.entity.d.ts +3 -3
- package/dist/domain/models/root.entity.d.ts.map +1 -1
- package/dist/domain/models/root.entity.js +9 -13
- package/dist/domain/models/root.entity.js.map +1 -1
- package/dist/domain/rules/number.rule.d.ts +1 -1
- package/dist/domain/rules/number.rule.d.ts.map +1 -1
- package/dist/domain/rules/number.rule.js +4 -7
- package/dist/domain/rules/number.rule.js.map +1 -1
- package/dist/domain/rules/rule-support.d.ts +1 -1
- package/dist/domain/rules/rule-support.d.ts.map +1 -1
- package/dist/domain/rules/rule-support.js +3 -7
- package/dist/domain/rules/rule-support.js.map +1 -1
- package/dist/domain/rules/text.rule.d.ts +1 -1
- package/dist/domain/rules/text.rule.d.ts.map +1 -1
- package/dist/domain/rules/text.rule.js +4 -7
- package/dist/domain/rules/text.rule.js.map +1 -1
- package/dist/domain/rules/value-violation.js +1 -2
- package/dist/domain/rules/value-violation.js.map +1 -1
- package/dist/http/domain-error-http-status.d.ts +1 -1
- package/dist/http/domain-error-http-status.d.ts.map +1 -1
- package/dist/http/domain-error-http-status.js +9 -12
- package/dist/http/domain-error-http-status.js.map +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +1 -17
- package/dist/http/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -21
- package/dist/index.js.map +1 -1
- package/dist/persistence/cache/cache-logger.js +2 -6
- package/dist/persistence/cache/cache-logger.js.map +1 -1
- package/dist/persistence/cache/memory.cache.d.ts +1 -1
- package/dist/persistence/cache/memory.cache.d.ts.map +1 -1
- package/dist/persistence/cache/memory.cache.js +4 -8
- package/dist/persistence/cache/memory.cache.js.map +1 -1
- package/dist/persistence/command-repository.abstract.d.ts +2 -2
- package/dist/persistence/command-repository.abstract.d.ts.map +1 -1
- package/dist/persistence/command-repository.abstract.js +1 -5
- package/dist/persistence/command-repository.abstract.js.map +1 -1
- package/dist/persistence/decorators/acknowledge-persisted.decorator.d.ts.map +1 -1
- package/dist/persistence/decorators/acknowledge-persisted.decorator.js +1 -4
- package/dist/persistence/decorators/acknowledge-persisted.decorator.js.map +1 -1
- package/dist/persistence/decorators/cache.decorator.d.ts +1 -1
- package/dist/persistence/decorators/cache.decorator.d.ts.map +1 -1
- package/dist/persistence/decorators/cache.decorator.js +22 -26
- package/dist/persistence/decorators/cache.decorator.js.map +1 -1
- package/dist/persistence/decorators/from-cache.decorator.d.ts +3 -3
- package/dist/persistence/decorators/from-cache.decorator.d.ts.map +1 -1
- package/dist/persistence/decorators/from-cache.decorator.js +16 -20
- package/dist/persistence/decorators/from-cache.decorator.js.map +1 -1
- package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts +1 -1
- package/dist/persistence/decorators/map-persistence-errors.decorator.d.ts.map +1 -1
- package/dist/persistence/decorators/map-persistence-errors.decorator.js +3 -6
- package/dist/persistence/decorators/map-persistence-errors.decorator.js.map +1 -1
- package/dist/persistence/decorators/persisted-write.decorator.d.ts +4 -4
- package/dist/persistence/decorators/persisted-write.decorator.d.ts.map +1 -1
- package/dist/persistence/decorators/persisted-write.decorator.js +7 -10
- package/dist/persistence/decorators/persisted-write.decorator.js.map +1 -1
- package/dist/persistence/helpers/cache-barrier.helper.js +4 -8
- package/dist/persistence/helpers/cache-barrier.helper.js.map +1 -1
- package/dist/persistence/helpers/cache-key.helper.d.ts +1 -1
- package/dist/persistence/helpers/cache-key.helper.d.ts.map +1 -1
- package/dist/persistence/helpers/cache-key.helper.js +11 -15
- package/dist/persistence/helpers/cache-key.helper.js.map +1 -1
- package/dist/persistence/helpers/cache-owner.helper.d.ts +1 -1
- package/dist/persistence/helpers/cache-owner.helper.d.ts.map +1 -1
- package/dist/persistence/helpers/cache-owner.helper.js +4 -7
- package/dist/persistence/helpers/cache-owner.helper.js.map +1 -1
- package/dist/persistence/helpers/cache-snapshot.helper.js +1 -4
- package/dist/persistence/helpers/cache-snapshot.helper.js.map +1 -1
- package/dist/persistence/helpers/cache-version.helper.js +5 -8
- package/dist/persistence/helpers/cache-version.helper.js.map +1 -1
- package/dist/persistence/index.d.ts +14 -14
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +14 -30
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/persistence-dialect.js +2 -6
- package/dist/persistence/persistence-dialect.js.map +1 -1
- package/dist/persistence/query-repository.abstract.d.ts +3 -3
- package/dist/persistence/query-repository.abstract.d.ts.map +1 -1
- package/dist/persistence/query-repository.abstract.js +1 -5
- package/dist/persistence/query-repository.abstract.js.map +1 -1
- package/dist/types/Method.type.js +1 -2
- package/dist/types/Method.type.js.map +1 -1
- 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
|
|
343
|
-
`eventBus.publishAll(events)
|
|
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
|
|
349
|
-
aggregate's own `
|
|
350
|
-
|
|
351
|
-
connected publisher therefore drops the events; so
|
|
352
|
-
`CommandBaseHandler` publish, or read `getUncommittedEvents()` and
|
|
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;
|
|
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
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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
|
|
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":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.query.d.ts","sourceRoot":"","sources":["../../application/base.query.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
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
|
-
|
|
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
|
-
|
|
33
|
-
|
|
29
|
+
defineHidden(this, 'hydrate', options?.hydrate ?? false);
|
|
30
|
+
defineHidden(this, 'refresh', options?.refresh ?? false);
|
|
34
31
|
if (sessionPrincipal !== undefined) {
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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":"
|
|
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 {
|
|
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 =
|
|
8
|
-
readonly aggregate:
|
|
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
|
|
16
|
-
*
|
|
17
|
-
* {@link IDomainEventPublisher}
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
|
19
|
-
*
|
|
20
|
-
* {@link IDomainEventPublisher}
|
|
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
|
|
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":"
|
|
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,
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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":"
|
|
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":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-repository.port.js","sourceRoot":"","sources":["../../../application/ports/command-repository.port.ts"],"names":[],"mappings":"
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-event-publisher.port.js","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"domain-event-publisher.port.js","sourceRoot":"","sources":["../../../application/ports/domain-event-publisher.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
|
|
@@ -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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-repository.port.js","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-repository.port.js","sourceRoot":"","sources":["../../../application/ports/query-repository.port.ts"],"names":[],"mappings":"AAAA,sEAAsE"}
|
|
@@ -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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-side-aggregate-repository.port.js","sourceRoot":"","sources":["../../../application/ports/write-side-aggregate-repository.port.ts"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.options.js","sourceRoot":"","sources":["../../application/query.options.ts"],"names":[],"mappings":"
|
|
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":"
|
|
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"}
|