@edirect/rate-limit-module 1.0.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -29
- package/dist/src/guards/rate-limiting.guard.js +67 -8
- package/dist/src/guards/rate-limiting.guard.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/shared/dls/dsl.interface.d.ts +42 -0
- package/dist/src/shared/dls/dsl.interface.js +10 -0
- package/dist/src/shared/dls/dsl.interface.js.map +1 -0
- package/dist/src/shared/dls/dsl.utils.d.ts +3 -0
- package/dist/src/shared/dls/dsl.utils.js +73 -0
- package/dist/src/shared/dls/dsl.utils.js.map +1 -0
- package/dist/src/shared/dsl/dsl.interface.d.ts +42 -0
- package/dist/src/shared/dsl/dsl.interface.js +10 -0
- package/dist/src/shared/dsl/dsl.interface.js.map +1 -0
- package/dist/src/shared/dsl/dsl.service.d.ts +6 -0
- package/dist/src/shared/dsl/dsl.service.js +74 -0
- package/dist/src/shared/dsl/dsl.service.js.map +1 -0
- package/dist/src/shared/dsl/dsl.utils.d.ts +3 -0
- package/dist/src/shared/dsl/dsl.utils.js +73 -0
- package/dist/src/shared/dsl/dsl.utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,102 +1,343 @@
|
|
|
1
1
|
# 📈 Rate Limiting Module
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
This module provides a flexible **rate-limiting system** where access to operations can be restricted based on dynamic **rule expressions** such as `count_quote( ) > 1`. If the condition evaluates to `true`, access is **blocked**.
|
|
6
|
+
|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
## ✨ Features
|
|
6
10
|
|
|
11
|
+
|
|
12
|
+
|
|
7
13
|
- Define rate-limiting rules with custom expressions.
|
|
14
|
+
|
|
8
15
|
- Dynamically inject context-aware functions for rule evaluation.
|
|
16
|
+
|
|
9
17
|
- Easily integrate with any resource via a decorator.
|
|
18
|
+
|
|
10
19
|
- Built with extensibility and modularity in mind.
|
|
11
20
|
|
|
21
|
+
|
|
22
|
+
|
|
12
23
|
## 🧱 How It Works
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
1. You define a rule using a simple expression (e.g., `count_quote( ) > 1`).
|
|
28
|
+
|
|
15
29
|
2. The rule is evaluated in runtime using data injected from the request context.
|
|
30
|
+
|
|
16
31
|
3. If the expression is true, the action is blocked.
|
|
17
32
|
|
|
33
|
+
|
|
34
|
+
|
|
18
35
|
## 🧩 Usage
|
|
19
36
|
|
|
37
|
+
|
|
38
|
+
|
|
20
39
|
### 1. Install the Module
|
|
21
40
|
|
|
41
|
+
|
|
42
|
+
|
|
22
43
|
```ts
|
|
44
|
+
|
|
23
45
|
@Module({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
|
|
47
|
+
imports: [
|
|
48
|
+
|
|
49
|
+
RateLimitingModule,
|
|
50
|
+
|
|
51
|
+
RuleEngineModule.forFeatureAsync({
|
|
52
|
+
|
|
53
|
+
useFactory: async (quoteService: QuoteService) => {
|
|
54
|
+
|
|
55
|
+
return await quoteService.countQuote();
|
|
56
|
+
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
inject: [QuoteService],
|
|
60
|
+
|
|
61
|
+
}),
|
|
62
|
+
|
|
63
|
+
],
|
|
64
|
+
|
|
33
65
|
})
|
|
34
|
-
|
|
66
|
+
|
|
67
|
+
export class YourFeatureModule {}
|
|
68
|
+
|
|
35
69
|
```
|
|
36
70
|
|
|
71
|
+
|
|
72
|
+
|
|
37
73
|
## 2. Decorate Your Handlers
|
|
38
74
|
|
|
75
|
+
|
|
76
|
+
|
|
39
77
|
Use the `@RateLimitingRuleMetadata` decorator to attach metadata used during rule evaluation.
|
|
40
78
|
|
|
79
|
+
|
|
80
|
+
|
|
41
81
|
```ts
|
|
42
|
-
|
|
82
|
+
|
|
83
|
+
import { RateLimitingRuleMetadata } from 'path-to-rate-limiting-module';
|
|
84
|
+
|
|
85
|
+
|
|
43
86
|
|
|
44
87
|
@RateLimitingRuleMetadata({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
|
|
89
|
+
action: 'create_quote',
|
|
90
|
+
|
|
91
|
+
partnerPath: 'partner.partnerId',
|
|
92
|
+
|
|
93
|
+
providerPath: 'provider',
|
|
94
|
+
|
|
95
|
+
productTypePath: 'productType',
|
|
96
|
+
|
|
97
|
+
marketPath: 'market',
|
|
98
|
+
|
|
49
99
|
})
|
|
100
|
+
|
|
50
101
|
@Post('quotes')
|
|
102
|
+
|
|
51
103
|
createQuote(@Body() body: CreateQuoteDto) {
|
|
52
|
-
|
|
104
|
+
|
|
105
|
+
return this.quoteService.create(body);
|
|
106
|
+
|
|
53
107
|
}
|
|
108
|
+
|
|
54
109
|
```
|
|
55
110
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
* `action`: Name of the action to be controlled.
|
|
114
|
+
|
|
115
|
+
* `partnerPath`: Path to extract the partner ID from the request context.
|
|
116
|
+
|
|
117
|
+
* `providerPath`: Path to extract the provider.
|
|
118
|
+
|
|
119
|
+
* `productTypePath`: Path to extract the product type.
|
|
120
|
+
|
|
121
|
+
|
|
60
122
|
|
|
61
123
|
## 🛠 Rule Engine Integration
|
|
62
124
|
|
|
125
|
+
|
|
126
|
+
|
|
63
127
|
This module depends on an underlying rule engine to evaluate expressions. You must provide the functions used in expressions through:
|
|
64
128
|
|
|
129
|
+
|
|
130
|
+
|
|
65
131
|
```ts
|
|
132
|
+
|
|
66
133
|
RuleEngineModule.forFeatureAsync({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
134
|
+
|
|
135
|
+
useFactory: async (useCase: RateLimitingInjectFunctionsUseCase) => {
|
|
136
|
+
|
|
137
|
+
return await useCase.getFunctions();
|
|
138
|
+
|
|
139
|
+
// returns an object like { count_quote: async () => number }
|
|
140
|
+
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
inject: [RateLimitingInjectFunctionsUseCase],
|
|
144
|
+
|
|
72
145
|
});
|
|
146
|
+
|
|
73
147
|
```
|
|
74
148
|
|
|
149
|
+
|
|
150
|
+
|
|
75
151
|
## 🧪 Example Rule
|
|
76
152
|
|
|
153
|
+
|
|
77
154
|
A rule stored in your system might look like:
|
|
78
155
|
|
|
156
|
+
|
|
79
157
|
```json
|
|
158
|
+
|
|
80
159
|
{
|
|
81
|
-
|
|
82
|
-
|
|
160
|
+
"expression": "count_quote() > 1",
|
|
161
|
+
"action": "create_quote"
|
|
83
162
|
}
|
|
163
|
+
|
|
84
164
|
```
|
|
85
165
|
|
|
166
|
+
|
|
167
|
+
|
|
86
168
|
If the expression returns `true`, the rate limiter will block further `create_quote` actions for the user based on the context values.
|
|
87
169
|
|
|
170
|
+
|
|
171
|
+
## 🧠 Dynamic Parameter Resolution
|
|
172
|
+
|
|
173
|
+
When building queries based on request context, it's possible to reference nested values using paths. This system supports:
|
|
174
|
+
|
|
175
|
+
- Resolving values using variable placeholders like `:applicant.documents[0].value`.
|
|
176
|
+
|
|
177
|
+
- Interpreting date expressions safely, like `date(-5d)` (5 days ago), without using `eval`.
|
|
178
|
+
|
|
179
|
+
### Supported Syntax
|
|
180
|
+
```json
|
|
181
|
+
|
|
182
|
+
{
|
|
183
|
+
"value": ":applicant.documents[0].value",
|
|
184
|
+
"label": "applicant.documents.value"
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Will extract the value from the context:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"applicant": {
|
|
194
|
+
"documents": [
|
|
195
|
+
{ "type": "NIF", "value": "ABCDE" }
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
Result: `"ABCDE"`
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
You can also use dynamic dates:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"value": "date(-7d)",
|
|
208
|
+
"label": "createdAt",
|
|
209
|
+
"op": "gte"
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Result: `"2025-07-10T00:00:00.000Z"` (7 days ago)
|
|
214
|
+
|
|
215
|
+
### Supported Date Units
|
|
216
|
+
|
|
217
|
+
- `d`: Days (default)
|
|
218
|
+
|
|
219
|
+
- `M`: Months
|
|
220
|
+
|
|
221
|
+
- `y`: Years
|
|
222
|
+
|
|
223
|
+
Examples:
|
|
224
|
+
|
|
225
|
+
- `date(-5d)` → 5 days ago
|
|
226
|
+
|
|
227
|
+
- `date(-1M)` → 1 month ago
|
|
228
|
+
|
|
229
|
+
- `date(0)` → Today
|
|
230
|
+
|
|
231
|
+
No dynamic code execution (`eval`, `new Function`) is used — expressions are parsed securely.
|
|
232
|
+
|
|
233
|
+
## ⚙️ Supported Operators (`op`)
|
|
234
|
+
|
|
235
|
+
You can optionally define an `op` (operation) field to specify how the value should be interpreted. The system currently supports:
|
|
236
|
+
|
|
237
|
+
### `gte` — Greater Than or Equal (usually for dates)
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"value": "date(-7d)",
|
|
242
|
+
"label": "createdAt",
|
|
243
|
+
"op": "gte"
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
🔍 This means: only include records created after **7 days ago**.
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"value": {
|
|
251
|
+
"from": 1,
|
|
252
|
+
"to": 10
|
|
253
|
+
},
|
|
254
|
+
"label": "createdAt",
|
|
255
|
+
"op": "range"
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
🔍 This sets a static date or value range. Can be used for numbers, dates, or custom fields.
|
|
259
|
+
|
|
260
|
+
### `rangeDate` — Dynamic Date Range
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"value": {
|
|
265
|
+
"from": "date(-30d)",
|
|
266
|
+
"to": "date(0)"
|
|
267
|
+
},
|
|
268
|
+
"label": "createdAt",
|
|
269
|
+
"op": "rangeDate"
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
🔍 This automatically resolves both `from` and `to` values as dates. For example, this would generate a date range from **30 days ago** to **now**.
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
## 🧬 DSL Support and MongoDB Integration
|
|
276
|
+
|
|
277
|
+
This module uses a lightweight **DSL (Domain-Specific Language)** to define rules and filters in a declarative and expressive way.
|
|
278
|
+
|
|
279
|
+
### What is a DSL?
|
|
280
|
+
|
|
281
|
+
A **DSL** is a simplified, pseudo-language designed for expressing business logic in a readable and configurable format. In this module, the DSL is used to define:
|
|
282
|
+
|
|
283
|
+
- Conditional expressions (e.g., `count_quote() > 1`)
|
|
284
|
+
- Filter structures using dynamic context variables and operators (`eq`, `range`, `gte`, etc.)
|
|
285
|
+
|
|
286
|
+
These DSL expressions are **not executed as raw code**, but safely parsed and evaluated using resolvers and expression evaluators.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
### DSL to MongoDB Filter Conversion
|
|
291
|
+
|
|
292
|
+
One powerful feature of this module is the ability to **transform DSL filters into MongoDB-compatible query objects**.
|
|
293
|
+
|
|
294
|
+
For example, the following DSL input:
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
createdAt: {
|
|
298
|
+
$gte: new Date('2025-06-17T00:00:00.000Z'),
|
|
299
|
+
$lte: new Date('2025-07-17T00:00:00.000Z')
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
This is handled by utility functions like `buildDlsOp`, which map DSL constructs to database query.
|
|
304
|
+
|
|
305
|
+
### ✅ Benefits of Using DSL
|
|
306
|
+
|
|
307
|
+
- **Separation of logic from code:** Business rules can be stored in DB or configs
|
|
308
|
+
|
|
309
|
+
- **Extensibility:** Easy to support new operators or DB backends (e.g., SQL, Elasticsearch)
|
|
310
|
+
|
|
311
|
+
- **Security:** No raw `eval` or dynamic JS execution
|
|
312
|
+
|
|
313
|
+
- **Readability:** DSL is expressive for non-technical stakeholders
|
|
314
|
+
|
|
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
|
+
|
|
317
|
+
|
|
88
318
|
## 🧰 Requirements
|
|
89
319
|
|
|
320
|
+
|
|
90
321
|
* NestJS
|
|
322
|
+
|
|
91
323
|
* RuleEngineModule (compatible expression parser/executor)
|
|
324
|
+
|
|
92
325
|
* Custom service to inject context functions (like `RateLimitingInjectFunctionsUseCase`)
|
|
93
326
|
|
|
327
|
+
|
|
94
328
|
## 📎 Notes
|
|
329
|
+
|
|
95
330
|
|
|
96
331
|
* Rules should be defined and stored externally (e.g., DB, config).
|
|
332
|
+
|
|
97
333
|
* The context extractor paths must match the structure of your handler inputs (e.g., body, params).
|
|
334
|
+
|
|
98
335
|
* Ensure `getFunctions()` returns **async functions** that provide the required values for the expression.
|
|
99
336
|
|
|
337
|
+
|
|
338
|
+
|
|
100
339
|
## 🧾 License
|
|
101
340
|
|
|
341
|
+
|
|
342
|
+
|
|
102
343
|
MIT
|
|
@@ -60,30 +60,27 @@ let RateLimitingRuleGuard = RateLimitingRuleGuard_1 = class RateLimitingRuleGuar
|
|
|
60
60
|
if (!rules || !rules.length)
|
|
61
61
|
return true;
|
|
62
62
|
for (const rule of rules) {
|
|
63
|
-
const contextVars =
|
|
64
|
-
...entity,
|
|
65
|
-
...rule.variables,
|
|
66
|
-
};
|
|
63
|
+
const contextVars = resolveVariables(rule.variables, entity);
|
|
67
64
|
const invalidExpressionMessage = this.ruleService.validateRuleExpression(rule.expression);
|
|
68
65
|
if (invalidExpressionMessage && invalidExpressionMessage.length) {
|
|
69
|
-
throw new common_1.
|
|
66
|
+
throw new common_1.HttpException(invalidExpressionMessage, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
70
67
|
}
|
|
71
68
|
const invalidFunctions = this.ruleEngine.validateFunctionsAreValid(rule.expression);
|
|
72
69
|
if (invalidFunctions && invalidFunctions.length) {
|
|
73
|
-
throw new common_1.
|
|
70
|
+
throw new common_1.HttpException(`these functions are not allowed ${invalidFunctions.join(', ')}`, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
74
71
|
}
|
|
75
72
|
if (rule.variablesRequired) {
|
|
76
73
|
const missingVars = await this.ruleEngine.validateExpressionVariables(rule.expression, contextVars);
|
|
77
74
|
if (missingVars && missingVars.length) {
|
|
78
75
|
this.logger.debug(`[RATE LIMITER] rule - ${rule.name} requires theses variables ${JSON.stringify(missingVars)}`);
|
|
79
|
-
throw new common_1.
|
|
76
|
+
throw new common_1.HttpException(`For rate limiting validation these variables are required ${JSON.stringify(missingVars)}`, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
79
|
const safeContextVars = (0, object_utils_1.withDefaultNull)(contextVars);
|
|
83
80
|
const notAllowed = await this.ruleEngine.evaluate(rule.expression, safeContextVars);
|
|
84
81
|
this.logger.debug(`[RATE LIMITER] rule - ${rule.name} reached the limit`);
|
|
85
82
|
if (notAllowed)
|
|
86
|
-
throw new common_1.
|
|
83
|
+
throw new common_1.HttpException(rule.errorMessage || `Rate Limiting rule reached limit`, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
87
84
|
}
|
|
88
85
|
return true;
|
|
89
86
|
}
|
|
@@ -109,4 +106,66 @@ function getValueFromPathOrRoot(obj, path) {
|
|
|
109
106
|
}
|
|
110
107
|
return obj?.[path];
|
|
111
108
|
}
|
|
109
|
+
function resolveDateExpr(expr) {
|
|
110
|
+
const match = expr.match(/^date\(([-\d]+)([dMy])?\)$/);
|
|
111
|
+
if (!match)
|
|
112
|
+
return expr;
|
|
113
|
+
const amount = parseInt(match[1], 10);
|
|
114
|
+
const unit = match[2] || 'd';
|
|
115
|
+
const date = new Date();
|
|
116
|
+
switch (unit) {
|
|
117
|
+
case 'd':
|
|
118
|
+
date.setDate(date.getDate() + amount);
|
|
119
|
+
break;
|
|
120
|
+
case 'M':
|
|
121
|
+
date.setMonth(date.getMonth() + amount);
|
|
122
|
+
break;
|
|
123
|
+
case 'y':
|
|
124
|
+
date.setFullYear(date.getFullYear() + amount);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return date.toISOString();
|
|
128
|
+
}
|
|
129
|
+
function resolveValue(raw, context) {
|
|
130
|
+
if (typeof raw === 'string') {
|
|
131
|
+
if (raw.startsWith(':')) {
|
|
132
|
+
const path = raw.slice(1);
|
|
133
|
+
const val = getByPath(context, path);
|
|
134
|
+
return resolveValue(val, context);
|
|
135
|
+
}
|
|
136
|
+
if (raw.startsWith('date(')) {
|
|
137
|
+
return resolveDateExpr(raw);
|
|
138
|
+
}
|
|
139
|
+
return raw;
|
|
140
|
+
}
|
|
141
|
+
if (typeof raw === 'object' && raw !== null && raw.from && raw.to) {
|
|
142
|
+
return {
|
|
143
|
+
from: resolveValue(raw.from, context),
|
|
144
|
+
to: resolveValue(raw.to, context)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return raw;
|
|
148
|
+
}
|
|
149
|
+
function resolveVariables(vars, context) {
|
|
150
|
+
return {
|
|
151
|
+
queries: vars.queries.map(q => ({
|
|
152
|
+
...q,
|
|
153
|
+
query: q.query.map(entry => ({
|
|
154
|
+
...entry,
|
|
155
|
+
value: resolveValue(entry.value, context)
|
|
156
|
+
}))
|
|
157
|
+
}))
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function getByPath(obj, path) {
|
|
161
|
+
if (!path)
|
|
162
|
+
return undefined;
|
|
163
|
+
const parts = path.replace(/\[(\d+)\]/g, '.$1').split('.');
|
|
164
|
+
return parts.reduce((acc, key) => {
|
|
165
|
+
if (acc && typeof acc === 'object') {
|
|
166
|
+
return acc[key];
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}, obj);
|
|
170
|
+
}
|
|
112
171
|
//# 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,
|
|
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;AAGvE,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,IAAI,CAAC;YAE/B,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CA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C,IAAI,EAAE,OAAO;IACrC,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC9B,GAAG,CAAC;YACJ,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC3B,GAAG,KAAK;gBACR,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC;aAC1C,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAGD,SAAS,SAAS,CAAC,GAAG,EAAE,IAAI;IAC1B,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAE5B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './decorators/rate-limiting-rule.decorator';
|
|
2
2
|
export * from './guards/rate-limiting.guard';
|
|
3
3
|
export * from './rate-limiting.module';
|
|
4
|
+
export * from './shared/dsl/dsl.interface';
|
|
5
|
+
export * from './shared/dsl/dsl.service';
|
|
4
6
|
export * from './shared/rule-engine/rule-engine.module';
|
|
5
7
|
export * from './validators/rule.constraint';
|
|
6
8
|
export declare const RULE_ENGINE_INSTANCE = "RULE_ENGINE_INSTANCE";
|
package/dist/src/index.js
CHANGED
|
@@ -18,6 +18,8 @@ exports.CUSTOM_RULE_FUNCTIONS = exports.RULE_ENGINE_INSTANCE = void 0;
|
|
|
18
18
|
__exportStar(require("./decorators/rate-limiting-rule.decorator"), exports);
|
|
19
19
|
__exportStar(require("./guards/rate-limiting.guard"), exports);
|
|
20
20
|
__exportStar(require("./rate-limiting.module"), exports);
|
|
21
|
+
__exportStar(require("./shared/dsl/dsl.interface"), exports);
|
|
22
|
+
__exportStar(require("./shared/dsl/dsl.service"), exports);
|
|
21
23
|
__exportStar(require("./shared/rule-engine/rule-engine.module"), exports);
|
|
22
24
|
__exportStar(require("./validators/rule.constraint"), exports);
|
|
23
25
|
exports.RULE_ENGINE_INSTANCE = 'RULE_ENGINE_INSTANCE';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4EAA0D;AAC1D,+DAA6C;AAC7C,yDAAuC;AACvC,0EAAwD;AACxD,+DAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4EAA0D;AAC1D,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AACzC,0EAAwD;AACxD,+DAA6C;AAEhC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type Primitive = string | number | boolean | Date;
|
|
2
|
+
interface EqFilter<T = Primitive> {
|
|
3
|
+
eq: T;
|
|
4
|
+
}
|
|
5
|
+
interface InFilter<T = Primitive> {
|
|
6
|
+
in: T[];
|
|
7
|
+
}
|
|
8
|
+
interface RangeFilter<T = Date | number> {
|
|
9
|
+
range: {
|
|
10
|
+
from?: T;
|
|
11
|
+
to?: T;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface GteFilter<T = Date | number> {
|
|
15
|
+
gte: T;
|
|
16
|
+
}
|
|
17
|
+
interface LteFilter<T = Date | number> {
|
|
18
|
+
lte: T;
|
|
19
|
+
}
|
|
20
|
+
interface ElemMatchFilter {
|
|
21
|
+
elemMatch: FilterDsl;
|
|
22
|
+
}
|
|
23
|
+
type FieldFilter = EqFilter | InFilter | RangeFilter | ElemMatchFilter | LteFilter | GteFilter;
|
|
24
|
+
export interface FilterDsl {
|
|
25
|
+
or?: FilterDsl[];
|
|
26
|
+
[field: string]: FieldFilter | FilterDsl[] | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface IDlsQuery {
|
|
29
|
+
fnContext: string;
|
|
30
|
+
query: IDlsQueryItem[];
|
|
31
|
+
}
|
|
32
|
+
export interface IDlsQueryItem {
|
|
33
|
+
label: string;
|
|
34
|
+
value: unknown;
|
|
35
|
+
op: OperationDlsEnum;
|
|
36
|
+
}
|
|
37
|
+
export declare enum OperationDlsEnum {
|
|
38
|
+
EQ = "eq",
|
|
39
|
+
RANGE = "range",
|
|
40
|
+
GTE = "gte"
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationDlsEnum = void 0;
|
|
4
|
+
var OperationDlsEnum;
|
|
5
|
+
(function (OperationDlsEnum) {
|
|
6
|
+
OperationDlsEnum["EQ"] = "eq";
|
|
7
|
+
OperationDlsEnum["RANGE"] = "range";
|
|
8
|
+
OperationDlsEnum["GTE"] = "gte";
|
|
9
|
+
})(OperationDlsEnum || (exports.OperationDlsEnum = OperationDlsEnum = {}));
|
|
10
|
+
//# sourceMappingURL=dsl.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsl.interface.js","sourceRoot":"","sources":["../../../../src/shared/dls/dsl.interface.ts"],"names":[],"mappings":";;;AAsDA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,mCAAe,CAAA;IACf,+BAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dslToMongoQuery = exports.buildDlsFilter = void 0;
|
|
4
|
+
const dayjs_1 = require("dayjs");
|
|
5
|
+
const buildDlsFilter = (query) => {
|
|
6
|
+
return query.reduce((acc, cur) => {
|
|
7
|
+
if (!cur || (!cur.label && !cur.value))
|
|
8
|
+
return acc;
|
|
9
|
+
return {
|
|
10
|
+
...acc,
|
|
11
|
+
[cur.label]: buildDlsOp(cur.op, cur.value),
|
|
12
|
+
};
|
|
13
|
+
}, {});
|
|
14
|
+
};
|
|
15
|
+
exports.buildDlsFilter = buildDlsFilter;
|
|
16
|
+
const buildDlsOp = (op, value) => {
|
|
17
|
+
if (op === 'rangeDate') {
|
|
18
|
+
const data = value;
|
|
19
|
+
return { range: {
|
|
20
|
+
from: data.from ||
|
|
21
|
+
(0, dayjs_1.default)().subtract(1, 'month').toDate(),
|
|
22
|
+
to: data.to || new Date(),
|
|
23
|
+
} };
|
|
24
|
+
}
|
|
25
|
+
if (op === 'range') {
|
|
26
|
+
const data = value;
|
|
27
|
+
return {
|
|
28
|
+
range: {
|
|
29
|
+
from: data.from,
|
|
30
|
+
to: data.to,
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return { [op || 'eq']: value };
|
|
35
|
+
};
|
|
36
|
+
const dslToMongoQuery = (filter) => {
|
|
37
|
+
const query = {};
|
|
38
|
+
for (const key in filter) {
|
|
39
|
+
const condition = filter[key];
|
|
40
|
+
if (key === 'or') {
|
|
41
|
+
query['$or'] = condition.map((subCond) => (0, exports.dslToMongoQuery)(subCond));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (condition.eq !== undefined) {
|
|
45
|
+
query[key] = condition.eq;
|
|
46
|
+
}
|
|
47
|
+
if (condition.in) {
|
|
48
|
+
query[key] = { $in: condition.in };
|
|
49
|
+
}
|
|
50
|
+
if (condition.range) {
|
|
51
|
+
query[key] = {};
|
|
52
|
+
if (condition.range.from)
|
|
53
|
+
query[key]['$gte'] = condition.range.from;
|
|
54
|
+
if (condition.range.to)
|
|
55
|
+
query[key]['$lte'] = condition.range.to;
|
|
56
|
+
}
|
|
57
|
+
if (condition.gte) {
|
|
58
|
+
query[key] = {};
|
|
59
|
+
query[key]['$gte'] = condition.gte;
|
|
60
|
+
}
|
|
61
|
+
if (condition.lte) {
|
|
62
|
+
query[key]['$lte'] = condition.lte;
|
|
63
|
+
}
|
|
64
|
+
if (condition.elemMatch) {
|
|
65
|
+
query[key] = {
|
|
66
|
+
$elemMatch: (0, exports.dslToMongoQuery)(condition.elemMatch),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return query;
|
|
71
|
+
};
|
|
72
|
+
exports.dslToMongoQuery = dslToMongoQuery;
|
|
73
|
+
//# sourceMappingURL=dsl.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsl.utils.js","sourceRoot":"","sources":["../../../../src/shared/dls/dsl.utils.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAGnB,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAa,EAAE;IAClE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC;QAElD,OAAO;YACL,GAAG,GAAG;YACN,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CA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