@nestjs/cqrs 11.0.2 → 12.0.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/README.md +0 -1
- 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 +8 -5
- package/dist/command-bus.js +32 -32
- package/dist/constants.js +1 -4
- package/dist/cqrs.module.d.ts +8 -5
- package/dist/cqrs.module.js +37 -37
- package/dist/decorators/command-handler.decorator.d.ts +3 -1
- package/dist/decorators/command-handler.decorator.js +11 -13
- package/dist/decorators/constants.js +7 -10
- package/dist/decorators/events-handler.decorator.d.ts +3 -1
- package/dist/decorators/events-handler.decorator.js +12 -14
- package/dist/decorators/index.d.ts +5 -5
- package/dist/decorators/index.js +5 -21
- package/dist/decorators/publishable.decorator.d.ts +2 -0
- package/dist/decorators/publishable.decorator.js +5 -6
- package/dist/decorators/query-handler.decorator.d.ts +3 -1
- package/dist/decorators/query-handler.decorator.js +11 -13
- package/dist/decorators/saga.decorator.d.ts +2 -0
- package/dist/decorators/saga.decorator.js +7 -9
- package/dist/event-bus.d.ts +13 -8
- package/dist/event-bus.js +54 -51
- package/dist/event-publisher.d.ts +9 -7
- package/dist/event-publisher.js +10 -10
- package/dist/exceptions/command-not-found.exception.d.ts +3 -0
- package/dist/exceptions/command-not-found.exception.js +4 -5
- package/dist/exceptions/index.d.ts +7 -7
- package/dist/exceptions/index.js +7 -23
- package/dist/exceptions/invalid-command-handler.exception.d.ts +3 -0
- package/dist/exceptions/invalid-command-handler.exception.js +4 -5
- package/dist/exceptions/invalid-events-handler.exception.d.ts +3 -0
- package/dist/exceptions/invalid-events-handler.exception.js +4 -5
- package/dist/exceptions/invalid-query-handler.exception.js +1 -5
- package/dist/exceptions/invalid-saga.exception.d.ts +3 -0
- package/dist/exceptions/invalid-saga.exception.js +4 -5
- package/dist/exceptions/query-not-found.exception.d.ts +3 -0
- package/dist/exceptions/query-not-found.exception.js +4 -5
- package/dist/exceptions/unsupported-saga-scope.exception.d.ts +3 -0
- package/dist/exceptions/unsupported-saga-scope.exception.js +4 -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 +53 -0
- package/dist/interfaces/aggregate-root.interface.js +1 -0
- package/dist/interfaces/commands/command-bus.interface.d.ts +5 -3
- package/dist/interfaces/commands/command-bus.interface.js +1 -2
- package/dist/interfaces/commands/command-handler.interface.d.ts +4 -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 +6 -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 +17 -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 +5 -3
- package/dist/interfaces/queries/query-bus.interface.js +1 -2
- package/dist/interfaces/queries/query-handler.interface.d.ts +4 -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 +6 -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 +67 -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 +8 -5
- package/dist/query-bus.js +31 -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 +1 -5
- 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 +35 -27
- 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 +36 -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,7 +1,7 @@
|
|
|
1
|
-
export * from './command-not-found.exception';
|
|
2
|
-
export * from './invalid-command-handler.exception';
|
|
3
|
-
export * from './invalid-events-handler.exception';
|
|
4
|
-
export * from './invalid-query-handler.exception';
|
|
5
|
-
export * from './invalid-saga.exception';
|
|
6
|
-
export * from './query-not-found.exception';
|
|
7
|
-
export * from './unsupported-saga-scope.exception';
|
|
1
|
+
export * from './command-not-found.exception.js';
|
|
2
|
+
export * from './invalid-command-handler.exception.js';
|
|
3
|
+
export * from './invalid-events-handler.exception.js';
|
|
4
|
+
export * from './invalid-query-handler.exception.js';
|
|
5
|
+
export * from './invalid-saga.exception.js';
|
|
6
|
+
export * from './query-not-found.exception.js';
|
|
7
|
+
export * from './unsupported-saga-scope.exception.js';
|
package/dist/exceptions/index.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./command-not-found.exception"), exports);
|
|
18
|
-
__exportStar(require("./invalid-command-handler.exception"), exports);
|
|
19
|
-
__exportStar(require("./invalid-events-handler.exception"), exports);
|
|
20
|
-
__exportStar(require("./invalid-query-handler.exception"), exports);
|
|
21
|
-
__exportStar(require("./invalid-saga.exception"), exports);
|
|
22
|
-
__exportStar(require("./query-not-found.exception"), exports);
|
|
23
|
-
__exportStar(require("./unsupported-saga-scope.exception"), exports);
|
|
1
|
+
export * from './command-not-found.exception.js';
|
|
2
|
+
export * from './invalid-command-handler.exception.js';
|
|
3
|
+
export * from './invalid-events-handler.exception.js';
|
|
4
|
+
export * from './invalid-query-handler.exception.js';
|
|
5
|
+
export * from './invalid-saga.exception.js';
|
|
6
|
+
export * from './query-not-found.exception.js';
|
|
7
|
+
export * from './unsupported-saga-scope.exception.js';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class InvalidCommandHandlerException extends Error {
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export class InvalidCommandHandlerException extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(`An invalid command handler has been provided. Please ensure that the provided handler is a class annotated with @CommandHandler and contains an 'execute' method.`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.InvalidCommandHandlerException = InvalidCommandHandlerException;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class InvalidEventsHandlerException extends Error {
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export class InvalidEventsHandlerException extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(`An invalid events handler has been provided. Please ensure that the provided handler is a class annotated with @EventsHandler and contains a 'handle' method.`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.InvalidEventsHandlerException = InvalidEventsHandlerException;
|
|
@@ -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,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class InvalidSagaException extends Error {
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export class InvalidSagaException extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(`Invalid saga. Each saga should return Observable stream.`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.InvalidSagaException = InvalidSagaException;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class QueryHandlerNotFoundException extends Error {
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export class QueryHandlerNotFoundException extends Error {
|
|
5
5
|
constructor(queryName) {
|
|
6
6
|
super(`No handler found for the query: "${queryName}"`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.QueryHandlerNotFoundException = QueryHandlerNotFoundException;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class UnsupportedSagaScopeException extends Error {
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export class UnsupportedSagaScopeException extends Error {
|
|
5
5
|
constructor() {
|
|
6
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.`);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
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,53 @@
|
|
|
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
|
+
*/
|
|
14
|
+
publish<T extends EventBase = EventBase>(event: T): void;
|
|
15
|
+
/**
|
|
16
|
+
* Publishes multiple events.
|
|
17
|
+
* @param events The events to publish.
|
|
18
|
+
*/
|
|
19
|
+
publishAll<T extends EventBase = EventBase>(events: T[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Commits all uncommitted events.
|
|
22
|
+
*/
|
|
23
|
+
commit(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Uncommits all events.
|
|
26
|
+
*/
|
|
27
|
+
uncommit(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Gets all uncommitted events.
|
|
30
|
+
* @returns An array of uncommitted events.
|
|
31
|
+
*/
|
|
32
|
+
getUncommittedEvents(): EventBase[];
|
|
33
|
+
/**
|
|
34
|
+
* Loads aggregate root state from event history.
|
|
35
|
+
* @param history The event history to load.
|
|
36
|
+
*/
|
|
37
|
+
loadFromHistory(history: EventBase[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Applies an event to the aggregate root.
|
|
40
|
+
* @param event The event to apply.
|
|
41
|
+
* @param isFromHistory Optional flag indicating if the event is from history.
|
|
42
|
+
*/
|
|
43
|
+
apply<T extends EventBase = EventBase>(event: T, isFromHistory?: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Applies an event to the aggregate root with options.
|
|
46
|
+
* @param event The event to apply.
|
|
47
|
+
* @param options Options for applying the event.
|
|
48
|
+
*/
|
|
49
|
+
apply<T extends EventBase = EventBase>(event: T, options?: {
|
|
50
|
+
fromHistory?: boolean;
|
|
51
|
+
skipHandler?: boolean;
|
|
52
|
+
}): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
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
|
+
*
|
|
7
|
+
* @publicApi
|
|
6
8
|
*/
|
|
7
9
|
export interface ICommandBus<CommandBase extends ICommand = ICommand> {
|
|
8
10
|
/**
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
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.
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
6
8
|
*/
|
|
7
9
|
export type ICommandHandler<TCommand extends ICommand = any, TResult = any> = TCommand extends Command<infer InferredCommandResult> ? {
|
|
8
10
|
/**
|
|
@@ -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,4 +1,9 @@
|
|
|
1
|
-
import { ICommand } from './command.interface';
|
|
1
|
+
import { ICommand } from './command.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a command publisher.
|
|
4
|
+
*
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
2
7
|
export interface ICommandPublisher<CommandBase extends ICommand = ICommand> {
|
|
3
8
|
publish<T extends CommandBase = CommandBase>(command: T): any;
|
|
4
9
|
}
|
|
@@ -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,10 +1,12 @@
|
|
|
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
|
+
*
|
|
9
|
+
* @publicApi
|
|
8
10
|
*/
|
|
9
11
|
export interface CqrsModuleOptions {
|
|
10
12
|
/**
|
|
@@ -39,9 +41,19 @@ export interface CqrsModuleOptions {
|
|
|
39
41
|
rethrowUnhandled?: boolean;
|
|
40
42
|
}
|
|
41
43
|
import { Provider, Type } from '@nestjs/common';
|
|
44
|
+
/**
|
|
45
|
+
* Options for the CqrsModuleOptionsFactory.
|
|
46
|
+
*
|
|
47
|
+
* @publicApi
|
|
48
|
+
*/
|
|
42
49
|
export interface CqrsModuleOptionsFactory {
|
|
43
50
|
createCqrsOptions(): Promise<CqrsModuleOptions> | CqrsModuleOptions;
|
|
44
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for the CqrsModuleAsyncOptions.
|
|
54
|
+
*
|
|
55
|
+
* @publicApi
|
|
56
|
+
*/
|
|
45
57
|
export interface CqrsModuleAsyncOptions {
|
|
46
58
|
imports?: any[];
|
|
47
59
|
useExisting?: Type<CqrsModuleOptionsFactory>;
|
|
@@ -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
|
*/
|