@edirect/rate-limit-module 2.0.1 โ 2.0.3
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/README.md +240 -0
- package/dist/src/guards/rate-limiting.guard.d.ts +8 -0
- package/dist/src/guards/rate-limiting.guard.js +145 -76
- package/dist/src/guards/rate-limiting.guard.js.map +1 -1
- package/dist/src/rules/dto/rule.dto.d.ts +1 -1
- package/dist/src/rules/dto/rule.dto.js.map +1 -1
- package/dist/src/rules/interface/rule.interface.d.ts +1 -1
- package/dist/src/shared/dsl/dsl.service.js +3 -2
- package/dist/src/shared/dsl/dsl.service.js.map +1 -1
- package/dist/src/shared/rule-engine/rule-engine.service.d.ts +3 -2
- package/dist/src/shared/rule-engine/rule-engine.service.js +15 -4
- package/dist/src/shared/rule-engine/rule-engine.service.js.map +1 -1
- package/dist/test/mocks/rule.mocks.js +1 -0
- package/dist/test/mocks/rule.mocks.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -314,6 +314,246 @@ This is handled by utility functions like `buildDlsOp`, which map DSL constructs
|
|
|
314
314
|
|
|
315
315
|
By combining DSL definitions with path-based context extraction and safe runtime resolution, this module provides a highly flexible and secure rate-limiting engine ready for dynamic environments.
|
|
316
316
|
|
|
317
|
+
## ๐งพ Dynamic Query Context with `variables.queries`
|
|
318
|
+
|
|
319
|
+
The `variables` object is designed to allow structured dynamic query generation through an array of `queries`. Each query defines:
|
|
320
|
+
|
|
321
|
+
- The **function(s)** where this context will be injected (`fnContext`)
|
|
322
|
+
- The **parameters** to be resolved and passed (`query`)
|
|
323
|
+
- **Optional operations** and **default values**
|
|
324
|
+
|
|
325
|
+
### Structure of `variables.queries`
|
|
326
|
+
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"queries": [
|
|
330
|
+
{
|
|
331
|
+
"fnContext": ["countQuoteByParams"],
|
|
332
|
+
"query": [
|
|
333
|
+
{
|
|
334
|
+
"value": ":partner.partnerId",
|
|
335
|
+
"label": "partner.partnerId"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"value": ":productType",
|
|
339
|
+
"label": "productType"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"value": ":provider",
|
|
343
|
+
"label": "provider"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"value": ":applicant.documents[0].value",
|
|
347
|
+
"label": "applicant.documents.value"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"value": ":applicant.documents[0].type",
|
|
351
|
+
"label": "applicant.documents.type"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"label": "createdAt",
|
|
355
|
+
"op": "range",
|
|
356
|
+
"value": {
|
|
357
|
+
"to": "date(0)",
|
|
358
|
+
"from": "fn:getValueFromSale"
|
|
359
|
+
},
|
|
360
|
+
"defaultValue": {
|
|
361
|
+
"from": "date(-5d)",
|
|
362
|
+
"to": "date(0)"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### ๐ Explanation
|
|
372
|
+
|
|
373
|
+
Field
|
|
374
|
+
|
|
375
|
+
Description
|
|
376
|
+
|
|
377
|
+
`fnContext`
|
|
378
|
+
|
|
379
|
+
The name(s) of the function(s) that will receive this query as parameter input
|
|
380
|
+
|
|
381
|
+
`query`
|
|
382
|
+
|
|
383
|
+
Array of parameter definitions. Each will be resolved based on context or DSL expressions
|
|
384
|
+
|
|
385
|
+
`label`
|
|
386
|
+
|
|
387
|
+
The target field to be passed (e.g. used to generate a MongoDB query or as input to a service)
|
|
388
|
+
|
|
389
|
+
`value`
|
|
390
|
+
|
|
391
|
+
Can be a dynamic reference (e.g., `:context.path`), a static value, or a DSL expression
|
|
392
|
+
|
|
393
|
+
`op`
|
|
394
|
+
|
|
395
|
+
Optional. Defines the operator (`eq`, `range`, `rangeDate`, `gte`, etc.)
|
|
396
|
+
|
|
397
|
+
`defaultValue`
|
|
398
|
+
|
|
399
|
+
Fallback value(s) to be used if dynamic resolution fails (e.g., missing path or function)
|
|
400
|
+
|
|
401
|
+
----------
|
|
402
|
+
|
|
403
|
+
### ๐ง Special Value Formats
|
|
404
|
+
|
|
405
|
+
- `:path.to.value` โ Dynamically extracted from the context object
|
|
406
|
+
|
|
407
|
+
- `date(-7d)` โ Resolved as a safe date expression
|
|
408
|
+
|
|
409
|
+
- `fn:getValueFromSale` โ Calls a predefined function to resolve the value dynamically
|
|
410
|
+
|
|
411
|
+
- Static values like `"moneyhero"` are passed as-is
|
|
412
|
+
|
|
413
|
+
### ๐งช Use Case Example
|
|
414
|
+
|
|
415
|
+
Imagine your service defines a method like:
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
async countQuoteByParams(filters: Record<string, any>): Promise<number>
|
|
419
|
+
|
|
420
|
+
At runtime, the module will:
|
|
421
|
+
|
|
422
|
+
1. Resolve each `value` in the `query` array using context and supported expressions.
|
|
423
|
+
|
|
424
|
+
2. Construct a query object:
|
|
425
|
+
|
|
426
|
+
```json
|
|
427
|
+
{
|
|
428
|
+
partner: { partnerId: "bolttech" },
|
|
429
|
+
productType: "car-insurance",
|
|
430
|
+
provider: "bolttech",
|
|
431
|
+
applicant: {
|
|
432
|
+
documents: [{ type: "NIF", value: "ABCDE" }]
|
|
433
|
+
},
|
|
434
|
+
createdAt: {
|
|
435
|
+
from: new Date("2025-07-25T00:00:00Z"), // resolved from fn:getValueFromSale
|
|
436
|
+
to: new Date("2025-07-30T00:00:00Z") // resolved from date(0)
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
3. Inject this into `countQuoteByParams(...)`
|
|
442
|
+
This approach gives you a highly flexible, configurable system for controlling dynamic function parameters via context-based DSLs and runtime evaluation.
|
|
443
|
+
|
|
444
|
+
----------
|
|
445
|
+
## ๐ง Custom Runtime Functions with `variables.functions`
|
|
446
|
+
|
|
447
|
+
In addition to defining query parameters in `variables.queries`, the system also supports **custom runtime functions** through the `variables.functions` array.
|
|
448
|
+
|
|
449
|
+
These functions can be executed **before query construction** to compute values that are **injected** dynamically into query fields.
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
### ๐ง Structure of `functions`
|
|
454
|
+
|
|
455
|
+
Each function definition includes:
|
|
456
|
+
|
|
457
|
+
| Field | Description |
|
|
458
|
+
|------------|-----------------------------------------------------------------------------|
|
|
459
|
+
| `name` | Unique function identifier |
|
|
460
|
+
| `fn` | The function to execute, in the format `functionName(args...)` |
|
|
461
|
+
| `variables`| Parameters passed to the function, which can include subqueries and values |
|
|
462
|
+
|
|
463
|
+
### ๐ Example
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"functions": [
|
|
468
|
+
{
|
|
469
|
+
"name": "getValueFromSale",
|
|
470
|
+
"fn": "getValueFromSale(queries, target)",
|
|
471
|
+
"variables": {
|
|
472
|
+
"target": "createdAt",
|
|
473
|
+
"queries": [
|
|
474
|
+
{
|
|
475
|
+
"value": ":productType",
|
|
476
|
+
"label": "products.productType"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"value": ":applicant.documents[0].value",
|
|
480
|
+
"label": "applicant.documents.value"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"value": ":applicant.documents[0].type",
|
|
484
|
+
"label": "applicant.documents.type"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"value": "date(-5d)",
|
|
488
|
+
"label": "createdAt",
|
|
489
|
+
"op": "gte"
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
### ๐ Using the Function Output in Queries
|
|
498
|
+
|
|
499
|
+
To use the result of a function, reference it in a `query.value` using the syntax: `fn:functionName`.
|
|
500
|
+
|
|
501
|
+
json
|
|
502
|
+
|
|
503
|
+
CopyEdit
|
|
504
|
+
|
|
505
|
+
```json
|
|
506
|
+
{
|
|
507
|
+
"label":"createdAt",
|
|
508
|
+
"op":"range",
|
|
509
|
+
"value":{
|
|
510
|
+
"from":"fn:getValueFromSale",
|
|
511
|
+
"to":"date(0)"
|
|
512
|
+
},
|
|
513
|
+
"defaultValue":{
|
|
514
|
+
"from":"date(-5d)",
|
|
515
|
+
"to":"date(0)"
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
๐ In this case, `getValueFromSale(...)` will run **before** the query is constructed, and the result will be injected into the `from` field.
|
|
521
|
+
|
|
522
|
+
----------
|
|
523
|
+
|
|
524
|
+
### ๐งฉ How It Works
|
|
525
|
+
|
|
526
|
+
1. The engine scans all `functions` in `variables.functions`.
|
|
527
|
+
|
|
528
|
+
2. For each `query` entry in `variables.queries`, if `value` (or `from`, `to`) starts with `fn:`, it:
|
|
529
|
+
|
|
530
|
+
- Finds the corresponding `function` by name
|
|
531
|
+
|
|
532
|
+
- Resolves its `variables` (supporting nested `:context.paths`)
|
|
533
|
+
|
|
534
|
+
- Executes the declared function like `getValueFromSale(queries, target)`
|
|
535
|
+
|
|
536
|
+
3. The return value of the function replaces the `fn:` reference.
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
----------
|
|
540
|
+
|
|
541
|
+
### โ
Benefits
|
|
542
|
+
|
|
543
|
+
- Enables **pre-processing logic** in a declarative way
|
|
544
|
+
|
|
545
|
+
- Keeps rule/query definitions **clean and context-aware**
|
|
546
|
+
|
|
547
|
+
- Promotes **reuse** of custom logic across different rules or queries
|
|
548
|
+
|
|
549
|
+
- Provides **defaultValue** fallback in case of failure
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
----------
|
|
553
|
+
|
|
554
|
+
> ๐ก Tip: Functions must be registered and resolvable at runtime by your system. The evaluation engine must be able to map the function name (`getValueFromSale`) to a real implementation.
|
|
555
|
+
|
|
556
|
+
|
|
317
557
|
|
|
318
558
|
## ๐งฐ Requirements
|
|
319
559
|
|
|
@@ -9,4 +9,12 @@ export declare class RateLimitingRuleGuard implements CanActivate {
|
|
|
9
9
|
private readonly logger;
|
|
10
10
|
constructor(reflector: Reflector, ruleService: RuleService, ruleEngine: RuleEngineService);
|
|
11
11
|
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
12
|
+
private _getValueFromPathOrRoot;
|
|
13
|
+
private _resolveDateExpr;
|
|
14
|
+
private _resolveValue;
|
|
15
|
+
private _resolveVariables;
|
|
16
|
+
private _resolveParams;
|
|
17
|
+
private _getByPath;
|
|
18
|
+
private _injectFnsResults;
|
|
19
|
+
private _updateFnsResults;
|
|
12
20
|
}
|
|
@@ -39,12 +39,12 @@ let RateLimitingRuleGuard = RateLimitingRuleGuard_1 = class RateLimitingRuleGuar
|
|
|
39
39
|
const req = context.switchToHttp().getRequest();
|
|
40
40
|
const entity = req.body;
|
|
41
41
|
const { action, partnerPath, providerPath, productTypePath, marketPath, } = ruleMetaData;
|
|
42
|
-
const partner =
|
|
42
|
+
const partner = this._getValueFromPathOrRoot(entity, partnerPath);
|
|
43
43
|
if (!partner)
|
|
44
44
|
return true;
|
|
45
|
-
const provider =
|
|
46
|
-
const productType =
|
|
47
|
-
const market =
|
|
45
|
+
const provider = this._getValueFromPathOrRoot(entity, providerPath);
|
|
46
|
+
const productType = this._getValueFromPathOrRoot(entity, productTypePath);
|
|
47
|
+
const market = this._getValueFromPathOrRoot(entity, marketPath);
|
|
48
48
|
const parameters = {
|
|
49
49
|
enabled: 'true',
|
|
50
50
|
partner: partner,
|
|
@@ -60,7 +60,8 @@ let RateLimitingRuleGuard = RateLimitingRuleGuard_1 = class RateLimitingRuleGuar
|
|
|
60
60
|
if (!rules || !rules.length)
|
|
61
61
|
return true;
|
|
62
62
|
for (const rule of rules) {
|
|
63
|
-
|
|
63
|
+
await this._injectFnsResults(rule.variables, entity);
|
|
64
|
+
const contextVars = this._resolveVariables(rule.variables, entity);
|
|
64
65
|
const invalidExpressionMessage = this.ruleService.validateRuleExpression(rule.expression);
|
|
65
66
|
if (invalidExpressionMessage && invalidExpressionMessage.length) {
|
|
66
67
|
throw new common_1.HttpException(invalidExpressionMessage, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
@@ -85,87 +86,155 @@ let RateLimitingRuleGuard = RateLimitingRuleGuard_1 = class RateLimitingRuleGuar
|
|
|
85
86
|
return true;
|
|
86
87
|
}
|
|
87
88
|
catch (err) {
|
|
88
|
-
|
|
89
|
+
if (err instanceof common_1.HttpException && err.getStatus?.() === 429) {
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
], RateLimitingRuleGuard);
|
|
100
|
-
function getValueFromPathOrRoot(obj, path) {
|
|
101
|
-
const valueFromPath = path
|
|
102
|
-
.split('.')
|
|
103
|
-
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
|
|
104
|
-
if (valueFromPath !== undefined) {
|
|
105
|
-
return valueFromPath;
|
|
95
|
+
_getValueFromPathOrRoot(obj, path) {
|
|
96
|
+
const valueFromPath = path
|
|
97
|
+
.split('.')
|
|
98
|
+
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
|
|
99
|
+
if (valueFromPath !== undefined) {
|
|
100
|
+
return valueFromPath;
|
|
101
|
+
}
|
|
102
|
+
return obj?.[path];
|
|
106
103
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
104
|
+
_resolveDateExpr(expr) {
|
|
105
|
+
const match = expr.match(/^date\(([-\d]+)([dMy])?\)$/);
|
|
106
|
+
if (!match)
|
|
107
|
+
return expr;
|
|
108
|
+
const amount = parseInt(match[1], 10);
|
|
109
|
+
const unit = match[2] || 'd';
|
|
110
|
+
const date = new Date();
|
|
111
|
+
switch (unit) {
|
|
112
|
+
case 'd':
|
|
113
|
+
date.setDate(date.getDate() + amount);
|
|
114
|
+
break;
|
|
115
|
+
case 'M':
|
|
116
|
+
date.setMonth(date.getMonth() + amount);
|
|
117
|
+
break;
|
|
118
|
+
case 'y':
|
|
119
|
+
date.setFullYear(date.getFullYear() + amount);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (amount !== 0) {
|
|
123
|
+
date.setHours(0, 0, 0, 0);
|
|
124
|
+
}
|
|
125
|
+
return date.toISOString();
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
_resolveValue(raw, context, defaultValue) {
|
|
128
|
+
if (typeof raw === 'string') {
|
|
129
|
+
if (!raw) {
|
|
130
|
+
if (defaultValue)
|
|
131
|
+
return this._resolveValue(defaultValue, context);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (raw.startsWith(':')) {
|
|
135
|
+
const path = raw.slice(1);
|
|
136
|
+
const val = this._getByPath(context, path);
|
|
137
|
+
return this._resolveValue(val, context);
|
|
138
|
+
}
|
|
139
|
+
if (/^\s*fn:/.test(raw)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (raw.startsWith('date(')) {
|
|
143
|
+
return this._resolveDateExpr(raw);
|
|
144
|
+
}
|
|
145
|
+
return raw;
|
|
135
146
|
}
|
|
136
|
-
if (raw
|
|
137
|
-
return
|
|
147
|
+
if (typeof raw === 'object' && raw !== null && raw.from && raw.to) {
|
|
148
|
+
return {
|
|
149
|
+
from: this._resolveValue(raw.from, context),
|
|
150
|
+
to: this._resolveValue(raw.to, context)
|
|
151
|
+
};
|
|
138
152
|
}
|
|
139
153
|
return raw;
|
|
140
154
|
}
|
|
141
|
-
|
|
155
|
+
_resolveVariables(vars, context) {
|
|
156
|
+
if (!vars.queries || !vars.queries.length)
|
|
157
|
+
return vars;
|
|
158
|
+
return {
|
|
159
|
+
queries: vars.queries.map(q => ({
|
|
160
|
+
...q,
|
|
161
|
+
query: q.query.map(entry => ({
|
|
162
|
+
...entry,
|
|
163
|
+
value: this._resolveValue(entry.value, context, entry?.defaultValue)
|
|
164
|
+
}))
|
|
165
|
+
}))
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
_resolveParams(vars, context) {
|
|
169
|
+
if (!vars.variables || !vars.variables.queries || !vars.variables.queries.length)
|
|
170
|
+
return vars;
|
|
142
171
|
return {
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
...vars.variables,
|
|
173
|
+
queries: vars.variables.queries.map(q => ({
|
|
174
|
+
...q,
|
|
175
|
+
value: this._resolveValue(q.value, context, q?.defaultValue)
|
|
176
|
+
})),
|
|
145
177
|
};
|
|
146
178
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return acc[key];
|
|
179
|
+
_getByPath(obj, path) {
|
|
180
|
+
if (!path)
|
|
181
|
+
return undefined;
|
|
182
|
+
const parts = path.replace(/\[(\d+)\]/g, '.$1').split('.');
|
|
183
|
+
return parts.reduce((acc, key) => {
|
|
184
|
+
if (acc && typeof acc === 'object') {
|
|
185
|
+
return acc[key];
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}, obj);
|
|
189
|
+
}
|
|
190
|
+
async _injectFnsResults(variables, entity) {
|
|
191
|
+
if (!variables || !variables.functions)
|
|
192
|
+
return;
|
|
193
|
+
const fns = variables.functions;
|
|
194
|
+
for (const fn of fns) {
|
|
195
|
+
const contextVars = this._resolveParams(fn, entity);
|
|
196
|
+
const value = await this.ruleEngine.getResultCustomFunction(fn.fn, contextVars);
|
|
197
|
+
this._updateFnsResults(variables, fn.name, value);
|
|
167
198
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
199
|
+
}
|
|
200
|
+
_updateFnsResults(vars, fnName, value) {
|
|
201
|
+
vars.queries.forEach(q => {
|
|
202
|
+
q.query.forEach(cond => {
|
|
203
|
+
if (/^\s*fn:/.test(cond.value) || typeof cond.value === 'object') {
|
|
204
|
+
if (typeof cond.value === 'object') {
|
|
205
|
+
if (cond.value.to.replace(/^fn:/, '') === fnName) {
|
|
206
|
+
if (value) {
|
|
207
|
+
cond.value.to = value;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
cond.value.to = cond?.defaultValue?.to;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (cond.value?.from.replace(/^fn:/, '') === fnName) {
|
|
214
|
+
if (value) {
|
|
215
|
+
cond.value.from = value;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
cond.value.from = cond?.defaultValue?.from;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const name = cond.value.replace(/^fn:/, '');
|
|
224
|
+
if (name === fnName) {
|
|
225
|
+
cond.value = value;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
exports.RateLimitingRuleGuard = RateLimitingRuleGuard;
|
|
233
|
+
exports.RateLimitingRuleGuard = RateLimitingRuleGuard = RateLimitingRuleGuard_1 = __decorate([
|
|
234
|
+
(0, common_1.Injectable)(),
|
|
235
|
+
__param(2, (0, common_1.Inject)('RULE_ENGINE_INSTANCE')),
|
|
236
|
+
__metadata("design:paramtypes", [core_1.Reflector,
|
|
237
|
+
rule_service_1.RuleService,
|
|
238
|
+
rule_engine_service_1.RuleEngineService])
|
|
239
|
+
], RateLimitingRuleGuard);
|
|
171
240
|
//# sourceMappingURL=rate-limiting.guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiting.guard.js","sourceRoot":"","sources":["../../../src/guards/rate-limiting.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,uCAAyC;AACzC,6FAGoD;AACpD,kDAAkD;AAElD,wDAAoD;AACpD,mFAA8E;
|
|
1
|
+
{"version":3,"file":"rate-limiting.guard.js","sourceRoot":"","sources":["../../../src/guards/rate-limiting.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,uCAAyC;AACzC,6FAGoD;AACpD,kDAAkD;AAElD,wDAAoD;AACpD,mFAA8E;AAgBvE,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAIb;IACA;IAEA;IANF,MAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAEjE,YACmB,SAAoB,EACpB,WAAwB,EAExB,UAA6B;QAH7B,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAa;QAExB,eAAU,GAAV,UAAU,CAAmB;IAC7C,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YAErC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CACrC,4CAAa,EACb,OAAO,CACR,CAAC;YAEF,IAAI,CAAC,YAAY;gBAAE,OAAO,I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CAAC,CAAC;oBAE5C,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;wBAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;oBACvB,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhRY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;qCAFH,gBAAS;QACP,0BAAW;QAEZ,uCAAiB;GAPrC,qBAAqB,CAgRjC"}
|
|
@@ -5,7 +5,7 @@ export declare class CreateRuleDTO implements IRule {
|
|
|
5
5
|
expression: string;
|
|
6
6
|
targetAction: string;
|
|
7
7
|
errorMessage?: string;
|
|
8
|
-
variables?: Record<string,
|
|
8
|
+
variables?: Record<string, unknown>;
|
|
9
9
|
variablesRequired?: boolean;
|
|
10
10
|
productType?: string;
|
|
11
11
|
partner?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.dto.js","sourceRoot":"","sources":["../../../../src/rules/dto/rule.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAwF;AACxF,oEAAoE;AAEpE,qDAAiD;AAGjD,MAAa,aAAa;IAOxB,IAAI,CAAS;IASb,UAAU,CAAS;IAQnB,YAAY,CAAS;IASrB,YAAY,CAAU;IAStB,SAAS,
|
|
1
|
+
{"version":3,"file":"rule.dto.js","sourceRoot":"","sources":["../../../../src/rules/dto/rule.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAwF;AACxF,oEAAoE;AAEpE,qDAAiD;AAGjD,MAAa,aAAa;IAOxB,IAAI,CAAS;IASb,UAAU,CAAS;IAQnB,YAAY,CAAS;IASrB,YAAY,CAAU;IAStB,SAAS,CAA2B;IASpC,iBAAiB,CAAW;IAS5B,WAAW,CAAU;IAQrB,OAAO,CAAU;IAS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AAM;QACZ,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;gDACQ;AASrB;IAPC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;8CACO;AASpB;IAPC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6CACK;AAUlB;IAPC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;2CACG"}
|
|
@@ -5,11 +5,12 @@ const dayjs_1 = require("dayjs");
|
|
|
5
5
|
class DslService {
|
|
6
6
|
static buildFilter = (query) => {
|
|
7
7
|
return query.reduce((acc, cur) => {
|
|
8
|
-
if (!cur ||
|
|
8
|
+
if (!cur || !cur.label)
|
|
9
9
|
return acc;
|
|
10
|
+
const value = cur.value ?? '';
|
|
10
11
|
return {
|
|
11
12
|
...acc,
|
|
12
|
-
[cur.label]: this.#buildOp(cur.op,
|
|
13
|
+
[cur.label]: this.#buildOp(cur.op, value),
|
|
13
14
|
};
|
|
14
15
|
}, {});
|
|
15
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dsl.service.js","sourceRoot":"","sources":["../../../../src/shared/dsl/dsl.service.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAI1B,MAAa,UAAU;IACrB,MAAM,CAAC,WAAW,GAAG,CAAC,KAAsB,EAAa,EAAE;QACzD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AC9B,IAAA,eAAK,GAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE;oBACvC,EAAE,EAAG,IAAI,CAAC,EAAsB,IAAI,IAAI,IAAI,EAAE;iBAC/C,EAAC,CAAA;QACJ,CAAC;QAED,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,GAAG,KAAY,CAAC;YAC1B,OAAO;gBACL,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,EAAE,EAAE,IAAI,CAAC,EAAE;iBACZ;aACF,CAAA;QACH,CAAC;QAED,OAAO,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,CAAA;IAChC,CAAC,CAAA;;AAjFH,gCAkFC"}
|
|
@@ -5,12 +5,13 @@ export declare class RuleEngineService {
|
|
|
5
5
|
private readonly allowedFns;
|
|
6
6
|
constructor(jexl: any, fns?: IRuleFunction[]);
|
|
7
7
|
evaluate<T>(expression: string, context: T): Promise<boolean>;
|
|
8
|
+
getResultCustomFunction(fnName: any, context: any): Promise<any>;
|
|
8
9
|
validateExpressionVariables<T>(expression: string, context: T): Promise<string[]>;
|
|
9
10
|
validateFunctionsAreValid(expression: any): String[];
|
|
10
11
|
getAllowedFunctions(): String[];
|
|
11
12
|
injectCustomFns(): void;
|
|
12
13
|
private _extractVariables;
|
|
13
14
|
private _validateVariablesInContext;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
15
|
+
private _extractFunctionCalls;
|
|
16
|
+
private _resolveValue;
|
|
16
17
|
}
|