@statezero/core 0.1.74 → 0.1.75
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.
|
@@ -243,8 +243,10 @@ const dtsActionTemplate = Handlebars.compile(TS_ACTION_DECLARATION_TEMPLATE);
|
|
|
243
243
|
// ================================================================================================
|
|
244
244
|
function generateZodSchemaForProperty(prop) {
|
|
245
245
|
let zodString;
|
|
246
|
-
if (prop.choices && prop.choices.length > 0) {
|
|
247
|
-
|
|
246
|
+
if (prop.choices && Object.keys(prop.choices).length > 0) {
|
|
247
|
+
// Extract just the keys (values) from the choices dict
|
|
248
|
+
const choiceValues = Object.keys(prop.choices);
|
|
249
|
+
zodString = `z.enum(${JSON.stringify(choiceValues)})`;
|
|
248
250
|
}
|
|
249
251
|
else {
|
|
250
252
|
switch (prop.type) {
|
|
@@ -327,8 +329,8 @@ function generateZodSchemaForProperty(prop) {
|
|
|
327
329
|
return zodString;
|
|
328
330
|
}
|
|
329
331
|
function generateTsTypeForProperty(prop) {
|
|
330
|
-
if (prop.choices && prop.choices.length > 0) {
|
|
331
|
-
return prop.choices
|
|
332
|
+
if (prop.choices && Object.keys(prop.choices).length > 0) {
|
|
333
|
+
return Object.keys(prop.choices)
|
|
332
334
|
.map((c) => `'${String(c).replace(/'/g, "\\'")}'`)
|
|
333
335
|
.join(" | ");
|
|
334
336
|
}
|
package/package.json
CHANGED