@lenne.tech/nest-server 11.1.6 → 11.1.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.
- package/dist/core/common/decorators/unified-field.decorator.d.ts +1 -1
- package/dist/core/common/decorators/unified-field.decorator.js +9 -1
- package/dist/core/common/decorators/unified-field.decorator.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/decorators/unified-field.decorator.ts +16 -16
- package/src/core/modules/user/inputs/core-user.input.ts +1 -1
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +1 -1
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.7",
|
|
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",
|
|
@@ -22,17 +22,6 @@ import { RoleEnum } from '../enums/role.enum';
|
|
|
22
22
|
import { Restricted, RestrictedType } from './restricted.decorator';
|
|
23
23
|
|
|
24
24
|
export interface UnifiedFieldOptions {
|
|
25
|
-
/**
|
|
26
|
-
* Indicates whether the property is an array.
|
|
27
|
-
*
|
|
28
|
-
* This value is typically determined automatically based on the property type or metadata.
|
|
29
|
-
*
|
|
30
|
-
* However, cases involving complex or dynamic type definitions (e.g., union types, generics, or factory functions)
|
|
31
|
-
* may result in inaccurate detection.
|
|
32
|
-
*
|
|
33
|
-
* When in doubt, explicitly set this property to ensure correct behavior.
|
|
34
|
-
*/
|
|
35
|
-
array?: boolean;
|
|
36
25
|
/** Description used for both Swagger & Gql */
|
|
37
26
|
description?: string;
|
|
38
27
|
/** Enum for class-validator */
|
|
@@ -41,10 +30,12 @@ export interface UnifiedFieldOptions {
|
|
|
41
30
|
example?: any;
|
|
42
31
|
/** Options for graphql */
|
|
43
32
|
gqlOptions?: FieldOptions;
|
|
44
|
-
/** Type if Swagger & Gql types
|
|
33
|
+
/** Type if Swagger & Gql types aren't compatible */
|
|
45
34
|
gqlType?: GraphQLScalarType | (new (...args: any[]) => any) | Record<number | string, number | string>;
|
|
46
35
|
/** If the property is Any (skips all Validation) */
|
|
47
36
|
isAny?: boolean;
|
|
37
|
+
/** Indicates whether the property is an array. */
|
|
38
|
+
isArray?: boolean;
|
|
48
39
|
/** Default: false */
|
|
49
40
|
isOptional?: boolean;
|
|
50
41
|
/** Restricted roles */
|
|
@@ -75,9 +66,9 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
|
|
|
75
66
|
return (target: any, propertyKey: string | symbol) => {
|
|
76
67
|
const metadataType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
77
68
|
const userType = opts.type;
|
|
78
|
-
const isArrayField = opts.
|
|
69
|
+
const isArrayField = opts.isArray === true || metadataType === Array;
|
|
79
70
|
|
|
80
|
-
// Throwing because
|
|
71
|
+
// Throwing because meta type only returns the generic array, but not the type of the array items
|
|
81
72
|
if (metadataType === Array && !userType) {
|
|
82
73
|
throw new Error(`Array field '${String(propertyKey)}' of '${String(target)}' must have an explicit type`);
|
|
83
74
|
}
|
|
@@ -129,12 +120,21 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
|
|
|
129
120
|
swaggerOpts.required = true;
|
|
130
121
|
}
|
|
131
122
|
|
|
132
|
-
//
|
|
123
|
+
// Set type for swagger
|
|
124
|
+
if (baseType) {
|
|
125
|
+
if (opts.enum) {
|
|
126
|
+
swaggerOpts.type = () => String;
|
|
127
|
+
} else {
|
|
128
|
+
swaggerOpts.type = () => resolvedTypeFn();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Set description
|
|
133
133
|
const defaultDesc = opts.description ?? `${String(propertyKey)} of ${target.constructor.name}`;
|
|
134
134
|
gqlOpts.description = gqlOpts.description ?? defaultDesc;
|
|
135
135
|
swaggerOpts.description = swaggerOpts.description ?? defaultDesc;
|
|
136
136
|
|
|
137
|
-
//
|
|
137
|
+
// Set swagger example
|
|
138
138
|
if (opts.example !== undefined) {
|
|
139
139
|
swaggerOpts.example = swaggerOpts.example ?? opts.example;
|
|
140
140
|
}
|