@quanticjs/core 1.1.1 → 2.1.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/dist/QuanticCoreModule.d.ts +4 -0
- package/dist/QuanticCoreModule.js +53 -0
- package/dist/cqrs/behaviors/LogBehavior.d.ts +4 -1
- package/dist/cqrs/behaviors/LogBehavior.js +3 -0
- package/dist/cqrs/behaviors/TransactionalBehavior.d.ts +4 -11
- package/dist/cqrs/behaviors/TransactionalBehavior.js +3 -12
- package/dist/cqrs/behaviors/ValidationBehavior.d.ts +4 -1
- package/dist/cqrs/behaviors/ValidationBehavior.js +3 -0
- package/dist/cqrs/pipeline/QuanticCommandBus.d.ts +3 -28
- package/dist/cqrs/pipeline/QuanticCommandBus.js +11 -59
- package/dist/cqrs/pipeline/QuanticQueryBus.d.ts +3 -19
- package/dist/cqrs/pipeline/QuanticQueryBus.js +11 -38
- package/dist/cqrs/pipeline/behavior-order.d.ts +11 -0
- package/dist/cqrs/pipeline/behavior-order.js +14 -0
- package/dist/cqrs/pipeline/types.d.ts +8 -0
- package/dist/cqrs/pipeline/types.js +4 -0
- package/dist/index.d.ts +6 -22
- package/dist/index.js +13 -44
- package/package.json +26 -80
- package/dist/cqrs/PipelineExecutor.d.ts +0 -31
- package/dist/cqrs/PipelineExecutor.js +0 -81
- package/dist/cqrs/behaviors/CacheBehavior.d.ts +0 -9
- package/dist/cqrs/behaviors/CacheBehavior.js +0 -68
- package/dist/cqrs/behaviors/DistributedLockBehavior.d.ts +0 -12
- package/dist/cqrs/behaviors/DistributedLockBehavior.js +0 -90
- package/dist/cqrs/behaviors/FeatureFlagBehavior.d.ts +0 -8
- package/dist/cqrs/behaviors/FeatureFlagBehavior.js +0 -58
- package/dist/cqrs/behaviors/InvalidateCacheBehavior.d.ts +0 -9
- package/dist/cqrs/behaviors/InvalidateCacheBehavior.js +0 -61
- package/dist/cqrs/behaviors/PerformanceBehavior.d.ts +0 -12
- package/dist/cqrs/behaviors/PerformanceBehavior.js +0 -56
- package/dist/cqrs/behaviors/WorkflowBehavior.d.ts +0 -8
- package/dist/cqrs/behaviors/WorkflowBehavior.js +0 -61
- package/dist/events/DomainEvent.d.ts +0 -14
- package/dist/events/DomainEvent.js +0 -27
- package/dist/events/OutboxEvent.entity.d.ts +0 -18
- package/dist/events/OutboxEvent.entity.js +0 -87
- package/dist/events/OutboxPublisherService.d.ts +0 -14
- package/dist/events/OutboxPublisherService.js +0 -104
- package/dist/events/RedisStreamConsumer.d.ts +0 -43
- package/dist/events/RedisStreamConsumer.js +0 -158
- package/dist/events/RedisStreamPublisher.d.ts +0 -9
- package/dist/events/RedisStreamPublisher.js +0 -60
- package/dist/metrics/MetricsController.d.ts +0 -7
- package/dist/metrics/MetricsController.js +0 -42
- package/dist/metrics/MetricsService.d.ts +0 -13
- package/dist/metrics/MetricsService.js +0 -58
- package/dist/redis/redis.module.d.ts +0 -8
- package/dist/redis/redis.module.js +0 -49
- package/dist/shared-kernel.module.d.ts +0 -13
- package/dist/shared-kernel.module.js +0 -87
- package/dist/testing/TestingModuleFactory.d.ts +0 -23
- package/dist/testing/TestingModuleFactory.js +0 -63
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.js +0 -7
- package/dist/unleash/initial-flags.d.ts +0 -7
- package/dist/unleash/initial-flags.js +0 -9
- package/dist/unleash/unleash.module.d.ts +0 -9
- package/dist/unleash/unleash.module.js +0 -47
- package/src/bootstrap/bootstrapService.ts +0 -72
- package/src/cqrs/behaviors/CacheBehavior.spec.ts +0 -63
- package/src/cqrs/behaviors/CacheBehavior.ts +0 -54
- package/src/cqrs/behaviors/DistributedLockBehavior.ts +0 -88
- package/src/cqrs/behaviors/FeatureFlagBehavior.ts +0 -46
- package/src/cqrs/behaviors/InvalidateCacheBehavior.spec.ts +0 -89
- package/src/cqrs/behaviors/InvalidateCacheBehavior.ts +0 -50
- package/src/cqrs/behaviors/LogBehavior.spec.ts +0 -55
- package/src/cqrs/behaviors/LogBehavior.ts +0 -121
- package/src/cqrs/behaviors/PerformanceBehavior.spec.ts +0 -48
- package/src/cqrs/behaviors/PerformanceBehavior.ts +0 -43
- package/src/cqrs/behaviors/TransactionalBehavior.ts +0 -64
- package/src/cqrs/behaviors/ValidationBehavior.spec.ts +0 -114
- package/src/cqrs/behaviors/ValidationBehavior.ts +0 -29
- package/src/cqrs/behaviors/WorkflowBehavior.spec.ts +0 -97
- package/src/cqrs/behaviors/WorkflowBehavior.ts +0 -62
- package/src/cqrs/constants.ts +0 -2
- package/src/cqrs/decorators/Cache.decorator.ts +0 -24
- package/src/cqrs/decorators/DistributedLock.decorator.ts +0 -34
- package/src/cqrs/decorators/FeatureFlag.decorator.ts +0 -23
- package/src/cqrs/decorators/InvalidateCache.decorator.spec.ts +0 -20
- package/src/cqrs/decorators/InvalidateCache.decorator.ts +0 -17
- package/src/cqrs/decorators/IsolatedTransaction.decorator.ts +0 -24
- package/src/cqrs/decorators/Log.decorator.ts +0 -22
- package/src/cqrs/decorators/Validate.decorator.ts +0 -39
- package/src/cqrs/decorators/Workflow.decorator.ts +0 -22
- package/src/cqrs/interfaces/WorkflowEngine.ts +0 -19
- package/src/cqrs/pipeline/QuanticCommandBus.ts +0 -69
- package/src/cqrs/pipeline/QuanticQueryBus.ts +0 -56
- package/src/cqrs/pipeline/runPipeline.ts +0 -22
- package/src/cqrs/transaction/TransactionContext.ts +0 -26
- package/src/cqrs/transaction/getTransactionalRepo.ts +0 -23
- package/src/cqrs/validation/ICommandValidator.ts +0 -55
- package/src/entities/BaseEntity.ts +0 -16
- package/src/entities/TenantBaseEntity.ts +0 -7
- package/src/events/DomainEvent.ts +0 -27
- package/src/events/OutboxEvent.entity.ts +0 -56
- package/src/events/OutboxPublisherService.ts +0 -94
- package/src/events/RedisStreamConsumer.ts +0 -172
- package/src/events/RedisStreamPublisher.ts +0 -54
- package/src/filters/GlobalExceptionFilter.ts +0 -125
- package/src/guards/JwtAuthGuard.ts +0 -29
- package/src/guards/JwtStrategy.ts +0 -41
- package/src/guards/RolesGuard.ts +0 -39
- package/src/index.ts +0 -118
- package/src/interceptors/ResultInterceptor.ts +0 -93
- package/src/lifecycle/GracefulShutdownService.ts +0 -77
- package/src/logging/pino-config.ts +0 -80
- package/src/metrics/MetricsController.ts +0 -17
- package/src/metrics/MetricsService.ts +0 -55
- package/src/middleware/CorrelationIdMiddleware.ts +0 -27
- package/src/middleware/CorrelationStore.ts +0 -13
- package/src/middleware/TenantContextMiddleware.ts +0 -21
- package/src/middleware/TenantStore.ts +0 -11
- package/src/redis/redis.module.ts +0 -41
- package/src/resilience/CircuitBreakerFactory.ts +0 -33
- package/src/result/Result.ts +0 -66
- package/src/shared-kernel.module.ts +0 -87
- package/src/subscribers/TenantSubscriber.ts +0 -47
- package/src/testing/TestingModuleFactory.ts +0 -78
- package/src/testing/index.ts +0 -2
- package/src/testing/mocks.ts +0 -59
- package/src/unleash/unleash.module.ts +0 -45
- package/tsconfig.json +0 -22
package/package.json
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quanticjs/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "NestJS CQRS framework — Result<T>, pipeline behaviors, base entities,
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "NestJS CQRS framework — Result<T>, pipeline behaviors, base entities, middleware, guards",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"src",
|
|
10
|
-
"tsconfig.json"
|
|
8
|
+
"dist"
|
|
11
9
|
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/quanticjs/quanticjs-backend.git"
|
|
15
|
-
},
|
|
16
10
|
"publishConfig": {
|
|
17
11
|
"registry": "https://registry.npmjs.org",
|
|
18
12
|
"access": "public"
|
|
@@ -20,8 +14,8 @@
|
|
|
20
14
|
"license": "MIT",
|
|
21
15
|
"scripts": {
|
|
22
16
|
"build": "tsc -p tsconfig.json",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
17
|
+
"test": "jest --passWithNoTests",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
25
19
|
},
|
|
26
20
|
"dependencies": {
|
|
27
21
|
"cockatiel": "^3.2.1",
|
|
@@ -30,12 +24,13 @@
|
|
|
30
24
|
},
|
|
31
25
|
"peerDependencies": {
|
|
32
26
|
"@nestjs/common": "^11.0.0",
|
|
27
|
+
"@nestjs/core": "^11.0.0",
|
|
28
|
+
"@nestjs/cqrs": "^11.0.3",
|
|
33
29
|
"@nestjs/passport": "^11.0.0",
|
|
34
30
|
"@nestjs/swagger": "^11.0.0",
|
|
35
|
-
"@nestjs/terminus": "^11.0.0",
|
|
36
31
|
"@nestjs/throttler": "^6.0.0",
|
|
32
|
+
"cookie-parser": "^1.4.0",
|
|
37
33
|
"helmet": "^8.0.0",
|
|
38
|
-
"ioredis": "^5.0.0",
|
|
39
34
|
"jwks-rsa": "^4.0.0",
|
|
40
35
|
"nestjs-pino": "^4.0.0",
|
|
41
36
|
"passport": "^0.7.0",
|
|
@@ -43,98 +38,49 @@
|
|
|
43
38
|
"pino": "^10.0.0",
|
|
44
39
|
"pino-http": "^11.0.0",
|
|
45
40
|
"pino-seq": "^3.0.0 || ^4.0.0",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
41
|
+
"reflect-metadata": ">=0.1.0",
|
|
42
|
+
"rxjs": "^7.0.0",
|
|
43
|
+
"typeorm": "^0.3.20"
|
|
49
44
|
},
|
|
50
45
|
"peerDependenciesMeta": {
|
|
51
|
-
"@nestjs/common": {
|
|
52
|
-
"optional": false
|
|
53
|
-
},
|
|
54
46
|
"@nestjs/passport": {
|
|
55
|
-
"optional":
|
|
47
|
+
"optional": true
|
|
56
48
|
},
|
|
57
49
|
"@nestjs/swagger": {
|
|
58
|
-
"optional":
|
|
59
|
-
},
|
|
60
|
-
"@nestjs/terminus": {
|
|
61
|
-
"optional": false
|
|
50
|
+
"optional": true
|
|
62
51
|
},
|
|
63
52
|
"@nestjs/throttler": {
|
|
64
|
-
"optional":
|
|
53
|
+
"optional": true
|
|
65
54
|
},
|
|
66
|
-
"
|
|
67
|
-
"optional":
|
|
55
|
+
"cookie-parser": {
|
|
56
|
+
"optional": true
|
|
68
57
|
},
|
|
69
|
-
"
|
|
70
|
-
"optional":
|
|
58
|
+
"helmet": {
|
|
59
|
+
"optional": true
|
|
71
60
|
},
|
|
72
61
|
"jwks-rsa": {
|
|
73
|
-
"optional":
|
|
62
|
+
"optional": true
|
|
74
63
|
},
|
|
75
64
|
"nestjs-pino": {
|
|
76
|
-
"optional":
|
|
65
|
+
"optional": true
|
|
77
66
|
},
|
|
78
67
|
"passport": {
|
|
79
|
-
"optional":
|
|
68
|
+
"optional": true
|
|
80
69
|
},
|
|
81
70
|
"passport-jwt": {
|
|
82
|
-
"optional":
|
|
71
|
+
"optional": true
|
|
83
72
|
},
|
|
84
73
|
"pino": {
|
|
85
|
-
"optional":
|
|
74
|
+
"optional": true
|
|
86
75
|
},
|
|
87
76
|
"pino-http": {
|
|
88
|
-
"optional":
|
|
77
|
+
"optional": true
|
|
89
78
|
},
|
|
90
79
|
"pino-seq": {
|
|
91
|
-
"optional":
|
|
92
|
-
},
|
|
93
|
-
"prom-client": {
|
|
94
|
-
"optional": false
|
|
80
|
+
"optional": true
|
|
95
81
|
},
|
|
96
82
|
"typeorm": {
|
|
97
|
-
"optional":
|
|
98
|
-
},
|
|
99
|
-
"unleash-client": {
|
|
100
|
-
"optional": false
|
|
83
|
+
"optional": true
|
|
101
84
|
}
|
|
102
|
-
},
|
|
103
|
-
"devDependencies": {
|
|
104
|
-
"@nestjs/common": "^11.1.19",
|
|
105
|
-
"@nestjs/core": "^11.1.19",
|
|
106
|
-
"@nestjs/cqrs": "^11.0.3",
|
|
107
|
-
"@nestjs/swagger": "^11.4.2",
|
|
108
|
-
"@nestjs/terminus": "^11.1.1",
|
|
109
|
-
"@nestjs/testing": "^11.1.19",
|
|
110
|
-
"@nestjs/throttler": "^6.5.0",
|
|
111
|
-
"@nestjs/typeorm": "^11.0.1",
|
|
112
|
-
"@types/cookie-parser": "^1.4.10",
|
|
113
|
-
"@types/express": "^5.0.6",
|
|
114
|
-
"@types/jest": "^29.5.0",
|
|
115
|
-
"@types/passport-jwt": "^4.0.1",
|
|
116
|
-
"@types/node": "^22.0.0",
|
|
117
|
-
"@types/uuid": "^10.0.0",
|
|
118
|
-
"cookie-parser": "^1.4.7",
|
|
119
|
-
"@nestjs/passport": "^11.0.5",
|
|
120
|
-
"eslint": "^9.0.0",
|
|
121
|
-
"express": "^5.2.1",
|
|
122
|
-
"helmet": "^8.1.0",
|
|
123
|
-
"ioredis": "^5.10.1",
|
|
124
|
-
"jest": "^29.7.0",
|
|
125
|
-
"jwks-rsa": "^4.0.1",
|
|
126
|
-
"passport": "^0.7.0",
|
|
127
|
-
"passport-jwt": "^4.0.1",
|
|
128
|
-
"nestjs-pino": "^4.6.1",
|
|
129
|
-
"pino": "^10.3.1",
|
|
130
|
-
"pino-http": "^11.0.0",
|
|
131
|
-
"pino-seq": "^4.0.0",
|
|
132
|
-
"prom-client": "^15.1.3",
|
|
133
|
-
"reflect-metadata": "^0.2.2",
|
|
134
|
-
"rxjs": "^7.8.2",
|
|
135
|
-
"ts-jest": "^29.2.0",
|
|
136
|
-
"typeorm": "^0.3.29",
|
|
137
|
-
"typescript": "^5.7.0",
|
|
138
|
-
"unleash-client": "^6.10.1"
|
|
139
85
|
}
|
|
140
86
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
|
3
|
-
import { LogBehavior } from './behaviors/LogBehavior';
|
|
4
|
-
import { FeatureFlagBehavior } from './behaviors/FeatureFlagBehavior';
|
|
5
|
-
import { ValidationBehavior } from './behaviors/ValidationBehavior';
|
|
6
|
-
import { CacheBehavior } from './behaviors/CacheBehavior';
|
|
7
|
-
import { DistributedLockBehavior } from './behaviors/DistributedLockBehavior';
|
|
8
|
-
import { TransactionalBehavior } from './behaviors/TransactionalBehavior';
|
|
9
|
-
import { PerformanceBehavior } from './behaviors/PerformanceBehavior';
|
|
10
|
-
import { WorkflowBehavior } from './behaviors/WorkflowBehavior';
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use QuanticCommandBus and QuanticQueryBus instead.
|
|
13
|
-
* This class is kept for backwards compatibility only.
|
|
14
|
-
*/
|
|
15
|
-
export declare class PipelineExecutor implements OnModuleInit {
|
|
16
|
-
private readonly commandBus;
|
|
17
|
-
private readonly queryBus;
|
|
18
|
-
private readonly logBehavior;
|
|
19
|
-
private readonly featureFlagBehavior;
|
|
20
|
-
private readonly validationBehavior;
|
|
21
|
-
private readonly cacheBehavior;
|
|
22
|
-
private readonly distributedLockBehavior;
|
|
23
|
-
private readonly transactionalBehavior;
|
|
24
|
-
private readonly performanceBehavior;
|
|
25
|
-
private readonly workflowBehavior;
|
|
26
|
-
private readonly logger;
|
|
27
|
-
private readonly quanticCommandBus;
|
|
28
|
-
private readonly quanticQueryBus;
|
|
29
|
-
constructor(commandBus: CommandBus, queryBus: QueryBus, logBehavior: LogBehavior, featureFlagBehavior: FeatureFlagBehavior | undefined, validationBehavior: ValidationBehavior, cacheBehavior: CacheBehavior, distributedLockBehavior: DistributedLockBehavior, transactionalBehavior: TransactionalBehavior, performanceBehavior: PerformanceBehavior, workflowBehavior: WorkflowBehavior | undefined);
|
|
30
|
-
onModuleInit(): void;
|
|
31
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var PipelineExecutor_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.PipelineExecutor = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const cqrs_1 = require("@nestjs/cqrs");
|
|
19
|
-
const LogBehavior_1 = require("./behaviors/LogBehavior");
|
|
20
|
-
const FeatureFlagBehavior_1 = require("./behaviors/FeatureFlagBehavior");
|
|
21
|
-
const ValidationBehavior_1 = require("./behaviors/ValidationBehavior");
|
|
22
|
-
const CacheBehavior_1 = require("./behaviors/CacheBehavior");
|
|
23
|
-
const DistributedLockBehavior_1 = require("./behaviors/DistributedLockBehavior");
|
|
24
|
-
const TransactionalBehavior_1 = require("./behaviors/TransactionalBehavior");
|
|
25
|
-
const PerformanceBehavior_1 = require("./behaviors/PerformanceBehavior");
|
|
26
|
-
const WorkflowBehavior_1 = require("./behaviors/WorkflowBehavior");
|
|
27
|
-
const QuanticCommandBus_1 = require("./pipeline/QuanticCommandBus");
|
|
28
|
-
const QuanticQueryBus_1 = require("./pipeline/QuanticQueryBus");
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated Use QuanticCommandBus and QuanticQueryBus instead.
|
|
31
|
-
* This class is kept for backwards compatibility only.
|
|
32
|
-
*/
|
|
33
|
-
let PipelineExecutor = PipelineExecutor_1 = class PipelineExecutor {
|
|
34
|
-
commandBus;
|
|
35
|
-
queryBus;
|
|
36
|
-
logBehavior;
|
|
37
|
-
featureFlagBehavior;
|
|
38
|
-
validationBehavior;
|
|
39
|
-
cacheBehavior;
|
|
40
|
-
distributedLockBehavior;
|
|
41
|
-
transactionalBehavior;
|
|
42
|
-
performanceBehavior;
|
|
43
|
-
workflowBehavior;
|
|
44
|
-
logger = new common_1.Logger(PipelineExecutor_1.name);
|
|
45
|
-
quanticCommandBus;
|
|
46
|
-
quanticQueryBus;
|
|
47
|
-
constructor(commandBus, queryBus, logBehavior, featureFlagBehavior, validationBehavior, cacheBehavior, distributedLockBehavior, transactionalBehavior, performanceBehavior, workflowBehavior) {
|
|
48
|
-
this.commandBus = commandBus;
|
|
49
|
-
this.queryBus = queryBus;
|
|
50
|
-
this.logBehavior = logBehavior;
|
|
51
|
-
this.featureFlagBehavior = featureFlagBehavior;
|
|
52
|
-
this.validationBehavior = validationBehavior;
|
|
53
|
-
this.cacheBehavior = cacheBehavior;
|
|
54
|
-
this.distributedLockBehavior = distributedLockBehavior;
|
|
55
|
-
this.transactionalBehavior = transactionalBehavior;
|
|
56
|
-
this.performanceBehavior = performanceBehavior;
|
|
57
|
-
this.workflowBehavior = workflowBehavior;
|
|
58
|
-
this.quanticCommandBus = new QuanticCommandBus_1.QuanticCommandBus(commandBus, logBehavior, performanceBehavior, featureFlagBehavior, validationBehavior, workflowBehavior, cacheBehavior, distributedLockBehavior, transactionalBehavior);
|
|
59
|
-
this.quanticQueryBus = new QuanticQueryBus_1.QuanticQueryBus(queryBus, logBehavior, performanceBehavior, featureFlagBehavior, validationBehavior, cacheBehavior);
|
|
60
|
-
}
|
|
61
|
-
onModuleInit() {
|
|
62
|
-
this.logger.warn('PipelineExecutor is deprecated. Use QuanticCommandBus and QuanticQueryBus instead.');
|
|
63
|
-
this.quanticCommandBus.onModuleInit();
|
|
64
|
-
this.quanticQueryBus.onModuleInit();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
exports.PipelineExecutor = PipelineExecutor;
|
|
68
|
-
exports.PipelineExecutor = PipelineExecutor = PipelineExecutor_1 = __decorate([
|
|
69
|
-
(0, common_1.Injectable)(),
|
|
70
|
-
__param(3, (0, common_1.Optional)()),
|
|
71
|
-
__param(3, (0, common_1.Inject)(FeatureFlagBehavior_1.FeatureFlagBehavior)),
|
|
72
|
-
__param(9, (0, common_1.Optional)()),
|
|
73
|
-
__param(9, (0, common_1.Inject)(WorkflowBehavior_1.WorkflowBehavior)),
|
|
74
|
-
__metadata("design:paramtypes", [cqrs_1.CommandBus,
|
|
75
|
-
cqrs_1.QueryBus,
|
|
76
|
-
LogBehavior_1.LogBehavior, Object, ValidationBehavior_1.ValidationBehavior,
|
|
77
|
-
CacheBehavior_1.CacheBehavior,
|
|
78
|
-
DistributedLockBehavior_1.DistributedLockBehavior,
|
|
79
|
-
TransactionalBehavior_1.TransactionalBehavior,
|
|
80
|
-
PerformanceBehavior_1.PerformanceBehavior, Object])
|
|
81
|
-
], PipelineExecutor);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/Result';
|
|
2
|
-
import type { Redis } from 'ioredis';
|
|
3
|
-
export declare class CacheBehavior {
|
|
4
|
-
private readonly redis?;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(redis?: Redis | undefined);
|
|
7
|
-
execute<T>(command: object, next: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
8
|
-
private interpolateKey;
|
|
9
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var CacheBehavior_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.CacheBehavior = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const Cache_decorator_1 = require("../decorators/Cache.decorator");
|
|
19
|
-
const Result_1 = require("../../result/Result");
|
|
20
|
-
const constants_1 = require("../constants");
|
|
21
|
-
let CacheBehavior = CacheBehavior_1 = class CacheBehavior {
|
|
22
|
-
redis;
|
|
23
|
-
logger = new common_1.Logger(CacheBehavior_1.name);
|
|
24
|
-
constructor(redis) {
|
|
25
|
-
this.redis = redis;
|
|
26
|
-
}
|
|
27
|
-
async execute(command, next) {
|
|
28
|
-
const metadata = (0, Cache_decorator_1.getCacheMetadata)(command.constructor);
|
|
29
|
-
if (!metadata || !this.redis) {
|
|
30
|
-
return next();
|
|
31
|
-
}
|
|
32
|
-
const cacheKey = this.interpolateKey(metadata.key, command);
|
|
33
|
-
try {
|
|
34
|
-
const cached = await this.redis.get(cacheKey);
|
|
35
|
-
if (cached) {
|
|
36
|
-
this.logger.debug(`Cache hit: ${cacheKey}`);
|
|
37
|
-
return Result_1.Result.success(JSON.parse(cached));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
this.logger.warn(`Cache read failed for key: ${cacheKey}`);
|
|
42
|
-
}
|
|
43
|
-
const result = await next();
|
|
44
|
-
if (result.isSuccess && result.value !== undefined) {
|
|
45
|
-
try {
|
|
46
|
-
await this.redis.set(cacheKey, JSON.stringify(result.value), 'EX', metadata.ttlSeconds);
|
|
47
|
-
this.logger.debug(`Cache set: ${cacheKey} (TTL: ${metadata.ttlSeconds}s)`);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
this.logger.warn(`Cache write failed for key: ${cacheKey}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
interpolateKey(template, command) {
|
|
56
|
-
return template.replace(/\{(\w+)\}/g, (_, prop) => {
|
|
57
|
-
const value = command[prop];
|
|
58
|
-
return value != null ? String(value) : '';
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
exports.CacheBehavior = CacheBehavior;
|
|
63
|
-
exports.CacheBehavior = CacheBehavior = CacheBehavior_1 = __decorate([
|
|
64
|
-
(0, common_1.Injectable)(),
|
|
65
|
-
__param(0, (0, common_1.Optional)()),
|
|
66
|
-
__param(0, (0, common_1.Inject)(constants_1.REDIS_CLIENT)),
|
|
67
|
-
__metadata("design:paramtypes", [Function])
|
|
68
|
-
], CacheBehavior);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/Result';
|
|
2
|
-
import type { Redis } from 'ioredis';
|
|
3
|
-
export declare class DistributedLockBehavior {
|
|
4
|
-
private readonly redis?;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(redis?: Redis | undefined);
|
|
7
|
-
execute<T>(command: object, next: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
8
|
-
private tryAcquire;
|
|
9
|
-
private release;
|
|
10
|
-
private sleep;
|
|
11
|
-
private interpolateKey;
|
|
12
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var DistributedLockBehavior_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.DistributedLockBehavior = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const DistributedLock_decorator_1 = require("../decorators/DistributedLock.decorator");
|
|
19
|
-
const Result_1 = require("../../result/Result");
|
|
20
|
-
const constants_1 = require("../constants");
|
|
21
|
-
const uuid_1 = require("uuid");
|
|
22
|
-
let DistributedLockBehavior = DistributedLockBehavior_1 = class DistributedLockBehavior {
|
|
23
|
-
redis;
|
|
24
|
-
logger = new common_1.Logger(DistributedLockBehavior_1.name);
|
|
25
|
-
constructor(redis) {
|
|
26
|
-
this.redis = redis;
|
|
27
|
-
}
|
|
28
|
-
async execute(command, next) {
|
|
29
|
-
const metadata = (0, DistributedLock_decorator_1.getDistributedLockMetadata)(command.constructor);
|
|
30
|
-
if (!metadata || !this.redis) {
|
|
31
|
-
return next();
|
|
32
|
-
}
|
|
33
|
-
const lockKey = `lock:${this.interpolateKey(metadata.key, command)}`;
|
|
34
|
-
const lockValue = (0, uuid_1.v4)();
|
|
35
|
-
const acquired = await this.tryAcquire(lockKey, lockValue, metadata.lockTtlSeconds, metadata.acquireTimeoutSeconds);
|
|
36
|
-
if (!acquired) {
|
|
37
|
-
this.logger.warn(`Failed to acquire lock: ${lockKey}`);
|
|
38
|
-
return Result_1.Result.failure(Result_1.ErrorType.Conflict, `Resource is locked: ${metadata.key}`);
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
return await next();
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
await this.release(lockKey, lockValue);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async tryAcquire(key, value, ttlSeconds, timeoutSeconds) {
|
|
48
|
-
const deadline = Date.now() + timeoutSeconds * 1000;
|
|
49
|
-
const retryDelay = 50;
|
|
50
|
-
while (Date.now() < deadline) {
|
|
51
|
-
const result = await this.redis.set(key, value, 'EX', ttlSeconds, 'NX');
|
|
52
|
-
if (result === 'OK')
|
|
53
|
-
return true;
|
|
54
|
-
await this.sleep(retryDelay);
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
async release(key, value) {
|
|
59
|
-
// Lua script ensures only the owner releases the lock
|
|
60
|
-
const script = `
|
|
61
|
-
if redis.call("get", KEYS[1]) == ARGV[1] then
|
|
62
|
-
return redis.call("del", KEYS[1])
|
|
63
|
-
else
|
|
64
|
-
return 0
|
|
65
|
-
end
|
|
66
|
-
`;
|
|
67
|
-
try {
|
|
68
|
-
await this.redis.eval(script, 1, key, value);
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
this.logger.warn(`Failed to release lock: ${key}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
sleep(ms) {
|
|
75
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
76
|
-
}
|
|
77
|
-
interpolateKey(template, command) {
|
|
78
|
-
return template.replace(/\{(\w+)\}/g, (_, prop) => {
|
|
79
|
-
const value = command[prop];
|
|
80
|
-
return value != null ? String(value) : '';
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.DistributedLockBehavior = DistributedLockBehavior;
|
|
85
|
-
exports.DistributedLockBehavior = DistributedLockBehavior = DistributedLockBehavior_1 = __decorate([
|
|
86
|
-
(0, common_1.Injectable)(),
|
|
87
|
-
__param(0, (0, common_1.Optional)()),
|
|
88
|
-
__param(0, (0, common_1.Inject)(constants_1.REDIS_CLIENT)),
|
|
89
|
-
__metadata("design:paramtypes", [Function])
|
|
90
|
-
], DistributedLockBehavior);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Unleash } from 'unleash-client';
|
|
2
|
-
import { Result } from '../../result/Result';
|
|
3
|
-
export declare class FeatureFlagBehavior {
|
|
4
|
-
private readonly unleash?;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(unleash?: Unleash | undefined);
|
|
7
|
-
execute<T>(command: object, next: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
8
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var FeatureFlagBehavior_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.FeatureFlagBehavior = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const unleash_client_1 = require("unleash-client");
|
|
19
|
-
const FeatureFlag_decorator_1 = require("../decorators/FeatureFlag.decorator");
|
|
20
|
-
const Result_1 = require("../../result/Result");
|
|
21
|
-
let FeatureFlagBehavior = FeatureFlagBehavior_1 = class FeatureFlagBehavior {
|
|
22
|
-
unleash;
|
|
23
|
-
logger = new common_1.Logger(FeatureFlagBehavior_1.name);
|
|
24
|
-
constructor(unleash) {
|
|
25
|
-
this.unleash = unleash;
|
|
26
|
-
}
|
|
27
|
-
async execute(command, next) {
|
|
28
|
-
const metadata = (0, FeatureFlag_decorator_1.getFeatureFlagMetadata)(command.constructor);
|
|
29
|
-
if (!metadata) {
|
|
30
|
-
return next();
|
|
31
|
-
}
|
|
32
|
-
if (!this.unleash) {
|
|
33
|
-
this.logger.debug('Unleash not configured, skipping feature flag check');
|
|
34
|
-
return next();
|
|
35
|
-
}
|
|
36
|
-
const { flagName, fallback, defaultValue } = metadata;
|
|
37
|
-
const isEnabled = this.unleash.isEnabled(flagName);
|
|
38
|
-
if (isEnabled) {
|
|
39
|
-
return next();
|
|
40
|
-
}
|
|
41
|
-
this.logger.warn(`Feature flag "${flagName}" is disabled, applying fallback: ${fallback}`);
|
|
42
|
-
switch (fallback) {
|
|
43
|
-
case 'skip':
|
|
44
|
-
return Result_1.Result.success(undefined);
|
|
45
|
-
case 'default':
|
|
46
|
-
return Result_1.Result.success(defaultValue);
|
|
47
|
-
case 'throw':
|
|
48
|
-
default:
|
|
49
|
-
return Result_1.Result.failure(Result_1.ErrorType.Forbidden, `Feature "${flagName}" is currently disabled`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.FeatureFlagBehavior = FeatureFlagBehavior;
|
|
54
|
-
exports.FeatureFlagBehavior = FeatureFlagBehavior = FeatureFlagBehavior_1 = __decorate([
|
|
55
|
-
(0, common_1.Injectable)(),
|
|
56
|
-
__param(0, (0, common_1.Optional)()),
|
|
57
|
-
__metadata("design:paramtypes", [unleash_client_1.Unleash])
|
|
58
|
-
], FeatureFlagBehavior);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/Result';
|
|
2
|
-
import type { Redis } from 'ioredis';
|
|
3
|
-
export declare class InvalidateCacheBehavior {
|
|
4
|
-
private readonly redis?;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(redis?: Redis | undefined);
|
|
7
|
-
execute<T>(command: object, next: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
8
|
-
private interpolateKey;
|
|
9
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var InvalidateCacheBehavior_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.InvalidateCacheBehavior = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const InvalidateCache_decorator_1 = require("../decorators/InvalidateCache.decorator");
|
|
19
|
-
const constants_1 = require("../constants");
|
|
20
|
-
let InvalidateCacheBehavior = InvalidateCacheBehavior_1 = class InvalidateCacheBehavior {
|
|
21
|
-
redis;
|
|
22
|
-
logger = new common_1.Logger(InvalidateCacheBehavior_1.name);
|
|
23
|
-
constructor(redis) {
|
|
24
|
-
this.redis = redis;
|
|
25
|
-
}
|
|
26
|
-
async execute(command, next) {
|
|
27
|
-
const metadata = (0, InvalidateCache_decorator_1.getInvalidateCacheMetadata)(command.constructor);
|
|
28
|
-
if (!metadata || !this.redis) {
|
|
29
|
-
return next();
|
|
30
|
-
}
|
|
31
|
-
const result = await next();
|
|
32
|
-
if (!result.isSuccess) {
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
const resolvedKeys = metadata.keys.map((key) => this.interpolateKey(key, command));
|
|
36
|
-
if (resolvedKeys.length === 0) {
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
await this.redis.del(...resolvedKeys);
|
|
41
|
-
this.logger.debug(`Cache invalidated: ${resolvedKeys.join(', ')}`);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
this.logger.warn(`Cache invalidation failed for keys: ${resolvedKeys.join(', ')}`);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
interpolateKey(template, command) {
|
|
49
|
-
return template.replace(/\{(\w+)\}/g, (_, prop) => {
|
|
50
|
-
const value = command[prop];
|
|
51
|
-
return value != null ? String(value) : '';
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.InvalidateCacheBehavior = InvalidateCacheBehavior;
|
|
56
|
-
exports.InvalidateCacheBehavior = InvalidateCacheBehavior = InvalidateCacheBehavior_1 = __decorate([
|
|
57
|
-
(0, common_1.Injectable)(),
|
|
58
|
-
__param(0, (0, common_1.Optional)()),
|
|
59
|
-
__param(0, (0, common_1.Inject)(constants_1.REDIS_CLIENT)),
|
|
60
|
-
__metadata("design:paramtypes", [Function])
|
|
61
|
-
], InvalidateCacheBehavior);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/Result';
|
|
2
|
-
import { MetricsService } from '../../metrics/MetricsService';
|
|
3
|
-
/**
|
|
4
|
-
* PerformanceBehavior logs a warning when a handler exceeds 500ms
|
|
5
|
-
* and records handler duration in Prometheus histogram.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PerformanceBehavior {
|
|
8
|
-
private readonly metrics?;
|
|
9
|
-
private readonly logger;
|
|
10
|
-
constructor(metrics?: MetricsService | undefined);
|
|
11
|
-
execute<T>(command: object, next: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
12
|
-
}
|