webspresso 0.0.39 → 0.0.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.
package/package.json
CHANGED
|
@@ -263,23 +263,23 @@ function createExtensionApiHandlers(options) {
|
|
|
263
263
|
return res.status(404).json({ error: 'Model not found or not enabled' });
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
// Get field metadata
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
266
|
+
// Get field metadata - model.columns is Map<string, ColumnMeta>
|
|
267
|
+
const columnMeta = model.columns.get(field);
|
|
268
|
+
if (!columnMeta) {
|
|
269
269
|
return res.status(400).json({ error: `Field "${field}" not found in model` });
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// Validate field type - only allow enum and boolean
|
|
273
|
-
const
|
|
274
|
-
const isEnum =
|
|
275
|
-
const isBoolean = columnMeta.type === 'boolean'
|
|
273
|
+
const enumValues = columnMeta.enumValues || columnMeta.enum;
|
|
274
|
+
const isEnum = enumValues && Array.isArray(enumValues);
|
|
275
|
+
const isBoolean = columnMeta.type === 'boolean';
|
|
276
276
|
|
|
277
277
|
if (!isEnum && !isBoolean) {
|
|
278
278
|
return res.status(400).json({ error: `Field "${field}" is not an enum or boolean type` });
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
// Validate value for enum fields
|
|
282
|
-
if (isEnum && !
|
|
282
|
+
if (isEnum && !enumValues.includes(value)) {
|
|
283
283
|
return res.status(400).json({ error: `Invalid value "${value}" for enum field "${field}"` });
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -352,17 +352,19 @@ function createExtensionApiHandlers(options) {
|
|
|
352
352
|
|
|
353
353
|
const bulkFields = [];
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const
|
|
355
|
+
// model.columns is a Map<string, ColumnMeta> - values are already metadata objects
|
|
356
|
+
for (const [fieldName, columnMeta] of model.columns.entries()) {
|
|
357
|
+
// Check for enum - schema uses 'enumValues' property
|
|
358
|
+
const enumValues = columnMeta.enumValues || columnMeta.enum;
|
|
359
|
+
const isEnum = enumValues && Array.isArray(enumValues);
|
|
360
|
+
const isBoolean = columnMeta.type === 'boolean';
|
|
359
361
|
|
|
360
362
|
if (isEnum) {
|
|
361
363
|
bulkFields.push({
|
|
362
364
|
name: fieldName,
|
|
363
365
|
type: 'enum',
|
|
364
366
|
label: columnMeta.label || fieldName,
|
|
365
|
-
options:
|
|
367
|
+
options: enumValues.map(v => ({ value: v, label: v })),
|
|
366
368
|
});
|
|
367
369
|
} else if (isBoolean) {
|
|
368
370
|
bulkFields.push({
|