@nestjs/cqrs 9.0.3 → 10.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
CHANGED
|
@@ -3,21 +3,21 @@ version: 2
|
|
|
3
3
|
aliases:
|
|
4
4
|
- &restore-cache
|
|
5
5
|
restore_cache:
|
|
6
|
-
|
|
6
|
+
key: dependency-cache-{{ checksum "package.json" }}
|
|
7
7
|
- &install-deps
|
|
8
8
|
run:
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
name: Install dependencies
|
|
10
|
+
command: npm ci --ignore-scripts
|
|
11
11
|
- &build-packages
|
|
12
12
|
run:
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
name: Build
|
|
14
|
+
command: npm run build
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
17
|
build:
|
|
18
18
|
working_directory: ~/nest
|
|
19
19
|
docker:
|
|
20
|
-
- image: cimg/node:
|
|
20
|
+
- image: cimg/node:20.3
|
|
21
21
|
steps:
|
|
22
22
|
- checkout
|
|
23
23
|
- run:
|
|
@@ -27,18 +27,17 @@ jobs:
|
|
|
27
27
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
28
28
|
- run:
|
|
29
29
|
name: Install dependencies
|
|
30
|
-
command: npm ci
|
|
30
|
+
command: npm ci --ignore-scripts
|
|
31
31
|
- save_cache:
|
|
32
32
|
key: dependency-cache-{{ checksum "package.json" }}
|
|
33
33
|
paths:
|
|
34
34
|
- ./node_modules
|
|
35
35
|
- run:
|
|
36
36
|
name: Build
|
|
37
|
-
command: npm run build
|
|
37
|
+
command: npm run build
|
|
38
38
|
|
|
39
39
|
workflows:
|
|
40
40
|
version: 2
|
|
41
41
|
build-and-test:
|
|
42
42
|
jobs:
|
|
43
43
|
- build
|
|
44
|
-
|
package/README.md
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
13
13
|
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
14
14
|
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
15
|
-
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
16
|
-
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
17
15
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
|
18
16
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
19
17
|
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
@@ -10,4 +10,4 @@ import { IEvent } from '../index';
|
|
|
10
10
|
*
|
|
11
11
|
* @see https://docs.nestjs.com/recipes/cqrs#events
|
|
12
12
|
*/
|
|
13
|
-
export declare const EventsHandler: (...events: IEvent[]) => ClassDecorator;
|
|
13
|
+
export declare const EventsHandler: (...events: (IEvent | (new (...args: any[]) => IEvent))[]) => ClassDecorator;
|
package/dist/event-bus.js
CHANGED
|
@@ -56,8 +56,7 @@ let EventBus = EventBus_1 = class EventBus extends utils_1.ObservableBus {
|
|
|
56
56
|
.pipe((0, operators_1.mergeMap)((event) => (0, rxjs_1.from)(Promise.resolve(handler.handle(event)))))
|
|
57
57
|
.subscribe({
|
|
58
58
|
error: (error) => {
|
|
59
|
-
this._logger.error(`"${handler.constructor.name}" has thrown an
|
|
60
|
-
throw error;
|
|
59
|
+
this._logger.error(`"${handler.constructor.name}" has thrown an unhandled exception.`, error);
|
|
61
60
|
},
|
|
62
61
|
});
|
|
63
62
|
this.subscriptions.push(subscription);
|
|
@@ -101,8 +100,7 @@ let EventBus = EventBus_1 = class EventBus extends utils_1.ObservableBus {
|
|
|
101
100
|
.pipe((0, operators_1.filter)((e) => !!e), (0, operators_1.mergeMap)((command) => (0, rxjs_1.from)(this.commandBus.execute(command))))
|
|
102
101
|
.subscribe({
|
|
103
102
|
error: (error) => {
|
|
104
|
-
this._logger.error(`Command handler which execution was triggered by Saga has thrown an
|
|
105
|
-
throw error;
|
|
103
|
+
this._logger.error(`Command handler which execution was triggered by Saga has thrown an unhandled exception.`, error);
|
|
106
104
|
},
|
|
107
105
|
});
|
|
108
106
|
this.subscriptions.push(subscription);
|
|
@@ -8,9 +8,8 @@ const constants_1 = require("../decorators/constants");
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
const defaultGetEventId = (event) => {
|
|
11
|
-
var _a, _b;
|
|
12
11
|
const { constructor } = Object.getPrototypeOf(event);
|
|
13
|
-
return
|
|
12
|
+
return Reflect.getMetadata(constants_1.EVENT_METADATA, constructor)?.id ?? null;
|
|
14
13
|
};
|
|
15
14
|
exports.defaultGetEventId = defaultGetEventId;
|
|
16
15
|
const defaultReflectEventId = (event) => {
|
package/dist/query-bus.js
CHANGED
|
@@ -8,15 +8,6 @@ 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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
12
|
exports.QueryBus = void 0;
|
|
22
13
|
const common_1 = require("@nestjs/common");
|
|
@@ -40,17 +31,15 @@ let QueryBus = class QueryBus extends observable_bus_1.ObservableBus {
|
|
|
40
31
|
set publisher(_publisher) {
|
|
41
32
|
this._publisher = _publisher;
|
|
42
33
|
}
|
|
43
|
-
execute(query) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return result;
|
|
53
|
-
});
|
|
34
|
+
async execute(query) {
|
|
35
|
+
const queryId = this.getQueryId(query);
|
|
36
|
+
const handler = this.handlers.get(queryId);
|
|
37
|
+
if (!handler) {
|
|
38
|
+
throw new exceptions_1.QueryHandlerNotFoundException(queryId);
|
|
39
|
+
}
|
|
40
|
+
this._publisher.publish(query);
|
|
41
|
+
const result = await handler.execute(query);
|
|
42
|
+
return result;
|
|
54
43
|
}
|
|
55
44
|
bind(handler, queryId) {
|
|
56
45
|
this.handlers.set(queryId, handler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cqrs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
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",
|
|
@@ -21,30 +21,30 @@
|
|
|
21
21
|
"uuid": "9.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@commitlint/cli": "17.
|
|
25
|
-
"@commitlint/config-angular": "17.
|
|
26
|
-
"@nestjs/common": "
|
|
27
|
-
"@nestjs/core": "
|
|
28
|
-
"@types/node": "18.
|
|
29
|
-
"@types/jest": "29.
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
31
|
-
"@typescript-eslint/parser": "5.
|
|
32
|
-
"eslint": "8.
|
|
33
|
-
"eslint-config-prettier": "8.
|
|
24
|
+
"@commitlint/cli": "17.6.5",
|
|
25
|
+
"@commitlint/config-angular": "17.6.5",
|
|
26
|
+
"@nestjs/common": "10.0.0",
|
|
27
|
+
"@nestjs/core": "10.0.0",
|
|
28
|
+
"@types/node": "18.16.18",
|
|
29
|
+
"@types/jest": "29.5.2",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "5.59.11",
|
|
31
|
+
"@typescript-eslint/parser": "5.59.11",
|
|
32
|
+
"eslint": "8.42.0",
|
|
33
|
+
"eslint-config-prettier": "8.8.0",
|
|
34
34
|
"eslint-plugin-import": "2.27.5",
|
|
35
35
|
"husky": "8.0.3",
|
|
36
|
-
"jest": "29.
|
|
37
|
-
"lint-staged": "13.
|
|
38
|
-
"prettier": "2.8.
|
|
36
|
+
"jest": "29.5.0",
|
|
37
|
+
"lint-staged": "13.2.2",
|
|
38
|
+
"prettier": "2.8.8",
|
|
39
39
|
"reflect-metadata": "0.1.13",
|
|
40
|
-
"release-it": "15.
|
|
41
|
-
"rxjs": "7.8.
|
|
42
|
-
"ts-jest": "29.0
|
|
43
|
-
"typescript": "
|
|
40
|
+
"release-it": "15.11.0",
|
|
41
|
+
"rxjs": "7.8.1",
|
|
42
|
+
"ts-jest": "29.1.0",
|
|
43
|
+
"typescript": "5.1.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@nestjs/common": "^9.0.0",
|
|
47
|
-
"@nestjs/core": "^9.0.0",
|
|
46
|
+
"@nestjs/common": "^9.0.0 || ^10.0.0",
|
|
47
|
+
"@nestjs/core": "^9.0.0 || ^10.0.0",
|
|
48
48
|
"reflect-metadata": "0.1.13",
|
|
49
49
|
"rxjs": "^7.2.0"
|
|
50
50
|
},
|