@hey-api/openapi-ts 0.90.2 → 0.90.4

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.
@@ -540,66 +540,6 @@ const valueToObject = ({ defaultValue, mappers: mappers$1, value }) => {
540
540
  return result;
541
541
  };
542
542
 
543
- //#endregion
544
- //#region src/config/output/source/config.ts
545
- function resolveSource(config) {
546
- const source$2 = valueToObject({
547
- defaultValue: {
548
- enabled: Boolean(config.source),
549
- extension: "json",
550
- fileName: "source",
551
- serialize: (input) => JSON.stringify(input, null, 2)
552
- },
553
- mappers: { boolean: (enabled) => ({ enabled }) },
554
- value: config.source
555
- });
556
- if (source$2.path === void 0 || source$2.path === true) source$2.path = "";
557
- else if (source$2.path === false) source$2.path = null;
558
- return source$2;
559
- }
560
-
561
- //#endregion
562
- //#region src/config/output/config.ts
563
- function getOutput(userConfig) {
564
- if (userConfig.output instanceof Array) throw new Error("Unexpected array of outputs in user configuration. This should have been expanded already.");
565
- const output = valueToObject({
566
- defaultValue: {
567
- clean: true,
568
- fileName: {
569
- case: "preserve",
570
- name: "{{name}}",
571
- suffix: ".gen"
572
- },
573
- format: null,
574
- header: "// This file is auto-generated by @hey-api/openapi-ts",
575
- indexFile: true,
576
- lint: null,
577
- path: "",
578
- preferExportAll: false
579
- },
580
- mappers: {
581
- object: (fields, defaultValue) => ({
582
- ...fields,
583
- fileName: valueToObject({
584
- defaultValue: { ...defaultValue.fileName },
585
- mappers: {
586
- function: (name) => ({ name }),
587
- string: (name) => ({ name })
588
- },
589
- value: fields.fileName
590
- })
591
- }),
592
- string: (path$10) => ({ path: path$10 })
593
- },
594
- value: userConfig.output
595
- });
596
- output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));
597
- if (output.importFileExtension === void 0 && (output.tsConfig?.options.moduleResolution === typescript.default.ModuleResolutionKind.NodeNext || output.tsConfig?.options.moduleResolution === typescript.default.ModuleResolutionKind.Node16)) output.importFileExtension = ".js";
598
- if (output.importFileExtension && !output.importFileExtension.startsWith(".")) output.importFileExtension = `.${output.importFileExtension}`;
599
- output.source = resolveSource(output);
600
- return output;
601
- }
602
-
603
543
  //#endregion
604
544
  //#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
605
545
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -1012,68 +952,169 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1012
952
  //#endregion
1013
953
  //#region src/config/output/postprocess.ts
1014
954
  var import_cross_spawn = require_cross_spawn();
1015
- /**
1016
- * Map of supported formatters
1017
- */
1018
- const formatters = {
1019
- biome: {
1020
- args: (path$10) => [
955
+ const postProcessors = {
956
+ "biome:format": {
957
+ args: [
1021
958
  "format",
1022
959
  "--write",
1023
- path$10
960
+ "{{path}}"
1024
961
  ],
1025
962
  command: "biome",
1026
963
  name: "Biome (Format)"
1027
964
  },
1028
- prettier: {
1029
- args: (path$10) => [
1030
- "--ignore-unknown",
1031
- path$10,
1032
- "--write",
1033
- "--ignore-path",
1034
- "./.prettierignore"
1035
- ],
1036
- command: "prettier",
1037
- name: "Prettier"
1038
- }
1039
- };
1040
- /**
1041
- * Map of supported linters
1042
- */
1043
- const linters = {
1044
- biome: {
1045
- args: (path$10) => [
965
+ "biome:lint": {
966
+ args: [
1046
967
  "lint",
1047
968
  "--apply",
1048
- path$10
969
+ "{{path}}"
1049
970
  ],
1050
971
  command: "biome",
1051
972
  name: "Biome (Lint)"
1052
973
  },
1053
974
  eslint: {
1054
- args: (path$10) => [path$10, "--fix"],
975
+ args: ["{{path}}", "--fix"],
1055
976
  command: "eslint",
1056
977
  name: "ESLint"
1057
978
  },
979
+ oxfmt: {
980
+ args: ["{{path}}"],
981
+ command: "oxfmt",
982
+ name: "Oxfmt"
983
+ },
1058
984
  oxlint: {
1059
- args: (path$10) => ["--fix", path$10],
985
+ args: ["--fix", "{{path}}"],
1060
986
  command: "oxlint",
1061
- name: "oxlint"
987
+ name: "Oxlint"
988
+ },
989
+ prettier: {
990
+ args: [
991
+ "--ignore-unknown",
992
+ "{{path}}",
993
+ "--write",
994
+ "--ignore-path",
995
+ "./.prettierignore"
996
+ ],
997
+ command: "prettier",
998
+ name: "Prettier"
1062
999
  }
1063
1000
  };
1064
- const postprocessOutput = (config) => {
1065
- if (config.lint) {
1066
- const module$1 = linters[config.lint];
1067
- console.log(`✨ Running ${module$1.name}`);
1068
- (0, import_cross_spawn.sync)(module$1.command, module$1.args(config.path));
1069
- }
1070
- if (config.format) {
1071
- const module$1 = formatters[config.format];
1072
- console.log(`✨ Running ${module$1.name}`);
1073
- (0, import_cross_spawn.sync)(module$1.command, module$1.args(config.path));
1001
+ const postprocessOutput = (config, jobPrefix) => {
1002
+ for (const processor of config.postProcess) {
1003
+ const resolved = typeof processor === "string" ? postProcessors[processor] : processor;
1004
+ const name = resolved.name ?? resolved.command;
1005
+ const args = resolved.args.map((arg) => arg.replace("{{path}}", config.path));
1006
+ console.log(`${jobPrefix}🧹 Running ${ansi_colors.default.cyanBright(name)}`);
1007
+ (0, import_cross_spawn.sync)(resolved.command, args);
1074
1008
  }
1075
1009
  };
1076
1010
 
1011
+ //#endregion
1012
+ //#region src/config/output/source/config.ts
1013
+ function resolveSource(config) {
1014
+ const source$2 = valueToObject({
1015
+ defaultValue: {
1016
+ enabled: Boolean(config.source),
1017
+ extension: "json",
1018
+ fileName: "source",
1019
+ serialize: (input) => JSON.stringify(input, null, 2)
1020
+ },
1021
+ mappers: { boolean: (enabled) => ({ enabled }) },
1022
+ value: config.source
1023
+ });
1024
+ if (source$2.path === void 0 || source$2.path === true) source$2.path = "";
1025
+ else if (source$2.path === false) source$2.path = null;
1026
+ return source$2;
1027
+ }
1028
+
1029
+ //#endregion
1030
+ //#region src/config/output/config.ts
1031
+ function getOutput(userConfig) {
1032
+ if (userConfig.output instanceof Array) throw new Error("Unexpected array of outputs in user configuration. This should have been expanded already.");
1033
+ const userOutput = typeof userConfig.output === "string" ? { path: userConfig.output } : userConfig.output ?? {};
1034
+ const legacyPostProcess = resolveLegacyPostProcess(userOutput);
1035
+ const output = valueToObject({
1036
+ defaultValue: {
1037
+ clean: true,
1038
+ fileName: {
1039
+ case: "preserve",
1040
+ name: "{{name}}",
1041
+ suffix: ".gen"
1042
+ },
1043
+ format: null,
1044
+ header: "// This file is auto-generated by @hey-api/openapi-ts",
1045
+ indexFile: true,
1046
+ lint: null,
1047
+ path: "",
1048
+ postProcess: [],
1049
+ preferExportAll: false
1050
+ },
1051
+ mappers: { object: (fields, defaultValue) => ({
1052
+ ...fields,
1053
+ fileName: valueToObject({
1054
+ defaultValue: { ...defaultValue.fileName },
1055
+ mappers: {
1056
+ function: (name) => ({ name }),
1057
+ string: (name) => ({ name })
1058
+ },
1059
+ value: fields.fileName
1060
+ })
1061
+ }) },
1062
+ value: userOutput
1063
+ });
1064
+ output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));
1065
+ if (output.importFileExtension === void 0 && (output.tsConfig?.options.moduleResolution === typescript.default.ModuleResolutionKind.NodeNext || output.tsConfig?.options.moduleResolution === typescript.default.ModuleResolutionKind.Node16)) output.importFileExtension = ".js";
1066
+ if (output.importFileExtension && !output.importFileExtension.startsWith(".")) output.importFileExtension = `.${output.importFileExtension}`;
1067
+ output.postProcess = normalizePostProcess(userOutput.postProcess ?? legacyPostProcess);
1068
+ output.source = resolveSource(output);
1069
+ return output;
1070
+ }
1071
+ function resolveLegacyPostProcess(config) {
1072
+ const result = [];
1073
+ if (config.lint !== void 0) {
1074
+ let processor;
1075
+ let preset;
1076
+ if (config.lint) {
1077
+ preset = config.lint === "biome" ? "biome:lint" : config.lint;
1078
+ processor = postProcessors[preset];
1079
+ if (processor) result.push(processor);
1080
+ }
1081
+ _hey_api_codegen_core.log.warnDeprecated({
1082
+ context: "output",
1083
+ field: "lint",
1084
+ replacement: `postProcess: [${processor && preset ? `'${preset}'` : ""}]`
1085
+ });
1086
+ }
1087
+ if (config.format !== void 0) {
1088
+ let processor;
1089
+ let preset;
1090
+ if (config.format) {
1091
+ preset = config.format === "biome" ? "biome:format" : config.format;
1092
+ processor = postProcessors[preset];
1093
+ if (processor) result.push(processor);
1094
+ }
1095
+ _hey_api_codegen_core.log.warnDeprecated({
1096
+ context: "output",
1097
+ field: "format",
1098
+ replacement: `postProcess: [${processor && preset ? `'${preset}'` : ""}]`
1099
+ });
1100
+ }
1101
+ return result;
1102
+ }
1103
+ function normalizePostProcess(input) {
1104
+ if (!input) return [];
1105
+ return input.map((item) => {
1106
+ if (typeof item === "string") {
1107
+ const preset = postProcessors[item];
1108
+ if (!preset) throw new Error(`Unknown post-processor preset: "${item}"`);
1109
+ return preset;
1110
+ }
1111
+ return {
1112
+ name: item.name ?? item.command,
1113
+ ...item
1114
+ };
1115
+ });
1116
+ }
1117
+
1077
1118
  //#endregion
1078
1119
  //#region src/config/packages.ts
1079
1120
  /**
@@ -11195,20 +11236,82 @@ const booleanToAst$3 = ({ plugin, schema }) => {
11195
11236
 
11196
11237
  //#endregion
11197
11238
  //#region src/plugins/valibot/v1/toAst/enum.ts
11198
- const enumToAst$3 = ({ plugin, schema, state }) => {
11239
+ function itemsNode$3(ctx$1) {
11240
+ const { schema } = ctx$1;
11199
11241
  const enumMembers = [];
11200
11242
  let isNullable = false;
11201
11243
  for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") enumMembers.push($.literal(item.const));
11202
11244
  else if (item.type === "null" || item.const === null) isNullable = true;
11245
+ return {
11246
+ enumMembers,
11247
+ isNullable
11248
+ };
11249
+ }
11250
+ function baseNode$15(ctx$1) {
11251
+ const { symbols } = ctx$1;
11252
+ const { v } = symbols;
11253
+ const { enumMembers } = ctx$1.nodes.items(ctx$1);
11254
+ return $(v).attr(identifiers$1.schemas.picklist).call($.array(...enumMembers));
11255
+ }
11256
+ function nullableNode$3(ctx$1) {
11257
+ const { symbols } = ctx$1;
11258
+ const { v } = symbols;
11259
+ const { isNullable } = ctx$1.nodes.items(ctx$1);
11260
+ if (!isNullable) return;
11261
+ const currentNode = ctx$1.pipes.toNode(ctx$1.pipes.current, ctx$1.plugin);
11262
+ return $(v).attr(identifiers$1.schemas.nullable).call(currentNode);
11263
+ }
11264
+ function enumResolver$3(ctx$1) {
11265
+ const { enumMembers } = ctx$1.nodes.items(ctx$1);
11266
+ if (!enumMembers.length) return ctx$1.pipes.current;
11267
+ const baseExpression = ctx$1.nodes.base(ctx$1);
11268
+ ctx$1.pipes.push(ctx$1.pipes.current, baseExpression);
11269
+ const nullableExpression = ctx$1.nodes.nullable(ctx$1);
11270
+ if (nullableExpression) return nullableExpression;
11271
+ return ctx$1.pipes.current;
11272
+ }
11273
+ const enumToAst$3 = ({ plugin, schema, state }) => {
11274
+ const v = plugin.external("valibot.v");
11275
+ const { enumMembers } = itemsNode$3({
11276
+ $,
11277
+ nodes: {
11278
+ base: baseNode$15,
11279
+ items: itemsNode$3,
11280
+ nullable: nullableNode$3
11281
+ },
11282
+ pipes: {
11283
+ ...pipes,
11284
+ current: []
11285
+ },
11286
+ plugin,
11287
+ schema,
11288
+ symbols: { v },
11289
+ utils: { state }
11290
+ });
11203
11291
  if (!enumMembers.length) return unknownToAst$3({
11204
11292
  plugin,
11205
11293
  schema: { type: "unknown" },
11206
11294
  state
11207
11295
  });
11208
- const v = plugin.external("valibot.v");
11209
- let resultExpression = $(v).attr(identifiers$1.schemas.picklist).call($.array(...enumMembers));
11210
- if (isNullable) resultExpression = $(v).attr(identifiers$1.schemas.nullable).call(resultExpression);
11211
- return resultExpression;
11296
+ const ctx$1 = {
11297
+ $,
11298
+ nodes: {
11299
+ base: baseNode$15,
11300
+ items: itemsNode$3,
11301
+ nullable: nullableNode$3
11302
+ },
11303
+ pipes: {
11304
+ ...pipes,
11305
+ current: []
11306
+ },
11307
+ plugin,
11308
+ schema,
11309
+ symbols: { v },
11310
+ utils: { state }
11311
+ };
11312
+ const resolver = plugin.config["~resolvers"]?.enum;
11313
+ const node = resolver?.(ctx$1) ?? enumResolver$3(ctx$1);
11314
+ return ctx$1.pipes.toNode(node, plugin);
11212
11315
  };
11213
11316
 
11214
11317
  //#endregion
@@ -11253,7 +11356,7 @@ const getIntegerLimit = (format) => {
11253
11356
 
11254
11357
  //#endregion
11255
11358
  //#region src/plugins/valibot/v1/toAst/number.ts
11256
- function baseNode$11(ctx$1) {
11359
+ function baseNode$14(ctx$1) {
11257
11360
  const { schema, symbols } = ctx$1;
11258
11361
  const { v } = symbols;
11259
11362
  if (ctx$1.utils.shouldCoerceToBigInt(schema.format)) return [$(v).attr(identifiers$1.schemas.union).call($.array($(v).attr(identifiers$1.schemas.number).call(), $(v).attr(identifiers$1.schemas.string).call(), $(v).attr(identifiers$1.schemas.bigInt).call())), $(v).attr(identifiers$1.actions.transform).call($.func().param("x").do($("BigInt").call("x").return()))];
@@ -11287,8 +11390,8 @@ function minNode$3(ctx$1) {
11287
11390
  function numberResolver$3(ctx$1) {
11288
11391
  const constNode$8 = ctx$1.nodes.const(ctx$1);
11289
11392
  if (constNode$8) return ctx$1.pipes.push(ctx$1.pipes.current, constNode$8);
11290
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
11291
- if (baseNode$12) ctx$1.pipes.push(ctx$1.pipes.current, baseNode$12);
11393
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
11394
+ if (baseNode$16) ctx$1.pipes.push(ctx$1.pipes.current, baseNode$16);
11292
11395
  const minNode$4 = ctx$1.nodes.min(ctx$1);
11293
11396
  if (minNode$4) ctx$1.pipes.push(ctx$1.pipes.current, minNode$4);
11294
11397
  const maxNode$4 = ctx$1.nodes.max(ctx$1);
@@ -11299,7 +11402,7 @@ const numberToNode$3 = ({ plugin, schema }) => {
11299
11402
  const ctx$1 = {
11300
11403
  $,
11301
11404
  nodes: {
11302
- base: baseNode$11,
11405
+ base: baseNode$14,
11303
11406
  const: constNode$7,
11304
11407
  max: maxNode$3,
11305
11408
  min: minNode$3
@@ -11339,7 +11442,7 @@ function additionalPropertiesNode$3(ctx$1) {
11339
11442
  if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
11340
11443
  return pipes.toNode(additionalAst.pipes, plugin);
11341
11444
  }
11342
- function baseNode$10(ctx$1) {
11445
+ function baseNode$13(ctx$1) {
11343
11446
  const { nodes, symbols } = ctx$1;
11344
11447
  const { v } = symbols;
11345
11448
  const additional = nodes.additionalProperties(ctx$1);
@@ -11382,7 +11485,7 @@ const objectToAst$3 = ({ plugin, schema, state }) => {
11382
11485
  $,
11383
11486
  nodes: {
11384
11487
  additionalProperties: additionalPropertiesNode$3,
11385
- base: baseNode$10,
11488
+ base: baseNode$13,
11386
11489
  shape: shapeNode$3
11387
11490
  },
11388
11491
  pipes: {
@@ -11405,7 +11508,7 @@ const objectToAst$3 = ({ plugin, schema, state }) => {
11405
11508
 
11406
11509
  //#endregion
11407
11510
  //#region src/plugins/valibot/v1/toAst/string.ts
11408
- function baseNode$9(ctx$1) {
11511
+ function baseNode$12(ctx$1) {
11409
11512
  const { v } = ctx$1.symbols;
11410
11513
  return $(v).attr(identifiers$1.schemas.string).call();
11411
11514
  }
@@ -11456,8 +11559,8 @@ function patternNode$3(ctx$1) {
11456
11559
  function stringResolver$3(ctx$1) {
11457
11560
  const constNode$8 = ctx$1.nodes.const(ctx$1);
11458
11561
  if (constNode$8) return ctx$1.pipes.push(ctx$1.pipes.current, constNode$8);
11459
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
11460
- if (baseNode$12) ctx$1.pipes.push(ctx$1.pipes.current, baseNode$12);
11562
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
11563
+ if (baseNode$16) ctx$1.pipes.push(ctx$1.pipes.current, baseNode$16);
11461
11564
  const formatNode$4 = ctx$1.nodes.format(ctx$1);
11462
11565
  if (formatNode$4) ctx$1.pipes.push(ctx$1.pipes.current, formatNode$4);
11463
11566
  const lengthNode$4 = ctx$1.nodes.length(ctx$1);
@@ -11476,7 +11579,7 @@ const stringToNode$3 = ({ plugin, schema }) => {
11476
11579
  const ctx$1 = {
11477
11580
  $,
11478
11581
  nodes: {
11479
- base: baseNode$9,
11582
+ base: baseNode$12,
11480
11583
  const: constNode$6,
11481
11584
  format: formatNode$3,
11482
11585
  length: lengthNode$3,
@@ -12480,9 +12583,9 @@ const booleanToAst$2 = ({ plugin, schema }) => {
12480
12583
 
12481
12584
  //#endregion
12482
12585
  //#region src/plugins/zod/mini/toAst/enum.ts
12483
- const enumToAst$2 = ({ plugin, schema, state }) => {
12484
- const z = plugin.external("zod.z");
12485
- const result = {};
12586
+ function itemsNode$2(ctx$1) {
12587
+ const { schema, symbols } = ctx$1;
12588
+ const { z } = symbols;
12486
12589
  const enumMembers = [];
12487
12590
  const literalMembers = [];
12488
12591
  let isNullable = false;
@@ -12500,16 +12603,78 @@ const enumToAst$2 = ({ plugin, schema, state }) => {
12500
12603
  const literal = $.literal(item.const);
12501
12604
  literalMembers.push($(z).attr(identifiers.literal).call(literal));
12502
12605
  } else if (item.type === "null" || item.const === null) isNullable = true;
12606
+ return {
12607
+ allStrings,
12608
+ enumMembers,
12609
+ isNullable,
12610
+ literalMembers
12611
+ };
12612
+ }
12613
+ function baseNode$11(ctx$1) {
12614
+ const { symbols } = ctx$1;
12615
+ const { z } = symbols;
12616
+ const { allStrings, enumMembers, literalMembers } = ctx$1.nodes.items(ctx$1);
12617
+ if (allStrings && enumMembers.length > 0) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
12618
+ else if (literalMembers.length === 1) return literalMembers[0];
12619
+ else return $(z).attr(identifiers.union).call($.array(...literalMembers));
12620
+ }
12621
+ function nullableNode$2(ctx$1) {
12622
+ const { chain, symbols } = ctx$1;
12623
+ const { z } = symbols;
12624
+ const { isNullable } = ctx$1.nodes.items(ctx$1);
12625
+ if (!isNullable) return;
12626
+ return $(z).attr(identifiers.nullable).call(chain.current);
12627
+ }
12628
+ function enumResolver$2(ctx$1) {
12629
+ const { literalMembers } = ctx$1.nodes.items(ctx$1);
12630
+ if (!literalMembers.length) return ctx$1.chain.current;
12631
+ const baseExpression = ctx$1.nodes.base(ctx$1);
12632
+ ctx$1.chain.current = baseExpression;
12633
+ const nullableExpression = ctx$1.nodes.nullable(ctx$1);
12634
+ if (nullableExpression) ctx$1.chain.current = nullableExpression;
12635
+ return ctx$1.chain.current;
12636
+ }
12637
+ const enumToAst$2 = ({ plugin, schema, state }) => {
12638
+ const z = plugin.external("zod.z");
12639
+ const { literalMembers } = itemsNode$2({
12640
+ $,
12641
+ chain: { current: $(z) },
12642
+ nodes: {
12643
+ base: baseNode$11,
12644
+ items: itemsNode$2,
12645
+ nullable: nullableNode$2
12646
+ },
12647
+ plugin,
12648
+ schema,
12649
+ symbols: { z },
12650
+ utils: {
12651
+ ast: {},
12652
+ state
12653
+ }
12654
+ });
12503
12655
  if (!literalMembers.length) return unknownToAst$2({
12504
12656
  plugin,
12505
12657
  schema: { type: "unknown" },
12506
12658
  state
12507
12659
  });
12508
- if (allStrings && enumMembers.length > 0) result.expression = $(z).attr(identifiers.enum).call($.array(...enumMembers));
12509
- else if (literalMembers.length === 1) result.expression = literalMembers[0];
12510
- else result.expression = $(z).attr(identifiers.union).call($.array(...literalMembers));
12511
- if (isNullable) result.expression = $(z).attr(identifiers.nullable).call(result.expression);
12512
- return result;
12660
+ const ctx$1 = {
12661
+ $,
12662
+ chain: { current: $(z) },
12663
+ nodes: {
12664
+ base: baseNode$11,
12665
+ items: itemsNode$2,
12666
+ nullable: nullableNode$2
12667
+ },
12668
+ plugin,
12669
+ schema,
12670
+ symbols: { z },
12671
+ utils: {
12672
+ ast: {},
12673
+ state
12674
+ }
12675
+ };
12676
+ const resolver = plugin.config["~resolvers"]?.enum;
12677
+ return { expression: resolver?.(ctx$1) ?? enumResolver$2(ctx$1) };
12513
12678
  };
12514
12679
 
12515
12680
  //#endregion
@@ -12532,7 +12697,7 @@ const nullToAst$2 = ({ plugin }) => {
12532
12697
 
12533
12698
  //#endregion
12534
12699
  //#region src/plugins/zod/mini/toAst/number.ts
12535
- function baseNode$8(ctx$1) {
12700
+ function baseNode$10(ctx$1) {
12536
12701
  const { schema, symbols } = ctx$1;
12537
12702
  const { z } = symbols;
12538
12703
  if (ctx$1.utils.shouldCoerceToBigInt(schema.format)) return $(z).attr(identifiers.coerce).attr(identifiers.bigint).call();
@@ -12568,8 +12733,8 @@ function numberResolver$2(ctx$1) {
12568
12733
  ctx$1.chain.current = constNode$8;
12569
12734
  return ctx$1.chain.current;
12570
12735
  }
12571
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
12572
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
12736
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
12737
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
12573
12738
  const checks = [];
12574
12739
  const minNode$4 = ctx$1.nodes.min(ctx$1);
12575
12740
  if (minNode$4) checks.push(minNode$4);
@@ -12585,7 +12750,7 @@ const numberToNode$2 = ({ plugin, schema, state }) => {
12585
12750
  $,
12586
12751
  chain: { current: $(z) },
12587
12752
  nodes: {
12588
- base: baseNode$8,
12753
+ base: baseNode$10,
12589
12754
  const: constNode$5,
12590
12755
  max: maxNode$2,
12591
12756
  min: minNode$2
@@ -12622,7 +12787,7 @@ function additionalPropertiesNode$2(ctx$1) {
12622
12787
  if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
12623
12788
  return additionalAst.expression;
12624
12789
  }
12625
- function baseNode$7(ctx$1) {
12790
+ function baseNode$9(ctx$1) {
12626
12791
  const { nodes, symbols } = ctx$1;
12627
12792
  const { z } = symbols;
12628
12793
  const additional = nodes.additionalProperties(ctx$1);
@@ -12666,7 +12831,7 @@ const objectToAst$2 = ({ plugin, schema, state }) => {
12666
12831
  chain: { current: $(z) },
12667
12832
  nodes: {
12668
12833
  additionalProperties: additionalPropertiesNode$2,
12669
- base: baseNode$7,
12834
+ base: baseNode$9,
12670
12835
  shape: shapeNode$2
12671
12836
  },
12672
12837
  plugin,
@@ -12684,7 +12849,7 @@ const objectToAst$2 = ({ plugin, schema, state }) => {
12684
12849
 
12685
12850
  //#endregion
12686
12851
  //#region src/plugins/zod/mini/toAst/string.ts
12687
- function baseNode$6(ctx$1) {
12852
+ function baseNode$8(ctx$1) {
12688
12853
  const { z } = ctx$1.symbols;
12689
12854
  return $(z).attr(identifiers.string).call();
12690
12855
  }
@@ -12741,8 +12906,8 @@ function stringResolver$2(ctx$1) {
12741
12906
  ctx$1.chain.current = constNode$8;
12742
12907
  return ctx$1.chain.current;
12743
12908
  }
12744
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
12745
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
12909
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
12910
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
12746
12911
  const formatNode$4 = ctx$1.nodes.format(ctx$1);
12747
12912
  if (formatNode$4) ctx$1.chain.current = formatNode$4;
12748
12913
  const checks = [];
@@ -12765,7 +12930,7 @@ const stringToNode$2 = ({ plugin, schema }) => {
12765
12930
  $,
12766
12931
  chain: { current: $(z) },
12767
12932
  nodes: {
12768
- base: baseNode$6,
12933
+ base: baseNode$8,
12769
12934
  const: constNode$4,
12770
12935
  format: formatNode$2,
12771
12936
  length: lengthNode$2,
@@ -13150,8 +13315,9 @@ const booleanToAst$1 = ({ plugin, schema }) => {
13150
13315
 
13151
13316
  //#endregion
13152
13317
  //#region src/plugins/zod/v3/toAst/enum.ts
13153
- const enumToAst$1 = ({ plugin, schema, state }) => {
13154
- const z = plugin.external("zod.z");
13318
+ function itemsNode$1(ctx$1) {
13319
+ const { schema, symbols } = ctx$1;
13320
+ const { z } = symbols;
13155
13321
  const enumMembers = [];
13156
13322
  const literalMembers = [];
13157
13323
  let isNullable = false;
@@ -13169,17 +13335,77 @@ const enumToAst$1 = ({ plugin, schema, state }) => {
13169
13335
  const literal = $.literal(item.const);
13170
13336
  literalMembers.push($(z).attr(identifiers.literal).call(literal));
13171
13337
  } else if (item.type === "null" || item.const === null) isNullable = true;
13338
+ return {
13339
+ allStrings,
13340
+ enumMembers,
13341
+ isNullable,
13342
+ literalMembers
13343
+ };
13344
+ }
13345
+ function baseNode$7(ctx$1) {
13346
+ const { symbols } = ctx$1;
13347
+ const { z } = symbols;
13348
+ const { allStrings, enumMembers, literalMembers } = ctx$1.nodes.items(ctx$1);
13349
+ if (allStrings && enumMembers.length > 0) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
13350
+ else if (literalMembers.length === 1) return literalMembers[0];
13351
+ else return $(z).attr(identifiers.union).call($.array(...literalMembers));
13352
+ }
13353
+ function nullableNode$1(ctx$1) {
13354
+ const { chain } = ctx$1;
13355
+ const { isNullable } = ctx$1.nodes.items(ctx$1);
13356
+ if (!isNullable) return;
13357
+ return chain.current.attr(identifiers.nullable).call();
13358
+ }
13359
+ function enumResolver$1(ctx$1) {
13360
+ const { literalMembers } = ctx$1.nodes.items(ctx$1);
13361
+ if (!literalMembers.length) return ctx$1.chain.current;
13362
+ const baseExpression = ctx$1.nodes.base(ctx$1);
13363
+ ctx$1.chain.current = baseExpression;
13364
+ const nullableExpression = ctx$1.nodes.nullable(ctx$1);
13365
+ if (nullableExpression) ctx$1.chain.current = nullableExpression;
13366
+ return ctx$1.chain.current;
13367
+ }
13368
+ const enumToAst$1 = ({ plugin, schema, state }) => {
13369
+ const z = plugin.external("zod.z");
13370
+ const { literalMembers } = itemsNode$1({
13371
+ $,
13372
+ chain: { current: $(z) },
13373
+ nodes: {
13374
+ base: baseNode$7,
13375
+ items: itemsNode$1,
13376
+ nullable: nullableNode$1
13377
+ },
13378
+ plugin,
13379
+ schema,
13380
+ symbols: { z },
13381
+ utils: {
13382
+ ast: {},
13383
+ state
13384
+ }
13385
+ });
13172
13386
  if (!literalMembers.length) return unknownToAst$1({
13173
13387
  plugin,
13174
13388
  schema: { type: "unknown" },
13175
13389
  state
13176
13390
  });
13177
- let enumExpression;
13178
- if (allStrings && enumMembers.length > 0) enumExpression = $(z).attr(identifiers.enum).call($.array(...enumMembers));
13179
- else if (literalMembers.length === 1) enumExpression = literalMembers[0];
13180
- else enumExpression = $(z).attr(identifiers.union).call($.array(...literalMembers));
13181
- if (isNullable) enumExpression = enumExpression.attr(identifiers.nullable).call();
13182
- return enumExpression;
13391
+ const ctx$1 = {
13392
+ $,
13393
+ chain: { current: $(z) },
13394
+ nodes: {
13395
+ base: baseNode$7,
13396
+ items: itemsNode$1,
13397
+ nullable: nullableNode$1
13398
+ },
13399
+ plugin,
13400
+ schema,
13401
+ symbols: { z },
13402
+ utils: {
13403
+ ast: {},
13404
+ state
13405
+ }
13406
+ };
13407
+ const resolver = plugin.config["~resolvers"]?.enum;
13408
+ return resolver?.(ctx$1) ?? enumResolver$1(ctx$1);
13183
13409
  };
13184
13410
 
13185
13411
  //#endregion
@@ -13196,7 +13422,7 @@ const nullToAst$1 = ({ plugin }) => {
13196
13422
 
13197
13423
  //#endregion
13198
13424
  //#region src/plugins/zod/v3/toAst/number.ts
13199
- function baseNode$5(ctx$1) {
13425
+ function baseNode$6(ctx$1) {
13200
13426
  const { schema, symbols } = ctx$1;
13201
13427
  const { z } = symbols;
13202
13428
  if (ctx$1.utils.shouldCoerceToBigInt(schema.format)) return $(z).attr(identifiers.coerce).attr(identifiers.bigint).call();
@@ -13230,8 +13456,8 @@ function numberResolver$1(ctx$1) {
13230
13456
  ctx$1.chain.current = constNode$8;
13231
13457
  return ctx$1.chain.current;
13232
13458
  }
13233
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
13234
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
13459
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
13460
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
13235
13461
  const minNode$4 = ctx$1.nodes.min(ctx$1);
13236
13462
  if (minNode$4) ctx$1.chain.current = minNode$4;
13237
13463
  const maxNode$4 = ctx$1.nodes.max(ctx$1);
@@ -13245,7 +13471,7 @@ const numberToNode$1 = ({ plugin, schema, state }) => {
13245
13471
  $,
13246
13472
  chain: { current: $(z) },
13247
13473
  nodes: {
13248
- base: baseNode$5,
13474
+ base: baseNode$6,
13249
13475
  const: constNode$3,
13250
13476
  max: maxNode$1,
13251
13477
  min: minNode$1
@@ -13281,7 +13507,7 @@ function additionalPropertiesNode$1(ctx$1) {
13281
13507
  if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
13282
13508
  return additionalAst.expression;
13283
13509
  }
13284
- function baseNode$4(ctx$1) {
13510
+ function baseNode$5(ctx$1) {
13285
13511
  const { nodes, symbols } = ctx$1;
13286
13512
  const { z } = symbols;
13287
13513
  const additional = nodes.additionalProperties(ctx$1);
@@ -13323,7 +13549,7 @@ const objectToAst$1 = ({ plugin, schema, state }) => {
13323
13549
  chain: { current: $(z) },
13324
13550
  nodes: {
13325
13551
  additionalProperties: additionalPropertiesNode$1,
13326
- base: baseNode$4,
13552
+ base: baseNode$5,
13327
13553
  shape: shapeNode$1
13328
13554
  },
13329
13555
  plugin,
@@ -13344,7 +13570,7 @@ const objectToAst$1 = ({ plugin, schema, state }) => {
13344
13570
 
13345
13571
  //#endregion
13346
13572
  //#region src/plugins/zod/v3/toAst/string.ts
13347
- function baseNode$3(ctx$1) {
13573
+ function baseNode$4(ctx$1) {
13348
13574
  const { z } = ctx$1.symbols;
13349
13575
  return $(z).attr(identifiers.string).call();
13350
13576
  }
@@ -13396,8 +13622,8 @@ function stringResolver$1(ctx$1) {
13396
13622
  ctx$1.chain.current = constNode$8;
13397
13623
  return ctx$1.chain.current;
13398
13624
  }
13399
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
13400
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
13625
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
13626
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
13401
13627
  const formatNode$4 = ctx$1.nodes.format(ctx$1);
13402
13628
  if (formatNode$4) ctx$1.chain.current = formatNode$4;
13403
13629
  const lengthNode$4 = ctx$1.nodes.length(ctx$1);
@@ -13418,7 +13644,7 @@ const stringToNode$1 = ({ plugin, schema }) => {
13418
13644
  $,
13419
13645
  chain: { current: $(z) },
13420
13646
  nodes: {
13421
- base: baseNode$3,
13647
+ base: baseNode$4,
13422
13648
  const: constNode$2,
13423
13649
  format: formatNode$1,
13424
13650
  length: lengthNode$1,
@@ -13804,9 +14030,9 @@ const booleanToAst = ({ plugin, schema }) => {
13804
14030
 
13805
14031
  //#endregion
13806
14032
  //#region src/plugins/zod/v4/toAst/enum.ts
13807
- const enumToAst = ({ plugin, schema, state }) => {
13808
- const result = {};
13809
- const z = plugin.external("zod.z");
14033
+ function itemsNode(ctx$1) {
14034
+ const { schema, symbols } = ctx$1;
14035
+ const { z } = symbols;
13810
14036
  const enumMembers = [];
13811
14037
  const literalMembers = [];
13812
14038
  let isNullable = false;
@@ -13824,16 +14050,78 @@ const enumToAst = ({ plugin, schema, state }) => {
13824
14050
  const literal = $.literal(item.const);
13825
14051
  literalMembers.push($(z).attr(identifiers.literal).call(literal));
13826
14052
  } else if (item.type === "null" || item.const === null) isNullable = true;
14053
+ return {
14054
+ allStrings,
14055
+ enumMembers,
14056
+ isNullable,
14057
+ literalMembers
14058
+ };
14059
+ }
14060
+ function baseNode$3(ctx$1) {
14061
+ const { symbols } = ctx$1;
14062
+ const { z } = symbols;
14063
+ const { allStrings, enumMembers, literalMembers } = ctx$1.nodes.items(ctx$1);
14064
+ if (allStrings && enumMembers.length > 0) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
14065
+ else if (literalMembers.length === 1) return literalMembers[0];
14066
+ else return $(z).attr(identifiers.union).call($.array(...literalMembers));
14067
+ }
14068
+ function nullableNode(ctx$1) {
14069
+ const { chain, symbols } = ctx$1;
14070
+ const { z } = symbols;
14071
+ const { isNullable } = ctx$1.nodes.items(ctx$1);
14072
+ if (!isNullable) return;
14073
+ return $(z).attr(identifiers.nullable).call(chain.current);
14074
+ }
14075
+ function enumResolver(ctx$1) {
14076
+ const { literalMembers } = ctx$1.nodes.items(ctx$1);
14077
+ if (!literalMembers.length) return ctx$1.chain.current;
14078
+ const baseExpression = ctx$1.nodes.base(ctx$1);
14079
+ ctx$1.chain.current = baseExpression;
14080
+ const nullableExpression = ctx$1.nodes.nullable(ctx$1);
14081
+ if (nullableExpression) ctx$1.chain.current = nullableExpression;
14082
+ return ctx$1.chain.current;
14083
+ }
14084
+ const enumToAst = ({ plugin, schema, state }) => {
14085
+ const z = plugin.external("zod.z");
14086
+ const { literalMembers } = itemsNode({
14087
+ $,
14088
+ chain: { current: $(z) },
14089
+ nodes: {
14090
+ base: baseNode$3,
14091
+ items: itemsNode,
14092
+ nullable: nullableNode
14093
+ },
14094
+ plugin,
14095
+ schema,
14096
+ symbols: { z },
14097
+ utils: {
14098
+ ast: {},
14099
+ state
14100
+ }
14101
+ });
13827
14102
  if (!literalMembers.length) return unknownToAst({
13828
14103
  plugin,
13829
14104
  schema: { type: "unknown" },
13830
14105
  state
13831
14106
  });
13832
- if (allStrings && enumMembers.length > 0) result.expression = $(z).attr(identifiers.enum).call($.array(...enumMembers));
13833
- else if (literalMembers.length === 1) result.expression = literalMembers[0];
13834
- else result.expression = $(z).attr(identifiers.union).call($.array(...literalMembers));
13835
- if (isNullable) result.expression = $(z).attr(identifiers.nullable).call(result.expression);
13836
- return result;
14107
+ const ctx$1 = {
14108
+ $,
14109
+ chain: { current: $(z) },
14110
+ nodes: {
14111
+ base: baseNode$3,
14112
+ items: itemsNode,
14113
+ nullable: nullableNode
14114
+ },
14115
+ plugin,
14116
+ schema,
14117
+ symbols: { z },
14118
+ utils: {
14119
+ ast: {},
14120
+ state
14121
+ }
14122
+ };
14123
+ const resolver = plugin.config["~resolvers"]?.enum;
14124
+ return { expression: resolver?.(ctx$1) ?? enumResolver(ctx$1) };
13837
14125
  };
13838
14126
 
13839
14127
  //#endregion
@@ -13888,8 +14176,8 @@ function numberResolver(ctx$1) {
13888
14176
  ctx$1.chain.current = constNode$8;
13889
14177
  return ctx$1.chain.current;
13890
14178
  }
13891
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
13892
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
14179
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
14180
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
13893
14181
  const minNode$4 = ctx$1.nodes.min(ctx$1);
13894
14182
  if (minNode$4) ctx$1.chain.current = minNode$4;
13895
14183
  const maxNode$4 = ctx$1.nodes.max(ctx$1);
@@ -14055,8 +14343,8 @@ function stringResolver(ctx$1) {
14055
14343
  ctx$1.chain.current = constNode$8;
14056
14344
  return ctx$1.chain.current;
14057
14345
  }
14058
- const baseNode$12 = ctx$1.nodes.base(ctx$1);
14059
- if (baseNode$12) ctx$1.chain.current = baseNode$12;
14346
+ const baseNode$16 = ctx$1.nodes.base(ctx$1);
14347
+ if (baseNode$16) ctx$1.chain.current = baseNode$16;
14060
14348
  const formatNode$4 = ctx$1.nodes.format(ctx$1);
14061
14349
  if (formatNode$4) ctx$1.chain.current = formatNode$4;
14062
14350
  const lengthNode$4 = ctx$1.nodes.length(ctx$1);
@@ -21675,4 +21963,4 @@ Object.defineProperty(exports, 'toCase', {
21675
21963
  return toCase;
21676
21964
  }
21677
21965
  });
21678
- //# sourceMappingURL=openApi-BwUPqtP_.cjs.map
21966
+ //# sourceMappingURL=openApi-3_A4QzK7.cjs.map