@common-stack/server-core 7.2.1-alpha.39 → 7.2.1-alpha.40
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.
|
@@ -254,13 +254,23 @@ function generateZodType(paramType, isOptional, paramName = '') {
|
|
|
254
254
|
}
|
|
255
255
|
return zodType;
|
|
256
256
|
} else if (nonNullableTypes.length > 1) {
|
|
257
|
-
// Multiple types -
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
// Multiple types - generate z.union() for known types
|
|
258
|
+
// This handles cases like "IExtensionIdentifier | string"
|
|
259
|
+
const unionTypes = nonNullableTypes.map(type => {
|
|
260
|
+
// Check if it's a GraphQL type
|
|
261
|
+
if (GRAPHQL_ZOD_TYPES.has(type)) {
|
|
262
|
+
const schemaName = type.replace(/^I/, '') + 'Schema';
|
|
263
|
+
return `${schemaName}()`;
|
|
264
|
+
}
|
|
265
|
+
// Handle primitive types
|
|
266
|
+
if (type === 'string') return 'z.string()';
|
|
267
|
+
if (type === 'number') return 'z.number()';
|
|
268
|
+
if (type === 'boolean') return 'z.boolean()';
|
|
269
|
+
// Default to passthrough
|
|
270
|
+
return 'PassthroughObjectSchema';
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
return `z.union([${unionTypes.join(', ')}])`;
|
|
264
274
|
}
|
|
265
275
|
}
|
|
266
276
|
|
|
@@ -364,6 +374,16 @@ function generateServiceSchemas() {
|
|
|
364
374
|
allUsedGraphQLTypes.add(innerType);
|
|
365
375
|
}
|
|
366
376
|
}
|
|
377
|
+
// Check in union types (e.g., "IExtensionIdentifier | string")
|
|
378
|
+
if (param.type.includes('|')) {
|
|
379
|
+
const types = param.type.split('|').map(t => t.trim());
|
|
380
|
+
types.forEach(type => {
|
|
381
|
+
// Remove null and undefined
|
|
382
|
+
if (type !== 'null' && type !== 'undefined' && GRAPHQL_ZOD_TYPES.has(type)) {
|
|
383
|
+
allUsedGraphQLTypes.add(type);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
367
387
|
});
|
|
368
388
|
});
|
|
369
389
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/server-core",
|
|
3
|
-
"version": "7.2.1-alpha.
|
|
3
|
+
"version": "7.2.1-alpha.40",
|
|
4
4
|
"description": "common core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "b01534f98cc4e891b51ce7d3857d1d6630e6ece9",
|
|
38
38
|
"typescript": {
|
|
39
39
|
"definition": "lib/index.d.ts"
|
|
40
40
|
}
|