@edirect/rate-limit-module 2.0.5 → 2.0.7

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.
@@ -1,7 +1,7 @@
1
- export * from '../test/mocks/rate-limiting.mocks';
2
- export * from '../test/modules/rate-limiting.module';
3
1
  export * from './decorators/rate-limiting-rule.decorator';
4
2
  export * from './guards/rate-limiting.guard';
3
+ export * from './mocks-modules/rate-limiting.module';
4
+ export * from './mocks-modules/rule.module';
5
5
  export * from './rate-limiting.module';
6
6
  export * from './shared/dsl/dsl.interface';
7
7
  export * from './shared/dsl/dsl.service';
package/dist/src/index.js CHANGED
@@ -15,10 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CUSTOM_RULE_FUNCTIONS = exports.RULE_ENGINE_INSTANCE = void 0;
18
- __exportStar(require("../test/mocks/rate-limiting.mocks"), exports);
19
- __exportStar(require("../test/modules/rate-limiting.module"), exports);
20
18
  __exportStar(require("./decorators/rate-limiting-rule.decorator"), exports);
21
19
  __exportStar(require("./guards/rate-limiting.guard"), exports);
20
+ __exportStar(require("./mocks-modules/rate-limiting.module"), exports);
21
+ __exportStar(require("./mocks-modules/rule.module"), exports);
22
22
  __exportStar(require("./rate-limiting.module"), exports);
23
23
  __exportStar(require("./shared/dsl/dsl.interface"), exports);
24
24
  __exportStar(require("./shared/dsl/dsl.service"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,uEAAqD;AACrD,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4EAA0D;AAC1D,+DAA6C;AAC7C,uEAAqD;AACrD,8DAA4C;AAC5C,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AACzC,0EAAwD;AACxD,+DAA6C;AAEhC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { IsValidExpressionConstraint } from '../validators/rule.constraint';
3
+ export declare const mockIsValidExpressionConstraint: {
4
+ provide: typeof IsValidExpressionConstraint;
5
+ useValue: {
6
+ validate: jest.Mock<any, any, any>;
7
+ defaultMessage: jest.Mock<any, any, any>;
8
+ };
9
+ };
10
+ export declare const mockRuleService: {
11
+ provide: string;
12
+ useValue: {
13
+ create: jest.Mock<any, any, any>;
14
+ findAll: jest.Mock<any, any, any>;
15
+ updateOne: jest.Mock<any, any, any>;
16
+ delete: jest.Mock<any, any, any>;
17
+ };
18
+ };
19
+ export declare class RateLimitingTestModule {
20
+ static register(rules: any): DynamicModule;
21
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitingTestModule = exports.mockRuleService = exports.mockIsValidExpressionConstraint = void 0;
4
+ const config_1 = require("@nestjs/config");
5
+ const mongoose_1 = require("@nestjs/mongoose");
6
+ const mongodb_memory_server_1 = require("mongodb-memory-server");
7
+ const rule_constraint_1 = require("../validators/rule.constraint");
8
+ const rule_module_1 = require("./rule.module");
9
+ exports.mockIsValidExpressionConstraint = {
10
+ provide: rule_constraint_1.IsValidExpressionConstraint,
11
+ useValue: {
12
+ validate: jest.fn(),
13
+ defaultMessage: jest.fn(),
14
+ },
15
+ };
16
+ exports.mockRuleService = {
17
+ provide: 'RuleService',
18
+ useValue: {
19
+ create: jest.fn(),
20
+ findAll: jest.fn(),
21
+ updateOne: jest.fn(),
22
+ delete: jest.fn(),
23
+ },
24
+ };
25
+ async function getMongoUri() {
26
+ const mongod = await mongodb_memory_server_1.MongoMemoryServer.create();
27
+ return mongod.getUri();
28
+ }
29
+ class RateLimitingTestModule {
30
+ static register(rules) {
31
+ return {
32
+ module: RateLimitingTestModule,
33
+ imports: [
34
+ config_1.ConfigModule.forRoot({ isGlobal: true }),
35
+ mongoose_1.MongooseModule.forRootAsync({
36
+ useFactory: async () => ({
37
+ uri: await getMongoUri(),
38
+ }),
39
+ inject: [],
40
+ }),
41
+ rule_module_1.RuleModuleMock.register(rules),
42
+ ],
43
+ providers: [
44
+ exports.mockIsValidExpressionConstraint,
45
+ exports.mockRuleService,
46
+ ],
47
+ exports: [
48
+ rule_module_1.RuleModuleMock,
49
+ ],
50
+ };
51
+ }
52
+ }
53
+ exports.RateLimitingTestModule = RateLimitingTestModule;
54
+ //# sourceMappingURL=rate-limiting.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiting.module.js","sourceRoot":"","sources":["../../../src/mocks-modules/rate-limiting.module.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAC9C,+CAAkD;AAClD,iEAA0D;AAC1D,mEAA4E;AAC5E,+CAA+C;AAElC,QAAA,+BAA+B,GAAG;IAC7C,OAAO,EAAE,6CAA2B;IACpC,QAAQ,EAAE;QACR,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;KAC1B;CACF,CAAC;AAEW,QAAA,eAAe,GAAG;IAC7B,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE;QACR,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QACjB,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;QACpB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;KAClB;CACF,CAAC;AAEF,KAAK,UAAU,WAAW;IACxB,MAAM,MAAM,GAAG,MAAM,yCAAiB,CAAC,MAAM,EAAE,CAAC;IAChD,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;AACzB,CAAC;AAED,MAAa,sBAAsB;IACjC,MAAM,CAAC,QAAQ,CAAC,KAAU;QACxB,OAAO;YACL,MAAM,EAAE,sBAAsB;YAC9B,OAAO,EAAE;gBACL,qBAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACxC,yBAAc,CAAC,YAAY,CAAC;oBAC1B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;wBACvB,GAAG,EAAE,MAAM,WAAW,EAAE;qBACzB,CAAC;oBACF,MAAM,EAAE,EAAE;iBACX,CAAC;gBACF,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;aACjC;YACD,SAAS,EAAE;gBACT,uCAA+B;gBAC/B,uBAAe;aAChB;YACD,OAAO,EAAE;gBACL,4BAAc;aACjB;SACF,CAAC;IACJ,CAAC;CACF;AAvBD,wDAuBC"}
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { IRule } from '../../src/rules/interface/rule.interface';
3
+ export declare class RuleModuleMock {
4
+ static register(rules: IRule[]): DynamicModule;
5
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RuleModuleMock = void 0;
4
+ const rule_repository_1 = require("../../src/rules/rule.repository");
5
+ const rule_service_1 = require("../../src/rules/rule.service");
6
+ const shared_module_mocks_1 = require("./shared-module.mocks");
7
+ class RuleModuleMock {
8
+ static register(rules) {
9
+ const mockRuleService = {
10
+ provide: rule_service_1.RuleService,
11
+ useValue: {
12
+ findAllWithoutPagination: jest.fn().mockResolvedValue(rules),
13
+ findAll: jest.fn().mockResolvedValue(rules),
14
+ create: jest.fn().mockResolvedValue(rules[0] || {}),
15
+ },
16
+ };
17
+ const mockRuleRepository = {
18
+ provide: rule_repository_1.RuleRepository,
19
+ useValue: {
20
+ update: jest.fn(),
21
+ findOneByRateId: jest.fn(),
22
+ findAll: jest.fn(),
23
+ save: jest.fn(),
24
+ },
25
+ };
26
+ return {
27
+ imports: [shared_module_mocks_1.MockSharedModule],
28
+ providers: [
29
+ { provide: rule_service_1.RuleService, useValue: mockRuleService },
30
+ { provide: rule_repository_1.RuleRepository, useValue: mockRuleRepository },
31
+ ],
32
+ exports: [rule_service_1.RuleService, rule_repository_1.RuleRepository],
33
+ module: RuleModuleMock,
34
+ };
35
+ }
36
+ }
37
+ exports.RuleModuleMock = RuleModuleMock;
38
+ //# sourceMappingURL=rule.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.module.js","sourceRoot":"","sources":["../../../src/mocks-modules/rule.module.ts"],"names":[],"mappings":";;;AAEA,qEAAiE;AACjE,+DAA2D;AAC3D,+DAAyD;AAEzD,MAAa,cAAc;IACzB,MAAM,CAAC,QAAQ,CAAC,KAAc;QAC5B,MAAM,eAAe,GAAG;YACtB,OAAO,EAAE,0BAAW;YACpB,QAAQ,EAAE;gBACR,wBAAwB,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC;gBAC5D,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC;gBAC3C,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpD;SACF,CAAC;QAEF,MAAM,kBAAkB,GAAG;YACzB,OAAO,EAAE,gCAAc;YACvB,QAAQ,EAAE;gBACR,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;gBACjB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;gBAC1B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;gBAClB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;aAChB;SACF,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,sCAAgB,CAAC;YAC3B,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,0BAAW,EAAE,QAAQ,EAAE,eAAe,EAAE;gBACnD,EAAE,OAAO,EAAE,gCAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE;aAC1D;YACD,OAAO,EAAE,CAAC,0BAAW,EAAE,gCAAc,CAAC;YACtC,MAAM,EAAE,cAAc;SACvB,CAAC;IACJ,CAAC;CACF;AA/BD,wCA+BC"}
@@ -0,0 +1,10 @@
1
+ export declare const mockCacheService: {
2
+ get: jest.Mock<any, any, any>;
3
+ set: jest.Mock<any, any, any>;
4
+ del: jest.Mock<any, any, any>;
5
+ };
6
+ export declare const mockRuleEngineService: {
7
+ evaluate: jest.Mock<any, any, any>;
8
+ };
9
+ export declare class MockSharedModule {
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.MockSharedModule = exports.mockRuleEngineService = exports.mockCacheService = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const rule_engine_service_1 = require("../../src/shared/rule-engine/rule-engine.service");
12
+ exports.mockCacheService = {
13
+ get: jest.fn(),
14
+ set: jest.fn(),
15
+ del: jest.fn(),
16
+ };
17
+ exports.mockRuleEngineService = {
18
+ evaluate: jest.fn(),
19
+ };
20
+ let MockSharedModule = class MockSharedModule {
21
+ };
22
+ exports.MockSharedModule = MockSharedModule;
23
+ exports.MockSharedModule = MockSharedModule = __decorate([
24
+ (0, common_1.Module)({
25
+ providers: [
26
+ { provide: 'CACHE_MANAGER', useValue: exports.mockCacheService },
27
+ { provide: rule_engine_service_1.RuleEngineService, useValue: exports.mockRuleEngineService },
28
+ ],
29
+ exports: ['CACHE_MANAGER', rule_engine_service_1.RuleEngineService],
30
+ })
31
+ ], MockSharedModule);
32
+ //# sourceMappingURL=shared-module.mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-module.mocks.js","sourceRoot":"","sources":["../../../src/mocks-modules/shared-module.mocks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,0FAAqF;AAExE,QAAA,gBAAgB,GAAG;IAC9B,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;CACf,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;CACpB,CAAC;AASK,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAP5B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,wBAAgB,EAAE;YACxD,EAAE,OAAO,EAAE,uCAAiB,EAAE,QAAQ,EAAE,6BAAqB,EAAE;SAChE;QACD,OAAO,EAAE,CAAC,eAAe,EAAE,uCAAiB,CAAC;KAC9C,CAAC;GACW,gBAAgB,CAAG"}