@kubb/agent 5.0.0-alpha.34 → 5.0.0-alpha.36

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 (183) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +16 -14
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +16 -14
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
  9. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
  10. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
  11. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
  12. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
  13. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
  14. package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
  15. package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
  16. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
  17. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
  18. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
  19. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
  20. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
  21. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
  22. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
  23. package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
  24. package/.output/server/node_modules/@clack/core/package.json +60 -0
  25. package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
  26. package/.output/server/node_modules/@clack/prompts/package.json +65 -0
  27. package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
  28. package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
  29. package/.output/server/node_modules/@kubb/ast/package.json +70 -0
  30. package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
  31. package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
  32. package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
  33. package/.output/server/node_modules/@kubb/core/package.json +109 -0
  34. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
  35. package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
  36. package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
  37. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
  38. package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
  39. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
  40. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
  41. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
  42. package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
  43. package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
  44. package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
  45. package/.output/server/node_modules/@kubb/oas/package.json +94 -0
  46. package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
  47. package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
  48. package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
  49. package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
  50. package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
  51. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
  52. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
  53. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
  54. package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
  55. package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
  56. package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
  57. package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
  58. package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
  59. package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
  60. package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
  61. package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
  62. package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
  63. package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
  64. package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
  65. package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
  66. package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
  67. package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
  68. package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
  69. package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
  70. package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
  71. package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
  72. package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
  73. package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
  74. package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
  75. package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
  76. package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
  77. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
  78. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
  79. package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
  80. package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
  81. package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
  82. package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
  83. package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
  84. package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
  85. package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
  86. package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
  87. package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
  88. package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
  89. package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
  90. package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
  91. package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
  92. package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
  93. package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
  94. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
  95. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
  96. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
  97. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
  98. package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
  99. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
  100. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
  101. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
  102. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
  103. package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
  104. package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
  105. package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
  106. package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
  107. package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
  108. package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
  109. package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
  110. package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
  111. package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
  112. package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
  113. package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
  114. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
  115. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
  116. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
  117. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
  118. package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
  119. package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
  120. package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
  121. package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
  122. package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
  123. package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
  124. package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
  125. package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
  126. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
  127. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
  128. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
  129. package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
  130. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
  131. package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
  132. package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
  133. package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
  134. package/.output/server/node_modules/@redocly/config/package.json +1 -1
  135. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
  136. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
  137. package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
  138. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
  139. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
  140. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
  141. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
  142. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
  143. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
  144. package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
  145. package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
  146. package/.output/server/node_modules/buffer-from/index.js +72 -0
  147. package/.output/server/node_modules/buffer-from/package.json +19 -0
  148. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  149. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  150. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  151. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  152. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  153. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  154. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  155. package/.output/server/node_modules/p-limit/index.js +127 -0
  156. package/.output/server/node_modules/p-limit/package.json +58 -0
  157. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  158. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  159. package/.output/server/node_modules/sisteransi/package.json +34 -0
  160. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  161. package/.output/server/node_modules/source-map-support/package.json +31 -0
  162. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  163. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  164. package/.output/server/node_modules/typescript/package.json +120 -0
  165. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  166. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  167. package/.output/server/package.json +35 -4
  168. package/package.json +20 -20
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  181. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  182. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  183. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,723 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { a as Url, i as Client, n as Operations, o as camelCase, r as ClassClient, s as pascalCase, t as StaticClassClient } from "./StaticClassClient-bCe7RG_w.js";
3
+ import path from "node:path";
4
+ import { pluginZodName } from "@kubb/plugin-zod";
5
+ import { usePluginManager } from "@kubb/core/hooks";
6
+ import { createReactGenerator } from "@kubb/plugin-oas/generators";
7
+ import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
8
+ import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
9
+ import { pluginTsName } from "@kubb/plugin-ts";
10
+ import { File, Function } from "@kubb/react-fabric";
11
+ import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
12
+ //#region src/components/WrapperClient.tsx
13
+ function WrapperClient({ name, classNames, isExportable = true, isIndexable = true }) {
14
+ const classCode = `export class ${name} {
15
+ ${classNames.map((className) => ` readonly ${camelCase(className)}: ${className}`).join("\n")}
16
+
17
+ constructor(config: Partial<RequestConfig> & { client?: Client } = {}) {
18
+ ${classNames.map((className) => ` this.${camelCase(className)} = new ${className}(config)`).join("\n")}
19
+ }
20
+ }`;
21
+ return /* @__PURE__ */ jsx(File.Source, {
22
+ name,
23
+ isExportable,
24
+ isIndexable,
25
+ children: classCode
26
+ });
27
+ }
28
+ //#endregion
29
+ //#region src/generators/classClientGenerator.tsx
30
+ const classClientGenerator = createReactGenerator({
31
+ name: "classClient",
32
+ Operations({ operations, generator, plugin, config }) {
33
+ const { options, key: pluginKey } = plugin;
34
+ const pluginManager = usePluginManager();
35
+ const oas = useOas();
36
+ const { getName, getFile, getGroup, getSchemas } = useOperationManager(generator);
37
+ function buildOperationData(operation) {
38
+ const type = {
39
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
40
+ schemas: getSchemas(operation, {
41
+ pluginKey: [pluginTsName],
42
+ type: "type"
43
+ })
44
+ };
45
+ const zod = {
46
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
47
+ schemas: getSchemas(operation, {
48
+ pluginKey: [pluginZodName],
49
+ type: "function"
50
+ })
51
+ };
52
+ return {
53
+ operation,
54
+ name: getName(operation, { type: "function" }),
55
+ typeSchemas: type.schemas,
56
+ zodSchemas: zod.schemas,
57
+ typeFile: type.file,
58
+ zodFile: zod.file
59
+ };
60
+ }
61
+ const controllers = operations.reduce((acc, operation) => {
62
+ const group = getGroup(operation);
63
+ const groupName = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) ?? pascalCase(group.tag) : "Client";
64
+ if (!group?.tag && !options.group) {
65
+ const name = "ApiClient";
66
+ const file = pluginManager.getFile({
67
+ name,
68
+ extname: ".ts",
69
+ pluginKey
70
+ });
71
+ const operationData = buildOperationData(operation);
72
+ const previousFile = acc.find((item) => item.file.path === file.path);
73
+ if (previousFile) previousFile.operations.push(operationData);
74
+ else acc.push({
75
+ name,
76
+ file,
77
+ operations: [operationData]
78
+ });
79
+ } else if (group?.tag) {
80
+ const name = groupName;
81
+ const file = pluginManager.getFile({
82
+ name,
83
+ extname: ".ts",
84
+ pluginKey,
85
+ options: { group }
86
+ });
87
+ const operationData = buildOperationData(operation);
88
+ const previousFile = acc.find((item) => item.file.path === file.path);
89
+ if (previousFile) previousFile.operations.push(operationData);
90
+ else acc.push({
91
+ name,
92
+ file,
93
+ operations: [operationData]
94
+ });
95
+ }
96
+ return acc;
97
+ }, []);
98
+ function collectTypeImports(ops) {
99
+ const typeImportsByFile = /* @__PURE__ */ new Map();
100
+ const typeFilesByPath = /* @__PURE__ */ new Map();
101
+ ops.forEach((op) => {
102
+ const { typeSchemas, typeFile } = op;
103
+ if (!typeImportsByFile.has(typeFile.path)) typeImportsByFile.set(typeFile.path, /* @__PURE__ */ new Set());
104
+ const typeImports = typeImportsByFile.get(typeFile.path);
105
+ if (typeSchemas.request?.name) typeImports.add(typeSchemas.request.name);
106
+ if (typeSchemas.response?.name) typeImports.add(typeSchemas.response.name);
107
+ if (typeSchemas.pathParams?.name) typeImports.add(typeSchemas.pathParams.name);
108
+ if (typeSchemas.queryParams?.name) typeImports.add(typeSchemas.queryParams.name);
109
+ if (typeSchemas.headerParams?.name) typeImports.add(typeSchemas.headerParams.name);
110
+ typeSchemas.statusCodes?.forEach((item) => {
111
+ if (item?.name) typeImports.add(item.name);
112
+ });
113
+ typeFilesByPath.set(typeFile.path, typeFile);
114
+ });
115
+ return {
116
+ typeImportsByFile,
117
+ typeFilesByPath
118
+ };
119
+ }
120
+ function collectZodImports(ops) {
121
+ const zodImportsByFile = /* @__PURE__ */ new Map();
122
+ const zodFilesByPath = /* @__PURE__ */ new Map();
123
+ ops.forEach((op) => {
124
+ const { zodSchemas, zodFile } = op;
125
+ if (!zodImportsByFile.has(zodFile.path)) zodImportsByFile.set(zodFile.path, /* @__PURE__ */ new Set());
126
+ const zodImports = zodImportsByFile.get(zodFile.path);
127
+ if (zodSchemas?.response?.name) zodImports.add(zodSchemas.response.name);
128
+ if (zodSchemas?.request?.name) zodImports.add(zodSchemas.request.name);
129
+ zodFilesByPath.set(zodFile.path, zodFile);
130
+ });
131
+ return {
132
+ zodImportsByFile,
133
+ zodFilesByPath
134
+ };
135
+ }
136
+ const files = controllers.map(({ name, file, operations: ops }) => {
137
+ const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
138
+ const { zodImportsByFile, zodFilesByPath } = options.parser === "zod" ? collectZodImports(ops) : {
139
+ zodImportsByFile: /* @__PURE__ */ new Map(),
140
+ zodFilesByPath: /* @__PURE__ */ new Map()
141
+ };
142
+ const hasFormData = ops.some((op) => op.operation.getContentType() === "multipart/form-data");
143
+ return /* @__PURE__ */ jsxs(File, {
144
+ baseName: file.baseName,
145
+ path: file.path,
146
+ meta: file.meta,
147
+ banner: getBanner({
148
+ oas,
149
+ output: options.output,
150
+ config: pluginManager.config
151
+ }),
152
+ footer: getFooter({
153
+ oas,
154
+ output: options.output
155
+ }),
156
+ children: [
157
+ options.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
158
+ /* @__PURE__ */ jsx(File.Import, {
159
+ name: "fetch",
160
+ path: options.importPath
161
+ }),
162
+ /* @__PURE__ */ jsx(File.Import, {
163
+ name: ["mergeConfig"],
164
+ path: options.importPath
165
+ }),
166
+ /* @__PURE__ */ jsx(File.Import, {
167
+ name: [
168
+ "Client",
169
+ "RequestConfig",
170
+ "ResponseErrorConfig"
171
+ ],
172
+ path: options.importPath,
173
+ isTypeOnly: true
174
+ })
175
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
176
+ /* @__PURE__ */ jsx(File.Import, {
177
+ name: ["fetch"],
178
+ root: file.path,
179
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
180
+ }),
181
+ /* @__PURE__ */ jsx(File.Import, {
182
+ name: ["mergeConfig"],
183
+ root: file.path,
184
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
185
+ }),
186
+ /* @__PURE__ */ jsx(File.Import, {
187
+ name: [
188
+ "Client",
189
+ "RequestConfig",
190
+ "ResponseErrorConfig"
191
+ ],
192
+ root: file.path,
193
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
194
+ isTypeOnly: true
195
+ })
196
+ ] }),
197
+ hasFormData && /* @__PURE__ */ jsx(File.Import, {
198
+ name: ["buildFormData"],
199
+ root: file.path,
200
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
201
+ }),
202
+ Array.from(typeImportsByFile.entries()).map(([filePath, imports]) => {
203
+ const typeFile = typeFilesByPath.get(filePath);
204
+ if (!typeFile) return null;
205
+ const importNames = Array.from(imports).filter(Boolean);
206
+ if (importNames.length === 0) return null;
207
+ return /* @__PURE__ */ jsx(File.Import, {
208
+ name: importNames,
209
+ root: file.path,
210
+ path: typeFile.path,
211
+ isTypeOnly: true
212
+ }, filePath);
213
+ }),
214
+ options.parser === "zod" && Array.from(zodImportsByFile.entries()).map(([filePath, imports]) => {
215
+ const zodFile = zodFilesByPath.get(filePath);
216
+ if (!zodFile) return null;
217
+ const importNames = Array.from(imports).filter(Boolean);
218
+ if (importNames.length === 0) return null;
219
+ return /* @__PURE__ */ jsx(File.Import, {
220
+ name: importNames,
221
+ root: file.path,
222
+ path: zodFile.path
223
+ }, filePath);
224
+ }),
225
+ /* @__PURE__ */ jsx(ClassClient, {
226
+ name,
227
+ operations: ops,
228
+ baseURL: options.baseURL,
229
+ dataReturnType: options.dataReturnType,
230
+ pathParamsType: options.pathParamsType,
231
+ paramsCasing: options.paramsCasing,
232
+ paramsType: options.paramsType,
233
+ parser: options.parser
234
+ })
235
+ ]
236
+ }, file.path);
237
+ });
238
+ if (options.wrapper) {
239
+ const wrapperFile = pluginManager.getFile({
240
+ name: options.wrapper.className,
241
+ extname: ".ts",
242
+ pluginKey
243
+ });
244
+ files.push(/* @__PURE__ */ jsxs(File, {
245
+ baseName: wrapperFile.baseName,
246
+ path: wrapperFile.path,
247
+ meta: wrapperFile.meta,
248
+ banner: getBanner({
249
+ oas,
250
+ output: options.output,
251
+ config: pluginManager.config
252
+ }),
253
+ footer: getFooter({
254
+ oas,
255
+ output: options.output
256
+ }),
257
+ children: [
258
+ options.importPath ? /* @__PURE__ */ jsx(File.Import, {
259
+ name: ["Client", "RequestConfig"],
260
+ path: options.importPath,
261
+ isTypeOnly: true
262
+ }) : /* @__PURE__ */ jsx(File.Import, {
263
+ name: ["Client", "RequestConfig"],
264
+ root: wrapperFile.path,
265
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
266
+ isTypeOnly: true
267
+ }),
268
+ controllers.map(({ name, file }) => /* @__PURE__ */ jsx(File.Import, {
269
+ name: [name],
270
+ root: wrapperFile.path,
271
+ path: file.path
272
+ }, name)),
273
+ /* @__PURE__ */ jsx(WrapperClient, {
274
+ name: options.wrapper.className,
275
+ classNames: controllers.map(({ name }) => name)
276
+ })
277
+ ]
278
+ }, wrapperFile.path));
279
+ }
280
+ return files;
281
+ }
282
+ });
283
+ //#endregion
284
+ //#region src/generators/clientGenerator.tsx
285
+ const clientGenerator = createReactGenerator({
286
+ name: "client",
287
+ Operation({ config, plugin, operation, generator }) {
288
+ const pluginManager = usePluginManager();
289
+ const { options, options: { output, urlType } } = plugin;
290
+ const oas = useOas();
291
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
292
+ const client = {
293
+ name: getName(operation, { type: "function" }),
294
+ file: getFile(operation)
295
+ };
296
+ const url = {
297
+ name: getName(operation, {
298
+ type: "function",
299
+ suffix: "url",
300
+ prefix: "get"
301
+ }),
302
+ file: getFile(operation)
303
+ };
304
+ const type = {
305
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
306
+ schemas: getSchemas(operation, {
307
+ pluginKey: [pluginTsName],
308
+ type: "type"
309
+ })
310
+ };
311
+ const zod = {
312
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
313
+ schemas: getSchemas(operation, {
314
+ pluginKey: [pluginZodName],
315
+ type: "function"
316
+ })
317
+ };
318
+ const isFormData = operation.getContentType() === "multipart/form-data";
319
+ return /* @__PURE__ */ jsxs(File, {
320
+ baseName: client.file.baseName,
321
+ path: client.file.path,
322
+ meta: client.file.meta,
323
+ banner: getBanner({
324
+ oas,
325
+ output,
326
+ config: pluginManager.config
327
+ }),
328
+ footer: getFooter({
329
+ oas,
330
+ output
331
+ }),
332
+ children: [
333
+ options.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Import, {
334
+ name: "fetch",
335
+ path: options.importPath
336
+ }), /* @__PURE__ */ jsx(File.Import, {
337
+ name: [
338
+ "Client",
339
+ "RequestConfig",
340
+ "ResponseErrorConfig"
341
+ ],
342
+ path: options.importPath,
343
+ isTypeOnly: true
344
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Import, {
345
+ name: ["fetch"],
346
+ root: client.file.path,
347
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
348
+ }), /* @__PURE__ */ jsx(File.Import, {
349
+ name: [
350
+ "Client",
351
+ "RequestConfig",
352
+ "ResponseErrorConfig"
353
+ ],
354
+ root: client.file.path,
355
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
356
+ isTypeOnly: true
357
+ })] }),
358
+ isFormData && type.schemas.request?.name && /* @__PURE__ */ jsx(File.Import, {
359
+ name: ["buildFormData"],
360
+ root: client.file.path,
361
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
362
+ }),
363
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, {
364
+ name: [zod.schemas.response.name, zod.schemas.request?.name].filter((x) => Boolean(x)),
365
+ root: client.file.path,
366
+ path: zod.file.path
367
+ }),
368
+ /* @__PURE__ */ jsx(File.Import, {
369
+ name: [
370
+ type.schemas.request?.name,
371
+ type.schemas.response.name,
372
+ type.schemas.pathParams?.name,
373
+ type.schemas.queryParams?.name,
374
+ type.schemas.headerParams?.name,
375
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
376
+ ].filter((x) => Boolean(x)),
377
+ root: client.file.path,
378
+ path: type.file.path,
379
+ isTypeOnly: true
380
+ }),
381
+ /* @__PURE__ */ jsx(Url, {
382
+ name: url.name,
383
+ baseURL: options.baseURL,
384
+ pathParamsType: options.pathParamsType,
385
+ paramsCasing: options.paramsCasing,
386
+ paramsType: options.paramsType,
387
+ typeSchemas: type.schemas,
388
+ operation,
389
+ isIndexable: urlType === "export",
390
+ isExportable: urlType === "export"
391
+ }),
392
+ /* @__PURE__ */ jsx(Client, {
393
+ name: client.name,
394
+ urlName: url.name,
395
+ baseURL: options.baseURL,
396
+ dataReturnType: options.dataReturnType,
397
+ pathParamsType: options.pathParamsType,
398
+ paramsCasing: options.paramsCasing,
399
+ paramsType: options.paramsType,
400
+ typeSchemas: type.schemas,
401
+ operation,
402
+ parser: options.parser,
403
+ zodSchemas: zod.schemas
404
+ })
405
+ ]
406
+ });
407
+ }
408
+ });
409
+ //#endregion
410
+ //#region src/generators/groupedClientGenerator.tsx
411
+ const groupedClientGenerator = createReactGenerator({
412
+ name: "groupedClient",
413
+ Operations({ operations, generator, plugin }) {
414
+ const { options, key: pluginKey } = plugin;
415
+ const pluginManager = usePluginManager();
416
+ const oas = useOas();
417
+ const { getName, getFile, getGroup } = useOperationManager(generator);
418
+ return operations.reduce((acc, operation) => {
419
+ if (options.group?.type === "tag") {
420
+ const group = getGroup(operation);
421
+ const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : void 0;
422
+ if (!group?.tag || !name) return acc;
423
+ const file = pluginManager.getFile({
424
+ name,
425
+ extname: ".ts",
426
+ pluginKey,
427
+ options: { group }
428
+ });
429
+ const client = {
430
+ name: getName(operation, { type: "function" }),
431
+ file: getFile(operation)
432
+ };
433
+ const previousFile = acc.find((item) => item.file.path === file.path);
434
+ if (previousFile) previousFile.clients.push(client);
435
+ else acc.push({
436
+ name,
437
+ file,
438
+ clients: [client]
439
+ });
440
+ }
441
+ return acc;
442
+ }, []).map(({ name, file, clients }) => {
443
+ return /* @__PURE__ */ jsxs(File, {
444
+ baseName: file.baseName,
445
+ path: file.path,
446
+ meta: file.meta,
447
+ banner: getBanner({
448
+ oas,
449
+ output: options.output,
450
+ config: pluginManager.config
451
+ }),
452
+ footer: getFooter({
453
+ oas,
454
+ output: options.output
455
+ }),
456
+ children: [clients.map((client) => /* @__PURE__ */ jsx(File.Import, {
457
+ name: [client.name],
458
+ root: file.path,
459
+ path: client.file.path
460
+ }, client.name)), /* @__PURE__ */ jsx(File.Source, {
461
+ name,
462
+ isExportable: true,
463
+ isIndexable: true,
464
+ children: /* @__PURE__ */ jsx(Function, {
465
+ export: true,
466
+ name,
467
+ children: `return { ${clients.map((client) => client.name).join(", ")} }`
468
+ })
469
+ })]
470
+ }, file.path);
471
+ });
472
+ }
473
+ });
474
+ //#endregion
475
+ //#region src/generators/operationsGenerator.tsx
476
+ const operationsGenerator = createReactGenerator({
477
+ name: "client",
478
+ Operations({ operations, plugin }) {
479
+ const { key: pluginKey, options: { output } } = plugin;
480
+ const pluginManager = usePluginManager();
481
+ const oas = useOas();
482
+ const name = "operations";
483
+ const file = pluginManager.getFile({
484
+ name,
485
+ extname: ".ts",
486
+ pluginKey
487
+ });
488
+ return /* @__PURE__ */ jsx(File, {
489
+ baseName: file.baseName,
490
+ path: file.path,
491
+ meta: file.meta,
492
+ banner: getBanner({
493
+ oas,
494
+ output,
495
+ config: pluginManager.config
496
+ }),
497
+ footer: getFooter({
498
+ oas,
499
+ output
500
+ }),
501
+ children: /* @__PURE__ */ jsx(Operations, {
502
+ name,
503
+ operations
504
+ })
505
+ });
506
+ }
507
+ });
508
+ //#endregion
509
+ //#region src/generators/staticClassClientGenerator.tsx
510
+ const staticClassClientGenerator = createReactGenerator({
511
+ name: "staticClassClient",
512
+ Operations({ operations, generator, plugin, config }) {
513
+ const { options, key: pluginKey } = plugin;
514
+ const pluginManager = usePluginManager();
515
+ const oas = useOas();
516
+ const { getName, getFile, getGroup, getSchemas } = useOperationManager(generator);
517
+ function buildOperationData(operation) {
518
+ const type = {
519
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
520
+ schemas: getSchemas(operation, {
521
+ pluginKey: [pluginTsName],
522
+ type: "type"
523
+ })
524
+ };
525
+ const zod = {
526
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
527
+ schemas: getSchemas(operation, {
528
+ pluginKey: [pluginZodName],
529
+ type: "function"
530
+ })
531
+ };
532
+ return {
533
+ operation,
534
+ name: getName(operation, { type: "function" }),
535
+ typeSchemas: type.schemas,
536
+ zodSchemas: zod.schemas,
537
+ typeFile: type.file,
538
+ zodFile: zod.file
539
+ };
540
+ }
541
+ const controllers = operations.reduce((acc, operation) => {
542
+ const group = getGroup(operation);
543
+ const groupName = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) ?? pascalCase(group.tag) : "Client";
544
+ if (!group?.tag && !options.group) {
545
+ const name = "ApiClient";
546
+ const file = pluginManager.getFile({
547
+ name,
548
+ extname: ".ts",
549
+ pluginKey
550
+ });
551
+ const operationData = buildOperationData(operation);
552
+ const previousFile = acc.find((item) => item.file.path === file.path);
553
+ if (previousFile) previousFile.operations.push(operationData);
554
+ else acc.push({
555
+ name,
556
+ file,
557
+ operations: [operationData]
558
+ });
559
+ } else if (group?.tag) {
560
+ const name = groupName;
561
+ const file = pluginManager.getFile({
562
+ name,
563
+ extname: ".ts",
564
+ pluginKey,
565
+ options: { group }
566
+ });
567
+ const operationData = buildOperationData(operation);
568
+ const previousFile = acc.find((item) => item.file.path === file.path);
569
+ if (previousFile) previousFile.operations.push(operationData);
570
+ else acc.push({
571
+ name,
572
+ file,
573
+ operations: [operationData]
574
+ });
575
+ }
576
+ return acc;
577
+ }, []);
578
+ function collectTypeImports(ops) {
579
+ const typeImportsByFile = /* @__PURE__ */ new Map();
580
+ const typeFilesByPath = /* @__PURE__ */ new Map();
581
+ ops.forEach((op) => {
582
+ const { typeSchemas, typeFile } = op;
583
+ if (!typeImportsByFile.has(typeFile.path)) typeImportsByFile.set(typeFile.path, /* @__PURE__ */ new Set());
584
+ const typeImports = typeImportsByFile.get(typeFile.path);
585
+ if (typeSchemas.request?.name) typeImports.add(typeSchemas.request.name);
586
+ if (typeSchemas.response?.name) typeImports.add(typeSchemas.response.name);
587
+ if (typeSchemas.pathParams?.name) typeImports.add(typeSchemas.pathParams.name);
588
+ if (typeSchemas.queryParams?.name) typeImports.add(typeSchemas.queryParams.name);
589
+ if (typeSchemas.headerParams?.name) typeImports.add(typeSchemas.headerParams.name);
590
+ typeSchemas.statusCodes?.forEach((item) => {
591
+ if (item?.name) typeImports.add(item.name);
592
+ });
593
+ typeFilesByPath.set(typeFile.path, typeFile);
594
+ });
595
+ return {
596
+ typeImportsByFile,
597
+ typeFilesByPath
598
+ };
599
+ }
600
+ function collectZodImports(ops) {
601
+ const zodImportsByFile = /* @__PURE__ */ new Map();
602
+ const zodFilesByPath = /* @__PURE__ */ new Map();
603
+ ops.forEach((op) => {
604
+ const { zodSchemas, zodFile } = op;
605
+ if (!zodImportsByFile.has(zodFile.path)) zodImportsByFile.set(zodFile.path, /* @__PURE__ */ new Set());
606
+ const zodImports = zodImportsByFile.get(zodFile.path);
607
+ if (zodSchemas?.response?.name) zodImports.add(zodSchemas.response.name);
608
+ if (zodSchemas?.request?.name) zodImports.add(zodSchemas.request.name);
609
+ zodFilesByPath.set(zodFile.path, zodFile);
610
+ });
611
+ return {
612
+ zodImportsByFile,
613
+ zodFilesByPath
614
+ };
615
+ }
616
+ return controllers.map(({ name, file, operations: ops }) => {
617
+ const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
618
+ const { zodImportsByFile, zodFilesByPath } = options.parser === "zod" ? collectZodImports(ops) : {
619
+ zodImportsByFile: /* @__PURE__ */ new Map(),
620
+ zodFilesByPath: /* @__PURE__ */ new Map()
621
+ };
622
+ const hasFormData = ops.some((op) => op.operation.getContentType() === "multipart/form-data");
623
+ return /* @__PURE__ */ jsxs(File, {
624
+ baseName: file.baseName,
625
+ path: file.path,
626
+ meta: file.meta,
627
+ banner: getBanner({
628
+ oas,
629
+ output: options.output,
630
+ config: pluginManager.config
631
+ }),
632
+ footer: getFooter({
633
+ oas,
634
+ output: options.output
635
+ }),
636
+ children: [
637
+ options.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
638
+ /* @__PURE__ */ jsx(File.Import, {
639
+ name: "fetch",
640
+ path: options.importPath
641
+ }),
642
+ /* @__PURE__ */ jsx(File.Import, {
643
+ name: ["mergeConfig"],
644
+ path: options.importPath
645
+ }),
646
+ /* @__PURE__ */ jsx(File.Import, {
647
+ name: [
648
+ "Client",
649
+ "RequestConfig",
650
+ "ResponseErrorConfig"
651
+ ],
652
+ path: options.importPath,
653
+ isTypeOnly: true
654
+ })
655
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
656
+ /* @__PURE__ */ jsx(File.Import, {
657
+ name: ["fetch"],
658
+ root: file.path,
659
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
660
+ }),
661
+ /* @__PURE__ */ jsx(File.Import, {
662
+ name: ["mergeConfig"],
663
+ root: file.path,
664
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
665
+ }),
666
+ /* @__PURE__ */ jsx(File.Import, {
667
+ name: [
668
+ "Client",
669
+ "RequestConfig",
670
+ "ResponseErrorConfig"
671
+ ],
672
+ root: file.path,
673
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
674
+ isTypeOnly: true
675
+ })
676
+ ] }),
677
+ hasFormData && /* @__PURE__ */ jsx(File.Import, {
678
+ name: ["buildFormData"],
679
+ root: file.path,
680
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
681
+ }),
682
+ Array.from(typeImportsByFile.entries()).map(([filePath, imports]) => {
683
+ const typeFile = typeFilesByPath.get(filePath);
684
+ if (!typeFile) return null;
685
+ const importNames = Array.from(imports).filter(Boolean);
686
+ if (importNames.length === 0) return null;
687
+ return /* @__PURE__ */ jsx(File.Import, {
688
+ name: importNames,
689
+ root: file.path,
690
+ path: typeFile.path,
691
+ isTypeOnly: true
692
+ }, filePath);
693
+ }),
694
+ options.parser === "zod" && Array.from(zodImportsByFile.entries()).map(([filePath, imports]) => {
695
+ const zodFile = zodFilesByPath.get(filePath);
696
+ if (!zodFile) return null;
697
+ const importNames = Array.from(imports).filter(Boolean);
698
+ if (importNames.length === 0) return null;
699
+ return /* @__PURE__ */ jsx(File.Import, {
700
+ name: importNames,
701
+ root: file.path,
702
+ path: zodFile.path
703
+ }, filePath);
704
+ }),
705
+ /* @__PURE__ */ jsx(StaticClassClient, {
706
+ name,
707
+ operations: ops,
708
+ baseURL: options.baseURL,
709
+ dataReturnType: options.dataReturnType,
710
+ pathParamsType: options.pathParamsType,
711
+ paramsCasing: options.paramsCasing,
712
+ paramsType: options.paramsType,
713
+ parser: options.parser
714
+ })
715
+ ]
716
+ }, file.path);
717
+ });
718
+ }
719
+ });
720
+ //#endregion
721
+ export { classClientGenerator as a, clientGenerator as i, operationsGenerator as n, groupedClientGenerator as r, staticClassClientGenerator as t };
722
+
723
+ //# sourceMappingURL=generators-BffddRNu.js.map