@hey-api/openapi-ts 0.90.7 → 0.90.9

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);
4029
4054
  }
4030
- /** Adds a computed property (e.g. `{ [expr]: value }`). */
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}`;
4059
+ }
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
 
@@ -15007,119 +15066,98 @@ const getPlugins = ({ dependencies, userConfig }) => {
15007
15066
  });
15008
15067
  };
15009
15068
 
15069
+ //#endregion
15070
+ //#region src/config/resolve.ts
15071
+ const resolveConfig = (validated, dependencies) => {
15072
+ const logs = getLogs(validated.job.config);
15073
+ const input = getInput(validated.job.config);
15074
+ const output = getOutput(validated.job.config);
15075
+ const parser = getParser(validated.job.config);
15076
+ output.path = node_path.default.resolve(process.cwd(), output.path);
15077
+ let plugins;
15078
+ try {
15079
+ plugins = getPlugins({
15080
+ dependencies,
15081
+ userConfig: validated.job.config
15082
+ });
15083
+ } catch (error) {
15084
+ validated.errors.push(error);
15085
+ plugins = {
15086
+ pluginOrder: [],
15087
+ plugins: {}
15088
+ };
15089
+ }
15090
+ const config = {
15091
+ configFile: validated.job.config.configFile ?? "",
15092
+ dryRun: validated.job.config.dryRun ?? false,
15093
+ input,
15094
+ interactive: validated.job.config.interactive ?? (0, _hey_api_codegen_core.detectInteractiveSession)(),
15095
+ logs,
15096
+ output,
15097
+ parser,
15098
+ pluginOrder: plugins.pluginOrder,
15099
+ plugins: plugins.plugins
15100
+ };
15101
+ if (logs.level === "debug") {
15102
+ const jobPrefix = ansi_colors.default.gray(`[Job ${validated.job.index}] `);
15103
+ console.warn(`${jobPrefix}${ansi_colors.default.cyan("config:")}`, config);
15104
+ }
15105
+ return {
15106
+ config,
15107
+ errors: validated.errors,
15108
+ index: validated.job.index
15109
+ };
15110
+ };
15111
+
15112
+ //#endregion
15113
+ //#region src/config/validate.ts
15114
+ function validateJobs(jobs) {
15115
+ return jobs.map((job) => {
15116
+ const errors = [];
15117
+ const { config } = job;
15118
+ if (!getInput(config).length) errors.push(new ConfigError("missing input - which OpenAPI specification should we use to generate your output?"));
15119
+ if (!getOutput(config).path) errors.push(new ConfigError("missing output - where should we generate your output?"));
15120
+ return {
15121
+ errors,
15122
+ job
15123
+ };
15124
+ });
15125
+ }
15126
+
15010
15127
  //#endregion
15011
15128
  //#region src/config/init.ts
15012
15129
  /**
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
15130
  * @internal
15016
15131
  */
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 }) => {
15132
+ async function resolveJobs({ logger, userConfigs }) {
15022
15133
  const configs = [];
15023
15134
  let dependencies = {};
15024
15135
  const eventLoad = logger.timeEvent("load");
15025
15136
  for (const userConfig of userConfigs) {
15026
- let configurationFile = void 0;
15027
- if (userConfig?.configFile) {
15137
+ let configFile;
15138
+ if (userConfig.configFile) {
15028
15139
  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
- });
15140
+ configFile = parts.slice(0, parts.length - 1).join(".");
15068
15141
  }
15142
+ const loaded = await (0, _hey_api_codegen_core.loadConfigFile)({
15143
+ configFile,
15144
+ logger,
15145
+ name: "openapi-ts",
15146
+ userConfig
15147
+ });
15148
+ if (!Object.keys(dependencies).length) dependencies = getProjectDependencies(loaded.foundConfig ? loaded.configFile : void 0);
15149
+ configs.push(...loaded.configs);
15069
15150
  }
15070
15151
  eventLoad.timeEnd();
15071
- const results = [];
15072
15152
  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
- }
15153
+ const resolvedJobs = validateJobs(expandToJobs(configs)).map((validated) => resolveConfig(validated, dependencies));
15117
15154
  eventBuild.timeEnd();
15118
15155
  return {
15119
15156
  dependencies,
15120
- results
15157
+ jobs: resolvedJobs,
15158
+ results: resolvedJobs
15121
15159
  };
15122
- };
15160
+ }
15123
15161
 
15124
15162
  //#endregion
15125
15163
  //#region src/plugins/@hey-api/client-core/bundle/params.ts
@@ -21891,12 +21929,6 @@ Object.defineProperty(exports, 'getSpec', {
21891
21929
  return getSpec;
21892
21930
  }
21893
21931
  });
21894
- Object.defineProperty(exports, 'initConfigs', {
21895
- enumerable: true,
21896
- get: function () {
21897
- return initConfigs;
21898
- }
21899
- });
21900
21932
  Object.defineProperty(exports, 'keywords', {
21901
21933
  enumerable: true,
21902
21934
  get: function () {
@@ -21951,6 +21983,12 @@ Object.defineProperty(exports, 'reserved', {
21951
21983
  return reserved;
21952
21984
  }
21953
21985
  });
21986
+ Object.defineProperty(exports, 'resolveJobs', {
21987
+ enumerable: true,
21988
+ get: function () {
21989
+ return resolveJobs;
21990
+ }
21991
+ });
21954
21992
  Object.defineProperty(exports, 'shouldReportCrash', {
21955
21993
  enumerable: true,
21956
21994
  get: function () {
@@ -21963,4 +22001,4 @@ Object.defineProperty(exports, 'toCase', {
21963
22001
  return toCase;
21964
22002
  }
21965
22003
  });
21966
- //# sourceMappingURL=openApi-BZ7m5ia5.cjs.map
22004
+ //# sourceMappingURL=openApi-BaGlRfMs.cjs.map