ag-common 0.0.866 → 0.0.868
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/api/helpers/zod.js +8 -3
- package/package.json +1 -1
package/dist/api/helpers/zod.js
CHANGED
|
@@ -22,8 +22,13 @@ function zodSchemaToString(schema) {
|
|
|
22
22
|
const fields = [];
|
|
23
23
|
for (const [key, value] of Object.entries(schema.shape)) {
|
|
24
24
|
const zodType = value;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
try {
|
|
26
|
+
const typeCode = zodTypeToCode(zodType);
|
|
27
|
+
fields.push(` ${key}: ${typeCode}`);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
throw new Error(`Failed to convert field "${key}": ${e.message}`);
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
return `z.object({\n${fields.join(',\n')}\n})`;
|
|
29
34
|
}
|
|
@@ -105,5 +110,5 @@ function zodTypeToCode(zodType) {
|
|
|
105
110
|
const itemsStr = items.map((item) => zodTypeToCode(item)).join(', ');
|
|
106
111
|
return `z.tuple([${itemsStr}])${describeChain}`;
|
|
107
112
|
}
|
|
108
|
-
throw new Error(`Unsupported Zod type: ${typeName}`);
|
|
113
|
+
throw new Error(`Unsupported Zod type: ${typeName} (keys: ${Object.keys(zodType._def).join(', ')})`);
|
|
109
114
|
}
|
package/package.json
CHANGED