@lenne.tech/nest-server 11.4.4 → 11.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "11.4.4",
3
+ "version": "11.4.5",
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",
@@ -7,6 +7,7 @@ import {
7
7
  IsArray,
8
8
  IsBoolean,
9
9
  IsDate,
10
+ IsDefined,
10
11
  IsEnum,
11
12
  IsNotEmpty,
12
13
  IsNumber,
@@ -22,6 +23,10 @@ import { GraphQLScalarType } from 'graphql';
22
23
  import { RoleEnum } from '../enums/role.enum';
23
24
  import { Restricted, RestrictedType } from './restricted.decorator';
24
25
 
26
+ // Registry to store nested type information for validation
27
+ // Key: `${className}.${propertyName}`, Value: nested type constructor
28
+ export const nestedTypeRegistry = new Map<string, any>();
29
+
25
30
  export interface UnifiedFieldOptions {
26
31
  /** Description used for both Swagger & Gql */
27
32
  description?: string;
@@ -128,6 +133,8 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
128
133
  swaggerOpts.nullable = true;
129
134
  swaggerOpts.required = false;
130
135
  } else {
136
+ // Use IsDefined to ensure field is present, then IsNotEmpty to ensure it's not empty
137
+ IsDefined()(target, propertyKey);
131
138
  IsNotEmpty()(target, propertyKey);
132
139
 
133
140
  gqlOpts.nullable = false;
@@ -209,10 +216,20 @@ export function UnifiedField(opts: UnifiedFieldOptions = {}): PropertyDecorator
209
216
  }
210
217
 
211
218
  if (!opts.isAny) {
219
+ // Special handling for Date: needs @Type transformation even though it's "primitive"
220
+ // This allows ISO date strings to be transformed to Date objects before validation
221
+ if (baseType === Date) {
222
+ Type(() => Date)(target, propertyKey);
223
+ }
212
224
  // Check if it's a primitive, if not apply transform
213
- if (!isPrimitive(baseType) && !opts.enum && !isGraphQLScalar(baseType)) {
225
+ else if (!isPrimitive(baseType) && !opts.enum && !isGraphQLScalar(baseType)) {
214
226
  Type(() => baseType)(target, propertyKey);
215
227
  ValidateNested({ each: isArrayField })(target, propertyKey);
228
+
229
+ // Store nested type info in registry for use in MapAndValidatePipe
230
+ const className = target.constructor.name;
231
+ const registryKey = `${className}.${String(propertyKey)}`;
232
+ nestedTypeRegistry.set(registryKey, baseType);
216
233
  }
217
234
  }
218
235