@tutti-os/app-release-tools 0.0.43 → 0.0.44
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.
|
@@ -296,8 +296,19 @@ function validateCLIInputSchema(schema, label) {
|
|
|
296
296
|
`${label}.properties.${name}.type must be string, boolean, or integer`
|
|
297
297
|
);
|
|
298
298
|
}
|
|
299
|
+
validateCLIInputEnum(
|
|
300
|
+
property.enum,
|
|
301
|
+
property.type,
|
|
302
|
+
`${label}.properties.${name}.enum`
|
|
303
|
+
);
|
|
304
|
+
validateCLIInputDefault(
|
|
305
|
+
property.default,
|
|
306
|
+
property.type,
|
|
307
|
+
property.enum,
|
|
308
|
+
`${label}.properties.${name}.default`
|
|
309
|
+
);
|
|
299
310
|
for (const key of Object.keys(property)) {
|
|
300
|
-
if (!["type", "description"].includes(key)) {
|
|
311
|
+
if (!["type", "description", "enum", "default"].includes(key)) {
|
|
301
312
|
throw new Error(`${label}.properties.${name}.${key} is not supported`);
|
|
302
313
|
}
|
|
303
314
|
}
|
|
@@ -320,6 +331,40 @@ function validateCLIInputSchema(schema, label) {
|
|
|
320
331
|
}
|
|
321
332
|
}
|
|
322
333
|
|
|
334
|
+
function validateCLIInputDefault(value, type, enumValues, label) {
|
|
335
|
+
if (value === undefined) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
validateCLIInputValue(value, type, label);
|
|
339
|
+
if (enumValues !== undefined && !enumValues.includes(value)) {
|
|
340
|
+
throw new Error(`${label} must be one of the declared enum values`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function validateCLIInputEnum(values, type, label) {
|
|
345
|
+
if (values === undefined) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
349
|
+
throw new Error(`${label} must be a non-empty array`);
|
|
350
|
+
}
|
|
351
|
+
for (const [index, value] of values.entries()) {
|
|
352
|
+
validateCLIInputValue(value, type, `${label}[${index}]`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function validateCLIInputValue(value, type, label) {
|
|
357
|
+
if (type === "integer") {
|
|
358
|
+
if (!Number.isInteger(value)) {
|
|
359
|
+
throw new Error(`${label} must be an integer`);
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (typeof value !== type) {
|
|
364
|
+
throw new Error(`${label} must be ${type}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
323
368
|
function validateCLIOutput(output, label) {
|
|
324
369
|
if (!output || typeof output !== "object" || Array.isArray(output)) {
|
|
325
370
|
throw new Error(`${label} must be an object`);
|