@edirect/rate-limit-module 11.0.45 โ†’ 11.0.46

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/dist/README.md +499 -0
  2. package/dist/package.json +41 -0
  3. package/dist/src/decorators/rate-limiting-rule.decorator.d.ts +10 -0
  4. package/dist/src/decorators/rate-limiting-rule.decorator.d.ts.map +1 -0
  5. package/dist/src/decorators/rate-limiting-rule.decorator.js +7 -0
  6. package/dist/src/guards/rate-limiting.guard.d.ts +21 -0
  7. package/dist/src/guards/rate-limiting.guard.d.ts.map +1 -0
  8. package/dist/src/guards/rate-limiting.guard.js +248 -0
  9. package/dist/src/index.d.ts +11 -0
  10. package/dist/src/index.d.ts.map +1 -0
  11. package/dist/src/index.js +14 -0
  12. package/dist/src/main.d.ts +2 -0
  13. package/dist/src/main.d.ts.map +1 -0
  14. package/dist/src/main.js +9 -0
  15. package/dist/src/object.utils.d.ts +3 -0
  16. package/dist/src/object.utils.d.ts.map +1 -0
  17. package/dist/src/object.utils.js +38 -0
  18. package/dist/src/rate-limiting.module.d.ts +3 -0
  19. package/dist/src/rate-limiting.module.d.ts.map +1 -0
  20. package/dist/src/rate-limiting.module.js +31 -0
  21. package/dist/src/rules/dto/pagination.dto.d.ts +6 -0
  22. package/dist/src/rules/dto/pagination.dto.d.ts.map +1 -0
  23. package/dist/src/rules/dto/pagination.dto.js +42 -0
  24. package/dist/src/rules/dto/rule.dto.d.ts +24 -0
  25. package/dist/src/rules/dto/rule.dto.d.ts.map +1 -0
  26. package/dist/src/rules/dto/rule.dto.js +198 -0
  27. package/dist/src/rules/interface/pagination.interface.d.ts +7 -0
  28. package/dist/src/rules/interface/pagination.interface.d.ts.map +1 -0
  29. package/dist/src/rules/interface/pagination.interface.js +2 -0
  30. package/dist/src/rules/interface/rule.interface.d.ts +29 -0
  31. package/dist/src/rules/interface/rule.interface.d.ts.map +1 -0
  32. package/dist/src/rules/interface/rule.interface.js +2 -0
  33. package/dist/src/rules/rule.controller.d.ts +14 -0
  34. package/dist/src/rules/rule.controller.d.ts.map +1 -0
  35. package/dist/src/rules/rule.controller.js +87 -0
  36. package/dist/src/rules/rule.module.d.ts +5 -0
  37. package/dist/src/rules/rule.module.d.ts.map +1 -0
  38. package/dist/src/rules/rule.module.js +38 -0
  39. package/dist/src/rules/rule.repository.d.ts +15 -0
  40. package/dist/src/rules/rule.repository.d.ts.map +1 -0
  41. package/dist/src/rules/rule.repository.js +79 -0
  42. package/dist/src/rules/rule.schema.d.ts +176 -0
  43. package/dist/src/rules/rule.schema.d.ts.map +1 -0
  44. package/dist/src/rules/rule.schema.js +150 -0
  45. package/dist/src/rules/rule.service.d.ts +26 -0
  46. package/dist/src/rules/rule.service.d.ts.map +1 -0
  47. package/dist/src/rules/rule.service.js +204 -0
  48. package/dist/src/shared/cache/cache.service.d.ts +10 -0
  49. package/dist/src/shared/cache/cache.service.d.ts.map +1 -0
  50. package/dist/src/shared/cache/cache.service.js +29 -0
  51. package/dist/src/shared/dsl/dsl.interface.d.ts +43 -0
  52. package/dist/src/shared/dsl/dsl.interface.d.ts.map +1 -0
  53. package/dist/src/shared/dsl/dsl.interface.js +9 -0
  54. package/dist/src/shared/dsl/dsl.service.d.ts +8 -0
  55. package/dist/src/shared/dsl/dsl.service.d.ts.map +1 -0
  56. package/dist/src/shared/dsl/dsl.service.js +87 -0
  57. package/dist/src/shared/redis/redis.module.d.ts +3 -0
  58. package/dist/src/shared/redis/redis.module.d.ts.map +1 -0
  59. package/dist/src/shared/redis/redis.module.js +32 -0
  60. package/dist/src/shared/redis/redis.service.d.ts +13 -0
  61. package/dist/src/shared/redis/redis.service.d.ts.map +1 -0
  62. package/dist/src/shared/redis/redis.service.js +53 -0
  63. package/dist/src/shared/rule-engine/interface/rule-engine.interface.d.ts +14 -0
  64. package/dist/src/shared/rule-engine/interface/rule-engine.interface.d.ts.map +1 -0
  65. package/dist/src/shared/rule-engine/interface/rule-engine.interface.js +2 -0
  66. package/dist/src/shared/rule-engine/rule-engine.module.d.ts +11 -0
  67. package/dist/src/shared/rule-engine/rule-engine.module.d.ts.map +1 -0
  68. package/dist/src/shared/rule-engine/rule-engine.module.js +51 -0
  69. package/dist/src/shared/rule-engine/rule-engine.service.d.ts +18 -0
  70. package/dist/src/shared/rule-engine/rule-engine.service.d.ts.map +1 -0
  71. package/dist/src/shared/rule-engine/rule-engine.service.js +134 -0
  72. package/dist/src/shared/shared.module.d.ts +3 -0
  73. package/dist/src/shared/shared.module.d.ts.map +1 -0
  74. package/dist/src/shared/shared.module.js +29 -0
  75. package/dist/src/validators/rule.constraint.d.ts +10 -0
  76. package/dist/src/validators/rule.constraint.d.ts.map +1 -0
  77. package/dist/src/validators/rule.constraint.js +49 -0
  78. package/dist/src/validators/rule.validator.d.ts +3 -0
  79. package/dist/src/validators/rule.validator.d.ts.map +1 -0
  80. package/dist/src/validators/rule.validator.js +16 -0
  81. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  82. package/package.json +3 -3
package/dist/README.md ADDED
@@ -0,0 +1,499 @@
1
+ # ๐Ÿ“ˆ Rate Limiting Module
2
+
3
+ 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**.
4
+
5
+ ## โœจ Features
6
+
7
+ - Define rate-limiting rules with custom expressions.
8
+
9
+ - Dynamically inject context-aware functions for rule evaluation.
10
+
11
+ - Easily integrate with any resource via a decorator.
12
+
13
+ - Built with extensibility and modularity in mind.
14
+
15
+ ## ๐Ÿงฑ How It Works
16
+
17
+ 1. You define a rule using a simple expression (e.g., `count_quote( ) > 1`).
18
+
19
+ 2. The rule is evaluated in runtime using data injected from the request context.
20
+
21
+ 3. If the expression is true, the action is blocked.
22
+
23
+ ## ๐Ÿงฉ Usage
24
+
25
+ ### 1. Install the Module
26
+
27
+ ```ts
28
+ @Module({
29
+ imports: [
30
+ RateLimitingModule,
31
+
32
+ RuleEngineModule.forFeatureAsync({
33
+ useFactory: async (quoteService: QuoteService) => {
34
+ return await quoteService.countQuote();
35
+ },
36
+
37
+ inject: [QuoteService],
38
+ }),
39
+ ],
40
+ })
41
+ export class YourFeatureModule {}
42
+ ```
43
+
44
+ ## 2. Decorate Your Handlers
45
+
46
+ Use the `@RateLimitingRuleMetadata` decorator to attach metadata used during rule evaluation.
47
+
48
+ ```ts
49
+
50
+ import { RateLimitingRuleMetadata } from 'path-to-rate-limiting-module';
51
+
52
+
53
+
54
+ @RateLimitingRuleMetadata({
55
+
56
+ action: 'create_quote',
57
+
58
+ partnerPath: 'partner.partnerId',
59
+
60
+ providerPath: 'provider',
61
+
62
+ productTypePath: 'productType',
63
+
64
+ marketPath: 'market',
65
+
66
+ })
67
+
68
+ @Post('quotes')
69
+
70
+ createQuote(@Body() body: CreateQuoteDto) {
71
+
72
+ return this.quoteService.create(body);
73
+
74
+ }
75
+
76
+ ```
77
+
78
+ - `action`: Name of the action to be controlled.
79
+
80
+ - `partnerPath`: Path to extract the partner ID from the request context.
81
+
82
+ - `providerPath`: Path to extract the provider.
83
+
84
+ - `productTypePath`: Path to extract the product type.
85
+
86
+ ## ๐Ÿ›  Rule Engine Integration
87
+
88
+ This module depends on an underlying rule engine to evaluate expressions. You must provide the functions used in expressions through:
89
+
90
+ ```ts
91
+ RuleEngineModule.forFeatureAsync({
92
+ useFactory: async (useCase: RateLimitingInjectFunctionsUseCase) => {
93
+ return await useCase.getFunctions();
94
+
95
+ // returns an object like { count_quote: async () => number }
96
+ },
97
+
98
+ inject: [RateLimitingInjectFunctionsUseCase],
99
+ });
100
+ ```
101
+
102
+ ## ๐Ÿงช Example Rule
103
+
104
+ A rule stored in your system might look like:
105
+
106
+ ```json
107
+ {
108
+ "expression": "count_quote() > 1",
109
+ "action": "create_quote"
110
+ }
111
+ ```
112
+
113
+ If the expression returns `true`, the rate limiter will block further `create_quote` actions for the user based on the context values.
114
+
115
+ ## ๐Ÿง  Dynamic Parameter Resolution
116
+
117
+ When building queries based on request context, it's possible to reference nested values using paths. This system supports:
118
+
119
+ - Resolving values using variable placeholders like `:applicant.documents[0].value`.
120
+ - Interpreting date expressions safely, like `date(-5d)` (5 days ago), without using `eval`.
121
+
122
+ ### Supported Syntax
123
+
124
+ ```json
125
+ {
126
+ "value": ":applicant.documents[0].value",
127
+ "label": "applicant.documents.value"
128
+ }
129
+ ```
130
+
131
+ Will extract the value from the context:
132
+
133
+ ```json
134
+ {
135
+ "applicant": {
136
+ "documents": [{ "type": "NIF", "value": "ABCDE" }]
137
+ }
138
+ }
139
+ ```
140
+
141
+ Result: `"ABCDE"`
142
+
143
+ You can also use dynamic dates:
144
+
145
+ ```json
146
+ {
147
+ "value": "date(-7d)",
148
+ "label": "createdAt",
149
+ "op": "gte"
150
+ }
151
+ ```
152
+
153
+ Result: `"2025-07-10T00:00:00.000Z"` (7 days ago)
154
+
155
+ ### Supported Date Units
156
+
157
+ - `d`: Days (default)
158
+ - `M`: Months
159
+ - `y`: Years
160
+
161
+ Examples:
162
+
163
+ - `date(-5d)` โ†’ 5 days ago
164
+ - `date(-1M)` โ†’ 1 month ago
165
+ - `date(0)` โ†’ Today
166
+
167
+ No dynamic code execution (`eval`, `new Function`) is used โ€” expressions are parsed securely.
168
+
169
+ ## โš™๏ธ Supported Operators (`op`)
170
+
171
+ You can optionally define an `op` (operation) field to specify how the value should be interpreted. The system currently supports:
172
+
173
+ ### `gte` โ€” Greater Than or Equal (usually for dates)
174
+
175
+ ```json
176
+ {
177
+ "value": "date(-7d)",
178
+ "label": "createdAt",
179
+ "op": "gte"
180
+ }
181
+ ```
182
+
183
+ ๐Ÿ” This means: only include records created after **7 days ago**.
184
+
185
+ ```json
186
+ {
187
+ "value": {
188
+ "from": 1,
189
+ "to": 10
190
+ },
191
+ "label": "createdAt",
192
+ "op": "range"
193
+ }
194
+ ```
195
+
196
+ ๐Ÿ” This sets a static date or value range. Can be used for numbers, dates, or custom fields.
197
+
198
+ ### `rangeDate` โ€” Dynamic Date Range
199
+
200
+ ```json
201
+ {
202
+ "value": {
203
+ "from": "date(-30d)",
204
+ "to": "date(0)"
205
+ },
206
+ "label": "createdAt",
207
+ "op": "rangeDate"
208
+ }
209
+ ```
210
+
211
+ ๐Ÿ” This automatically resolves both `from` and `to` values as dates. For example, this would generate a date range from **30 days ago** to **now**.
212
+
213
+ ## ๐Ÿงฌ DSL Support and MongoDB Integration
214
+
215
+ This module uses a lightweight **DSL (Domain-Specific Language)** to define rules and filters in a declarative and expressive way.
216
+
217
+ ### What is a DSL?
218
+
219
+ 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:
220
+
221
+ - Conditional expressions (e.g., `count_quote() > 1`)
222
+ - Filter structures using dynamic context variables and operators (`eq`, `range`, `gte`, etc.)
223
+
224
+ These DSL expressions are **not executed as raw code**, but safely parsed and evaluated using resolvers and expression evaluators.
225
+
226
+ ---
227
+
228
+ ### DSL to MongoDB Filter Conversion
229
+
230
+ One powerful feature of this module is the ability to **transform DSL filters into MongoDB-compatible query objects**.
231
+
232
+ For example, the following DSL input:
233
+
234
+ ```json
235
+ {
236
+ createdAt: {
237
+ $gte: new Date('2025-06-17T00:00:00.000Z'),
238
+ $lte: new Date('2025-07-17T00:00:00.000Z')
239
+ }
240
+ }
241
+ ```
242
+
243
+ This is handled by utility functions like `buildDlsOp`, which map DSL constructs to database query.
244
+
245
+ ### โœ… Benefits of Using DSL
246
+
247
+ - **Separation of logic from code:** Business rules can be stored in DB or configs
248
+ - **Extensibility:** Easy to support new operators or DB backends (e.g., SQL, Elasticsearch)
249
+ - **Security:** No raw `eval` or dynamic JS execution
250
+ - **Readability:** DSL is expressive for non-technical stakeholders
251
+
252
+ 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.
253
+
254
+ ## ๐Ÿงพ Dynamic Query Context with `variables.queries`
255
+
256
+ The `variables` object is designed to allow structured dynamic query generation through an array of `queries`. Each query defines:
257
+
258
+ - The **function(s)** where this context will be injected (`fnContext`)
259
+ - The **parameters** to be resolved and passed (`query`)
260
+ - **Optional operations** and **default values**
261
+
262
+ ### Structure of `variables.queries`
263
+
264
+ ```json
265
+ {
266
+ "queries": [
267
+ {
268
+ "fnContext": ["countQuoteByParams"],
269
+ "query": [
270
+ {
271
+ "value": ":partner.partnerId",
272
+ "label": "partner.partnerId"
273
+ },
274
+ {
275
+ "value": ":productType",
276
+ "label": "productType"
277
+ },
278
+ {
279
+ "value": ":provider",
280
+ "label": "provider"
281
+ },
282
+ {
283
+ "value": ":applicant.documents[0].value",
284
+ "label": "applicant.documents.value"
285
+ },
286
+ {
287
+ "value": ":applicant.documents[0].type",
288
+ "label": "applicant.documents.type"
289
+ },
290
+ {
291
+ "label": "createdAt",
292
+ "op": "range",
293
+ "value": {
294
+ "to": "date(0)",
295
+ "from": "fn:getValueFromSale"
296
+ },
297
+ "defaultValue": {
298
+ "from": "date(-5d)",
299
+ "to": "date(0)"
300
+ }
301
+ }
302
+ ]
303
+ }
304
+ ]
305
+ }
306
+ ```
307
+
308
+ ### ๐Ÿ” Explanation
309
+
310
+ Field
311
+
312
+ Description
313
+
314
+ `fnContext`
315
+
316
+ The name(s) of the function(s) that will receive this query as parameter input
317
+
318
+ `query`
319
+
320
+ Array of parameter definitions. Each will be resolved based on context or DSL expressions
321
+
322
+ `label`
323
+
324
+ The target field to be passed (e.g. used to generate a MongoDB query or as input to a service)
325
+
326
+ `value`
327
+
328
+ Can be a dynamic reference (e.g., `:context.path`), a static value, or a DSL expression
329
+
330
+ `op`
331
+
332
+ Optional. Defines the operator (`eq`, `range`, `rangeDate`, `gte`, etc.)
333
+
334
+ `defaultValue`
335
+
336
+ Fallback value(s) to be used if dynamic resolution fails (e.g., missing path or function)
337
+
338
+ ---
339
+
340
+ ### ๐Ÿง  Special Value Formats
341
+
342
+ - `:path.to.value` โ€” Dynamically extracted from the context object
343
+ - `date(-7d)` โ€” Resolved as a safe date expression
344
+ - `fn:getValueFromSale` โ€” Calls a predefined function to resolve the value dynamically
345
+ - Static values like `"moneyhero"` are passed as-is
346
+
347
+ ### ๐Ÿงช Use Case Example
348
+
349
+ Imagine your service defines a method like:
350
+
351
+ async countQuoteByParams(filters: Record<string, any>): Promise<number>
352
+
353
+ At runtime, the module will:
354
+
355
+ 1. Resolve each `value` in the `query` array using context and supported expressions.
356
+ 2. Construct a query object:
357
+
358
+ ```json
359
+ {
360
+ partner: { partnerId: "bolttech" },
361
+ productType: "car-insurance",
362
+ provider: "bolttech",
363
+ applicant: {
364
+ documents: [{ type: "NIF", value: "ABCDE" }]
365
+ },
366
+ createdAt: {
367
+ from: new Date("2025-07-25T00:00:00Z"), // resolved from fn:getValueFromSale
368
+ to: new Date("2025-07-30T00:00:00Z") // resolved from date(0)
369
+ }
370
+ }
371
+ ```
372
+
373
+ 3. Inject this into `countQuoteByParams(...)`
374
+ This approach gives you a highly flexible, configurable system for controlling dynamic function parameters via context-based DSLs and runtime evaluation.
375
+
376
+ ---
377
+
378
+ ## ๐Ÿง  Custom Runtime Functions with `variables.functions`
379
+
380
+ In addition to defining query parameters in `variables.queries`, the system also supports **custom runtime functions** through the `variables.functions` array.
381
+
382
+ These functions can be executed **before query construction** to compute values that are **injected** dynamically into query fields.
383
+
384
+ ---
385
+
386
+ ### ๐Ÿ”ง Structure of `functions`
387
+
388
+ Each function definition includes:
389
+
390
+ | Field | Description |
391
+ | ----------- | -------------------------------------------------------------------------- |
392
+ | `name` | Unique function identifier |
393
+ | `fn` | The function to execute, in the format `functionName(args...)` |
394
+ | `variables` | Parameters passed to the function, which can include subqueries and values |
395
+
396
+ ### ๐Ÿ“Œ Example
397
+
398
+ ```json
399
+ {
400
+ "functions": [
401
+ {
402
+ "name": "getValueFromSale",
403
+ "fn": "getValueFromSale(queries, target)",
404
+ "variables": {
405
+ "target": "createdAt",
406
+ "queries": [
407
+ {
408
+ "value": ":productType",
409
+ "label": "products.productType"
410
+ },
411
+ {
412
+ "value": ":applicant.documents[0].value",
413
+ "label": "applicant.documents.value"
414
+ },
415
+ {
416
+ "value": ":applicant.documents[0].type",
417
+ "label": "applicant.documents.type"
418
+ },
419
+ {
420
+ "value": "date(-5d)",
421
+ "label": "createdAt",
422
+ "op": "gte"
423
+ }
424
+ ]
425
+ }
426
+ }
427
+ ]
428
+ }
429
+ ```
430
+
431
+ ### ๐Ÿ”„ Using the Function Output in Queries
432
+
433
+ To use the result of a function, reference it in a `query.value` using the syntax: `fn:functionName`.
434
+
435
+ json
436
+
437
+ CopyEdit
438
+
439
+ ```json
440
+ {
441
+ "label": "createdAt",
442
+ "op": "range",
443
+ "value": {
444
+ "from": "fn:getValueFromSale",
445
+ "to": "date(0)"
446
+ },
447
+ "defaultValue": {
448
+ "from": "date(-5d)",
449
+ "to": "date(0)"
450
+ }
451
+ }
452
+ ```
453
+
454
+ ๐Ÿ” In this case, `getValueFromSale(...)` will run **before** the query is constructed, and the result will be injected into the `from` field.
455
+
456
+ ---
457
+
458
+ ### ๐Ÿงฉ How It Works
459
+
460
+ 1. The engine scans all `functions` in `variables.functions`.
461
+ 2. For each `query` entry in `variables.queries`, if `value` (or `from`, `to`) starts with `fn:`, it:
462
+ - Finds the corresponding `function` by name
463
+ - Resolves its `variables` (supporting nested `:context.paths`)
464
+ - Executes the declared function like `getValueFromSale(queries, target)`
465
+
466
+ 3. The return value of the function replaces the `fn:` reference.
467
+
468
+ ---
469
+
470
+ ### โœ… Benefits
471
+
472
+ - Enables **pre-processing logic** in a declarative way
473
+ - Keeps rule/query definitions **clean and context-aware**
474
+ - Promotes **reuse** of custom logic across different rules or queries
475
+ - Provides **defaultValue** fallback in case of failure
476
+
477
+ ---
478
+
479
+ > ๐Ÿ’ก 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.
480
+
481
+ ## ๐Ÿงฐ Requirements
482
+
483
+ - NestJS
484
+
485
+ - RuleEngineModule (compatible expression parser/executor)
486
+
487
+ - Custom service to inject context functions (like `RateLimitingInjectFunctionsUseCase`)
488
+
489
+ ## ๐Ÿ“Ž Notes
490
+
491
+ - Rules should be defined and stored externally (e.g., DB, config).
492
+
493
+ - The context extractor paths must match the structure of your handler inputs (e.g., body, params).
494
+
495
+ - Ensure `getFunctions()` returns **async functions** that provide the required values for the expression.
496
+
497
+ ## ๐Ÿงพ License
498
+
499
+ MIT
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@edirect/rate-limit-module",
3
+ "version": "11.0.46",
4
+ "main": "./dist/src/index.js",
5
+ "types": "./dist/src/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/src/index.js",
9
+ "default": "./dist/src/index.js",
10
+ "require": "./dist/src/index.js",
11
+ "types": "./dist/src/index.d.ts"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@edirect/auth": "^11.0.46",
20
+ "@edirect/logger": "^11.0.46",
21
+ "@nestjs/cache-manager": "^3.1.0",
22
+ "@nestjs/common": "^11.1.12",
23
+ "@nestjs/config": "^4.0.2",
24
+ "@nestjs/core": "^11.1.12",
25
+ "@nestjs/mongoose": "^11.0.4",
26
+ "@nestjs/swagger": "^11.2.5",
27
+ "cache-manager-redis-store": "^3.0.1",
28
+ "class-transformer": "^0.5.1",
29
+ "class-validator": "^0.14.3",
30
+ "dayjs": "^1.11.19",
31
+ "ioredis": "^5.9.2",
32
+ "jexl": "^2.3.0",
33
+ "mongoose": "^9.1.5",
34
+ "tslib": "^2.8.1",
35
+ "uuid": "^13.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/jexl": "^2.3.4"
39
+ },
40
+ "type": "commonjs"
41
+ }
@@ -0,0 +1,10 @@
1
+ export declare const RULE_METADATA = "RATE_LIMITING_RULE_METADATA";
2
+ export interface RateLimitingRuleMetadataOptions {
3
+ action: string;
4
+ partnerPath: string;
5
+ providerPath: string;
6
+ productTypePath: string;
7
+ marketPath: string;
8
+ }
9
+ export declare const RateLimitingRuleMetadata: (options: RateLimitingRuleMetadataOptions) => import("@nestjs/common").CustomDecorator<string>;
10
+ //# sourceMappingURL=rate-limiting-rule.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiting-rule.decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/rate-limiting-rule.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAAgC,CAAC;AAE3D,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,wBAAwB,GACnC,SAAS,+BAA+B,qDACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitingRuleMetadata = exports.RULE_METADATA = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.RULE_METADATA = 'RATE_LIMITING_RULE_METADATA';
6
+ const RateLimitingRuleMetadata = (options) => (0, common_1.SetMetadata)(exports.RULE_METADATA, options);
7
+ exports.RateLimitingRuleMetadata = RateLimitingRuleMetadata;
@@ -0,0 +1,21 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ import { RuleService } from '../rules/rule.service';
4
+ import { RuleEngineService } from '../shared/rule-engine/rule-engine.service';
5
+ export declare class RateLimitingRuleGuard implements CanActivate {
6
+ private readonly reflector;
7
+ private readonly ruleService;
8
+ private readonly ruleEngine;
9
+ private readonly logger;
10
+ constructor(reflector: Reflector, ruleService: RuleService, ruleEngine: RuleEngineService);
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;
20
+ }
21
+ //# sourceMappingURL=rate-limiting.guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiting.guard.d.ts","sourceRoot":"","sources":["../../../src/guards/rate-limiting.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAiB9E,qBACa,qBAAsB,YAAW,WAAW;IAIrD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAE5B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAN7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAG9C,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EAExB,UAAU,EAAE,iBAAiB;IAG1C,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoH9D,OAAO,CAAC,uBAAuB;IAoB/B,OAAO,CAAC,gBAAgB;IA2BxB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,UAAU;YAWJ,iBAAiB;IAiB/B,OAAO,CAAC,iBAAiB;CA4C1B"}