@edirect/rate-limit-module 11.0.43 → 11.0.45

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.
Files changed (82) hide show
  1. package/package.json +3 -3
  2. package/dist/README.md +0 -499
  3. package/dist/package.json +0 -41
  4. package/dist/src/decorators/rate-limiting-rule.decorator.d.ts +0 -10
  5. package/dist/src/decorators/rate-limiting-rule.decorator.d.ts.map +0 -1
  6. package/dist/src/decorators/rate-limiting-rule.decorator.js +0 -7
  7. package/dist/src/guards/rate-limiting.guard.d.ts +0 -21
  8. package/dist/src/guards/rate-limiting.guard.d.ts.map +0 -1
  9. package/dist/src/guards/rate-limiting.guard.js +0 -248
  10. package/dist/src/index.d.ts +0 -11
  11. package/dist/src/index.d.ts.map +0 -1
  12. package/dist/src/index.js +0 -14
  13. package/dist/src/main.d.ts +0 -2
  14. package/dist/src/main.d.ts.map +0 -1
  15. package/dist/src/main.js +0 -9
  16. package/dist/src/object.utils.d.ts +0 -3
  17. package/dist/src/object.utils.d.ts.map +0 -1
  18. package/dist/src/object.utils.js +0 -38
  19. package/dist/src/rate-limiting.module.d.ts +0 -3
  20. package/dist/src/rate-limiting.module.d.ts.map +0 -1
  21. package/dist/src/rate-limiting.module.js +0 -31
  22. package/dist/src/rules/dto/pagination.dto.d.ts +0 -6
  23. package/dist/src/rules/dto/pagination.dto.d.ts.map +0 -1
  24. package/dist/src/rules/dto/pagination.dto.js +0 -42
  25. package/dist/src/rules/dto/rule.dto.d.ts +0 -24
  26. package/dist/src/rules/dto/rule.dto.d.ts.map +0 -1
  27. package/dist/src/rules/dto/rule.dto.js +0 -198
  28. package/dist/src/rules/interface/pagination.interface.d.ts +0 -7
  29. package/dist/src/rules/interface/pagination.interface.d.ts.map +0 -1
  30. package/dist/src/rules/interface/pagination.interface.js +0 -2
  31. package/dist/src/rules/interface/rule.interface.d.ts +0 -29
  32. package/dist/src/rules/interface/rule.interface.d.ts.map +0 -1
  33. package/dist/src/rules/interface/rule.interface.js +0 -2
  34. package/dist/src/rules/rule.controller.d.ts +0 -14
  35. package/dist/src/rules/rule.controller.d.ts.map +0 -1
  36. package/dist/src/rules/rule.controller.js +0 -87
  37. package/dist/src/rules/rule.module.d.ts +0 -5
  38. package/dist/src/rules/rule.module.d.ts.map +0 -1
  39. package/dist/src/rules/rule.module.js +0 -38
  40. package/dist/src/rules/rule.repository.d.ts +0 -15
  41. package/dist/src/rules/rule.repository.d.ts.map +0 -1
  42. package/dist/src/rules/rule.repository.js +0 -79
  43. package/dist/src/rules/rule.schema.d.ts +0 -176
  44. package/dist/src/rules/rule.schema.d.ts.map +0 -1
  45. package/dist/src/rules/rule.schema.js +0 -150
  46. package/dist/src/rules/rule.service.d.ts +0 -26
  47. package/dist/src/rules/rule.service.d.ts.map +0 -1
  48. package/dist/src/rules/rule.service.js +0 -204
  49. package/dist/src/shared/cache/cache.service.d.ts +0 -10
  50. package/dist/src/shared/cache/cache.service.d.ts.map +0 -1
  51. package/dist/src/shared/cache/cache.service.js +0 -29
  52. package/dist/src/shared/dsl/dsl.interface.d.ts +0 -43
  53. package/dist/src/shared/dsl/dsl.interface.d.ts.map +0 -1
  54. package/dist/src/shared/dsl/dsl.interface.js +0 -9
  55. package/dist/src/shared/dsl/dsl.service.d.ts +0 -8
  56. package/dist/src/shared/dsl/dsl.service.d.ts.map +0 -1
  57. package/dist/src/shared/dsl/dsl.service.js +0 -87
  58. package/dist/src/shared/redis/redis.module.d.ts +0 -3
  59. package/dist/src/shared/redis/redis.module.d.ts.map +0 -1
  60. package/dist/src/shared/redis/redis.module.js +0 -32
  61. package/dist/src/shared/redis/redis.service.d.ts +0 -13
  62. package/dist/src/shared/redis/redis.service.d.ts.map +0 -1
  63. package/dist/src/shared/redis/redis.service.js +0 -53
  64. package/dist/src/shared/rule-engine/interface/rule-engine.interface.d.ts +0 -14
  65. package/dist/src/shared/rule-engine/interface/rule-engine.interface.d.ts.map +0 -1
  66. package/dist/src/shared/rule-engine/interface/rule-engine.interface.js +0 -2
  67. package/dist/src/shared/rule-engine/rule-engine.module.d.ts +0 -11
  68. package/dist/src/shared/rule-engine/rule-engine.module.d.ts.map +0 -1
  69. package/dist/src/shared/rule-engine/rule-engine.module.js +0 -51
  70. package/dist/src/shared/rule-engine/rule-engine.service.d.ts +0 -18
  71. package/dist/src/shared/rule-engine/rule-engine.service.d.ts.map +0 -1
  72. package/dist/src/shared/rule-engine/rule-engine.service.js +0 -134
  73. package/dist/src/shared/shared.module.d.ts +0 -3
  74. package/dist/src/shared/shared.module.d.ts.map +0 -1
  75. package/dist/src/shared/shared.module.js +0 -29
  76. package/dist/src/validators/rule.constraint.d.ts +0 -10
  77. package/dist/src/validators/rule.constraint.d.ts.map +0 -1
  78. package/dist/src/validators/rule.constraint.js +0 -49
  79. package/dist/src/validators/rule.validator.d.ts +0 -3
  80. package/dist/src/validators/rule.validator.d.ts.map +0 -1
  81. package/dist/src/validators/rule.validator.js +0 -16
  82. package/dist/tsconfig.lib.tsbuildinfo +0 -1
@@ -1,248 +0,0 @@
1
- "use strict";
2
- var RateLimitingRuleGuard_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.RateLimitingRuleGuard = void 0;
5
- const tslib_1 = require("tslib");
6
- const common_1 = require("@nestjs/common");
7
- const core_1 = require("@nestjs/core");
8
- const rate_limiting_rule_decorator_1 = require("../decorators/rate-limiting-rule.decorator");
9
- const object_utils_1 = require("../object.utils");
10
- const rule_service_1 = require("../rules/rule.service");
11
- const rule_engine_service_1 = require("../shared/rule-engine/rule-engine.service");
12
- let RateLimitingRuleGuard = RateLimitingRuleGuard_1 = class RateLimitingRuleGuard {
13
- reflector;
14
- ruleService;
15
- ruleEngine;
16
- logger = new common_1.Logger(RateLimitingRuleGuard_1.name);
17
- constructor(reflector, ruleService, ruleEngine) {
18
- this.reflector = reflector;
19
- this.ruleService = ruleService;
20
- this.ruleEngine = ruleEngine;
21
- }
22
- async canActivate(context) {
23
- try {
24
- const handler = context.getHandler();
25
- const ruleMetaData = this.reflector.get(rate_limiting_rule_decorator_1.RULE_METADATA, handler);
26
- if (!ruleMetaData)
27
- return true;
28
- const req = context.switchToHttp().getRequest();
29
- const entity = req.body;
30
- const { action, partnerPath, providerPath, productTypePath, marketPath } = ruleMetaData;
31
- const partner = this._getValueFromPathOrRoot(entity, partnerPath);
32
- if (!partner)
33
- return true;
34
- const provider = this._getValueFromPathOrRoot(entity, providerPath);
35
- const productType = this._getValueFromPathOrRoot(entity, productTypePath);
36
- const market = this._getValueFromPathOrRoot(entity, marketPath);
37
- const parameters = {
38
- enabled: 'true',
39
- partner: partner,
40
- provider: provider,
41
- market: market,
42
- targetAction: action,
43
- productType: productType,
44
- page: 1,
45
- limit: 10,
46
- };
47
- const rules = await this.ruleService.findAllWithoutPagination(parameters);
48
- this.logger.debug(`[RATE LIMITER] ${rules?.length} rules found - ${JSON.stringify(rules)}`);
49
- if (!rules || !rules?.length)
50
- return true;
51
- for (const rule of rules) {
52
- await this._injectFnsResults(rule.variables, entity);
53
- const contextVars = this._resolveVariables(rule.variables, entity);
54
- const invalidExpressionMessage = this.ruleService.validateRuleExpression(rule.expression);
55
- if (invalidExpressionMessage && invalidExpressionMessage.length) {
56
- throw new common_1.HttpException(invalidExpressionMessage, common_1.HttpStatus.TOO_MANY_REQUESTS);
57
- }
58
- const invalidFunctions = this.ruleEngine.validateFunctionsAreValid(rule.expression);
59
- if (invalidFunctions && invalidFunctions.length) {
60
- throw new common_1.HttpException(`these functions are not allowed ${invalidFunctions.join(', ')}`, common_1.HttpStatus.TOO_MANY_REQUESTS);
61
- }
62
- if (rule.variablesRequired) {
63
- const missingVars = await this.ruleEngine.validateExpressionVariables(rule.expression, contextVars);
64
- if (missingVars && missingVars.length) {
65
- this.logger.debug(`[RATE LIMITER] rule - ${rule.name} requires theses variables ${JSON.stringify(missingVars)}`);
66
- throw new common_1.HttpException(`For rate limiting validation these variables are required ${JSON.stringify(missingVars)}`, common_1.HttpStatus.TOO_MANY_REQUESTS);
67
- }
68
- }
69
- const safeContextVars = (0, object_utils_1.withDefaultNull)(contextVars ?? {});
70
- const notAllowed = await this.ruleEngine.evaluate(rule.expression, safeContextVars);
71
- this.logger.debug(`[RATE LIMITER] rule - ${rule.name} reached the limit`);
72
- if (notAllowed)
73
- throw new common_1.HttpException(rule.errorMessage || `Rate Limiting rule reached limit`, common_1.HttpStatus.TOO_MANY_REQUESTS);
74
- }
75
- return true;
76
- }
77
- catch (err) {
78
- if (err instanceof common_1.HttpException && err.getStatus?.() === 429) {
79
- throw err;
80
- }
81
- return true;
82
- }
83
- }
84
- _getValueFromPathOrRoot(obj, path) {
85
- if (!obj)
86
- return undefined;
87
- const valueFromPath = path
88
- .split('.')
89
- .reduce((acc, key) => acc && typeof acc === 'object' && key in acc
90
- ? acc[key]
91
- : undefined, obj);
92
- if (valueFromPath !== undefined) {
93
- return valueFromPath;
94
- }
95
- return obj[path];
96
- }
97
- _resolveDateExpr(expr) {
98
- const match = expr.match(/^date\(([-\d]+)([dMy])?\)$/);
99
- if (!match)
100
- return expr;
101
- const amount = parseInt(match[1], 10);
102
- const unit = match[2] || 'd';
103
- const date = new Date();
104
- switch (unit) {
105
- case 'd':
106
- date.setDate(date.getDate() + amount);
107
- break;
108
- case 'M':
109
- date.setMonth(date.getMonth() + amount);
110
- break;
111
- case 'y':
112
- date.setFullYear(date.getFullYear() + amount);
113
- break;
114
- }
115
- if (amount !== 0) {
116
- date.setHours(0, 0, 0, 0);
117
- }
118
- return date.toISOString();
119
- }
120
- _resolveValue(raw, context, defaultValue) {
121
- if (typeof raw === 'string') {
122
- if (!raw) {
123
- if (defaultValue)
124
- return this._resolveValue(defaultValue, context);
125
- return;
126
- }
127
- if (raw.startsWith(':')) {
128
- const path = raw.slice(1);
129
- const val = this._getByPath(context, path);
130
- return this._resolveValue(val, context);
131
- }
132
- if (/^\s*fn:/.test(raw)) {
133
- return;
134
- }
135
- if (raw.startsWith('date(')) {
136
- return this._resolveDateExpr(raw);
137
- }
138
- return raw;
139
- }
140
- if (typeof raw === 'object' &&
141
- raw !== null &&
142
- 'from' in raw &&
143
- 'to' in raw) {
144
- const obj = raw;
145
- return {
146
- from: this._resolveValue(obj.from, context),
147
- to: this._resolveValue(obj.to, context),
148
- };
149
- }
150
- return raw;
151
- }
152
- _resolveVariables(vars, context) {
153
- if (!vars ||
154
- !vars.queries ||
155
- !Array.isArray(vars.queries) ||
156
- !vars.queries.length)
157
- return vars;
158
- return {
159
- queries: vars.queries.map((q) => ({
160
- ...q,
161
- query: Array.isArray(q.query)
162
- ? q.query.map(entry => ({
163
- ...entry,
164
- value: this._resolveValue(entry.value, context ?? {}, entry?.defaultValue),
165
- }))
166
- : [],
167
- })),
168
- };
169
- }
170
- _resolveParams(vars, context) {
171
- if (!vars.variables ||
172
- !vars.variables.queries ||
173
- !vars.variables.queries.length)
174
- return {};
175
- return {
176
- ...vars.variables,
177
- queries: vars.variables.queries.map(q => ({
178
- ...q,
179
- value: this._resolveValue(q.value, context, q?.defaultValue),
180
- })),
181
- };
182
- }
183
- _getByPath(obj, path) {
184
- if (!path)
185
- return undefined;
186
- const parts = path.replace(/\[(\d+)\]/g, '.$1').split('.');
187
- return parts.reduce((acc, key) => {
188
- if (acc && typeof acc === 'object') {
189
- return acc[key];
190
- }
191
- return undefined;
192
- }, obj);
193
- }
194
- async _injectFnsResults(variables, entity) {
195
- if (!variables || !variables.functions)
196
- return;
197
- const fns = variables.functions;
198
- for (const fn of fns) {
199
- const contextVars = this._resolveParams(fn, entity);
200
- const value = await this.ruleEngine.getResultCustomFunction(fn.fn, contextVars);
201
- this._updateFnsResults(variables, fn.name, value);
202
- }
203
- }
204
- _updateFnsResults(vars, fnName, value) {
205
- if (!vars.queries || !Array.isArray(vars.queries))
206
- return;
207
- vars.queries.forEach((q) => {
208
- if (!Array.isArray(q.query))
209
- return;
210
- q.query.forEach(cond => {
211
- if (/^\s*fn:/.test(cond.value) || typeof cond.value === 'object') {
212
- if (typeof cond.value === 'object') {
213
- if (cond.value.to.replace(/^fn:/, '') === fnName) {
214
- if (value) {
215
- cond.value.to = value;
216
- }
217
- else {
218
- cond.value.to = cond?.defaultValue?.to;
219
- }
220
- }
221
- const fromStr = typeof cond.value?.from === 'string' ? cond.value.from : '';
222
- if (fromStr.replace(/^fn:/, '') === fnName) {
223
- if (value) {
224
- cond.value.from = value;
225
- }
226
- else {
227
- cond.value.from = cond?.defaultValue?.from;
228
- }
229
- }
230
- return;
231
- }
232
- const name = cond.value.replace(/^fn:/, '');
233
- if (name === fnName) {
234
- cond.value = value;
235
- }
236
- }
237
- });
238
- });
239
- }
240
- };
241
- exports.RateLimitingRuleGuard = RateLimitingRuleGuard;
242
- exports.RateLimitingRuleGuard = RateLimitingRuleGuard = RateLimitingRuleGuard_1 = tslib_1.__decorate([
243
- (0, common_1.Injectable)(),
244
- tslib_1.__param(2, (0, common_1.Inject)('RULE_ENGINE_INSTANCE')),
245
- tslib_1.__metadata("design:paramtypes", [core_1.Reflector,
246
- rule_service_1.RuleService,
247
- rule_engine_service_1.RuleEngineService])
248
- ], RateLimitingRuleGuard);
@@ -1,11 +0,0 @@
1
- export * from './decorators/rate-limiting-rule.decorator';
2
- export * from './guards/rate-limiting.guard';
3
- export * from './rate-limiting.module';
4
- export * from './rules/rule.service';
5
- export * from './shared/dsl/dsl.interface';
6
- export * from './shared/dsl/dsl.service';
7
- export * from './shared/rule-engine/rule-engine.module';
8
- export * from './validators/rule.constraint';
9
- export declare const RULE_ENGINE_INSTANCE = "RULE_ENGINE_INSTANCE";
10
- export declare const CUSTOM_RULE_FUNCTIONS = "CUSTOM_RULE_FUNCTIONS";
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAE7C,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,qBAAqB,0BAA0B,CAAC"}
package/dist/src/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CUSTOM_RULE_FUNCTIONS = exports.RULE_ENGINE_INSTANCE = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./decorators/rate-limiting-rule.decorator"), exports);
6
- tslib_1.__exportStar(require("./guards/rate-limiting.guard"), exports);
7
- tslib_1.__exportStar(require("./rate-limiting.module"), exports);
8
- tslib_1.__exportStar(require("./rules/rule.service"), exports);
9
- tslib_1.__exportStar(require("./shared/dsl/dsl.interface"), exports);
10
- tslib_1.__exportStar(require("./shared/dsl/dsl.service"), exports);
11
- tslib_1.__exportStar(require("./shared/rule-engine/rule-engine.module"), exports);
12
- tslib_1.__exportStar(require("./validators/rule.constraint"), exports);
13
- exports.RULE_ENGINE_INSTANCE = 'RULE_ENGINE_INSTANCE';
14
- exports.CUSTOM_RULE_FUNCTIONS = 'CUSTOM_RULE_FUNCTIONS';
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":""}
package/dist/src/main.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@nestjs/core");
4
- const rate_limiting_module_1 = require("./rate-limiting.module");
5
- async function bootstrap() {
6
- const app = await core_1.NestFactory.create(rate_limiting_module_1.RateLimitingModule);
7
- await app.listen(process.env.PORT ?? 3040);
8
- }
9
- bootstrap();
@@ -1,3 +0,0 @@
1
- export declare const withDefaultNull: <T extends object>(context: T) => T;
2
- export declare const calculateDepth: (expression: string) => number | undefined;
3
- //# sourceMappingURL=object.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.utils.d.ts","sourceRoot":"","sources":["../../src/object.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,SAAS,CAAC,KAAG,CAqB9D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,YAAY,MAAM,KAAG,MAAM,GAAG,SAgB5D,CAAC"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateDepth = exports.withDefaultNull = void 0;
4
- const withDefaultNull = (context) => {
5
- return new Proxy(context, {
6
- get(target, prop, receiver) {
7
- const value = Reflect.get(target, prop, receiver);
8
- if (value === undefined) {
9
- return null;
10
- }
11
- if (value !== null &&
12
- typeof value === 'object' &&
13
- !Array.isArray(value) &&
14
- value.constructor === Object) {
15
- return (0, exports.withDefaultNull)(value);
16
- }
17
- return value;
18
- },
19
- });
20
- };
21
- exports.withDefaultNull = withDefaultNull;
22
- const calculateDepth = (expression) => {
23
- if (!expression)
24
- return;
25
- let depth = 0;
26
- let maxDepth = 0;
27
- for (const char of expression) {
28
- if (char === '(') {
29
- depth++;
30
- maxDepth = Math.max(maxDepth, depth);
31
- }
32
- else if (char === ')') {
33
- depth--;
34
- }
35
- }
36
- return depth;
37
- };
38
- exports.calculateDepth = calculateDepth;
@@ -1,3 +0,0 @@
1
- export declare class RateLimitingModule {
2
- }
3
- //# sourceMappingURL=rate-limiting.module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rate-limiting.module.d.ts","sourceRoot":"","sources":["../../src/rate-limiting.module.ts"],"names":[],"mappings":"AAMA,qBAiBa,kBAAkB;CAAG"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RateLimitingModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const config_1 = require("@nestjs/config");
7
- const mongoose_1 = require("@nestjs/mongoose");
8
- const rule_module_1 = require("./rules/rule.module");
9
- const rule_constraint_1 = require("./validators/rule.constraint");
10
- let RateLimitingModule = class RateLimitingModule {
11
- };
12
- exports.RateLimitingModule = RateLimitingModule;
13
- exports.RateLimitingModule = RateLimitingModule = tslib_1.__decorate([
14
- (0, common_1.Module)({
15
- imports: [
16
- rule_module_1.RuleModule.register(),
17
- config_1.ConfigModule.forRoot({
18
- isGlobal: true,
19
- }),
20
- mongoose_1.MongooseModule.forRootAsync({
21
- imports: [config_1.ConfigModule],
22
- useFactory: async (config) => ({
23
- uri: config.get('MONGO_URL'),
24
- }),
25
- inject: [config_1.ConfigService],
26
- }),
27
- ],
28
- providers: [rule_constraint_1.IsValidExpressionConstraint],
29
- exports: [rule_module_1.RuleModule],
30
- })
31
- ], RateLimitingModule);
@@ -1,6 +0,0 @@
1
- export declare class PaginationDTO {
2
- page: number;
3
- order?: number | undefined;
4
- limit: number;
5
- }
6
- //# sourceMappingURL=pagination.dto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.dto.d.ts","sourceRoot":"","sources":["../../../../src/rules/dto/pagination.dto.ts"],"names":[],"mappings":"AAKA,qBAAa,aAAa;IAWxB,IAAI,SAAK;IAUT,KAAK,CAAC,qBAAM;IAIZ,KAAK,SAAM;CACZ"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PaginationDTO = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const swagger_1 = require("@nestjs/swagger");
7
- const class_transformer_1 = require("class-transformer");
8
- const class_validator_1 = require("class-validator");
9
- class PaginationDTO {
10
- page = 1;
11
- order = -1;
12
- limit = 10;
13
- }
14
- exports.PaginationDTO = PaginationDTO;
15
- tslib_1.__decorate([
16
- (0, swagger_1.ApiProperty)({ type: Number, required: false }),
17
- (0, class_validator_1.IsNotEmpty)(),
18
- (0, class_validator_1.IsInt)(),
19
- (0, class_validator_1.IsOptional)(),
20
- (0, class_transformer_1.Transform)(({ value }) => {
21
- const parsed = Number.parseInt(value);
22
- if (parsed === 0)
23
- throw new common_1.BadRequestException('Page needs to be bigger than 0');
24
- return parsed;
25
- }),
26
- tslib_1.__metadata("design:type", Object)
27
- ], PaginationDTO.prototype, "page", void 0);
28
- tslib_1.__decorate([
29
- (0, swagger_1.ApiProperty)({
30
- type: Number,
31
- required: false,
32
- default: -1,
33
- description: 'You can add more than one field by using trailing commas ex: 1,-1',
34
- }),
35
- (0, class_validator_1.IsOptional)(),
36
- tslib_1.__metadata("design:type", Object)
37
- ], PaginationDTO.prototype, "order", void 0);
38
- tslib_1.__decorate([
39
- (0, swagger_1.ApiProperty)({ type: Number, required: false, default: 10 }),
40
- (0, class_validator_1.IsOptional)(),
41
- tslib_1.__metadata("design:type", Object)
42
- ], PaginationDTO.prototype, "limit", void 0);
@@ -1,24 +0,0 @@
1
- import { IFindRule, IRule } from '../interface/rule.interface';
2
- import { PaginationDTO } from './pagination.dto';
3
- export declare class CreateRuleDTO implements IRule {
4
- name: string;
5
- expression: string;
6
- targetAction: string;
7
- errorMessage?: string;
8
- variables?: Record<string, unknown>;
9
- variablesRequired?: boolean;
10
- productType?: string;
11
- partner?: string;
12
- market?: string;
13
- provider?: string;
14
- }
15
- export declare class FindRuleDTO extends PaginationDTO implements IFindRule {
16
- name?: string;
17
- targetAction?: string;
18
- partner?: string;
19
- productType?: string;
20
- isEnabled?: boolean;
21
- provider?: string;
22
- market?: string;
23
- }
24
- //# sourceMappingURL=rule.dto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rule.dto.d.ts","sourceRoot":"","sources":["../../../../src/rules/dto/rule.dto.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,aAAc,YAAW,KAAK;IAOzC,IAAI,EAAG,MAAM,CAAC;IASd,UAAU,EAAG,MAAM,CAAC;IAQpB,YAAY,EAAG,MAAM,CAAC;IAStB,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IASpC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAS5B,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,OAAO,CAAC,EAAE,MAAM,CAAC;IASjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAShB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAY,SAAQ,aAAc,YAAW,SAAS;IAQjE,IAAI,CAAC,EAAE,MAAM,CAAC;IASd,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,OAAO,CAAC,EAAE,MAAM,CAAC;IASjB,WAAW,CAAC,EAAE,MAAM,CAAC;IASrB,SAAS,CAAC,EAAE,OAAO,CAAC;IASpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IASlB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,198 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FindRuleDTO = exports.CreateRuleDTO = void 0;
4
- const tslib_1 = require("tslib");
5
- const swagger_1 = require("@nestjs/swagger");
6
- const class_validator_1 = require("class-validator");
7
- const rule_validator_1 = require("../../validators/rule.validator");
8
- const pagination_dto_1 = require("./pagination.dto");
9
- class CreateRuleDTO {
10
- name;
11
- expression;
12
- targetAction;
13
- errorMessage;
14
- variables;
15
- variablesRequired;
16
- productType;
17
- partner;
18
- market;
19
- provider;
20
- }
21
- exports.CreateRuleDTO = CreateRuleDTO;
22
- tslib_1.__decorate([
23
- (0, swagger_1.ApiProperty)({
24
- type: String,
25
- required: true,
26
- }),
27
- (0, class_validator_1.IsNotEmpty)(),
28
- (0, class_validator_1.IsString)(),
29
- tslib_1.__metadata("design:type", String)
30
- ], CreateRuleDTO.prototype, "name", void 0);
31
- tslib_1.__decorate([
32
- (0, swagger_1.ApiProperty)({
33
- type: String,
34
- required: true,
35
- }),
36
- (0, class_validator_1.IsNotEmpty)(),
37
- (0, class_validator_1.IsString)(),
38
- (0, rule_validator_1.IsValidExpression)(),
39
- tslib_1.__metadata("design:type", String)
40
- ], CreateRuleDTO.prototype, "expression", void 0);
41
- tslib_1.__decorate([
42
- (0, swagger_1.ApiProperty)({
43
- type: String,
44
- required: true,
45
- }),
46
- (0, class_validator_1.IsNotEmpty)(),
47
- (0, class_validator_1.IsString)(),
48
- tslib_1.__metadata("design:type", String)
49
- ], CreateRuleDTO.prototype, "targetAction", void 0);
50
- tslib_1.__decorate([
51
- (0, swagger_1.ApiProperty)({
52
- type: String,
53
- required: false,
54
- }),
55
- (0, class_validator_1.IsNotEmpty)(),
56
- (0, class_validator_1.IsString)(),
57
- (0, class_validator_1.IsOptional)(),
58
- tslib_1.__metadata("design:type", String)
59
- ], CreateRuleDTO.prototype, "errorMessage", void 0);
60
- tslib_1.__decorate([
61
- (0, swagger_1.ApiProperty)({
62
- type: Object,
63
- required: false,
64
- }),
65
- (0, class_validator_1.IsNotEmpty)(),
66
- (0, class_validator_1.IsObject)(),
67
- (0, class_validator_1.IsOptional)(),
68
- tslib_1.__metadata("design:type", Object)
69
- ], CreateRuleDTO.prototype, "variables", void 0);
70
- tslib_1.__decorate([
71
- (0, swagger_1.ApiProperty)({
72
- type: Boolean,
73
- required: false,
74
- }),
75
- (0, class_validator_1.IsNotEmpty)(),
76
- (0, class_validator_1.IsBoolean)(),
77
- (0, class_validator_1.IsOptional)(),
78
- tslib_1.__metadata("design:type", Boolean)
79
- ], CreateRuleDTO.prototype, "variablesRequired", void 0);
80
- tslib_1.__decorate([
81
- (0, swagger_1.ApiProperty)({
82
- type: String,
83
- required: false,
84
- }),
85
- (0, class_validator_1.IsNotEmpty)(),
86
- (0, class_validator_1.IsString)(),
87
- (0, class_validator_1.IsOptional)(),
88
- tslib_1.__metadata("design:type", String)
89
- ], CreateRuleDTO.prototype, "productType", void 0);
90
- tslib_1.__decorate([
91
- (0, swagger_1.ApiProperty)({
92
- type: String,
93
- required: true,
94
- }),
95
- (0, class_validator_1.IsNotEmpty)(),
96
- (0, class_validator_1.IsString)(),
97
- tslib_1.__metadata("design:type", String)
98
- ], CreateRuleDTO.prototype, "partner", void 0);
99
- tslib_1.__decorate([
100
- (0, swagger_1.ApiProperty)({
101
- type: String,
102
- required: true,
103
- }),
104
- (0, class_validator_1.IsNotEmpty)(),
105
- (0, class_validator_1.IsString)(),
106
- (0, class_validator_1.IsOptional)(),
107
- tslib_1.__metadata("design:type", String)
108
- ], CreateRuleDTO.prototype, "market", void 0);
109
- tslib_1.__decorate([
110
- (0, swagger_1.ApiProperty)({
111
- type: String,
112
- required: false,
113
- }),
114
- (0, class_validator_1.IsNotEmpty)(),
115
- (0, class_validator_1.IsString)(),
116
- (0, class_validator_1.IsOptional)(),
117
- tslib_1.__metadata("design:type", String)
118
- ], CreateRuleDTO.prototype, "provider", void 0);
119
- class FindRuleDTO extends pagination_dto_1.PaginationDTO {
120
- name;
121
- targetAction;
122
- partner;
123
- productType;
124
- isEnabled;
125
- provider;
126
- market;
127
- }
128
- exports.FindRuleDTO = FindRuleDTO;
129
- tslib_1.__decorate([
130
- (0, swagger_1.ApiProperty)({
131
- type: String,
132
- required: false,
133
- }),
134
- (0, class_validator_1.IsNotEmpty)(),
135
- (0, class_validator_1.IsString)(),
136
- (0, class_validator_1.IsOptional)(),
137
- tslib_1.__metadata("design:type", String)
138
- ], FindRuleDTO.prototype, "name", void 0);
139
- tslib_1.__decorate([
140
- (0, swagger_1.ApiProperty)({
141
- type: String,
142
- required: false,
143
- }),
144
- (0, class_validator_1.IsNotEmpty)(),
145
- (0, class_validator_1.IsString)(),
146
- (0, class_validator_1.IsOptional)(),
147
- tslib_1.__metadata("design:type", String)
148
- ], FindRuleDTO.prototype, "targetAction", void 0);
149
- tslib_1.__decorate([
150
- (0, swagger_1.ApiProperty)({
151
- type: String,
152
- required: true,
153
- }),
154
- (0, class_validator_1.IsNotEmpty)(),
155
- (0, class_validator_1.IsString)(),
156
- (0, class_validator_1.IsOptional)(),
157
- tslib_1.__metadata("design:type", String)
158
- ], FindRuleDTO.prototype, "partner", void 0);
159
- tslib_1.__decorate([
160
- (0, swagger_1.ApiProperty)({
161
- type: String,
162
- required: true,
163
- }),
164
- (0, class_validator_1.IsNotEmpty)(),
165
- (0, class_validator_1.IsString)(),
166
- (0, class_validator_1.IsOptional)(),
167
- tslib_1.__metadata("design:type", String)
168
- ], FindRuleDTO.prototype, "productType", void 0);
169
- tslib_1.__decorate([
170
- (0, swagger_1.ApiProperty)({
171
- type: String,
172
- required: false,
173
- }),
174
- (0, class_validator_1.IsNotEmpty)(),
175
- (0, class_validator_1.IsBoolean)(),
176
- (0, class_validator_1.IsOptional)(),
177
- tslib_1.__metadata("design:type", Boolean)
178
- ], FindRuleDTO.prototype, "isEnabled", void 0);
179
- tslib_1.__decorate([
180
- (0, swagger_1.ApiProperty)({
181
- type: String,
182
- required: false,
183
- }),
184
- (0, class_validator_1.IsNotEmpty)(),
185
- (0, class_validator_1.IsString)(),
186
- (0, class_validator_1.IsOptional)(),
187
- tslib_1.__metadata("design:type", String)
188
- ], FindRuleDTO.prototype, "provider", void 0);
189
- tslib_1.__decorate([
190
- (0, swagger_1.ApiProperty)({
191
- type: String,
192
- required: false,
193
- }),
194
- (0, class_validator_1.IsNotEmpty)(),
195
- (0, class_validator_1.IsString)(),
196
- (0, class_validator_1.IsOptional)(),
197
- tslib_1.__metadata("design:type", String)
198
- ], FindRuleDTO.prototype, "market", void 0);
@@ -1,7 +0,0 @@
1
- export interface IPagination<T> {
2
- currentPage: number;
3
- data: T;
4
- total: number;
5
- totalPages: number;
6
- }
7
- //# sourceMappingURL=pagination.interface.d.ts.map