@nestjs/cqrs 11.0.3 → 12.1.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/.circleci/config.yml +3 -3
- package/.nvmrc +1 -0
- package/dist/aggregate-root.d.ts +3 -67
- package/dist/aggregate-root.js +6 -83
- package/dist/classes/command.d.ts +2 -2
- package/dist/classes/command.js +2 -6
- package/dist/classes/constants.js +1 -4
- package/dist/classes/index.d.ts +2 -2
- package/dist/classes/index.js +2 -18
- package/dist/classes/query.d.ts +2 -2
- package/dist/classes/query.js +2 -6
- package/dist/command-bus.d.ts +5 -5
- package/dist/command-bus.js +29 -32
- package/dist/constants.js +1 -4
- package/dist/cqrs.module.d.ts +5 -5
- package/dist/cqrs.module.js +34 -37
- package/dist/decorators/command-handler.decorator.d.ts +1 -1
- package/dist/decorators/command-handler.decorator.js +9 -13
- package/dist/decorators/constants.js +7 -10
- package/dist/decorators/events-handler.decorator.d.ts +1 -1
- package/dist/decorators/events-handler.decorator.js +9 -13
- package/dist/decorators/index.d.ts +5 -5
- package/dist/decorators/index.js +5 -21
- package/dist/decorators/publishable.decorator.js +3 -6
- package/dist/decorators/query-handler.decorator.d.ts +1 -1
- package/dist/decorators/query-handler.decorator.js +9 -13
- package/dist/decorators/saga.decorator.js +5 -9
- package/dist/event-bus.d.ts +10 -8
- package/dist/event-bus.js +52 -52
- package/dist/event-publisher.d.ts +8 -7
- package/dist/event-publisher.js +17 -18
- package/dist/exceptions/command-not-found.exception.js +1 -5
- package/dist/exceptions/index.d.ts +7 -7
- package/dist/exceptions/index.js +7 -23
- package/dist/exceptions/invalid-command-handler.exception.js +1 -5
- package/dist/exceptions/invalid-events-handler.exception.js +1 -5
- package/dist/exceptions/invalid-query-handler.exception.js +1 -5
- package/dist/exceptions/invalid-saga.exception.js +1 -5
- package/dist/exceptions/query-not-found.exception.js +1 -5
- package/dist/exceptions/unsupported-saga-scope.exception.js +1 -5
- package/dist/helpers/default-command-pubsub.d.ts +1 -1
- package/dist/helpers/default-command-pubsub.js +1 -5
- package/dist/helpers/default-event-id-provider.d.ts +1 -1
- package/dist/helpers/default-event-id-provider.js +3 -6
- package/dist/helpers/default-pubsub.d.ts +1 -1
- package/dist/helpers/default-pubsub.js +1 -5
- package/dist/helpers/default-query-pubsub.d.ts +1 -1
- package/dist/helpers/default-query-pubsub.js +1 -5
- package/dist/helpers/default-unhandled-exception-pubsub.d.ts +1 -1
- package/dist/helpers/default-unhandled-exception-pubsub.js +1 -5
- package/dist/index.d.ts +15 -14
- package/dist/index.js +15 -30
- package/dist/interfaces/aggregate-root.interface.d.ts +63 -0
- package/dist/interfaces/aggregate-root.interface.js +1 -0
- package/dist/interfaces/commands/command-bus.interface.d.ts +3 -3
- package/dist/interfaces/commands/command-bus.interface.js +1 -2
- package/dist/interfaces/commands/command-handler.interface.d.ts +2 -2
- package/dist/interfaces/commands/command-handler.interface.js +1 -2
- package/dist/interfaces/commands/command-metadata.interface.js +1 -2
- package/dist/interfaces/commands/command-publisher.interface.d.ts +1 -1
- package/dist/interfaces/commands/command-publisher.interface.js +1 -2
- package/dist/interfaces/commands/command.interface.js +1 -2
- package/dist/interfaces/cqrs-module-options.interface.d.ts +5 -5
- package/dist/interfaces/cqrs-module-options.interface.js +1 -2
- package/dist/interfaces/events/event-bus.interface.d.ts +2 -2
- package/dist/interfaces/events/event-bus.interface.js +1 -2
- package/dist/interfaces/events/event-handler.interface.d.ts +1 -1
- package/dist/interfaces/events/event-handler.interface.js +1 -2
- package/dist/interfaces/events/event-id-provider.interface.d.ts +1 -1
- package/dist/interfaces/events/event-id-provider.interface.js +1 -2
- package/dist/interfaces/events/event-publisher.interface.d.ts +2 -2
- package/dist/interfaces/events/event-publisher.interface.js +1 -2
- package/dist/interfaces/events/event.interface.js +1 -2
- package/dist/interfaces/events/message-source.interface.d.ts +1 -1
- package/dist/interfaces/events/message-source.interface.js +1 -2
- package/dist/interfaces/exceptions/unhandled-exception-info.interface.d.ts +2 -2
- package/dist/interfaces/exceptions/unhandled-exception-info.interface.js +1 -2
- package/dist/interfaces/exceptions/unhandled-exception-publisher.interface.d.ts +3 -3
- package/dist/interfaces/exceptions/unhandled-exception-publisher.interface.js +1 -2
- package/dist/interfaces/index.d.ts +20 -19
- package/dist/interfaces/index.js +20 -35
- package/dist/interfaces/providers-introspection-result.interface.d.ts +4 -4
- package/dist/interfaces/providers-introspection-result.interface.js +1 -2
- package/dist/interfaces/queries/query-bus.interface.d.ts +3 -3
- package/dist/interfaces/queries/query-bus.interface.js +1 -2
- package/dist/interfaces/queries/query-handler.interface.d.ts +2 -2
- package/dist/interfaces/queries/query-handler.interface.js +1 -2
- package/dist/interfaces/queries/query-metadata.interface.js +1 -2
- package/dist/interfaces/queries/query-publisher.interface.d.ts +1 -1
- package/dist/interfaces/queries/query-publisher.interface.js +1 -2
- package/dist/interfaces/queries/query-result.interface.js +1 -2
- package/dist/interfaces/queries/query.interface.js +1 -2
- package/dist/interfaces/saga.type.d.ts +2 -2
- package/dist/interfaces/saga.type.js +1 -2
- package/dist/mixins/index.d.ts +1 -0
- package/dist/mixins/index.js +1 -0
- package/dist/mixins/with-aggregate-root.mixin.d.ts +11 -0
- package/dist/mixins/with-aggregate-root.mixin.js +75 -0
- package/dist/operators/index.d.ts +1 -1
- package/dist/operators/index.js +1 -17
- package/dist/operators/of-type.d.ts +1 -1
- package/dist/operators/of-type.js +3 -6
- package/dist/query-bus.d.ts +5 -5
- package/dist/query-bus.js +28 -31
- package/dist/scopes/async.context.js +9 -13
- package/dist/scopes/index.d.ts +1 -1
- package/dist/scopes/index.js +1 -17
- package/dist/services/explorer.service.d.ts +5 -5
- package/dist/services/explorer.service.js +14 -20
- package/dist/storages/aggregate-root.storage.d.ts +3 -3
- package/dist/storages/aggregate-root.storage.js +9 -9
- package/dist/unhandled-exception-bus.d.ts +2 -2
- package/dist/unhandled-exception-bus.js +14 -17
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -17
- package/dist/utils/observable-bus.js +3 -7
- package/package.json +34 -26
- package/test/e2e/aggregate-commit-context.spec.ts +243 -0
- package/test/e2e/basic-flows.spec.ts +46 -26
- package/test/e2e/generics.spec.ts +3 -3
- package/test/e2e/request-scope.spec.ts +23 -22
- package/test/e2e/sync-event-handlers-app.spec.ts +123 -0
- package/test/e2e/unhandled-exceptions.spec.ts +55 -20
- package/tsconfig.build.json +3 -2
- package/vitest.config.e2e.ts +13 -0
- package/vitest.config.ts +8 -0
- package/dist/exceptions/invalid-module-ref.exception.d.ts +0 -3
- package/dist/exceptions/invalid-module-ref.exception.js +0 -8
- package/dist/helpers/default-get-event-id.d.ts +0 -9
- package/dist/helpers/default-get-event-id.js +0 -18
- package/dist/helpers/default-get-event-name.d.ts +0 -2
- package/dist/helpers/default-get-event-name.js +0 -8
- package/dist/interfaces/cqrs-options.interface.d.ts +0 -10
- package/dist/interfaces/cqrs-options.interface.js +0 -2
- package/dist/interfaces/event-observable.interface.d.ts +0 -4
- package/dist/interfaces/event-observable.interface.js +0 -2
- package/dist/utils/command-handler.decorator.d.ts +0 -3
- package/dist/utils/command-handler.decorator.js +0 -9
- package/dist/utils/constants.d.ts +0 -2
- package/dist/utils/constants.js +0 -4
- package/dist/utils/default-pubsub.d.ts +0 -9
- package/dist/utils/default-pubsub.js +0 -14
- package/dist/utils/events-handler.decorator.d.ts +0 -3
- package/dist/utils/events-handler.decorator.js +0 -9
- package/eslint.config.mjs +0 -42
- package/index.d.ts +0 -1
- package/index.js +0 -6
- package/jest.config.js +0 -9
- package/test/jest-e2e.json +0 -9
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidQueryHandlerException = void 0;
|
|
4
|
-
class InvalidQueryHandlerException extends Error {
|
|
1
|
+
export class InvalidQueryHandlerException extends Error {
|
|
5
2
|
constructor() {
|
|
6
3
|
super(`An invalid query handler has been provided. Please ensure that the provided handler is a class annotated with @QueryHandler and contains an 'execute' method.`);
|
|
7
4
|
}
|
|
8
5
|
}
|
|
9
|
-
exports.InvalidQueryHandlerException = InvalidQueryHandlerException;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidSagaException = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @publicApi
|
|
6
3
|
*/
|
|
7
|
-
class InvalidSagaException extends Error {
|
|
4
|
+
export class InvalidSagaException extends Error {
|
|
8
5
|
constructor() {
|
|
9
6
|
super(`Invalid saga. Each saga should return Observable stream.`);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.InvalidSagaException = InvalidSagaException;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryHandlerNotFoundException = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @publicApi
|
|
6
3
|
*/
|
|
7
|
-
class QueryHandlerNotFoundException extends Error {
|
|
4
|
+
export class QueryHandlerNotFoundException extends Error {
|
|
8
5
|
constructor(queryName) {
|
|
9
6
|
super(`No handler found for the query: "${queryName}"`);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.QueryHandlerNotFoundException = QueryHandlerNotFoundException;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedSagaScopeException = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @publicApi
|
|
6
3
|
*/
|
|
7
|
-
class UnsupportedSagaScopeException extends Error {
|
|
4
|
+
export class UnsupportedSagaScopeException extends Error {
|
|
8
5
|
constructor() {
|
|
9
6
|
super(`Request-scoped saga hosts are not supported. Instead, you should retrieve async-context-specific instances within the saga itself, using the "ModuleRef" provider.`);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.UnsupportedSagaScopeException = UnsupportedSagaScopeException;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { ICommand, ICommandPublisher } from '../interfaces';
|
|
2
|
+
import { ICommand, ICommandPublisher } from '../interfaces/index.js';
|
|
3
3
|
export declare class DefaultCommandPubSub<CommandBase extends ICommand> implements ICommandPublisher<CommandBase> {
|
|
4
4
|
private subject$;
|
|
5
5
|
constructor(subject$: Subject<CommandBase>);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultCommandPubSub = void 0;
|
|
4
|
-
class DefaultCommandPubSub {
|
|
1
|
+
export class DefaultCommandPubSub {
|
|
5
2
|
constructor(subject$) {
|
|
6
3
|
this.subject$ = subject$;
|
|
7
4
|
}
|
|
@@ -9,4 +6,3 @@ class DefaultCommandPubSub {
|
|
|
9
6
|
this.subject$.next(command);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.DefaultCommandPubSub = DefaultCommandPubSub;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import { EventIdProvider, IEvent } from '../interfaces';
|
|
2
|
+
import { EventIdProvider, IEvent } from '../interfaces/index.js';
|
|
3
3
|
declare class DefaultEventIdProvider<EventBase extends IEvent = IEvent> implements EventIdProvider<EventBase> {
|
|
4
4
|
getEventId(event: Type<EventBase>): string | null;
|
|
5
5
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultEventIdProvider = void 0;
|
|
4
|
-
const constants_1 = require("../decorators/constants");
|
|
1
|
+
import { EVENT_METADATA } from '../decorators/constants.js';
|
|
5
2
|
class DefaultEventIdProvider {
|
|
6
3
|
getEventId(event) {
|
|
7
|
-
return Reflect.getMetadata(
|
|
4
|
+
return Reflect.getMetadata(EVENT_METADATA, event)?.id ?? null;
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
export const defaultEventIdProvider = new DefaultEventIdProvider();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { IEvent, IEventPublisher, IMessageSource } from '../interfaces';
|
|
2
|
+
import { IEvent, IEventPublisher, IMessageSource } from '../interfaces/index.js';
|
|
3
3
|
export declare class DefaultPubSub<EventBase extends IEvent> implements IEventPublisher<EventBase>, IMessageSource<EventBase> {
|
|
4
4
|
private subject$;
|
|
5
5
|
constructor(subject$: Subject<EventBase>);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultPubSub = void 0;
|
|
4
|
-
class DefaultPubSub {
|
|
1
|
+
export class DefaultPubSub {
|
|
5
2
|
constructor(subject$) {
|
|
6
3
|
this.subject$ = subject$;
|
|
7
4
|
}
|
|
@@ -12,4 +9,3 @@ class DefaultPubSub {
|
|
|
12
9
|
this.subject$ = subject;
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
|
-
exports.DefaultPubSub = DefaultPubSub;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { IQuery, IQueryPublisher } from '../interfaces';
|
|
2
|
+
import { IQuery, IQueryPublisher } from '../interfaces/index.js';
|
|
3
3
|
export declare class DefaultQueryPubSub<QueryBase extends IQuery> implements IQueryPublisher<QueryBase> {
|
|
4
4
|
private subject$;
|
|
5
5
|
constructor(subject$: Subject<QueryBase>);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultQueryPubSub = void 0;
|
|
4
|
-
class DefaultQueryPubSub {
|
|
1
|
+
export class DefaultQueryPubSub {
|
|
5
2
|
constructor(subject$) {
|
|
6
3
|
this.subject$ = subject$;
|
|
7
4
|
}
|
|
@@ -9,4 +6,3 @@ class DefaultQueryPubSub {
|
|
|
9
6
|
this.subject$.next(query);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.DefaultQueryPubSub = DefaultQueryPubSub;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { ICommand, IEvent, IUnhandledExceptionPublisher, UnhandledExceptionInfo } from '../interfaces';
|
|
2
|
+
import { ICommand, IEvent, IUnhandledExceptionPublisher, UnhandledExceptionInfo } from '../interfaces/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Default implementation of the `IUnhandledExceptionPublisher` interface.
|
|
5
5
|
*/
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultUnhandledExceptionPubSub = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Default implementation of the `IUnhandledExceptionPublisher` interface.
|
|
6
3
|
*/
|
|
7
|
-
class DefaultUnhandledExceptionPubSub {
|
|
4
|
+
export class DefaultUnhandledExceptionPubSub {
|
|
8
5
|
constructor(subject$) {
|
|
9
6
|
this.subject$ = subject$;
|
|
10
7
|
}
|
|
@@ -12,4 +9,3 @@ class DefaultUnhandledExceptionPubSub {
|
|
|
12
9
|
this.subject$.next(info);
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
|
-
exports.DefaultUnhandledExceptionPubSub = DefaultUnhandledExceptionPubSub;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export * from './aggregate-root';
|
|
2
|
-
export * from './classes';
|
|
3
|
-
export * from './command-bus';
|
|
4
|
-
export * from './cqrs.module';
|
|
5
|
-
export * from './decorators';
|
|
6
|
-
export * from './event-bus';
|
|
7
|
-
export * from './event-publisher';
|
|
8
|
-
export * from './exceptions';
|
|
9
|
-
export * from './interfaces';
|
|
10
|
-
export * from './operators';
|
|
11
|
-
export * from './query-bus';
|
|
12
|
-
export * from './scopes';
|
|
13
|
-
export * from './unhandled-exception-bus';
|
|
14
|
-
export * from './utils';
|
|
1
|
+
export * from './aggregate-root.js';
|
|
2
|
+
export * from './classes/index.js';
|
|
3
|
+
export * from './command-bus.js';
|
|
4
|
+
export * from './cqrs.module.js';
|
|
5
|
+
export * from './decorators/index.js';
|
|
6
|
+
export * from './event-bus.js';
|
|
7
|
+
export * from './event-publisher.js';
|
|
8
|
+
export * from './exceptions/index.js';
|
|
9
|
+
export * from './interfaces/index.js';
|
|
10
|
+
export * from './operators/index.js';
|
|
11
|
+
export * from './query-bus.js';
|
|
12
|
+
export * from './scopes/index.js';
|
|
13
|
+
export * from './unhandled-exception-bus.js';
|
|
14
|
+
export * from './utils/index.js';
|
|
15
|
+
export * from './mixins/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Nest CQRS Module
|
|
4
3
|
* Copyright(c) 2017-... Kamil Mysliwiec
|
|
5
4
|
* www.kamilmysliwiec.com
|
|
6
5
|
* MIT Licensed
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
__exportStar(require("./aggregate-root"), exports);
|
|
24
|
-
__exportStar(require("./classes"), exports);
|
|
25
|
-
__exportStar(require("./command-bus"), exports);
|
|
26
|
-
__exportStar(require("./cqrs.module"), exports);
|
|
27
|
-
__exportStar(require("./decorators"), exports);
|
|
28
|
-
__exportStar(require("./event-bus"), exports);
|
|
29
|
-
__exportStar(require("./event-publisher"), exports);
|
|
30
|
-
__exportStar(require("./exceptions"), exports);
|
|
31
|
-
__exportStar(require("./interfaces"), exports);
|
|
32
|
-
__exportStar(require("./operators"), exports);
|
|
33
|
-
__exportStar(require("./query-bus"), exports);
|
|
34
|
-
__exportStar(require("./scopes"), exports);
|
|
35
|
-
__exportStar(require("./unhandled-exception-bus"), exports);
|
|
36
|
-
__exportStar(require("./utils"), exports);
|
|
7
|
+
export * from './aggregate-root.js';
|
|
8
|
+
export * from './classes/index.js';
|
|
9
|
+
export * from './command-bus.js';
|
|
10
|
+
export * from './cqrs.module.js';
|
|
11
|
+
export * from './decorators/index.js';
|
|
12
|
+
export * from './event-bus.js';
|
|
13
|
+
export * from './event-publisher.js';
|
|
14
|
+
export * from './exceptions/index.js';
|
|
15
|
+
export * from './interfaces/index.js';
|
|
16
|
+
export * from './operators/index.js';
|
|
17
|
+
export * from './query-bus.js';
|
|
18
|
+
export * from './scopes/index.js';
|
|
19
|
+
export * from './unhandled-exception-bus.js';
|
|
20
|
+
export * from './utils/index.js';
|
|
21
|
+
export * from './mixins/index.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { IEvent } from './events/event.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the aggregate root interface with event sourcing capabilities.
|
|
4
|
+
*/
|
|
5
|
+
export interface IAggregateRoot<EventBase extends IEvent = IEvent> {
|
|
6
|
+
/**
|
|
7
|
+
* Sets or gets the auto-commit flag.
|
|
8
|
+
*/
|
|
9
|
+
autoCommit: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Publishes a single event.
|
|
12
|
+
* @param event The event to publish.
|
|
13
|
+
* @param dispatcherContext Dispatcher context passed to the event publisher, such as
|
|
14
|
+
* `{ transaction }`. Defaults to the aggregate (merged with `EventPublisher`) or none (`@Publishable()`).
|
|
15
|
+
* @returns What the event bus returns (the event publisher's result).
|
|
16
|
+
*/
|
|
17
|
+
publish<T extends EventBase = EventBase>(event: T, dispatcherContext?: unknown): any;
|
|
18
|
+
/**
|
|
19
|
+
* Publishes multiple events.
|
|
20
|
+
* @param events The events to publish.
|
|
21
|
+
* @param dispatcherContext Dispatcher context passed to the event publisher, such as
|
|
22
|
+
* `{ transaction }`. Defaults to the aggregate (merged with `EventPublisher`) or none (`@Publishable()`).
|
|
23
|
+
* @returns What the event bus returns (the event publisher's result).
|
|
24
|
+
*/
|
|
25
|
+
publishAll<T extends EventBase = EventBase>(events: T[], dispatcherContext?: unknown): any;
|
|
26
|
+
/**
|
|
27
|
+
* Commits all uncommitted events.
|
|
28
|
+
* The events are cleared once they are handed to the event bus, before an asynchronous publisher settles.
|
|
29
|
+
* @param dispatcherContext Dispatcher context passed to the event publisher, such as
|
|
30
|
+
* `{ transaction }`. Defaults to the aggregate (merged with `EventPublisher`) or none (`@Publishable()`).
|
|
31
|
+
* @returns What `publishAll()` returns: await it to wait for (and catch the errors of) an asynchronous publisher.
|
|
32
|
+
*/
|
|
33
|
+
commit(dispatcherContext?: unknown): any;
|
|
34
|
+
/**
|
|
35
|
+
* Uncommits all events.
|
|
36
|
+
*/
|
|
37
|
+
uncommit(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Gets all uncommitted events.
|
|
40
|
+
* @returns An array of uncommitted events.
|
|
41
|
+
*/
|
|
42
|
+
getUncommittedEvents(): EventBase[];
|
|
43
|
+
/**
|
|
44
|
+
* Loads aggregate root state from event history.
|
|
45
|
+
* @param history The event history to load.
|
|
46
|
+
*/
|
|
47
|
+
loadFromHistory(history: EventBase[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Applies an event to the aggregate root.
|
|
50
|
+
* @param event The event to apply.
|
|
51
|
+
* @param isFromHistory Optional flag indicating if the event is from history.
|
|
52
|
+
*/
|
|
53
|
+
apply<T extends EventBase = EventBase>(event: T, isFromHistory?: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* Applies an event to the aggregate root with options.
|
|
56
|
+
* @param event The event to apply.
|
|
57
|
+
* @param options Options for applying the event.
|
|
58
|
+
*/
|
|
59
|
+
apply<T extends EventBase = EventBase>(event: T, options?: {
|
|
60
|
+
fromHistory?: boolean;
|
|
61
|
+
skipHandler?: boolean;
|
|
62
|
+
}): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from '../../classes';
|
|
2
|
-
import { AsyncContext } from '../../scopes/async.context';
|
|
3
|
-
import { ICommand } from './command.interface';
|
|
1
|
+
import { Command } from '../../classes/index.js';
|
|
2
|
+
import { AsyncContext } from '../../scopes/async.context.js';
|
|
3
|
+
import { ICommand } from './command.interface.js';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a command bus.
|
|
6
6
|
*
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command } from '../../classes';
|
|
2
|
-
import { ICommand } from './command.interface';
|
|
1
|
+
import { Command } from '../../classes/index.js';
|
|
2
|
+
import { ICommand } from './command.interface.js';
|
|
3
3
|
/**
|
|
4
4
|
* Represents a command handler.
|
|
5
5
|
* Command handlers are used to execute commands.
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ICommandPublisher } from './commands/command-publisher.interface';
|
|
2
|
-
import { EventIdProvider } from './events/event-id-provider.interface';
|
|
3
|
-
import { IEventPublisher } from './events/event-publisher.interface';
|
|
4
|
-
import { IUnhandledExceptionPublisher } from './exceptions/unhandled-exception-publisher.interface';
|
|
5
|
-
import { IQueryPublisher } from './queries/query-publisher.interface';
|
|
1
|
+
import { ICommandPublisher } from './commands/command-publisher.interface.js';
|
|
2
|
+
import { EventIdProvider } from './events/event-id-provider.interface.js';
|
|
3
|
+
import { IEventPublisher } from './events/event-publisher.interface.js';
|
|
4
|
+
import { IUnhandledExceptionPublisher } from './exceptions/unhandled-exception-publisher.interface.js';
|
|
5
|
+
import { IQueryPublisher } from './queries/query-publisher.interface.js';
|
|
6
6
|
/**
|
|
7
7
|
* Options for the CqrsModule.
|
|
8
8
|
*
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import { IEvent } from './event.interface';
|
|
2
|
+
import { IEvent } from './event.interface.js';
|
|
3
3
|
export interface EventIdProvider<EventBase extends IEvent = IEvent> {
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the unique identifier for the given event instance.
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AsyncContext } from '../../scopes';
|
|
2
|
-
import { IEvent } from './event.interface';
|
|
1
|
+
import { AsyncContext } from '../../scopes/index.js';
|
|
2
|
+
import { IEvent } from './event.interface.js';
|
|
3
3
|
export interface IEventPublisher<EventBase extends IEvent = IEvent> {
|
|
4
4
|
/**
|
|
5
5
|
* Publishes an event.
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ICommand } from '../commands/command.interface';
|
|
2
|
-
import { IEvent } from '../events/event.interface';
|
|
1
|
+
import { ICommand } from '../commands/command.interface.js';
|
|
2
|
+
import { IEvent } from '../events/event.interface.js';
|
|
3
3
|
/**
|
|
4
4
|
* Represents an unhandled exception.
|
|
5
5
|
*/
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ICommand } from '../commands/command.interface';
|
|
2
|
-
import { IEvent } from '../events/event.interface';
|
|
3
|
-
import { UnhandledExceptionInfo } from './unhandled-exception-info.interface';
|
|
1
|
+
import { ICommand } from '../commands/command.interface.js';
|
|
2
|
+
import { IEvent } from '../events/event.interface.js';
|
|
3
|
+
import { UnhandledExceptionInfo } from './unhandled-exception-info.interface.js';
|
|
4
4
|
export interface IUnhandledExceptionPublisher<CauseBase = IEvent | ICommand, ExceptionBase = any> {
|
|
5
5
|
/**
|
|
6
6
|
* Publishes an unhandled exception.
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './commands/command-
|
|
3
|
-
export * from './commands/command-
|
|
4
|
-
export * from './commands/command.interface';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './events/event-
|
|
8
|
-
export * from './events/event-
|
|
9
|
-
export * from './events/event.interface';
|
|
10
|
-
export * from './events/
|
|
11
|
-
export * from './events/
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './exceptions/unhandled-exception-
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './queries/query-
|
|
16
|
-
export * from './queries/query-
|
|
17
|
-
export * from './queries/query-
|
|
18
|
-
export * from './queries/query.interface';
|
|
19
|
-
export * from './
|
|
1
|
+
export * from './aggregate-root.interface.js';
|
|
2
|
+
export * from './commands/command-bus.interface.js';
|
|
3
|
+
export * from './commands/command-handler.interface.js';
|
|
4
|
+
export * from './commands/command-publisher.interface.js';
|
|
5
|
+
export * from './commands/command.interface.js';
|
|
6
|
+
export * from './cqrs-module-options.interface.js';
|
|
7
|
+
export * from './events/event-bus.interface.js';
|
|
8
|
+
export * from './events/event-handler.interface.js';
|
|
9
|
+
export * from './events/event-publisher.interface.js';
|
|
10
|
+
export * from './events/event.interface.js';
|
|
11
|
+
export * from './events/message-source.interface.js';
|
|
12
|
+
export * from './events/event-id-provider.interface.js';
|
|
13
|
+
export * from './exceptions/unhandled-exception-info.interface.js';
|
|
14
|
+
export * from './exceptions/unhandled-exception-publisher.interface.js';
|
|
15
|
+
export * from './queries/query-bus.interface.js';
|
|
16
|
+
export * from './queries/query-handler.interface.js';
|
|
17
|
+
export * from './queries/query-publisher.interface.js';
|
|
18
|
+
export * from './queries/query-result.interface.js';
|
|
19
|
+
export * from './queries/query.interface.js';
|
|
20
|
+
export * from './saga.type.js';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__exportStar(require("./cqrs-module-options.interface"), exports);
|
|
22
|
-
__exportStar(require("./events/event-bus.interface"), exports);
|
|
23
|
-
__exportStar(require("./events/event-handler.interface"), exports);
|
|
24
|
-
__exportStar(require("./events/event-publisher.interface"), exports);
|
|
25
|
-
__exportStar(require("./events/event.interface"), exports);
|
|
26
|
-
__exportStar(require("./events/message-source.interface"), exports);
|
|
27
|
-
__exportStar(require("./events/event-id-provider.interface"), exports);
|
|
28
|
-
__exportStar(require("./exceptions/unhandled-exception-info.interface"), exports);
|
|
29
|
-
__exportStar(require("./exceptions/unhandled-exception-publisher.interface"), exports);
|
|
30
|
-
__exportStar(require("./queries/query-bus.interface"), exports);
|
|
31
|
-
__exportStar(require("./queries/query-handler.interface"), exports);
|
|
32
|
-
__exportStar(require("./queries/query-publisher.interface"), exports);
|
|
33
|
-
__exportStar(require("./queries/query-result.interface"), exports);
|
|
34
|
-
__exportStar(require("./queries/query.interface"), exports);
|
|
35
|
-
__exportStar(require("./saga.type"), exports);
|
|
1
|
+
export * from './aggregate-root.interface.js';
|
|
2
|
+
export * from './commands/command-bus.interface.js';
|
|
3
|
+
export * from './commands/command-handler.interface.js';
|
|
4
|
+
export * from './commands/command-publisher.interface.js';
|
|
5
|
+
export * from './commands/command.interface.js';
|
|
6
|
+
export * from './cqrs-module-options.interface.js';
|
|
7
|
+
export * from './events/event-bus.interface.js';
|
|
8
|
+
export * from './events/event-handler.interface.js';
|
|
9
|
+
export * from './events/event-publisher.interface.js';
|
|
10
|
+
export * from './events/event.interface.js';
|
|
11
|
+
export * from './events/message-source.interface.js';
|
|
12
|
+
export * from './events/event-id-provider.interface.js';
|
|
13
|
+
export * from './exceptions/unhandled-exception-info.interface.js';
|
|
14
|
+
export * from './exceptions/unhandled-exception-publisher.interface.js';
|
|
15
|
+
export * from './queries/query-bus.interface.js';
|
|
16
|
+
export * from './queries/query-handler.interface.js';
|
|
17
|
+
export * from './queries/query-publisher.interface.js';
|
|
18
|
+
export * from './queries/query-result.interface.js';
|
|
19
|
+
export * from './queries/query.interface.js';
|
|
20
|
+
export * from './saga.type.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
2
|
-
import { ICommandHandler } from './commands/command-handler.interface';
|
|
3
|
-
import { IEventHandler } from './events/event-handler.interface';
|
|
4
|
-
import { IQueryHandler } from './queries/query-handler.interface';
|
|
1
|
+
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';
|
|
2
|
+
import { ICommandHandler } from './commands/command-handler.interface.js';
|
|
3
|
+
import { IEventHandler } from './events/event-handler.interface.js';
|
|
4
|
+
import { IQueryHandler } from './queries/query-handler.interface.js';
|
|
5
5
|
export interface ProvidersIntrospectionResult {
|
|
6
6
|
events?: InstanceWrapper<IEventHandler>[];
|
|
7
7
|
queries?: InstanceWrapper<IQueryHandler>[];
|