@lenne.tech/nest-server 11.1.2 → 11.1.3
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/dist/core/common/args/pagination.args.js +5 -4
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/unified-field.decorator.d.ts +2 -0
- package/dist/core/common/decorators/unified-field.decorator.js +8 -6
- package/dist/core/common/decorators/unified-field.decorator.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +2 -1
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.js +6 -3
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/args/pagination.args.ts +5 -4
- package/src/core/common/decorators/unified-field.decorator.ts +13 -7
- package/src/core/common/inputs/single-filter.input.ts +2 -1
- package/src/core/modules/health-check/core-health-check-result.model.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.3",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -12,8 +12,9 @@ export class PaginationArgs extends CoreInput {
|
|
|
12
12
|
*/
|
|
13
13
|
@UnifiedField({
|
|
14
14
|
description: 'Limit specifies the maximum number of elements found that are to be returned',
|
|
15
|
+
gqlType: Int,
|
|
15
16
|
isOptional: true,
|
|
16
|
-
type:
|
|
17
|
+
type: Number,
|
|
17
18
|
})
|
|
18
19
|
limit?: number = undefined;
|
|
19
20
|
|
|
@@ -22,8 +23,8 @@ export class PaginationArgs extends CoreInput {
|
|
|
22
23
|
*/
|
|
23
24
|
@UnifiedField({
|
|
24
25
|
description: 'Alias for skip',
|
|
26
|
+
gqlType: Int,
|
|
25
27
|
isOptional: true,
|
|
26
|
-
type: Int,
|
|
27
28
|
})
|
|
28
29
|
offset?: number = undefined;
|
|
29
30
|
|
|
@@ -32,8 +33,8 @@ export class PaginationArgs extends CoreInput {
|
|
|
32
33
|
*/
|
|
33
34
|
@UnifiedField({
|
|
34
35
|
description: 'Skip specifies how many found elements should be skipped on return',
|
|
36
|
+
gqlType: Int,
|
|
35
37
|
isOptional: true,
|
|
36
|
-
type: Int,
|
|
37
38
|
})
|
|
38
39
|
skip?: number = undefined;
|
|
39
40
|
|
|
@@ -52,8 +53,8 @@ export class PaginationArgs extends CoreInput {
|
|
|
52
53
|
*/
|
|
53
54
|
@UnifiedField({
|
|
54
55
|
description: 'Alias for limit',
|
|
56
|
+
gqlType: Int,
|
|
55
57
|
isOptional: true,
|
|
56
|
-
type: () => Int,
|
|
57
58
|
})
|
|
58
59
|
take?: number = undefined;
|
|
59
60
|
|
|
@@ -41,6 +41,10 @@ export interface UnifiedFieldOptions {
|
|
|
41
41
|
example?: any;
|
|
42
42
|
/** Options for graphql */
|
|
43
43
|
gqlOptions?: FieldOptions;
|
|
44
|
+
/** Type if Swagger & Gql types arent compatible */
|
|
45
|
+
gqlType?: GraphQLScalarType | (new (...args: any[]) => any) | Record<number | string, number | string>;
|
|
46
|
+
/** If the property is Any (skips all Validation) */
|
|
47
|
+
isAny?: boolean;
|
|
44
48
|
/** Default: false */
|
|
45
49
|
isOptional?: boolean;
|
|
46
50
|
/** Restricted roles */
|
|
@@ -148,8 +152,8 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
|
|
|
148
152
|
|
|
149
153
|
// Type function for gql
|
|
150
154
|
const gqlTypeFn = isArrayField
|
|
151
|
-
? () => [opts.enum?.enum || resolvedTypeFn()]
|
|
152
|
-
: () => opts.enum?.enum || resolvedTypeFn();
|
|
155
|
+
? () => [opts.enum?.enum || opts.gqlType || resolvedTypeFn()]
|
|
156
|
+
: () => opts.enum?.enum || opts.gqlType || resolvedTypeFn();
|
|
153
157
|
|
|
154
158
|
// Gql decorator
|
|
155
159
|
Field(gqlTypeFn, gqlOpts)(target, propertyKey);
|
|
@@ -202,10 +206,10 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
|
|
|
202
206
|
IsNotEmpty()(target, propertyKey);
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
//
|
|
209
|
+
// Completely skip validation if its any
|
|
206
210
|
if (opts.validator) {
|
|
207
211
|
opts.validator(valOpts).forEach(d => d(target, propertyKey));
|
|
208
|
-
} else {
|
|
212
|
+
} else if (!opts.isAny) {
|
|
209
213
|
const validator = getBuiltInValidator(baseType, valOpts, isArrayField, target);
|
|
210
214
|
if (validator) {
|
|
211
215
|
validator(target, propertyKey);
|
|
@@ -217,10 +221,12 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
|
|
|
217
221
|
IsEnum(opts.enum.enum, opts.enum.options)(target, propertyKey);
|
|
218
222
|
}
|
|
219
223
|
|
|
224
|
+
if (!opts.isAny) {
|
|
220
225
|
// Check if it's a primitive, if not apply transform
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
if (!isPrimitive(baseType) && !opts.enum && !isGraphQLScalar(baseType)) {
|
|
227
|
+
Type(() => baseType)(target, propertyKey);
|
|
228
|
+
ValidateNested({ each: isArrayField })(target, propertyKey);
|
|
229
|
+
}
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
// Roles
|
|
@@ -78,9 +78,10 @@ export class SingleFilterInput extends CoreInput {
|
|
|
78
78
|
|
|
79
79
|
@UnifiedField({
|
|
80
80
|
description: 'Value of the property',
|
|
81
|
+
gqlType: JSON,
|
|
82
|
+
isAny: true,
|
|
81
83
|
isOptional: true,
|
|
82
84
|
roles: RoleEnum.S_EVERYONE,
|
|
83
|
-
type: () => JSON,
|
|
84
85
|
})
|
|
85
86
|
value: any = undefined;
|
|
86
87
|
}
|
|
@@ -31,9 +31,10 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
31
31
|
*/
|
|
32
32
|
@UnifiedField({
|
|
33
33
|
description: 'The info object contains information of each health indicator which is of status “up”',
|
|
34
|
+
gqlType: JSON,
|
|
34
35
|
isOptional: true,
|
|
35
36
|
roles: RoleEnum.S_EVERYONE,
|
|
36
|
-
type: () =>
|
|
37
|
+
type: () => Object,
|
|
37
38
|
})
|
|
38
39
|
info: JSON = undefined;
|
|
39
40
|
|
|
@@ -42,9 +43,10 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
42
43
|
*/
|
|
43
44
|
@UnifiedField({
|
|
44
45
|
description: 'The error object contains information of each health indicator which is of status “down”',
|
|
46
|
+
gqlType: JSON,
|
|
45
47
|
isOptional: true,
|
|
46
48
|
roles: RoleEnum.S_EVERYONE,
|
|
47
|
-
type: () =>
|
|
49
|
+
type: () => Object,
|
|
48
50
|
})
|
|
49
51
|
error: JSON = undefined;
|
|
50
52
|
|
|
@@ -53,9 +55,10 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
53
55
|
*/
|
|
54
56
|
@UnifiedField({
|
|
55
57
|
description: 'The details object contains information of every health indicator',
|
|
58
|
+
gqlType: JSON,
|
|
56
59
|
isOptional: true,
|
|
57
60
|
roles: RoleEnum.S_EVERYONE,
|
|
58
|
-
type: () =>
|
|
61
|
+
type: () => Object,
|
|
59
62
|
})
|
|
60
63
|
details: JSON = undefined;
|
|
61
64
|
}
|