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.
@@ -13418,10 +13418,17 @@ function parseEnumValue(value, values, label) {
13418
13418
  return match;
13419
13419
  }
13420
13420
  function validateStringPattern(value, schema, label) {
13421
- if (schema.pattern === void 0) {
13422
- return value;
13421
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
13422
+ throw new UserError(
13423
+ `Invalid value for "${label}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
13424
+ );
13423
13425
  }
13424
- if (!matchesStringPattern(value, schema.pattern)) {
13426
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
13427
+ throw new UserError(
13428
+ `Invalid value for "${label}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
13429
+ );
13430
+ }
13431
+ if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
13425
13432
  throw new UserError(
13426
13433
  `Invalid value for "${label}": "${value}" does not match pattern "${schema.pattern}".`
13427
13434
  );
@@ -13603,6 +13610,18 @@ function parseArrayValue(value, schema, label) {
13603
13610
  (item) => parseScalarValue(item, itemSchema, label)
13604
13611
  );
13605
13612
  }
13613
+ function validateArrayBounds(value, schema, label) {
13614
+ if (schema.minItems !== void 0 && value.length < schema.minItems) {
13615
+ throw new UserError(
13616
+ `Invalid value for "${label}". Expected an array with at least ${schema.minItems} items, got array(${value.length}).`
13617
+ );
13618
+ }
13619
+ if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
13620
+ throw new UserError(
13621
+ `Invalid value for "${label}". Expected an array with at most ${schema.maxItems} items, got array(${value.length}).`
13622
+ );
13623
+ }
13624
+ }
13606
13625
  function createOption(field, globalLongOptionFlags) {
13607
13626
  const flags = formatOptionFlags(field, globalLongOptionFlags);
13608
13627
  const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
@@ -14572,6 +14591,9 @@ function describeExpectedPresetValue(schema) {
14572
14591
  if (schema.kind === "array") {
14573
14592
  return "an array";
14574
14593
  }
14594
+ if (schema.kind === "number") {
14595
+ return getExpectedNumberDescription(schema);
14596
+ }
14575
14597
  if (schema.kind === "json") {
14576
14598
  return "valid JSON";
14577
14599
  }
@@ -14589,6 +14611,16 @@ function validatePresetScalarValue(value, schema, fieldPath, presetPath) {
14589
14611
  if (typeof value !== "string") {
14590
14612
  break;
14591
14613
  }
14614
+ if (schema.minLength !== void 0 && value.length < schema.minLength) {
14615
+ throw new UserError(
14616
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at least ${schema.minLength}, got string with length ${value.length}.`
14617
+ );
14618
+ }
14619
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
14620
+ throw new UserError(
14621
+ `Preset file "${presetPath}" has an invalid value for "${fieldPath}". Expected a string with length at most ${schema.maxLength}, got string with length ${value.length}.`
14622
+ );
14623
+ }
14592
14624
  if (schema.pattern !== void 0 && !matchesStringPattern(value, schema.pattern)) {
14593
14625
  throw new UserError(
14594
14626
  `Preset file "${presetPath}" has an invalid value for "${fieldPath}": "${value}" does not match pattern "${schema.pattern}".`
@@ -14638,6 +14670,16 @@ function validatePresetFieldValue(value, field, presetPath) {
14638
14670
  `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array, got ${describeReceived(value)}.`
14639
14671
  );
14640
14672
  }
14673
+ if (field.schema.minItems !== void 0 && value.length < field.schema.minItems) {
14674
+ throw new UserError(
14675
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at least ${field.schema.minItems} items, got array(${value.length}).`
14676
+ );
14677
+ }
14678
+ if (field.schema.maxItems !== void 0 && value.length > field.schema.maxItems) {
14679
+ throw new UserError(
14680
+ `Preset file "${presetPath}" has an invalid value for "${field.displayPath}". Expected an array with at most ${field.schema.maxItems} items, got array(${value.length}).`
14681
+ );
14682
+ }
14641
14683
  return value.map(
14642
14684
  (item) => validatePresetScalarValue(item, itemSchema, field.displayPath, presetPath)
14643
14685
  );
@@ -15047,12 +15089,17 @@ function parseOptionFieldValue(field, value, errors2) {
15047
15089
  }
15048
15090
  parsedValues.push(...parsed);
15049
15091
  }
15092
+ validateArrayBounds(parsedValues, field.schema, field.displayPath);
15050
15093
  return { ok: true, value: parsedValues };
15051
15094
  }
15052
15095
  if (typeof value !== "string") {
15053
15096
  return { ok: true, value };
15054
15097
  }
15055
- return { ok: true, value: parseFieldInputValue(value, field.schema, field.displayPath) };
15098
+ const parsedValue = parseFieldInputValue(value, field.schema, field.displayPath);
15099
+ if (field.schema.kind === "array" && Array.isArray(parsedValue)) {
15100
+ validateArrayBounds(parsedValue, field.schema, field.displayPath);
15101
+ }
15102
+ return { ok: true, value: parsedValue };
15056
15103
  } catch (error3) {
15057
15104
  if (error3 instanceof UserError || error3 instanceof InvalidArgumentError) {
15058
15105
  errors2.push({
@@ -15113,6 +15160,7 @@ function consumeFieldValue(args, index, schema, label, inlineValue) {
15113
15160
  if (values.length === 0) {
15114
15161
  throw new InvalidArgumentError(`option '${label}' argument missing`);
15115
15162
  }
15163
+ validateArrayBounds(values, schema, label);
15116
15164
  return {
15117
15165
  nextIndex,
15118
15166
  value: values