@kubb/agent 5.0.0-alpha.11 → 5.0.0-alpha.13

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.
Files changed (21) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1121 -1458
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/permessage-deflate.js +6 -6
  5. package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/websocket-server.js +5 -5
  6. package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/websocket.js +6 -6
  7. package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/package.json +4 -3
  8. package/.output/server/node_modules/.nitro/ws@8.20.0/wrapper.mjs +21 -0
  9. package/.output/server/package.json +2 -2
  10. package/package.json +18 -18
  11. package/.output/server/node_modules/.nitro/ws@8.19.0/wrapper.mjs +0 -8
  12. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/buffer-util.js +0 -0
  13. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/constants.js +0 -0
  14. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/event-target.js +0 -0
  15. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/extension.js +0 -0
  16. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/limiter.js +0 -0
  17. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/receiver.js +0 -0
  18. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/sender.js +0 -0
  19. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/stream.js +0 -0
  20. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/subprotocol.js +0 -0
  21. /package/.output/server/node_modules/.nitro/{ws@8.19.0 → ws@8.20.0}/lib/validation.js +0 -0
@@ -14,7 +14,7 @@ import process$1, { version as version$2 } from 'node:process';
14
14
  import { Logtail } from '@logtail/node';
15
15
  import { consola } from 'consola';
16
16
  import { access, rm, readFile as readFile$1, readdir as readdir$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
17
- import { createFabric, createReactFabric, Fabric, File, Function as Function$1, Const, FunctionParams, Type as Type$2, useFabric } from '@kubb/react-fabric';
17
+ import { createFabric, createReactFabric, Fabric, File, Function as Function$1, Const, FunctionParams, Type as Type$1, useFabric } from '@kubb/react-fabric';
18
18
  import { typescriptParser } from '@kubb/react-fabric/parsers';
19
19
  import { fsPlugin } from '@kubb/react-fabric/plugins';
20
20
  import { performance as performance$1 } from 'node:perf_hooks';
@@ -4713,7 +4713,7 @@ function toCamelOrPascal$f(text, pascal) {
4713
4713
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
4714
4714
  }
4715
4715
  function applyToFileParts$f(text, transformPart) {
4716
- const parts = text.split(".");
4716
+ const parts = text.split(/\.(?=[a-zA-Z])/);
4717
4717
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
4718
4718
  }
4719
4719
  function camelCase$f(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -4794,13 +4794,14 @@ function createLimit(concurrency) {
4794
4794
  };
4795
4795
  }
4796
4796
  function getChildren(node, recurse) {
4797
+ var _a;
4797
4798
  switch (node.kind) {
4798
4799
  case "Root":
4799
4800
  return [...node.schemas, ...node.operations];
4800
4801
  case "Operation":
4801
4802
  return [
4802
4803
  ...node.parameters,
4803
- ...node.requestBody ? [node.requestBody] : [],
4804
+ ...((_a = node.requestBody) == null ? void 0 : _a.schema) ? [node.requestBody.schema] : [],
4804
4805
  ...node.responses
4805
4806
  ];
4806
4807
  case "Schema": {
@@ -4870,6 +4871,79 @@ async function _walk(node, visitor, recurse, limit) {
4870
4871
  const children = getChildren(node, recurse);
4871
4872
  await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit)));
4872
4873
  }
4874
+ function transform(node, visitor, options = {}) {
4875
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4876
+ const recurse = ((_a = options.depth) != null ? _a : visitorDepths.deep) === visitorDepths.deep;
4877
+ switch (node.kind) {
4878
+ case "Root": {
4879
+ let root = node;
4880
+ const replaced = (_b = visitor.root) == null ? void 0 : _b.call(visitor, root);
4881
+ if (replaced) root = replaced;
4882
+ return {
4883
+ ...root,
4884
+ schemas: root.schemas.map((s) => transform(s, visitor, options)),
4885
+ operations: root.operations.map((op) => transform(op, visitor, options))
4886
+ };
4887
+ }
4888
+ case "Operation": {
4889
+ let op = node;
4890
+ const replaced = (_c = visitor.operation) == null ? void 0 : _c.call(visitor, op);
4891
+ if (replaced) op = replaced;
4892
+ return {
4893
+ ...op,
4894
+ parameters: op.parameters.map((p) => transform(p, visitor, options)),
4895
+ requestBody: op.requestBody ? {
4896
+ ...op.requestBody,
4897
+ schema: op.requestBody.schema ? transform(op.requestBody.schema, visitor, options) : void 0
4898
+ } : void 0,
4899
+ responses: op.responses.map((r) => transform(r, visitor, options))
4900
+ };
4901
+ }
4902
+ case "Schema": {
4903
+ let schema = node;
4904
+ const replaced = (_d = visitor.schema) == null ? void 0 : _d.call(visitor, schema);
4905
+ if (replaced) schema = replaced;
4906
+ return {
4907
+ ...schema,
4908
+ ..."properties" in schema && recurse ? { properties: schema.properties.map((p) => transform(p, visitor, options)) } : {},
4909
+ ..."items" in schema && recurse ? { items: (_e = schema.items) == null ? void 0 : _e.map((i) => transform(i, visitor, options)) } : {},
4910
+ ..."members" in schema && recurse ? { members: (_f = schema.members) == null ? void 0 : _f.map((m) => transform(m, visitor, options)) } : {},
4911
+ ..."additionalProperties" in schema && recurse && schema.additionalProperties && schema.additionalProperties !== true ? { additionalProperties: transform(schema.additionalProperties, visitor, options) } : {}
4912
+ };
4913
+ }
4914
+ case "Property": {
4915
+ let prop = node;
4916
+ const replaced = (_g = visitor.property) == null ? void 0 : _g.call(visitor, prop);
4917
+ if (replaced) prop = replaced;
4918
+ return {
4919
+ ...prop,
4920
+ schema: transform(prop.schema, visitor, options)
4921
+ };
4922
+ }
4923
+ case "Parameter": {
4924
+ let param = node;
4925
+ const replaced = (_h = visitor.parameter) == null ? void 0 : _h.call(visitor, param);
4926
+ if (replaced) param = replaced;
4927
+ return {
4928
+ ...param,
4929
+ schema: transform(param.schema, visitor, options)
4930
+ };
4931
+ }
4932
+ case "Response": {
4933
+ let response = node;
4934
+ const replaced = (_i = visitor.response) == null ? void 0 : _i.call(visitor, response);
4935
+ if (replaced) response = replaced;
4936
+ return {
4937
+ ...response,
4938
+ schema: transform(response.schema, visitor, options)
4939
+ };
4940
+ }
4941
+ case "FunctionParameter":
4942
+ case "ObjectBindingParameter":
4943
+ case "FunctionParameters":
4944
+ return node;
4945
+ }
4946
+ }
4873
4947
  function collect(node, visitor, options = {}) {
4874
4948
  var _a, _b, _c, _d, _e, _f, _g;
4875
4949
  const recurse = ((_a = options.depth) != null ? _a : visitorDepths.deep) === visitorDepths.deep;
@@ -4984,7 +5058,7 @@ function toCamelOrPascal$e(text, pascal) {
4984
5058
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
4985
5059
  }
4986
5060
  function applyToFileParts$e(text, transformPart) {
4987
- const parts = text.split(".");
5061
+ const parts = text.split(/\.(?=[a-zA-Z])/);
4988
5062
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
4989
5063
  }
4990
5064
  function camelCase$e(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -5955,7 +6029,7 @@ const fsStorage = createStorage(() => ({
5955
6029
  await clean(resolve(base));
5956
6030
  }
5957
6031
  }));
5958
- var version$1 = "5.0.0-alpha.11";
6032
+ var version$1 = "5.0.0-alpha.13";
5959
6033
  function getDiagnosticInfo() {
5960
6034
  return {
5961
6035
  nodeVersion: version$2,
@@ -6742,7 +6816,7 @@ function satisfiesDependency(dependency, version2, cwd) {
6742
6816
  return satisfies(semVer, version2);
6743
6817
  }
6744
6818
 
6745
- var version = "5.0.0-alpha.11";
6819
+ var version = "5.0.0-alpha.13";
6746
6820
 
6747
6821
  function isCommandMessage(msg) {
6748
6822
  return msg.type === "command";
@@ -6947,7 +7021,7 @@ function toCamelOrPascal$d(text, pascal) {
6947
7021
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
6948
7022
  }
6949
7023
  function applyToFileParts$d(text, transformPart) {
6950
- const parts = text.split(".");
7024
+ const parts = text.split(/\.(?=[a-zA-Z])/);
6951
7025
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
6952
7026
  }
6953
7027
  function camelCase$d(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -7097,7 +7171,7 @@ function toCamelOrPascal$c(text, pascal) {
7097
7171
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
7098
7172
  }
7099
7173
  function applyToFileParts$c(text, transformPart) {
7100
- const parts = text.split(".");
7174
+ const parts = text.split(/\.(?=[a-zA-Z])/);
7101
7175
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
7102
7176
  }
7103
7177
  function camelCase$c(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -7267,8 +7341,8 @@ function getDefaultValue(schema) {
7267
7341
  }
7268
7342
  if (schema.type === "object" || schema.properties) return "{}";
7269
7343
  }
7270
- async function parse$3(pathOrApi, { oasClass = Oas, canBundle = true, enablePaths = true } = {}) {
7271
- if (typeof pathOrApi === "string" && canBundle) return parse$3((await bundle({
7344
+ async function parse$2(pathOrApi, { oasClass = Oas, canBundle = true, enablePaths = true } = {}) {
7345
+ if (typeof pathOrApi === "string" && canBundle) return parse$2((await bundle({
7272
7346
  ref: pathOrApi,
7273
7347
  config: await loadConfig$1(),
7274
7348
  base: pathOrApi
@@ -7288,13 +7362,13 @@ async function parse$3(pathOrApi, { oasClass = Oas, canBundle = true, enablePath
7288
7362
  return new oasClass(document);
7289
7363
  }
7290
7364
  async function merge(pathOrApi, { oasClass = Oas } = {}) {
7291
- const instances = await Promise.all(pathOrApi.map((p) => parse$3(p, {
7365
+ const instances = await Promise.all(pathOrApi.map((p) => parse$2(p, {
7292
7366
  oasClass,
7293
7367
  enablePaths: false,
7294
7368
  canBundle: false
7295
7369
  })));
7296
7370
  if (instances.length === 0) throw new Error("No OAS instances provided for merging.");
7297
- return parse$3(instances.reduce((acc, current) => {
7371
+ return parse$2(instances.reduce((acc, current) => {
7298
7372
  return mergeDeep(acc, current.document);
7299
7373
  }, {
7300
7374
  openapi: "3.0.0",
@@ -7308,16 +7382,16 @@ async function merge(pathOrApi, { oasClass = Oas } = {}) {
7308
7382
  }
7309
7383
  function parseFromConfig(config, oasClass = Oas) {
7310
7384
  if ("data" in config.input) {
7311
- if (typeof config.input.data === "object") return parse$3(structuredClone(config.input.data), { oasClass });
7385
+ if (typeof config.input.data === "object") return parse$2(structuredClone(config.input.data), { oasClass });
7312
7386
  try {
7313
- return parse$3(yaml.parse(config.input.data), { oasClass });
7387
+ return parse$2(yaml.parse(config.input.data), { oasClass });
7314
7388
  } catch (_e) {
7315
- return parse$3(config.input.data, { oasClass });
7389
+ return parse$2(config.input.data, { oasClass });
7316
7390
  }
7317
7391
  }
7318
7392
  if (Array.isArray(config.input)) return merge(config.input.map((input) => path$2.resolve(config.root, input.path)), { oasClass });
7319
- if (new URLPath$9(config.input.path).isURL) return parse$3(config.input.path, { oasClass });
7320
- return parse$3(path$2.resolve(config.root, config.input.path), { oasClass });
7393
+ if (new URLPath$9(config.input.path).isURL) return parse$2(config.input.path, { oasClass });
7394
+ return parse$2(path$2.resolve(config.root, config.input.path), { oasClass });
7321
7395
  }
7322
7396
  function flattenSchema(schema) {
7323
7397
  if (!(schema == null ? void 0 : schema.allOf) || schema.allOf.length === 0) return schema || null;
@@ -9234,7 +9308,7 @@ function toCamelOrPascal$b(text, pascal) {
9234
9308
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
9235
9309
  }
9236
9310
  function applyToFileParts$b(text, transformPart) {
9237
- const parts = text.split(".");
9311
+ const parts = text.split(/\.(?=[a-zA-Z])/);
9238
9312
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
9239
9313
  }
9240
9314
  function camelCase$b(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -10296,7 +10370,7 @@ function Operations({ name, operations }) {
10296
10370
  name: "OperationSchema",
10297
10371
  isExportable: true,
10298
10372
  isIndexable: true,
10299
- children: /* @__PURE__ */ jsx(Type$2, {
10373
+ children: /* @__PURE__ */ jsx(Type$1, {
10300
10374
  name: "OperationSchema",
10301
10375
  export: true,
10302
10376
  children: `{
@@ -10320,7 +10394,7 @@ function Operations({ name, operations }) {
10320
10394
  name: "OperationsMap",
10321
10395
  isExportable: true,
10322
10396
  isIndexable: true,
10323
- children: /* @__PURE__ */ jsx(Type$2, {
10397
+ children: /* @__PURE__ */ jsx(Type$1, {
10324
10398
  name: "OperationsMap",
10325
10399
  export: true,
10326
10400
  children: "Record<string, OperationSchema>"
@@ -10631,11 +10705,26 @@ const miniModifierKeywords = [
10631
10705
  function extractMiniModifiers(schemas) {
10632
10706
  const defaultSchema = schemas.find((item) => isKeyword(item, schemaKeywords.default));
10633
10707
  const isBigInt = schemas.some((item) => isKeyword(item, schemaKeywords.bigint));
10708
+ let defaultValue = defaultSchema == null ? void 0 : defaultSchema.args;
10709
+ if (defaultValue !== void 0) {
10710
+ const enumSchema = schemas.find((it) => isKeyword(it, schemaKeywords.enum));
10711
+ if (enumSchema) {
10712
+ let rawDefault = defaultValue;
10713
+ if (typeof rawDefault === "string") try {
10714
+ rawDefault = JSON.parse(rawDefault);
10715
+ } catch {
10716
+ }
10717
+ if (!enumSchema.args.items.map((item) => {
10718
+ var _a;
10719
+ return (_a = item.value) != null ? _a : item.name;
10720
+ }).includes(rawDefault)) defaultValue = void 0;
10721
+ }
10722
+ }
10634
10723
  return {
10635
10724
  hasOptional: schemas.some((item) => isKeyword(item, schemaKeywords.optional)),
10636
10725
  hasNullable: schemas.some((item) => isKeyword(item, schemaKeywords.nullable)),
10637
10726
  hasNullish: schemas.some((item) => isKeyword(item, schemaKeywords.nullish)),
10638
- defaultValue: defaultSchema == null ? void 0 : defaultSchema.args,
10727
+ defaultValue,
10639
10728
  isBigInt
10640
10729
  };
10641
10730
  }
@@ -10657,7 +10746,7 @@ const shouldCoerce = (coercion, type) => {
10657
10746
  if (typeof coercion === "boolean") return coercion;
10658
10747
  return !!coercion[type];
10659
10748
  };
10660
- const parse$2 = createParser({
10749
+ const parse$1 = createParser({
10661
10750
  mapper: zodKeywordMapper,
10662
10751
  handlers: {
10663
10752
  union(tree, options) {
@@ -10848,7 +10937,21 @@ const parse$2 = createParser({
10848
10937
  const { current, siblings } = tree;
10849
10938
  if (options.mini) return;
10850
10939
  const isBigInt = siblings.some((it) => isKeyword(it, schemaKeywords.bigint));
10851
- if (current.args !== void 0) return zodKeywordMapper.default(current.args, void 0, void 0, isBigInt);
10940
+ if (current.args !== void 0) {
10941
+ const enumSchema = siblings.find((it) => isKeyword(it, schemaKeywords.enum));
10942
+ if (enumSchema) {
10943
+ let rawDefault = current.args;
10944
+ if (typeof rawDefault === "string") try {
10945
+ rawDefault = JSON.parse(rawDefault);
10946
+ } catch {
10947
+ }
10948
+ if (!enumSchema.args.items.map((item) => {
10949
+ var _a;
10950
+ return (_a = item.value) != null ? _a : item.name;
10951
+ }).includes(rawDefault)) return;
10952
+ }
10953
+ return zodKeywordMapper.default(current.args, void 0, void 0, isBigInt);
10954
+ }
10852
10955
  return zodKeywordMapper.default();
10853
10956
  },
10854
10957
  describe(tree, options) {
@@ -10927,7 +11030,7 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
10927
11030
  });
10928
11031
  const baseSchemas = mini ? filterMiniModifiers(schemas) : schemas;
10929
11032
  const output = baseSchemas.map((schemaKeyword, index) => {
10930
- return parse$2({
11033
+ return parse$1({
10931
11034
  schema,
10932
11035
  parent: void 0,
10933
11036
  current: schemaKeyword,
@@ -10952,7 +11055,7 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
10952
11055
  if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) if (version === "3") suffix = ".schema";
10953
11056
  else suffix = ".unwrap()";
10954
11057
  }
10955
- const emptyValue = parse$2({
11058
+ const emptyValue = parse$1({
10956
11059
  schema,
10957
11060
  parent: void 0,
10958
11061
  current: { keyword: schemaKeywords[emptySchemaType] },
@@ -10987,11 +11090,11 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
10987
11090
  isExportable: true,
10988
11091
  isIndexable: true,
10989
11092
  isTypeOnly: true,
10990
- children: [typeName && /* @__PURE__ */ jsx(Type$2, {
11093
+ children: [typeName && /* @__PURE__ */ jsx(Type$1, {
10991
11094
  export: true,
10992
11095
  name: inferTypeName,
10993
11096
  children: typeName
10994
- }), !typeName && /* @__PURE__ */ jsx(Type$2, {
11097
+ }), !typeName && /* @__PURE__ */ jsx(Type$1, {
10995
11098
  export: true,
10996
11099
  name: inferTypeName,
10997
11100
  children: `z.infer<typeof ${name}>`
@@ -10999,6 +11102,41 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
10999
11102
  })] });
11000
11103
  }
11001
11104
 
11105
+ function toCamelOrPascal$a(text, pascal) {
11106
+ 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) => {
11107
+ if (word.length > 1 && word === word.toUpperCase()) return word;
11108
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
11109
+ return word.charAt(0).toUpperCase() + word.slice(1);
11110
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
11111
+ }
11112
+ function applyToFileParts$a(text, transformPart) {
11113
+ const parts = text.split(/\.(?=[a-zA-Z])/);
11114
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
11115
+ }
11116
+ function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
11117
+ if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
11118
+ prefix,
11119
+ suffix
11120
+ } : {}));
11121
+ return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
11122
+ }
11123
+ function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
11124
+ if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
11125
+ prefix,
11126
+ suffix
11127
+ }) : camelCase$a(part));
11128
+ return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
11129
+ }
11130
+ function snakeCase(text, { prefix = "", suffix = "" } = {}) {
11131
+ 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("_");
11132
+ }
11133
+ function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
11134
+ return snakeCase(text, {
11135
+ prefix,
11136
+ suffix
11137
+ }).toUpperCase();
11138
+ }
11139
+
11002
11140
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : "undefined" !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11003
11141
 
11004
11142
  function getDefaultExportFromCjs (x) {
@@ -208883,40 +209021,6 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
208883
209021
  var typescriptExports = typescript.exports;
208884
209022
  const ts = /*@__PURE__*/getDefaultExportFromCjs(typescriptExports);
208885
209023
 
208886
- function toCamelOrPascal$a(text, pascal) {
208887
- 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) => {
208888
- if (word.length > 1 && word === word.toUpperCase()) return word;
208889
- if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
208890
- return word.charAt(0).toUpperCase() + word.slice(1);
208891
- }).join("").replace(/[^a-zA-Z0-9]/g, "");
208892
- }
208893
- function applyToFileParts$a(text, transformPart) {
208894
- const parts = text.split(".");
208895
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
208896
- }
208897
- function camelCase$a(text, { isFile, prefix = "", suffix = "" } = {}) {
208898
- if (isFile) return applyToFileParts$a(text, (part, isLast) => camelCase$a(part, isLast ? {
208899
- prefix,
208900
- suffix
208901
- } : {}));
208902
- return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, false);
208903
- }
208904
- function pascalCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
208905
- if (isFile) return applyToFileParts$a(text, (part, isLast) => isLast ? pascalCase$6(part, {
208906
- prefix,
208907
- suffix
208908
- }) : camelCase$a(part));
208909
- return toCamelOrPascal$a(`${prefix} ${text} ${suffix}`, true);
208910
- }
208911
- function snakeCase(text, { prefix = "", suffix = "" } = {}) {
208912
- 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("_");
208913
- }
208914
- function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
208915
- return snakeCase(text, {
208916
- prefix,
208917
- suffix
208918
- }).toUpperCase();
208919
- }
208920
209024
  function trimQuotes$1(text) {
208921
209025
  if (text.length >= 2) {
208922
209026
  const first = text[0];
@@ -208945,6 +209049,27 @@ function jsStringEscape$1(input) {
208945
209049
  }
208946
209050
  });
208947
209051
  }
209052
+ function stringify$1(value) {
209053
+ if (value === void 0 || value === null) return '""';
209054
+ return JSON.stringify(trimQuotes$1(value.toString()));
209055
+ }
209056
+ const OPTIONAL_ADDS_UNDEFINED = /* @__PURE__ */ new Set(["undefined", "questionTokenAndUndefined"]);
209057
+ const OPTIONAL_ADDS_QUESTION_TOKEN = /* @__PURE__ */ new Set(["questionToken", "questionTokenAndUndefined"]);
209058
+ const ENUM_TYPES_WITH_KEY_SUFFIX = /* @__PURE__ */ new Set(["asConst", "asPascalConst"]);
209059
+ const ENUM_TYPES_WITH_RUNTIME_VALUE = /* @__PURE__ */ new Set([
209060
+ "enum",
209061
+ "asConst",
209062
+ "asPascalConst",
209063
+ "constEnum",
209064
+ "literal",
209065
+ void 0
209066
+ ]);
209067
+ const ENUM_TYPES_WITH_TYPE_ONLY = /* @__PURE__ */ new Set([
209068
+ "asConst",
209069
+ "asPascalConst",
209070
+ "literal",
209071
+ void 0
209072
+ ]);
208948
209073
  const { SyntaxKind, factory } = ts;
208949
209074
  const modifiers = {
208950
209075
  async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),
@@ -208957,11 +209082,6 @@ const syntaxKind = {
208957
209082
  literalType: SyntaxKind.LiteralType,
208958
209083
  stringLiteral: SyntaxKind.StringLiteral
208959
209084
  };
208960
- function getUnknownType(unknownType) {
208961
- if (unknownType === "any") return keywordTypeNodes.any;
208962
- if (unknownType === "void") return keywordTypeNodes.void;
208963
- return keywordTypeNodes.unknown;
208964
- }
208965
209085
  function isValidIdentifier(str) {
208966
209086
  if (!str.length || str.trim() !== str) return false;
208967
209087
  const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest);
@@ -209148,376 +209268,291 @@ const createTupleTypeNode = factory.createTupleTypeNode;
209148
209268
  const createRestTypeNode = factory.createRestTypeNode;
209149
209269
  const createTrue = factory.createTrue;
209150
209270
  const createFalse = factory.createFalse;
209151
- const createIndexedAccessTypeNode = factory.createIndexedAccessTypeNode;
209152
- const createTypeOperatorNode = factory.createTypeOperatorNode;
209271
+ factory.createIndexedAccessTypeNode;
209272
+ factory.createTypeOperatorNode;
209153
209273
  const createPrefixUnaryExpression = factory.createPrefixUnaryExpression;
209154
- const typeKeywordMapper = {
209155
- any: () => keywordTypeNodes.any,
209156
- unknown: () => keywordTypeNodes.unknown,
209157
- void: () => keywordTypeNodes.void,
209158
- number: () => keywordTypeNodes.number,
209159
- integer: () => keywordTypeNodes.number,
209160
- bigint: () => keywordTypeNodes.bigint,
209161
- object: (nodes) => {
209162
- if (!nodes || !nodes.length) return keywordTypeNodes.object;
209163
- return createTypeLiteralNode(nodes);
209164
- },
209165
- string: () => keywordTypeNodes.string,
209166
- boolean: () => keywordTypeNodes.boolean,
209167
- undefined: () => keywordTypeNodes.undefined,
209168
- nullable: void 0,
209169
- null: () => keywordTypeNodes.null,
209170
- nullish: void 0,
209171
- array: (nodes, arrayType) => {
209172
- if (!nodes) return;
209173
- return createArrayDeclaration({
209174
- nodes,
209175
- arrayType
209176
- });
209177
- },
209178
- tuple: (nodes, rest, min, max) => {
209179
- if (!nodes) return;
209180
- if (max) {
209181
- nodes = nodes.slice(0, max);
209182
- if (nodes.length < max && rest) nodes = [...nodes, ...Array(max - nodes.length).fill(rest)];
209183
- }
209184
- if (min) nodes = nodes.map((node, index) => index >= min ? createOptionalTypeNode(node) : node);
209185
- if (typeof max === "undefined" && rest) nodes.push(createRestTypeNode(createArrayTypeNode(rest)));
209186
- return createTupleTypeNode(nodes);
209187
- },
209188
- enum: (name) => {
209189
- if (!name) return;
209190
- return createTypeReferenceNode(name, void 0);
209191
- },
209192
- union: (nodes) => {
209193
- if (!nodes) return;
209194
- return createUnionDeclaration({
209195
- withParentheses: true,
209196
- nodes
209197
- });
209198
- },
209199
- const: (name, format) => {
209200
- if (name === null || name === void 0 || name === "") return;
209201
- if (format === "boolean") {
209202
- if (name === true) return createLiteralTypeNode(createTrue());
209203
- return createLiteralTypeNode(createFalse());
209274
+ function constToTypeNode(value, format) {
209275
+ if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
209276
+ if (format === "number" && typeof value === "number") {
209277
+ if (value < 0) return createLiteralTypeNode(createPrefixUnaryExpression(SyntaxKind.MinusToken, createNumericLiteral(Math.abs(value))));
209278
+ return createLiteralTypeNode(createNumericLiteral(value));
209279
+ }
209280
+ return createLiteralTypeNode(createStringLiteral(String(value)));
209281
+ }
209282
+ function dateOrStringNode(node) {
209283
+ return node.representation === "date" ? createTypeReferenceNode(createIdentifier("Date")) : keywordTypeNodes.string;
209284
+ }
209285
+ function buildMemberNodes(members, print) {
209286
+ return (members != null ? members : []).map(print).filter(Boolean);
209287
+ }
209288
+ function buildTupleNode(node, print) {
209289
+ var _a, _b;
209290
+ let items = ((_a = node.items) != null ? _a : []).map(print).filter(Boolean);
209291
+ const restNode = node.rest ? (_b = print(node.rest)) != null ? _b : void 0 : void 0;
209292
+ const { min, max } = node;
209293
+ if (max !== void 0) {
209294
+ items = items.slice(0, max);
209295
+ if (items.length < max && restNode) items = [...items, ...Array(max - items.length).fill(restNode)];
209296
+ }
209297
+ if (min !== void 0) items = items.map((item, i) => i >= min ? createOptionalTypeNode(item) : item);
209298
+ if (max === void 0 && restNode) items.push(createRestTypeNode(createArrayTypeNode(restNode)));
209299
+ return createTupleTypeNode(items);
209300
+ }
209301
+ function buildPropertyType(schema, baseType, optionalType) {
209302
+ const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
209303
+ let type = baseType;
209304
+ if (schema.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
209305
+ if ((schema.nullish || schema.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209306
+ return type;
209307
+ }
209308
+ function buildPropertyJSDocComments(schema) {
209309
+ const isArray = schema.type === "array";
209310
+ return [
209311
+ "description" in schema && schema.description ? `@description ${jsStringEscape$1(schema.description)}` : void 0,
209312
+ "deprecated" in schema && schema.deprecated ? "@deprecated" : void 0,
209313
+ !isArray && "min" in schema && schema.min !== void 0 ? `@minLength ${schema.min}` : void 0,
209314
+ !isArray && "max" in schema && schema.max !== void 0 ? `@maxLength ${schema.max}` : void 0,
209315
+ "pattern" in schema && schema.pattern ? `@pattern ${schema.pattern}` : void 0,
209316
+ "default" in schema && schema.default !== void 0 ? `@default ${"primitive" in schema && schema.primitive === "string" ? stringify$1(schema.default) : schema.default}` : void 0,
209317
+ "example" in schema && schema.example !== void 0 ? `@example ${schema.example}` : void 0,
209318
+ "primitive" in schema && schema.primitive ? [`@type ${schema.primitive || "unknown"}`, "optional" in schema && schema.optional ? " | undefined" : void 0].filter(Boolean).join("") : void 0
209319
+ ];
209320
+ }
209321
+ function buildIndexSignatures(node, propertyCount, print) {
209322
+ var _a, _b;
209323
+ const elements = [];
209324
+ if (node.additionalProperties && node.additionalProperties !== true) {
209325
+ const additionalType = (_a = print(node.additionalProperties)) != null ? _a : keywordTypeNodes.unknown;
209326
+ elements.push(createIndexSignature(propertyCount > 0 ? keywordTypeNodes.unknown : additionalType));
209327
+ } else if (node.additionalProperties === true) elements.push(createIndexSignature(keywordTypeNodes.unknown));
209328
+ if (node.patternProperties) {
209329
+ const first = Object.values(node.patternProperties)[0];
209330
+ if (first) {
209331
+ let patternType = (_b = print(first)) != null ? _b : keywordTypeNodes.unknown;
209332
+ if (first.nullable) patternType = createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] });
209333
+ elements.push(createIndexSignature(patternType));
209204
209334
  }
209205
- if (format === "number" && typeof name === "number") return createLiteralTypeNode(createNumericLiteral(name));
209206
- return createLiteralTypeNode(createStringLiteral(name.toString()));
209207
- },
209208
- datetime: () => keywordTypeNodes.string,
209209
- date: (type = "string") => type === "string" ? keywordTypeNodes.string : createTypeReferenceNode(createIdentifier("Date")),
209210
- time: (type = "string") => type === "string" ? keywordTypeNodes.string : createTypeReferenceNode(createIdentifier("Date")),
209211
- uuid: () => keywordTypeNodes.string,
209212
- url: () => keywordTypeNodes.string,
209213
- default: void 0,
209214
- and: (nodes) => {
209215
- if (!nodes) return;
209216
- return createIntersectionDeclaration({
209217
- withParentheses: true,
209218
- nodes
209219
- });
209220
- },
209221
- describe: void 0,
209222
- min: void 0,
209223
- max: void 0,
209224
- optional: void 0,
209225
- matches: () => keywordTypeNodes.string,
209226
- email: () => keywordTypeNodes.string,
209227
- firstName: void 0,
209228
- lastName: void 0,
209229
- password: void 0,
209230
- phone: void 0,
209231
- readOnly: void 0,
209232
- writeOnly: void 0,
209233
- ref: (propertyName2) => {
209234
- if (!propertyName2) return;
209235
- return createTypeReferenceNode(propertyName2, void 0);
209236
- },
209237
- blob: () => createTypeReferenceNode("Blob", []),
209238
- deprecated: void 0,
209239
- example: void 0,
209240
- schema: void 0,
209241
- catchall: void 0,
209242
- name: void 0,
209243
- interface: void 0,
209244
- exclusiveMaximum: void 0,
209245
- exclusiveMinimum: void 0
209246
- };
209247
- const parse$1 = createParser({
209248
- mapper: typeKeywordMapper,
209249
- handlers: {
209250
- union(tree, options) {
209251
- const { current, schema, name } = tree;
209252
- return typeKeywordMapper.union(current.args.map((it) => this.parse({
209253
- schema,
209254
- parent: current,
209255
- name,
209256
- current: it,
209257
- siblings: []
209258
- }, options)).filter(Boolean));
209259
- },
209260
- and(tree, options) {
209261
- const { current, schema, name } = tree;
209262
- return typeKeywordMapper.and(current.args.map((it) => this.parse({
209263
- schema,
209264
- parent: current,
209265
- name,
209266
- current: it,
209267
- siblings: []
209268
- }, options)).filter(Boolean));
209269
- },
209270
- array(tree, options) {
209271
- const { current, schema, name } = tree;
209272
- return typeKeywordMapper.array(current.args.items.map((it) => this.parse({
209273
- schema,
209274
- parent: current,
209275
- name,
209276
- current: it,
209277
- siblings: []
209278
- }, options)).filter(Boolean), options.arrayType);
209279
- },
209280
- enum(tree, options) {
209281
- const { current } = tree;
209282
- if (options.enumType === "inlineLiteral") {
209283
- const enumValues = current.args.items.map((item) => item.value).filter((value) => value !== void 0 && value !== null).map((value) => {
209284
- const format = typeof value === "number" ? "number" : typeof value === "boolean" ? "boolean" : "string";
209285
- return typeKeywordMapper.const(value, format);
209286
- }).filter(Boolean);
209287
- return typeKeywordMapper.union(enumValues);
209288
- }
209289
- return typeKeywordMapper.enum(["asConst", "asPascalConst"].includes(options.enumType) ? `${current.args.typeName}Key` : current.args.typeName);
209290
- },
209291
- ref(tree, _options) {
209292
- const { current } = tree;
209293
- return typeKeywordMapper.ref(current.args.name);
209294
- },
209295
- blob() {
209296
- return typeKeywordMapper.blob();
209297
- },
209298
- tuple(tree, options) {
209299
- var _a;
209300
- const { current, schema, name } = tree;
209301
- return typeKeywordMapper.tuple(current.args.items.map((it) => this.parse({
209302
- schema,
209303
- parent: current,
209304
- name,
209305
- current: it,
209306
- siblings: []
209307
- }, options)).filter(Boolean), current.args.rest && ((_a = this.parse({
209308
- schema,
209309
- parent: current,
209310
- name,
209311
- current: current.args.rest,
209312
- siblings: []
209313
- }, options)) != null ? _a : void 0), current.args.min, current.args.max);
209314
- },
209315
- const(tree, _options) {
209316
- const { current } = tree;
209317
- return typeKeywordMapper.const(current.args.name, current.args.format);
209318
- },
209319
- object(tree, options) {
209320
- var _a, _b, _c, _d, _e;
209321
- const { current, schema, name } = tree;
209322
- const properties = Object.entries(((_a = current.args) == null ? void 0 : _a.properties) || {}).filter((item) => {
209323
- const schemas = item[1];
209324
- return schemas && typeof schemas.map === "function";
209325
- }).map(([name2, schemas]) => {
209326
- var _a2, _b2, _c2, _d2, _e2;
209327
- const mappedName = ((_a2 = schemas.find((schema2) => schema2.keyword === schemaKeywords.name)) == null ? void 0 : _a2.args) || name2;
209328
- const isNullish = schemas.some((schema2) => schema2.keyword === schemaKeywords.nullish);
209329
- const isNullable = schemas.some((schema2) => schema2.keyword === schemaKeywords.nullable);
209330
- const isOptional = schemas.some((schema2) => schema2.keyword === schemaKeywords.optional);
209331
- const isReadonly = schemas.some((schema2) => schema2.keyword === schemaKeywords.readOnly);
209332
- const describeSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.describe);
209333
- const deprecatedSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.deprecated);
209334
- const defaultSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.default);
209335
- const exampleSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.example);
209336
- const schemaSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.schema);
209337
- const minSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.min);
209338
- const maxSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.max);
209339
- const matchesSchema = schemas.find((schema2) => schema2.keyword === schemaKeywords.matches);
209340
- let type = schemas.map((it) => this.parse({
209341
- schema,
209342
- parent: current,
209343
- name: name2,
209344
- current: it,
209345
- siblings: schemas
209346
- }, options)).filter(Boolean)[0];
209347
- if (isNullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
209348
- if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209349
- if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209350
- return appendJSDocToNode({
209351
- node: createPropertySignature({
209352
- questionToken: isOptional || isNullish ? ["questionToken", "questionTokenAndUndefined"].includes(options.optionalType) : false,
209353
- name: mappedName,
209354
- type,
209355
- readOnly: isReadonly
209356
- }),
209357
- comments: [
209358
- describeSchema ? `@description ${jsStringEscape$1(describeSchema.args)}` : void 0,
209359
- deprecatedSchema ? "@deprecated" : void 0,
209360
- minSchema ? `@minLength ${minSchema.args}` : void 0,
209361
- maxSchema ? `@maxLength ${maxSchema.args}` : void 0,
209362
- matchesSchema ? `@pattern ${matchesSchema.args}` : void 0,
209363
- defaultSchema ? `@default ${defaultSchema.args}` : void 0,
209364
- exampleSchema ? `@example ${exampleSchema.args}` : void 0,
209365
- ((_b2 = schemaSchema == null ? void 0 : schemaSchema.args) == null ? void 0 : _b2.type) || ((_c2 = schemaSchema == null ? void 0 : schemaSchema.args) == null ? void 0 : _c2.format) ? [`@type ${((_d2 = schemaSchema == null ? void 0 : schemaSchema.args) == null ? void 0 : _d2.type) || "unknown"}${!isOptional ? "" : " | undefined"}`, (_e2 = schemaSchema == null ? void 0 : schemaSchema.args) == null ? void 0 : _e2.format].filter(Boolean).join(", ") : void 0
209366
- ].filter(Boolean)
209335
+ }
209336
+ return elements;
209337
+ }
209338
+ const printerTs = definePrinter((options) => {
209339
+ const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
209340
+ return {
209341
+ name: "typescript",
209342
+ options,
209343
+ nodes: {
209344
+ any: () => keywordTypeNodes.any,
209345
+ unknown: () => keywordTypeNodes.unknown,
209346
+ void: () => keywordTypeNodes.void,
209347
+ never: () => keywordTypeNodes.never,
209348
+ boolean: () => keywordTypeNodes.boolean,
209349
+ null: () => keywordTypeNodes.null,
209350
+ blob: () => createTypeReferenceNode("Blob", []),
209351
+ string: () => keywordTypeNodes.string,
209352
+ uuid: () => keywordTypeNodes.string,
209353
+ email: () => keywordTypeNodes.string,
209354
+ url: (node) => {
209355
+ if (node.path) return createUrlTemplateType(node.path);
209356
+ return keywordTypeNodes.string;
209357
+ },
209358
+ datetime: () => keywordTypeNodes.string,
209359
+ number: () => keywordTypeNodes.number,
209360
+ integer: () => keywordTypeNodes.number,
209361
+ bigint: () => keywordTypeNodes.bigint,
209362
+ date: dateOrStringNode,
209363
+ time: dateOrStringNode,
209364
+ ref(node) {
209365
+ var _a;
209366
+ if (!node.name) return;
209367
+ const refName = node.ref ? (_a = node.ref.split("/").at(-1)) != null ? _a : node.name : node.name;
209368
+ return createTypeReferenceNode(node.ref ? this.options.resolver.default(refName, "type") : refName, void 0);
209369
+ },
209370
+ enum(node) {
209371
+ var _a, _b, _c, _d;
209372
+ const values = (_c = (_b = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => v.value)) != null ? _b : node.enumValues) != null ? _c : [];
209373
+ if (this.options.enumType === "inlineLiteral" || !node.name) return (_d = createUnionDeclaration({
209374
+ withParentheses: true,
209375
+ nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
209376
+ })) != null ? _d : void 0;
209377
+ const resolvedName = this.options.resolver.default(node.name, "type");
209378
+ return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) ? `${resolvedName}Key` : resolvedName, void 0);
209379
+ },
209380
+ union(node) {
209381
+ var _a, _b, _c;
209382
+ const members = (_a = node.members) != null ? _a : [];
209383
+ const hasStringLiteral = members.some((m) => m.type === "enum" && (m.enumType === "string" || m.primitive === "string"));
209384
+ const hasPlainString = members.some((m) => isPlainStringType(m));
209385
+ if (hasStringLiteral && hasPlainString) return (_b = createUnionDeclaration({
209386
+ withParentheses: true,
209387
+ nodes: members.map((m) => {
209388
+ if (isPlainStringType(m)) return createIntersectionDeclaration({
209389
+ nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
209390
+ withParentheses: true
209391
+ });
209392
+ return this.print(m);
209393
+ }).filter(Boolean)
209394
+ })) != null ? _b : void 0;
209395
+ return (_c = createUnionDeclaration({
209396
+ withParentheses: true,
209397
+ nodes: buildMemberNodes(members, this.print)
209398
+ })) != null ? _c : void 0;
209399
+ },
209400
+ intersection(node) {
209401
+ var _a;
209402
+ return (_a = createIntersectionDeclaration({
209403
+ withParentheses: true,
209404
+ nodes: buildMemberNodes(node.members, this.print)
209405
+ })) != null ? _a : void 0;
209406
+ },
209407
+ array(node) {
209408
+ var _a, _b;
209409
+ return (_b = createArrayDeclaration({
209410
+ nodes: ((_a = node.items) != null ? _a : []).map((item) => this.print(item)).filter(Boolean),
209411
+ arrayType: this.options.arrayType
209412
+ })) != null ? _b : void 0;
209413
+ },
209414
+ tuple(node) {
209415
+ return buildTupleNode(node, this.print);
209416
+ },
209417
+ object(node) {
209418
+ const { print, options: options2 } = this;
209419
+ const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
209420
+ const propertyNodes = node.properties.map((prop) => {
209421
+ var _a;
209422
+ const baseType = (_a = print(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
209423
+ const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
209424
+ return appendJSDocToNode({
209425
+ node: createPropertySignature({
209426
+ questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,
209427
+ name: prop.name,
209428
+ type,
209429
+ readOnly: prop.schema.readOnly
209430
+ }),
209431
+ comments: buildPropertyJSDocComments(prop.schema)
209432
+ });
209367
209433
  });
209368
- });
209369
- let additionalProperties;
209370
- if ((_c = (_b = current.args) == null ? void 0 : _b.additionalProperties) == null ? void 0 : _c.length) {
209371
- let additionalPropertiesType = current.args.additionalProperties.map((it) => this.parse({
209372
- schema,
209373
- parent: current,
209374
- name,
209375
- current: it,
209376
- siblings: []
209377
- }, options)).filter(Boolean).at(0);
209378
- if ((_d = current.args) == null ? void 0 : _d.additionalProperties.some((schema2) => isKeyword(schema2, schemaKeywords.nullable))) additionalPropertiesType = createUnionDeclaration({ nodes: [additionalPropertiesType, keywordTypeNodes.null] });
209379
- additionalProperties = createIndexSignature(properties.length > 0 ? keywordTypeNodes.unknown : additionalPropertiesType);
209380
- }
209381
- let patternProperties;
209382
- if ((_e = current.args) == null ? void 0 : _e.patternProperties) {
209383
- const allPatternSchemas = Object.values(current.args.patternProperties).flat();
209384
- if (allPatternSchemas.length > 0) {
209385
- patternProperties = allPatternSchemas.map((it) => this.parse({
209386
- schema,
209387
- parent: current,
209388
- name,
209389
- current: it,
209390
- siblings: []
209391
- }, options)).filter(Boolean).at(0);
209392
- if (allPatternSchemas.some((schema2) => isKeyword(schema2, schemaKeywords.nullable))) patternProperties = createUnionDeclaration({ nodes: [patternProperties, keywordTypeNodes.null] });
209393
- patternProperties = createIndexSignature(patternProperties);
209394
- }
209434
+ const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, print)];
209435
+ if (!allElements.length) return keywordTypeNodes.object;
209436
+ return createTypeLiteralNode(allElements);
209395
209437
  }
209396
- return typeKeywordMapper.object([
209397
- ...properties,
209398
- additionalProperties,
209399
- patternProperties
209400
- ].filter(Boolean));
209401
209438
  },
209402
- datetime() {
209403
- return typeKeywordMapper.datetime();
209404
- },
209405
- date(tree) {
209406
- const { current } = tree;
209407
- return typeKeywordMapper.date(current.args.type);
209408
- },
209409
- time(tree) {
209410
- const { current } = tree;
209411
- return typeKeywordMapper.time(current.args.type);
209439
+ print(node) {
209440
+ let type = this.print(node);
209441
+ if (!type) return;
209442
+ if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
209443
+ if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209444
+ const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
209445
+ if (!typeName) return type;
209446
+ const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
209447
+ return createTypeDeclaration({
209448
+ name: typeName,
209449
+ isExportable: true,
209450
+ type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
209451
+ keys: keysToOmit,
209452
+ type,
209453
+ nonNullable: true
209454
+ }) : type,
209455
+ syntax: useTypeGeneration ? "type" : "interface",
209456
+ comments: [
209457
+ (node == null ? void 0 : node.title) ? jsStringEscape$1(node.title) : void 0,
209458
+ description ? `@description ${jsStringEscape$1(description)}` : void 0,
209459
+ (node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
209460
+ node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
209461
+ node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
209462
+ node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
209463
+ (node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
209464
+ (node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
209465
+ ]
209466
+ });
209412
209467
  }
209413
- }
209468
+ };
209414
209469
  });
209415
- function Type$1({ name, typedName, tree, keysToOmit, schema, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description }) {
209416
- const typeNodes = [];
209417
- if (!tree.length) return "";
209418
- const schemaFromTree = tree.find((item) => item.keyword === schemaKeywords.schema);
209419
- const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum);
209420
- let type = tree.map((current, _index, siblings) => parse$1({
209421
- name,
209422
- schema,
209423
- parent: void 0,
209424
- current,
209425
- siblings
209426
- }, {
209470
+ function getEnumNames({ node, enumType, resolver }) {
209471
+ const resolved = resolver.default(node.name, "type");
209472
+ return {
209473
+ enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
209474
+ typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? `${resolved}Key` : resolved,
209475
+ refName: resolved
209476
+ };
209477
+ }
209478
+ function Enum({ node, enumType, enumKeyCasing, resolver }) {
209479
+ var _a, _b, _c, _d;
209480
+ const { enumName, typeName, refName } = getEnumNames({
209481
+ node,
209482
+ enumType,
209483
+ resolver
209484
+ });
209485
+ const [nameNode, typeNode] = createEnumDeclaration({
209486
+ name: enumName,
209487
+ typeName,
209488
+ 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 : [],
209489
+ type: enumType,
209490
+ enumKeyCasing
209491
+ });
209492
+ const needsRefAlias = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && refName !== typeName;
209493
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
209494
+ nameNode && /* @__PURE__ */ jsx(File.Source, {
209495
+ name: enumName,
209496
+ isExportable: true,
209497
+ isIndexable: true,
209498
+ isTypeOnly: false,
209499
+ children: safePrint(nameNode)
209500
+ }),
209501
+ /* @__PURE__ */ jsx(File.Source, {
209502
+ name: typeName,
209503
+ isIndexable: true,
209504
+ isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
209505
+ isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
209506
+ children: safePrint(typeNode)
209507
+ }),
209508
+ needsRefAlias && /* @__PURE__ */ jsx(File.Source, {
209509
+ name: refName,
209510
+ isExportable: true,
209511
+ isIndexable: true,
209512
+ isTypeOnly: true,
209513
+ children: `export type ${refName} = ${typeName}`
209514
+ })
209515
+ ] });
209516
+ }
209517
+ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description, resolver }) {
209518
+ const resolvedDescription = description || (node == null ? void 0 : node.description);
209519
+ const enumSchemaNodes = collect(node, { schema(n) {
209520
+ if (n.type === "enum" && n.name) return n;
209521
+ } });
209522
+ const typeNode = printerTs({
209427
209523
  optionalType,
209428
209524
  arrayType,
209429
- enumType
209430
- })).filter(Boolean).at(0) || typeKeywordMapper.undefined();
209431
- if (["asConst", "asPascalConst"].includes(enumType) && enumSchemas.length > 0) {
209432
- const isDirectEnum = schema.type === "array" && schema.items !== void 0;
209433
- const isEnumOnly = "enum" in schema && schema.enum;
209434
- if (isDirectEnum || isEnumOnly) {
209435
- type = createTypeReferenceNode(`${enumSchemas[0].args.typeName}Key`);
209436
- if (schema.type === "array") if (arrayType === "generic") type = createTypeReferenceNode(createIdentifier("Array"), [type]);
209437
- else type = createArrayTypeNode(type);
209438
- }
209439
- }
209440
- if (schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.schema)) {
209441
- const isNullish = tree.some((item) => item.keyword === schemaKeywords.nullish);
209442
- const isNullable = tree.some((item) => item.keyword === schemaKeywords.nullable);
209443
- const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
209444
- if (isNullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
209445
- if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209446
- if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
209447
- }
209448
- const useTypeGeneration = syntaxType === "type" || [syntaxKind.union].includes(type.kind) || !!(keysToOmit == null ? void 0 : keysToOmit.length);
209449
- typeNodes.push(createTypeDeclaration({
209450
- name,
209451
- isExportable: true,
209452
- type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
209453
- keys: keysToOmit,
209454
- type,
209455
- nonNullable: true
209456
- }) : type,
209457
- syntax: useTypeGeneration ? "type" : "interface",
209458
- comments: [
209459
- schema.title ? `${jsStringEscape$1(schema.title)}` : void 0,
209460
- description ? `@description ${jsStringEscape$1(description)}` : void 0,
209461
- schema.deprecated ? "@deprecated" : void 0,
209462
- schema.minLength ? `@minLength ${schema.minLength}` : void 0,
209463
- schema.maxLength ? `@maxLength ${schema.maxLength}` : void 0,
209464
- schema.pattern ? `@pattern ${schema.pattern}` : void 0,
209465
- schema.default ? `@default ${schema.default}` : void 0,
209466
- schema.example ? `@example ${schema.example}` : void 0
209467
- ]
209468
- }));
209469
- const enums = [...new Set(enumSchemas)].map((enumSchema) => {
209470
- const name2 = enumType === "asPascalConst" ? pascalCase$6(enumSchema.args.name) : camelCase$a(enumSchema.args.name);
209471
- const typeName = ["asConst", "asPascalConst"].includes(enumType) ? `${enumSchema.args.typeName}Key` : enumSchema.args.typeName;
209472
- const [nameNode, typeNode] = createEnumDeclaration({
209473
- name: name2,
209474
- typeName,
209475
- enums: enumSchema.args.items.map((item) => {
209476
- var _a;
209477
- return item.value === void 0 ? void 0 : [trimQuotes$1((_a = item.name) == null ? void 0 : _a.toString()), item.value];
209478
- }).filter(Boolean),
209479
- type: enumType,
209480
- enumKeyCasing
209481
- });
209525
+ enumType,
209526
+ typeName: name,
209527
+ syntaxType,
209528
+ description: resolvedDescription,
209529
+ keysToOmit,
209530
+ resolver
209531
+ }).print(node);
209532
+ if (!typeNode) return;
209533
+ const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node2) => {
209482
209534
  return {
209483
- nameNode,
209484
- typeNode,
209485
- name: name2,
209486
- typeName
209535
+ node: node2,
209536
+ ...getEnumNames({
209537
+ node: node2,
209538
+ enumType,
209539
+ resolver
209540
+ })
209487
209541
  };
209488
209542
  });
209489
209543
  const shouldExportEnums = enumType !== "inlineLiteral";
209490
209544
  const shouldExportType = enumType === "inlineLiteral" || enums.every((item) => item.typeName !== name);
209491
- return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({ name: name2, nameNode, typeName, typeNode }) => /* @__PURE__ */ jsxs(Fragment, { children: [nameNode && /* @__PURE__ */ jsx(File.Source, {
209492
- name: name2,
209493
- isExportable: true,
209494
- isIndexable: true,
209495
- isTypeOnly: false,
209496
- children: safePrint(nameNode)
209497
- }), /* @__PURE__ */ jsx(File.Source, {
209498
- name: typeName,
209499
- isIndexable: true,
209500
- isExportable: [
209501
- "enum",
209502
- "asConst",
209503
- "asPascalConst",
209504
- "constEnum",
209505
- "literal",
209506
- void 0
209507
- ].includes(enumType),
209508
- isTypeOnly: [
209509
- "asConst",
209510
- "asPascalConst",
209511
- "literal",
209512
- void 0
209513
- ].includes(enumType),
209514
- children: safePrint(typeNode)
209515
- })] })), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
209545
+ return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({ node: node2 }) => /* @__PURE__ */ jsx(Enum, {
209546
+ node: node2,
209547
+ enumType,
209548
+ enumKeyCasing,
209549
+ resolver
209550
+ })), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
209516
209551
  name: typedName,
209517
209552
  isTypeOnly: true,
209518
209553
  isExportable: true,
209519
209554
  isIndexable: true,
209520
- children: safePrint(...typeNodes)
209555
+ children: safePrint(typeNode)
209521
209556
  })] });
209522
209557
  }
209523
209558
 
@@ -209599,871 +209634,21 @@ function usePluginDriver() {
209599
209634
  return meta.driver;
209600
209635
  }
209601
209636
 
209602
- function useOas() {
209603
- const { meta } = useFabric();
209604
- return meta.oas;
209605
- }
209606
- function useOperationManager(generator) {
209607
- const plugin = usePlugin();
209608
- const driver = usePluginDriver();
209609
- const defaultPluginName = plugin.name;
209610
- const getName = (operation, { prefix = "", suffix = "", pluginName = defaultPluginName, type }) => {
209611
- return driver.resolveName({
209612
- name: `${prefix} ${operation.getOperationId()} ${suffix}`,
209613
- pluginName,
209614
- type
209615
- });
209616
- };
209617
- const getGroup = (operation) => {
209618
- var _a;
209619
- return {
209620
- tag: (_a = operation.getTags().at(0)) == null ? void 0 : _a.name,
209621
- path: operation.path
209622
- };
209623
- };
209624
- const getSchemas = (operation, params) => {
209625
- if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
209626
- return generator.getSchemas(operation, { resolveName: (name) => {
209627
- var _a;
209628
- return driver.resolveName({
209629
- name,
209630
- pluginName: (_a = params == null ? void 0 : params.pluginName) != null ? _a : defaultPluginName,
209631
- type: params == null ? void 0 : params.type
209632
- });
209633
- } });
209634
- };
209635
- const getFile = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = ".ts" } = {}) => {
209636
- const name = getName(operation, {
209637
- type: "file",
209638
- pluginName,
209639
- prefix,
209640
- suffix
209641
- });
209642
- const group = getGroup(operation);
209643
- const file = driver.getFile({
209644
- name,
209645
- extname,
209646
- pluginName,
209647
- options: {
209648
- type: "file",
209649
- pluginName,
209650
- group
209651
- }
209652
- });
209653
- return {
209654
- ...file,
209655
- meta: {
209656
- ...file.meta,
209657
- name,
209658
- pluginName,
209659
- group
209660
- }
209661
- };
209662
- };
209663
- const groupSchemasByName = (operation, { pluginName = defaultPluginName, type }) => {
209664
- var _a, _b, _c, _d;
209665
- if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
209666
- const schemas = getSchemas(operation);
209667
- const errors = (schemas.errors || []).reduce((prev, acc) => {
209668
- if (!acc.statusCode) return prev;
209669
- prev[acc.statusCode] = driver.resolveName({
209670
- name: acc.name,
209671
- pluginName,
209672
- type
209673
- });
209674
- return prev;
209675
- }, {});
209676
- const responses = (schemas.responses || []).reduce((prev, acc) => {
209677
- if (!acc.statusCode) return prev;
209678
- prev[acc.statusCode] = driver.resolveName({
209679
- name: acc.name,
209680
- pluginName,
209681
- type
209682
- });
209683
- return prev;
209684
- }, {});
209685
- return {
209686
- request: ((_a = schemas.request) == null ? void 0 : _a.name) ? driver.resolveName({
209687
- name: schemas.request.name,
209688
- pluginName,
209689
- type
209690
- }) : void 0,
209691
- parameters: {
209692
- path: ((_b = schemas.pathParams) == null ? void 0 : _b.name) ? driver.resolveName({
209693
- name: schemas.pathParams.name,
209694
- pluginName,
209695
- type
209696
- }) : void 0,
209697
- query: ((_c = schemas.queryParams) == null ? void 0 : _c.name) ? driver.resolveName({
209698
- name: schemas.queryParams.name,
209699
- pluginName,
209700
- type
209701
- }) : void 0,
209702
- header: ((_d = schemas.headerParams) == null ? void 0 : _d.name) ? driver.resolveName({
209703
- name: schemas.headerParams.name,
209704
- pluginName,
209705
- type
209706
- }) : void 0
209707
- },
209708
- responses: {
209709
- ...responses,
209710
- ["default"]: driver.resolveName({
209711
- name: schemas.response.name,
209712
- pluginName,
209713
- type
209714
- }),
209715
- ...errors
209716
- },
209717
- errors
209718
- };
209719
- };
209720
- return {
209721
- getName,
209722
- getFile,
209723
- getSchemas,
209724
- groupSchemasByName,
209725
- getGroup
209726
- };
209727
- }
209728
- function useSchemaManager() {
209729
- const plugin = usePlugin();
209730
- const driver = usePluginDriver();
209731
- const getName = (name, { pluginName = plugin.name, type }) => {
209732
- return driver.resolveName({
209733
- name,
209734
- pluginName,
209735
- type
209736
- });
209737
- };
209738
- const getFile = (name, { mode = "split", pluginName = plugin.name, extname = ".ts", group } = {}) => {
209739
- const resolvedName = mode === "single" ? "" : getName(name, {
209740
- type: "file",
209741
- pluginName
209742
- });
209743
- const file = driver.getFile({
209744
- name: resolvedName,
209745
- extname,
209746
- pluginName,
209747
- options: {
209748
- type: "file",
209749
- pluginName,
209750
- group
209751
- }
209752
- });
209753
- return {
209754
- ...file,
209755
- meta: {
209756
- ...file.meta,
209757
- name: resolvedName,
209758
- pluginName
209759
- }
209760
- };
209761
- };
209762
- return {
209763
- getName,
209764
- getFile
209765
- };
209766
- }
209767
-
209768
- function stringify$1(value) {
209769
- if (value === void 0 || value === null) return '""';
209770
- return JSON.stringify(trimQuotes$1(value.toString()));
209771
- }
209772
- function printCombinedSchema({ name, schemas, driver }) {
209773
- const properties = {};
209774
- if (schemas.response) properties["response"] = createUnionDeclaration({ nodes: schemas.responses.map((res) => {
209775
- return createTypeReferenceNode(createIdentifier(driver.resolveName({
209776
- name: res.name,
209777
- pluginName: pluginTsName,
209778
- type: "function"
209779
- })), void 0);
209780
- }) });
209781
- if (schemas.request) properties["request"] = createTypeReferenceNode(createIdentifier(driver.resolveName({
209782
- name: schemas.request.name,
209783
- pluginName: pluginTsName,
209784
- type: "function"
209785
- })), void 0);
209786
- if (schemas.pathParams) properties["pathParams"] = createTypeReferenceNode(createIdentifier(driver.resolveName({
209787
- name: schemas.pathParams.name,
209788
- pluginName: pluginTsName,
209789
- type: "function"
209790
- })), void 0);
209791
- if (schemas.queryParams) properties["queryParams"] = createTypeReferenceNode(createIdentifier(driver.resolveName({
209792
- name: schemas.queryParams.name,
209793
- pluginName: pluginTsName,
209794
- type: "function"
209795
- })), void 0);
209796
- if (schemas.headerParams) properties["headerParams"] = createTypeReferenceNode(createIdentifier(driver.resolveName({
209797
- name: schemas.headerParams.name,
209798
- pluginName: pluginTsName,
209799
- type: "function"
209800
- })), void 0);
209801
- if (schemas.errors) properties["errors"] = createUnionDeclaration({ nodes: schemas.errors.map((error) => {
209802
- return createTypeReferenceNode(createIdentifier(driver.resolveName({
209803
- name: error.name,
209804
- pluginName: pluginTsName,
209805
- type: "function"
209806
- })), void 0);
209807
- }) });
209808
- return safePrint(createTypeAliasDeclaration({
209809
- name,
209810
- type: createTypeLiteralNode(Object.keys(properties).map((key) => {
209811
- const type = properties[key];
209812
- if (!type) return;
209813
- return createPropertySignature({
209814
- name: pascalCase$6(key),
209815
- type
209816
- });
209817
- }).filter(Boolean)),
209818
- modifiers: [modifiers.export]
209819
- }));
209820
- }
209821
- function printRequestSchema({ baseName, operation, schemas, driver }) {
209822
- const name = driver.resolveName({
209823
- name: `${baseName} Request`,
209824
- pluginName: pluginTsName,
209825
- type: "type"
209826
- });
209827
- const results = [];
209828
- const dataRequestProperties = [];
209829
- if (schemas.request) {
209830
- const identifier = driver.resolveName({
209831
- name: schemas.request.name,
209832
- pluginName: pluginTsName,
209833
- type: "type"
209834
- });
209835
- dataRequestProperties.push(createPropertySignature({
209836
- name: "data",
209837
- questionToken: true,
209838
- type: createTypeReferenceNode(createIdentifier(identifier), void 0)
209839
- }));
209840
- } else dataRequestProperties.push(createPropertySignature({
209841
- name: "data",
209842
- questionToken: true,
209843
- type: keywordTypeNodes.never
209844
- }));
209845
- if (schemas.pathParams) {
209846
- const identifier = driver.resolveName({
209847
- name: schemas.pathParams.name,
209848
- pluginName: pluginTsName,
209849
- type: "type"
209850
- });
209851
- dataRequestProperties.push(createPropertySignature({
209852
- name: "pathParams",
209853
- type: createTypeReferenceNode(createIdentifier(identifier), void 0)
209854
- }));
209855
- } else dataRequestProperties.push(createPropertySignature({
209856
- name: "pathParams",
209857
- questionToken: true,
209858
- type: keywordTypeNodes.never
209859
- }));
209860
- if (schemas.queryParams) {
209861
- const identifier = driver.resolveName({
209862
- name: schemas.queryParams.name,
209863
- pluginName: pluginTsName,
209864
- type: "type"
209865
- });
209866
- dataRequestProperties.push(createPropertySignature({
209867
- name: "queryParams",
209868
- questionToken: true,
209869
- type: createTypeReferenceNode(createIdentifier(identifier), void 0)
209870
- }));
209871
- } else dataRequestProperties.push(createPropertySignature({
209872
- name: "queryParams",
209873
- questionToken: true,
209874
- type: keywordTypeNodes.never
209875
- }));
209876
- if (schemas.headerParams) {
209877
- const identifier = driver.resolveName({
209878
- name: schemas.headerParams.name,
209879
- pluginName: pluginTsName,
209880
- type: "type"
209881
- });
209882
- dataRequestProperties.push(createPropertySignature({
209883
- name: "headerParams",
209884
- questionToken: true,
209885
- type: createTypeReferenceNode(createIdentifier(identifier), void 0)
209886
- }));
209887
- } else dataRequestProperties.push(createPropertySignature({
209888
- name: "headerParams",
209889
- questionToken: true,
209890
- type: keywordTypeNodes.never
209891
- }));
209892
- dataRequestProperties.push(createPropertySignature({
209893
- name: "url",
209894
- type: createUrlTemplateType(operation.path)
209895
- }));
209896
- const dataRequestNode = createTypeAliasDeclaration({
209897
- name,
209898
- type: createTypeLiteralNode(dataRequestProperties),
209899
- modifiers: [modifiers.export]
209900
- });
209901
- results.push(safePrint(dataRequestNode));
209902
- return results.join("\n\n");
209903
- }
209904
- function printResponseSchema({ baseName, schemas, driver, unknownType }) {
209905
- const results = [];
209906
- const name = driver.resolveName({
209907
- name: `${baseName} ResponseData`,
209908
- pluginName: pluginTsName,
209909
- type: "type"
209910
- });
209911
- if (schemas.responses && schemas.responses.length > 0) {
209912
- const responsesProperties = schemas.responses.map((res) => {
209913
- var _a, _b;
209914
- const identifier = driver.resolveName({
209915
- name: res.name,
209916
- pluginName: pluginTsName,
209917
- type: "type"
209918
- });
209919
- return createPropertySignature({
209920
- name: (_b = (_a = res.statusCode) == null ? void 0 : _a.toString()) != null ? _b : "default",
209921
- type: createTypeReferenceNode(createIdentifier(identifier), void 0)
209922
- });
209923
- });
209924
- const responsesNode = createTypeAliasDeclaration({
209925
- name: `${baseName}Responses`,
209926
- type: createTypeLiteralNode(responsesProperties),
209927
- modifiers: [modifiers.export]
209928
- });
209929
- results.push(safePrint(responsesNode));
209930
- const responseNode = createTypeAliasDeclaration({
209931
- name,
209932
- type: createIndexedAccessTypeNode(createTypeReferenceNode(createIdentifier(`${baseName}Responses`), void 0), createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, createTypeReferenceNode(createIdentifier(`${baseName}Responses`), void 0))),
209933
- modifiers: [modifiers.export]
209934
- });
209935
- results.push(safePrint(responseNode));
209936
- } else {
209937
- const responseNode = createTypeAliasDeclaration({
209938
- name,
209939
- modifiers: [modifiers.export],
209940
- type: getUnknownType(unknownType)
209941
- });
209942
- results.push(safePrint(responseNode));
209943
- }
209944
- return results.join("\n\n");
209945
- }
209946
- const typeGenerator$1 = createReactGenerator({
209947
- name: "typescript",
209948
- Operation({ operation, generator, plugin }) {
209949
- const { options, options: { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType, paramsCasing } } = plugin;
209950
- const mode = useMode();
209951
- const driver = usePluginDriver();
209952
- const oas = useOas();
209953
- const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator);
209954
- const schemaManager = useSchemaManager();
209955
- const name = getName(operation, {
209956
- type: "type",
209957
- pluginName: pluginTsName
209958
- });
209959
- const file = getFile(operation);
209960
- const schemas = getSchemas(operation);
209961
- const schemaGenerator = new SchemaGenerator(options, {
209962
- fabric: generator.context.fabric,
209963
- oas,
209964
- events: generator.context.events,
209965
- plugin,
209966
- driver,
209967
- mode,
209968
- override: options.override
209969
- });
209970
- const operationSchemas = [
209971
- schemas.pathParams,
209972
- schemas.queryParams,
209973
- schemas.headerParams,
209974
- schemas.statusCodes,
209975
- schemas.request,
209976
- schemas.response
209977
- ].flat().filter(Boolean);
209978
- const mapOperationSchema = ({ name: name2, schema, description, keysToOmit, ...options2 }) => {
209979
- const transformedSchema = paramsCasing && isParameterSchema(name2) ? applyParamsCasing(schema, paramsCasing) : schema;
209980
- const tree = schemaGenerator.parse({
209981
- schema: transformedSchema,
209982
- name: name2,
209983
- parentName: null
209984
- });
209985
- const imports = getImports(tree);
209986
- const group = options2.operation ? getGroup(options2.operation) : void 0;
209987
- const type = {
209988
- name: schemaManager.getName(name2, { type: "type" }),
209989
- typedName: schemaManager.getName(name2, { type: "type" }),
209990
- file: schemaManager.getFile(options2.operationName || name2, { group })
209991
- };
209992
- return /* @__PURE__ */ jsxs(Fragment, { children: [mode === "split" && imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
209993
- root: file.path,
209994
- path: imp.path,
209995
- name: imp.name,
209996
- isTypeOnly: true
209997
- }, [
209998
- name2,
209999
- imp.name,
210000
- imp.path,
210001
- imp.isTypeOnly
210002
- ].join("-"))), /* @__PURE__ */ jsx(Type$1, {
210003
- name: type.name,
210004
- typedName: type.typedName,
210005
- description,
210006
- tree,
210007
- schema: transformedSchema,
210008
- enumType,
210009
- enumKeyCasing,
210010
- optionalType,
210011
- arrayType,
210012
- keysToOmit,
210013
- syntaxType
210014
- })] });
210015
- };
210016
- const responseName = schemaManager.getName(schemas.response.name, { type: "type" });
210017
- const combinedSchemaName = operation.method === "get" ? `${name}Query` : `${name}Mutation`;
210018
- return /* @__PURE__ */ jsxs(File, {
210019
- baseName: file.baseName,
210020
- path: file.path,
210021
- meta: file.meta,
210022
- banner: getBanner({
210023
- oas,
210024
- output: plugin.options.output,
210025
- config: driver.config
210026
- }),
210027
- footer: getFooter({
210028
- oas,
210029
- output: plugin.options.output
210030
- }),
210031
- children: [operationSchemas.map(mapOperationSchema), generator.context.UNSTABLE_NAMING ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
210032
- name: `${name}Request`,
210033
- isExportable: true,
210034
- isIndexable: true,
210035
- isTypeOnly: true,
210036
- children: printRequestSchema({
210037
- baseName: name,
210038
- operation,
210039
- schemas,
210040
- driver
210041
- })
210042
- }), /* @__PURE__ */ jsx(File.Source, {
210043
- name: responseName,
210044
- isExportable: true,
210045
- isIndexable: true,
210046
- isTypeOnly: true,
210047
- children: printResponseSchema({
210048
- baseName: name,
210049
- schemas,
210050
- driver,
210051
- unknownType
210052
- })
210053
- })] }) : /* @__PURE__ */ jsx(File.Source, {
210054
- name: combinedSchemaName,
210055
- isExportable: true,
210056
- isIndexable: true,
210057
- isTypeOnly: true,
210058
- children: printCombinedSchema({
210059
- name: combinedSchemaName,
210060
- schemas,
210061
- driver
210062
- })
210063
- })]
210064
- });
210065
- },
210066
- Schema({ schema, plugin }) {
210067
- const { options: { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, output } } = plugin;
210068
- const mode = useMode();
210069
- const oas = useOas();
210070
- const driver = usePluginDriver();
210071
- const { getName, getFile } = useSchemaManager();
210072
- const imports = getImports(schema.tree);
210073
- const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema);
210074
- let typedName = getName(schema.name, { type: "type" });
210075
- if (["asConst", "asPascalConst"].includes(enumType) && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) typedName = typedName += "Key";
210076
- const type = {
210077
- name: getName(schema.name, { type: "function" }),
210078
- typedName,
210079
- file: getFile(schema.name)
210080
- };
210081
- return /* @__PURE__ */ jsxs(File, {
210082
- baseName: type.file.baseName,
210083
- path: type.file.path,
210084
- meta: type.file.meta,
210085
- banner: getBanner({
210086
- oas,
210087
- output,
210088
- config: driver.config
210089
- }),
210090
- footer: getFooter({
210091
- oas,
210092
- output
210093
- }),
210094
- children: [mode === "split" && imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
210095
- root: type.file.path,
210096
- path: imp.path,
210097
- name: imp.name,
210098
- isTypeOnly: true
210099
- }, [
210100
- schema.name,
210101
- imp.path,
210102
- imp.isTypeOnly
210103
- ].join("-"))), /* @__PURE__ */ jsx(Type$1, {
210104
- name: type.name,
210105
- typedName: type.typedName,
210106
- description: schema.value.description,
210107
- tree: schema.tree,
210108
- schema: schema.value,
210109
- enumType,
210110
- enumKeyCasing,
210111
- optionalType,
210112
- arrayType,
210113
- syntaxType
210114
- })]
210115
- });
210116
- }
210117
- });
210118
- const OPTIONAL_ADDS_UNDEFINED = /* @__PURE__ */ new Set(["undefined", "questionTokenAndUndefined"]);
210119
- const OPTIONAL_ADDS_QUESTION_TOKEN = /* @__PURE__ */ new Set(["questionToken", "questionTokenAndUndefined"]);
210120
- const ENUM_TYPES_WITH_KEY_SUFFIX = /* @__PURE__ */ new Set(["asConst", "asPascalConst"]);
210121
- const ENUM_TYPES_WITH_RUNTIME_VALUE = /* @__PURE__ */ new Set([
210122
- "enum",
210123
- "asConst",
210124
- "asPascalConst",
210125
- "constEnum",
210126
- "literal",
210127
- void 0
210128
- ]);
210129
- const ENUM_TYPES_WITH_TYPE_ONLY = /* @__PURE__ */ new Set([
210130
- "asConst",
210131
- "asPascalConst",
210132
- "literal",
210133
- void 0
210134
- ]);
210135
- function constToTypeNode(value, format) {
210136
- if (format === "boolean") return createLiteralTypeNode(value === true ? createTrue() : createFalse());
210137
- if (format === "number" && typeof value === "number") {
210138
- if (value < 0) return createLiteralTypeNode(createPrefixUnaryExpression(SyntaxKind.MinusToken, createNumericLiteral(Math.abs(value))));
210139
- return createLiteralTypeNode(createNumericLiteral(value));
210140
- }
210141
- return createLiteralTypeNode(createStringLiteral(String(value)));
210142
- }
210143
- function dateOrStringNode(node) {
210144
- return node.representation === "date" ? createTypeReferenceNode(createIdentifier("Date")) : keywordTypeNodes.string;
210145
- }
210146
- function buildMemberNodes(members, print) {
210147
- return (members != null ? members : []).map(print).filter(Boolean);
210148
- }
210149
- function buildTupleNode(node, print) {
210150
- var _a, _b;
210151
- let items = ((_a = node.items) != null ? _a : []).map(print).filter(Boolean);
210152
- const restNode = node.rest ? (_b = print(node.rest)) != null ? _b : void 0 : void 0;
210153
- const { min, max } = node;
210154
- if (max !== void 0) {
210155
- items = items.slice(0, max);
210156
- if (items.length < max && restNode) items = [...items, ...Array(max - items.length).fill(restNode)];
210157
- }
210158
- if (min !== void 0) items = items.map((item, i) => i >= min ? createOptionalTypeNode(item) : item);
210159
- if (max === void 0 && restNode) items.push(createRestTypeNode(createArrayTypeNode(restNode)));
210160
- return createTupleTypeNode(items);
210161
- }
210162
- function buildPropertyType(schema, baseType, optionalType) {
210163
- const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
210164
- let type = baseType;
210165
- if (schema.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
210166
- if ((schema.nullish || schema.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
210167
- return type;
210168
- }
210169
- function buildPropertyJSDocComments(schema) {
210170
- return [
210171
- "description" in schema && schema.description ? `@description ${jsStringEscape$1(schema.description)}` : void 0,
210172
- "deprecated" in schema && schema.deprecated ? "@deprecated" : void 0,
210173
- "min" in schema && schema.min !== void 0 ? `@minLength ${schema.min}` : void 0,
210174
- "max" in schema && schema.max !== void 0 ? `@maxLength ${schema.max}` : void 0,
210175
- "pattern" in schema && schema.pattern ? `@pattern ${schema.pattern}` : void 0,
210176
- "default" in schema && schema.default !== void 0 ? `@default ${"primitive" in schema && schema.primitive === "string" ? stringify$1(schema.default) : schema.default}` : void 0,
210177
- "example" in schema && schema.example !== void 0 ? `@example ${schema.example}` : void 0,
210178
- "primitive" in schema && schema.primitive ? [`@type ${schema.primitive || "unknown"}`, "optional" in schema && schema.optional ? " | undefined" : void 0].filter(Boolean).join("") : void 0
210179
- ];
210180
- }
210181
- function buildIndexSignatures(node, propertyCount, print) {
210182
- var _a, _b;
210183
- const elements = [];
210184
- if (node.additionalProperties && node.additionalProperties !== true) {
210185
- const additionalType = (_a = print(node.additionalProperties)) != null ? _a : keywordTypeNodes.unknown;
210186
- elements.push(createIndexSignature(propertyCount > 0 ? keywordTypeNodes.unknown : additionalType));
210187
- } else if (node.additionalProperties === true) elements.push(createIndexSignature(keywordTypeNodes.unknown));
210188
- if (node.patternProperties) {
210189
- const first = Object.values(node.patternProperties)[0];
210190
- if (first) {
210191
- let patternType = (_b = print(first)) != null ? _b : keywordTypeNodes.unknown;
210192
- if (first.nullable) patternType = createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] });
210193
- elements.push(createIndexSignature(patternType));
210194
- }
210195
- }
210196
- return elements;
210197
- }
210198
- const printerTs = definePrinter((options) => {
210199
- const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
210200
- return {
210201
- name: "typescript",
210202
- options,
210203
- nodes: {
210204
- any: () => keywordTypeNodes.any,
210205
- unknown: () => keywordTypeNodes.unknown,
210206
- void: () => keywordTypeNodes.void,
210207
- never: () => keywordTypeNodes.never,
210208
- boolean: () => keywordTypeNodes.boolean,
210209
- null: () => keywordTypeNodes.null,
210210
- blob: () => createTypeReferenceNode("Blob", []),
210211
- string: () => keywordTypeNodes.string,
210212
- uuid: () => keywordTypeNodes.string,
210213
- email: () => keywordTypeNodes.string,
210214
- url: (node) => {
210215
- if (node.path) return createUrlTemplateType(node.path);
210216
- return keywordTypeNodes.string;
210217
- },
210218
- datetime: () => keywordTypeNodes.string,
210219
- number: () => keywordTypeNodes.number,
210220
- integer: () => keywordTypeNodes.number,
210221
- bigint: () => keywordTypeNodes.bigint,
210222
- date: dateOrStringNode,
210223
- time: dateOrStringNode,
210224
- ref(node) {
210225
- if (!node.name) return;
210226
- return createTypeReferenceNode(node.name, void 0);
210227
- },
210228
- enum(node) {
210229
- var _a, _b, _c, _d;
210230
- const values = (_c = (_b = (_a = node.namedEnumValues) == null ? void 0 : _a.map((v) => v.value)) != null ? _b : node.enumValues) != null ? _c : [];
210231
- if (this.options.enumType === "inlineLiteral" || !node.name) return (_d = createUnionDeclaration({
210232
- withParentheses: true,
210233
- nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
210234
- })) != null ? _d : void 0;
210235
- const resolvedName = pascalCase$6(node.name);
210236
- return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) ? `${resolvedName}Key` : resolvedName, void 0);
210237
- },
210238
- union(node) {
210239
- var _a, _b, _c;
210240
- const members = (_a = node.members) != null ? _a : [];
210241
- const hasStringLiteral = members.some((m) => m.type === "enum" && (m.enumType === "string" || m.primitive === "string"));
210242
- const hasPlainString = members.some((m) => isPlainStringType(m));
210243
- if (hasStringLiteral && hasPlainString) return (_b = createUnionDeclaration({
210244
- withParentheses: true,
210245
- nodes: members.map((m) => {
210246
- if (isPlainStringType(m)) return createIntersectionDeclaration({
210247
- nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
210248
- withParentheses: true
210249
- });
210250
- return this.print(m);
210251
- }).filter(Boolean)
210252
- })) != null ? _b : void 0;
210253
- return (_c = createUnionDeclaration({
210254
- withParentheses: true,
210255
- nodes: buildMemberNodes(members, this.print)
210256
- })) != null ? _c : void 0;
210257
- },
210258
- intersection(node) {
210259
- var _a;
210260
- return (_a = createIntersectionDeclaration({
210261
- withParentheses: true,
210262
- nodes: buildMemberNodes(node.members, this.print)
210263
- })) != null ? _a : void 0;
210264
- },
210265
- array(node) {
210266
- var _a, _b;
210267
- return (_b = createArrayDeclaration({
210268
- nodes: ((_a = node.items) != null ? _a : []).map((item) => this.print(item)).filter(Boolean),
210269
- arrayType: this.options.arrayType
210270
- })) != null ? _b : void 0;
210271
- },
210272
- tuple(node) {
210273
- return buildTupleNode(node, this.print);
210274
- },
210275
- object(node) {
210276
- const { print, options: options2 } = this;
210277
- const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options2.optionalType);
210278
- const propertyNodes = node.properties.map((prop) => {
210279
- var _a;
210280
- const baseType = (_a = print(prop.schema)) != null ? _a : keywordTypeNodes.unknown;
210281
- const type = buildPropertyType(prop.schema, baseType, options2.optionalType);
210282
- return appendJSDocToNode({
210283
- node: createPropertySignature({
210284
- questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,
210285
- name: prop.name,
210286
- type,
210287
- readOnly: prop.schema.readOnly
210288
- }),
210289
- comments: buildPropertyJSDocComments(prop.schema)
210290
- });
210291
- });
210292
- const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, print)];
210293
- if (!allElements.length) return keywordTypeNodes.object;
210294
- return createTypeLiteralNode(allElements);
210295
- }
210296
- },
210297
- print(node) {
210298
- let type = this.print(node);
210299
- if (!type) return;
210300
- if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
210301
- if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
210302
- const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
210303
- if (!typeName) return type;
210304
- const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!(keysToOmit == null ? void 0 : keysToOmit.length);
210305
- return createTypeDeclaration({
210306
- name: typeName,
210307
- isExportable: true,
210308
- type: (keysToOmit == null ? void 0 : keysToOmit.length) ? createOmitDeclaration({
210309
- keys: keysToOmit,
210310
- type,
210311
- nonNullable: true
210312
- }) : type,
210313
- syntax: useTypeGeneration ? "type" : "interface",
210314
- comments: [
210315
- (node == null ? void 0 : node.title) ? jsStringEscape$1(node.title) : void 0,
210316
- description ? `@description ${jsStringEscape$1(description)}` : void 0,
210317
- (node == null ? void 0 : node.deprecated) ? "@deprecated" : void 0,
210318
- node && "min" in node && node.min !== void 0 ? `@minLength ${node.min}` : void 0,
210319
- node && "max" in node && node.max !== void 0 ? `@maxLength ${node.max}` : void 0,
210320
- node && "pattern" in node && node.pattern ? `@pattern ${node.pattern}` : void 0,
210321
- (node == null ? void 0 : node.default) ? `@default ${node.default}` : void 0,
210322
- (node == null ? void 0 : node.example) ? `@example ${node.example}` : void 0
210323
- ]
210324
- });
210325
- }
210326
- };
210327
- });
210328
- function getEnumNames(node, enumType) {
210329
- const resolved = pascalCase$6(node.name);
210330
- return {
210331
- enumName: enumType === "asPascalConst" ? resolved : camelCase$a(node.name),
210332
- typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? `${resolved}Key` : resolved
210333
- };
210334
- }
210335
- function Enum({ node, enumType, enumKeyCasing }) {
210336
- var _a, _b, _c, _d;
210337
- const { enumName, typeName } = getEnumNames(node, enumType);
210338
- const [nameNode, typeNode] = createEnumDeclaration({
210339
- name: enumName,
210340
- typeName,
210341
- 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 : [],
210342
- type: enumType,
210343
- enumKeyCasing
210344
- });
210345
- return /* @__PURE__ */ jsxs(Fragment, { children: [nameNode && /* @__PURE__ */ jsx(File.Source, {
210346
- name: enumName,
210347
- isExportable: true,
210348
- isIndexable: true,
210349
- isTypeOnly: false,
210350
- children: safePrint(nameNode)
210351
- }), /* @__PURE__ */ jsx(File.Source, {
210352
- name: typeName,
210353
- isIndexable: true,
210354
- isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
210355
- isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
210356
- children: safePrint(typeNode)
210357
- })] });
210358
- }
210359
- function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description }) {
210360
- const resolvedDescription = description || (node == null ? void 0 : node.description);
210361
- const enumSchemaNodes = collect(node, { schema(n) {
210362
- if (n.type === "enum" && n.name) return n;
210363
- } });
210364
- const typeNode = printerTs({
210365
- optionalType,
210366
- arrayType,
210367
- enumType,
210368
- typeName: name,
210369
- syntaxType,
210370
- description: resolvedDescription,
210371
- keysToOmit
210372
- }).print(node);
210373
- if (!typeNode) return;
210374
- const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node2) => {
210375
- return {
210376
- node: node2,
210377
- ...getEnumNames(node2, enumType)
210378
- };
210379
- });
210380
- const shouldExportEnums = enumType !== "inlineLiteral";
210381
- const shouldExportType = enumType === "inlineLiteral" || enums.every((item) => item.typeName !== name);
210382
- return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({ node: node2 }) => /* @__PURE__ */ jsx(Enum, {
210383
- node: node2,
210384
- enumType,
210385
- enumKeyCasing
210386
- })), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
210387
- name: typedName,
210388
- isTypeOnly: true,
210389
- isExportable: true,
210390
- isIndexable: true,
210391
- children: safePrint(typeNode)
210392
- })] });
210393
- }
210394
- const resolverTs = defineResolver(() => {
210395
- return {
210396
- default(name, type) {
210397
- return pascalCase$6(name, { isFile: type === "file" });
210398
- },
210399
- resolveName(name) {
210400
- return this.default(name, "function");
210401
- },
210402
- resolveTypedName(name) {
210403
- return this.default(name, "type");
210404
- },
210405
- resolvePathName(name, type) {
210406
- return this.default(name, type);
210407
- },
210408
- resolveParamName(node, param) {
210409
- return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210410
- },
210411
- resolveParamTypedName(node, param) {
210412
- return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210413
- },
210414
- resolveResponseStatusName(node, statusCode) {
210415
- return this.resolveName(`${node.operationId} Status ${statusCode}`);
210416
- },
210417
- resolveResponseStatusTypedName(node, statusCode) {
210418
- return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
210419
- },
210420
- resolveDataName(node) {
210421
- return this.resolveName(`${node.operationId} Data`);
210422
- },
210423
- resolveDataTypedName(node) {
210424
- return this.resolveTypedName(`${node.operationId} Data`);
210425
- },
210426
- resolveRequestConfigName(node) {
210427
- return this.resolveName(`${node.operationId} RequestConfig`);
210428
- },
210429
- resolveRequestConfigTypedName(node) {
210430
- return this.resolveTypedName(`${node.operationId} RequestConfig`);
210431
- },
210432
- resolveResponsesName(node) {
210433
- return this.resolveName(`${node.operationId} Responses`);
210434
- },
210435
- resolveResponsesTypedName(node) {
210436
- return this.resolveTypedName(`${node.operationId} Responses`);
210437
- },
210438
- resolveResponseName(node) {
210439
- return this.resolveName(`${node.operationId} Response`);
210440
- },
210441
- resolveResponseTypedName(node) {
210442
- return this.resolveTypedName(`${node.operationId} Response`);
210443
- },
210444
- resolveEnumKeyTypedName(node) {
210445
- var _a;
210446
- return `${this.resolveTypedName((_a = node.name) != null ? _a : "")}Key`;
210447
- }
210448
- };
210449
- });
210450
- function buildParamsSchema({ params, operationId, resolveName }) {
209637
+ function buildParamsSchema({ params, node, resolver }) {
210451
209638
  return createSchema({
210452
209639
  type: "object",
210453
209640
  properties: params.map((param) => createProperty({
210454
209641
  name: param.name,
210455
209642
  schema: createSchema({
210456
209643
  type: "ref",
210457
- name: resolveName({
210458
- name: `${operationId} ${pascalCase$6(param.in)} ${param.name}`,
210459
- type: "function"
210460
- }),
209644
+ name: resolver.resolveParamName(node, param),
210461
209645
  optional: !param.required
210462
209646
  })
210463
209647
  }))
210464
209648
  });
210465
209649
  }
210466
- function buildDataSchemaNode({ node, resolveName }) {
209650
+ function buildDataSchemaNode({ node, resolver }) {
209651
+ var _a;
210467
209652
  const pathParams = node.parameters.filter((p) => p.in === "path");
210468
209653
  const queryParams = node.parameters.filter((p) => p.in === "query");
210469
209654
  const headerParams = node.parameters.filter((p) => p.in === "header");
@@ -210473,12 +209658,9 @@ function buildDataSchemaNode({ node, resolveName }) {
210473
209658
  properties: [
210474
209659
  createProperty({
210475
209660
  name: "data",
210476
- schema: node.requestBody ? createSchema({
209661
+ schema: ((_a = node.requestBody) == null ? void 0 : _a.schema) ? createSchema({
210477
209662
  type: "ref",
210478
- name: resolveName({
210479
- name: `${node.operationId} Data`,
210480
- type: "function"
210481
- }),
209663
+ name: resolver.resolveDataTypedName(node),
210482
209664
  optional: true
210483
209665
  }) : createSchema({
210484
209666
  type: "never",
@@ -210489,8 +209671,8 @@ function buildDataSchemaNode({ node, resolveName }) {
210489
209671
  name: "pathParams",
210490
209672
  schema: pathParams.length > 0 ? buildParamsSchema({
210491
209673
  params: pathParams,
210492
- operationId: node.operationId,
210493
- resolveName
209674
+ node,
209675
+ resolver
210494
209676
  }) : createSchema({
210495
209677
  type: "never",
210496
209678
  optional: true
@@ -210501,8 +209683,8 @@ function buildDataSchemaNode({ node, resolveName }) {
210501
209683
  schema: queryParams.length > 0 ? createSchema({
210502
209684
  ...buildParamsSchema({
210503
209685
  params: queryParams,
210504
- operationId: node.operationId,
210505
- resolveName
209686
+ node,
209687
+ resolver
210506
209688
  }),
210507
209689
  optional: true
210508
209690
  }) : createSchema({
@@ -210515,8 +209697,8 @@ function buildDataSchemaNode({ node, resolveName }) {
210515
209697
  schema: headerParams.length > 0 ? createSchema({
210516
209698
  ...buildParamsSchema({
210517
209699
  params: headerParams,
210518
- operationId: node.operationId,
210519
- resolveName
209700
+ node,
209701
+ resolver
210520
209702
  }),
210521
209703
  optional: true
210522
209704
  }) : createSchema({
@@ -210534,7 +209716,7 @@ function buildDataSchemaNode({ node, resolveName }) {
210534
209716
  ]
210535
209717
  });
210536
209718
  }
210537
- function buildResponsesSchemaNode({ node, resolveName }) {
209719
+ function buildResponsesSchemaNode({ node, resolver }) {
210538
209720
  if (node.responses.length === 0) return null;
210539
209721
  return createSchema({
210540
209722
  type: "object",
@@ -210542,48 +209724,174 @@ function buildResponsesSchemaNode({ node, resolveName }) {
210542
209724
  name: String(res.statusCode),
210543
209725
  schema: createSchema({
210544
209726
  type: "ref",
210545
- name: resolveName({
210546
- name: `${node.operationId} Status ${res.statusCode}`,
210547
- type: "function"
210548
- })
209727
+ name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
210549
209728
  })
210550
209729
  }))
210551
209730
  });
210552
209731
  }
210553
- function buildResponseUnionSchemaNode({ node, resolveName }) {
209732
+ function buildResponseUnionSchemaNode({ node, resolver }) {
210554
209733
  const responsesWithSchema = node.responses.filter((res) => res.schema);
210555
209734
  if (responsesWithSchema.length === 0) return null;
210556
209735
  return createSchema({
210557
209736
  type: "union",
210558
209737
  members: responsesWithSchema.map((res) => createSchema({
210559
209738
  type: "ref",
210560
- name: resolveName({
210561
- name: `${node.operationId} Status ${res.statusCode}`,
210562
- type: "function"
210563
- })
209739
+ name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
210564
209740
  }))
210565
209741
  });
210566
209742
  }
209743
+ function buildGroupedParamsSchema({ params, parentName }) {
209744
+ return createSchema({
209745
+ type: "object",
209746
+ properties: params.map((param) => {
209747
+ let schema = {
209748
+ ...param.schema,
209749
+ optional: !param.required
209750
+ };
209751
+ if (narrowSchema(schema, "enum") && !schema.name && parentName) schema = {
209752
+ ...schema,
209753
+ name: pascalCase$6([
209754
+ parentName,
209755
+ param.name,
209756
+ "enum"
209757
+ ].join(" "))
209758
+ };
209759
+ return createProperty({
209760
+ name: param.name,
209761
+ schema
209762
+ });
209763
+ })
209764
+ });
209765
+ }
209766
+ function buildLegacyResponsesSchemaNode({ node, resolver }) {
209767
+ var _a;
209768
+ const isGet = node.method.toLowerCase() === "get";
209769
+ const successResponses = node.responses.filter((res) => {
209770
+ const code = Number(res.statusCode);
209771
+ return !Number.isNaN(code) && code >= 200 && code < 300;
209772
+ });
209773
+ const errorResponses = node.responses.filter((res) => res.statusCode === "default" || Number(res.statusCode) >= 400);
209774
+ const responseSchema = successResponses.length > 0 ? successResponses.length === 1 ? createSchema({
209775
+ type: "ref",
209776
+ name: resolver.resolveResponseStatusTypedName(node, successResponses[0].statusCode)
209777
+ }) : createSchema({
209778
+ type: "union",
209779
+ members: successResponses.map((res) => createSchema({
209780
+ type: "ref",
209781
+ name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
209782
+ }))
209783
+ }) : createSchema({ type: "any" });
209784
+ const errorsSchema = errorResponses.length > 0 ? errorResponses.length === 1 ? createSchema({
209785
+ type: "ref",
209786
+ name: resolver.resolveResponseStatusTypedName(node, errorResponses[0].statusCode)
209787
+ }) : createSchema({
209788
+ type: "union",
209789
+ members: errorResponses.map((res) => createSchema({
209790
+ type: "ref",
209791
+ name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
209792
+ }))
209793
+ }) : createSchema({ type: "any" });
209794
+ const properties = [createProperty({
209795
+ name: "Response",
209796
+ schema: responseSchema
209797
+ })];
209798
+ if (!isGet && ((_a = node.requestBody) == null ? void 0 : _a.schema)) properties.push(createProperty({
209799
+ name: "Request",
209800
+ schema: createSchema({
209801
+ type: "ref",
209802
+ name: resolver.resolveDataTypedName(node)
209803
+ })
209804
+ }));
209805
+ if (node.parameters.some((p) => p.in === "query") && resolver.resolveQueryParamsTypedName) properties.push(createProperty({
209806
+ name: "QueryParams",
209807
+ schema: createSchema({
209808
+ type: "ref",
209809
+ name: resolver.resolveQueryParamsTypedName(node)
209810
+ })
209811
+ }));
209812
+ if (node.parameters.some((p) => p.in === "path") && resolver.resolvePathParamsTypedName) properties.push(createProperty({
209813
+ name: "PathParams",
209814
+ schema: createSchema({
209815
+ type: "ref",
209816
+ name: resolver.resolvePathParamsTypedName(node)
209817
+ })
209818
+ }));
209819
+ if (node.parameters.some((p) => p.in === "header") && resolver.resolveHeaderParamsTypedName) properties.push(createProperty({
209820
+ name: "HeaderParams",
209821
+ schema: createSchema({
209822
+ type: "ref",
209823
+ name: resolver.resolveHeaderParamsTypedName(node)
209824
+ })
209825
+ }));
209826
+ properties.push(createProperty({
209827
+ name: "Errors",
209828
+ schema: errorsSchema
209829
+ }));
209830
+ return createSchema({
209831
+ type: "object",
209832
+ properties
209833
+ });
209834
+ }
209835
+ function buildLegacyResponseUnionSchemaNode({ node, resolver }) {
209836
+ const successResponses = node.responses.filter((res) => {
209837
+ const code = Number(res.statusCode);
209838
+ return !Number.isNaN(code) && code >= 200 && code < 300;
209839
+ });
209840
+ if (successResponses.length === 0) return createSchema({ type: "any" });
209841
+ if (successResponses.length === 1) return createSchema({
209842
+ type: "ref",
209843
+ name: resolver.resolveResponseStatusTypedName(node, successResponses[0].statusCode)
209844
+ });
209845
+ return createSchema({
209846
+ type: "union",
209847
+ members: successResponses.map((res) => createSchema({
209848
+ type: "ref",
209849
+ name: resolver.resolveResponseStatusTypedName(node, res.statusCode)
209850
+ }))
209851
+ });
209852
+ }
209853
+ function nameUnnamedEnums(node, parentName) {
209854
+ return transform(node, {
209855
+ schema(n) {
209856
+ if (n.type === "enum" && !n.name) return {
209857
+ ...n,
209858
+ name: pascalCase$6([parentName, "enum"].join(" "))
209859
+ };
209860
+ },
209861
+ property(p) {
209862
+ const enumNode = narrowSchema(p.schema, "enum");
209863
+ if (enumNode && !enumNode.name) return {
209864
+ ...p,
209865
+ schema: {
209866
+ ...enumNode,
209867
+ name: pascalCase$6([
209868
+ parentName,
209869
+ p.name,
209870
+ "enum"
209871
+ ].join(" "))
209872
+ }
209873
+ };
209874
+ }
209875
+ });
209876
+ }
210567
209877
  const typeGenerator = defineGenerator({
210568
209878
  name: "typescript",
210569
209879
  type: "react",
210570
209880
  Operation({ node, adapter, options }) {
210571
- const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group } = options;
210572
- const { mode, getFile, resolveName, resolveBanner, resolveFooter } = useKubb();
209881
+ var _a, _b, _c;
209882
+ const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group, resolver, baseResolver, legacy } = options;
209883
+ const { mode, getFile, resolveBanner, resolveFooter } = useKubb();
210573
209884
  const file = getFile({
210574
209885
  name: node.operationId,
210575
209886
  extname: ".ts",
210576
209887
  mode,
210577
- options: { group: group ? group.type === "tag" ? { tag: node.tags[0] } : { path: node.path } : void 0 }
209888
+ options: { group: group ? group.type === "tag" ? { tag: (_a = node.tags[0]) != null ? _a : "default" } : { path: node.path } : void 0 }
210578
209889
  });
210579
209890
  const params = applyParamsCasing$1(node.parameters, paramsCasing);
210580
- function renderSchemaType({ node: schemaNode, name, typedName, description }) {
209891
+ function renderSchemaType({ node: schemaNode, name, typedName, description, keysToOmit }) {
210581
209892
  if (!schemaNode) return null;
210582
209893
  const imports = adapter.getImports(schemaNode, (schemaName) => ({
210583
- name: resolveName({
210584
- name: schemaName,
210585
- type: "type"
210586
- }),
209894
+ name: resolver.default(schemaName, "type"),
210587
209895
  path: getFile({
210588
209896
  name: schemaName,
210589
209897
  extname: ".ts",
@@ -210608,25 +209916,111 @@ const typeGenerator = defineGenerator({
210608
209916
  enumKeyCasing,
210609
209917
  optionalType,
210610
209918
  arrayType,
210611
- syntaxType
209919
+ syntaxType,
209920
+ resolver,
209921
+ keysToOmit,
209922
+ legacy
210612
209923
  })] });
210613
209924
  }
209925
+ const responseTypes = legacy ? node.responses.map((res) => {
209926
+ const responseName = resolver.resolveResponseStatusName(node, res.statusCode);
209927
+ const baseResponseName = (baseResolver != null ? baseResolver : resolver).resolveResponseStatusName(node, res.statusCode);
209928
+ return renderSchemaType({
209929
+ node: res.schema ? nameUnnamedEnums(res.schema, baseResponseName) : res.schema,
209930
+ name: responseName,
209931
+ typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
209932
+ description: res.description,
209933
+ keysToOmit: res.keysToOmit
209934
+ });
209935
+ }) : node.responses.map((res) => renderSchemaType({
209936
+ node: res.schema,
209937
+ name: resolver.resolveResponseStatusName(node, res.statusCode),
209938
+ typedName: resolver.resolveResponseStatusTypedName(node, res.statusCode),
209939
+ description: res.description,
209940
+ keysToOmit: res.keysToOmit
209941
+ }));
209942
+ const requestType = ((_b = node.requestBody) == null ? void 0 : _b.schema) ? renderSchemaType({
209943
+ node: legacy ? nameUnnamedEnums(node.requestBody.schema, (baseResolver != null ? baseResolver : resolver).resolveDataName(node)) : node.requestBody.schema,
209944
+ name: resolver.resolveDataName(node),
209945
+ typedName: resolver.resolveDataTypedName(node),
209946
+ description: (_c = node.requestBody.description) != null ? _c : node.requestBody.schema.description,
209947
+ keysToOmit: node.requestBody.keysToOmit
209948
+ }) : null;
209949
+ if (legacy) {
209950
+ const pathParams = params.filter((p) => p.in === "path");
209951
+ const queryParams = params.filter((p) => p.in === "query");
209952
+ const headerParams = params.filter((p) => p.in === "header");
209953
+ const legacyParamTypes = [
209954
+ pathParams.length > 0 ? renderSchemaType({
209955
+ node: buildGroupedParamsSchema({
209956
+ params: pathParams,
209957
+ parentName: (baseResolver != null ? baseResolver : resolver).resolvePathParamsName(node)
209958
+ }),
209959
+ name: resolver.resolvePathParamsName(node),
209960
+ typedName: resolver.resolvePathParamsTypedName(node)
209961
+ }) : null,
209962
+ queryParams.length > 0 ? renderSchemaType({
209963
+ node: buildGroupedParamsSchema({
209964
+ params: queryParams,
209965
+ parentName: (baseResolver != null ? baseResolver : resolver).resolveQueryParamsName(node)
209966
+ }),
209967
+ name: resolver.resolveQueryParamsName(node),
209968
+ typedName: resolver.resolveQueryParamsTypedName(node)
209969
+ }) : null,
209970
+ headerParams.length > 0 ? renderSchemaType({
209971
+ node: buildGroupedParamsSchema({
209972
+ params: headerParams,
209973
+ parentName: (baseResolver != null ? baseResolver : resolver).resolveHeaderParamsName(node)
209974
+ }),
209975
+ name: resolver.resolveHeaderParamsName(node),
209976
+ typedName: resolver.resolveHeaderParamsTypedName(node)
209977
+ }) : null
209978
+ ];
209979
+ const legacyResponsesType = renderSchemaType({
209980
+ node: buildLegacyResponsesSchemaNode({
209981
+ node,
209982
+ resolver
209983
+ }),
209984
+ name: resolver.resolveResponsesName(node),
209985
+ typedName: resolver.resolveResponsesTypedName(node)
209986
+ });
209987
+ const legacyResponseType = renderSchemaType({
209988
+ node: buildLegacyResponseUnionSchemaNode({
209989
+ node,
209990
+ resolver
209991
+ }),
209992
+ name: resolver.resolveResponseName(node),
209993
+ typedName: resolver.resolveResponseTypedName(node)
209994
+ });
209995
+ return /* @__PURE__ */ jsxs(File, {
209996
+ baseName: file.baseName,
209997
+ path: file.path,
209998
+ meta: file.meta,
209999
+ banner: resolveBanner(),
210000
+ footer: resolveFooter(),
210001
+ children: [
210002
+ legacyParamTypes,
210003
+ responseTypes,
210004
+ requestType,
210005
+ legacyResponseType,
210006
+ legacyResponsesType
210007
+ ]
210008
+ });
210009
+ }
210614
210010
  const paramTypes = params.map((param) => renderSchemaType({
210615
210011
  node: param.schema,
210616
- name: resolverTs.resolveParamName(node, param),
210617
- typedName: resolverTs.resolveParamTypedName(node, param)
210012
+ name: resolver.resolveParamName(node, param),
210013
+ typedName: resolver.resolveParamTypedName(node, param)
210618
210014
  }));
210619
- const responseTypes = node.responses.map((res) => renderSchemaType({
210620
- node: res.schema,
210621
- name: resolverTs.resolveResponseStatusName(node, res.statusCode),
210622
- typedName: resolverTs.resolveResponseStatusTypedName(node, res.statusCode),
210623
- description: res.description
210624
- }));
210625
- const requestType = node.requestBody ? renderSchemaType({
210626
- node: node.requestBody,
210627
- name: resolverTs.resolveDataName(node),
210628
- typedName: resolverTs.resolveDataTypedName(node),
210629
- description: node.requestBody.description
210015
+ const queryParamsList = params.filter((p) => p.in === "query");
210016
+ const queryParamsType = queryParamsList.length > 0 ? renderSchemaType({
210017
+ node: buildParamsSchema({
210018
+ params: queryParamsList,
210019
+ node,
210020
+ resolver
210021
+ }),
210022
+ name: resolver.resolveQueryParamsName(node),
210023
+ typedName: resolver.resolveQueryParamsTypedName(node)
210630
210024
  }) : null;
210631
210025
  const dataType = renderSchemaType({
210632
210026
  node: buildDataSchemaNode({
@@ -210634,26 +210028,26 @@ const typeGenerator = defineGenerator({
210634
210028
  ...node,
210635
210029
  parameters: params
210636
210030
  },
210637
- resolveName
210031
+ resolver
210638
210032
  }),
210639
- name: resolverTs.resolveRequestConfigName(node),
210640
- typedName: resolverTs.resolveRequestConfigTypedName(node)
210033
+ name: resolver.resolveRequestConfigName(node),
210034
+ typedName: resolver.resolveRequestConfigTypedName(node)
210641
210035
  });
210642
210036
  const responsesType = renderSchemaType({
210643
210037
  node: buildResponsesSchemaNode({
210644
210038
  node,
210645
- resolveName
210039
+ resolver
210646
210040
  }),
210647
- name: resolverTs.resolveResponsesName(node),
210648
- typedName: resolverTs.resolveResponsesTypedName(node)
210041
+ name: resolver.resolveResponsesName(node),
210042
+ typedName: resolver.resolveResponsesTypedName(node)
210649
210043
  });
210650
210044
  const responseType = renderSchemaType({
210651
210045
  node: buildResponseUnionSchemaNode({
210652
210046
  node,
210653
- resolveName
210047
+ resolver
210654
210048
  }),
210655
- name: resolverTs.resolveResponseName(node),
210656
- typedName: resolverTs.resolveResponseTypedName(node),
210049
+ name: resolver.resolveResponseName(node),
210050
+ typedName: resolver.resolveResponseTypedName(node),
210657
210051
  description: "Union of all possible responses"
210658
210052
  });
210659
210053
  return /* @__PURE__ */ jsxs(File, {
@@ -210664,6 +210058,7 @@ const typeGenerator = defineGenerator({
210664
210058
  footer: resolveFooter(),
210665
210059
  children: [
210666
210060
  paramTypes,
210061
+ queryParamsType,
210667
210062
  responseTypes,
210668
210063
  requestType,
210669
210064
  dataType,
@@ -210673,14 +210068,11 @@ const typeGenerator = defineGenerator({
210673
210068
  });
210674
210069
  },
210675
210070
  Schema({ node, adapter, options }) {
210676
- const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options;
210677
- const { mode, resolveName, getFile, resolveBanner, resolveFooter } = useKubb();
210071
+ const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, resolver, legacy } = options;
210072
+ const { mode, getFile, resolveBanner, resolveFooter } = useKubb();
210678
210073
  if (!node.name) return;
210679
210074
  const imports = adapter.getImports(node, (schemaName) => ({
210680
- name: resolveName({
210681
- name: schemaName,
210682
- type: "type"
210683
- }),
210075
+ name: resolver.default(schemaName, "type"),
210684
210076
  path: getFile({
210685
210077
  name: schemaName,
210686
210078
  extname: ".ts",
@@ -210688,9 +210080,9 @@ const typeGenerator = defineGenerator({
210688
210080
  }).path
210689
210081
  }));
210690
210082
  const isEnumSchema = node.type === "enum";
210691
- const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolverTs.resolveEnumKeyTypedName(node) : resolverTs.resolveTypedName(node.name);
210083
+ const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolver.resolveEnumKeyTypedName(node) : resolver.resolveTypedName(node.name);
210692
210084
  const type = {
210693
- name: resolverTs.resolveName(node.name),
210085
+ name: resolver.resolveName(node.name),
210694
210086
  typedName,
210695
210087
  file: getFile({
210696
210088
  name: node.name,
@@ -210721,38 +210113,179 @@ const typeGenerator = defineGenerator({
210721
210113
  enumKeyCasing,
210722
210114
  optionalType,
210723
210115
  arrayType,
210724
- syntaxType
210116
+ syntaxType,
210117
+ resolver,
210118
+ legacy
210725
210119
  })]
210726
210120
  });
210727
210121
  }
210728
210122
  });
210123
+
210124
+ function resolveName(name, type) {
210125
+ return pascalCase$6(name, { isFile: type === "file" });
210126
+ }
210127
+ const resolverTs = defineResolver(() => {
210128
+ return {
210129
+ default(name, type) {
210130
+ return resolveName(name, type);
210131
+ },
210132
+ resolveName(name) {
210133
+ return this.default(name, "function");
210134
+ },
210135
+ resolveTypedName(name) {
210136
+ return this.default(name, "type");
210137
+ },
210138
+ resolvePathName(name, type) {
210139
+ return this.default(name, type);
210140
+ },
210141
+ resolveParamName(node, param) {
210142
+ return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210143
+ },
210144
+ resolveParamTypedName(node, param) {
210145
+ return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
210146
+ },
210147
+ resolveResponseStatusName(node, statusCode) {
210148
+ return this.resolveName(`${node.operationId} Status ${statusCode}`);
210149
+ },
210150
+ resolveResponseStatusTypedName(node, statusCode) {
210151
+ return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
210152
+ },
210153
+ resolveDataName(node) {
210154
+ return this.resolveName(`${node.operationId} Data`);
210155
+ },
210156
+ resolveDataTypedName(node) {
210157
+ return this.resolveTypedName(`${node.operationId} Data`);
210158
+ },
210159
+ resolveRequestConfigName(node) {
210160
+ return this.resolveName(`${node.operationId} RequestConfig`);
210161
+ },
210162
+ resolveRequestConfigTypedName(node) {
210163
+ return this.resolveTypedName(`${node.operationId} RequestConfig`);
210164
+ },
210165
+ resolveResponsesName(node) {
210166
+ return this.resolveName(`${node.operationId} Responses`);
210167
+ },
210168
+ resolveResponsesTypedName(node) {
210169
+ return this.resolveTypedName(`${node.operationId} Responses`);
210170
+ },
210171
+ resolveResponseName(node) {
210172
+ return this.resolveName(`${node.operationId} Response`);
210173
+ },
210174
+ resolveResponseTypedName(node) {
210175
+ return this.resolveTypedName(`${node.operationId} Response`);
210176
+ },
210177
+ resolveEnumKeyTypedName(node) {
210178
+ var _a;
210179
+ return `${this.resolveTypedName((_a = node.name) != null ? _a : "")}Key`;
210180
+ },
210181
+ resolvePathParamsName(_node) {
210182
+ throw new Error("resolvePathParamsName is only available in legacy mode (legacy: true). Use resolveParamName per individual parameter instead.");
210183
+ },
210184
+ resolvePathParamsTypedName(_node) {
210185
+ throw new Error("resolvePathParamsTypedName is only available in legacy mode (legacy: true). Use resolveParamTypedName per individual parameter instead.");
210186
+ },
210187
+ resolveQueryParamsName(node) {
210188
+ return this.resolveName(`${node.operationId} QueryParams`);
210189
+ },
210190
+ resolveQueryParamsTypedName(node) {
210191
+ return this.resolveTypedName(`${node.operationId} QueryParams`);
210192
+ },
210193
+ resolveHeaderParamsName(_node) {
210194
+ throw new Error("resolveHeaderParamsName is only available in legacy mode (legacy: true). Use resolveParamName per individual parameter instead.");
210195
+ },
210196
+ resolveHeaderParamsTypedName(_node) {
210197
+ throw new Error("resolveHeaderParamsTypedName is only available in legacy mode (legacy: true). Use resolveParamTypedName per individual parameter instead.");
210198
+ }
210199
+ };
210200
+ });
210201
+ const resolverTsLegacy = defineResolver(() => {
210202
+ return {
210203
+ ...resolverTs,
210204
+ resolveResponseStatusName(node, statusCode) {
210205
+ if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
210206
+ return this.resolveName(`${node.operationId} ${statusCode}`);
210207
+ },
210208
+ resolveResponseStatusTypedName(node, statusCode) {
210209
+ if (statusCode === "default") return this.resolveTypedName(`${node.operationId} Error`);
210210
+ return this.resolveTypedName(`${node.operationId} ${statusCode}`);
210211
+ },
210212
+ resolveDataName(node) {
210213
+ const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
210214
+ return this.resolveName(`${node.operationId} ${suffix}`);
210215
+ },
210216
+ resolveDataTypedName(node) {
210217
+ const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
210218
+ return this.resolveTypedName(`${node.operationId} ${suffix}`);
210219
+ },
210220
+ resolveResponsesName(node) {
210221
+ const suffix = node.method === "GET" ? "Query" : "Mutation";
210222
+ return `${this.default(node.operationId, "function")}${suffix}`;
210223
+ },
210224
+ resolveResponsesTypedName(node) {
210225
+ const suffix = node.method === "GET" ? "Query" : "Mutation";
210226
+ return `${this.default(node.operationId, "type")}${suffix}`;
210227
+ },
210228
+ resolveResponseName(node) {
210229
+ const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
210230
+ return this.resolveName(`${node.operationId} ${suffix}`);
210231
+ },
210232
+ resolveResponseTypedName(node) {
210233
+ const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
210234
+ return this.resolveTypedName(`${node.operationId} ${suffix}`);
210235
+ },
210236
+ resolvePathParamsName(node) {
210237
+ return this.resolveName(`${node.operationId} PathParams`);
210238
+ },
210239
+ resolvePathParamsTypedName(node) {
210240
+ return this.resolveTypedName(`${node.operationId} PathParams`);
210241
+ },
210242
+ resolveQueryParamsName(node) {
210243
+ return this.resolveName(`${node.operationId} QueryParams`);
210244
+ },
210245
+ resolveQueryParamsTypedName(node) {
210246
+ return this.resolveTypedName(`${node.operationId} QueryParams`);
210247
+ },
210248
+ resolveHeaderParamsName(node) {
210249
+ return this.resolveName(`${node.operationId} HeaderParams`);
210250
+ },
210251
+ resolveHeaderParamsTypedName(node) {
210252
+ return this.resolveTypedName(`${node.operationId} HeaderParams`);
210253
+ }
210254
+ };
210255
+ });
210256
+
210729
210257
  const pluginTsName = "plugin-ts";
210730
210258
  const pluginTs = createPlugin((options) => {
210731
210259
  const { output = {
210732
210260
  path: "types",
210733
210261
  barrelType: "named"
210734
- }, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", enumSuffix = "enum", dateType = "string", integerType = "number", unknownType = "any", optionalType = "questionToken", arrayType = "array", emptySchemaType = unknownType, syntaxType = "type", transformers = {}, paramsCasing, generators = [typeGenerator$1, typeGenerator].filter(Boolean), contentType, UNSTABLE_NAMING } = options;
210262
+ }, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", optionalType = "questionToken", arrayType = "array", syntaxType = "type", transformers = {}, paramsCasing, generators = [typeGenerator].filter(Boolean), legacy = false } = options;
210263
+ const baseResolver = legacy ? resolverTsLegacy : resolverTs;
210264
+ const resolver = (transformers == null ? void 0 : transformers.name) ? {
210265
+ ...baseResolver,
210266
+ default(name, type) {
210267
+ const resolved = baseResolver.default(name, type);
210268
+ return transformers.name(resolved, type) || resolved;
210269
+ }
210270
+ } : baseResolver;
210271
+ let resolveNameWarning = false;
210735
210272
  return {
210736
210273
  name: pluginTsName,
210737
210274
  options: {
210738
210275
  output,
210739
210276
  transformers,
210740
- dateType,
210741
- integerType,
210742
210277
  optionalType,
210743
210278
  arrayType,
210744
210279
  enumType,
210745
210280
  enumKeyCasing,
210746
- enumSuffix,
210747
- unknownType,
210748
- emptySchemaType,
210749
210281
  syntaxType,
210750
210282
  group,
210751
210283
  override,
210752
210284
  paramsCasing,
210753
- usedEnumNames: {}
210285
+ legacy,
210286
+ resolver,
210287
+ baseResolver
210754
210288
  },
210755
- pre: [pluginOasName],
210756
210289
  resolvePath(baseName, pathMode, options2) {
210757
210290
  var _a, _b;
210758
210291
  const root = path$2.resolve(this.config.root, this.config.output.path);
@@ -210768,107 +210301,71 @@ const pluginTs = createPlugin((options) => {
210768
210301
  return path$2.resolve(root, output.path, baseName);
210769
210302
  },
210770
210303
  resolveName(name, type) {
210771
- var _a;
210772
- const resolvedName = resolverTs.default(name, type);
210773
- if (type) return ((_a = transformers == null ? void 0 : transformers.name) == null ? void 0 : _a.call(transformers, resolvedName, type)) || resolvedName;
210774
- return resolvedName;
210304
+ if (!resolveNameWarning) {
210305
+ this.driver.events.emit("warn", "Do not use resolveName for pluginTs, use resolverTs instead");
210306
+ resolveNameWarning = true;
210307
+ }
210308
+ return resolver.default(name, type);
210775
210309
  },
210776
210310
  async install() {
210777
- var _a, _b;
210311
+ var _a;
210778
210312
  const { config, fabric, plugin, adapter, rootNode, driver, openInStudio } = this;
210779
210313
  const root = path$2.resolve(config.root, config.output.path);
210780
210314
  const mode = getMode(path$2.resolve(root, output.path));
210781
- if (adapter) {
210782
- await openInStudio({ ast: true });
210783
- await walk(rootNode, {
210784
- async schema(schemaNode) {
210785
- const writeTasks = generators.map(async (generator) => {
210786
- if (generator.type === "react" && generator.version === "2") {
210787
- const options2 = resolverTs.resolveOptions(schemaNode, {
210788
- options: plugin.options,
210789
- exclude,
210790
- include,
210791
- override
210792
- });
210793
- if (options2 === null) return;
210794
- await renderSchema$1(schemaNode, {
210795
- options: options2,
210796
- adapter,
210797
- config,
210798
- fabric,
210799
- Component: generator.Schema,
210800
- plugin,
210801
- driver,
210802
- mode
210803
- });
210804
- }
210805
- });
210806
- await Promise.all(writeTasks);
210807
- },
210808
- async operation(operationNode) {
210809
- const writeTasks = generators.map(async (generator) => {
210810
- if (generator.type === "react" && generator.version === "2") {
210811
- const options2 = resolverTs.resolveOptions(operationNode, {
210812
- options: plugin.options,
210813
- exclude,
210814
- include,
210815
- override
210816
- });
210817
- if (options2 === null) return;
210818
- await renderOperation$1(operationNode, {
210819
- options: options2,
210820
- adapter,
210821
- config,
210822
- fabric,
210823
- Component: generator.Operation,
210824
- plugin,
210825
- driver,
210826
- mode
210827
- });
210828
- }
210829
- });
210830
- await Promise.all(writeTasks);
210831
- }
210832
- }, { depth: "shallow" });
210833
- const barrelFiles2 = await getBarrelFiles(this.fabric.files, {
210834
- type: (_a = output.barrelType) != null ? _a : "named",
210835
- root,
210836
- output,
210837
- meta: { pluginName: this.plugin.name }
210838
- });
210839
- await this.upsertFile(...barrelFiles2);
210840
- return;
210841
- }
210842
- const oas = await this.getOas();
210843
- const schemaFiles = await new SchemaGenerator(this.plugin.options, {
210844
- fabric: this.fabric,
210845
- oas,
210846
- driver: this.driver,
210847
- events: this.events,
210848
- plugin: this.plugin,
210849
- contentType,
210850
- include: void 0,
210851
- override,
210852
- mode,
210853
- output: output.path
210854
- }).build(...generators);
210855
- await this.upsertFile(...schemaFiles);
210856
- const operationFiles = await new OperationGenerator(this.plugin.options, {
210857
- fabric: this.fabric,
210858
- oas,
210859
- driver: this.driver,
210860
- events: this.events,
210861
- plugin: this.plugin,
210862
- contentType,
210863
- exclude,
210864
- include,
210865
- override,
210866
- mode,
210867
- UNSTABLE_NAMING
210868
- }).build(...generators);
210869
- await this.upsertFile(...operationFiles);
210315
+ if (!adapter) throw new Error("Plugin cannot work without adapter being set");
210316
+ await openInStudio({ ast: true });
210317
+ await walk(rootNode, {
210318
+ async schema(schemaNode) {
210319
+ const writeTasks = generators.map(async (generator) => {
210320
+ if (generator.type === "react" && generator.version === "2") {
210321
+ const options2 = resolver.resolveOptions(schemaNode, {
210322
+ options: plugin.options,
210323
+ exclude,
210324
+ include,
210325
+ override
210326
+ });
210327
+ if (options2 === null) return;
210328
+ await renderSchema$1(schemaNode, {
210329
+ options: options2,
210330
+ adapter,
210331
+ config,
210332
+ fabric,
210333
+ Component: generator.Schema,
210334
+ plugin,
210335
+ driver,
210336
+ mode
210337
+ });
210338
+ }
210339
+ });
210340
+ await Promise.all(writeTasks);
210341
+ },
210342
+ async operation(operationNode) {
210343
+ const writeTasks = generators.map(async (generator) => {
210344
+ if (generator.type === "react" && generator.version === "2") {
210345
+ const options2 = resolver.resolveOptions(operationNode, {
210346
+ options: plugin.options,
210347
+ exclude,
210348
+ include,
210349
+ override
210350
+ });
210351
+ if (options2 === null) return;
210352
+ await renderOperation$1(operationNode, {
210353
+ options: options2,
210354
+ adapter,
210355
+ config,
210356
+ fabric,
210357
+ Component: generator.Operation,
210358
+ plugin,
210359
+ driver,
210360
+ mode
210361
+ });
210362
+ }
210363
+ });
210364
+ await Promise.all(writeTasks);
210365
+ }
210366
+ }, { depth: "shallow" });
210870
210367
  const barrelFiles = await getBarrelFiles(this.fabric.files, {
210871
- type: (_b = output.barrelType) != null ? _b : "named",
210368
+ type: (_a = output.barrelType) != null ? _a : "named",
210872
210369
  root,
210873
210370
  output,
210874
210371
  meta: { pluginName: this.plugin.name }
@@ -210878,6 +210375,172 @@ const pluginTs = createPlugin((options) => {
210878
210375
  };
210879
210376
  });
210880
210377
 
210378
+ function useOas() {
210379
+ const { meta } = useFabric();
210380
+ return meta.oas;
210381
+ }
210382
+ function useOperationManager(generator) {
210383
+ const plugin = usePlugin();
210384
+ const driver = usePluginDriver();
210385
+ const defaultPluginName = plugin.name;
210386
+ const getName = (operation, { prefix = "", suffix = "", pluginName = defaultPluginName, type }) => {
210387
+ return driver.resolveName({
210388
+ name: `${prefix} ${operation.getOperationId()} ${suffix}`,
210389
+ pluginName,
210390
+ type
210391
+ });
210392
+ };
210393
+ const getGroup = (operation) => {
210394
+ var _a, _b;
210395
+ return {
210396
+ tag: (_b = (_a = operation.getTags().at(0)) == null ? void 0 : _a.name) != null ? _b : "default",
210397
+ path: operation.path
210398
+ };
210399
+ };
210400
+ const getSchemas = (operation, params) => {
210401
+ if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
210402
+ return generator.getSchemas(operation, { resolveName: (name) => {
210403
+ var _a;
210404
+ return driver.resolveName({
210405
+ name,
210406
+ pluginName: (_a = params == null ? void 0 : params.pluginName) != null ? _a : defaultPluginName,
210407
+ type: params == null ? void 0 : params.type
210408
+ });
210409
+ } });
210410
+ };
210411
+ const getFile = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = ".ts" } = {}) => {
210412
+ const name = getName(operation, {
210413
+ type: "file",
210414
+ pluginName,
210415
+ prefix,
210416
+ suffix
210417
+ });
210418
+ const group = getGroup(operation);
210419
+ const file = driver.getFile({
210420
+ name,
210421
+ extname,
210422
+ pluginName,
210423
+ options: {
210424
+ type: "file",
210425
+ pluginName,
210426
+ group
210427
+ }
210428
+ });
210429
+ return {
210430
+ ...file,
210431
+ meta: {
210432
+ ...file.meta,
210433
+ name,
210434
+ pluginName,
210435
+ group
210436
+ }
210437
+ };
210438
+ };
210439
+ const groupSchemasByName = (operation, { pluginName = defaultPluginName, type }) => {
210440
+ var _a, _b, _c, _d;
210441
+ if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
210442
+ const schemas = getSchemas(operation);
210443
+ const errors = (schemas.errors || []).reduce((prev, acc) => {
210444
+ if (!acc.statusCode) return prev;
210445
+ prev[acc.statusCode] = driver.resolveName({
210446
+ name: acc.name,
210447
+ pluginName,
210448
+ type
210449
+ });
210450
+ return prev;
210451
+ }, {});
210452
+ const responses = (schemas.responses || []).reduce((prev, acc) => {
210453
+ if (!acc.statusCode) return prev;
210454
+ prev[acc.statusCode] = driver.resolveName({
210455
+ name: acc.name,
210456
+ pluginName,
210457
+ type
210458
+ });
210459
+ return prev;
210460
+ }, {});
210461
+ return {
210462
+ request: ((_a = schemas.request) == null ? void 0 : _a.name) ? driver.resolveName({
210463
+ name: schemas.request.name,
210464
+ pluginName,
210465
+ type
210466
+ }) : void 0,
210467
+ parameters: {
210468
+ path: ((_b = schemas.pathParams) == null ? void 0 : _b.name) ? driver.resolveName({
210469
+ name: schemas.pathParams.name,
210470
+ pluginName,
210471
+ type
210472
+ }) : void 0,
210473
+ query: ((_c = schemas.queryParams) == null ? void 0 : _c.name) ? driver.resolveName({
210474
+ name: schemas.queryParams.name,
210475
+ pluginName,
210476
+ type
210477
+ }) : void 0,
210478
+ header: ((_d = schemas.headerParams) == null ? void 0 : _d.name) ? driver.resolveName({
210479
+ name: schemas.headerParams.name,
210480
+ pluginName,
210481
+ type
210482
+ }) : void 0
210483
+ },
210484
+ responses: {
210485
+ ...responses,
210486
+ ["default"]: driver.resolveName({
210487
+ name: schemas.response.name,
210488
+ pluginName,
210489
+ type
210490
+ }),
210491
+ ...errors
210492
+ },
210493
+ errors
210494
+ };
210495
+ };
210496
+ return {
210497
+ getName,
210498
+ getFile,
210499
+ getSchemas,
210500
+ groupSchemasByName,
210501
+ getGroup
210502
+ };
210503
+ }
210504
+ function useSchemaManager() {
210505
+ const plugin = usePlugin();
210506
+ const driver = usePluginDriver();
210507
+ const getName = (name, { pluginName = plugin.name, type }) => {
210508
+ return driver.resolveName({
210509
+ name,
210510
+ pluginName,
210511
+ type
210512
+ });
210513
+ };
210514
+ const getFile = (name, { mode = "split", pluginName = plugin.name, extname = ".ts", group } = {}) => {
210515
+ const resolvedName = mode === "single" ? "" : getName(name, {
210516
+ type: "file",
210517
+ pluginName
210518
+ });
210519
+ const file = driver.getFile({
210520
+ name: resolvedName,
210521
+ extname,
210522
+ pluginName,
210523
+ options: {
210524
+ type: "file",
210525
+ pluginName,
210526
+ group
210527
+ }
210528
+ });
210529
+ return {
210530
+ ...file,
210531
+ meta: {
210532
+ ...file.meta,
210533
+ name: resolvedName,
210534
+ pluginName
210535
+ }
210536
+ };
210537
+ };
210538
+ return {
210539
+ getName,
210540
+ getFile
210541
+ };
210542
+ }
210543
+
210881
210544
  const operationsGenerator$1 = createReactGenerator({
210882
210545
  name: "operations",
210883
210546
  Operations({ operations, generator, plugin }) {
@@ -211162,7 +210825,7 @@ function toCamelOrPascal$9(text, pascal) {
211162
210825
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
211163
210826
  }
211164
210827
  function applyToFileParts$9(text, transformPart) {
211165
- const parts = text.split(".");
210828
+ const parts = text.split(/\.(?=[a-zA-Z])/);
211166
210829
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
211167
210830
  }
211168
210831
  function camelCase$9(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -212129,7 +211792,7 @@ function toCamelOrPascal$8(text, pascal) {
212129
211792
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
212130
211793
  }
212131
211794
  function applyToFileParts$8(text, transformPart) {
212132
- const parts = text.split(".");
211795
+ const parts = text.split(/\.(?=[a-zA-Z])/);
212133
211796
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
212134
211797
  }
212135
211798
  function camelCase$8(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -213038,7 +212701,7 @@ function toCamelOrPascal$7(text, pascal) {
213038
212701
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
213039
212702
  }
213040
212703
  function applyToFileParts$7(text, transformPart) {
213041
- const parts = text.split(".");
212704
+ const parts = text.split(/\.(?=[a-zA-Z])/);
213042
212705
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
213043
212706
  }
213044
212707
  function camelCase$7(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -213146,7 +212809,7 @@ function toCamelOrPascal$6(text, pascal) {
213146
212809
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
213147
212810
  }
213148
212811
  function applyToFileParts$6(text, transformPart) {
213149
- const parts = text.split(".");
212812
+ const parts = text.split(/\.(?=[a-zA-Z])/);
213150
212813
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
213151
212814
  }
213152
212815
  function camelCase$6(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -213664,7 +213327,7 @@ function toCamelOrPascal$5(text, pascal) {
213664
213327
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
213665
213328
  }
213666
213329
  function applyToFileParts$5(text, transformPart) {
213667
- const parts = text.split(".");
213330
+ const parts = text.split(/\.(?=[a-zA-Z])/);
213668
213331
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
213669
213332
  }
213670
213333
  function camelCase$5(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -214128,7 +213791,7 @@ function toCamelOrPascal$4(text, pascal) {
214128
213791
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
214129
213792
  }
214130
213793
  function applyToFileParts$4(text, transformPart) {
214131
- const parts = text.split(".");
213794
+ const parts = text.split(/\.(?=[a-zA-Z])/);
214132
213795
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
214133
213796
  }
214134
213797
  function camelCase$4(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -214281,7 +213944,7 @@ function MutationKey$4({ name, typeSchemas, pathParamsType, paramsCasing, operat
214281
213944
  isExportable: true,
214282
213945
  isIndexable: true,
214283
213946
  isTypeOnly: true,
214284
- children: /* @__PURE__ */ jsx(Type$2, {
213947
+ children: /* @__PURE__ */ jsx(Type$1, {
214285
213948
  name: typeName,
214286
213949
  export: true,
214287
213950
  children: `ReturnType<typeof ${name}>`
@@ -214349,7 +214012,7 @@ function QueryKey$4({ name, typeSchemas, paramsCasing, pathParamsType, operation
214349
214012
  isExportable: true,
214350
214013
  isIndexable: true,
214351
214014
  isTypeOnly: true,
214352
- children: /* @__PURE__ */ jsx(Type$2, {
214015
+ children: /* @__PURE__ */ jsx(Type$1, {
214353
214016
  name: typeName,
214354
214017
  export: true,
214355
214018
  children: `ReturnType<typeof ${name}>`
@@ -215842,7 +215505,7 @@ const hookOptionsGenerator = createReactGenerator({
215842
215505
  isExportable: true,
215843
215506
  isIndexable: true,
215844
215507
  isTypeOnly: true,
215845
- children: /* @__PURE__ */ jsx(Type$2, {
215508
+ children: /* @__PURE__ */ jsx(Type$1, {
215846
215509
  export: true,
215847
215510
  name,
215848
215511
  children: `{ ${Object.keys(hookOptions).map((key) => `${JSON.stringify(key)}: ${hookOptions[key]}`)} }`
@@ -217203,7 +216866,7 @@ function toCamelOrPascal$3(text, pascal) {
217203
216866
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
217204
216867
  }
217205
216868
  function applyToFileParts$3(text, transformPart) {
217206
- const parts = text.split(".");
216869
+ const parts = text.split(/\.(?=[a-zA-Z])/);
217207
216870
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
217208
216871
  }
217209
216872
  function camelCase$3(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -217351,7 +217014,7 @@ function MutationKey$3({ name, typeSchemas, pathParamsType, paramsCasing, operat
217351
217014
  isExportable: true,
217352
217015
  isIndexable: true,
217353
217016
  isTypeOnly: true,
217354
- children: /* @__PURE__ */ jsx(Type$2, {
217017
+ children: /* @__PURE__ */ jsx(Type$1, {
217355
217018
  name: typeName,
217356
217019
  export: true,
217357
217020
  children: `ReturnType<typeof ${name}>`
@@ -217419,7 +217082,7 @@ function QueryKey$3({ name, typeSchemas, paramsCasing, pathParamsType, operation
217419
217082
  isExportable: true,
217420
217083
  isIndexable: true,
217421
217084
  isTypeOnly: true,
217422
- children: /* @__PURE__ */ jsx(Type$2, {
217085
+ children: /* @__PURE__ */ jsx(Type$1, {
217423
217086
  name: typeName,
217424
217087
  export: true,
217425
217088
  children: `ReturnType<typeof ${name}>`
@@ -218353,7 +218016,7 @@ function toCamelOrPascal$2(text, pascal) {
218353
218016
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
218354
218017
  }
218355
218018
  function applyToFileParts$2(text, transformPart) {
218356
- const parts = text.split(".");
218019
+ const parts = text.split(/\.(?=[a-zA-Z])/);
218357
218020
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
218358
218021
  }
218359
218022
  function camelCase$2(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -218501,7 +218164,7 @@ function MutationKey$2({ name, typeSchemas, pathParamsType, paramsCasing, operat
218501
218164
  isExportable: true,
218502
218165
  isIndexable: true,
218503
218166
  isTypeOnly: true,
218504
- children: /* @__PURE__ */ jsx(Type$2, {
218167
+ children: /* @__PURE__ */ jsx(Type$1, {
218505
218168
  name: typeName,
218506
218169
  export: true,
218507
218170
  children: `ReturnType<typeof ${name}>`
@@ -218569,7 +218232,7 @@ function QueryKey$2({ name, typeSchemas, paramsCasing, pathParamsType, operation
218569
218232
  isExportable: true,
218570
218233
  isIndexable: true,
218571
218234
  isTypeOnly: true,
218572
- children: /* @__PURE__ */ jsx(Type$2, {
218235
+ children: /* @__PURE__ */ jsx(Type$1, {
218573
218236
  name: typeName,
218574
218237
  export: true,
218575
218238
  children: `ReturnType<typeof ${name}>`
@@ -219503,7 +219166,7 @@ function toCamelOrPascal$1(text, pascal) {
219503
219166
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
219504
219167
  }
219505
219168
  function applyToFileParts$1(text, transformPart) {
219506
- const parts = text.split(".");
219169
+ const parts = text.split(/\.(?=[a-zA-Z])/);
219507
219170
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
219508
219171
  }
219509
219172
  function camelCase$1(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -219651,7 +219314,7 @@ function MutationKey$1({ name, typeSchemas, pathParamsType, paramsCasing, operat
219651
219314
  isExportable: true,
219652
219315
  isIndexable: true,
219653
219316
  isTypeOnly: true,
219654
- children: /* @__PURE__ */ jsx(Type$2, {
219317
+ children: /* @__PURE__ */ jsx(Type$1, {
219655
219318
  name: typeName,
219656
219319
  export: true,
219657
219320
  children: `ReturnType<typeof ${name}>`
@@ -219719,7 +219382,7 @@ function QueryKey$1({ name, typeSchemas, paramsCasing, pathParamsType, operation
219719
219382
  isExportable: true,
219720
219383
  isIndexable: true,
219721
219384
  isTypeOnly: true,
219722
- children: /* @__PURE__ */ jsx(Type$2, {
219385
+ children: /* @__PURE__ */ jsx(Type$1, {
219723
219386
  name: typeName,
219724
219387
  export: true,
219725
219388
  children: `ReturnType<typeof ${name}>`
@@ -219848,7 +219511,7 @@ function Mutation$1({ name, clientName, mutationKeyName, mutationKeyTypeName, pa
219848
219511
  isExportable: true,
219849
219512
  isIndexable: true,
219850
219513
  isTypeOnly: true,
219851
- children: /* @__PURE__ */ jsx(Type$2, {
219514
+ children: /* @__PURE__ */ jsx(Type$1, {
219852
219515
  name: mutationArgTypeName,
219853
219516
  export: true,
219854
219517
  children: hasMutationParams ? `{${mutationArg}}` : "never"
@@ -220675,7 +220338,7 @@ function toCamelOrPascal(text, pascal) {
220675
220338
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
220676
220339
  }
220677
220340
  function applyToFileParts(text, transformPart) {
220678
- const parts = text.split(".");
220341
+ const parts = text.split(/\.(?=[a-zA-Z])/);
220679
220342
  return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
220680
220343
  }
220681
220344
  function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
@@ -220862,7 +220525,7 @@ function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation,
220862
220525
  isExportable: true,
220863
220526
  isIndexable: true,
220864
220527
  isTypeOnly: true,
220865
- children: /* @__PURE__ */ jsx(Type$2, {
220528
+ children: /* @__PURE__ */ jsx(Type$1, {
220866
220529
  name: typeName,
220867
220530
  export: true,
220868
220531
  children: `ReturnType<typeof ${name}>`
@@ -221340,7 +221003,7 @@ function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operatio
221340
221003
  isExportable: true,
221341
221004
  isIndexable: true,
221342
221005
  isTypeOnly: true,
221343
- children: /* @__PURE__ */ jsx(Type$2, {
221006
+ children: /* @__PURE__ */ jsx(Type$1, {
221344
221007
  name: typeName,
221345
221008
  export: true,
221346
221009
  children: `ReturnType<typeof ${name}>`