@kubb/agent 5.0.0-alpha.35 → 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 (180) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1293 -20554
  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/buffer-from/index.js +72 -0
  134. package/.output/server/node_modules/buffer-from/package.json +19 -0
  135. package/.output/server/node_modules/empathic/access.js +39 -0
  136. package/.output/server/node_modules/empathic/access.mjs +34 -0
  137. package/.output/server/node_modules/empathic/find.js +81 -0
  138. package/.output/server/node_modules/empathic/find.mjs +76 -0
  139. package/.output/server/node_modules/empathic/package.json +49 -0
  140. package/.output/server/node_modules/empathic/package.mjs +52 -0
  141. package/.output/server/node_modules/empathic/resolve.js +31 -0
  142. package/.output/server/node_modules/empathic/resolve.mjs +27 -0
  143. package/.output/server/node_modules/empathic/walk.js +22 -0
  144. package/.output/server/node_modules/empathic/walk.mjs +20 -0
  145. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  146. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  147. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  148. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  149. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  150. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  151. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  152. package/.output/server/node_modules/p-limit/index.js +127 -0
  153. package/.output/server/node_modules/p-limit/package.json +58 -0
  154. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  155. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  156. package/.output/server/node_modules/sisteransi/package.json +34 -0
  157. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  158. package/.output/server/node_modules/source-map-support/package.json +31 -0
  159. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  160. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  161. package/.output/server/node_modules/typescript/package.json +120 -0
  162. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  163. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  164. package/.output/server/package.json +34 -2
  165. package/package.json +20 -20
  166. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  167. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  168. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,399 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { a as MutationKey, i as QueryKey, n as QueryOptions, r as Mutation, t as Query } from "./components-DRDGvgXG.js";
3
+ import path from "node:path";
4
+ import { pluginClientName } from "@kubb/plugin-client";
5
+ import { pluginTsName } from "@kubb/plugin-ts";
6
+ import { pluginZodName } from "@kubb/plugin-zod";
7
+ import { Client } from "@kubb/plugin-client/components";
8
+ import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
9
+ import { File } from "@kubb/react-fabric";
10
+ import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
11
+ import { usePluginManager } from "@kubb/core/hooks";
12
+ import { createReactGenerator } from "@kubb/plugin-oas/generators";
13
+ import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
14
+ import { difference } from "remeda";
15
+ //#region src/generators/mutationGenerator.tsx
16
+ const mutationGenerator = createReactGenerator({
17
+ name: "swr-mutation",
18
+ Operation({ config, operation, generator, plugin }) {
19
+ const { options, options: { output } } = plugin;
20
+ const pluginManager = usePluginManager();
21
+ const oas = useOas();
22
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
23
+ const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
24
+ const isMutation = options.mutation !== false && !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
25
+ const importPath = options.mutation ? options.mutation.importPath : "swr";
26
+ const mutation = {
27
+ name: getName(operation, {
28
+ type: "function",
29
+ prefix: "use"
30
+ }),
31
+ typeName: getName(operation, { type: "type" }),
32
+ file: getFile(operation, { prefix: "use" })
33
+ };
34
+ const type = {
35
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
36
+ schemas: getSchemas(operation, {
37
+ pluginKey: [pluginTsName],
38
+ type: "type"
39
+ })
40
+ };
41
+ const zod = {
42
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
43
+ schemas: getSchemas(operation, {
44
+ pluginKey: [pluginZodName],
45
+ type: "function"
46
+ })
47
+ };
48
+ const shouldUseClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]) && options.client.clientType !== "class";
49
+ const client = {
50
+ name: shouldUseClientPlugin ? getName(operation, {
51
+ type: "function",
52
+ pluginKey: [pluginClientName]
53
+ }) : getName(operation, { type: "function" }),
54
+ file: getFile(operation, { pluginKey: [pluginClientName] })
55
+ };
56
+ const mutationKey = {
57
+ name: getName(operation, {
58
+ type: "const",
59
+ suffix: "MutationKey"
60
+ }),
61
+ typeName: getName(operation, {
62
+ type: "type",
63
+ suffix: "MutationKey"
64
+ })
65
+ };
66
+ if (!isMutation) return null;
67
+ return /* @__PURE__ */ jsxs(File, {
68
+ baseName: mutation.file.baseName,
69
+ path: mutation.file.path,
70
+ meta: mutation.file.meta,
71
+ banner: getBanner({
72
+ oas,
73
+ output,
74
+ config: pluginManager.config
75
+ }),
76
+ footer: getFooter({
77
+ oas,
78
+ output
79
+ }),
80
+ children: [
81
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, {
82
+ name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
83
+ root: mutation.file.path,
84
+ path: zod.file.path
85
+ }),
86
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
87
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
88
+ name: "fetch",
89
+ path: options.client.importPath
90
+ }),
91
+ /* @__PURE__ */ jsx(File.Import, {
92
+ name: [
93
+ "Client",
94
+ "RequestConfig",
95
+ "ResponseErrorConfig"
96
+ ],
97
+ path: options.client.importPath,
98
+ isTypeOnly: true
99
+ }),
100
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
101
+ name: ["ResponseConfig"],
102
+ path: options.client.importPath,
103
+ isTypeOnly: true
104
+ })
105
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
106
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
107
+ name: ["fetch"],
108
+ root: mutation.file.path,
109
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
110
+ }),
111
+ /* @__PURE__ */ jsx(File.Import, {
112
+ name: [
113
+ "Client",
114
+ "RequestConfig",
115
+ "ResponseErrorConfig"
116
+ ],
117
+ root: mutation.file.path,
118
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
119
+ isTypeOnly: true
120
+ }),
121
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
122
+ name: ["ResponseConfig"],
123
+ root: mutation.file.path,
124
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
125
+ isTypeOnly: true
126
+ })
127
+ ] }),
128
+ /* @__PURE__ */ jsx(File.Import, {
129
+ name: "useSWRMutation",
130
+ path: importPath
131
+ }),
132
+ /* @__PURE__ */ jsx(File.Import, {
133
+ name: ["SWRMutationConfiguration", "SWRMutationResponse"],
134
+ path: importPath,
135
+ isTypeOnly: true
136
+ }),
137
+ shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
138
+ name: [client.name],
139
+ root: mutation.file.path,
140
+ path: client.file.path
141
+ }),
142
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
143
+ name: ["buildFormData"],
144
+ root: mutation.file.path,
145
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
146
+ }),
147
+ /* @__PURE__ */ jsx(File.Import, {
148
+ name: [
149
+ type.schemas.request?.name,
150
+ type.schemas.response.name,
151
+ type.schemas.pathParams?.name,
152
+ type.schemas.queryParams?.name,
153
+ type.schemas.headerParams?.name,
154
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
155
+ ].filter(Boolean),
156
+ root: mutation.file.path,
157
+ path: type.file.path,
158
+ isTypeOnly: true
159
+ }),
160
+ /* @__PURE__ */ jsx(MutationKey, {
161
+ name: mutationKey.name,
162
+ typeName: mutationKey.typeName,
163
+ operation,
164
+ pathParamsType: options.pathParamsType,
165
+ typeSchemas: type.schemas,
166
+ paramsCasing: options.paramsCasing,
167
+ transformer: options.mutationKey
168
+ }),
169
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(Client, {
170
+ name: client.name,
171
+ baseURL: options.client.baseURL,
172
+ operation,
173
+ typeSchemas: type.schemas,
174
+ zodSchemas: zod.schemas,
175
+ dataReturnType: options.client.dataReturnType || "data",
176
+ paramsCasing: options.client?.paramsCasing || options.paramsCasing,
177
+ paramsType: options.paramsType,
178
+ pathParamsType: options.pathParamsType,
179
+ parser: options.parser
180
+ }),
181
+ options.mutation && /* @__PURE__ */ jsx(Mutation, {
182
+ name: mutation.name,
183
+ clientName: client.name,
184
+ typeName: mutation.typeName,
185
+ typeSchemas: type.schemas,
186
+ operation,
187
+ dataReturnType: options.client.dataReturnType || "data",
188
+ paramsType: options.paramsType,
189
+ paramsCasing: options.paramsCasing,
190
+ pathParamsType: options.pathParamsType,
191
+ mutationKeyName: mutationKey.name,
192
+ mutationKeyTypeName: mutationKey.typeName,
193
+ paramsToTrigger: options.mutation.paramsToTrigger
194
+ })
195
+ ]
196
+ });
197
+ }
198
+ });
199
+ //#endregion
200
+ //#region src/generators/queryGenerator.tsx
201
+ const queryGenerator = createReactGenerator({
202
+ name: "swr-query",
203
+ Operation({ config, operation, generator, plugin }) {
204
+ const { options, options: { output } } = plugin;
205
+ const pluginManager = usePluginManager();
206
+ const oas = useOas();
207
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
208
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
209
+ const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
210
+ const importPath = options.query ? options.query.importPath : "swr/mutation";
211
+ const query = {
212
+ name: getName(operation, {
213
+ type: "function",
214
+ prefix: "use"
215
+ }),
216
+ typeName: getName(operation, { type: "type" }),
217
+ file: getFile(operation, { prefix: "use" })
218
+ };
219
+ const shouldUseClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]) && options.client.clientType !== "class";
220
+ const client = {
221
+ name: shouldUseClientPlugin ? getName(operation, {
222
+ type: "function",
223
+ pluginKey: [pluginClientName]
224
+ }) : getName(operation, { type: "function" }),
225
+ file: getFile(operation, { pluginKey: [pluginClientName] })
226
+ };
227
+ const queryOptions = { name: getName(operation, {
228
+ type: "function",
229
+ suffix: "QueryOptions"
230
+ }) };
231
+ const queryKey = {
232
+ name: getName(operation, {
233
+ type: "const",
234
+ suffix: "QueryKey"
235
+ }),
236
+ typeName: getName(operation, {
237
+ type: "type",
238
+ suffix: "QueryKey"
239
+ })
240
+ };
241
+ const type = {
242
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
243
+ schemas: getSchemas(operation, {
244
+ pluginKey: [pluginTsName],
245
+ type: "type"
246
+ })
247
+ };
248
+ const zod = {
249
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
250
+ schemas: getSchemas(operation, {
251
+ pluginKey: [pluginZodName],
252
+ type: "function"
253
+ })
254
+ };
255
+ if (!isQuery || isMutation) return null;
256
+ return /* @__PURE__ */ jsxs(File, {
257
+ baseName: query.file.baseName,
258
+ path: query.file.path,
259
+ meta: query.file.meta,
260
+ banner: getBanner({
261
+ oas,
262
+ output,
263
+ config: pluginManager.config
264
+ }),
265
+ footer: getFooter({
266
+ oas,
267
+ output
268
+ }),
269
+ children: [
270
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, {
271
+ name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
272
+ root: query.file.path,
273
+ path: zod.file.path
274
+ }),
275
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
276
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
277
+ name: "fetch",
278
+ path: options.client.importPath
279
+ }),
280
+ /* @__PURE__ */ jsx(File.Import, {
281
+ name: [
282
+ "Client",
283
+ "RequestConfig",
284
+ "ResponseErrorConfig"
285
+ ],
286
+ path: options.client.importPath,
287
+ isTypeOnly: true
288
+ }),
289
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
290
+ name: ["ResponseConfig"],
291
+ path: options.client.importPath,
292
+ isTypeOnly: true
293
+ })
294
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
295
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
296
+ name: ["fetch"],
297
+ root: query.file.path,
298
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
299
+ }),
300
+ /* @__PURE__ */ jsx(File.Import, {
301
+ name: [
302
+ "Client",
303
+ "RequestConfig",
304
+ "ResponseErrorConfig"
305
+ ],
306
+ root: query.file.path,
307
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
308
+ isTypeOnly: true
309
+ }),
310
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
311
+ name: ["ResponseConfig"],
312
+ root: query.file.path,
313
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
314
+ isTypeOnly: true
315
+ })
316
+ ] }),
317
+ shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
318
+ name: [client.name],
319
+ root: query.file.path,
320
+ path: client.file.path
321
+ }),
322
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
323
+ name: ["buildFormData"],
324
+ root: query.file.path,
325
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
326
+ }),
327
+ /* @__PURE__ */ jsx(File.Import, {
328
+ name: [
329
+ type.schemas.request?.name,
330
+ type.schemas.response.name,
331
+ type.schemas.pathParams?.name,
332
+ type.schemas.queryParams?.name,
333
+ type.schemas.headerParams?.name,
334
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
335
+ ].filter(Boolean),
336
+ root: query.file.path,
337
+ path: type.file.path,
338
+ isTypeOnly: true
339
+ }),
340
+ /* @__PURE__ */ jsx(QueryKey, {
341
+ name: queryKey.name,
342
+ typeName: queryKey.typeName,
343
+ operation,
344
+ pathParamsType: options.pathParamsType,
345
+ typeSchemas: type.schemas,
346
+ paramsCasing: options.paramsCasing,
347
+ transformer: options.queryKey
348
+ }),
349
+ !shouldUseClientPlugin && /* @__PURE__ */ jsx(Client, {
350
+ name: client.name,
351
+ baseURL: options.client.baseURL,
352
+ operation,
353
+ typeSchemas: type.schemas,
354
+ zodSchemas: zod.schemas,
355
+ dataReturnType: options.client.dataReturnType || "data",
356
+ paramsCasing: options.client.paramsCasing || options.paramsCasing,
357
+ paramsType: options.paramsType,
358
+ pathParamsType: options.pathParamsType,
359
+ parser: options.parser
360
+ }),
361
+ /* @__PURE__ */ jsx(QueryOptions, {
362
+ name: queryOptions.name,
363
+ clientName: client.name,
364
+ typeSchemas: type.schemas,
365
+ paramsType: options.paramsType,
366
+ paramsCasing: options.paramsCasing,
367
+ pathParamsType: options.pathParamsType
368
+ }),
369
+ options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
370
+ /* @__PURE__ */ jsx(File.Import, {
371
+ name: "useSWR",
372
+ path: importPath
373
+ }),
374
+ /* @__PURE__ */ jsx(File.Import, {
375
+ name: ["SWRResponse"],
376
+ path: importPath,
377
+ isTypeOnly: true
378
+ }),
379
+ /* @__PURE__ */ jsx(Query, {
380
+ name: query.name,
381
+ queryOptionsName: queryOptions.name,
382
+ typeSchemas: type.schemas,
383
+ paramsType: options.paramsType,
384
+ pathParamsType: options.pathParamsType,
385
+ operation,
386
+ dataReturnType: options.client.dataReturnType || "data",
387
+ queryKeyName: queryKey.name,
388
+ paramsCasing: options.paramsCasing,
389
+ queryKeyTypeName: queryKey.typeName
390
+ })
391
+ ] })
392
+ ]
393
+ });
394
+ }
395
+ });
396
+ //#endregion
397
+ export { mutationGenerator as n, queryGenerator as t };
398
+
399
+ //# sourceMappingURL=generators-ClWZJ-YG.js.map
@@ -0,0 +1,144 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { a as MutationKey, i as QueryKey, o as camelCase, s as pascalCase } from "./components-DRDGvgXG.js";
3
+ import { n as mutationGenerator, t as queryGenerator } from "./generators-ClWZJ-YG.js";
4
+ import path from "node:path";
5
+ import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
6
+ import { pluginClientName } from "@kubb/plugin-client";
7
+ import { source } from "@kubb/plugin-client/templates/clients/axios.source";
8
+ import { source as source$1 } from "@kubb/plugin-client/templates/clients/fetch.source";
9
+ import { source as source$2 } from "@kubb/plugin-client/templates/config.source";
10
+ import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
11
+ import { pluginTsName } from "@kubb/plugin-ts";
12
+ import { pluginZodName } from "@kubb/plugin-zod";
13
+ //#region src/plugin.ts
14
+ const pluginSwrName = "plugin-swr";
15
+ const pluginSwr = definePlugin((options) => {
16
+ const { output = {
17
+ path: "hooks",
18
+ barrelType: "named"
19
+ }, group, exclude = [], include, override = [], parser = "client", transformers = {}, query, mutation, client, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", mutationKey = MutationKey.getTransformer, queryKey = QueryKey.getTransformer, generators = [queryGenerator, mutationGenerator].filter(Boolean), paramsCasing, contentType } = options;
20
+ const clientName = client?.client ?? "axios";
21
+ const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
22
+ return {
23
+ name: pluginSwrName,
24
+ options: {
25
+ output,
26
+ client: {
27
+ bundle: client?.bundle,
28
+ baseURL: client?.baseURL,
29
+ client: clientName,
30
+ clientType: client?.clientType ?? "function",
31
+ importPath: clientImportPath,
32
+ dataReturnType: client?.dataReturnType ?? "data",
33
+ paramsCasing
34
+ },
35
+ queryKey,
36
+ query: query === false ? false : {
37
+ importPath: "swr",
38
+ methods: ["get"],
39
+ ...query
40
+ },
41
+ mutationKey,
42
+ mutation: mutation === false ? false : {
43
+ importPath: "swr/mutation",
44
+ methods: [
45
+ "post",
46
+ "put",
47
+ "delete",
48
+ "patch"
49
+ ],
50
+ ...mutation
51
+ },
52
+ parser,
53
+ paramsType,
54
+ pathParamsType,
55
+ paramsCasing,
56
+ group
57
+ },
58
+ pre: [
59
+ pluginOasName,
60
+ pluginTsName,
61
+ parser === "zod" ? pluginZodName : void 0
62
+ ].filter(Boolean),
63
+ resolvePath(baseName, pathMode, options) {
64
+ const root = path.resolve(this.config.root, this.config.output.path);
65
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
66
+ /**
67
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
68
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
69
+ */
70
+ return path.resolve(root, output.path);
71
+ if (group && (options?.group?.path || options?.group?.tag)) {
72
+ const groupName = group?.name ? group.name : (ctx) => {
73
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
74
+ return `${camelCase(ctx.group)}Controller`;
75
+ };
76
+ return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
77
+ }
78
+ return path.resolve(root, output.path, baseName);
79
+ },
80
+ resolveName(name, type) {
81
+ let resolvedName = camelCase(name);
82
+ if (type === "file" || type === "function") resolvedName = camelCase(name, { isFile: type === "file" });
83
+ if (type === "type") resolvedName = pascalCase(name);
84
+ if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
85
+ return resolvedName;
86
+ },
87
+ async install() {
88
+ const root = path.resolve(this.config.root, this.config.output.path);
89
+ const mode = getMode(path.resolve(root, output.path));
90
+ const oas = await this.getOas();
91
+ const baseURL = await this.getBaseURL();
92
+ if (baseURL) this.plugin.options.client.baseURL = baseURL;
93
+ const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName]);
94
+ if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
95
+ baseName: "fetch.ts",
96
+ path: path.resolve(root, ".kubb/fetch.ts"),
97
+ sources: [{
98
+ name: "fetch",
99
+ value: this.plugin.options.client.client === "fetch" ? source$1 : source,
100
+ isExportable: true,
101
+ isIndexable: true
102
+ }],
103
+ imports: [],
104
+ exports: []
105
+ });
106
+ if (!hasClientPlugin) await this.addFile({
107
+ baseName: "config.ts",
108
+ path: path.resolve(root, ".kubb/config.ts"),
109
+ sources: [{
110
+ name: "config",
111
+ value: source$2,
112
+ isExportable: false,
113
+ isIndexable: false
114
+ }],
115
+ imports: [],
116
+ exports: []
117
+ });
118
+ const files = await new OperationGenerator(this.plugin.options, {
119
+ fabric: this.fabric,
120
+ oas,
121
+ pluginManager: this.pluginManager,
122
+ events: this.events,
123
+ plugin: this.plugin,
124
+ contentType,
125
+ exclude,
126
+ include,
127
+ override,
128
+ mode
129
+ }).build(...generators);
130
+ await this.upsertFile(...files);
131
+ const barrelFiles = await getBarrelFiles(this.fabric.files, {
132
+ type: output.barrelType ?? "named",
133
+ root,
134
+ output,
135
+ meta: { pluginKey: this.plugin.key }
136
+ });
137
+ await this.upsertFile(...barrelFiles);
138
+ }
139
+ };
140
+ });
141
+ //#endregion
142
+ export { pluginSwr, pluginSwrName };
143
+
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "@kubb/plugin-swr",
3
+ "version": "4.37.2",
4
+ "description": "SWR hooks generator plugin for Kubb, creating type-safe data fetching hooks from OpenAPI specifications for React and Next.js applications.",
5
+ "keywords": [
6
+ "swr",
7
+ "react",
8
+ "nextjs",
9
+ "next",
10
+ "next.js",
11
+ "vercel",
12
+ "data-fetching",
13
+ "react-hooks",
14
+ "hooks",
15
+ "api-client",
16
+ "sdk-generator",
17
+ "typescript",
18
+ "type-safe",
19
+ "openapi",
20
+ "swagger",
21
+ "oas",
22
+ "code-generator",
23
+ "codegen",
24
+ "plugins",
25
+ "kubb"
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/kubb-labs/kubb.git",
30
+ "directory": "packages/plugin-swr"
31
+ },
32
+ "license": "MIT",
33
+ "author": "stijnvanhulle",
34
+ "sideEffects": false,
35
+ "type": "module",
36
+ "exports": {
37
+ ".": {
38
+ "import": "./dist/index.js",
39
+ "require": "./dist/index.cjs"
40
+ },
41
+ "./components": {
42
+ "import": "./dist/components.js",
43
+ "require": "./dist/components.cjs"
44
+ },
45
+ "./generators": {
46
+ "import": "./dist/generators.js",
47
+ "require": "./dist/generators.cjs"
48
+ },
49
+ "./package.json": "./package.json"
50
+ },
51
+ "types": "./dist/index.d.ts",
52
+ "typesVersions": {
53
+ "*": {
54
+ "components": [
55
+ "./dist/components.d.ts"
56
+ ],
57
+ "generators": [
58
+ "./dist/generators.d.ts"
59
+ ]
60
+ }
61
+ },
62
+ "files": [
63
+ "src",
64
+ "dist",
65
+ "!/**/**.test.**",
66
+ "!/**/__tests__/**",
67
+ "!/**/__snapshots__/**"
68
+ ],
69
+ "size-limit": [
70
+ {
71
+ "path": "./dist/*.js",
72
+ "limit": "510 KiB",
73
+ "gzip": true
74
+ }
75
+ ],
76
+ "dependencies": {
77
+ "@kubb/fabric-core": "0.14.0",
78
+ "@kubb/react-fabric": "0.14.0",
79
+ "remeda": "^2.33.6",
80
+ "@kubb/core": "4.37.2",
81
+ "@kubb/oas": "4.37.2",
82
+ "@kubb/plugin-client": "4.37.2",
83
+ "@kubb/plugin-oas": "4.37.2",
84
+ "@kubb/plugin-ts": "4.37.2",
85
+ "@kubb/plugin-zod": "4.37.2"
86
+ },
87
+ "peerDependencies": {
88
+ "@kubb/fabric-core": "0.14.0",
89
+ "@kubb/react-fabric": "0.14.0"
90
+ },
91
+ "engines": {
92
+ "node": ">=20"
93
+ },
94
+ "publishConfig": {
95
+ "access": "public",
96
+ "registry": "https://registry.npmjs.org/"
97
+ },
98
+ "main": "./dist/index.cjs",
99
+ "module": "./dist/index.js",
100
+ "devDependencies": {
101
+ "@internals/tanstack-query": "0.0.0",
102
+ "@internals/utils": "0.0.0"
103
+ },
104
+ "scripts": {
105
+ "build": "tsdown && size-limit",
106
+ "clean": "rimraf ./dist",
107
+ "lint": "bun biome lint .",
108
+ "lint:fix": "bun biome lint --fix --unsafe .",
109
+ "release": "pnpm publish --no-git-check",
110
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
111
+ "start": "tsdown --watch",
112
+ "test": "vitest --passWithNoTests",
113
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
114
+ }
115
+ }
@@ -0,0 +1,8 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+ //#endregion
8
+ export { __name as t };