@mondart/nestjs-common-module 2.1.3 → 2.2.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.
@@ -18,7 +18,7 @@ jobs:
18
18
  node-version: '16' # Use the Node.js version your project requires
19
19
 
20
20
  - name: Install dependencies
21
- run: npm install
21
+ run: npm install --force
22
22
 
23
23
  - name: Build project
24
24
  run: npm run build # Adjust this if your build command is different
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+ export declare function DependOnProperty(conditionValue: any, relatedProperty: string[], options?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DependOnProperty = DependOnProperty;
4
+ const class_validator_1 = require("class-validator");
5
+ function DependOnProperty(conditionValue, relatedProperty, options) {
6
+ return function (object, propertyName) {
7
+ (0, class_validator_1.registerDecorator)({
8
+ name: 'dependOnProperty',
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ options: options,
12
+ constraints: relatedProperty,
13
+ validator: {
14
+ validate(value, args) {
15
+ if (conditionValue === value) {
16
+ const relatedValues = args.constraints.map((relatedProperty) => args.object[relatedProperty]);
17
+ return (relatedValues.filter((relatedValue) => relatedValue)?.length ===
18
+ relatedProperty?.length);
19
+ }
20
+ return true;
21
+ },
22
+ defaultMessage(args) {
23
+ return `You must fill all of the following properties: ${args.constraints.join(', ')} depending on the ${args.property}: ${args.value}.`;
24
+ },
25
+ },
26
+ });
27
+ };
28
+ }
@@ -2,3 +2,4 @@ export * from './default';
2
2
  export * from './is-id.decorator';
3
3
  export * from './is-not-empty-string.decorator';
4
4
  export * from './is-one-of-property.decorator';
5
+ export * from './depend-on-property.decorator';
@@ -18,3 +18,4 @@ __exportStar(require("./default"), exports);
18
18
  __exportStar(require("./is-id.decorator"), exports);
19
19
  __exportStar(require("./is-not-empty-string.decorator"), exports);
20
20
  __exportStar(require("./is-one-of-property.decorator"), exports);
21
+ __exportStar(require("./depend-on-property.decorator"), exports);
@@ -12,7 +12,6 @@ const common_1 = require("@nestjs/common");
12
12
  const caching_service_1 = require("./caching.service");
13
13
  const cache_manager_1 = require("@nestjs/cache-manager");
14
14
  const caching_interface_1 = require("./caching.interface");
15
- const cache_manager_ioredis_yet_1 = require("cache-manager-ioredis-yet");
16
15
  let CachingModule = CachingModule_1 = class CachingModule {
17
16
  static register(options) {
18
17
  return {
@@ -21,12 +20,10 @@ let CachingModule = CachingModule_1 = class CachingModule {
21
20
  cache_manager_1.CacheModule.register({
22
21
  isGlobal: true,
23
22
  useFactory: async (cachingOptions) => ({
24
- store: await (0, cache_manager_ioredis_yet_1.redisStore)({
25
- host: cachingOptions.host,
26
- port: cachingOptions.port,
27
- password: cachingOptions.password,
28
- ttl: cachingOptions.ttl,
29
- }),
23
+ host: cachingOptions.host,
24
+ port: cachingOptions.port,
25
+ password: cachingOptions.password,
26
+ ttl: cachingOptions.ttl,
30
27
  }),
31
28
  }),
32
29
  ],
@@ -50,12 +47,10 @@ let CachingModule = CachingModule_1 = class CachingModule {
50
47
  cache_manager_1.CacheModule.registerAsync({
51
48
  imports: [asyncOptionsProvider],
52
49
  useFactory: async (cachingOptions) => ({
53
- store: await (0, cache_manager_ioredis_yet_1.redisStore)({
54
- host: cachingOptions.host,
55
- port: cachingOptions.port,
56
- password: cachingOptions.password,
57
- ttl: cachingOptions.ttl,
58
- }),
50
+ host: cachingOptions.host,
51
+ port: cachingOptions.port,
52
+ password: cachingOptions.password,
53
+ ttl: cachingOptions.ttl,
59
54
  max: 10000,
60
55
  }),
61
56
  inject: [caching_interface_1.CACHING_MODULE_OPTIONS],
@@ -2,7 +2,7 @@ import { Cache } from 'cache-manager';
2
2
  export declare class CachingService {
3
3
  private cacheManager;
4
4
  constructor(cacheManager: Cache);
5
- getRedisClient(): import("cache-manager").Store;
5
+ getRedisClient(): import("keyv").Keyv<any>[];
6
6
  get<T>(key: string): Promise<T | undefined>;
7
7
  set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
8
8
  del(key: string): Promise<void>;
@@ -20,7 +20,7 @@ let CachingService = class CachingService {
20
20
  this.cacheManager = cacheManager;
21
21
  }
22
22
  getRedisClient() {
23
- return this.cacheManager.store;
23
+ return this.cacheManager.stores;
24
24
  }
25
25
  async get(key) {
26
26
  const result = await this.cacheManager.get(key);