@hg-ts/cqrs 0.1.54 → 0.1.56
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/package.json +9 -9
- package/.eslintcache +0 -1
- package/.turbo/turbo-build.log +0 -2
- package/.turbo/turbo-lint$colon$ts.log +0 -2
- package/.turbo/turbo-test.log +0 -30
- package/eslint.config.mjs +0 -3
- package/src/abstracts/base.command-handler.ts +0 -6
- package/src/abstracts/base.command.ts +0 -5
- package/src/abstracts/base.executor.test-suite.ts +0 -64
- package/src/abstracts/base.executor.ts +0 -46
- package/src/abstracts/base.query-handler.ts +0 -6
- package/src/abstracts/base.query.ts +0 -5
- package/src/abstracts/index.ts +0 -7
- package/src/cqrs.module.ts +0 -120
- package/src/decorators/command-handler.decorator.ts +0 -14
- package/src/decorators/index.ts +0 -4
- package/src/decorators/query-handler.decorator.ts +0 -14
- package/src/exceptions/handler-already-added.exception.ts +0 -8
- package/src/exceptions/handler-not-found.exception.ts +0 -8
- package/src/exceptions/index.ts +0 -2
- package/src/executors/command.executor.ts +0 -18
- package/src/executors/index.ts +0 -2
- package/src/executors/query.executor.ts +0 -18
- package/src/index.ts +0 -10
- package/src/tests/command-executor.test.ts +0 -31
- package/src/tests/commands/index.ts +0 -2
- package/src/tests/commands/test.command.ts +0 -11
- package/src/tests/commands/unknown.command.ts +0 -11
- package/src/tests/cqrs-test.module.ts +0 -7
- package/src/tests/cqrs.module.test.ts +0 -73
- package/src/tests/queries/index.ts +0 -2
- package/src/tests/queries/test.query.ts +0 -11
- package/src/tests/queries/unknown.query.ts +0 -11
- package/src/tests/query-executor.test.ts +0 -30
- package/src/tests/test-command.handler.ts +0 -17
- package/src/tests/test-query.handler.ts +0 -18
- package/src/types.ts +0 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/cqrs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"test:dev": "yarn build:dev --onSuccess \"yarn test\""
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@hg-ts-config/typescript": "0.1.
|
|
20
|
-
"@hg-ts/exception": "0.1.
|
|
21
|
-
"@hg-ts/ioc": "0.1.
|
|
22
|
-
"@hg-ts/linter": "0.1.
|
|
23
|
-
"@hg-ts/tests": "0.1.
|
|
24
|
-
"@hg-ts/types": "0.1.
|
|
19
|
+
"@hg-ts-config/typescript": "0.1.56",
|
|
20
|
+
"@hg-ts/exception": "0.1.56",
|
|
21
|
+
"@hg-ts/ioc": "0.1.56",
|
|
22
|
+
"@hg-ts/linter": "0.1.56",
|
|
23
|
+
"@hg-ts/tests": "0.1.56",
|
|
24
|
+
"@hg-ts/types": "0.1.56",
|
|
25
25
|
"@types/node": "22.10.6",
|
|
26
26
|
"eslint": "9.18.0",
|
|
27
27
|
"reflect-metadata": "0.2.2",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"typescript": "5.7.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@hg-ts/exception": "0.1.
|
|
34
|
-
"@hg-ts/ioc": "0.1.
|
|
33
|
+
"@hg-ts/exception": "0.1.56",
|
|
34
|
+
"@hg-ts/ioc": "0.1.56",
|
|
35
35
|
"reflect-metadata": "*",
|
|
36
36
|
"tslib": "*"
|
|
37
37
|
}
|
package/.eslintcache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.command-handler.js":"1","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.command.js":"2","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.executor.js":"3","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.executor.test-suite.js":"4","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.query-handler.js":"5","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.query.js":"6","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/index.js":"7","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/command.executor.js":"8","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/index.js":"9","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/query.executor.js":"10","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/handler-already-added.exception.js":"11","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/handler-not-found.exception.js":"12","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/index.js":"13","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/index.js":"14","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/command-executor.mock.js":"15","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/command-executor.test.js":"16","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/query-executor.test.js":"17","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test-command.handler.js":"18","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test-query.handler.js":"19","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test.command.js":"20","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test.query.js":"21","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/types.js":"22","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/eslint.config.mjs":"23","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.command-handler.ts":"24","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.command.ts":"25","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.executor.test-suite.ts":"26","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.executor.ts":"27","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.query-handler.ts":"28","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.query.ts":"29","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/index.ts":"30","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/handler-already-added.exception.ts":"31","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/handler-not-found.exception.ts":"32","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/index.ts":"33","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/index.ts":"34","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/command-executor.test.ts":"35","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/query-executor.test.ts":"36","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/test-command.handler.ts":"37","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/test-query.handler.ts":"38","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/types.ts":"39","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/cqrs.module.js":"40","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/command-handler.decorator.js":"41","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/index.js":"42","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/query-handler.decorator.js":"43","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/command.executor.js":"44","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/index.js":"45","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/query.executor.js":"46","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/index.js":"47","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/test.command.js":"48","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/unknown.command.js":"49","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/cqrs-test.module.js":"50","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/cqrs.module.test.js":"51","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/index.js":"52","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/test.query.js":"53","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/unknown.query.js":"54","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/unknown.command.js":"55","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/unknown.query.js":"56","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/cqrs.module.ts":"57","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/command-handler.decorator.ts":"58","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/index.ts":"59","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/query-handler.decorator.ts":"60","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/command.executor.ts":"61","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/index.ts":"62","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/query.executor.ts":"63","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/index.ts":"64","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/test.command.ts":"65","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/unknown.command.ts":"66","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/cqrs-test.module.ts":"67","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/cqrs.module.test.ts":"68","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/index.ts":"69","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/test.query.ts":"70","/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/unknown.query.ts":"71"},{"size":240,"mtime":1746294769289,"results":"72","hashOfConfig":"73"},{"size":287,"mtime":1746294769276,"results":"74","hashOfConfig":"73"},{"size":874,"mtime":1746294769286,"results":"75","hashOfConfig":"73"},{"size":2757,"mtime":1746294769292,"results":"76","hashOfConfig":"73"},{"size":230,"mtime":1746294769287,"results":"77","hashOfConfig":"73"},{"size":271,"mtime":1746294769277,"results":"78","hashOfConfig":"73"},{"size":576,"mtime":1746294769293,"results":"79","hashOfConfig":"73"},{"size":571,"mtime":1746294464045,"results":"80","hashOfConfig":"73"},{"size":206,"mtime":1746294464045,"results":"81","hashOfConfig":"73"},{"size":549,"mtime":1746294464046,"results":"82","hashOfConfig":"73"},{"size":477,"mtime":1746294769281,"results":"83","hashOfConfig":"73"},{"size":453,"mtime":1746294769283,"results":"84","hashOfConfig":"73"},{"size":294,"mtime":1746294769284,"results":"85","hashOfConfig":"73"},{"size":1453,"mtime":1746294769306,"results":"86","hashOfConfig":"73"},{"size":567,"mtime":1746294464048,"results":"87","hashOfConfig":"73"},{"size":1040,"mtime":1746294769310,"results":"88","hashOfConfig":"73"},{"size":1004,"mtime":1746294769318,"results":"89","hashOfConfig":"73"},{"size":912,"mtime":1746294769309,"results":"90","hashOfConfig":"73"},{"size":885,"mtime":1746294769314,"results":"91","hashOfConfig":"73"},{"size":404,"mtime":1746294464050,"results":"92","hashOfConfig":"73"},{"size":392,"mtime":1746294464050,"results":"93","hashOfConfig":"73"},{"size":110,"mtime":1746294769278,"results":"94","hashOfConfig":"73"},{"size":59,"mtime":1736896000125,"results":"95","hashOfConfig":"73"},{"size":245,"mtime":1746263558362,"results":"96","hashOfConfig":"97"},{"size":171,"mtime":1746263542112,"results":"98","hashOfConfig":"97"},{"size":1962,"mtime":1746263213528,"results":"99","hashOfConfig":"97"},{"size":1399,"mtime":1746262662828,"results":"100","hashOfConfig":"97"},{"size":225,"mtime":1746263554287,"results":"101","hashOfConfig":"97"},{"size":156,"mtime":1746263537127,"results":"102","hashOfConfig":"97"},{"size":250,"mtime":1746263294449,"results":"103","hashOfConfig":"97"},{"size":291,"mtime":1746262067685,"results":"104","hashOfConfig":"97"},{"size":283,"mtime":1746261943966,"results":"105","hashOfConfig":"97"},{"size":98,"mtime":1746263521872,"results":"106","hashOfConfig":"97"},{"size":261,"mtime":1746288959197,"results":"107","hashOfConfig":"97"},{"size":825,"mtime":1746285067767,"results":"108","hashOfConfig":"97"},{"size":789,"mtime":1746285067762,"results":"109","hashOfConfig":"97"},{"size":538,"mtime":1746285574102,"results":"110","hashOfConfig":"97"},{"size":520,"mtime":1746285574108,"results":"111","hashOfConfig":"97"},{"size":886,"mtime":1746261916727,"results":"112","hashOfConfig":"97"},{"size":3963,"mtime":1746294769304,"results":"113","hashOfConfig":"73"},{"size":441,"mtime":1746294769296,"results":"114","hashOfConfig":"73"},{"size":313,"mtime":1746294769298,"results":"115","hashOfConfig":"73"},{"size":421,"mtime":1746294769295,"results":"116","hashOfConfig":"73"},{"size":571,"mtime":1746294769299,"results":"117","hashOfConfig":"73"},{"size":266,"mtime":1746294769301,"results":"118","hashOfConfig":"73"},{"size":549,"mtime":1746294769301,"results":"119","hashOfConfig":"73"},{"size":263,"mtime":1746294769308,"results":"120","hashOfConfig":"73"},{"size":407,"mtime":1746294769308,"results":"121","hashOfConfig":"73"},{"size":422,"mtime":1746294769307,"results":"122","hashOfConfig":"73"},{"size":731,"mtime":1746294769315,"results":"123","hashOfConfig":"73"},{"size":3413,"mtime":1746294769317,"results":"124","hashOfConfig":"73"},{"size":259,"mtime":1746294769312,"results":"125","hashOfConfig":"73"},{"size":395,"mtime":1746294769312,"results":"126","hashOfConfig":"73"},{"size":410,"mtime":1746294769311,"results":"127","hashOfConfig":"73"},{"size":407,"mtime":1746294464051,"results":"128","hashOfConfig":"73"},{"size":395,"mtime":1746294464051,"results":"129","hashOfConfig":"73"},{"size":3051,"mtime":1746289583382,"results":"130","hashOfConfig":"97"},{"size":442,"mtime":1746287683093,"results":"131","hashOfConfig":"97"},{"size":116,"mtime":1746285666289,"results":"132","hashOfConfig":"97"},{"size":412,"mtime":1746285579676,"results":"133","hashOfConfig":"97"},{"size":535,"mtime":1746262677907,"results":"134","hashOfConfig":"97"},{"size":70,"mtime":1746284081547,"results":"135","hashOfConfig":"97"},{"size":507,"mtime":1746262758826,"results":"136","hashOfConfig":"97"},{"size":67,"mtime":1746284988415,"results":"137","hashOfConfig":"97"},{"size":248,"mtime":1746284988413,"results":"138","hashOfConfig":"97"},{"size":251,"mtime":1746284988407,"results":"139","hashOfConfig":"97"},{"size":318,"mtime":1746288559798,"results":"140","hashOfConfig":"97"},{"size":1801,"mtime":1746288959195,"results":"141","hashOfConfig":"97"},{"size":63,"mtime":1746285015683,"results":"142","hashOfConfig":"97"},{"size":242,"mtime":1746285004564,"results":"143","hashOfConfig":"97"},{"size":245,"mtime":1746285004562,"results":"144","hashOfConfig":"97"},{"filePath":"145","messages":"146","suppressedMessages":"147","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1gtnk1i",{"filePath":"148","messages":"149","suppressedMessages":"150","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"151","messages":"152","suppressedMessages":"153","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"154","messages":"155","suppressedMessages":"156","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"157","messages":"158","suppressedMessages":"159","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"160","messages":"161","suppressedMessages":"162","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"163","messages":"164","suppressedMessages":"165","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"166","messages":"167","suppressedMessages":"168","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"169","messages":"170","suppressedMessages":"171","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"172","messages":"173","suppressedMessages":"174","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"175","messages":"176","suppressedMessages":"177","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"178","messages":"179","suppressedMessages":"180","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"181","messages":"182","suppressedMessages":"183","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"184","messages":"185","suppressedMessages":"186","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"187","messages":"188","suppressedMessages":"189","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"190","messages":"191","suppressedMessages":"192","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"193","messages":"194","suppressedMessages":"195","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"196","messages":"197","suppressedMessages":"198","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"199","messages":"200","suppressedMessages":"201","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"202","messages":"203","suppressedMessages":"204","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"205","messages":"206","suppressedMessages":"207","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"208","messages":"209","suppressedMessages":"210","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"211","messages":"212","suppressedMessages":"213","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"214","messages":"215","suppressedMessages":"216","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"i5df87",{"filePath":"217","messages":"218","suppressedMessages":"219","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"220","messages":"221","suppressedMessages":"222","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"223","messages":"224","suppressedMessages":"225","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"226","messages":"227","suppressedMessages":"228","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"229","messages":"230","suppressedMessages":"231","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"232","messages":"233","suppressedMessages":"234","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"235","messages":"236","suppressedMessages":"237","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"238","messages":"239","suppressedMessages":"240","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"241","messages":"242","suppressedMessages":"243","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"244","messages":"245","suppressedMessages":"246","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"247","messages":"248","suppressedMessages":"249","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"250","messages":"251","suppressedMessages":"252","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"253","messages":"254","suppressedMessages":"255","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"256","messages":"257","suppressedMessages":"258","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"259","messages":"260","suppressedMessages":"261","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"262","messages":"263","suppressedMessages":"264","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"265","messages":"266","suppressedMessages":"267","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"268","messages":"269","suppressedMessages":"270","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"271","messages":"272","suppressedMessages":"273","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"274","messages":"275","suppressedMessages":"276","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"277","messages":"278","suppressedMessages":"279","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"280","messages":"281","suppressedMessages":"282","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"283","messages":"284","suppressedMessages":"285","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"286","messages":"287","suppressedMessages":"288","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"289","messages":"290","suppressedMessages":"291","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"292","messages":"293","suppressedMessages":"294","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"295","messages":"296","suppressedMessages":"297","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"298","messages":"299","suppressedMessages":"300","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"301","messages":"302","suppressedMessages":"303","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"304","messages":"305","suppressedMessages":"306","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"307","messages":"308","suppressedMessages":"309","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"310","messages":"311","suppressedMessages":"312","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"313","messages":"314","suppressedMessages":"315","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"316","messages":"317","suppressedMessages":"318","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"319","messages":"320","suppressedMessages":"321","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"322","messages":"323","suppressedMessages":"324","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"325","messages":"326","suppressedMessages":"327","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"328","messages":"329","suppressedMessages":"330","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"331","messages":"332","suppressedMessages":"333","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"334","messages":"335","suppressedMessages":"336","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"337","messages":"338","suppressedMessages":"339","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"340","messages":"341","suppressedMessages":"342","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"343","messages":"344","suppressedMessages":"345","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"346","messages":"347","suppressedMessages":"348","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"349","messages":"350","suppressedMessages":"351","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"352","messages":"353","suppressedMessages":"354","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"355","messages":"356","suppressedMessages":"357","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.command-handler.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.command.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.executor.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.executor.test-suite.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.query-handler.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/base.query.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/abstracts/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/command.executor.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/command/query.executor.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/handler-already-added.exception.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/handler-not-found.exception.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/exceptions/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/command-executor.mock.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/command-executor.test.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/query-executor.test.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test-command.handler.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test-query.handler.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test.command.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/test.query.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/types.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/eslint.config.mjs",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.command-handler.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.command.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.executor.test-suite.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.executor.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.query-handler.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/base.query.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/abstracts/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/handler-already-added.exception.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/handler-not-found.exception.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/exceptions/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/command-executor.test.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/query-executor.test.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/test-command.handler.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/test-query.handler.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/types.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/cqrs.module.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/command-handler.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/decorators/query-handler.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/command.executor.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/executors/query.executor.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/test.command.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/commands/unknown.command.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/cqrs-test.module.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/cqrs.module.test.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/test.query.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/queries/unknown.query.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/unknown.command.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/dist/tests/unknown.query.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/cqrs.module.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/command-handler.decorator.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/decorators/query-handler.decorator.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/command.executor.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/executors/query.executor.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/test.command.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/commands/unknown.command.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/cqrs-test.module.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/cqrs.module.test.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/test.query.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/cqrs/src/tests/queries/unknown.query.ts",[],[]]
|
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
▶ CommandExecutorTest
|
|
3
|
-
[32m✔ successExecute [90m(0.845292ms)[39m[39m
|
|
4
|
-
[32m✔ multipleHandlers [90m(0.278875ms)[39m[39m
|
|
5
|
-
[32m✔ handlerNotFound [90m(0.34375ms)[39m[39m
|
|
6
|
-
[32m✔ successPassException [90m(0.273709ms)[39m[39m
|
|
7
|
-
[32m✔ CommandExecutorTest [90m(2.382958ms)[39m[39m
|
|
8
|
-
▶ QueryExecutorTest
|
|
9
|
-
[32m✔ executorProvides [90m(15.849917ms)[39m[39m
|
|
10
|
-
[32m✔ commandSuccess [90m(5.198ms)[39m[39m
|
|
11
|
-
[32m✔ unknownCommand [90m(3.315417ms)[39m[39m
|
|
12
|
-
[32m✔ querySuccess [90m(2.474917ms)[39m[39m
|
|
13
|
-
[32m✔ unknownQuery [90m(2.500458ms)[39m[39m
|
|
14
|
-
[32m✔ QueryExecutorTest [90m(29.890667ms)[39m[39m
|
|
15
|
-
▶ QueryExecutorTest
|
|
16
|
-
[32m✔ successExecute [90m(0.863958ms)[39m[39m
|
|
17
|
-
[32m✔ multipleHandlers [90m(0.3015ms)[39m[39m
|
|
18
|
-
[32m✔ handlerNotFound [90m(0.388916ms)[39m[39m
|
|
19
|
-
[32m✔ successPassException [90m(0.297917ms)[39m[39m
|
|
20
|
-
[32m✔ QueryExecutorTest [90m(2.576417ms)[39m[39m
|
|
21
|
-
[32m✔ dist/tests/test-command.handler.js [90m(153.538666ms)[39m[39m
|
|
22
|
-
[32m✔ dist/tests/test-query.handler.js [90m(153.399125ms)[39m[39m
|
|
23
|
-
[34mℹ tests 15[39m
|
|
24
|
-
[34mℹ suites 3[39m
|
|
25
|
-
[34mℹ pass 15[39m
|
|
26
|
-
[34mℹ fail 0[39m
|
|
27
|
-
[34mℹ cancelled 0[39m
|
|
28
|
-
[34mℹ skipped 0[39m
|
|
29
|
-
[34mℹ todo 0[39m
|
|
30
|
-
[34mℹ duration_ms 428.092167[39m
|
package/eslint.config.mjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
expect,
|
|
3
|
-
Test,
|
|
4
|
-
Suite,
|
|
5
|
-
ExpectException,
|
|
6
|
-
} from '@hg-ts/tests';
|
|
7
|
-
import { UnknownException } from '@hg-ts/exception';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
HandlerAlreadyAddedException,
|
|
11
|
-
HandlerNotFoundException,
|
|
12
|
-
} from '../exceptions';
|
|
13
|
-
import {
|
|
14
|
-
BaseCommandOrQuery,
|
|
15
|
-
CommonHandler,
|
|
16
|
-
} from '../types';
|
|
17
|
-
import { BaseExecutor } from './base.executor';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const INPUT_FOR_EXCEPTION = 'Some special string that will throw an exception';
|
|
21
|
-
|
|
22
|
-
export abstract class BaseExecutorTestSuite<CommandOrQuery extends BaseCommandOrQuery> extends Suite {
|
|
23
|
-
private executor: BaseExecutor<CommandOrQuery>;
|
|
24
|
-
|
|
25
|
-
@Test()
|
|
26
|
-
public async successExecute(): Promise<void> {
|
|
27
|
-
const expectedResult = String(Math.random());
|
|
28
|
-
|
|
29
|
-
this.executor['addHandler'](this.getCommandOrQueryCtor(), this.getHandler());
|
|
30
|
-
|
|
31
|
-
const result = await this.executor.execute(this.getCommandOrQuery(expectedResult));
|
|
32
|
-
|
|
33
|
-
expect(result).toBe(expectedResult);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@ExpectException(HandlerAlreadyAddedException)
|
|
37
|
-
@Test()
|
|
38
|
-
public async multipleHandlers(): Promise<void> {
|
|
39
|
-
this.executor['addHandler'](this.getCommandOrQueryCtor(), this.getHandler());
|
|
40
|
-
this.executor['addHandler'](this.getCommandOrQueryCtor(), this.getHandler());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@ExpectException(HandlerNotFoundException)
|
|
44
|
-
@Test()
|
|
45
|
-
public async handlerNotFound(): Promise<void> {
|
|
46
|
-
await this.executor.execute(this.getCommandOrQuery(''));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@ExpectException(UnknownException)
|
|
50
|
-
@Test()
|
|
51
|
-
public async successPassException(): Promise<void> {
|
|
52
|
-
this.executor['addHandler'](this.getCommandOrQueryCtor(), this.getHandler());
|
|
53
|
-
await this.executor.execute(this.getCommandOrQuery(INPUT_FOR_EXCEPTION));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public override async beforeEach(): Promise<void> {
|
|
57
|
-
this.executor = this.getExecutor();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
protected abstract getExecutor(): BaseExecutor<CommandOrQuery>;
|
|
61
|
-
protected abstract getHandler(): CommonHandler<CommandOrQuery>;
|
|
62
|
-
protected abstract getCommandOrQueryCtor(): Class<CommandOrQuery, [string]>;
|
|
63
|
-
protected abstract getCommandOrQuery(input: string): CommandOrQuery;
|
|
64
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import {
|
|
3
|
-
HandlerAlreadyAddedException,
|
|
4
|
-
HandlerNotFoundException,
|
|
5
|
-
} from '../exceptions';
|
|
6
|
-
import {
|
|
7
|
-
CommonHandler,
|
|
8
|
-
CommonResult,
|
|
9
|
-
} from '../types';
|
|
10
|
-
|
|
11
|
-
import { BaseCommand } from './base.command';
|
|
12
|
-
import { BaseQuery } from './base.query';
|
|
13
|
-
|
|
14
|
-
export abstract class BaseExecutor<
|
|
15
|
-
BaseCommandOrQuery extends BaseQuery<any> | BaseCommand<any>
|
|
16
|
-
> {
|
|
17
|
-
protected readonly handlers = new Map<Class<BaseCommandOrQuery>, CommonHandler<BaseCommandOrQuery>>();
|
|
18
|
-
|
|
19
|
-
public async execute<CommandOrQuery extends BaseCommandOrQuery>(
|
|
20
|
-
commandOrQuery: CommandOrQuery,
|
|
21
|
-
): Promise<CommonResult<CommandOrQuery>> {
|
|
22
|
-
return this.executeHandler(commandOrQuery);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected addHandler<CommandOrQuery extends BaseCommandOrQuery>(
|
|
26
|
-
command: Class<CommandOrQuery, any[]>,
|
|
27
|
-
handler: CommonHandler<BaseCommandOrQuery>,
|
|
28
|
-
): void {
|
|
29
|
-
const existHandler = this.handlers.get(command);
|
|
30
|
-
|
|
31
|
-
assert.ok(!existHandler, new HandlerAlreadyAddedException(command));
|
|
32
|
-
|
|
33
|
-
this.handlers.set(command, handler);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected assertHandler(
|
|
37
|
-
handler: Nullable<CommonHandler<BaseCommandOrQuery>>,
|
|
38
|
-
commandOrQuery: Class<BaseCommandOrQuery, any[]>,
|
|
39
|
-
): asserts handler {
|
|
40
|
-
assert.ok(handler, new HandlerNotFoundException(commandOrQuery));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
protected abstract executeHandler<CommandOrQuery extends BaseCommandOrQuery>(
|
|
44
|
-
commandOrQuery: CommandOrQuery,
|
|
45
|
-
): Promise<CommonResult<CommandOrQuery>>;
|
|
46
|
-
}
|
package/src/abstracts/index.ts
DELETED
package/src/cqrs.module.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { WillNeverHappenedException } from '@hg-ts/exception';
|
|
2
|
-
import {
|
|
3
|
-
Dependency,
|
|
4
|
-
DiscoveryService,
|
|
5
|
-
INIT_HOOK,
|
|
6
|
-
Module,
|
|
7
|
-
} from '@hg-ts/ioc';
|
|
8
|
-
import assert from 'node:assert/strict';
|
|
9
|
-
import {
|
|
10
|
-
BaseCommand,
|
|
11
|
-
BaseCommandHandler,
|
|
12
|
-
BaseQuery,
|
|
13
|
-
BaseQueryHandler,
|
|
14
|
-
} from './abstracts';
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
COMMAND_HANDLER_METADATA,
|
|
18
|
-
QUERY_HANDLER_METADATA,
|
|
19
|
-
} from './decorators';
|
|
20
|
-
import {
|
|
21
|
-
CommandExecutor,
|
|
22
|
-
QueryExecutor,
|
|
23
|
-
} from './executors';
|
|
24
|
-
|
|
25
|
-
@Module({
|
|
26
|
-
providers: [
|
|
27
|
-
CommandExecutor,
|
|
28
|
-
QueryExecutor,
|
|
29
|
-
],
|
|
30
|
-
exports: [
|
|
31
|
-
CommandExecutor,
|
|
32
|
-
QueryExecutor,
|
|
33
|
-
],
|
|
34
|
-
discovery: true,
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
export class CqrsModule {
|
|
38
|
-
@Dependency()
|
|
39
|
-
private readonly discoveryService: DiscoveryService;
|
|
40
|
-
|
|
41
|
-
@Dependency()
|
|
42
|
-
private readonly commandExecutor: CommandExecutor;
|
|
43
|
-
|
|
44
|
-
@Dependency()
|
|
45
|
-
private readonly queryExecutor: QueryExecutor;
|
|
46
|
-
|
|
47
|
-
public async [INIT_HOOK](): Promise<void> {
|
|
48
|
-
const providers = this.discoveryService.getProviders()
|
|
49
|
-
.filter(wrapper => wrapper.instance)
|
|
50
|
-
.map(wrapper => wrapper.instance);
|
|
51
|
-
|
|
52
|
-
providers.forEach(provider => {
|
|
53
|
-
const handlerCtor = Object.getPrototypeOf(provider)!.constructor;
|
|
54
|
-
|
|
55
|
-
const isCommandHandler = this.isCommandHandler(provider);
|
|
56
|
-
const isQueryHandler = this.isQueryHandler(provider);
|
|
57
|
-
|
|
58
|
-
const commandMetadata = this.getCommandMetadata(handlerCtor);
|
|
59
|
-
const queryMetadata = this.getQueryMetadata(handlerCtor);
|
|
60
|
-
|
|
61
|
-
if (isCommandHandler && commandMetadata) {
|
|
62
|
-
this.commandExecutor['addHandler'](commandMetadata, provider);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (isCommandHandler) {
|
|
67
|
-
throw new WillNeverHappenedException('Command handler instance provided without CommandHandler decorator');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (commandMetadata) {
|
|
71
|
-
throw new WillNeverHappenedException('CommandHandler decorate class that does not extended BaseCommandHandler');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isQueryHandler && queryMetadata) {
|
|
75
|
-
this.queryExecutor['addHandler'](queryMetadata, provider);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (isQueryHandler) {
|
|
80
|
-
throw new WillNeverHappenedException('Query handler instance provided without QueryHandler decorator');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (queryMetadata) {
|
|
84
|
-
throw new WillNeverHappenedException('QueryHandler decorate class that does not extended BaseQueryHandler');
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private getCommandMetadata(handlerCtor: Class<any, any[]>): Nullable<Class<BaseCommand, any[]>> {
|
|
90
|
-
const metadata = Reflect.getMetadata(COMMAND_HANDLER_METADATA, handlerCtor);
|
|
91
|
-
|
|
92
|
-
if (!metadata) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
assert.ok(metadata.prototype instanceof BaseCommand);
|
|
97
|
-
|
|
98
|
-
return metadata;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private getQueryMetadata(handlerCtor: Class<any, any[]>): Nullable<Class<BaseQuery<any>, any[]>> {
|
|
102
|
-
const metadata = Reflect.getMetadata(QUERY_HANDLER_METADATA, handlerCtor);
|
|
103
|
-
|
|
104
|
-
if (!metadata) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
assert.ok(metadata.prototype instanceof BaseQuery);
|
|
109
|
-
|
|
110
|
-
return metadata;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private isCommandHandler(provider: any): provider is BaseCommandHandler<BaseCommand<any>> {
|
|
114
|
-
return provider instanceof BaseCommandHandler;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private isQueryHandler(provider: any): provider is BaseQueryHandler<BaseQuery<any>> {
|
|
118
|
-
return provider instanceof BaseQueryHandler;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseCommand,
|
|
3
|
-
BaseCommandHandler,
|
|
4
|
-
} from '../abstracts';
|
|
5
|
-
|
|
6
|
-
export const COMMAND_HANDLER_METADATA = Symbol('COMMAND_HANDLER_METADATA');
|
|
7
|
-
|
|
8
|
-
export function CommandHandler<Command extends BaseCommand<any>>(
|
|
9
|
-
commandCtor: Class<Command, any[]>,
|
|
10
|
-
): TypedClassDecorator<Class<BaseCommandHandler<Command>>> {
|
|
11
|
-
return (ctor: Class<BaseCommandHandler<Command>>) => {
|
|
12
|
-
Reflect.defineMetadata(COMMAND_HANDLER_METADATA, commandCtor, ctor);
|
|
13
|
-
};
|
|
14
|
-
}
|
package/src/decorators/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseQuery,
|
|
3
|
-
BaseQueryHandler,
|
|
4
|
-
} from '../abstracts';
|
|
5
|
-
|
|
6
|
-
export const QUERY_HANDLER_METADATA = Symbol('QUERY_HANDLER_METADATA');
|
|
7
|
-
|
|
8
|
-
export function QueryHandler<Query extends BaseQuery<any>>(
|
|
9
|
-
queryCtor: Class<Query, any[]>,
|
|
10
|
-
): TypedClassDecorator<Class<BaseQueryHandler<Query>>> {
|
|
11
|
-
return (ctor: Class<BaseQueryHandler<Query>>) => {
|
|
12
|
-
Reflect.defineMetadata(QUERY_HANDLER_METADATA, queryCtor, ctor);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseException } from '@hg-ts/exception';
|
|
2
|
-
import { BaseCommandOrQuery } from '../types';
|
|
3
|
-
|
|
4
|
-
export class HandlerAlreadyAddedException extends BaseException {
|
|
5
|
-
public constructor(command: Class<BaseCommandOrQuery>) {
|
|
6
|
-
super(`Handler for command "${command.name}" already added`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseException } from '@hg-ts/exception';
|
|
2
|
-
import { BaseCommandOrQuery } from '../types';
|
|
3
|
-
|
|
4
|
-
export class HandlerNotFoundException extends BaseException {
|
|
5
|
-
public constructor(command: Class<BaseCommandOrQuery>) {
|
|
6
|
-
super(`Handler for command "${command.name}" not found`);
|
|
7
|
-
}
|
|
8
|
-
}
|
package/src/exceptions/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseCommand,
|
|
3
|
-
BaseExecutor,
|
|
4
|
-
} from '../abstracts';
|
|
5
|
-
import { CommonResult } from '../types';
|
|
6
|
-
|
|
7
|
-
export class CommandExecutor extends BaseExecutor<BaseCommand<any>> {
|
|
8
|
-
protected override async executeHandler<Command extends BaseCommand<any>>(
|
|
9
|
-
command: Command,
|
|
10
|
-
): Promise<CommonResult<Command>> {
|
|
11
|
-
const commandCtor = Object.getPrototypeOf(command)!.constructor as Class<Command>;
|
|
12
|
-
const handler = this.handlers.get(commandCtor) ?? null;
|
|
13
|
-
|
|
14
|
-
this.assertHandler(handler, commandCtor);
|
|
15
|
-
|
|
16
|
-
return handler.execute(command);
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/executors/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseQuery,
|
|
3
|
-
BaseExecutor,
|
|
4
|
-
} from '../abstracts';
|
|
5
|
-
import { CommonResult } from '../types';
|
|
6
|
-
|
|
7
|
-
export class QueryExecutor extends BaseExecutor<BaseQuery<any>> {
|
|
8
|
-
protected override async executeHandler<Query extends BaseQuery<any>>(
|
|
9
|
-
query: Query,
|
|
10
|
-
): Promise<CommonResult<Query>> {
|
|
11
|
-
const queryCtor = Object.getPrototypeOf(query)!.constructor as Class<Query>;
|
|
12
|
-
const handler = this.handlers.get(queryCtor) ?? null;
|
|
13
|
-
|
|
14
|
-
this.assertHandler(handler, queryCtor);
|
|
15
|
-
|
|
16
|
-
return handler.execute(query);
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
BaseQuery,
|
|
3
|
-
BaseQueryHandler,
|
|
4
|
-
BaseCommand,
|
|
5
|
-
BaseCommandHandler,
|
|
6
|
-
} from './abstracts';
|
|
7
|
-
export * from './exceptions';
|
|
8
|
-
export * from './executors';
|
|
9
|
-
export { CommandHandler, QueryHandler } from './decorators';
|
|
10
|
-
export { CqrsModule } from './cqrs.module';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Describe } from '@hg-ts/tests';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BaseCommand,
|
|
5
|
-
BaseCommandHandler,
|
|
6
|
-
BaseExecutor,
|
|
7
|
-
BaseExecutorTestSuite,
|
|
8
|
-
} from '../abstracts';
|
|
9
|
-
import { CommandExecutor } from '../executors';
|
|
10
|
-
import { TestCommand } from './commands';
|
|
11
|
-
|
|
12
|
-
import { TestCommandHandler } from './test-command.handler';
|
|
13
|
-
|
|
14
|
-
@Describe()
|
|
15
|
-
export class CommandExecutorTest extends BaseExecutorTestSuite<BaseCommand<any>> {
|
|
16
|
-
protected override getCommandOrQuery(input: string): TestCommand {
|
|
17
|
-
return new TestCommand(input);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
protected override getExecutor(): BaseExecutor<BaseCommand<any>> {
|
|
21
|
-
return new CommandExecutor();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
protected override getHandler(): BaseCommandHandler<BaseCommand<any>> {
|
|
25
|
-
return new TestCommandHandler();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
protected override getCommandOrQueryCtor(): Class<BaseCommand<any>, [string]> {
|
|
29
|
-
return TestCommand;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '../../abstracts';
|
|
2
|
-
|
|
3
|
-
export class TestCommand extends BaseCommand<string> {
|
|
4
|
-
public readonly expectedResult: string;
|
|
5
|
-
|
|
6
|
-
public constructor(expectedResult: string) {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this.expectedResult = expectedResult;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '../../abstracts';
|
|
2
|
-
|
|
3
|
-
export class UnknownCommand extends BaseCommand<string> {
|
|
4
|
-
public readonly expectedResult: string;
|
|
5
|
-
|
|
6
|
-
public constructor(expectedResult: string) {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this.expectedResult = expectedResult;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Module } from '@hg-ts/ioc';
|
|
2
|
-
import { CqrsModule } from '../cqrs.module';
|
|
3
|
-
import { TestCommandHandler } from './test-command.handler';
|
|
4
|
-
import { TestQueryHandler } from './test-query.handler';
|
|
5
|
-
|
|
6
|
-
@Module({ imports: [CqrsModule], providers: [TestCommandHandler, TestQueryHandler] })
|
|
7
|
-
export class CqrsTestModule {}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { TestContainer } from '@hg-ts/ioc';
|
|
2
|
-
import {
|
|
3
|
-
Describe,
|
|
4
|
-
expect,
|
|
5
|
-
ExpectException,
|
|
6
|
-
Suite,
|
|
7
|
-
Test,
|
|
8
|
-
} from '@hg-ts/tests';
|
|
9
|
-
|
|
10
|
-
import { HandlerNotFoundException } from '../exceptions';
|
|
11
|
-
import {
|
|
12
|
-
CommandExecutor,
|
|
13
|
-
QueryExecutor,
|
|
14
|
-
} from '../executors';
|
|
15
|
-
import {
|
|
16
|
-
TestCommand,
|
|
17
|
-
UnknownCommand,
|
|
18
|
-
} from './commands';
|
|
19
|
-
import { CqrsTestModule } from './cqrs-test.module';
|
|
20
|
-
import {
|
|
21
|
-
TestQuery,
|
|
22
|
-
UnknownQuery,
|
|
23
|
-
} from './queries';
|
|
24
|
-
|
|
25
|
-
@Describe()
|
|
26
|
-
export class QueryExecutorTest extends Suite {
|
|
27
|
-
private container: TestContainer;
|
|
28
|
-
private commandExecutor: CommandExecutor;
|
|
29
|
-
private queryExecutor: QueryExecutor;
|
|
30
|
-
|
|
31
|
-
@Test()
|
|
32
|
-
public async executorProvides(): Promise<void> {
|
|
33
|
-
expect(this.commandExecutor).toBeInstanceOf(CommandExecutor);
|
|
34
|
-
expect(this.queryExecutor).toBeInstanceOf(QueryExecutor);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Test()
|
|
38
|
-
public async commandSuccess(): Promise<void> {
|
|
39
|
-
const value = String(Math.random());
|
|
40
|
-
const result = await this.commandExecutor.execute(new TestCommand(value));
|
|
41
|
-
|
|
42
|
-
expect(result).toBe(value);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Test()
|
|
46
|
-
@ExpectException(HandlerNotFoundException)
|
|
47
|
-
public async unknownCommand(): Promise<void> {
|
|
48
|
-
await this.commandExecutor.execute(new UnknownCommand(''));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Test()
|
|
52
|
-
public async querySuccess(): Promise<void> {
|
|
53
|
-
const value = String(Math.random());
|
|
54
|
-
const result = await this.queryExecutor.execute(new TestQuery(value));
|
|
55
|
-
|
|
56
|
-
expect(result).toBe(value);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Test()
|
|
60
|
-
@ExpectException(HandlerNotFoundException)
|
|
61
|
-
public async unknownQuery(): Promise<void> {
|
|
62
|
-
await this.queryExecutor.execute(new UnknownQuery(''));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public override async beforeEach(): Promise<void> {
|
|
66
|
-
this.container = await TestContainer.create(CqrsTestModule);
|
|
67
|
-
|
|
68
|
-
await this.container.init();
|
|
69
|
-
|
|
70
|
-
this.queryExecutor = this.container.get(QueryExecutor);
|
|
71
|
-
this.commandExecutor = this.container.get(CommandExecutor);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Describe } from '@hg-ts/tests';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BaseExecutor,
|
|
5
|
-
BaseExecutorTestSuite,
|
|
6
|
-
BaseQuery,
|
|
7
|
-
BaseQueryHandler,
|
|
8
|
-
} from '../abstracts';
|
|
9
|
-
import { QueryExecutor } from '../executors';
|
|
10
|
-
import { TestQuery } from './queries';
|
|
11
|
-
import { TestQueryHandler } from './test-query.handler';
|
|
12
|
-
|
|
13
|
-
@Describe()
|
|
14
|
-
export class QueryExecutorTest extends BaseExecutorTestSuite<BaseQuery<any>> {
|
|
15
|
-
protected override getCommandOrQuery(input: string): TestQuery {
|
|
16
|
-
return new TestQuery(input);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected override getExecutor(): BaseExecutor<BaseQuery<any>> {
|
|
20
|
-
return new QueryExecutor();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
protected override getHandler(): BaseQueryHandler<BaseQuery<any>> {
|
|
24
|
-
return new TestQueryHandler();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
protected override getCommandOrQueryCtor(): Class<BaseQuery<any>, [string]> {
|
|
28
|
-
return TestQuery;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { UnknownException } from '@hg-ts/exception';
|
|
2
|
-
import {
|
|
3
|
-
BaseCommandHandler,
|
|
4
|
-
INPUT_FOR_EXCEPTION,
|
|
5
|
-
} from '../abstracts';
|
|
6
|
-
import { CommandHandler } from '../decorators';
|
|
7
|
-
import { TestCommand } from './commands';
|
|
8
|
-
|
|
9
|
-
@CommandHandler(TestCommand)
|
|
10
|
-
export class TestCommandHandler extends BaseCommandHandler<TestCommand> {
|
|
11
|
-
public async execute(command: TestCommand): Promise<string> {
|
|
12
|
-
if (command.expectedResult === INPUT_FOR_EXCEPTION) {
|
|
13
|
-
throw new UnknownException(command.expectedResult);
|
|
14
|
-
}
|
|
15
|
-
return command.expectedResult;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { UnknownException } from '@hg-ts/exception';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BaseQueryHandler,
|
|
5
|
-
INPUT_FOR_EXCEPTION,
|
|
6
|
-
} from '../abstracts';
|
|
7
|
-
import { QueryHandler } from '../decorators';
|
|
8
|
-
import { TestQuery } from './queries';
|
|
9
|
-
|
|
10
|
-
@QueryHandler(TestQuery)
|
|
11
|
-
export class TestQueryHandler extends BaseQueryHandler<TestQuery> {
|
|
12
|
-
public async execute(command: TestQuery): Promise<string> {
|
|
13
|
-
if (command.expectedResult === INPUT_FOR_EXCEPTION) {
|
|
14
|
-
throw new UnknownException(command.expectedResult);
|
|
15
|
-
}
|
|
16
|
-
return command.expectedResult;
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseQuery,
|
|
3
|
-
BaseCommand,
|
|
4
|
-
BaseQueryHandler,
|
|
5
|
-
BaseCommandHandler,
|
|
6
|
-
} from './abstracts';
|
|
7
|
-
|
|
8
|
-
export type CommandResult<Command extends BaseCommand<any>> = Command extends BaseCommand<infer Result>
|
|
9
|
-
? Result
|
|
10
|
-
: never;
|
|
11
|
-
export type QueryResult<Command extends BaseQuery<any>> = Command extends BaseQuery<infer Result>
|
|
12
|
-
? Result
|
|
13
|
-
: never;
|
|
14
|
-
|
|
15
|
-
export type BaseCommandOrQuery = BaseQuery<any> | BaseCommand<any>;
|
|
16
|
-
|
|
17
|
-
export type CommonHandler<CommandOrQuery extends BaseCommandOrQuery> =
|
|
18
|
-
CommandOrQuery extends BaseQuery<any>
|
|
19
|
-
? BaseQueryHandler<CommandOrQuery>
|
|
20
|
-
: CommandOrQuery extends BaseCommand<any>
|
|
21
|
-
? BaseCommandHandler<CommandOrQuery>
|
|
22
|
-
: never;
|
|
23
|
-
|
|
24
|
-
export type CommonResult<CommandOrQuery extends BaseCommandOrQuery> =
|
|
25
|
-
CommandOrQuery extends BaseQuery<any>
|
|
26
|
-
? QueryResult<CommandOrQuery>
|
|
27
|
-
: CommandOrQuery extends BaseCommand<any>
|
|
28
|
-
? CommandResult<CommandOrQuery>
|
|
29
|
-
: never;
|