@nestjs/cqrs 8.0.3 → 8.0.4
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/event-bus.d.ts +1 -0
- package/dist/event-bus.js +19 -5
- package/package.json +19 -19
package/dist/event-bus.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class EventBus<EventBase extends IEvent = IEvent> extends Observa
|
|
|
11
11
|
protected getEventId: (event: EventBase) => string | null;
|
|
12
12
|
protected readonly subscriptions: Subscription[];
|
|
13
13
|
private _publisher;
|
|
14
|
+
private readonly _logger;
|
|
14
15
|
constructor(commandBus: CommandBus, moduleRef: ModuleRef);
|
|
15
16
|
get publisher(): IEventPublisher<EventBase>;
|
|
16
17
|
set publisher(_publisher: IEventPublisher<EventBase>);
|
package/dist/event-bus.js
CHANGED
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var EventBus_1;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.EventBus = void 0;
|
|
13
14
|
const common_1 = require("@nestjs/common");
|
|
@@ -21,11 +22,12 @@ const exceptions_1 = require("./exceptions");
|
|
|
21
22
|
const default_get_event_id_1 = require("./helpers/default-get-event-id");
|
|
22
23
|
const default_pubsub_1 = require("./helpers/default-pubsub");
|
|
23
24
|
const utils_1 = require("./utils");
|
|
24
|
-
let EventBus = class EventBus extends utils_1.ObservableBus {
|
|
25
|
+
let EventBus = EventBus_1 = class EventBus extends utils_1.ObservableBus {
|
|
25
26
|
constructor(commandBus, moduleRef) {
|
|
26
27
|
super();
|
|
27
28
|
this.commandBus = commandBus;
|
|
28
29
|
this.moduleRef = moduleRef;
|
|
30
|
+
this._logger = new common_1.Logger(EventBus_1.name);
|
|
29
31
|
this.subscriptions = [];
|
|
30
32
|
this.getEventId = default_get_event_id_1.defaultGetEventId;
|
|
31
33
|
this.useDefaultPublisher();
|
|
@@ -50,7 +52,14 @@ let EventBus = class EventBus extends utils_1.ObservableBus {
|
|
|
50
52
|
}
|
|
51
53
|
bind(handler, id) {
|
|
52
54
|
const stream$ = id ? this.ofEventId(id) : this.subject$;
|
|
53
|
-
const subscription = stream
|
|
55
|
+
const subscription = stream$
|
|
56
|
+
.pipe((0, operators_1.mergeMap)((event) => (0, rxjs_1.from)(handler.handle(event))))
|
|
57
|
+
.subscribe({
|
|
58
|
+
error: (error) => {
|
|
59
|
+
this._logger.error(`"${handler.constructor.name}" has thrown an error.`, error);
|
|
60
|
+
throw error;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
54
63
|
this.subscriptions.push(subscription);
|
|
55
64
|
}
|
|
56
65
|
registerSagas(types = []) {
|
|
@@ -89,8 +98,13 @@ let EventBus = class EventBus extends utils_1.ObservableBus {
|
|
|
89
98
|
throw new exceptions_1.InvalidSagaException();
|
|
90
99
|
}
|
|
91
100
|
const subscription = stream$
|
|
92
|
-
.pipe((0, operators_1.filter)((e) => !!e))
|
|
93
|
-
.subscribe(
|
|
101
|
+
.pipe((0, operators_1.filter)((e) => !!e), (0, operators_1.mergeMap)((command) => (0, rxjs_1.from)(this.commandBus.execute(command))))
|
|
102
|
+
.subscribe({
|
|
103
|
+
error: (error) => {
|
|
104
|
+
this._logger.error(`Command handler which execution was triggered by Saga has thrown an error.`, error);
|
|
105
|
+
throw error;
|
|
106
|
+
},
|
|
107
|
+
});
|
|
94
108
|
this.subscriptions.push(subscription);
|
|
95
109
|
}
|
|
96
110
|
reflectEvents(handler) {
|
|
@@ -100,7 +114,7 @@ let EventBus = class EventBus extends utils_1.ObservableBus {
|
|
|
100
114
|
this._publisher = new default_pubsub_1.DefaultPubSub(this.subject$);
|
|
101
115
|
}
|
|
102
116
|
};
|
|
103
|
-
EventBus = __decorate([
|
|
117
|
+
EventBus = EventBus_1 = __decorate([
|
|
104
118
|
(0, common_1.Injectable)(),
|
|
105
119
|
__metadata("design:paramtypes", [command_bus_1.CommandBus,
|
|
106
120
|
core_1.ModuleRef])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cqrs",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
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",
|
|
@@ -20,26 +20,26 @@
|
|
|
20
20
|
"uuid": "8.3.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@commitlint/cli": "16.2.
|
|
24
|
-
"@commitlint/config-angular": "16.2.
|
|
25
|
-
"@nestjs/common": "8.4.
|
|
26
|
-
"@nestjs/core": "8.4.
|
|
27
|
-
"@types/node": "16.11.
|
|
28
|
-
"@types/jest": "27.
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
30
|
-
"@typescript-eslint/parser": "5.
|
|
31
|
-
"eslint": "8.
|
|
32
|
-
"eslint-config-prettier": "8.
|
|
33
|
-
"eslint-plugin-import": "2.
|
|
23
|
+
"@commitlint/cli": "16.2.4",
|
|
24
|
+
"@commitlint/config-angular": "16.2.4",
|
|
25
|
+
"@nestjs/common": "8.4.4",
|
|
26
|
+
"@nestjs/core": "8.4.4",
|
|
27
|
+
"@types/node": "16.11.33",
|
|
28
|
+
"@types/jest": "27.5.0",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "5.22.0",
|
|
30
|
+
"@typescript-eslint/parser": "5.22.0",
|
|
31
|
+
"eslint": "8.14.0",
|
|
32
|
+
"eslint-config-prettier": "8.5.0",
|
|
33
|
+
"eslint-plugin-import": "2.26.0",
|
|
34
34
|
"husky": "7.0.4",
|
|
35
|
-
"jest": "
|
|
36
|
-
"lint-staged": "12.
|
|
37
|
-
"prettier": "2.
|
|
35
|
+
"jest": "28.0.3",
|
|
36
|
+
"lint-staged": "12.4.1",
|
|
37
|
+
"prettier": "2.6.2",
|
|
38
38
|
"reflect-metadata": "0.1.13",
|
|
39
|
-
"release-it": "
|
|
40
|
-
"rxjs": "7.5.
|
|
41
|
-
"ts-jest": "
|
|
42
|
-
"typescript": "4.6.
|
|
39
|
+
"release-it": "15.0.0",
|
|
40
|
+
"rxjs": "7.5.5",
|
|
41
|
+
"ts-jest": "28.0.1",
|
|
42
|
+
"typescript": "4.6.4"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@nestjs/common": "^8.0.0",
|