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.
@@ -13411,10 +13411,17 @@ function parseEnumValue(value, values, label) {
13411
13411
  return match;
13412
13412
  }
13413
13413
  function validateStringPattern(value, schema, label) {
13414
- if (schema.pattern === void 0) {
13415
- return value;
13414
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
13415
+ throw new UserError(
13416
+ `Invalid value for "${label}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
13417
+ );
13416
13418
  }
13417
- if (!matchesStringPattern(value, schema.pattern)) {
13419
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
13420
+ throw new UserError(
13421
+ `Invalid value for "${label}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
13422
+ );
13423
+ }
13424
+ if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
13418
13425
  throw new UserError(
13419
13426
  `Invalid value for "${label}": "${value}" does not match pattern "${schema.pattern}".`
13420
13427
  );
@@ -13596,6 +13603,18 @@ function parseArrayValue(value, schema, label) {
13596
13603
  (item) => parseScalarValue(item, itemSchema, label)
13597
13604
  );
13598
13605
  }
13606
+ function validateArrayBounds(value, schema, label) {
13607
+ if (schema.minItems !== void 0 && value.length < schema.minItems) {
13608
+ throw new UserError(
13609
+ `Invalid value for "${label}". Expected an array with at least ${schema.minItems} items, got array(${value.length}).`
13610
+ );
13611
+ }
13612
+ if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
13613
+ throw new UserError(
13614
+ `Invalid value for "${label}". Expected an array with at most ${schema.maxItems} items, got array(${value.length}).`
13615
+ );
13616
+ }
13617
+ }
13599
13618
  function createOption(field, globalLongOptionFlags) {
13600
13619
  const flags = formatOptionFlags(field, globalLongOptionFlags);
13601
13620
  const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
@@ -14565,6 +14584,9 @@ function describeExpectedPresetValue(schema) {
14565
14584
  if (schema.kind === "array") {
14566
14585
  return "an array";
14567
14586
  }
14587
+ if (schema.kind === "number") {
14588
+ return getExpectedNumberDescription(schema);
14589
+ }
14568
14590
  if (schema.kind === "json") {
14569
14591
  return "valid JSON";
14570
14592
  }
@@ -14582,6 +14604,16 @@ function validatePresetScalarValue(value, schema, fieldPath, presetPath) {
14582
14604
  if (typeof value !== "string") {
14583
14605
  break;
14584
14606
  }
14607
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
14608
+ throw new UserError(
14609
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
14610
+ );
14611
+ }
14612
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
14613
+ throw new UserError(
14614
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
14615
+ );
14616
+ }
14585
14617
  if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
14586
14618
  throw new UserError(
14587
14619
  `Preset file "${presetPath}" has an invalid value for "${fieldPath}": "${value}" does not match pattern "${schema.pattern}".`
@@ -14631,6 +14663,16 @@ function validatePresetFieldValue(value, field, presetPath) {
14631
14663
  `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array, got ${describeReceived(value)}.`
14632
14664
  );
14633
14665
  }
14666
+ if (field.schema.minItems !== void 0 && value.length < field.schema.minItems) {
14667
+ throw new UserError(
14668
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at least ${field.schema.minItems} items, got array(${value.length}).`
14669
+ );
14670
+ }
14671
+ if (field.schema.maxItems !== void 0 && value.length > field.schema.maxItems) {
14672
+ throw new UserError(
14673
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at most ${field.schema.maxItems} items, got array(${value.length}).`
14674
+ );
14675
+ }
14634
14676
  return value.map(
14635
14677
  (item) => validatePresetScalarValue(item, itemSchema, field.displayPath, presetPath)
14636
14678
  );
@@ -15040,12 +15082,17 @@ function parseOptionFieldValue(field, value, errors2) {
15040
15082
  }
15041
15083
  parsedValues.push(...parsed);
15042
15084
  }
15085
+ validateArrayBounds(parsedValues, field.schema, field.displayPath);
15043
15086
  return { ok: true, value: parsedValues };
15044
15087
  }
15045
15088
  if (typeof value !== "string") {
15046
15089
  return { ok: true, value };
15047
15090
  }
15048
- return { ok: true, value: parseFieldInputValue(value, field.schema, field.displayPath) };
15091
+ const parsedValue = parseFieldInputValue(value, field.schema, field.displayPath);
15092
+ if (field.schema.kind === "array" && Array.isArray(parsedValue)) {
15093
+ validateArrayBounds(parsedValue, field.schema, field.displayPath);
15094
+ }
15095
+ return { ok: true, value: parsedValue };
15049
15096
  } catch (error3) {
15050
15097
  if (error3 instanceof UserError || error3 instanceof InvalidArgumentError) {
15051
15098
  errors2.push({
@@ -15106,6 +15153,7 @@ function consumeFieldValue(args, index, schema, label, inlineValue) {
15106
15153
  if (values.length === 0) {
15107
15154
  throw new InvalidArgumentError(`option '${label}' argument missing`);
15108
15155
  }
15156
+ validateArrayBounds(values, schema, label);
15109
15157
  return {
15110
15158
  nextIndex,
15111
15159
  value: values