next-openapi-gen 1.4.1 → 1.4.2

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.
@@ -3455,23 +3455,58 @@ var SymbolResolver = class {
3455
3455
  }
3456
3456
  /**
3457
3457
  * Returns a simple literal value (string/number/boolean/null) for a `const` declarator,
3458
- * or `null` if no such declarator exists.
3458
+ * following imports and re-exports when the name is not declared locally.
3459
3459
  */
3460
3460
  resolveLiteral(filePath, name) {
3461
+ const visited = /* @__PURE__ */ new Set();
3462
+ return this.resolveLiteralInternal(filePath, name, visited);
3463
+ }
3464
+ resolveLiteralInternal(filePath, name, visited) {
3465
+ if (visited.has(filePath))
3466
+ return void 0;
3467
+ visited.add(filePath);
3461
3468
  const index = this.getIndex(filePath);
3462
3469
  if (!index)
3463
3470
  return void 0;
3464
3471
  const literal2 = index.constLiterals.get(name);
3465
- if (!literal2)
3466
- return void 0;
3467
- if (t4.isStringLiteral(literal2))
3468
- return literal2.value;
3469
- if (t4.isNumericLiteral(literal2))
3470
- return literal2.value;
3471
- if (t4.isBooleanLiteral(literal2))
3472
- return literal2.value;
3473
- if (t4.isNullLiteral(literal2))
3474
- return null;
3472
+ if (literal2) {
3473
+ if (t4.isStringLiteral(literal2))
3474
+ return literal2.value;
3475
+ if (t4.isNumericLiteral(literal2))
3476
+ return literal2.value;
3477
+ if (t4.isBooleanLiteral(literal2))
3478
+ return literal2.value;
3479
+ if (t4.isNullLiteral(literal2))
3480
+ return null;
3481
+ }
3482
+ const imports = this.getImports(filePath);
3483
+ const importInfo = imports?.get(name);
3484
+ if (importInfo) {
3485
+ const resolved = this.resolveImportPath(filePath, importInfo.source);
3486
+ if (resolved) {
3487
+ const targetName = importInfo.importedName === "default" ? name : importInfo.importedName;
3488
+ const result = this.resolveLiteralInternal(resolved, targetName, visited);
3489
+ if (result !== void 0)
3490
+ return result;
3491
+ }
3492
+ }
3493
+ const reExport = index.namedReExports.get(name);
3494
+ if (reExport) {
3495
+ const resolved = this.resolveImportPath(filePath, reExport.source);
3496
+ if (resolved) {
3497
+ const result = this.resolveLiteralInternal(resolved, reExport.importedName, visited);
3498
+ if (result !== void 0)
3499
+ return result;
3500
+ }
3501
+ }
3502
+ for (const starSrc of index.exportsStar) {
3503
+ const resolved = this.resolveImportPath(filePath, starSrc);
3504
+ if (!resolved)
3505
+ continue;
3506
+ const result = this.resolveLiteralInternal(resolved, name, visited);
3507
+ if (result !== void 0)
3508
+ return result;
3509
+ }
3475
3510
  return void 0;
3476
3511
  }
3477
3512
  /**
@@ -13794,6 +13829,58 @@ var ZodSchemaConverter = class {
13794
13829
  this.symbolResolver.primeAST(this.currentFilePath, this.currentAST);
13795
13830
  return this.symbolResolver.resolveLiteral(this.currentFilePath, name);
13796
13831
  }
13832
+ /**
13833
+ * Unwrap a possible `TSAsExpression` / `TSSatisfiesExpression` to get the
13834
+ * underlying expression node. Returns the node itself when no wrapper is
13835
+ * present.
13836
+ */
13837
+ unwrapTypeAssertion(node) {
13838
+ if (!node)
13839
+ return void 0;
13840
+ if (t11.isTSAsExpression(node) || t11.isTSSatisfiesExpression(node)) {
13841
+ return node.expression;
13842
+ }
13843
+ return node;
13844
+ }
13845
+ /**
13846
+ * Resolve a numeric value from a call-expression argument.
13847
+ * Handles: numeric literals, identifier references to const numbers,
13848
+ * and `x as number` / `x satisfies number` wrappers around either.
13849
+ */
13850
+ resolveNumericArg(arg) {
13851
+ if (!arg)
13852
+ return void 0;
13853
+ const node = this.unwrapTypeAssertion(arg);
13854
+ if (t11.isNumericLiteral(node))
13855
+ return node.value;
13856
+ if (t11.isUnaryExpression(node) && node.operator === "-" && t11.isNumericLiteral(node.argument)) {
13857
+ return -node.argument.value;
13858
+ }
13859
+ if (t11.isIdentifier(node)) {
13860
+ const val = this.resolveLiteralValue(node.name);
13861
+ if (typeof val === "number")
13862
+ return val;
13863
+ }
13864
+ return void 0;
13865
+ }
13866
+ /**
13867
+ * Resolve a string value from a call-expression argument.
13868
+ * Handles: string literals, identifier references to const strings,
13869
+ * and `x as string` / `x satisfies string` wrappers around either.
13870
+ */
13871
+ resolveStringArg(arg) {
13872
+ if (!arg)
13873
+ return void 0;
13874
+ const node = this.unwrapTypeAssertion(arg);
13875
+ if (t11.isStringLiteral(node))
13876
+ return node.value;
13877
+ if (t11.isIdentifier(node)) {
13878
+ const val = this.resolveLiteralValue(node.name);
13879
+ if (typeof val === "string")
13880
+ return val;
13881
+ }
13882
+ return void 0;
13883
+ }
13797
13884
  /**
13798
13885
  * Resolve an identifier referring to a `z.object({...})` (or similar) call expression.
13799
13886
  * This lets callers inline the referenced object's shape.
@@ -13862,6 +13949,14 @@ var ZodSchemaConverter = class {
13862
13949
  if (t11.isNullLiteral(node)) {
13863
13950
  return null;
13864
13951
  }
13952
+ if (t11.isIdentifier(node)) {
13953
+ const val = this.resolveLiteralValue(node.name);
13954
+ if (val !== void 0)
13955
+ return val;
13956
+ }
13957
+ if (t11.isTSAsExpression(node) || t11.isTSSatisfiesExpression(node)) {
13958
+ return this.extractStaticJsonValue(node.expression);
13959
+ }
13865
13960
  if (t11.isArrayExpression(node)) {
13866
13961
  const values = [];
13867
13962
  for (const element of node.elements) {
@@ -13960,53 +14055,60 @@ var ZodSchemaConverter = class {
13960
14055
  schema.nullable = true;
13961
14056
  }
13962
14057
  break;
13963
- case "describe":
13964
- if (node.arguments.length > 0 && t11.isStringLiteral(node.arguments[0])) {
13965
- const description = node.arguments[0].value;
13966
- if (description.startsWith("@deprecated")) {
14058
+ case "describe": {
14059
+ const descVal = this.resolveStringArg(node.arguments[0]);
14060
+ if (descVal !== void 0) {
14061
+ if (descVal.startsWith("@deprecated")) {
13967
14062
  schema.deprecated = true;
13968
- schema.description = description.replace("@deprecated", "").trim();
14063
+ schema.description = descVal.replace("@deprecated", "").trim();
13969
14064
  } else {
13970
- schema.description = description;
14065
+ schema.description = descVal;
13971
14066
  }
13972
14067
  }
13973
14068
  break;
14069
+ }
13974
14070
  case "deprecated":
13975
14071
  schema.deprecated = true;
13976
14072
  break;
13977
- case "min":
13978
- if (node.arguments.length > 0 && t11.isNumericLiteral(node.arguments[0])) {
14073
+ case "min": {
14074
+ const minVal = this.resolveNumericArg(node.arguments[0]);
14075
+ if (minVal !== void 0) {
13979
14076
  if (schema.type === "string") {
13980
- schema.minLength = node.arguments[0].value;
14077
+ schema.minLength = minVal;
13981
14078
  } else if (schema.type === "number" || schema.type === "integer") {
13982
- schema.minimum = node.arguments[0].value;
14079
+ schema.minimum = minVal;
13983
14080
  } else if (schema.type === "array") {
13984
- schema.minItems = node.arguments[0].value;
14081
+ schema.minItems = minVal;
13985
14082
  }
13986
14083
  }
13987
14084
  break;
13988
- case "max":
13989
- if (node.arguments.length > 0 && t11.isNumericLiteral(node.arguments[0])) {
14085
+ }
14086
+ case "max": {
14087
+ const maxVal = this.resolveNumericArg(node.arguments[0]);
14088
+ if (maxVal !== void 0) {
13990
14089
  if (schema.type === "string") {
13991
- schema.maxLength = node.arguments[0].value;
14090
+ schema.maxLength = maxVal;
13992
14091
  } else if (schema.type === "number" || schema.type === "integer") {
13993
- schema.maximum = node.arguments[0].value;
14092
+ schema.maximum = maxVal;
13994
14093
  } else if (schema.type === "array") {
13995
- schema.maxItems = node.arguments[0].value;
14094
+ schema.maxItems = maxVal;
13996
14095
  }
13997
14096
  }
13998
14097
  break;
13999
- case "length":
14000
- if (node.arguments.length > 0 && t11.isNumericLiteral(node.arguments[0])) {
14098
+ }
14099
+ case "length": {
14100
+ const lenVal = this.resolveNumericArg(node.arguments[0]);
14101
+ if (lenVal !== void 0) {
14001
14102
  if (schema.type === "string") {
14002
- schema.minLength = node.arguments[0].value;
14003
- schema.maxLength = node.arguments[0].value;
14103
+ schema.minLength = lenVal;
14104
+ schema.maxLength = lenVal;
14004
14105
  } else if (schema.type === "array") {
14005
- schema.minItems = node.arguments[0].value;
14006
- schema.maxItems = node.arguments[0].value;
14106
+ schema.minItems = lenVal;
14107
+ schema.maxItems = lenVal;
14007
14108
  }
14008
14109
  }
14009
14110
  break;
14111
+ }
14010
14112
  case "nonempty":
14011
14113
  if (schema.type === "array") {
14012
14114
  schema.minItems = Math.max(schema.minItems ?? 0, 1);
@@ -14082,21 +14184,27 @@ var ZodSchemaConverter = class {
14082
14184
  schema.pattern = node.arguments[0].pattern;
14083
14185
  }
14084
14186
  break;
14085
- case "startsWith":
14086
- if (node.arguments.length > 0 && t11.isStringLiteral(node.arguments[0])) {
14087
- schema.pattern = `^${this.escapeRegExp(node.arguments[0].value)}`;
14187
+ case "startsWith": {
14188
+ const swVal = this.resolveStringArg(node.arguments[0]);
14189
+ if (swVal !== void 0) {
14190
+ schema.pattern = `^${this.escapeRegExp(swVal)}`;
14088
14191
  }
14089
14192
  break;
14090
- case "endsWith":
14091
- if (node.arguments.length > 0 && t11.isStringLiteral(node.arguments[0])) {
14092
- schema.pattern = `${this.escapeRegExp(node.arguments[0].value)}$`;
14193
+ }
14194
+ case "endsWith": {
14195
+ const ewVal = this.resolveStringArg(node.arguments[0]);
14196
+ if (ewVal !== void 0) {
14197
+ schema.pattern = `${this.escapeRegExp(ewVal)}$`;
14093
14198
  }
14094
14199
  break;
14095
- case "includes":
14096
- if (node.arguments.length > 0 && t11.isStringLiteral(node.arguments[0])) {
14097
- schema.pattern = this.escapeRegExp(node.arguments[0].value);
14200
+ }
14201
+ case "includes": {
14202
+ const incVal = this.resolveStringArg(node.arguments[0]);
14203
+ if (incVal !== void 0) {
14204
+ schema.pattern = this.escapeRegExp(incVal);
14098
14205
  }
14099
14206
  break;
14207
+ }
14100
14208
  case "int":
14101
14209
  schema.type = "integer";
14102
14210
  break;
@@ -14120,17 +14228,22 @@ var ZodSchemaConverter = class {
14120
14228
  break;
14121
14229
  case "default":
14122
14230
  if (node.arguments.length > 0) {
14123
- if (t11.isStringLiteral(node.arguments[0])) {
14124
- schema.default = node.arguments[0].value;
14125
- } else if (t11.isNumericLiteral(node.arguments[0])) {
14126
- schema.default = node.arguments[0].value;
14127
- } else if (t11.isBooleanLiteral(node.arguments[0])) {
14128
- schema.default = node.arguments[0].value;
14129
- } else if (t11.isNullLiteral(node.arguments[0])) {
14231
+ const defaultArg = this.unwrapTypeAssertion(node.arguments[0]);
14232
+ if (t11.isStringLiteral(defaultArg)) {
14233
+ schema.default = defaultArg.value;
14234
+ } else if (t11.isNumericLiteral(defaultArg)) {
14235
+ schema.default = defaultArg.value;
14236
+ } else if (t11.isBooleanLiteral(defaultArg)) {
14237
+ schema.default = defaultArg.value;
14238
+ } else if (t11.isNullLiteral(defaultArg)) {
14130
14239
  schema.default = null;
14131
- } else if (t11.isObjectExpression(node.arguments[0])) {
14240
+ } else if (t11.isIdentifier(defaultArg)) {
14241
+ const val = this.resolveLiteralValue(defaultArg.name);
14242
+ if (val !== void 0)
14243
+ schema.default = val;
14244
+ } else if (t11.isObjectExpression(defaultArg)) {
14132
14245
  const defaultObj = {};
14133
- node.arguments[0].properties.forEach((prop) => {
14246
+ defaultArg.properties.forEach((prop) => {
14134
14247
  if (t11.isObjectProperty(prop) && (t11.isIdentifier(prop.key) || t11.isStringLiteral(prop.key)) && (t11.isStringLiteral(prop.value) || t11.isNumericLiteral(prop.value) || t11.isBooleanLiteral(prop.value))) {
14135
14248
  const key = t11.isIdentifier(prop.key) ? prop.key.name : prop.key.value;
14136
14249
  const value = t11.isStringLiteral(prop.value) ? prop.value.value : t11.isNumericLiteral(prop.value) ? prop.value.value : t11.isBooleanLiteral(prop.value) ? prop.value.value : null;
@@ -2455,23 +2455,58 @@ var SymbolResolver = class {
2455
2455
  }
2456
2456
  /**
2457
2457
  * Returns a simple literal value (string/number/boolean/null) for a `const` declarator,
2458
- * or `null` if no such declarator exists.
2458
+ * following imports and re-exports when the name is not declared locally.
2459
2459
  */
2460
2460
  resolveLiteral(filePath, name) {
2461
+ const visited = /* @__PURE__ */ new Set();
2462
+ return this.resolveLiteralInternal(filePath, name, visited);
2463
+ }
2464
+ resolveLiteralInternal(filePath, name, visited) {
2465
+ if (visited.has(filePath))
2466
+ return void 0;
2467
+ visited.add(filePath);
2461
2468
  const index = this.getIndex(filePath);
2462
2469
  if (!index)
2463
2470
  return void 0;
2464
2471
  const literal2 = index.constLiterals.get(name);
2465
- if (!literal2)
2466
- return void 0;
2467
- if (t3.isStringLiteral(literal2))
2468
- return literal2.value;
2469
- if (t3.isNumericLiteral(literal2))
2470
- return literal2.value;
2471
- if (t3.isBooleanLiteral(literal2))
2472
- return literal2.value;
2473
- if (t3.isNullLiteral(literal2))
2474
- return null;
2472
+ if (literal2) {
2473
+ if (t3.isStringLiteral(literal2))
2474
+ return literal2.value;
2475
+ if (t3.isNumericLiteral(literal2))
2476
+ return literal2.value;
2477
+ if (t3.isBooleanLiteral(literal2))
2478
+ return literal2.value;
2479
+ if (t3.isNullLiteral(literal2))
2480
+ return null;
2481
+ }
2482
+ const imports = this.getImports(filePath);
2483
+ const importInfo = imports?.get(name);
2484
+ if (importInfo) {
2485
+ const resolved = this.resolveImportPath(filePath, importInfo.source);
2486
+ if (resolved) {
2487
+ const targetName = importInfo.importedName === "default" ? name : importInfo.importedName;
2488
+ const result = this.resolveLiteralInternal(resolved, targetName, visited);
2489
+ if (result !== void 0)
2490
+ return result;
2491
+ }
2492
+ }
2493
+ const reExport = index.namedReExports.get(name);
2494
+ if (reExport) {
2495
+ const resolved = this.resolveImportPath(filePath, reExport.source);
2496
+ if (resolved) {
2497
+ const result = this.resolveLiteralInternal(resolved, reExport.importedName, visited);
2498
+ if (result !== void 0)
2499
+ return result;
2500
+ }
2501
+ }
2502
+ for (const starSrc of index.exportsStar) {
2503
+ const resolved = this.resolveImportPath(filePath, starSrc);
2504
+ if (!resolved)
2505
+ continue;
2506
+ const result = this.resolveLiteralInternal(resolved, name, visited);
2507
+ if (result !== void 0)
2508
+ return result;
2509
+ }
2475
2510
  return void 0;
2476
2511
  }
2477
2512
  /**
@@ -12794,6 +12829,58 @@ var ZodSchemaConverter = class {
12794
12829
  this.symbolResolver.primeAST(this.currentFilePath, this.currentAST);
12795
12830
  return this.symbolResolver.resolveLiteral(this.currentFilePath, name);
12796
12831
  }
12832
+ /**
12833
+ * Unwrap a possible `TSAsExpression` / `TSSatisfiesExpression` to get the
12834
+ * underlying expression node. Returns the node itself when no wrapper is
12835
+ * present.
12836
+ */
12837
+ unwrapTypeAssertion(node) {
12838
+ if (!node)
12839
+ return void 0;
12840
+ if (t10.isTSAsExpression(node) || t10.isTSSatisfiesExpression(node)) {
12841
+ return node.expression;
12842
+ }
12843
+ return node;
12844
+ }
12845
+ /**
12846
+ * Resolve a numeric value from a call-expression argument.
12847
+ * Handles: numeric literals, identifier references to const numbers,
12848
+ * and `x as number` / `x satisfies number` wrappers around either.
12849
+ */
12850
+ resolveNumericArg(arg) {
12851
+ if (!arg)
12852
+ return void 0;
12853
+ const node = this.unwrapTypeAssertion(arg);
12854
+ if (t10.isNumericLiteral(node))
12855
+ return node.value;
12856
+ if (t10.isUnaryExpression(node) && node.operator === "-" && t10.isNumericLiteral(node.argument)) {
12857
+ return -node.argument.value;
12858
+ }
12859
+ if (t10.isIdentifier(node)) {
12860
+ const val = this.resolveLiteralValue(node.name);
12861
+ if (typeof val === "number")
12862
+ return val;
12863
+ }
12864
+ return void 0;
12865
+ }
12866
+ /**
12867
+ * Resolve a string value from a call-expression argument.
12868
+ * Handles: string literals, identifier references to const strings,
12869
+ * and `x as string` / `x satisfies string` wrappers around either.
12870
+ */
12871
+ resolveStringArg(arg) {
12872
+ if (!arg)
12873
+ return void 0;
12874
+ const node = this.unwrapTypeAssertion(arg);
12875
+ if (t10.isStringLiteral(node))
12876
+ return node.value;
12877
+ if (t10.isIdentifier(node)) {
12878
+ const val = this.resolveLiteralValue(node.name);
12879
+ if (typeof val === "string")
12880
+ return val;
12881
+ }
12882
+ return void 0;
12883
+ }
12797
12884
  /**
12798
12885
  * Resolve an identifier referring to a `z.object({...})` (or similar) call expression.
12799
12886
  * This lets callers inline the referenced object's shape.
@@ -12862,6 +12949,14 @@ var ZodSchemaConverter = class {
12862
12949
  if (t10.isNullLiteral(node)) {
12863
12950
  return null;
12864
12951
  }
12952
+ if (t10.isIdentifier(node)) {
12953
+ const val = this.resolveLiteralValue(node.name);
12954
+ if (val !== void 0)
12955
+ return val;
12956
+ }
12957
+ if (t10.isTSAsExpression(node) || t10.isTSSatisfiesExpression(node)) {
12958
+ return this.extractStaticJsonValue(node.expression);
12959
+ }
12865
12960
  if (t10.isArrayExpression(node)) {
12866
12961
  const values = [];
12867
12962
  for (const element of node.elements) {
@@ -12960,53 +13055,60 @@ var ZodSchemaConverter = class {
12960
13055
  schema.nullable = true;
12961
13056
  }
12962
13057
  break;
12963
- case "describe":
12964
- if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
12965
- const description = node.arguments[0].value;
12966
- if (description.startsWith("@deprecated")) {
13058
+ case "describe": {
13059
+ const descVal = this.resolveStringArg(node.arguments[0]);
13060
+ if (descVal !== void 0) {
13061
+ if (descVal.startsWith("@deprecated")) {
12967
13062
  schema.deprecated = true;
12968
- schema.description = description.replace("@deprecated", "").trim();
13063
+ schema.description = descVal.replace("@deprecated", "").trim();
12969
13064
  } else {
12970
- schema.description = description;
13065
+ schema.description = descVal;
12971
13066
  }
12972
13067
  }
12973
13068
  break;
13069
+ }
12974
13070
  case "deprecated":
12975
13071
  schema.deprecated = true;
12976
13072
  break;
12977
- case "min":
12978
- if (node.arguments.length > 0 && t10.isNumericLiteral(node.arguments[0])) {
13073
+ case "min": {
13074
+ const minVal = this.resolveNumericArg(node.arguments[0]);
13075
+ if (minVal !== void 0) {
12979
13076
  if (schema.type === "string") {
12980
- schema.minLength = node.arguments[0].value;
13077
+ schema.minLength = minVal;
12981
13078
  } else if (schema.type === "number" || schema.type === "integer") {
12982
- schema.minimum = node.arguments[0].value;
13079
+ schema.minimum = minVal;
12983
13080
  } else if (schema.type === "array") {
12984
- schema.minItems = node.arguments[0].value;
13081
+ schema.minItems = minVal;
12985
13082
  }
12986
13083
  }
12987
13084
  break;
12988
- case "max":
12989
- if (node.arguments.length > 0 && t10.isNumericLiteral(node.arguments[0])) {
13085
+ }
13086
+ case "max": {
13087
+ const maxVal = this.resolveNumericArg(node.arguments[0]);
13088
+ if (maxVal !== void 0) {
12990
13089
  if (schema.type === "string") {
12991
- schema.maxLength = node.arguments[0].value;
13090
+ schema.maxLength = maxVal;
12992
13091
  } else if (schema.type === "number" || schema.type === "integer") {
12993
- schema.maximum = node.arguments[0].value;
13092
+ schema.maximum = maxVal;
12994
13093
  } else if (schema.type === "array") {
12995
- schema.maxItems = node.arguments[0].value;
13094
+ schema.maxItems = maxVal;
12996
13095
  }
12997
13096
  }
12998
13097
  break;
12999
- case "length":
13000
- if (node.arguments.length > 0 && t10.isNumericLiteral(node.arguments[0])) {
13098
+ }
13099
+ case "length": {
13100
+ const lenVal = this.resolveNumericArg(node.arguments[0]);
13101
+ if (lenVal !== void 0) {
13001
13102
  if (schema.type === "string") {
13002
- schema.minLength = node.arguments[0].value;
13003
- schema.maxLength = node.arguments[0].value;
13103
+ schema.minLength = lenVal;
13104
+ schema.maxLength = lenVal;
13004
13105
  } else if (schema.type === "array") {
13005
- schema.minItems = node.arguments[0].value;
13006
- schema.maxItems = node.arguments[0].value;
13106
+ schema.minItems = lenVal;
13107
+ schema.maxItems = lenVal;
13007
13108
  }
13008
13109
  }
13009
13110
  break;
13111
+ }
13010
13112
  case "nonempty":
13011
13113
  if (schema.type === "array") {
13012
13114
  schema.minItems = Math.max(schema.minItems ?? 0, 1);
@@ -13082,21 +13184,27 @@ var ZodSchemaConverter = class {
13082
13184
  schema.pattern = node.arguments[0].pattern;
13083
13185
  }
13084
13186
  break;
13085
- case "startsWith":
13086
- if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
13087
- schema.pattern = `^${this.escapeRegExp(node.arguments[0].value)}`;
13187
+ case "startsWith": {
13188
+ const swVal = this.resolveStringArg(node.arguments[0]);
13189
+ if (swVal !== void 0) {
13190
+ schema.pattern = `^${this.escapeRegExp(swVal)}`;
13088
13191
  }
13089
13192
  break;
13090
- case "endsWith":
13091
- if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
13092
- schema.pattern = `${this.escapeRegExp(node.arguments[0].value)}$`;
13193
+ }
13194
+ case "endsWith": {
13195
+ const ewVal = this.resolveStringArg(node.arguments[0]);
13196
+ if (ewVal !== void 0) {
13197
+ schema.pattern = `${this.escapeRegExp(ewVal)}$`;
13093
13198
  }
13094
13199
  break;
13095
- case "includes":
13096
- if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
13097
- schema.pattern = this.escapeRegExp(node.arguments[0].value);
13200
+ }
13201
+ case "includes": {
13202
+ const incVal = this.resolveStringArg(node.arguments[0]);
13203
+ if (incVal !== void 0) {
13204
+ schema.pattern = this.escapeRegExp(incVal);
13098
13205
  }
13099
13206
  break;
13207
+ }
13100
13208
  case "int":
13101
13209
  schema.type = "integer";
13102
13210
  break;
@@ -13120,17 +13228,22 @@ var ZodSchemaConverter = class {
13120
13228
  break;
13121
13229
  case "default":
13122
13230
  if (node.arguments.length > 0) {
13123
- if (t10.isStringLiteral(node.arguments[0])) {
13124
- schema.default = node.arguments[0].value;
13125
- } else if (t10.isNumericLiteral(node.arguments[0])) {
13126
- schema.default = node.arguments[0].value;
13127
- } else if (t10.isBooleanLiteral(node.arguments[0])) {
13128
- schema.default = node.arguments[0].value;
13129
- } else if (t10.isNullLiteral(node.arguments[0])) {
13231
+ const defaultArg = this.unwrapTypeAssertion(node.arguments[0]);
13232
+ if (t10.isStringLiteral(defaultArg)) {
13233
+ schema.default = defaultArg.value;
13234
+ } else if (t10.isNumericLiteral(defaultArg)) {
13235
+ schema.default = defaultArg.value;
13236
+ } else if (t10.isBooleanLiteral(defaultArg)) {
13237
+ schema.default = defaultArg.value;
13238
+ } else if (t10.isNullLiteral(defaultArg)) {
13130
13239
  schema.default = null;
13131
- } else if (t10.isObjectExpression(node.arguments[0])) {
13240
+ } else if (t10.isIdentifier(defaultArg)) {
13241
+ const val = this.resolveLiteralValue(defaultArg.name);
13242
+ if (val !== void 0)
13243
+ schema.default = val;
13244
+ } else if (t10.isObjectExpression(defaultArg)) {
13132
13245
  const defaultObj = {};
13133
- node.arguments[0].properties.forEach((prop) => {
13246
+ defaultArg.properties.forEach((prop) => {
13134
13247
  if (t10.isObjectProperty(prop) && (t10.isIdentifier(prop.key) || t10.isStringLiteral(prop.key)) && (t10.isStringLiteral(prop.value) || t10.isNumericLiteral(prop.value) || t10.isBooleanLiteral(prop.value))) {
13135
13248
  const key = t10.isIdentifier(prop.key) ? prop.key.name : prop.key.value;
13136
13249
  const value = t10.isStringLiteral(prop.value) ? prop.value.value : t10.isNumericLiteral(prop.value) ? prop.value.value : t10.isBooleanLiteral(prop.value) ? prop.value.value : null;