@nestjs/cqrs 7.0.0-next.3 → 8.0.1
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 +1 -1
- package/.github/ISSUE_TEMPLATE/Bug_report.yml +106 -0
- package/.github/ISSUE_TEMPLATE/Feature_request.yml +52 -0
- package/.github/ISSUE_TEMPLATE/Regression.yml +78 -0
- package/.github/ISSUE_TEMPLATE/config.yml +7 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -14
- package/CONTRIBUTING.md +4 -3
- package/LICENSE +21 -0
- package/dist/aggregate-root.d.ts +4 -2
- package/dist/aggregate-root.js +2 -1
- package/dist/command-bus.d.ts +4 -4
- package/dist/command-bus.js +56 -53
- package/dist/cqrs.module.js +25 -28
- package/dist/decorators/command-handler.decorator.d.ts +10 -0
- package/dist/decorators/command-handler.decorator.js +16 -1
- package/dist/decorators/constants.d.ts +3 -1
- package/dist/decorators/constants.js +4 -2
- package/dist/decorators/events-handler.decorator.d.ts +10 -0
- package/dist/decorators/events-handler.decorator.js +12 -1
- package/dist/decorators/index.js +2 -2
- package/dist/decorators/query-handler.decorator.d.ts +10 -0
- package/dist/decorators/query-handler.decorator.js +16 -1
- package/dist/decorators/saga.decorator.d.ts +5 -0
- package/dist/decorators/saga.decorator.js +7 -1
- package/dist/event-bus.js +77 -80
- package/dist/event-publisher.js +29 -26
- package/dist/exceptions/index.js +2 -2
- package/dist/helpers/default-get-event-name.js +2 -1
- package/dist/index.js +8 -2
- package/dist/interfaces/commands/command-bus.interface.d.ts +1 -1
- package/dist/interfaces/commands/command-metadata.interface.d.ts +3 -0
- package/dist/interfaces/commands/command-metadata.interface.js +2 -0
- package/dist/interfaces/index.js +2 -2
- package/dist/interfaces/queries/query-metadata.interface.d.ts +3 -0
- package/dist/interfaces/queries/query-metadata.interface.js +2 -0
- package/dist/interfaces/queries/query-publisher.interface.d.ts +1 -1
- package/dist/operators/index.js +2 -2
- package/dist/operators/of-type.d.ts +8 -0
- package/dist/operators/of-type.js +9 -1
- package/dist/query-bus.d.ts +3 -3
- package/dist/query-bus.js +59 -56
- package/dist/services/explorer.service.js +35 -38
- package/dist/utils/index.js +2 -2
- package/package.json +26 -23
- package/.github/ISSUE_TEMPLATE.md +0 -46
|
@@ -13,44 +13,41 @@ exports.ExplorerService = void 0;
|
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const modules_container_1 = require("@nestjs/core/injector/modules-container");
|
|
15
15
|
const constants_1 = require("../decorators/constants");
|
|
16
|
-
let ExplorerService =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
let ExplorerService = class ExplorerService {
|
|
17
|
+
constructor(modulesContainer) {
|
|
18
|
+
this.modulesContainer = modulesContainer;
|
|
19
|
+
}
|
|
20
|
+
explore() {
|
|
21
|
+
const modules = [...this.modulesContainer.values()];
|
|
22
|
+
const commands = this.flatMap(modules, (instance) => this.filterProvider(instance, constants_1.COMMAND_HANDLER_METADATA));
|
|
23
|
+
const queries = this.flatMap(modules, (instance) => this.filterProvider(instance, constants_1.QUERY_HANDLER_METADATA));
|
|
24
|
+
const events = this.flatMap(modules, (instance) => this.filterProvider(instance, constants_1.EVENTS_HANDLER_METADATA));
|
|
25
|
+
const sagas = this.flatMap(modules, (instance) => this.filterProvider(instance, constants_1.SAGA_METADATA));
|
|
26
|
+
return { commands, queries, events, sagas };
|
|
27
|
+
}
|
|
28
|
+
flatMap(modules, callback) {
|
|
29
|
+
const items = modules
|
|
30
|
+
.map((module) => [...module.providers.values()].map(callback))
|
|
31
|
+
.reduce((a, b) => a.concat(b), []);
|
|
32
|
+
return items.filter((element) => !!element);
|
|
33
|
+
}
|
|
34
|
+
filterProvider(wrapper, metadataKey) {
|
|
35
|
+
const { instance } = wrapper;
|
|
36
|
+
if (!instance) {
|
|
37
|
+
return undefined;
|
|
20
38
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const sagas = this.flatMap(modules, (instance) => this.filterProvider(instance, constants_1.SAGA_METADATA));
|
|
27
|
-
return { commands, queries, events, sagas };
|
|
39
|
+
return this.extractMetadata(instance, metadataKey);
|
|
40
|
+
}
|
|
41
|
+
extractMetadata(instance, metadataKey) {
|
|
42
|
+
if (!instance.constructor) {
|
|
43
|
+
return;
|
|
28
44
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!instance) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
return this.extractMetadata(instance, metadataKey);
|
|
41
|
-
}
|
|
42
|
-
extractMetadata(instance, metadataKey) {
|
|
43
|
-
if (!instance.constructor) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const metadata = Reflect.getMetadata(metadataKey, instance.constructor);
|
|
47
|
-
return metadata ? instance.constructor : undefined;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
ExplorerService = __decorate([
|
|
51
|
-
common_1.Injectable(),
|
|
52
|
-
__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
|
53
|
-
], ExplorerService);
|
|
54
|
-
return ExplorerService;
|
|
55
|
-
})();
|
|
45
|
+
const metadata = Reflect.getMetadata(metadataKey, instance.constructor);
|
|
46
|
+
return metadata ? instance.constructor : undefined;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
ExplorerService = __decorate([
|
|
50
|
+
(0, common_1.Injectable)(),
|
|
51
|
+
__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
|
52
|
+
], ExplorerService);
|
|
56
53
|
exports.ExplorerService = ExplorerService;
|
package/dist/utils/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
11
|
-
}
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./observable-bus"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cqrs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
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",
|
|
@@ -16,33 +16,36 @@
|
|
|
16
16
|
"prerelease": "npm run build",
|
|
17
17
|
"release": "release-it"
|
|
18
18
|
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"uuid": "8.3.2"
|
|
21
|
+
},
|
|
19
22
|
"devDependencies": {
|
|
20
|
-
"@commitlint/cli": "
|
|
21
|
-
"@commitlint/config-angular": "
|
|
22
|
-
"@nestjs/common": "
|
|
23
|
-
"@nestjs/core": "
|
|
24
|
-
"@types/node": "11.
|
|
25
|
-
"@types/jest": "
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "
|
|
27
|
-
"@typescript-eslint/parser": "
|
|
28
|
-
"eslint": "
|
|
29
|
-
"eslint-config-prettier": "
|
|
30
|
-
"eslint-plugin-import": "2.
|
|
31
|
-
"husky": "
|
|
32
|
-
"jest": "
|
|
33
|
-
"lint-staged": "
|
|
34
|
-
"prettier": "2.
|
|
23
|
+
"@commitlint/cli": "15.0.0",
|
|
24
|
+
"@commitlint/config-angular": "15.0.0",
|
|
25
|
+
"@nestjs/common": "8.2.3",
|
|
26
|
+
"@nestjs/core": "8.2.3",
|
|
27
|
+
"@types/node": "16.11.12",
|
|
28
|
+
"@types/jest": "27.0.3",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "5.6.0",
|
|
30
|
+
"@typescript-eslint/parser": "5.6.0",
|
|
31
|
+
"eslint": "8.4.1",
|
|
32
|
+
"eslint-config-prettier": "8.3.0",
|
|
33
|
+
"eslint-plugin-import": "2.25.3",
|
|
34
|
+
"husky": "7.0.4",
|
|
35
|
+
"jest": "27.4.3",
|
|
36
|
+
"lint-staged": "12.1.2",
|
|
37
|
+
"prettier": "2.5.1",
|
|
35
38
|
"reflect-metadata": "0.1.13",
|
|
36
|
-
"release-it": "
|
|
37
|
-
"rxjs": "
|
|
38
|
-
"ts-jest": "
|
|
39
|
-
"typescript": "
|
|
39
|
+
"release-it": "14.11.8",
|
|
40
|
+
"rxjs": "7.4.0",
|
|
41
|
+
"ts-jest": "27.1.1",
|
|
42
|
+
"typescript": "4.5.2"
|
|
40
43
|
},
|
|
41
44
|
"peerDependencies": {
|
|
42
|
-
"@nestjs/common": "^
|
|
43
|
-
"@nestjs/core": "^
|
|
45
|
+
"@nestjs/common": "^8.0.0",
|
|
46
|
+
"@nestjs/core": "^8.0.0",
|
|
44
47
|
"reflect-metadata": "0.1.13",
|
|
45
|
-
"rxjs": "^
|
|
48
|
+
"rxjs": "^7.2.0"
|
|
46
49
|
},
|
|
47
50
|
"lint-staged": {
|
|
48
51
|
"*.ts": [
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.
|
|
3
|
-
|
|
4
|
-
ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.
|
|
5
|
-
-->
|
|
6
|
-
|
|
7
|
-
## I'm submitting a...
|
|
8
|
-
<!--
|
|
9
|
-
Please search GitHub for a similar issue or PR before submitting.
|
|
10
|
-
Check one of the following options with "x" -->
|
|
11
|
-
<pre><code>
|
|
12
|
-
[ ] Regression <!--(a behavior that used to work and stopped working in a new release)-->
|
|
13
|
-
[ ] Bug report
|
|
14
|
-
[ ] Feature request
|
|
15
|
-
[ ] Documentation issue or request
|
|
16
|
-
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
|
|
17
|
-
</code></pre>
|
|
18
|
-
|
|
19
|
-
## Current behavior
|
|
20
|
-
<!-- Describe how the issue manifests. -->
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Expected behavior
|
|
24
|
-
<!-- Describe what the desired behavior would be. -->
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Minimal reproduction of the problem with instructions
|
|
28
|
-
<!-- Please share a repo, a gist, or step-by-step instructions. -->
|
|
29
|
-
|
|
30
|
-
## What is the motivation / use case for changing the behavior?
|
|
31
|
-
<!-- Describe the motivation or the concrete use case. -->
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Environment
|
|
35
|
-
|
|
36
|
-
<pre><code>
|
|
37
|
-
Nest version: X.Y.Z
|
|
38
|
-
<!-- Check whether this is still an issue in the most recent Nest version -->
|
|
39
|
-
|
|
40
|
-
For Tooling issues:
|
|
41
|
-
- Node version: XX <!-- run `node --version` -->
|
|
42
|
-
- Platform: <!-- Mac, Linux, Windows -->
|
|
43
|
-
|
|
44
|
-
Others:
|
|
45
|
-
<!-- Anything else relevant? Operating system version, IDE, package manager, ... -->
|
|
46
|
-
</code></pre>
|