@nestjs/cqrs 11.0.1 → 11.0.2
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/dist/cqrs.module.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamicModule, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
2
|
import { CommandBus } from './command-bus';
|
|
3
3
|
import { EventBus } from './event-bus';
|
|
4
|
-
import { CqrsModuleOptions, IEvent } from './interfaces';
|
|
4
|
+
import { CqrsModuleAsyncOptions, CqrsModuleOptions, IEvent } from './interfaces';
|
|
5
5
|
import { QueryBus } from './query-bus';
|
|
6
6
|
import { ExplorerService } from './services/explorer.service';
|
|
7
7
|
export declare class CqrsModule<EventBase extends IEvent = IEvent> implements OnApplicationBootstrap {
|
|
@@ -9,12 +9,9 @@ export declare class CqrsModule<EventBase extends IEvent = IEvent> implements On
|
|
|
9
9
|
private readonly eventBus;
|
|
10
10
|
private readonly commandBus;
|
|
11
11
|
private readonly queryBus;
|
|
12
|
-
/**
|
|
13
|
-
* Registers CQRS module globally.
|
|
14
|
-
* @param options CQRS module options.
|
|
15
|
-
* @returns A dynamic module.
|
|
16
|
-
*/
|
|
17
12
|
static forRoot(options?: CqrsModuleOptions): DynamicModule;
|
|
13
|
+
static forRootAsync(options: CqrsModuleAsyncOptions): DynamicModule;
|
|
14
|
+
private static createAsyncProviders;
|
|
18
15
|
constructor(explorerService: ExplorerService<EventBase>, eventBus: EventBus<EventBase>, commandBus: CommandBus, queryBus: QueryBus);
|
|
19
16
|
onApplicationBootstrap(): void;
|
|
20
17
|
}
|
package/dist/cqrs.module.js
CHANGED
|
@@ -21,11 +21,6 @@ const explorer_service_1 = require("./services/explorer.service");
|
|
|
21
21
|
const unhandled_exception_bus_1 = require("./unhandled-exception-bus");
|
|
22
22
|
const aggregate_root_storage_1 = require("./storages/aggregate-root.storage");
|
|
23
23
|
let CqrsModule = CqrsModule_1 = class CqrsModule {
|
|
24
|
-
/**
|
|
25
|
-
* Registers CQRS module globally.
|
|
26
|
-
* @param options CQRS module options.
|
|
27
|
-
* @returns A dynamic module.
|
|
28
|
-
*/
|
|
29
24
|
static forRoot(options) {
|
|
30
25
|
return {
|
|
31
26
|
module: CqrsModule_1,
|
|
@@ -38,6 +33,57 @@ let CqrsModule = CqrsModule_1 = class CqrsModule {
|
|
|
38
33
|
global: true,
|
|
39
34
|
};
|
|
40
35
|
}
|
|
36
|
+
static forRootAsync(options) {
|
|
37
|
+
return {
|
|
38
|
+
module: CqrsModule_1,
|
|
39
|
+
global: true,
|
|
40
|
+
imports: options.imports || [],
|
|
41
|
+
providers: [...this.createAsyncProviders(options)],
|
|
42
|
+
exports: [constants_1.CQRS_MODULE_OPTIONS],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
static createAsyncProviders(options) {
|
|
46
|
+
if (options.useValue) {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
provide: constants_1.CQRS_MODULE_OPTIONS,
|
|
50
|
+
useValue: options.useValue,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
if (options.useFactory) {
|
|
55
|
+
return [
|
|
56
|
+
{
|
|
57
|
+
provide: constants_1.CQRS_MODULE_OPTIONS,
|
|
58
|
+
useFactory: options.useFactory,
|
|
59
|
+
inject: options.inject || [],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
if (options.useClass) {
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
provide: options.useClass,
|
|
67
|
+
useClass: options.useClass,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
provide: constants_1.CQRS_MODULE_OPTIONS,
|
|
71
|
+
useFactory: async (optionsFactory) => optionsFactory.createCqrsOptions(),
|
|
72
|
+
inject: [options.useClass],
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
if (options.useExisting) {
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
provide: constants_1.CQRS_MODULE_OPTIONS,
|
|
80
|
+
useFactory: async (optionsFactory) => optionsFactory.createCqrsOptions(),
|
|
81
|
+
inject: [options.useExisting],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
throw new Error('Invalid CqrsModuleAsyncOptions configuration. Provide useValue, useFactory, useClass, or useExisting.');
|
|
86
|
+
}
|
|
41
87
|
constructor(explorerService, eventBus, commandBus, queryBus) {
|
|
42
88
|
this.explorerService = explorerService;
|
|
43
89
|
this.eventBus = eventBus;
|
|
@@ -10,14 +10,14 @@ export declare class EventPublisher<EventBase extends IEvent = IEvent> {
|
|
|
10
10
|
constructor(eventBus: EventBus<EventBase>);
|
|
11
11
|
/**
|
|
12
12
|
* Merge the event publisher into the provided class.
|
|
13
|
-
* This is required to make `publish` and `publishAll` available on the `
|
|
13
|
+
* This is required to make `publish` and `publishAll` available on the `AggregateRoot` class.
|
|
14
14
|
* @param metatype The class to merge into.
|
|
15
15
|
* @param asyncContext The async context (if scoped).
|
|
16
16
|
*/
|
|
17
17
|
mergeClassContext<T extends Constructor<AggregateRoot<EventBase>>>(metatype: T, asyncContext?: AsyncContext): T;
|
|
18
18
|
/**
|
|
19
19
|
* Merge the event publisher into the provided object.
|
|
20
|
-
* This is required to make `publish` and `publishAll` available on the `
|
|
20
|
+
* This is required to make `publish` and `publishAll` available on the `AggregateRoot` class instance.
|
|
21
21
|
* @param object The object to merge into.
|
|
22
22
|
* @param asyncContext The async context (if scoped).
|
|
23
23
|
*/
|
package/dist/event-publisher.js
CHANGED
|
@@ -18,7 +18,7 @@ let EventPublisher = class EventPublisher {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Merge the event publisher into the provided class.
|
|
21
|
-
* This is required to make `publish` and `publishAll` available on the `
|
|
21
|
+
* This is required to make `publish` and `publishAll` available on the `AggregateRoot` class.
|
|
22
22
|
* @param metatype The class to merge into.
|
|
23
23
|
* @param asyncContext The async context (if scoped).
|
|
24
24
|
*/
|
|
@@ -35,7 +35,7 @@ let EventPublisher = class EventPublisher {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Merge the event publisher into the provided object.
|
|
38
|
-
* This is required to make `publish` and `publishAll` available on the `
|
|
38
|
+
* This is required to make `publish` and `publishAll` available on the `AggregateRoot` class instance.
|
|
39
39
|
* @param object The object to merge into.
|
|
40
40
|
* @param asyncContext The async context (if scoped).
|
|
41
41
|
*/
|
|
@@ -38,3 +38,16 @@ export interface CqrsModuleOptions {
|
|
|
38
38
|
*/
|
|
39
39
|
rethrowUnhandled?: boolean;
|
|
40
40
|
}
|
|
41
|
+
import { Provider, Type } from '@nestjs/common';
|
|
42
|
+
export interface CqrsModuleOptionsFactory {
|
|
43
|
+
createCqrsOptions(): Promise<CqrsModuleOptions> | CqrsModuleOptions;
|
|
44
|
+
}
|
|
45
|
+
export interface CqrsModuleAsyncOptions {
|
|
46
|
+
imports?: any[];
|
|
47
|
+
useExisting?: Type<CqrsModuleOptionsFactory>;
|
|
48
|
+
useClass?: Type<CqrsModuleOptionsFactory>;
|
|
49
|
+
useFactory?: (...args: any[]) => Promise<CqrsModuleOptions> | CqrsModuleOptions;
|
|
50
|
+
useValue?: CqrsModuleOptions;
|
|
51
|
+
inject?: any[];
|
|
52
|
+
extraProviders?: Provider[];
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cqrs",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.2",
|
|
4
4
|
"description": "A lightweight CQRS module for Nest framework (node.js)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"url": "https://github.com/nestjs/cqrs#readme",
|
|
@@ -22,26 +22,26 @@
|
|
|
22
22
|
"@commitlint/cli": "19.7.1",
|
|
23
23
|
"@commitlint/config-angular": "19.7.1",
|
|
24
24
|
"@eslint/eslintrc": "3.2.0",
|
|
25
|
-
"@eslint/js": "9.
|
|
26
|
-
"@nestjs/common": "11.0.
|
|
27
|
-
"@nestjs/core": "11.0.
|
|
28
|
-
"@nestjs/testing": "11.0.
|
|
25
|
+
"@eslint/js": "9.20.0",
|
|
26
|
+
"@nestjs/common": "11.0.9",
|
|
27
|
+
"@nestjs/core": "11.0.9",
|
|
28
|
+
"@nestjs/testing": "11.0.9",
|
|
29
29
|
"@types/jest": "29.5.14",
|
|
30
|
-
"@types/node": "22.13.
|
|
31
|
-
"eslint": "9.
|
|
30
|
+
"@types/node": "22.13.1",
|
|
31
|
+
"eslint": "9.20.1",
|
|
32
32
|
"eslint-config-prettier": "10.0.1",
|
|
33
33
|
"eslint-plugin-prettier": "5.2.3",
|
|
34
34
|
"globals": "15.14.0",
|
|
35
35
|
"husky": "9.1.7",
|
|
36
36
|
"jest": "29.7.0",
|
|
37
37
|
"lint-staged": "15.4.3",
|
|
38
|
-
"prettier": "3.
|
|
38
|
+
"prettier": "3.5.0",
|
|
39
39
|
"reflect-metadata": "0.2.2",
|
|
40
40
|
"release-it": "18.1.2",
|
|
41
41
|
"rxjs": "7.8.1",
|
|
42
42
|
"ts-jest": "29.2.5",
|
|
43
43
|
"typescript": "5.7.3",
|
|
44
|
-
"typescript-eslint": "8.
|
|
44
|
+
"typescript-eslint": "8.24.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|