@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.
- package/.github/workflows/npm-publish.yml +1 -1
- package/dist/decorators/validations/depend-on-property.decorator.d.ts +2 -0
- package/dist/decorators/validations/depend-on-property.decorator.js +28 -0
- package/dist/decorators/validations/index.d.ts +1 -0
- package/dist/decorators/validations/index.js +1 -0
- package/dist/lib/caching/caching.module.js +8 -13
- package/dist/lib/caching/caching.service.d.ts +1 -1
- package/dist/lib/caching/caching.service.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -19
|
@@ -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
|
+
}
|
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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("
|
|
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>;
|