terminal-pilot 0.0.29 → 0.0.30

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/cli.js CHANGED
@@ -13339,10 +13339,17 @@ function parseEnumValue(value, values, label) {
13339
13339
  return match;
13340
13340
  }
13341
13341
  function validateStringPattern(value, schema, label) {
13342
- if (schema.pattern === void 0) {
13343
- return value;
13342
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
13343
+ throw new UserError(
13344
+ `Invalid value for "${label}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
13345
+ );
13344
13346
  }
13345
- if (!matchesStringPattern(value, schema.pattern)) {
13347
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
13348
+ throw new UserError(
13349
+ `Invalid value for "${label}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
13350
+ );
13351
+ }
13352
+ if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
13346
13353
  throw new UserError(
13347
13354
  `Invalid value for "${label}": "${value}" does not match pattern "${schema.pattern}".`
13348
13355
  );
@@ -13524,6 +13531,18 @@ function parseArrayValue(value, schema, label) {
13524
13531
  (item) => parseScalarValue(item, itemSchema, label)
13525
13532
  );
13526
13533
  }
13534
+ function validateArrayBounds(value, schema, label) {
13535
+ if (schema.minItems !== void 0 && value.length < schema.minItems) {
13536
+ throw new UserError(
13537
+ `Invalid value for "${label}". Expected an array with at least ${schema.minItems} items, got array(${value.length}).`
13538
+ );
13539
+ }
13540
+ if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
13541
+ throw new UserError(
13542
+ `Invalid value for "${label}". Expected an array with at most ${schema.maxItems} items, got array(${value.length}).`
13543
+ );
13544
+ }
13545
+ }
13527
13546
  function createOption(field, globalLongOptionFlags) {
13528
13547
  const flags = formatOptionFlags(field, globalLongOptionFlags);
13529
13548
  const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
@@ -14493,6 +14512,9 @@ function describeExpectedPresetValue(schema) {
14493
14512
  if (schema.kind === "array") {
14494
14513
  return "an array";
14495
14514
  }
14515
+ if (schema.kind === "number") {
14516
+ return getExpectedNumberDescription(schema);
14517
+ }
14496
14518
  if (schema.kind === "json") {
14497
14519
  return "valid JSON";
14498
14520
  }
@@ -14510,6 +14532,16 @@ function validatePresetScalarValue(value, schema, fieldPath, presetPath) {
14510
14532
  if (typeof value !== "string") {
14511
14533
  break;
14512
14534
  }
14535
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
14536
+ throw new UserError(
14537
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
14538
+ );
14539
+ }
14540
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
14541
+ throw new UserError(
14542
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
14543
+ );
14544
+ }
14513
14545
  if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
14514
14546
  throw new UserError(
14515
14547
  `Preset file "${presetPath}" has an invalid value for "${fieldPath}": "${value}" does not match pattern "${schema.pattern}".`
@@ -14559,6 +14591,16 @@ function validatePresetFieldValue(value, field, presetPath) {
14559
14591
  `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array, got ${describeReceived(value)}.`
14560
14592
  );
14561
14593
  }
14594
+ if (field.schema.minItems !== void 0 && value.length < field.schema.minItems) {
14595
+ throw new UserError(
14596
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at least ${field.schema.minItems} items, got array(${value.length}).`
14597
+ );
14598
+ }
14599
+ if (field.schema.maxItems !== void 0 && value.length > field.schema.maxItems) {
14600
+ throw new UserError(
14601
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at most ${field.schema.maxItems} items, got array(${value.length}).`
14602
+ );
14603
+ }
14562
14604
  return value.map(
14563
14605
  (item) => validatePresetScalarValue(item, itemSchema, field.displayPath, presetPath)
14564
14606
  );
@@ -14968,12 +15010,17 @@ function parseOptionFieldValue(field, value, errors2) {
14968
15010
  }
14969
15011
  parsedValues.push(...parsed);
14970
15012
  }
15013
+ validateArrayBounds(parsedValues, field.schema, field.displayPath);
14971
15014
  return { ok: true, value: parsedValues };
14972
15015
  }
14973
15016
  if (typeof value !== "string") {
14974
15017
  return { ok: true, value };
14975
15018
  }
14976
- return { ok: true, value: parseFieldInputValue(value, field.schema, field.displayPath) };
15019
+ const parsedValue = parseFieldInputValue(value, field.schema, field.displayPath);
15020
+ if (field.schema.kind === "array" && Array.isArray(parsedValue)) {
15021
+ validateArrayBounds(parsedValue, field.schema, field.displayPath);
15022
+ }
15023
+ return { ok: true, value: parsedValue };
14977
15024
  } catch (error3) {
14978
15025
  if (error3 instanceof UserError || error3 instanceof InvalidArgumentError) {
14979
15026
  errors2.push({
@@ -15034,6 +15081,7 @@ function consumeFieldValue(args, index, schema, label, inlineValue) {
15034
15081
  if (values.length === 0) {
15035
15082
  throw new InvalidArgumentError(`option '${label}' argument missing`);
15036
15083
  }
15084
+ validateArrayBounds(values, schema, label);
15037
15085
  return {
15038
15086
  nextIndex,
15039
15087
  value: values