@kubb/agent 5.0.0-alpha.22 → 5.0.0-alpha.23

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.
@@ -7,7 +7,7 @@ import https, { Server as Server$1 } from 'node:https';
7
7
  import { EventEmitter } from 'node:events';
8
8
  import { Buffer as Buffer$1 } from 'node:buffer';
9
9
  import fs$1, { promises, existsSync, readFileSync } from 'node:fs';
10
- import path$2, { resolve, dirname, relative, join, basename, extname, posix } from 'node:path';
10
+ import path$2, { resolve, dirname, relative, join, basename, posix, extname } from 'node:path';
11
11
  import anymatch from 'anymatch';
12
12
  import { createHash, randomBytes } from 'node:crypto';
13
13
  import process$1, { version as version$2 } from 'node:process';
@@ -4595,65 +4595,7 @@ const visitorDepths = {
4595
4595
  };
4596
4596
  const schemaTypes = {
4597
4597
  enum: "enum"};
4598
- function toCamelOrPascal$f(text, pascal) {
4599
- return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
4600
- if (word.length > 1 && word === word.toUpperCase()) return word;
4601
- if (i === 0 && true) return word.charAt(0).toLowerCase() + word.slice(1);
4602
- return word.charAt(0).toUpperCase() + word.slice(1);
4603
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
4604
- }
4605
- function applyToFileParts$f(text, transformPart) {
4606
- const parts = text.split(/\.(?=[a-zA-Z])/);
4607
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
4608
- }
4609
- function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
4610
- if (isFile) return applyToFileParts$f(text, (part, isLast) => camelCase$f(part, isLast ? {
4611
- prefix,
4612
- suffix
4613
- } : {}));
4614
- return toCamelOrPascal$f(`${prefix} ${text} ${suffix}`);
4615
- }
4616
- function isValidVarName$c(name) {
4617
- try {
4618
- new Function(`var ${name}`);
4619
- } catch {
4620
- return false;
4621
- }
4622
- return true;
4623
- }
4624
- function narrowSchema(node, type) {
4625
- return (node == null ? void 0 : node.type) === type ? node : void 0;
4626
- }
4627
- function isKind(kind) {
4628
- return (node) => node.kind === kind;
4629
- }
4630
- const isOperationNode = isKind("Operation");
4631
- const isSchemaNode = isKind("Schema");
4632
- const plainStringTypes = /* @__PURE__ */ new Set([
4633
- "string",
4634
- "uuid",
4635
- "email",
4636
- "url",
4637
- "datetime"
4638
- ]);
4639
- function isStringType(node) {
4640
- var _a;
4641
- if (plainStringTypes.has(node.type)) return true;
4642
- const temporal = (_a = narrowSchema(node, "date")) != null ? _a : narrowSchema(node, "time");
4643
- if (temporal) return temporal.representation !== "date";
4644
- return false;
4645
- }
4646
- function caseParams(params, casing) {
4647
- if (!casing) return params;
4648
- return params.map((param) => {
4649
- const transformed = casing === "camelcase" || !isValidVarName$c(param.name) ? camelCase$f(param.name) : param.name;
4650
- return {
4651
- ...param,
4652
- name: transformed
4653
- };
4654
- });
4655
- }
4656
- function syncOptionality(required, schema) {
4598
+ function syncOptionality(schema, required) {
4657
4599
  var _a;
4658
4600
  const nullable = (_a = schema.nullable) != null ? _a : false;
4659
4601
  return {
@@ -4680,7 +4622,7 @@ function createProperty(props) {
4680
4622
  ...props,
4681
4623
  kind: "Property",
4682
4624
  required,
4683
- schema: syncOptionality(required, props.schema)
4625
+ schema: syncOptionality(props.schema, required)
4684
4626
  };
4685
4627
  }
4686
4628
  function createParameter(props) {
@@ -4690,9 +4632,17 @@ function createParameter(props) {
4690
4632
  ...props,
4691
4633
  kind: "Parameter",
4692
4634
  required,
4693
- schema: syncOptionality(required, props.schema)
4635
+ schema: syncOptionality(props.schema, required)
4694
4636
  };
4695
4637
  }
4638
+ function narrowSchema(node, type) {
4639
+ return (node == null ? void 0 : node.type) === type ? node : void 0;
4640
+ }
4641
+ function isKind(kind) {
4642
+ return (node) => node.kind === kind;
4643
+ }
4644
+ const isOperationNode = isKind("Operation");
4645
+ const isSchemaNode = isKind("Schema");
4696
4646
  function definePrinter(build) {
4697
4647
  return createPrinterFactory((node) => node.type)(build);
4698
4648
  }
@@ -4719,6 +4669,32 @@ function createPrinterFactory(getKey) {
4719
4669
  };
4720
4670
  };
4721
4671
  }
4672
+ function toCamelOrPascal$f(text, pascal) {
4673
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
4674
+ if (word.length > 1 && word === word.toUpperCase()) return word;
4675
+ if (i === 0 && true) return word.charAt(0).toLowerCase() + word.slice(1);
4676
+ return word.charAt(0).toUpperCase() + word.slice(1);
4677
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
4678
+ }
4679
+ function applyToFileParts$f(text, transformPart) {
4680
+ const parts = text.split(/\.(?=[a-zA-Z])/);
4681
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
4682
+ }
4683
+ function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
4684
+ if (isFile) return applyToFileParts$f(text, (part, isLast) => camelCase$f(part, isLast ? {
4685
+ prefix,
4686
+ suffix
4687
+ } : {}));
4688
+ return toCamelOrPascal$f(`${prefix} ${text} ${suffix}`);
4689
+ }
4690
+ function isValidVarName$c(name) {
4691
+ try {
4692
+ new Function(`var ${name}`);
4693
+ } catch {
4694
+ return false;
4695
+ }
4696
+ return true;
4697
+ }
4722
4698
  function createLimit(concurrency) {
4723
4699
  let active = 0;
4724
4700
  const queue = [];
@@ -4767,8 +4743,9 @@ function getChildren(node, recurse) {
4767
4743
  case "Response":
4768
4744
  return node.schema ? [node.schema] : [];
4769
4745
  case "FunctionParameter":
4770
- case "ObjectBindingParameter":
4746
+ case "ParameterGroup":
4771
4747
  case "FunctionParameters":
4748
+ case "Type":
4772
4749
  return [];
4773
4750
  }
4774
4751
  }
@@ -4915,8 +4892,9 @@ function transform(node, options) {
4915
4892
  };
4916
4893
  }
4917
4894
  case "FunctionParameter":
4918
- case "ObjectBindingParameter":
4895
+ case "ParameterGroup":
4919
4896
  case "FunctionParameters":
4897
+ case "Type":
4920
4898
  return node;
4921
4899
  }
4922
4900
  }
@@ -4993,12 +4971,36 @@ function collect(node, options) {
4993
4971
  })) results.push(item);
4994
4972
  return results;
4995
4973
  }
4974
+ const plainStringTypes = /* @__PURE__ */ new Set([
4975
+ "string",
4976
+ "uuid",
4977
+ "email",
4978
+ "url",
4979
+ "datetime"
4980
+ ]);
4981
+ function isStringType(node) {
4982
+ var _a;
4983
+ if (plainStringTypes.has(node.type)) return true;
4984
+ const temporal = (_a = narrowSchema(node, "date")) != null ? _a : narrowSchema(node, "time");
4985
+ if (temporal) return temporal.representation !== "date";
4986
+ return false;
4987
+ }
4988
+ function caseParams(params, casing) {
4989
+ if (!casing) return params;
4990
+ return params.map((param) => {
4991
+ const transformed = casing === "camelcase" || !isValidVarName$c(param.name) ? camelCase$f(param.name) : param.name;
4992
+ return {
4993
+ ...param,
4994
+ name: transformed
4995
+ };
4996
+ });
4997
+ }
4996
4998
 
4997
- var __defProp$i = Object.defineProperty;
4999
+ var __defProp$h = Object.defineProperty;
4998
5000
  var __typeError$c = (msg) => {
4999
5001
  throw TypeError(msg);
5000
5002
  };
5001
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5003
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5002
5004
  var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
5003
5005
  var __accessCheck$c = (obj, member, msg) => member.has(obj) || __typeError$c("Cannot " + msg);
5004
5006
  var __privateGet$c = (obj, member, getter) => (__accessCheck$c(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -5013,9 +5015,7 @@ var __privateWrapper$1 = (obj, member, setter, getter) => ({
5013
5015
  return __privateGet$c(obj, member, getter);
5014
5016
  }
5015
5017
  });
5016
- var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _studioIsOpen, _plugins, _usedPluginNames, _PluginDriver_instances, getSortedPlugins_fn, emitProcessingEnd_fn, execute_fn, executeSync_fn, parse_fn, _d, _items, _FunctionParams_static, _e, orderItems_fn, addParams_fn, _cachedLeaves, _f;
5017
- var ValidationPluginError = class extends Error {
5018
- };
5018
+ var _emitter, _a$c, _options$c, _URLPath_instances$a, transformParam_fn$a, eachParam_fn$a, _b$2, _head$1, _tail$1, _size$1, _c, _studioIsOpen, _PluginDriver_instances, emitProcessingEnd_fn, execute_fn, executeSync_fn, _d, _items, _FunctionParams_static, _e, orderItems_fn, addParams_fn, _cachedLeaves, _f;
5019
5019
  function toError(value) {
5020
5020
  return value instanceof Error ? value : new Error(String(value));
5021
5021
  }
@@ -5190,15 +5190,6 @@ async function clean(path2) {
5190
5190
  force: true
5191
5191
  });
5192
5192
  }
5193
- function setUniqueName(originalName, data) {
5194
- let used = data[originalName] || 0;
5195
- if (used) {
5196
- data[originalName] = ++used;
5197
- return originalName;
5198
- }
5199
- data[originalName] = 1;
5200
- return originalName;
5201
- }
5202
5193
  function isPromiseRejectedResult(result) {
5203
5194
  return result.status === "rejected";
5204
5195
  }
@@ -5674,8 +5665,10 @@ var PluginDriver = (_d = class {
5674
5665
  __publicField$b(this, "rootNode");
5675
5666
  __publicField$b(this, "adapter");
5676
5667
  __privateAdd$c(this, _studioIsOpen, false);
5677
- __privateAdd$c(this, _plugins, /* @__PURE__ */ new Set());
5678
- __privateAdd$c(this, _usedPluginNames, {});
5668
+ __publicField$b(this, "plugins", /* @__PURE__ */ new Map());
5669
+ /**
5670
+ * @deprecated use resolvers context instead
5671
+ */
5679
5672
  __publicField$b(this, "resolvePath", (params) => {
5680
5673
  var _a2, _b2;
5681
5674
  const defaultPath = resolve(resolve(this.config.root, this.config.output.path), params.baseName);
@@ -5697,42 +5690,46 @@ var PluginDriver = (_d = class {
5697
5690
  ]
5698
5691
  })) == null ? void 0 : _b2.result) || defaultPath;
5699
5692
  });
5693
+ /**
5694
+ * @deprecated use resolvers context instead
5695
+ */
5700
5696
  __publicField$b(this, "resolveName", (params) => {
5701
- var _a2;
5702
- if (params.pluginName) {
5703
- const names = this.hookForPluginSync({
5704
- pluginName: params.pluginName,
5705
- hookName: "resolveName",
5706
- parameters: [params.name.trim(), params.type]
5707
- });
5708
- return transformReservedWord([...new Set(names)].at(0) || params.name);
5709
- }
5710
- const name = (_a2 = this.hookFirstSync({
5697
+ var _a2, _b2, _c2;
5698
+ if (params.pluginName) return transformReservedWord((_b2 = (_a2 = this.hookForPluginSync({
5699
+ pluginName: params.pluginName,
5700
+ hookName: "resolveName",
5701
+ parameters: [params.name.trim(), params.type]
5702
+ })) == null ? void 0 : _a2.at(0)) != null ? _b2 : params.name);
5703
+ const name = (_c2 = this.hookFirstSync({
5711
5704
  hookName: "resolveName",
5712
5705
  parameters: [params.name.trim(), params.type]
5713
- })) == null ? void 0 : _a2.result;
5706
+ })) == null ? void 0 : _c2.result;
5714
5707
  return transformReservedWord(name != null ? name : params.name);
5715
5708
  });
5716
5709
  this.config = config;
5717
5710
  this.options = options;
5718
- [...config.plugins || []].forEach((plugin) => {
5719
- const parsedPlugin = __privateMethod$c(this, _PluginDriver_instances, parse_fn).call(this, plugin);
5720
- __privateGet$c(this, _plugins).add(parsedPlugin);
5711
+ config.plugins.map((plugin) => Object.assign({ install() {
5712
+ } }, plugin)).sort((a, b) => {
5713
+ var _a2, _b2;
5714
+ if ((_a2 = b.pre) == null ? void 0 : _a2.includes(a.name)) return 1;
5715
+ if ((_b2 = b.post) == null ? void 0 : _b2.includes(a.name)) return -1;
5716
+ return 0;
5717
+ }).forEach((plugin) => {
5718
+ this.plugins.set(plugin.name, plugin);
5721
5719
  });
5722
5720
  }
5723
5721
  get events() {
5724
5722
  return this.options.events;
5725
5723
  }
5726
5724
  getContext(plugin) {
5727
- const plugins = [...__privateGet$c(this, _plugins)];
5728
5725
  const driver = this;
5729
5726
  const baseContext = {
5730
- fabric: this.options.fabric,
5731
- config: this.config,
5727
+ fabric: driver.options.fabric,
5728
+ config: driver.config,
5732
5729
  plugin,
5733
- events: this.options.events,
5734
- driver: this,
5735
- mode: getMode(resolve(this.config.root, this.config.output.path)),
5730
+ getPlugin: driver.getPlugin.bind(driver),
5731
+ events: driver.options.events,
5732
+ driver,
5736
5733
  addFile: async (...files) => {
5737
5734
  await this.options.fabric.addFile(...files);
5738
5735
  },
@@ -5745,6 +5742,9 @@ var PluginDriver = (_d = class {
5745
5742
  get adapter() {
5746
5743
  return driver.adapter;
5747
5744
  },
5745
+ get resolver() {
5746
+ return plugin.resolver;
5747
+ },
5748
5748
  openInStudio(options) {
5749
5749
  var _a2, _b2;
5750
5750
  if (!driver.config.devtools || __privateGet$c(driver, _studioIsOpen)) return;
@@ -5756,8 +5756,8 @@ var PluginDriver = (_d = class {
5756
5756
  }
5757
5757
  };
5758
5758
  const mergedExtras = {};
5759
- for (const p of plugins) if (typeof p.inject === "function") {
5760
- const result = p.inject.call(baseContext, baseContext);
5759
+ for (const plugin2 of this.plugins.values()) if (typeof plugin2.inject === "function") {
5760
+ const result = plugin2.inject.call(baseContext, baseContext);
5761
5761
  if (result !== null && typeof result === "object") Object.assign(mergedExtras, result);
5762
5762
  }
5763
5763
  return {
@@ -5765,9 +5765,9 @@ var PluginDriver = (_d = class {
5765
5765
  ...mergedExtras
5766
5766
  };
5767
5767
  }
5768
- get plugins() {
5769
- return __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this);
5770
- }
5768
+ /**
5769
+ * @deprecated use resolvers context instead
5770
+ */
5771
5771
  getFile({ name, mode, extname: extname2, pluginName, options }) {
5772
5772
  const resolvedName = mode ? mode === "single" ? "" : this.resolveName({
5773
5773
  name,
@@ -5794,44 +5794,41 @@ var PluginDriver = (_d = class {
5794
5794
  * Run a specific hookName for plugin x.
5795
5795
  */
5796
5796
  async hookForPlugin({ pluginName, hookName, parameters }) {
5797
- const plugins = this.getPluginsByName(hookName, pluginName);
5797
+ const plugin = this.plugins.get(pluginName);
5798
+ if (!plugin) return [null];
5798
5799
  this.events.emit("plugins:hook:progress:start", {
5799
5800
  hookName,
5800
- plugins
5801
+ plugins: [plugin]
5802
+ });
5803
+ const result = await __privateMethod$c(this, _PluginDriver_instances, execute_fn).call(this, {
5804
+ strategy: "hookFirst",
5805
+ hookName,
5806
+ parameters,
5807
+ plugin
5801
5808
  });
5802
- const items = [];
5803
- for (const plugin of plugins) {
5804
- const result = await __privateMethod$c(this, _PluginDriver_instances, execute_fn).call(this, {
5805
- strategy: "hookFirst",
5806
- hookName,
5807
- parameters,
5808
- plugin
5809
- });
5810
- if (result !== void 0 && result !== null) items.push(result);
5811
- }
5812
5809
  this.events.emit("plugins:hook:progress:end", { hookName });
5813
- return items;
5810
+ return [result];
5814
5811
  }
5815
5812
  /**
5816
5813
  * Run a specific hookName for plugin x.
5817
5814
  */
5818
5815
  hookForPluginSync({ pluginName, hookName, parameters }) {
5819
- return this.getPluginsByName(hookName, pluginName).map((plugin) => {
5820
- return __privateMethod$c(this, _PluginDriver_instances, executeSync_fn).call(this, {
5821
- strategy: "hookFirst",
5822
- hookName,
5823
- parameters,
5824
- plugin
5825
- });
5826
- }).filter((x2) => x2 !== null);
5816
+ const plugin = this.plugins.get(pluginName);
5817
+ if (!plugin) return null;
5818
+ const result = __privateMethod$c(this, _PluginDriver_instances, executeSync_fn).call(this, {
5819
+ strategy: "hookFirst",
5820
+ hookName,
5821
+ parameters,
5822
+ plugin
5823
+ });
5824
+ return result !== null ? [result] : [];
5827
5825
  }
5828
5826
  /**
5829
5827
  * Returns the first non-null result.
5830
5828
  */
5831
5829
  async hookFirst({ hookName, parameters, skipped }) {
5832
- const plugins = __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this, hookName).filter((plugin) => {
5833
- return skipped ? !skipped.has(plugin) : true;
5834
- });
5830
+ const plugins = [];
5831
+ for (const plugin of this.plugins.values()) if (hookName in plugin && (skipped ? !skipped.has(plugin) : true)) plugins.push(plugin);
5835
5832
  this.events.emit("plugins:hook:progress:start", {
5836
5833
  hookName,
5837
5834
  plugins
@@ -5858,10 +5855,9 @@ var PluginDriver = (_d = class {
5858
5855
  */
5859
5856
  hookFirstSync({ hookName, parameters, skipped }) {
5860
5857
  let parseResult = null;
5861
- const plugins = __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this, hookName).filter((plugin) => {
5862
- return skipped ? !skipped.has(plugin) : true;
5863
- });
5864
- for (const plugin of plugins) {
5858
+ for (const plugin of this.plugins.values()) {
5859
+ if (!(hookName in plugin)) continue;
5860
+ if (skipped == null ? void 0 : skipped.has(plugin)) continue;
5865
5861
  parseResult = {
5866
5862
  result: __privateMethod$c(this, _PluginDriver_instances, executeSync_fn).call(this, {
5867
5863
  strategy: "hookFirst",
@@ -5871,7 +5867,7 @@ var PluginDriver = (_d = class {
5871
5867
  }),
5872
5868
  plugin
5873
5869
  };
5874
- if ((parseResult == null ? void 0 : parseResult.result) != null) break;
5870
+ if (parseResult.result != null) break;
5875
5871
  }
5876
5872
  return parseResult;
5877
5873
  }
@@ -5879,7 +5875,8 @@ var PluginDriver = (_d = class {
5879
5875
  * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
5880
5876
  */
5881
5877
  async hookParallel({ hookName, parameters }) {
5882
- const plugins = __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this, hookName);
5878
+ const plugins = [];
5879
+ for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
5883
5880
  this.events.emit("plugins:hook:progress:start", {
5884
5881
  hookName,
5885
5882
  plugins
@@ -5899,7 +5896,7 @@ var PluginDriver = (_d = class {
5899
5896
  results.forEach((result, index) => {
5900
5897
  var _a2;
5901
5898
  if (isPromiseRejectedResult(result)) {
5902
- const plugin = __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this, hookName)[index];
5899
+ const plugin = plugins[index];
5903
5900
  if (plugin) {
5904
5901
  const startTime = (_a2 = pluginStartTimes.get(plugin)) != null ? _a2 : performance$1.now();
5905
5902
  this.events.emit("error", result.reason, {
@@ -5922,7 +5919,8 @@ var PluginDriver = (_d = class {
5922
5919
  * Chains plugins
5923
5920
  */
5924
5921
  async hookSeq({ hookName, parameters }) {
5925
- const plugins = __privateMethod$c(this, _PluginDriver_instances, getSortedPlugins_fn).call(this, hookName);
5922
+ const plugins = [];
5923
+ for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
5926
5924
  this.events.emit("plugins:hook:progress:start", {
5927
5925
  hookName,
5928
5926
  plugins
@@ -5937,35 +5935,10 @@ var PluginDriver = (_d = class {
5937
5935
  }));
5938
5936
  this.events.emit("plugins:hook:progress:end", { hookName });
5939
5937
  }
5940
- getPluginByName(pluginName) {
5941
- return [...__privateGet$c(this, _plugins)].find((item) => item.name === pluginName);
5938
+ getPlugin(pluginName) {
5939
+ return this.plugins.get(pluginName);
5942
5940
  }
5943
- getPluginsByName(hookName, pluginName) {
5944
- const plugins = [...this.plugins];
5945
- const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
5946
- if (!(pluginByPluginName == null ? void 0 : pluginByPluginName.length)) {
5947
- const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
5948
- return corePlugin ? [corePlugin] : [];
5949
- }
5950
- return pluginByPluginName;
5951
- }
5952
- }, _studioIsOpen = new WeakMap(), _plugins = new WeakMap(), _usedPluginNames = new WeakMap(), _PluginDriver_instances = new WeakSet(), getSortedPlugins_fn = function(hookName) {
5953
- const plugins = [...__privateGet$c(this, _plugins)];
5954
- if (hookName) return plugins.filter((plugin) => hookName in plugin);
5955
- return plugins.map((plugin) => {
5956
- if (plugin.pre) {
5957
- let missingPlugins = plugin.pre.filter((pluginName) => !plugins.find((pluginToFind) => pluginToFind.name === pluginName));
5958
- if (missingPlugins.includes("plugin-oas") && this.adapter) missingPlugins = missingPlugins.filter((pluginName) => pluginName !== "plugin-oas");
5959
- if (missingPlugins.length > 0) throw new ValidationPluginError(`The plugin '${plugin.name}' has a pre set that references missing plugins for '${missingPlugins.join(", ")}'`);
5960
- }
5961
- return plugin;
5962
- }).sort((a, b) => {
5963
- var _a2, _b2;
5964
- if ((_a2 = b.pre) == null ? void 0 : _a2.includes(a.name)) return 1;
5965
- if ((_b2 = b.post) == null ? void 0 : _b2.includes(a.name)) return -1;
5966
- return 0;
5967
- });
5968
- }, /**
5941
+ }, _studioIsOpen = new WeakMap(), _PluginDriver_instances = new WeakSet(), /**
5969
5942
  * Run an async plugin hook and return the result.
5970
5943
  * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
5971
5944
  * @param args Arguments passed to the plugin hook.
@@ -6048,16 +6021,6 @@ executeSync_fn = function({ strategy, hookName, parameters, plugin }) {
6048
6021
  });
6049
6022
  return null;
6050
6023
  }
6051
- }, parse_fn = function(plugin) {
6052
- const usedPluginNames = __privateGet$c(this, _usedPluginNames);
6053
- setUniqueName(plugin.name, usedPluginNames);
6054
- const usageCount = usedPluginNames[plugin.name];
6055
- if (usageCount && usageCount > 1) throw new ValidationPluginError(`Duplicate plugin "${plugin.name}" detected. Each plugin can only be used once. Use a different configuration instead of adding multiple instances of the same plugin.`);
6056
- return {
6057
- install() {
6058
- },
6059
- ...plugin
6060
- };
6061
6024
  }, _d);
6062
6025
  function createStorage(build2) {
6063
6026
  return (options) => build2(options != null ? options : {});
@@ -6108,7 +6071,7 @@ const fsStorage = createStorage(() => ({
6108
6071
  await clean(resolve(base));
6109
6072
  }
6110
6073
  }));
6111
- var version$1 = "5.0.0-alpha.22";
6074
+ var version$1 = "5.0.0-alpha.23";
6112
6075
  function getDiagnosticInfo() {
6113
6076
  return {
6114
6077
  nodeVersion: version$2,
@@ -6252,7 +6215,7 @@ async function safeBuild(options, overrides) {
6252
6215
  const pluginTimings = /* @__PURE__ */ new Map();
6253
6216
  const config = driver.config;
6254
6217
  try {
6255
- for (const plugin of driver.plugins) {
6218
+ for (const plugin of driver.plugins.values()) {
6256
6219
  const context = driver.getContext(plugin);
6257
6220
  const hrStart = process.hrtime();
6258
6221
  const installer = plugin.install.bind(context);
@@ -6362,7 +6325,7 @@ async function safeBuild(options, overrides) {
6362
6325
  }
6363
6326
  function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }) {
6364
6327
  const pluginNameMap = /* @__PURE__ */ new Map();
6365
- for (const plugin of driver.plugins) pluginNameMap.set(plugin.name, plugin);
6328
+ for (const plugin of driver.plugins.values()) pluginNameMap.set(plugin.name, plugin);
6366
6329
  return barrelFiles.flatMap((file) => {
6367
6330
  var _a2, _b2;
6368
6331
  const containsOnlyTypes = (_a2 = file.sources) == null ? void 0 : _a2.every((source) => source.isTypeOnly);
@@ -6403,9 +6366,6 @@ function inputToAdapterSource(config) {
6403
6366
  function createPlugin(build2) {
6404
6367
  return (options) => build2(options != null ? options : {});
6405
6368
  }
6406
- function defineBuilder(build2) {
6407
- return build2();
6408
- }
6409
6369
  function defineGenerator(generator) {
6410
6370
  if (generator.type === "react") return {
6411
6371
  version: "2",
@@ -6434,14 +6394,6 @@ function defineGenerator(generator) {
6434
6394
  ...generator
6435
6395
  };
6436
6396
  }
6437
- function definePreset(name, { resolvers, transformers, generators }) {
6438
- return {
6439
- name,
6440
- resolvers,
6441
- transformers,
6442
- generators
6443
- };
6444
- }
6445
6397
  function definePresets(presets) {
6446
6398
  return presets;
6447
6399
  }
@@ -6500,13 +6452,7 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
6500
6452
  }
6501
6453
  function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root, output, group }) {
6502
6454
  if ((pathMode != null ? pathMode : getMode(path$2.resolve(root, output.path))) === "single") return path$2.resolve(root, output.path);
6503
- if (group && (groupPath || tag)) {
6504
- const groupName = group.name ? group.name : (ctx) => {
6505
- if (group.type === "path") return `${ctx.group.split("/")[1]}`;
6506
- return `${camelCase$e(ctx.group)}Controller`;
6507
- };
6508
- return path$2.resolve(root, output.path, groupName({ group: group.type === "path" ? groupPath : tag }), baseName);
6509
- }
6455
+ if (group && (groupPath || tag)) return path$2.resolve(root, output.path, group.name({ group: group.type === "path" ? groupPath : tag }), baseName);
6510
6456
  return path$2.resolve(root, output.path, baseName);
6511
6457
  }
6512
6458
  function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context) {
@@ -6582,19 +6528,15 @@ async function renderOperation$1(node, options) {
6582
6528
  const { config, fabric, plugin, Component, adapter, driver } = options;
6583
6529
  if (!Component) return;
6584
6530
  const fabricChild = createReactFabric();
6585
- await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
6586
- meta: {
6587
- plugin,
6588
- driver
6589
- },
6590
- children: /* @__PURE__ */ jsx(Component, {
6591
- config,
6592
- plugin,
6593
- adapter,
6594
- node,
6595
- options: options.options
6596
- })
6597
- }));
6531
+ await fabricChild.render(/* @__PURE__ */ jsx(Fabric, { children: /* @__PURE__ */ jsx(Component, {
6532
+ config,
6533
+ plugin,
6534
+ driver,
6535
+ adapter,
6536
+ node,
6537
+ options: options.options,
6538
+ resolver: options.resolver
6539
+ }) }));
6598
6540
  fabric.context.fileManager.upsert(...fabricChild.files);
6599
6541
  fabricChild.unmount();
6600
6542
  }
@@ -6602,19 +6544,15 @@ async function renderSchema$1(node, options) {
6602
6544
  const { config, fabric, plugin, Component, adapter, driver } = options;
6603
6545
  if (!Component) return;
6604
6546
  const fabricChild = createReactFabric();
6605
- await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
6606
- meta: {
6607
- plugin,
6608
- driver
6609
- },
6610
- children: /* @__PURE__ */ jsx(Component, {
6611
- config,
6612
- plugin,
6613
- adapter,
6614
- node,
6615
- options: options.options
6616
- })
6617
- }));
6547
+ await fabricChild.render(/* @__PURE__ */ jsx(Fabric, { children: /* @__PURE__ */ jsx(Component, {
6548
+ config,
6549
+ plugin,
6550
+ driver,
6551
+ adapter,
6552
+ node,
6553
+ options: options.options,
6554
+ resolver: options.resolver
6555
+ }) }));
6618
6556
  fabric.context.fileManager.upsert(...fabricChild.files);
6619
6557
  fabricChild.unmount();
6620
6558
  }
@@ -6967,7 +6905,10 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
6967
6905
  }
6968
6906
  async function getConfigs(config, args) {
6969
6907
  const resolved = await (typeof config === "function" ? config(args) : config);
6970
- return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({ ...item }));
6908
+ return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
6909
+ plugins: [],
6910
+ ...item
6911
+ }));
6971
6912
  }
6972
6913
  function mergeResolvers(...resolvers) {
6973
6914
  return resolvers.reduce((acc, curr) => ({
@@ -6977,7 +6918,7 @@ function mergeResolvers(...resolvers) {
6977
6918
  }
6978
6919
  function getPreset(params) {
6979
6920
  var _a2, _b2, _c2, _d2, _e2;
6980
- const { preset: presetName, presets, resolvers, transformers: userTransformers, generators: userGenerators } = params;
6921
+ const { preset: presetName, presets, resolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = params;
6981
6922
  const [defaultResolver2, ...userResolvers] = resolvers;
6982
6923
  const preset = presets[presetName];
6983
6924
  const resolver = mergeResolvers(mergeResolvers(defaultResolver2, ...(_a2 = preset == null ? void 0 : preset.resolvers) != null ? _a2 : []), ...userResolvers != null ? userResolvers : []);
@@ -7036,7 +6977,7 @@ function satisfiesDependency(dependency, version2, cwd) {
7036
6977
  return satisfies(semVer, version2);
7037
6978
  }
7038
6979
 
7039
- var version = "5.0.0-alpha.22";
6980
+ var version = "5.0.0-alpha.23";
7040
6981
 
7041
6982
  function isCommandMessage(msg) {
7042
6983
  return msg.type === "command";
@@ -7227,8 +7168,8 @@ async function loadConfig(resolvedConfigPath) {
7227
7168
  return configs[0];
7228
7169
  }
7229
7170
 
7230
- var __defProp$h = Object.defineProperty;
7231
- var __name$6 = (target, value) => __defProp$h(target, "name", {
7171
+ var __defProp$g = Object.defineProperty;
7172
+ var __name$5 = (target, value) => __defProp$g(target, "name", {
7232
7173
  value,
7233
7174
  configurable: true
7234
7175
  });
@@ -7362,11 +7303,11 @@ function isKeyword(meta, keyword) {
7362
7303
  return meta.keyword === keyword;
7363
7304
  }
7364
7305
 
7365
- var __defProp$g = Object.defineProperty;
7306
+ var __defProp$f = Object.defineProperty;
7366
7307
  var __typeError$b = (msg) => {
7367
7308
  throw TypeError(msg);
7368
7309
  };
7369
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7310
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7370
7311
  var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
7371
7312
  var __accessCheck$b = (obj, member, msg) => member.has(obj) || __typeError$b("Cannot " + msg);
7372
7313
  var __privateGet$b = (obj, member, getter) => (__accessCheck$b(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -8106,11 +8047,11 @@ function resolveServerUrl(server, overrides) {
8106
8047
  return url;
8107
8048
  }
8108
8049
 
8109
- var __defProp$f = Object.defineProperty;
8050
+ var __defProp$e = Object.defineProperty;
8110
8051
  var __typeError$a = (msg) => {
8111
8052
  throw TypeError(msg);
8112
8053
  };
8113
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8054
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8114
8055
  var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
8115
8056
  var __accessCheck$a = (obj, member, msg) => member.has(obj) || __typeError$a("Cannot " + msg);
8116
8057
  var __privateGet$a = (obj, member, getter) => (__accessCheck$a(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -9344,11 +9285,11 @@ function withRequiredRequestBodySchema(operationSchema) {
9344
9285
  };
9345
9286
  }
9346
9287
 
9347
- var __defProp$e = Object.defineProperty;
9288
+ var __defProp$d = Object.defineProperty;
9348
9289
  var __typeError$9 = (msg) => {
9349
9290
  throw TypeError(msg);
9350
9291
  };
9351
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9292
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9352
9293
  var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
9353
9294
  var __accessCheck$9 = (obj, member, msg) => member.has(obj) || __typeError$9("Cannot " + msg);
9354
9295
  var __privateGet$9 = (obj, member, getter) => (__accessCheck$9(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -9594,11 +9535,11 @@ function isParameterSchema(schemaName) {
9594
9535
  return lowerName.includes("pathparams") || lowerName.includes("queryparams") || lowerName.includes("headerparams");
9595
9536
  }
9596
9537
 
9597
- var __defProp$d = Object.defineProperty;
9538
+ var __defProp$c = Object.defineProperty;
9598
9539
  var __typeError$8 = (msg) => {
9599
9540
  throw TypeError(msg);
9600
9541
  };
9601
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9542
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9602
9543
  var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
9603
9544
  var __accessCheck$8 = (obj, member, msg) => member.has(obj) || __typeError$8("Cannot " + msg);
9604
9545
  var __privateGet$8 = (obj, member, getter) => (__accessCheck$8(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -9802,7 +9743,7 @@ function getParams$1$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }
9802
9743
  default: getDefaultValue((_b = typeSchemas.pathParams) == null ? void 0 : _b.schema)
9803
9744
  } : void 0 });
9804
9745
  }
9805
- __name$6(getParams$1$5, "getParams");
9746
+ __name$5(getParams$1$5, "getParams");
9806
9747
  function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }) {
9807
9748
  const path = new URLPath$7(operation.path);
9808
9749
  const params = getParams$1$5({
@@ -9983,7 +9924,7 @@ Client.getParams = getParams$d;
9983
9924
  function buildHeaders$1(contentType, hasHeaderParams) {
9984
9925
  return [contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0, hasHeaderParams ? "...headers" : void 0].filter(Boolean);
9985
9926
  }
9986
- __name$6(buildHeaders$1, "buildHeaders");
9927
+ __name$5(buildHeaders$1, "buildHeaders");
9987
9928
  function buildGenerics$1(typeSchemas) {
9988
9929
  var _a2, _b;
9989
9930
  const TError = `ResponseErrorConfig<${((_a2 = typeSchemas.errors) == null ? void 0 : _a2.map((item) => item.name).join(" | ")) || "Error"}>`;
@@ -9993,7 +9934,7 @@ function buildGenerics$1(typeSchemas) {
9993
9934
  ((_b = typeSchemas.request) == null ? void 0 : _b.name) || "unknown"
9994
9935
  ].filter(Boolean);
9995
9936
  }
9996
- __name$6(buildGenerics$1, "buildGenerics");
9937
+ __name$5(buildGenerics$1, "buildGenerics");
9997
9938
  function buildClientParams$1({ operation, path, baseURL, typeSchemas, isFormData, headers }) {
9998
9939
  var _a2, _b;
9999
9940
  return FunctionParams.factory({ config: {
@@ -10009,25 +9950,25 @@ function buildClientParams$1({ operation, path, baseURL, typeSchemas, isFormData
10009
9950
  }
10010
9951
  } });
10011
9952
  }
10012
- __name$6(buildClientParams$1, "buildClientParams");
9953
+ __name$5(buildClientParams$1, "buildClientParams");
10013
9954
  function buildRequestDataLine$1({ parser, zodSchemas, typeSchemas }) {
10014
9955
  var _a2, _b;
10015
9956
  if (parser === "zod" && ((_a2 = zodSchemas == null ? void 0 : zodSchemas.request) == null ? void 0 : _a2.name)) return `const requestData = ${zodSchemas.request.name}.parse(data)`;
10016
9957
  if ((_b = typeSchemas == null ? void 0 : typeSchemas.request) == null ? void 0 : _b.name) return "const requestData = data";
10017
9958
  return "";
10018
9959
  }
10019
- __name$6(buildRequestDataLine$1, "buildRequestDataLine");
9960
+ __name$5(buildRequestDataLine$1, "buildRequestDataLine");
10020
9961
  function buildFormDataLine$1(isFormData, hasRequest) {
10021
9962
  return isFormData && hasRequest ? "const formData = buildFormData(requestData)" : "";
10022
9963
  }
10023
- __name$6(buildFormDataLine$1, "buildFormDataLine");
9964
+ __name$5(buildFormDataLine$1, "buildFormDataLine");
10024
9965
  function buildReturnStatement$1({ dataReturnType, parser, zodSchemas }) {
10025
9966
  if (dataReturnType === "full" && parser === "zod" && zodSchemas) return `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`;
10026
9967
  if (dataReturnType === "data" && parser === "zod" && zodSchemas) return `return ${zodSchemas.response.name}.parse(res.data)`;
10027
9968
  if (dataReturnType === "full" && parser === "client") return "return res";
10028
9969
  return "return res.data";
10029
9970
  }
10030
- __name$6(buildReturnStatement$1, "buildReturnStatement");
9971
+ __name$5(buildReturnStatement$1, "buildReturnStatement");
10031
9972
  function generateMethod$1({ operation, name, typeSchemas, zodSchemas, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType }) {
10032
9973
  var _a2, _b;
10033
9974
  const path = new URLPath$7(operation.path, { casing: paramsCasing });
@@ -10074,7 +10015,7 @@ function generateMethod$1({ operation, name, typeSchemas, zodSchemas, baseURL, d
10074
10015
  ${methodBody}
10075
10016
  }`;
10076
10017
  }
10077
- __name$6(generateMethod$1, "generateMethod");
10018
+ __name$5(generateMethod$1, "generateMethod");
10078
10019
  function ClassClient({ name, isExportable = true, isIndexable = true, operations, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType, children }) {
10079
10020
  const classCode = `export class ${name} {
10080
10021
  #config: Partial<RequestConfig> & { client?: Client }
@@ -11451,157 +11392,6 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
11451
11392
  })] });
11452
11393
  }
11453
11394
 
11454
- var __defProp$c = Object.defineProperty;
11455
- var __name$5 = (target, value) => __defProp$c(target, "name", {
11456
- value,
11457
- configurable: true
11458
- });
11459
-
11460
- const builderTs = defineBuilder(() => ({
11461
- name: "default",
11462
- buildParams({ params, node, resolver }) {
11463
- return createSchema({
11464
- type: "object",
11465
- properties: params.map((param) => createProperty({
11466
- name: param.name,
11467
- required: param.required,
11468
- schema: createSchema({
11469
- type: "ref",
11470
- name: resolver.resolveParamName(node, param)
11471
- })
11472
- }))
11473
- });
11474
- },
11475
- buildData({ node, resolver }) {
11476
- var _a;
11477
- const pathParams = node.parameters.filter((p) => p.in === "path");
11478
- const queryParams = node.parameters.filter((p) => p.in === "query");
11479
- const headerParams = node.parameters.filter((p) => p.in === "header");
11480
- return createSchema({
11481
- type: "object",
11482
- deprecated: node.deprecated,
11483
- properties: [
11484
- createProperty({
11485
- name: "data",
11486
- schema: ((_a = node.requestBody) == null ? void 0 : _a.schema) ? createSchema({
11487
- type: "ref",
11488
- name: resolver.resolveDataTypedName(node),
11489
- optional: true
11490
- }) : createSchema({
11491
- type: "never",
11492
- optional: true
11493
- })
11494
- }),
11495
- createProperty({
11496
- name: "pathParams",
11497
- required: pathParams.length > 0,
11498
- schema: pathParams.length > 0 ? this.buildParams({
11499
- params: pathParams,
11500
- node,
11501
- resolver
11502
- }) : createSchema({ type: "never" })
11503
- }),
11504
- createProperty({
11505
- name: "queryParams",
11506
- schema: queryParams.length > 0 ? createSchema({
11507
- ...this.buildParams({
11508
- params: queryParams,
11509
- node,
11510
- resolver
11511
- }),
11512
- optional: true
11513
- }) : createSchema({
11514
- type: "never",
11515
- optional: true
11516
- })
11517
- }),
11518
- createProperty({
11519
- name: "headerParams",
11520
- schema: headerParams.length > 0 ? createSchema({
11521
- ...this.buildParams({
11522
- params: headerParams,
11523
- node,
11524
- resolver
11525
- }),
11526
- optional: true
11527
- }) : createSchema({
11528
- type: "never",
11529
- optional: true
11530
- })
11531
- }),
11532
- createProperty({
11533
- name: "url",
11534
- required: true,
11535
- schema: createSchema({
11536
- type: "url",
11537
- path: node.path
11538
- })
11539
- })
11540
- ]
11541
- });
11542
- },
11543
- buildResponses({ node, resolver }) {
11544
- if (node.responses.length === 0) return null;
11545
- return createSchema({
11546
- type: "object",
11547
- properties: node.responses.map((res) => createProperty({
11548
- name: String(res.statusCode),
11549
- required: true,
11550
- schema: createSchema({
11551
- type: "ref",
11552
- name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
11553
- })
11554
- }))
11555
- });
11556
- },
11557
- buildResponseUnion({ node, resolver }) {
11558
- const responsesWithSchema = node.responses.filter((res) => res.schema);
11559
- if (responsesWithSchema.length === 0) return null;
11560
- return createSchema({
11561
- type: "union",
11562
- members: responsesWithSchema.map((res) => createSchema({
11563
- type: "ref",
11564
- name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
11565
- }))
11566
- });
11567
- }
11568
- }));
11569
-
11570
- function toCamelOrPascal$a(text, pascal) {
11571
- return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
11572
- if (word.length > 1 && word === word.toUpperCase()) return word;
11573
- if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
11574
- return word.charAt(0).toUpperCase() + word.slice(1);
11575
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
11576
- }
11577
- function applyToFileParts$a(text, transformPart) {
11578
- const parts = text.split(/\.(?=[a-zA-Z])/);
11579
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
11580
- }
11581
- function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
11582
- if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
11583
- prefix,
11584
- suffix
11585
- } : {}));
11586
- return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
11587
- }
11588
- function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
11589
- if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
11590
- prefix,
11591
- suffix
11592
- }) : camelCase$a(part));
11593
- return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
11594
- }
11595
- function snakeCase(text, { prefix = "", suffix = "" } = {}) {
11596
- return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
11597
- }
11598
- function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
11599
- return snakeCase(text, {
11600
- prefix,
11601
- suffix
11602
- }).toUpperCase();
11603
- }
11604
-
11605
11395
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : "undefined" !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11606
11396
 
11607
11397
  function getDefaultExportFromCjs (x) {
@@ -209486,6 +209276,40 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
209486
209276
  var typescriptExports = typescript.exports;
209487
209277
  const ts = /*@__PURE__*/getDefaultExportFromCjs(typescriptExports);
209488
209278
 
209279
+ function toCamelOrPascal$a(text, pascal) {
209280
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
209281
+ if (word.length > 1 && word === word.toUpperCase()) return word;
209282
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
209283
+ return word.charAt(0).toUpperCase() + word.slice(1);
209284
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
209285
+ }
209286
+ function applyToFileParts$a(text, transformPart) {
209287
+ const parts = text.split(/\.(?=[a-zA-Z])/);
209288
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
209289
+ }
209290
+ function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
209291
+ if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
209292
+ prefix,
209293
+ suffix
209294
+ } : {}));
209295
+ return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
209296
+ }
209297
+ function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
209298
+ if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
209299
+ prefix,
209300
+ suffix
209301
+ }) : camelCase$a(part));
209302
+ return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
209303
+ }
209304
+ function snakeCase(text, { prefix = "", suffix = "" } = {}) {
209305
+ return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
209306
+ }
209307
+ function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
209308
+ return snakeCase(text, {
209309
+ prefix,
209310
+ suffix
209311
+ }).toUpperCase();
209312
+ }
209489
209313
  function trimQuotes$1(text) {
209490
209314
  if (text.length >= 2) {
209491
209315
  const first = text[0];
@@ -209697,8 +209521,8 @@ const keywordTypeNodes = {
209697
209521
  null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword)),
209698
209522
  never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)
209699
209523
  };
209700
- function createUrlTemplateType(path) {
209701
- const normalized = path.replace(/:([^/]+)/g, "{$1}");
209524
+ function createUrlTemplateType(path2) {
209525
+ const normalized = path2.replace(/:([^/]+)/g, "{$1}");
209702
209526
  if (!normalized.includes("{")) return factory.createLiteralTypeNode(factory.createStringLiteral(normalized));
209703
209527
  const segments = normalized.split(/(\{[^}]+\})/);
209704
209528
  const parts = [];
@@ -209736,6 +209560,43 @@ const createFalse = factory.createFalse;
209736
209560
  factory.createIndexedAccessTypeNode;
209737
209561
  factory.createTypeOperatorNode;
209738
209562
  const createPrefixUnaryExpression = factory.createPrefixUnaryExpression;
209563
+ function getEnumNames({ node, enumType, enumTypeSuffix, resolver }) {
209564
+ const resolved = resolver.default(node.name, "type");
209565
+ return {
209566
+ enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
209567
+ typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolved,
209568
+ refName: resolved
209569
+ };
209570
+ }
209571
+ function Enum({ node, enumType, enumTypeSuffix, enumKeyCasing, resolver }) {
209572
+ var _a, _b, _c, _d;
209573
+ const { enumName, typeName } = getEnumNames({
209574
+ node,
209575
+ enumType,
209576
+ enumTypeSuffix,
209577
+ resolver
209578
+ });
209579
+ const [nameNode, typeNode] = createEnumDeclaration({
209580
+ name: enumName,
209581
+ typeName,
209582
+ enums: (_d = (_c = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => [trimQuotes$1(v.name.toString()), v.value])) != null ? _c : (_b = node.enumValues) == null ? void 0 : _b.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes$1(v.toString()), v])) != null ? _d : [],
209583
+ type: enumType,
209584
+ enumKeyCasing
209585
+ });
209586
+ return /* @__PURE__ */ jsxs(Fragment, { children: [nameNode && /* @__PURE__ */ jsx(File.Source, {
209587
+ name: enumName,
209588
+ isExportable: true,
209589
+ isIndexable: true,
209590
+ isTypeOnly: false,
209591
+ children: safePrint(nameNode)
209592
+ }), /* @__PURE__ */ jsx(File.Source, {
209593
+ name: typeName,
209594
+ isIndexable: true,
209595
+ isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
209596
+ isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
209597
+ children: safePrint(typeNode)
209598
+ })] });
209599
+ }
209739
209600
  function constToTypeNode(value, format) {
209740
209601
  if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
209741
209602
  if (format === "number" && typeof value === "number") {
@@ -209839,7 +209700,7 @@ const printerTs = definePrinter((options) => {
209839
209700
  withParentheses: true,
209840
209701
  nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
209841
209702
  })) != null ? _d : void 0;
209842
- return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyTypedName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
209703
+ return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
209843
209704
  },
209844
209705
  union(node) {
209845
209706
  var _a, _b, _c;
@@ -209882,11 +209743,11 @@ const printerTs = definePrinter((options) => {
209882
209743
  return buildTupleNode(node, this.transform);
209883
209744
  },
209884
209745
  object(node) {
209885
- const { transform, options: options2 } = this;
209746
+ const { transform: transform2, options: options2 } = this;
209886
209747
  const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
209887
209748
  const propertyNodes = node.properties.map((prop) => {
209888
209749
  var _a;
209889
- const baseType = (_a = transform(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
209750
+ const baseType = (_a = transform2(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
209890
209751
  const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
209891
209752
  return appendJSDocToNode({
209892
209753
  node: createPropertySignature({
@@ -209898,7 +209759,7 @@ const printerTs = definePrinter((options) => {
209898
209759
  comments: buildPropertyJSDocComments(prop.schema)
209899
209760
  });
209900
209761
  });
209901
- const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform)];
209762
+ const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform2)];
209902
209763
  if (!allElements.length) return keywordTypeNodes.object;
209903
209764
  return createTypeLiteralNode(allElements);
209904
209765
  }
@@ -209908,11 +209769,11 @@ const printerTs = definePrinter((options) => {
209908
209769
  if (!type) return null;
209909
209770
  if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
209910
209771
  if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209911
- const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
209912
- if (!typeName) return safePrint(type);
209772
+ const { name, syntaxType = "type", description, keysToOmit } = this.options;
209773
+ if (!name) return safePrint(type);
209913
209774
  const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
209914
209775
  return safePrint(createTypeDeclaration({
209915
- name: typeName,
209776
+ name,
209916
209777
  isExportable: true,
209917
209778
  type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
209918
209779
  keys: keysToOmit,
@@ -209934,45 +209795,7 @@ const printerTs = definePrinter((options) => {
209934
209795
  }
209935
209796
  };
209936
209797
  });
209937
-
209938
- function getEnumNames({ node, enumType, enumTypeSuffix, resolver }) {
209939
- const resolved = resolver.default(node.name, "type");
209940
- return {
209941
- enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
209942
- typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? resolver.resolveEnumKeyTypedName(node, enumTypeSuffix) : resolved,
209943
- refName: resolved
209944
- };
209945
- }
209946
- function Enum({ node, enumType, enumTypeSuffix, enumKeyCasing, resolver }) {
209947
- var _a, _b, _c, _d;
209948
- const { enumName, typeName } = getEnumNames({
209949
- node,
209950
- enumType,
209951
- enumTypeSuffix,
209952
- resolver
209953
- });
209954
- const [nameNode, typeNode] = createEnumDeclaration({
209955
- name: enumName,
209956
- typeName,
209957
- enums: (_d = (_c = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => [trimQuotes$1(v.name.toString()), v.value])) != null ? _c : (_b = node.enumValues) == null ? void 0 : _b.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes$1(v.toString()), v])) != null ? _d : [],
209958
- type: enumType,
209959
- enumKeyCasing
209960
- });
209961
- return /* @__PURE__ */ jsxs(Fragment, { children: [nameNode && /* @__PURE__ */ jsx(File.Source, {
209962
- name: enumName,
209963
- isExportable: true,
209964
- isIndexable: true,
209965
- isTypeOnly: false,
209966
- children: safePrint(nameNode)
209967
- }), /* @__PURE__ */ jsx(File.Source, {
209968
- name: typeName,
209969
- isIndexable: true,
209970
- isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
209971
- isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
209972
- children: safePrint(typeNode)
209973
- })] });
209974
- }
209975
- function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumTypeSuffix, enumKeyCasing, description, resolver }) {
209798
+ function Type({ name, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumTypeSuffix, enumKeyCasing, description, resolver }) {
209976
209799
  const resolvedDescription = description || (node == null ? void 0 : node.description);
209977
209800
  const enumSchemaNodes = collect(node, { schema(n) {
209978
209801
  const enumNode = narrowSchema(n, schemaTypes.enum);
@@ -209983,7 +209806,7 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
209983
209806
  arrayType,
209984
209807
  enumType,
209985
209808
  enumTypeSuffix,
209986
- typeName: name,
209809
+ name,
209987
209810
  syntaxType,
209988
209811
  description: resolvedDescription,
209989
209812
  keysToOmit,
@@ -210010,156 +209833,125 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
210010
209833
  enumKeyCasing,
210011
209834
  resolver
210012
209835
  })), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
210013
- name: typedName,
209836
+ name,
210014
209837
  isTypeOnly: true,
210015
209838
  isExportable: true,
210016
209839
  isIndexable: true,
210017
209840
  children: output
210018
209841
  })] });
210019
209842
  }
210020
-
210021
- function resolveName(name, type) {
210022
- return pascalCase$6(name, { isFile: type === "file" });
209843
+ function buildParams({ params, node, resolver }) {
209844
+ return createSchema({
209845
+ type: "object",
209846
+ properties: params.map((param) => createProperty({
209847
+ name: param.name,
209848
+ required: param.required,
209849
+ schema: createSchema({
209850
+ type: "ref",
209851
+ name: resolver.resolveParamName(node, param)
209852
+ })
209853
+ }))
209854
+ });
209855
+ }
209856
+ function buildData({ node, resolver }) {
209857
+ var _a;
209858
+ const pathParams = node.parameters.filter((p) => p.in === "path");
209859
+ const queryParams = node.parameters.filter((p) => p.in === "query");
209860
+ const headerParams = node.parameters.filter((p) => p.in === "header");
209861
+ return createSchema({
209862
+ type: "object",
209863
+ deprecated: node.deprecated,
209864
+ properties: [
209865
+ createProperty({
209866
+ name: "data",
209867
+ schema: ((_a = node.requestBody) == null ? void 0 : _a.schema) ? createSchema({
209868
+ type: "ref",
209869
+ name: resolver.resolveDataName(node),
209870
+ optional: true
209871
+ }) : createSchema({
209872
+ type: "never",
209873
+ optional: true
209874
+ })
209875
+ }),
209876
+ createProperty({
209877
+ name: "pathParams",
209878
+ required: pathParams.length > 0,
209879
+ schema: pathParams.length > 0 ? buildParams({
209880
+ params: pathParams,
209881
+ node,
209882
+ resolver
209883
+ }) : createSchema({ type: "never" })
209884
+ }),
209885
+ createProperty({
209886
+ name: "queryParams",
209887
+ schema: queryParams.length > 0 ? createSchema({
209888
+ ...buildParams({
209889
+ params: queryParams,
209890
+ node,
209891
+ resolver
209892
+ }),
209893
+ optional: true
209894
+ }) : createSchema({
209895
+ type: "never",
209896
+ optional: true
209897
+ })
209898
+ }),
209899
+ createProperty({
209900
+ name: "headerParams",
209901
+ schema: headerParams.length > 0 ? createSchema({
209902
+ ...buildParams({
209903
+ params: headerParams,
209904
+ node,
209905
+ resolver
209906
+ }),
209907
+ optional: true
209908
+ }) : createSchema({
209909
+ type: "never",
209910
+ optional: true
209911
+ })
209912
+ }),
209913
+ createProperty({
209914
+ name: "url",
209915
+ required: true,
209916
+ schema: createSchema({
209917
+ type: "url",
209918
+ path: node.path
209919
+ })
209920
+ })
209921
+ ]
209922
+ });
209923
+ }
209924
+ function buildResponses({ node, resolver }) {
209925
+ if (node.responses.length === 0) return null;
209926
+ return createSchema({
209927
+ type: "object",
209928
+ properties: node.responses.map((res) => createProperty({
209929
+ name: String(res.statusCode),
209930
+ required: true,
209931
+ schema: createSchema({
209932
+ type: "ref",
209933
+ name: resolver.resolveResponseStatusName(node, res.statusCode)
209934
+ })
209935
+ }))
209936
+ });
209937
+ }
209938
+ function buildResponseUnion({ node, resolver }) {
209939
+ const responsesWithSchema = node.responses.filter((res) => res.schema);
209940
+ if (responsesWithSchema.length === 0) return null;
209941
+ return createSchema({
209942
+ type: "union",
209943
+ members: responsesWithSchema.map((res) => createSchema({
209944
+ type: "ref",
209945
+ name: resolver.resolveResponseStatusName(node, res.statusCode)
209946
+ }))
209947
+ });
210023
209948
  }
210024
- const resolverTs = defineResolver(() => {
210025
- return {
210026
- name: "default",
210027
- pluginName: "plugin-ts",
210028
- default(name, type) {
210029
- return resolveName(name, type);
210030
- },
210031
- resolveName(name) {
210032
- return this.default(name, "function");
210033
- },
210034
- resolveTypedName(name) {
210035
- return this.default(name, "type");
210036
- },
210037
- resolvePathName(name, type) {
210038
- return this.default(name, type);
210039
- },
210040
- resolveParamName(node, param) {
210041
- return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210042
- },
210043
- resolveParamTypedName(node, param) {
210044
- return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210045
- },
210046
- resolveResponseStatusName(node, statusCode) {
210047
- return this.resolveName(`${node.operationId} Status ${statusCode}`);
210048
- },
210049
- resolveResponseStatusTypedName(node, statusCode) {
210050
- return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
210051
- },
210052
- resolveDataName(node) {
210053
- return this.resolveName(`${node.operationId} Data`);
210054
- },
210055
- resolveDataTypedName(node) {
210056
- return this.resolveTypedName(`${node.operationId} Data`);
210057
- },
210058
- resolveRequestConfigName(node) {
210059
- return this.resolveName(`${node.operationId} RequestConfig`);
210060
- },
210061
- resolveRequestConfigTypedName(node) {
210062
- return this.resolveTypedName(`${node.operationId} RequestConfig`);
210063
- },
210064
- resolveResponsesName(node) {
210065
- return this.resolveName(`${node.operationId} Responses`);
210066
- },
210067
- resolveResponsesTypedName(node) {
210068
- return this.resolveTypedName(`${node.operationId} Responses`);
210069
- },
210070
- resolveResponseName(node) {
210071
- return this.resolveName(`${node.operationId} Response`);
210072
- },
210073
- resolveResponseTypedName(node) {
210074
- return this.resolveTypedName(`${node.operationId} Response`);
210075
- },
210076
- resolveEnumKeyTypedName(node, enumTypeSuffix = "key") {
210077
- var _a;
210078
- return `${this.resolveTypedName((_a = node.name) != null ? _a : "")}${enumTypeSuffix}`;
210079
- },
210080
- resolvePathParamsName(_node) {
210081
- throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
210082
- },
210083
- resolvePathParamsTypedName(_node) {
210084
- throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
210085
- },
210086
- resolveQueryParamsName(_node) {
210087
- throw new Error("resolveQueryParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
210088
- },
210089
- resolveQueryParamsTypedName(_node) {
210090
- throw new Error("resolveQueryParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
210091
- },
210092
- resolveHeaderParamsName(_node) {
210093
- throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
210094
- },
210095
- resolveHeaderParamsTypedName(_node) {
210096
- throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
210097
- }
210098
- };
210099
- });
210100
- const resolverTsLegacy = defineResolver(() => {
210101
- return {
210102
- ...resolverTs,
210103
- pluginName: "plugin-ts",
210104
- resolveResponseStatusName(node, statusCode) {
210105
- if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
210106
- return this.resolveName(`${node.operationId} ${statusCode}`);
210107
- },
210108
- resolveResponseStatusTypedName(node, statusCode) {
210109
- if (statusCode === "default") return this.resolveTypedName(`${node.operationId} Error`);
210110
- return this.resolveTypedName(`${node.operationId} ${statusCode}`);
210111
- },
210112
- resolveDataName(node) {
210113
- const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
210114
- return this.resolveName(`${node.operationId} ${suffix}`);
210115
- },
210116
- resolveDataTypedName(node) {
210117
- const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
210118
- return this.resolveTypedName(`${node.operationId} ${suffix}`);
210119
- },
210120
- resolveResponsesName(node) {
210121
- const suffix = node.method === "GET" ? "Query" : "Mutation";
210122
- return `${this.default(node.operationId, "function")}${suffix}`;
210123
- },
210124
- resolveResponsesTypedName(node) {
210125
- const suffix = node.method === "GET" ? "Query" : "Mutation";
210126
- return `${this.default(node.operationId, "type")}${suffix}`;
210127
- },
210128
- resolveResponseName(node) {
210129
- const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
210130
- return this.resolveName(`${node.operationId} ${suffix}`);
210131
- },
210132
- resolveResponseTypedName(node) {
210133
- const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
210134
- return this.resolveTypedName(`${node.operationId} ${suffix}`);
210135
- },
210136
- resolvePathParamsName(node) {
210137
- return this.resolveName(`${node.operationId} PathParams`);
210138
- },
210139
- resolvePathParamsTypedName(node) {
210140
- return this.resolveTypedName(`${node.operationId} PathParams`);
210141
- },
210142
- resolveQueryParamsName(node) {
210143
- return this.resolveName(`${node.operationId} QueryParams`);
210144
- },
210145
- resolveQueryParamsTypedName(node) {
210146
- return this.resolveTypedName(`${node.operationId} QueryParams`);
210147
- },
210148
- resolveHeaderParamsName(node) {
210149
- return this.resolveName(`${node.operationId} HeaderParams`);
210150
- },
210151
- resolveHeaderParamsTypedName(node) {
210152
- return this.resolveTypedName(`${node.operationId} HeaderParams`);
210153
- }
210154
- };
210155
- });
210156
-
210157
209949
  const typeGenerator = defineGenerator({
210158
209950
  name: "typescript",
210159
209951
  type: "react",
210160
- Operation({ node, adapter, options, config }) {
209952
+ Operation({ node, adapter, options, config, resolver }) {
210161
209953
  var _a, _b, _c;
210162
- const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, resolver, transformers = [] } = options;
209954
+ const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, transformers = [] } = options;
210163
209955
  const root = path$2.resolve(config.root, config.output.path);
210164
209956
  const mode = getMode(path$2.resolve(root, output.path));
210165
209957
  const file = resolver.resolveFile({
@@ -210173,7 +209965,7 @@ const typeGenerator = defineGenerator({
210173
209965
  group
210174
209966
  });
210175
209967
  const params = caseParams(node.parameters, paramsCasing);
210176
- function renderSchemaType({ node: schemaNode, name, typedName, description, keysToOmit }) {
209968
+ function renderSchemaType({ node: schemaNode, name, description, keysToOmit }) {
210177
209969
  if (!schemaNode) return null;
210178
209970
  const transformedNode = transform(schemaNode, composeTransformers(...transformers));
210179
209971
  const imports = adapter.getImports(transformedNode, (schemaName) => ({
@@ -210198,7 +209990,6 @@ const typeGenerator = defineGenerator({
210198
209990
  imp.isTypeOnly
210199
209991
  ].join("-"))), /* @__PURE__ */ jsx(Type, {
210200
209992
  name,
210201
- typedName,
210202
209993
  node: transformedNode,
210203
209994
  description,
210204
209995
  enumType,
@@ -210213,49 +210004,43 @@ const typeGenerator = defineGenerator({
210213
210004
  }
210214
210005
  const paramTypes = params.map((param) => renderSchemaType({
210215
210006
  node: param.schema,
210216
- name: resolver.resolveParamName(node, param),
210217
- typedName: resolver.resolveParamTypedName(node, param)
210007
+ name: resolver.resolveParamName(node, param)
210218
210008
  }));
210219
210009
  const requestType = ((_b = node.requestBody) == null ? void 0 : _b.schema) ? renderSchemaType({
210220
210010
  node: node.requestBody.schema,
210221
210011
  name: resolver.resolveDataName(node),
210222
- typedName: resolver.resolveDataTypedName(node),
210223
210012
  description: (_c = node.requestBody.description) != null ? _c : node.requestBody.schema.description,
210224
210013
  keysToOmit: node.requestBody.keysToOmit
210225
210014
  }) : null;
210226
210015
  const responseTypes = node.responses.map((res) => renderSchemaType({
210227
210016
  node: res.schema,
210228
210017
  name: resolver.resolveResponseStatusName(node, res.statusCode),
210229
- typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
210230
210018
  description: res.description,
210231
210019
  keysToOmit: res.keysToOmit
210232
210020
  }));
210233
210021
  const dataType = renderSchemaType({
210234
- node: builderTs.buildData({
210022
+ node: buildData({
210235
210023
  node: {
210236
210024
  ...node,
210237
210025
  parameters: params
210238
210026
  },
210239
210027
  resolver
210240
210028
  }),
210241
- name: resolver.resolveRequestConfigName(node),
210242
- typedName: resolver.resolveRequestConfigTypedName(node)
210029
+ name: resolver.resolveRequestConfigName(node)
210243
210030
  });
210244
210031
  const responsesType = renderSchemaType({
210245
- node: builderTs.buildResponses({
210032
+ node: buildResponses({
210246
210033
  node,
210247
210034
  resolver
210248
210035
  }),
210249
- name: resolver.resolveResponsesName(node),
210250
- typedName: resolver.resolveResponsesTypedName(node)
210036
+ name: resolver.resolveResponsesName(node)
210251
210037
  });
210252
210038
  const responseType = renderSchemaType({
210253
- node: builderTs.buildResponseUnion({
210039
+ node: buildResponseUnion({
210254
210040
  node,
210255
210041
  resolver
210256
210042
  }),
210257
210043
  name: resolver.resolveResponseName(node),
210258
- typedName: resolver.resolveResponseTypedName(node),
210259
210044
  description: "Union of all possible responses"
210260
210045
  });
210261
210046
  return /* @__PURE__ */ jsxs(File, {
@@ -210280,8 +210065,8 @@ const typeGenerator = defineGenerator({
210280
210065
  ]
210281
210066
  });
210282
210067
  },
210283
- Schema({ node, adapter, options, config }) {
210284
- const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, resolver, transformers = [] } = options;
210068
+ Schema({ node, adapter, options, config, resolver }) {
210069
+ const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, transformers = [] } = options;
210285
210070
  const root = path$2.resolve(config.root, config.output.path);
210286
210071
  const mode = getMode(path$2.resolve(root, output.path));
210287
210072
  if (!node.name) return;
@@ -210298,10 +210083,8 @@ const typeGenerator = defineGenerator({
210298
210083
  }).path
210299
210084
  }));
210300
210085
  const isEnumSchema = !!narrowSchema(node, schemaTypes.enum);
210301
- const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyTypedName(node, enumTypeSuffix) : resolver.resolveTypedName(node.name);
210302
210086
  const type = {
210303
- name: resolver.resolveName(node.name),
210304
- typedName,
210087
+ name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolver.resolveName(node.name),
210305
210088
  file: resolver.resolveFile({
210306
210089
  name: node.name,
210307
210090
  extname: ".ts"
@@ -210334,7 +210117,6 @@ const typeGenerator = defineGenerator({
210334
210117
  imp.isTypeOnly
210335
210118
  ].join("-"))), /* @__PURE__ */ jsx(Type, {
210336
210119
  name: type.name,
210337
- typedName: type.typedName,
210338
210120
  node: transformedNode,
210339
210121
  enumType,
210340
210122
  enumTypeSuffix,
@@ -210347,6 +210129,86 @@ const typeGenerator = defineGenerator({
210347
210129
  });
210348
210130
  }
210349
210131
  });
210132
+ function resolveName(name, type) {
210133
+ return pascalCase$6(name, { isFile: type === "file" });
210134
+ }
210135
+ const resolverTs = defineResolver(() => {
210136
+ return {
210137
+ name: "default",
210138
+ pluginName: "plugin-ts",
210139
+ default(name, type) {
210140
+ return resolveName(name, type);
210141
+ },
210142
+ resolveName(name) {
210143
+ return this.default(name, "function");
210144
+ },
210145
+ resolvePathName(name, type) {
210146
+ return this.default(name, type);
210147
+ },
210148
+ resolveParamName(node, param) {
210149
+ return this.resolveName(`${node.operationId} ${param.in} ${param.name}`);
210150
+ },
210151
+ resolveResponseStatusName(node, statusCode) {
210152
+ return this.resolveName(`${node.operationId} Status ${statusCode}`);
210153
+ },
210154
+ resolveDataName(node) {
210155
+ return this.resolveName(`${node.operationId} Data`);
210156
+ },
210157
+ resolveRequestConfigName(node) {
210158
+ return this.resolveName(`${node.operationId} RequestConfig`);
210159
+ },
210160
+ resolveResponsesName(node) {
210161
+ return this.resolveName(`${node.operationId} Responses`);
210162
+ },
210163
+ resolveResponseName(node) {
210164
+ return this.resolveName(`${node.operationId} Response`);
210165
+ },
210166
+ resolveEnumKeyName(node, enumTypeSuffix = "key") {
210167
+ var _a;
210168
+ return `${this.resolveName((_a = node.name) != null ? _a : "")}${enumTypeSuffix}`;
210169
+ },
210170
+ resolvePathParamsName(node, param) {
210171
+ return this.resolveParamName(node, param);
210172
+ },
210173
+ resolveQueryParamsName(node, param) {
210174
+ return this.resolveParamName(node, param);
210175
+ },
210176
+ resolveHeaderParamsName(node, param) {
210177
+ return this.resolveParamName(node, param);
210178
+ }
210179
+ };
210180
+ });
210181
+ const resolverTsLegacy = defineResolver(() => {
210182
+ return {
210183
+ ...resolverTs,
210184
+ pluginName: "plugin-ts",
210185
+ resolveResponseStatusName(node, statusCode) {
210186
+ if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
210187
+ return this.resolveName(`${node.operationId} ${statusCode}`);
210188
+ },
210189
+ resolveDataName(node) {
210190
+ const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
210191
+ return this.resolveName(`${node.operationId} ${suffix}`);
210192
+ },
210193
+ resolveResponsesName(node) {
210194
+ const suffix = node.method === "GET" ? "Query" : "Mutation";
210195
+ return this.resolveName(`${node.operationId} ${suffix}`);
210196
+ },
210197
+ resolveResponseName(node) {
210198
+ const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
210199
+ return this.resolveName(`${node.operationId} ${suffix}`);
210200
+ },
210201
+ resolvePathParamsName(node, _param) {
210202
+ return this.resolveName(`${node.operationId} PathParams`);
210203
+ },
210204
+ resolveQueryParamsName(node, _param) {
210205
+ return this.resolveName(`${node.operationId} QueryParams`);
210206
+ },
210207
+ resolveHeaderParamsName(node, _param) {
210208
+ return this.resolveName(`${node.operationId} HeaderParams`);
210209
+ }
210210
+ };
210211
+ });
210350
210212
  function buildGroupedParamsSchema({ params, parentName }) {
210351
210213
  return createSchema({
210352
210214
  type: "object",
@@ -210378,22 +210240,22 @@ function buildLegacyResponsesSchemaNode({ node, resolver }) {
210378
210240
  const errorResponses = node.responses.filter((res) => res.statusCode === "default" || Number(res.statusCode) >= 400);
210379
210241
  const responseSchema = successResponses.length > 0 ? successResponses.length === 1 ? createSchema({
210380
210242
  type: "ref",
210381
- name: resolver.resolveResponseStatusTypedName(node, successResponses[0].statusCode)
210243
+ name: resolver.resolveResponseStatusName(node, successResponses[0].statusCode)
210382
210244
  }) : createSchema({
210383
210245
  type: "union",
210384
210246
  members: successResponses.map((res) => createSchema({
210385
210247
  type: "ref",
210386
- name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
210248
+ name: resolver.resolveResponseStatusName(node, res.statusCode)
210387
210249
  }))
210388
210250
  }) : createSchema({ type: "any" });
210389
210251
  const errorsSchema = errorResponses.length > 0 ? errorResponses.length === 1 ? createSchema({
210390
210252
  type: "ref",
210391
- name: resolver.resolveResponseStatusTypedName(node, errorResponses[0].statusCode)
210253
+ name: resolver.resolveResponseStatusName(node, errorResponses[0].statusCode)
210392
210254
  }) : createSchema({
210393
210255
  type: "union",
210394
210256
  members: errorResponses.map((res) => createSchema({
210395
210257
  type: "ref",
210396
- name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
210258
+ name: resolver.resolveResponseStatusName(node, res.statusCode)
210397
210259
  }))
210398
210260
  }) : createSchema({ type: "any" });
210399
210261
  const properties = [createProperty({
@@ -210406,31 +210268,34 @@ function buildLegacyResponsesSchemaNode({ node, resolver }) {
210406
210268
  required: true,
210407
210269
  schema: createSchema({
210408
210270
  type: "ref",
210409
- name: resolver.resolveDataTypedName(node)
210271
+ name: resolver.resolveDataName(node)
210410
210272
  })
210411
210273
  }));
210412
- if (node.parameters.some((p) => p.in === "query") && resolver.resolveQueryParamsTypedName) properties.push(createProperty({
210274
+ const queryParam = node.parameters.find((p) => p.in === "query");
210275
+ if (queryParam) properties.push(createProperty({
210413
210276
  name: "QueryParams",
210414
210277
  required: true,
210415
210278
  schema: createSchema({
210416
210279
  type: "ref",
210417
- name: resolver.resolveQueryParamsTypedName(node)
210280
+ name: resolver.resolveQueryParamsName(node, queryParam)
210418
210281
  })
210419
210282
  }));
210420
- if (node.parameters.some((p) => p.in === "path") && resolver.resolvePathParamsTypedName) properties.push(createProperty({
210283
+ const pathParam = node.parameters.find((p) => p.in === "path");
210284
+ if (pathParam) properties.push(createProperty({
210421
210285
  name: "PathParams",
210422
210286
  required: true,
210423
210287
  schema: createSchema({
210424
210288
  type: "ref",
210425
- name: resolver.resolvePathParamsTypedName(node)
210289
+ name: resolver.resolvePathParamsName(node, pathParam)
210426
210290
  })
210427
210291
  }));
210428
- if (node.parameters.some((p) => p.in === "header") && resolver.resolveHeaderParamsTypedName) properties.push(createProperty({
210292
+ const headerParam = node.parameters.find((p) => p.in === "header");
210293
+ if (headerParam) properties.push(createProperty({
210429
210294
  name: "HeaderParams",
210430
210295
  required: true,
210431
210296
  schema: createSchema({
210432
210297
  type: "ref",
210433
- name: resolver.resolveHeaderParamsTypedName(node)
210298
+ name: resolver.resolveHeaderParamsName(node, headerParam)
210434
210299
  })
210435
210300
  }));
210436
210301
  properties.push(createProperty({
@@ -210451,13 +210316,13 @@ function buildLegacyResponseUnionSchemaNode({ node, resolver }) {
210451
210316
  if (successResponses.length === 0) return createSchema({ type: "any" });
210452
210317
  if (successResponses.length === 1) return createSchema({
210453
210318
  type: "ref",
210454
- name: resolver.resolveResponseStatusTypedName(node, successResponses[0].statusCode)
210319
+ name: resolver.resolveResponseStatusName(node, successResponses[0].statusCode)
210455
210320
  });
210456
210321
  return createSchema({
210457
210322
  type: "union",
210458
210323
  members: successResponses.map((res) => createSchema({
210459
210324
  type: "ref",
210460
- name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
210325
+ name: resolver.resolveResponseStatusName(node, res.statusCode)
210461
210326
  }))
210462
210327
  });
210463
210328
  }
@@ -210489,9 +210354,9 @@ function nameUnnamedEnums(node, parentName) {
210489
210354
  const typeGeneratorLegacy = defineGenerator({
210490
210355
  name: "typescript-legacy",
210491
210356
  type: "react",
210492
- Operation({ node, adapter, options, config }) {
210357
+ Operation({ node, adapter, options, config, resolver }) {
210493
210358
  var _a, _b, _c;
210494
- const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, resolver, transformers = [] } = options;
210359
+ const { enumType, enumTypeSuffix, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, output, transformers = [] } = options;
210495
210360
  const root = path$2.resolve(config.root, config.output.path);
210496
210361
  const mode = getMode(path$2.resolve(root, output.path));
210497
210362
  const file = resolver.resolveFile({
@@ -210505,7 +210370,7 @@ const typeGeneratorLegacy = defineGenerator({
210505
210370
  group
210506
210371
  });
210507
210372
  const params = caseParams(node.parameters, paramsCasing);
210508
- function renderSchemaType({ node: schemaNode, name, typedName, description, keysToOmit }) {
210373
+ function renderSchemaType({ node: schemaNode, name, description, keysToOmit }) {
210509
210374
  if (!schemaNode) return null;
210510
210375
  const transformedNode = transform(schemaNode, composeTransformers(...transformers));
210511
210376
  const imports = adapter.getImports(transformedNode, (schemaName) => ({
@@ -210530,7 +210395,6 @@ const typeGeneratorLegacy = defineGenerator({
210530
210395
  imp.isTypeOnly
210531
210396
  ].join("-"))), /* @__PURE__ */ jsx(Type, {
210532
210397
  name,
210533
- typedName,
210534
210398
  node: transformedNode,
210535
210399
  description,
210536
210400
  enumType,
@@ -210552,7 +210416,6 @@ const typeGeneratorLegacy = defineGenerator({
210552
210416
  return renderSchemaType({
210553
210417
  node: res.schema ? nameUnnamedEnums(res.schema, baseResponseName) : res.schema,
210554
210418
  name: responseName,
210555
- typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
210556
210419
  description: res.description,
210557
210420
  keysToOmit: res.keysToOmit
210558
210421
  });
@@ -210560,7 +210423,6 @@ const typeGeneratorLegacy = defineGenerator({
210560
210423
  const requestType = ((_b = node.requestBody) == null ? void 0 : _b.schema) ? renderSchemaType({
210561
210424
  node: nameUnnamedEnums(node.requestBody.schema, resolverTsLegacy.resolveDataName(node)),
210562
210425
  name: resolver.resolveDataName(node),
210563
- typedName: resolver.resolveDataTypedName(node),
210564
210426
  description: (_c = node.requestBody.description) != null ? _c : node.requestBody.schema.description,
210565
210427
  keysToOmit: node.requestBody.keysToOmit
210566
210428
  }) : null;
@@ -210568,26 +210430,23 @@ const typeGeneratorLegacy = defineGenerator({
210568
210430
  pathParams.length > 0 ? renderSchemaType({
210569
210431
  node: buildGroupedParamsSchema({
210570
210432
  params: pathParams,
210571
- parentName: resolverTsLegacy.resolvePathParamsName(node)
210433
+ parentName: resolverTsLegacy.resolvePathParamsName(node, pathParams[0])
210572
210434
  }),
210573
- name: resolver.resolvePathParamsName(node),
210574
- typedName: resolver.resolvePathParamsTypedName(node)
210435
+ name: resolver.resolvePathParamsName(node, pathParams[0])
210575
210436
  }) : null,
210576
210437
  queryParams.length > 0 ? renderSchemaType({
210577
210438
  node: buildGroupedParamsSchema({
210578
210439
  params: queryParams,
210579
- parentName: resolverTsLegacy.resolveQueryParamsName(node)
210440
+ parentName: resolverTsLegacy.resolveQueryParamsName(node, queryParams[0])
210580
210441
  }),
210581
- name: resolver.resolveQueryParamsName(node),
210582
- typedName: resolver.resolveQueryParamsTypedName(node)
210442
+ name: resolver.resolveQueryParamsName(node, queryParams[0])
210583
210443
  }) : null,
210584
210444
  headerParams.length > 0 ? renderSchemaType({
210585
210445
  node: buildGroupedParamsSchema({
210586
210446
  params: headerParams,
210587
- parentName: resolverTsLegacy.resolveHeaderParamsName(node)
210447
+ parentName: resolverTsLegacy.resolveHeaderParamsName(node, headerParams[0])
210588
210448
  }),
210589
- name: resolver.resolveHeaderParamsName(node),
210590
- typedName: resolver.resolveHeaderParamsTypedName(node)
210449
+ name: resolver.resolveHeaderParamsName(node, headerParams[0])
210591
210450
  }) : null
210592
210451
  ];
210593
210452
  const legacyResponsesType = renderSchemaType({
@@ -210595,16 +210454,14 @@ const typeGeneratorLegacy = defineGenerator({
210595
210454
  node,
210596
210455
  resolver
210597
210456
  }),
210598
- name: resolver.resolveResponsesName(node),
210599
- typedName: resolver.resolveResponsesTypedName(node)
210457
+ name: resolver.resolveResponsesName(node)
210600
210458
  });
210601
210459
  const legacyResponseType = renderSchemaType({
210602
210460
  node: buildLegacyResponseUnionSchemaNode({
210603
210461
  node,
210604
210462
  resolver
210605
210463
  }),
210606
- name: resolver.resolveResponseName(node),
210607
- typedName: resolver.resolveResponseTypedName(node)
210464
+ name: resolver.resolveResponseName(node)
210608
210465
  });
210609
210466
  return /* @__PURE__ */ jsxs(File, {
210610
210467
  baseName: file.baseName,
@@ -210627,8 +210484,8 @@ const typeGeneratorLegacy = defineGenerator({
210627
210484
  ]
210628
210485
  });
210629
210486
  },
210630
- Schema({ node, adapter, options, config }) {
210631
- const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, resolver, transformers = [] } = options;
210487
+ Schema({ node, adapter, options, config, resolver }) {
210488
+ const { enumType, enumTypeSuffix, enumKeyCasing, syntaxType, optionalType, arrayType, output, group, transformers = [] } = options;
210632
210489
  const root = path$2.resolve(config.root, config.output.path);
210633
210490
  const mode = getMode(path$2.resolve(root, output.path));
210634
210491
  if (!node.name) return;
@@ -210645,10 +210502,8 @@ const typeGeneratorLegacy = defineGenerator({
210645
210502
  }).path
210646
210503
  }));
210647
210504
  const isEnumSchema = !!narrowSchema(node, schemaTypes.enum);
210648
- const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyTypedName(node, enumTypeSuffix) : resolver.resolveTypedName(node.name);
210649
210505
  const type = {
210650
- name: resolver.resolveName(node.name),
210651
- typedName,
210506
+ name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumTypeSuffix) : resolver.resolveName(node.name),
210652
210507
  file: resolver.resolveFile({
210653
210508
  name: node.name,
210654
210509
  extname: ".ts"
@@ -210681,7 +210536,6 @@ const typeGeneratorLegacy = defineGenerator({
210681
210536
  imp.isTypeOnly
210682
210537
  ].join("-"))), /* @__PURE__ */ jsx(Type, {
210683
210538
  name: type.name,
210684
- typedName: type.typedName,
210685
210539
  node: transformedNode,
210686
210540
  enumType,
210687
210541
  enumTypeSuffix,
@@ -210694,34 +210548,27 @@ const typeGeneratorLegacy = defineGenerator({
210694
210548
  });
210695
210549
  }
210696
210550
  });
210697
-
210698
210551
  const presets = definePresets({
210699
- default: definePreset("default", {
210552
+ default: {
210553
+ name: "default",
210700
210554
  resolvers: [resolverTs],
210701
210555
  generators: [typeGenerator]
210702
- }),
210703
- kubbV4: definePreset("kubbV4", {
210556
+ },
210557
+ kubbV4: {
210558
+ name: "kubbV4",
210704
210559
  resolvers: [resolverTsLegacy],
210705
210560
  generators: [typeGeneratorLegacy]
210706
- })
210561
+ }
210707
210562
  });
210708
- function getPreset$1(preset, { resolvers, transformers, generators }) {
210709
- return getPreset({
210710
- preset,
210711
- presets,
210712
- resolvers: [resolverTs, ...resolvers != null ? resolvers : []],
210713
- transformers,
210714
- generators
210715
- });
210716
- }
210717
- __name$5(getPreset$1, "getPreset");
210718
210563
  const pluginTsName = "plugin-ts";
210719
210564
  const pluginTs = createPlugin((options) => {
210720
210565
  const { output = {
210721
210566
  path: "types",
210722
210567
  barrelType: "named"
210723
210568
  }, group, exclude = [], include, override = [], enumType = "asConst", enumTypeSuffix = "Key", enumKeyCasing = "none", optionalType = "questionToken", arrayType = "array", syntaxType = "type", paramsCasing, compatibilityPreset = "default", resolvers: userResolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = options;
210724
- const { resolver, transformers, generators } = getPreset$1(compatibilityPreset, {
210569
+ const preset = getPreset({
210570
+ preset: compatibilityPreset,
210571
+ presets,
210725
210572
  resolvers: userResolvers,
210726
210573
  transformers: userTransformers,
210727
210574
  generators: userGenerators
@@ -210730,26 +210577,37 @@ const pluginTs = createPlugin((options) => {
210730
210577
  let resolvePathWarning = false;
210731
210578
  return {
210732
210579
  name: pluginTsName,
210733
- options: {
210734
- output,
210735
- optionalType,
210736
- group,
210737
- arrayType,
210738
- enumType,
210739
- enumTypeSuffix,
210740
- enumKeyCasing,
210741
- syntaxType,
210742
- paramsCasing,
210743
- resolver,
210744
- transformers
210580
+ get resolver() {
210581
+ return preset.resolver;
210582
+ },
210583
+ get options() {
210584
+ return {
210585
+ output,
210586
+ optionalType,
210587
+ group: group ? {
210588
+ ...options.group,
210589
+ name: (ctx) => {
210590
+ var _a;
210591
+ if (((_a = options.group) == null ? void 0 : _a.type) === "path") return `${ctx.group.split("/")[1]}`;
210592
+ return `${camelCase$a(ctx.group)}Controller`;
210593
+ }
210594
+ } : void 0,
210595
+ arrayType,
210596
+ enumType,
210597
+ enumTypeSuffix,
210598
+ enumKeyCasing,
210599
+ syntaxType,
210600
+ paramsCasing,
210601
+ transformers: preset.transformers
210602
+ };
210745
210603
  },
210746
210604
  resolvePath(baseName, pathMode, options2) {
210747
210605
  var _a, _b;
210748
210606
  if (!resolvePathWarning) {
210749
- this.driver.events.emit("warn", "Do not use resolvePath for pluginTs, use resolverTs.resolvePath instead");
210607
+ this.events.emit("warn", "Do not use resolvePath for pluginTs, use resolverTs.resolvePath instead");
210750
210608
  resolvePathWarning = true;
210751
210609
  }
210752
- return resolver.resolvePath({
210610
+ return this.plugin.resolver.resolvePath({
210753
210611
  baseName,
210754
210612
  pathMode,
210755
210613
  tag: (_a = options2 == null ? void 0 : options2.group) == null ? void 0 : _a.tag,
@@ -210757,26 +210615,26 @@ const pluginTs = createPlugin((options) => {
210757
210615
  }, {
210758
210616
  root: path$2.resolve(this.config.root, this.config.output.path),
210759
210617
  output,
210760
- group
210618
+ group: this.plugin.options.group
210761
210619
  });
210762
210620
  },
210763
210621
  resolveName(name, type) {
210764
210622
  if (!resolveNameWarning) {
210765
- this.driver.events.emit("warn", "Do not use resolveName for pluginTs, use resolverTs.default instead");
210623
+ this.events.emit("warn", "Do not use resolveName for pluginTs, use resolverTs.default instead");
210766
210624
  resolveNameWarning = true;
210767
210625
  }
210768
- return resolver.default(name, type);
210626
+ return this.plugin.resolver.default(name, type);
210769
210627
  },
210770
210628
  async install() {
210771
210629
  var _a;
210772
- const { config, fabric, plugin, adapter, rootNode, driver, openInStudio } = this;
210630
+ const { config, fabric, plugin, adapter, rootNode, driver, openInStudio, resolver } = this;
210773
210631
  const root = path$2.resolve(config.root, config.output.path);
210774
210632
  if (!adapter) throw new Error("Plugin cannot work without adapter being set");
210775
210633
  await openInStudio({ ast: true });
210776
210634
  await walk(rootNode, {
210777
210635
  depth: "shallow",
210778
210636
  async schema(schemaNode) {
210779
- const writeTasks = generators.map(async (generator) => {
210637
+ const writeTasks = preset.generators.map(async (generator) => {
210780
210638
  if (generator.type === "react" && generator.version === "2") {
210781
210639
  const options2 = resolver.resolveOptions(schemaNode, {
210782
210640
  options: plugin.options,
@@ -210787,6 +210645,7 @@ const pluginTs = createPlugin((options) => {
210787
210645
  if (options2 === null) return;
210788
210646
  await renderSchema$1(schemaNode, {
210789
210647
  options: options2,
210648
+ resolver,
210790
210649
  adapter,
210791
210650
  config,
210792
210651
  fabric,
@@ -210799,7 +210658,7 @@ const pluginTs = createPlugin((options) => {
210799
210658
  await Promise.all(writeTasks);
210800
210659
  },
210801
210660
  async operation(operationNode) {
210802
- const writeTasks = generators.map(async (generator) => {
210661
+ const writeTasks = preset.generators.map(async (generator) => {
210803
210662
  if (generator.type === "react" && generator.version === "2") {
210804
210663
  const options2 = resolver.resolveOptions(operationNode, {
210805
210664
  options: plugin.options,
@@ -210810,6 +210669,7 @@ const pluginTs = createPlugin((options) => {
210810
210669
  if (options2 === null) return;
210811
210670
  await renderOperation$1(operationNode, {
210812
210671
  options: options2,
210672
+ resolver,
210813
210673
  adapter,
210814
210674
  config,
210815
210675
  fabric,
@@ -213705,7 +213565,7 @@ const serverGenerator = createReactGenerator({
213705
213565
  "${((_b = oas.api.info) == null ? void 0 : _b.title) || "server"}": {
213706
213566
  "type": "stdio",
213707
213567
  "command": "npx",
213708
- "args": ["tsx", "${file.path}"]
213568
+ "args": ["tsx", "${path$2.relative(path$2.dirname(jsonFile.path), file.path)}"]
213709
213569
  }
213710
213570
  }
213711
213571
  }
@@ -213772,7 +213632,7 @@ const pluginMcp = createPlugin((options) => {
213772
213632
  const oas = await this.getOas();
213773
213633
  const baseURL = await this.getBaseURL();
213774
213634
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
213775
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
213635
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
213776
213636
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.addFile({
213777
213637
  baseName: "fetch.ts",
213778
213638
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -216138,7 +215998,7 @@ const infiniteQueryGenerator$1 = createReactGenerator({
216138
215998
  suffix: "infinite"
216139
215999
  })
216140
216000
  };
216141
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
216001
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
216142
216002
  const client = {
216143
216003
  name: shouldUseClientPlugin ? getName(operation, {
216144
216004
  type: "function",
@@ -216392,7 +216252,7 @@ const mutationGenerator$4 = createReactGenerator({
216392
216252
  type: "function"
216393
216253
  })
216394
216254
  };
216395
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
216255
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
216396
216256
  const client = {
216397
216257
  name: shouldUseClientPlugin ? getName(operation, {
216398
216258
  type: "function",
@@ -216588,7 +216448,7 @@ const queryGenerator$4 = createReactGenerator({
216588
216448
  typeName: getName(operation, { type: "type" }),
216589
216449
  file: getFile(operation, { prefix: "use" })
216590
216450
  };
216591
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
216451
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
216592
216452
  const client = {
216593
216453
  name: shouldUseClientPlugin ? getName(operation, {
216594
216454
  type: "function",
@@ -216807,7 +216667,7 @@ const suspenseInfiniteQueryGenerator = createReactGenerator({
216807
216667
  suffix: "suspenseInfinite"
216808
216668
  })
216809
216669
  };
216810
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
216670
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
216811
216671
  const client = {
216812
216672
  name: shouldUseClientPlugin ? getName(operation, {
216813
216673
  type: "function",
@@ -217041,7 +216901,7 @@ const suspenseQueryGenerator = createReactGenerator({
217041
216901
  suffix: "suspense"
217042
216902
  })
217043
216903
  };
217044
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
216904
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
217045
216905
  const client = {
217046
216906
  name: shouldUseClientPlugin ? getName(operation, {
217047
216907
  type: "function",
@@ -217339,7 +217199,7 @@ const pluginReactQuery = createPlugin((options) => {
217339
217199
  const oas = await this.getOas();
217340
217200
  const baseURL = await this.getBaseURL();
217341
217201
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
217342
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
217202
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
217343
217203
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
217344
217204
  baseName: "fetch.ts",
217345
217205
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -218143,7 +218003,7 @@ const mutationGenerator$3 = createReactGenerator({
218143
218003
  type: "function"
218144
218004
  })
218145
218005
  };
218146
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
218006
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
218147
218007
  const client = {
218148
218008
  name: shouldUseClientPlugin ? getName(operation, {
218149
218009
  type: "function",
@@ -218318,7 +218178,7 @@ const queryGenerator$3 = createReactGenerator({
218318
218178
  typeName: getName(operation, { type: "type" }),
218319
218179
  file: getFile(operation, { prefix: "create" })
218320
218180
  };
218321
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
218181
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
218322
218182
  const client = {
218323
218183
  name: shouldUseClientPlugin ? getName(operation, {
218324
218184
  type: "function",
@@ -218587,7 +218447,7 @@ const pluginSolidQuery = createPlugin((options) => {
218587
218447
  const oas = await this.getOas();
218588
218448
  const baseURL = await this.getBaseURL();
218589
218449
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
218590
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
218450
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
218591
218451
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
218592
218452
  baseName: "fetch.ts",
218593
218453
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -219337,7 +219197,7 @@ const mutationGenerator$2 = createReactGenerator({
219337
219197
  type: "function"
219338
219198
  })
219339
219199
  };
219340
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
219200
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
219341
219201
  const client = {
219342
219202
  name: shouldUseClientPlugin ? getName(operation, {
219343
219203
  type: "function",
@@ -219511,7 +219371,7 @@ const queryGenerator$2 = createReactGenerator({
219511
219371
  typeName: getName(operation, { type: "type" }),
219512
219372
  file: getFile(operation, { prefix: "create" })
219513
219373
  };
219514
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
219374
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
219515
219375
  const client = {
219516
219376
  name: shouldUseClientPlugin ? getName(operation, {
219517
219377
  type: "function",
@@ -219780,7 +219640,7 @@ const pluginSvelteQuery = createPlugin((options) => {
219780
219640
  const oas = await this.getOas();
219781
219641
  const baseURL = await this.getBaseURL();
219782
219642
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
219783
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
219643
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
219784
219644
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
219785
219645
  baseName: "fetch.ts",
219786
219646
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -220568,7 +220428,7 @@ const mutationGenerator$1 = createReactGenerator({
220568
220428
  type: "function"
220569
220429
  })
220570
220430
  };
220571
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
220431
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
220572
220432
  const client = {
220573
220433
  name: shouldUseClientPlugin ? getName(operation, {
220574
220434
  type: "function",
@@ -220738,7 +220598,7 @@ const queryGenerator$1 = createReactGenerator({
220738
220598
  typeName: getName(operation, { type: "type" }),
220739
220599
  file: getFile(operation, { prefix: "use" })
220740
220600
  };
220741
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
220601
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
220742
220602
  const client = {
220743
220603
  name: shouldUseClientPlugin ? getName(operation, {
220744
220604
  type: "function",
@@ -220995,7 +220855,7 @@ const pluginSwr = createPlugin((options) => {
220995
220855
  const oas = await this.getOas();
220996
220856
  const baseURL = await this.getBaseURL();
220997
220857
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
220998
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
220858
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
220999
220859
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
221000
220860
  baseName: "fetch.ts",
221001
220861
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -222090,7 +221950,7 @@ const infiniteQueryGenerator = createReactGenerator({
222090
221950
  suffix: "infinite"
222091
221951
  })
222092
221952
  };
222093
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
221953
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
222094
221954
  const client = {
222095
221955
  name: shouldUseClientPlugin ? getName(operation, {
222096
221956
  type: "function",
@@ -222335,7 +222195,7 @@ const mutationGenerator = createReactGenerator({
222335
222195
  type: "function"
222336
222196
  })
222337
222197
  };
222338
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
222198
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
222339
222199
  const client = {
222340
222200
  name: shouldUseClientPlugin ? getName(operation, {
222341
222201
  type: "function",
@@ -222510,7 +222370,7 @@ const queryGenerator = createReactGenerator({
222510
222370
  typeName: getName(operation, { type: "type" }),
222511
222371
  file: getFile(operation, { prefix: "use" })
222512
222372
  };
222513
- const shouldUseClientPlugin = !!driver.getPluginByName(pluginClientName) && options.client.clientType !== "class";
222373
+ const shouldUseClientPlugin = !!driver.getPlugin(pluginClientName) && options.client.clientType !== "class";
222514
222374
  const client = {
222515
222375
  name: shouldUseClientPlugin ? getName(operation, {
222516
222376
  type: "function",
@@ -222800,7 +222660,7 @@ const pluginVueQuery = createPlugin((options) => {
222800
222660
  const oas = await this.getOas();
222801
222661
  const baseURL = await this.getBaseURL();
222802
222662
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
222803
- const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
222663
+ const hasClientPlugin = !!this.getPlugin(pluginClientName);
222804
222664
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
222805
222665
  baseName: "fetch.ts",
222806
222666
  path: path$2.resolve(root, ".kubb/fetch.ts"),
@@ -223050,13 +222910,12 @@ function setupEventsStream(ws, events, getSource) {
223050
222910
  });
223051
222911
  });
223052
222912
  events.on("generation:start", (config) => {
223053
- var _a;
223054
222913
  sendDataMessage({
223055
222914
  type: "generation:start",
223056
222915
  data: [
223057
222916
  {
223058
222917
  name: config.name,
223059
- plugins: ((_a = config.plugins) == null ? void 0 : _a.length) || 0
222918
+ plugins: config.plugins.length
223060
222919
  }
223061
222920
  ],
223062
222921
  timestamp: Date.now()
@@ -223163,7 +223022,7 @@ async function connectToStudio(options) {
223163
223022
  heartbeatTimer = setInterval(() => sendAgentMessage(ws, { type: "ping" }), heartbeatInterval);
223164
223023
  setupEventsStream(ws, events, () => currentSource);
223165
223024
  ws.addEventListener("message", async (message) => {
223166
- var _a2, _b, _c, _d, _e, _f, _g;
223025
+ var _a2, _b, _c, _d, _e, _f;
223167
223026
  try {
223168
223027
  const data = JSON.parse(message.data);
223169
223028
  logger.info(`[${maskedSessionId}] Received "${data.type}" from Studio`);
@@ -223225,7 +223084,7 @@ async function connectToStudio(options) {
223225
223084
  configPath,
223226
223085
  permissions: { allowAll: effectiveAllowAll, allowWrite: effectiveWrite, allowPublish: effectivePublish },
223227
223086
  config: {
223228
- plugins: (_d = config.plugins) == null ? void 0 : _d.map((plugin) => ({
223087
+ plugins: config.plugins.map((plugin) => ({
223229
223088
  name: `@kubb/${plugin.name}`,
223230
223089
  options: serializePluginOptions(plugin.options)
223231
223090
  }))
@@ -223242,7 +223101,7 @@ async function connectToStudio(options) {
223242
223101
  }
223243
223102
  currentSource = "publish";
223244
223103
  const config = await loadConfig(resolvedConfigPath);
223245
- const resolvedCommand = (_f = (_e = data.payload.command) != null ? _e : process.env.KUBB_AGENT_PUBLISH_COMMAND) != null ? _f : "npm publish";
223104
+ const resolvedCommand = (_e = (_d = data.payload.command) != null ? _d : process.env.KUBB_AGENT_PUBLISH_COMMAND) != null ? _e : "npm publish";
223246
223105
  await publish({
223247
223106
  command: resolvedCommand,
223248
223107
  outputPath: config.output.path,
@@ -223256,7 +223115,7 @@ async function connectToStudio(options) {
223256
223115
  }
223257
223116
  logger.warn(`[${maskedSessionId}] Unknown message type from Kubb Studio: ${message.data}`);
223258
223117
  } catch (error) {
223259
- logger.error(`[${maskedSessionId}] [unhandledRejection] ${(_g = error == null ? void 0 : error.message) != null ? _g : error}`);
223118
+ logger.error(`[${maskedSessionId}] [unhandledRejection] ${(_f = error == null ? void 0 : error.message) != null ? _f : error}`);
223260
223119
  }
223261
223120
  });
223262
223121
  } catch (error) {