@hey-api/openapi-ts 0.90.8 → 0.90.10

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.
@@ -459,6 +459,76 @@ const getInput = (userConfig) => {
459
459
  return inputs;
460
460
  };
461
461
 
462
+ //#endregion
463
+ //#region src/config/expand.ts
464
+ function expandToJobs(configs) {
465
+ const jobs = [];
466
+ let jobIndex = 0;
467
+ for (const config of configs) {
468
+ const inputs = getInput(config);
469
+ const outputs = config.output instanceof Array ? config.output : [config.output];
470
+ if (outputs.length === 1) jobs.push({
471
+ config: {
472
+ ...config,
473
+ input: inputs,
474
+ output: outputs[0]
475
+ },
476
+ index: jobIndex++
477
+ });
478
+ else if (outputs.length > 1 && inputs.length !== outputs.length) {
479
+ console.warn(`⚙️ ${ansi_colors.default.yellow("Warning:")} You provided ${ansi_colors.default.cyan(String(inputs.length))} ${ansi_colors.default.cyan(inputs.length === 1 ? "input" : "inputs")} and ${ansi_colors.default.yellow(String(outputs.length))} ${ansi_colors.default.yellow("outputs")}. This will produce identical output in multiple locations. You likely want to provide a single output or the same number of outputs as inputs.`);
480
+ for (const output of outputs) jobs.push({
481
+ config: {
482
+ ...config,
483
+ input: inputs,
484
+ output
485
+ },
486
+ index: jobIndex++
487
+ });
488
+ } else if (outputs.length > 1) outputs.forEach((output, index) => {
489
+ jobs.push({
490
+ config: {
491
+ ...config,
492
+ input: inputs[index],
493
+ output
494
+ },
495
+ index: jobIndex++
496
+ });
497
+ });
498
+ }
499
+ return jobs;
500
+ }
501
+
502
+ //#endregion
503
+ //#region src/config/packages.ts
504
+ /**
505
+ * Finds and reads the project's package.json file by searching upwards from the config file location,
506
+ * or from process.cwd() if no config file is provided.
507
+ * This ensures we get the correct dependencies even in monorepo setups.
508
+ *
509
+ * @param configFilePath - The path to the configuration file (e.g., openapi-ts.config.ts)
510
+ * @returns An object containing all project dependencies (dependencies, devDependencies, peerDependencies, optionalDependencies)
511
+ */
512
+ const getProjectDependencies = (configFilePath) => {
513
+ let currentDir = configFilePath ? node_path.default.dirname(configFilePath) : process.cwd();
514
+ while (currentDir !== node_path.default.dirname(currentDir)) {
515
+ const packageJsonPath = node_path.default.join(currentDir, "package.json");
516
+ if (node_fs.default.existsSync(packageJsonPath)) try {
517
+ const packageJson = JSON.parse(node_fs.default.readFileSync(packageJsonPath, "utf8"));
518
+ return {
519
+ ...packageJson.dependencies,
520
+ ...packageJson.devDependencies,
521
+ ...packageJson.peerDependencies,
522
+ ...packageJson.optionalDependencies
523
+ };
524
+ } catch {}
525
+ const parentDir = node_path.default.dirname(currentDir);
526
+ if (parentDir === currentDir) break;
527
+ currentDir = parentDir;
528
+ }
529
+ return {};
530
+ };
531
+
462
532
  //#endregion
463
533
  //#region src/config/logs.ts
464
534
  const getLogs = (userConfig) => {
@@ -475,27 +545,6 @@ const getLogs = (userConfig) => {
475
545
  return logs;
476
546
  };
477
547
 
478
- //#endregion
479
- //#region src/config/merge.ts
480
- const mergeObjects = (objA, objB) => {
481
- const a = objA || {};
482
- const b = objB || {};
483
- return {
484
- ...a,
485
- ...b
486
- };
487
- };
488
- const mergeConfigs = (configA, configB) => {
489
- const a = configA || {};
490
- const b = configB || {};
491
- const merged = {
492
- ...a,
493
- ...b
494
- };
495
- if (typeof merged.logs === "object") merged.logs = mergeObjects(a.logs, b.logs);
496
- return merged;
497
- };
498
-
499
548
  //#endregion
500
549
  //#region src/config/utils/config.ts
501
550
  const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && typeof value !== "function";
@@ -545,7 +594,7 @@ const valueToObject = ({ defaultValue, mappers: mappers$1, value }) => {
545
594
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
546
595
  module.exports = isexe;
547
596
  isexe.sync = sync;
548
- var fs$4 = require("fs");
597
+ var fs$3 = require("fs");
549
598
  function checkPathExt(path$10, options) {
550
599
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
551
600
  if (!pathext) return true;
@@ -562,12 +611,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
562
611
  return checkPathExt(path$10, options);
563
612
  }
564
613
  function isexe(path$10, options, cb) {
565
- fs$4.stat(path$10, function(er, stat) {
614
+ fs$3.stat(path$10, function(er, stat) {
566
615
  cb(er, er ? false : checkStat(stat, path$10, options));
567
616
  });
568
617
  }
569
618
  function sync(path$10, options) {
570
- return checkStat(fs$4.statSync(path$10), path$10, options);
619
+ return checkStat(fs$3.statSync(path$10), path$10, options);
571
620
  }
572
621
  }));
573
622
 
@@ -576,14 +625,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
576
625
  var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
577
626
  module.exports = isexe;
578
627
  isexe.sync = sync;
579
- var fs$3 = require("fs");
628
+ var fs$2 = require("fs");
580
629
  function isexe(path$10, options, cb) {
581
- fs$3.stat(path$10, function(er, stat) {
630
+ fs$2.stat(path$10, function(er, stat) {
582
631
  cb(er, er ? false : checkStat(stat, options));
583
632
  });
584
633
  }
585
634
  function sync(path$10, options) {
586
- return checkStat(fs$3.statSync(path$10), options);
635
+ return checkStat(fs$2.statSync(path$10), options);
587
636
  }
588
637
  function checkStat(stat, options) {
589
638
  return stat.isFile() && checkMode(stat, options);
@@ -649,7 +698,7 @@ var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
649
698
  //#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
650
699
  var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
651
700
  const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
652
- const path$7 = require("path");
701
+ const path$6 = require("path");
653
702
  const COLON = isWindows ? ";" : ":";
654
703
  const isexe = require_isexe();
655
704
  const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -679,7 +728,7 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
679
728
  if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
680
729
  const ppRaw = pathEnv[i];
681
730
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
682
- const pCmd = path$7.join(pathPart, cmd);
731
+ const pCmd = path$6.join(pathPart, cmd);
683
732
  resolve(subStep(!pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd, i, 0));
684
733
  });
685
734
  const subStep = (p, i, ii) => new Promise((resolve, reject) => {
@@ -700,7 +749,7 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
700
749
  for (let i = 0; i < pathEnv.length; i++) {
701
750
  const ppRaw = pathEnv[i];
702
751
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
703
- const pCmd = path$7.join(pathPart, cmd);
752
+ const pCmd = path$6.join(pathPart, cmd);
704
753
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
705
754
  for (let j = 0; j < pathExt.length; j++) {
706
755
  const cur = p + pathExt[j];
@@ -733,7 +782,7 @@ var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
733
782
  //#endregion
734
783
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
735
784
  var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
736
- const path$6 = require("path");
785
+ const path$5 = require("path");
737
786
  const which = require_which();
738
787
  const getPathKey = require_path_key();
739
788
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -748,12 +797,12 @@ var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) =>
748
797
  try {
749
798
  resolved = which.sync(parsed.command, {
750
799
  path: env[getPathKey({ env })],
751
- pathExt: withoutPathExt ? path$6.delimiter : void 0
800
+ pathExt: withoutPathExt ? path$5.delimiter : void 0
752
801
  });
753
802
  } catch (e) {} finally {
754
803
  if (shouldSwitchCwd) process.chdir(cwd);
755
804
  }
756
- if (resolved) resolved = path$6.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
805
+ if (resolved) resolved = path$5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
757
806
  return resolved;
758
807
  }
759
808
  function resolveCommand(parsed) {
@@ -806,16 +855,16 @@ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) =
806
855
  //#endregion
807
856
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
808
857
  var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
809
- const fs$2 = require("fs");
858
+ const fs$1 = require("fs");
810
859
  const shebangCommand = require_shebang_command();
811
860
  function readShebang(command) {
812
861
  const size = 150;
813
862
  const buffer = Buffer.alloc(size);
814
863
  let fd;
815
864
  try {
816
- fd = fs$2.openSync(command, "r");
817
- fs$2.readSync(fd, buffer, 0, size, 0);
818
- fs$2.closeSync(fd);
865
+ fd = fs$1.openSync(command, "r");
866
+ fs$1.readSync(fd, buffer, 0, size, 0);
867
+ fs$1.closeSync(fd);
819
868
  } catch (e) {}
820
869
  return shebangCommand(buffer.toString());
821
870
  }
@@ -825,7 +874,7 @@ var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
825
874
  //#endregion
826
875
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
827
876
  var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
828
- const path$5 = require("path");
877
+ const path$4 = require("path");
829
878
  const resolveCommand = require_resolveCommand();
830
879
  const escape = require_escape();
831
880
  const readShebang = require_readShebang();
@@ -848,7 +897,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
848
897
  const needsShell = !isExecutableRegExp.test(commandFile);
849
898
  if (parsed.options.forceShell || needsShell) {
850
899
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
851
- parsed.command = path$5.normalize(parsed.command);
900
+ parsed.command = path$4.normalize(parsed.command);
852
901
  parsed.command = escape.command(parsed.command);
853
902
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
854
903
  parsed.args = [
@@ -1115,36 +1164,6 @@ function normalizePostProcess(input) {
1115
1164
  });
1116
1165
  }
1117
1166
 
1118
- //#endregion
1119
- //#region src/config/packages.ts
1120
- /**
1121
- * Finds and reads the project's package.json file by searching upwards from the config file location,
1122
- * or from process.cwd() if no config file is provided.
1123
- * This ensures we get the correct dependencies even in monorepo setups.
1124
- *
1125
- * @param configFilePath - The path to the configuration file (e.g., openapi-ts.config.ts)
1126
- * @returns An object containing all project dependencies (dependencies, devDependencies, peerDependencies, optionalDependencies)
1127
- */
1128
- const getProjectDependencies = (configFilePath) => {
1129
- let currentDir = configFilePath ? node_path.default.dirname(configFilePath) : process.cwd();
1130
- while (currentDir !== node_path.default.dirname(currentDir)) {
1131
- const packageJsonPath = node_path.default.join(currentDir, "package.json");
1132
- if (node_fs.default.existsSync(packageJsonPath)) try {
1133
- const packageJson = JSON.parse(node_fs.default.readFileSync(packageJsonPath, "utf8"));
1134
- return {
1135
- ...packageJson.dependencies,
1136
- ...packageJson.devDependencies,
1137
- ...packageJson.peerDependencies,
1138
- ...packageJson.optionalDependencies
1139
- };
1140
- } catch {}
1141
- const parentDir = node_path.default.dirname(currentDir);
1142
- if (parentDir === currentDir) break;
1143
- currentDir = parentDir;
1144
- }
1145
- return {};
1146
- };
1147
-
1148
1167
  //#endregion
1149
1168
  //#region src/config/parser.ts
1150
1169
  const defaultPaginationKeywords = [
@@ -3957,16 +3976,21 @@ const Mixed$25 = DocMixin(TsDsl);
3957
3976
  var ObjectPropTsDsl = class extends Mixed$25 {
3958
3977
  "~dsl" = "ObjectPropTsDsl";
3959
3978
  _value;
3960
- meta;
3979
+ _meta;
3961
3980
  constructor(meta) {
3962
3981
  super();
3963
- this.meta = meta;
3982
+ this._meta = meta;
3983
+ }
3984
+ get kind() {
3985
+ return this._meta.kind;
3986
+ }
3987
+ get propName() {
3988
+ return this._meta.name;
3964
3989
  }
3965
3990
  analyze(ctx$1) {
3966
3991
  super.analyze(ctx$1);
3967
3992
  ctx$1.analyze(this._value);
3968
3993
  }
3969
- /** Returns true when all required builder calls are present. */
3970
3994
  get isValid() {
3971
3995
  return this.missingRequiredCalls().length === 0;
3972
3996
  }
@@ -3978,33 +4002,33 @@ var ObjectPropTsDsl = class extends Mixed$25 {
3978
4002
  toAst() {
3979
4003
  this.$validate();
3980
4004
  const node = this.$node(this._value);
3981
- if (this.meta.kind === "spread") {
4005
+ if (this._meta.kind === "spread") {
3982
4006
  if (typescript.default.isStatement(node)) throw new Error("Invalid spread: object spread must be an expression, not a statement.");
3983
4007
  const result$1 = typescript.default.factory.createSpreadAssignment(node);
3984
4008
  return this.$docs(result$1);
3985
4009
  }
3986
- if (this.meta.kind === "getter") {
3987
- const getter = new GetterTsDsl(this.meta.name).do(node);
4010
+ if (this._meta.kind === "getter") {
4011
+ const getter = new GetterTsDsl(this._meta.name).do(node);
3988
4012
  const result$1 = this.$node(getter);
3989
4013
  return this.$docs(result$1);
3990
4014
  }
3991
- if (this.meta.kind === "setter") {
3992
- const setter = new SetterTsDsl(this.meta.name).do(node);
4015
+ if (this._meta.kind === "setter") {
4016
+ const setter = new SetterTsDsl(this._meta.name).do(node);
3993
4017
  const result$1 = this.$node(setter);
3994
4018
  return this.$docs(result$1);
3995
4019
  }
3996
- if (typescript.default.isIdentifier(node) && node.text === this.meta.name) {
3997
- const result$1 = typescript.default.factory.createShorthandPropertyAssignment(this.meta.name);
4020
+ if (typescript.default.isIdentifier(node) && node.text === this._meta.name) {
4021
+ const result$1 = typescript.default.factory.createShorthandPropertyAssignment(this._meta.name);
3998
4022
  return this.$docs(result$1);
3999
4023
  }
4000
4024
  if (typescript.default.isStatement(node)) throw new Error("Invalid property: object property value must be an expression, not a statement.");
4001
- const result = typescript.default.factory.createPropertyAssignment(this.meta.kind === "computed" ? typescript.default.factory.createComputedPropertyName(this.$node(new IdTsDsl(this.meta.name))) : this.$node(safePropName(this.meta.name)), node);
4025
+ const result = typescript.default.factory.createPropertyAssignment(this._meta.kind === "computed" ? typescript.default.factory.createComputedPropertyName(this.$node(new IdTsDsl(this._meta.name))) : this.$node(safePropName(this._meta.name)), node);
4002
4026
  return this.$docs(result);
4003
4027
  }
4004
4028
  $validate() {
4005
4029
  const missing = this.missingRequiredCalls();
4006
4030
  if (missing.length === 0) return;
4007
- throw new Error(`Object property${this.meta.name ? ` "${this.meta.name}"` : ""} missing ${missing.join(" and ")}`);
4031
+ throw new Error(`Object property${this._meta.name ? ` "${this._meta.name}"` : ""} missing ${missing.join(" and ")}`);
4008
4032
  }
4009
4033
  missingRequiredCalls() {
4010
4034
  const missing = [];
@@ -4018,26 +4042,34 @@ var ObjectPropTsDsl = class extends Mixed$25 {
4018
4042
  const Mixed$24 = AsMixin(ExprMixin(HintMixin(LayoutMixin(TsDsl))));
4019
4043
  var ObjectTsDsl = class extends Mixed$24 {
4020
4044
  "~dsl" = "ObjectTsDsl";
4021
- _props = [];
4045
+ _props = /* @__PURE__ */ new Map();
4046
+ _spreadCounter = 0;
4022
4047
  constructor(...props) {
4023
4048
  super();
4024
4049
  this.props(...props);
4025
4050
  }
4026
4051
  analyze(ctx$1) {
4027
4052
  super.analyze(ctx$1);
4028
- for (const prop of this._props) ctx$1.analyze(prop);
4053
+ for (const prop of this._props.values()) ctx$1.analyze(prop);
4054
+ }
4055
+ /** Returns composite key for the property. */
4056
+ _propKey(prop) {
4057
+ if (prop.kind === "spread") return `spread:${this._spreadCounter++}`;
4058
+ return `${prop.kind}:${prop.propName}`;
4029
4059
  }
4030
- /** Adds a computed property (e.g. `{ [expr]: value }`). */
4060
+ /** Adds a computed property (e.g. `{ [expr]: value }`), or removes if null. */
4031
4061
  computed(name, expr) {
4032
- this._props.push(new ObjectPropTsDsl({
4062
+ if (expr === null) this._props.delete(`computed:${name}`);
4063
+ else this._props.set(`computed:${name}`, new ObjectPropTsDsl({
4033
4064
  kind: "computed",
4034
4065
  name
4035
4066
  }).value(expr));
4036
4067
  return this;
4037
4068
  }
4038
- /** Adds a getter property (e.g. `{ get foo() { ... } }`). */
4069
+ /** Adds a getter property (e.g. `{ get foo() { ... } }`), or removes if null. */
4039
4070
  getter(name, stmt) {
4040
- this._props.push(new ObjectPropTsDsl({
4071
+ if (stmt === null) this._props.delete(`getter:${name}`);
4072
+ else this._props.set(`getter:${name}`, new ObjectPropTsDsl({
4041
4073
  kind: "getter",
4042
4074
  name
4043
4075
  }).value(stmt));
@@ -4045,15 +4077,16 @@ var ObjectTsDsl = class extends Mixed$24 {
4045
4077
  }
4046
4078
  /** Returns true if object has at least one property or spread. */
4047
4079
  hasProps() {
4048
- return this._props.length > 0;
4080
+ return this._props.size > 0;
4049
4081
  }
4050
4082
  /** Returns true if object has no properties or spreads. */
4051
4083
  get isEmpty() {
4052
- return this._props.length === 0;
4084
+ return this._props.size === 0;
4053
4085
  }
4054
- /** Adds a property assignment. */
4086
+ /** Adds a property assignment, or removes if null. */
4055
4087
  prop(name, expr) {
4056
- this._props.push(new ObjectPropTsDsl({
4088
+ if (expr === null) this._props.delete(`prop:${name}`);
4089
+ else this._props.set(`prop:${name}`, new ObjectPropTsDsl({
4057
4090
  kind: "prop",
4058
4091
  name
4059
4092
  }).value(expr));
@@ -4061,12 +4094,13 @@ var ObjectTsDsl = class extends Mixed$24 {
4061
4094
  }
4062
4095
  /** Adds multiple properties. */
4063
4096
  props(...props) {
4064
- this._props.push(...props);
4097
+ for (const prop of props) this._props.set(this._propKey(prop), prop);
4065
4098
  return this;
4066
4099
  }
4067
- /** Adds a setter property (e.g. `{ set foo(v) { ... } }`). */
4100
+ /** Adds a setter property (e.g. `{ set foo(v) { ... } }`), or removes if null. */
4068
4101
  setter(name, stmt) {
4069
- this._props.push(new ObjectPropTsDsl({
4102
+ if (stmt === null) this._props.delete(`setter:${name}`);
4103
+ else this._props.set(`setter:${name}`, new ObjectPropTsDsl({
4070
4104
  kind: "setter",
4071
4105
  name
4072
4106
  }).value(stmt));
@@ -4074,11 +4108,13 @@ var ObjectTsDsl = class extends Mixed$24 {
4074
4108
  }
4075
4109
  /** Adds a spread property (e.g. `{ ...options }`). */
4076
4110
  spread(expr) {
4077
- this._props.push(new ObjectPropTsDsl({ kind: "spread" }).value(expr));
4111
+ const key = `spread:${this._spreadCounter++}`;
4112
+ this._props.set(key, new ObjectPropTsDsl({ kind: "spread" }).value(expr));
4078
4113
  return this;
4079
4114
  }
4080
4115
  toAst() {
4081
- const node = typescript.default.factory.createObjectLiteralExpression(this.$node(this._props), this.$multiline(this._props.length));
4116
+ const props = [...this._props.values()];
4117
+ const node = typescript.default.factory.createObjectLiteralExpression(this.$node(props), this.$multiline(props.length));
4082
4118
  return this.$hint(node);
4083
4119
  }
4084
4120
  };
@@ -4577,6 +4613,14 @@ var TypeIdxSigTsDsl = class extends Mixed$10 {
4577
4613
  this.name.set(name);
4578
4614
  fn?.(this);
4579
4615
  }
4616
+ /** Element kind. */
4617
+ get kind() {
4618
+ return "idxSig";
4619
+ }
4620
+ /** Index signature parameter name. */
4621
+ get propName() {
4622
+ return this.name.toString();
4623
+ }
4580
4624
  analyze(ctx$1) {
4581
4625
  super.analyze(ctx$1);
4582
4626
  ctx$1.analyze(this._key);
@@ -4627,6 +4671,14 @@ var TypePropTsDsl = class extends Mixed$9 {
4627
4671
  this.name.set(name);
4628
4672
  fn(this);
4629
4673
  }
4674
+ /** Element kind. */
4675
+ get kind() {
4676
+ return "prop";
4677
+ }
4678
+ /** Property name. */
4679
+ get propName() {
4680
+ return this.name.toString();
4681
+ }
4630
4682
  analyze(ctx$1) {
4631
4683
  super.analyze(ctx$1);
4632
4684
  ctx$1.analyze(this._type);
@@ -4650,33 +4702,40 @@ const Mixed$8 = TsDsl;
4650
4702
  var TypeObjectTsDsl = class extends Mixed$8 {
4651
4703
  "~dsl" = "TypeObjectTsDsl";
4652
4704
  scope = "type";
4653
- props = [];
4705
+ _props = /* @__PURE__ */ new Map();
4654
4706
  analyze(ctx$1) {
4655
4707
  super.analyze(ctx$1);
4656
- for (const prop of this.props) ctx$1.analyze(prop);
4708
+ for (const prop of this._props.values()) ctx$1.analyze(prop);
4657
4709
  }
4658
- /** Returns true if object has at least one property or spread. */
4710
+ /** Returns true if object has at least one property or index signature. */
4659
4711
  hasProps() {
4660
- return this.props.length > 0;
4712
+ return this._props.size > 0;
4661
4713
  }
4662
- /** Adds an index signature to the object type. */
4714
+ /** Adds an index signature to the object type, or removes if fn is null. */
4663
4715
  idxSig(name, fn) {
4664
- const idx = new TypeIdxSigTsDsl(name, fn);
4665
- this.props.push(idx);
4716
+ const key = `idxSig:${name}`;
4717
+ if (fn === null) this._props.delete(key);
4718
+ else this._props.set(key, new TypeIdxSigTsDsl(name, fn));
4666
4719
  return this;
4667
4720
  }
4668
- /** Returns true if object has no properties or spreads. */
4721
+ /** Returns true if object has no properties or index signatures. */
4669
4722
  get isEmpty() {
4670
- return !this.props.length;
4723
+ return this._props.size === 0;
4671
4724
  }
4672
- /** Adds a property signature (returns property builder). */
4725
+ /** Adds a property signature, or removes if fn is null. */
4673
4726
  prop(name, fn) {
4674
- const prop = new TypePropTsDsl(name, fn);
4675
- this.props.push(prop);
4727
+ const key = `prop:${name}`;
4728
+ if (fn === null) this._props.delete(key);
4729
+ else this._props.set(key, new TypePropTsDsl(name, fn));
4730
+ return this;
4731
+ }
4732
+ /** Adds multiple properties/index signatures. */
4733
+ props(...members) {
4734
+ for (const member of members) this._props.set(`${member.kind}:${member.propName}`, member);
4676
4735
  return this;
4677
4736
  }
4678
4737
  toAst() {
4679
- return typescript.default.factory.createTypeLiteralNode(this.$node(this.props));
4738
+ return typescript.default.factory.createTypeLiteralNode(this.$node([...this._props.values()]));
4680
4739
  }
4681
4740
  };
4682
4741
 
@@ -5602,6 +5661,25 @@ const pathToJsonPointer = (path$10) => {
5602
5661
  const segments = path$10.map(encodeJsonPointerSegment).join("/");
5603
5662
  return "#" + (segments ? `/${segments}` : "");
5604
5663
  };
5664
+ /**
5665
+ * Checks if a $ref points to a top-level component (not a deep path reference).
5666
+ *
5667
+ * Top-level component references:
5668
+ * - OpenAPI 3.x: #/components/{type}/{name} (3 segments)
5669
+ * - OpenAPI 2.0: #/definitions/{name} (2 segments)
5670
+ *
5671
+ * Deep path references (4+ segments for 3.x, 3+ for 2.0) should be inlined
5672
+ * because they don't have corresponding registered symbols.
5673
+ *
5674
+ * @param $ref - The $ref string to check
5675
+ * @returns true if the ref points to a top-level component, false otherwise
5676
+ */
5677
+ const isTopLevelComponentRef = ($ref) => {
5678
+ const path$10 = jsonPointerToPath($ref);
5679
+ if (path$10[0] === "components") return path$10.length === 3;
5680
+ if (path$10[0] === "definitions") return path$10.length === 2;
5681
+ return false;
5682
+ };
5605
5683
  const resolveRef = ({ $ref, spec }) => {
5606
5684
  const path$10 = jsonPointerToPath(decodeURI($ref));
5607
5685
  let current = spec;
@@ -5620,7 +5698,7 @@ const resolveRef = ({ $ref, spec }) => {
5620
5698
  * - Prefixes all conflicting names with their location (e.g. path_foo, query_foo)
5621
5699
  * - Returns a flat map of resolved parameter names to their metadata
5622
5700
  */
5623
- const getSignatureParameters = ({ operation }) => {
5701
+ function getSignatureParameters({ operation }) {
5624
5702
  const locations = [
5625
5703
  "header",
5626
5704
  "path",
@@ -5707,7 +5785,10 @@ const getSignatureParameters = ({ operation }) => {
5707
5785
  name: "body",
5708
5786
  schema: operation.body.schema
5709
5787
  };
5710
- fields.push({ in: "body" });
5788
+ fields.push({
5789
+ key: "body",
5790
+ map: "body"
5791
+ });
5711
5792
  }
5712
5793
  }
5713
5794
  if (!Object.keys(signatureParameters).length) return;
@@ -5715,7 +5796,7 @@ const getSignatureParameters = ({ operation }) => {
5715
5796
  fields,
5716
5797
  parameters: signatureParameters
5717
5798
  };
5718
- };
5799
+ }
5719
5800
 
5720
5801
  //#endregion
5721
5802
  //#region src/plugins/@hey-api/sdk/shared/validator.ts
@@ -5767,7 +5848,7 @@ const operationOptionsType = ({ isDataAllowed = true, operation, plugin, throwOn
5767
5848
  if (throwOnError) return $.type(symbolOptions).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(throwOnError);
5768
5849
  return $.type(symbolOptions).$if(!isDataAllowed || symbolDataType, (t) => t.generic(isDataAllowed ? symbolDataType : "never"));
5769
5850
  };
5770
- const operationParameters = ({ isRequiredOptions, operation, plugin }) => {
5851
+ function operationParameters({ isRequiredOptions, operation, plugin }) {
5771
5852
  const result = {
5772
5853
  argNames: [],
5773
5854
  fields: [],
@@ -5804,7 +5885,7 @@ const operationParameters = ({ isRequiredOptions, operation, plugin }) => {
5804
5885
  throwOnError: isNuxtClient ? void 0 : "ThrowOnError"
5805
5886
  }))));
5806
5887
  return result;
5807
- };
5888
+ }
5808
5889
  /**
5809
5890
  * Infers `responseType` value from provided response content type. This is
5810
5891
  * an adapted version of `getParseAs()` from the Fetch API client.
@@ -5827,7 +5908,7 @@ const getResponseType = (contentType) => {
5827
5908
  ].some((type) => cleanContent.startsWith(type))) return "blob";
5828
5909
  if (cleanContent.startsWith("text/")) return "text";
5829
5910
  };
5830
- const operationStatements = ({ isRequiredOptions, opParameters, operation, plugin }) => {
5911
+ function operationStatements({ isRequiredOptions, opParameters, operation, plugin }) {
5831
5912
  const client = getClientPlugin(plugin.context.config);
5832
5913
  const isNuxtClient = client.name === "@hey-api/client-nuxt";
5833
5914
  const symbolResponseType = plugin.querySymbol({
@@ -5958,7 +6039,7 @@ const operationStatements = ({ isRequiredOptions, opParameters, operation, plugi
5958
6039
  functionName = functionName.attr(operation.method);
5959
6040
  statements.push($.return(functionName.call(reqOptions).$if(isNuxtClient, (f$1) => f$1.generic(nuxtTypeComposable).generic($.type.or(symbolResponseType ?? "unknown", nuxtTypeDefault)).generic(symbolErrorType ?? "unknown").generic(nuxtTypeDefault), (f$1) => f$1.generic(symbolResponseType ?? "unknown").generic(symbolErrorType ?? "unknown").generic("ThrowOnError")).$if(plugin.config.responseStyle === "data", (f$1) => f$1.generic($.type.literal(plugin.config.responseStyle)))));
5960
6041
  return statements;
5961
- };
6042
+ }
5962
6043
 
5963
6044
  //#endregion
5964
6045
  //#region src/plugins/@hey-api/sdk/v1/node.ts
@@ -9115,7 +9196,13 @@ const createMutationOptions = ({ operation, plugin }) => {
9115
9196
  if (plugin.getPluginOrThrow("@hey-api/sdk").config.responseStyle === "data") statements.push($.return(awaitSdkFn));
9116
9197
  else statements.push($.const().object("data").assign(awaitSdkFn), $.return("data"));
9117
9198
  const mutationOptionsFn = "mutationOptions";
9118
- const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions));
9199
+ const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions), { meta: {
9200
+ category: "hook",
9201
+ resource: "operation",
9202
+ resourceId: operation.id,
9203
+ role: "mutationOptions",
9204
+ tool: plugin.name
9205
+ } });
9119
9206
  const statement = $.const(symbolMutationOptions).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions$1).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
9120
9207
  plugin.node(statement);
9121
9208
  };
@@ -15007,119 +15094,98 @@ const getPlugins = ({ dependencies, userConfig }) => {
15007
15094
  });
15008
15095
  };
15009
15096
 
15097
+ //#endregion
15098
+ //#region src/config/resolve.ts
15099
+ const resolveConfig = (validated, dependencies) => {
15100
+ const logs = getLogs(validated.job.config);
15101
+ const input = getInput(validated.job.config);
15102
+ const output = getOutput(validated.job.config);
15103
+ const parser = getParser(validated.job.config);
15104
+ output.path = node_path.default.resolve(process.cwd(), output.path);
15105
+ let plugins;
15106
+ try {
15107
+ plugins = getPlugins({
15108
+ dependencies,
15109
+ userConfig: validated.job.config
15110
+ });
15111
+ } catch (error) {
15112
+ validated.errors.push(error);
15113
+ plugins = {
15114
+ pluginOrder: [],
15115
+ plugins: {}
15116
+ };
15117
+ }
15118
+ const config = {
15119
+ configFile: validated.job.config.configFile ?? "",
15120
+ dryRun: validated.job.config.dryRun ?? false,
15121
+ input,
15122
+ interactive: validated.job.config.interactive ?? (0, _hey_api_codegen_core.detectInteractiveSession)(),
15123
+ logs,
15124
+ output,
15125
+ parser,
15126
+ pluginOrder: plugins.pluginOrder,
15127
+ plugins: plugins.plugins
15128
+ };
15129
+ if (logs.level === "debug") {
15130
+ const jobPrefix = ansi_colors.default.gray(`[Job ${validated.job.index}] `);
15131
+ console.warn(`${jobPrefix}${ansi_colors.default.cyan("config:")}`, config);
15132
+ }
15133
+ return {
15134
+ config,
15135
+ errors: validated.errors,
15136
+ index: validated.job.index
15137
+ };
15138
+ };
15139
+
15140
+ //#endregion
15141
+ //#region src/config/validate.ts
15142
+ function validateJobs(jobs) {
15143
+ return jobs.map((job) => {
15144
+ const errors = [];
15145
+ const { config } = job;
15146
+ if (!getInput(config).length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
15147
+ if (!getOutput(config).path) errors.push(new ConfigError("missing output - where should we generate your output?"));
15148
+ return {
15149
+ errors,
15150
+ job
15151
+ };
15152
+ });
15153
+ }
15154
+
15010
15155
  //#endregion
15011
15156
  //#region src/config/init.ts
15012
15157
  /**
15013
- * Detect if the current session is interactive based on TTY status and environment variables.
15014
- * This is used as a fallback when the user doesn't explicitly set the interactive option.
15015
15158
  * @internal
15016
15159
  */
15017
- const detectInteractiveSession = () => Boolean(process.stdin.isTTY && process.stdout.isTTY && !process.env.CI && !process.env.NO_INTERACTIVE && !process.env.NO_INTERACTION);
15018
- /**
15019
- * @internal
15020
- */
15021
- const initConfigs = async ({ logger, userConfigs }) => {
15160
+ async function resolveJobs({ logger, userConfigs }) {
15022
15161
  const configs = [];
15023
15162
  let dependencies = {};
15024
15163
  const eventLoad = logger.timeEvent("load");
15025
15164
  for (const userConfig of userConfigs) {
15026
- let configurationFile = void 0;
15027
- if (userConfig?.configFile) {
15165
+ let configFile;
15166
+ if (userConfig.configFile) {
15028
15167
  const parts = userConfig.configFile.split(".");
15029
- configurationFile = parts.slice(0, parts.length - 1).join(".");
15030
- }
15031
- const eventC12 = logger.timeEvent("c12");
15032
- const { loadConfig } = await import("c12");
15033
- const { config: configFromFile, configFile: loadedConfigFile } = await loadConfig({
15034
- configFile: configurationFile,
15035
- name: "openapi-ts"
15036
- });
15037
- eventC12.timeEnd();
15038
- if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(Object.keys(configFromFile).length ? loadedConfigFile : void 0);
15039
- const mergedConfigs = configFromFile instanceof Array ? configFromFile.map((config) => mergeConfigs(config, userConfig)) : [mergeConfigs(configFromFile, userConfig)];
15040
- for (const mergedConfig of mergedConfigs) {
15041
- const input = getInput(mergedConfig);
15042
- if (mergedConfig.output instanceof Array) {
15043
- const countInputs = input.length;
15044
- const countOutputs = mergedConfig.output.length;
15045
- if (countOutputs > 1) if (countInputs !== countOutputs) {
15046
- console.warn(`⚙️ ${ansi_colors.default.yellow("Warning:")} You provided ${ansi_colors.default.cyan(String(countInputs))} ${ansi_colors.default.cyan(countInputs === 1 ? "input" : "inputs")} and ${ansi_colors.default.yellow(String(countOutputs))} ${ansi_colors.default.yellow("outputs")}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);
15047
- for (const output of mergedConfig.output) configs.push({
15048
- ...mergedConfig,
15049
- input,
15050
- output
15051
- });
15052
- } else mergedConfig.output.forEach((output, index) => {
15053
- configs.push({
15054
- ...mergedConfig,
15055
- input: input[index],
15056
- output
15057
- });
15058
- });
15059
- else configs.push({
15060
- ...mergedConfig,
15061
- input,
15062
- output: mergedConfig.output[0] ?? ""
15063
- });
15064
- } else configs.push({
15065
- ...mergedConfig,
15066
- input
15067
- });
15168
+ configFile = parts.slice(0, parts.length - 1).join(".");
15068
15169
  }
15170
+ const loaded = await (0, _hey_api_codegen_core.loadConfigFile)({
15171
+ configFile,
15172
+ logger,
15173
+ name: "openapi-ts",
15174
+ userConfig
15175
+ });
15176
+ if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(loaded.foundConfig ? loaded.configFile : void 0);
15177
+ configs.push(...loaded.configs);
15069
15178
  }
15070
15179
  eventLoad.timeEnd();
15071
- const results = [];
15072
15180
  const eventBuild = logger.timeEvent("build");
15073
- for (const userConfig of configs) {
15074
- const logs = getLogs(userConfig);
15075
- const input = getInput(userConfig);
15076
- const output = getOutput(userConfig);
15077
- const parser = getParser(userConfig);
15078
- const errors = [];
15079
- if (!input.length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
15080
- if (!output.path) errors.push(new ConfigError("missing output - where should we generate your output?"));
15081
- output.path = node_path.default.resolve(process.cwd(), output.path);
15082
- let plugins;
15083
- try {
15084
- plugins = getPlugins({
15085
- dependencies,
15086
- userConfig
15087
- });
15088
- } catch (error) {
15089
- errors.push(error);
15090
- plugins = {
15091
- pluginOrder: [],
15092
- plugins: {}
15093
- };
15094
- }
15095
- const config = {
15096
- configFile: userConfig.configFile ?? "",
15097
- dryRun: userConfig.dryRun ?? false,
15098
- input,
15099
- interactive: userConfig.interactive ?? detectInteractiveSession(),
15100
- logs,
15101
- output,
15102
- parser,
15103
- pluginOrder: plugins.pluginOrder,
15104
- plugins: plugins.plugins
15105
- };
15106
- const jobIndex = results.length;
15107
- if (logs.level === "debug") {
15108
- const jobPrefix = ansi_colors.default.gray(`[Job ${jobIndex + 1}] `);
15109
- console.warn(`${jobPrefix}${ansi_colors.default.cyan("config:")}`, config);
15110
- }
15111
- results.push({
15112
- config,
15113
- errors,
15114
- jobIndex
15115
- });
15116
- }
15181
+ const resolvedJobs = validateJobs(expandToJobs(configs)).map((validated) => resolveConfig(validated, dependencies));
15117
15182
  eventBuild.timeEnd();
15118
15183
  return {
15119
15184
  dependencies,
15120
- results
15185
+ jobs: resolvedJobs,
15186
+ results: resolvedJobs
15121
15187
  };
15122
- };
15188
+ }
15123
15189
 
15124
15190
  //#endregion
15125
15191
  //#region src/plugins/@hey-api/client-core/bundle/params.ts
@@ -18112,7 +18178,7 @@ const parseEnum$2 = ({ context, schema, state }) => {
18112
18178
  };
18113
18179
  const parseRef$2 = ({ context, schema, state }) => {
18114
18180
  const irSchema = {};
18115
- if (!schema.$ref.startsWith("#/definitions/")) {
18181
+ if (!isTopLevelComponentRef(schema.$ref)) {
18116
18182
  if (!state.circularReferenceTracker.has(schema.$ref)) {
18117
18183
  const refSchema = context.resolveRef(schema.$ref);
18118
18184
  const originalRef = state.$ref;
@@ -19412,7 +19478,7 @@ const parseOneOf$1 = ({ context, schema, state }) => {
19412
19478
  return irSchema;
19413
19479
  };
19414
19480
  const parseRef$1 = ({ context, schema, state }) => {
19415
- if (!schema.$ref.startsWith("#/components/")) {
19481
+ if (!isTopLevelComponentRef(schema.$ref)) {
19416
19482
  if (!state.circularReferenceTracker.has(schema.$ref)) {
19417
19483
  const refSchema = context.resolveRef(schema.$ref);
19418
19484
  const originalRef = state.$ref;
@@ -20760,7 +20826,7 @@ const parseOneOf = ({ context, schema, state }) => {
20760
20826
  return irSchema;
20761
20827
  };
20762
20828
  const parseRef = ({ context, schema, state }) => {
20763
- if (!schema.$ref.startsWith("#/components/")) {
20829
+ if (!isTopLevelComponentRef(schema.$ref)) {
20764
20830
  if (!state.circularReferenceTracker.has(schema.$ref)) {
20765
20831
  const refSchema = context.resolveRef(schema.$ref);
20766
20832
  const originalRef = state.$ref;
@@ -21891,12 +21957,6 @@ Object.defineProperty(exports, 'getSpec', {
21891
21957
  return getSpec;
21892
21958
  }
21893
21959
  });
21894
- Object.defineProperty(exports, 'initConfigs', {
21895
- enumerable: true,
21896
- get: function () {
21897
- return initConfigs;
21898
- }
21899
- });
21900
21960
  Object.defineProperty(exports, 'keywords', {
21901
21961
  enumerable: true,
21902
21962
  get: function () {
@@ -21951,6 +22011,12 @@ Object.defineProperty(exports, 'reserved', {
21951
22011
  return reserved;
21952
22012
  }
21953
22013
  });
22014
+ Object.defineProperty(exports, 'resolveJobs', {
22015
+ enumerable: true,
22016
+ get: function () {
22017
+ return resolveJobs;
22018
+ }
22019
+ });
21954
22020
  Object.defineProperty(exports, 'shouldReportCrash', {
21955
22021
  enumerable: true,
21956
22022
  get: function () {
@@ -21963,4 +22029,4 @@ Object.defineProperty(exports, 'toCase', {
21963
22029
  return toCase;
21964
22030
  }
21965
22031
  });
21966
- //# sourceMappingURL=openApi-BZ7m5ia5.cjs.map
22032
+ //# sourceMappingURL=openApi-Dy5wknYZ.cjs.map