@kubb/plugin-swr 3.16.1 → 3.16.3

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 (39) hide show
  1. package/dist/components-BQIcQmn3.js +435 -0
  2. package/dist/components-BQIcQmn3.js.map +1 -0
  3. package/dist/components-Zv6v8ZAm.cjs +493 -0
  4. package/dist/components-Zv6v8ZAm.cjs.map +1 -0
  5. package/dist/components.cjs +6 -27
  6. package/dist/components.d.cts +177 -78
  7. package/dist/components.d.ts +177 -78
  8. package/dist/components.js +3 -3
  9. package/dist/generators-B-fWjDXL.js +328 -0
  10. package/dist/generators-B-fWjDXL.js.map +1 -0
  11. package/dist/generators-ByyKDjyt.cjs +339 -0
  12. package/dist/generators-ByyKDjyt.cjs.map +1 -0
  13. package/dist/generators.cjs +4 -16
  14. package/dist/generators.d.cts +8 -9
  15. package/dist/generators.d.ts +8 -9
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +107 -136
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -8
  20. package/dist/index.d.ts +6 -8
  21. package/dist/index.js +107 -130
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-CSnGy9Uj.d.ts +1355 -0
  24. package/dist/types-CjDGkyWH.d.cts +1355 -0
  25. package/package.json +25 -30
  26. package/dist/chunk-2N4Q32XH.cjs +0 -285
  27. package/dist/chunk-2N4Q32XH.cjs.map +0 -1
  28. package/dist/chunk-GWLPXHRE.js +0 -282
  29. package/dist/chunk-GWLPXHRE.js.map +0 -1
  30. package/dist/chunk-MNOTKHSE.cjs +0 -367
  31. package/dist/chunk-MNOTKHSE.cjs.map +0 -1
  32. package/dist/chunk-RZTUH4QW.js +0 -361
  33. package/dist/chunk-RZTUH4QW.js.map +0 -1
  34. package/dist/components.cjs.map +0 -1
  35. package/dist/components.js.map +0 -1
  36. package/dist/generators.cjs.map +0 -1
  37. package/dist/generators.js.map +0 -1
  38. package/dist/types-DVQ2siUx.d.cts +0 -134
  39. package/dist/types-DVQ2siUx.d.ts +0 -134
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "3.16.1",
3
+ "version": "3.16.3",
4
4
  "description": "SWR hooks generator plugin for Kubb, creating type-safe data fetching hooks from OpenAPI specifications for React and Next.js applications.",
5
5
  "keywords": [
6
6
  "swr",
@@ -31,25 +31,21 @@
31
31
  "exports": {
32
32
  ".": {
33
33
  "import": "./dist/index.js",
34
- "require": "./dist/index.cjs",
35
- "default": "./dist/index.cjs"
36
- },
37
- "./generators": {
38
- "import": "./dist/generators.js",
39
- "require": "./dist/generators.cjs",
40
- "default": "./dist/generators.cjs"
34
+ "require": "./dist/index.cjs"
41
35
  },
42
36
  "./components": {
43
37
  "import": "./dist/components.js",
44
- "require": "./dist/components.cjs",
45
- "default": "./dist/components.cjs"
38
+ "require": "./dist/components.cjs"
39
+ },
40
+ "./generators": {
41
+ "import": "./dist/generators.js",
42
+ "require": "./dist/generators.cjs"
46
43
  },
47
- "./package.json": "./package.json",
48
- "./*": "./*"
44
+ "./package.json": "./package.json"
49
45
  },
50
- "main": "dist/index.cjs",
51
- "module": "dist/index.js",
52
- "types": "./dist/index.d.ts",
46
+ "main": "./dist/index.cjs",
47
+ "module": "./dist/index.js",
48
+ "types": "./dist/index.d.cts",
53
49
  "typesVersions": {
54
50
  "*": {
55
51
  "components": [
@@ -67,22 +63,21 @@
67
63
  "!/**/__tests__/**"
68
64
  ],
69
65
  "dependencies": {
70
- "remeda": "^2.26.0",
71
- "@kubb/core": "3.16.1",
72
- "@kubb/oas": "3.16.1",
73
- "@kubb/plugin-client": "3.16.1",
74
- "@kubb/plugin-oas": "3.16.1",
75
- "@kubb/plugin-ts": "3.16.1",
76
- "@kubb/plugin-zod": "3.16.1",
77
- "@kubb/react": "3.16.1"
66
+ "remeda": "^2.30.0",
67
+ "@kubb/core": "3.16.3",
68
+ "@kubb/oas": "3.16.3",
69
+ "@kubb/plugin-client": "3.16.3",
70
+ "@kubb/plugin-oas": "3.16.3",
71
+ "@kubb/plugin-ts": "3.16.3",
72
+ "@kubb/plugin-zod": "3.16.3",
73
+ "@kubb/react": "3.16.3"
78
74
  },
79
75
  "devDependencies": {
80
76
  "@types/react": "^18.3.23",
81
77
  "react": "^18.3.1",
82
- "tsup": "^8.5.0",
83
- "typescript": "^5.8.3",
84
- "@kubb/config-ts": "3.16.1",
85
- "@kubb/config-tsup": "3.16.1"
78
+ "tsdown": "^0.14.1",
79
+ "typescript": "^5.9.2",
80
+ "@kubb/config-ts": "3.16.3"
86
81
  },
87
82
  "peerDependencies": {
88
83
  "@kubb/react": "^3.0.0"
@@ -95,13 +90,13 @@
95
90
  "registry": "https://registry.npmjs.org/"
96
91
  },
97
92
  "scripts": {
98
- "build": "tsup",
93
+ "build": "tsdown",
99
94
  "clean": "rimraf ./dist",
100
95
  "lint": "bun biome lint .",
101
- "lint:fix": "bun biome lint--fix --unsafe .",
96
+ "lint:fix": "bun biome lint --fix --unsafe .",
102
97
  "release": "pnpm publish --no-git-check",
103
98
  "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
104
- "start": "tsup --watch",
99
+ "start": "tsdown --watch",
105
100
  "test": "vitest --passWithNoTests",
106
101
  "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
107
102
  }
@@ -1,285 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkMNOTKHSE_cjs = require('./chunk-MNOTKHSE.cjs');
4
- var pluginClient = require('@kubb/plugin-client');
5
- var components = require('@kubb/plugin-client/components');
6
- var pluginOas = require('@kubb/plugin-oas');
7
- var hooks = require('@kubb/plugin-oas/hooks');
8
- var utils = require('@kubb/plugin-oas/utils');
9
- var pluginTs = require('@kubb/plugin-ts');
10
- var pluginZod = require('@kubb/plugin-zod');
11
- var react = require('@kubb/react');
12
- var remeda = require('remeda');
13
- var jsxRuntime = require('@kubb/react/jsx-runtime');
14
-
15
- var queryGenerator = pluginOas.createReactGenerator({
16
- name: "swr-query",
17
- Operation({ options, operation }) {
18
- const {
19
- plugin: {
20
- options: { output }
21
- },
22
- pluginManager
23
- } = react.useApp();
24
- const oas = hooks.useOas();
25
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
26
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
27
- const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
28
- (method) => operation.method === method
29
- );
30
- const importPath = options.query ? options.query.importPath : "swr/mutation";
31
- const query = {
32
- name: getName(operation, { type: "function", prefix: "use" }),
33
- typeName: getName(operation, { type: "type" }),
34
- file: getFile(operation, { prefix: "use" })
35
- };
36
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
37
- const client = {
38
- name: hasClientPlugin ? getName(operation, {
39
- type: "function",
40
- pluginKey: [pluginClient.pluginClientName]
41
- }) : getName(operation, {
42
- type: "function"
43
- }),
44
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
45
- };
46
- const queryOptions = {
47
- name: getName(operation, { type: "function", suffix: "QueryOptions" })
48
- };
49
- const queryKey = {
50
- name: getName(operation, { type: "const", suffix: "QueryKey" }),
51
- typeName: getName(operation, { type: "type", suffix: "QueryKey" })
52
- };
53
- const type = {
54
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
55
- //todo remove type?
56
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
57
- };
58
- const zod = {
59
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
60
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
61
- };
62
- if (!isQuery || isMutation) {
63
- return null;
64
- }
65
- return /* @__PURE__ */ jsxRuntime.jsxs(
66
- react.File,
67
- {
68
- baseName: query.file.baseName,
69
- path: query.file.path,
70
- meta: query.file.meta,
71
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
72
- footer: utils.getFooter({ oas, output }),
73
- children: [
74
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
75
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
76
- !!hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
77
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
78
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
79
- /* @__PURE__ */ jsxRuntime.jsx(
80
- react.File.Import,
81
- {
82
- name: [
83
- type.schemas.request?.name,
84
- type.schemas.response.name,
85
- type.schemas.pathParams?.name,
86
- type.schemas.queryParams?.name,
87
- type.schemas.headerParams?.name,
88
- ...type.schemas.statusCodes?.map((item) => item.name) || []
89
- ].filter(Boolean),
90
- root: query.file.path,
91
- path: type.file.path,
92
- isTypeOnly: true
93
- }
94
- ),
95
- /* @__PURE__ */ jsxRuntime.jsx(
96
- chunkMNOTKHSE_cjs.QueryKey,
97
- {
98
- name: queryKey.name,
99
- typeName: queryKey.typeName,
100
- operation,
101
- pathParamsType: options.pathParamsType,
102
- typeSchemas: type.schemas,
103
- paramsCasing: options.paramsCasing,
104
- transformer: options.queryKey
105
- }
106
- ),
107
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
108
- components.Client,
109
- {
110
- name: client.name,
111
- baseURL: options.client.baseURL,
112
- operation,
113
- typeSchemas: type.schemas,
114
- zodSchemas: zod.schemas,
115
- dataReturnType: options.client.dataReturnType,
116
- paramsCasing: options.paramsCasing,
117
- paramsType: options.paramsType,
118
- pathParamsType: options.pathParamsType,
119
- parser: options.parser
120
- }
121
- ),
122
- /* @__PURE__ */ jsxRuntime.jsx(
123
- chunkMNOTKHSE_cjs.QueryOptions,
124
- {
125
- name: queryOptions.name,
126
- clientName: client.name,
127
- typeSchemas: type.schemas,
128
- paramsType: options.paramsType,
129
- paramsCasing: options.paramsCasing,
130
- pathParamsType: options.pathParamsType
131
- }
132
- ),
133
- options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
134
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWR", path: importPath }),
135
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRResponse"], path: importPath, isTypeOnly: true }),
136
- /* @__PURE__ */ jsxRuntime.jsx(
137
- chunkMNOTKHSE_cjs.Query,
138
- {
139
- name: query.name,
140
- queryOptionsName: queryOptions.name,
141
- typeSchemas: type.schemas,
142
- paramsType: options.paramsType,
143
- pathParamsType: options.pathParamsType,
144
- operation,
145
- dataReturnType: options.client.dataReturnType,
146
- queryKeyName: queryKey.name,
147
- paramsCasing: options.paramsCasing,
148
- queryKeyTypeName: queryKey.typeName
149
- }
150
- )
151
- ] })
152
- ]
153
- }
154
- );
155
- }
156
- });
157
- var mutationGenerator = pluginOas.createReactGenerator({
158
- name: "swr-mutation",
159
- Operation({ options, operation }) {
160
- const {
161
- plugin: {
162
- options: { output }
163
- },
164
- pluginManager
165
- } = react.useApp();
166
- const oas = hooks.useOas();
167
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
168
- const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
169
- const isMutation = !isQuery && remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
170
- const importPath = options.mutation ? options.mutation.importPath : "swr";
171
- const mutation = {
172
- name: getName(operation, { type: "function", prefix: "use" }),
173
- typeName: getName(operation, { type: "type" }),
174
- file: getFile(operation, { prefix: "use" })
175
- };
176
- const type = {
177
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
178
- //todo remove type?
179
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
180
- };
181
- const zod = {
182
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
183
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
184
- };
185
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
186
- const client = {
187
- name: hasClientPlugin ? getName(operation, {
188
- type: "function",
189
- pluginKey: [pluginClient.pluginClientName]
190
- }) : getName(operation, {
191
- type: "function"
192
- }),
193
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
194
- };
195
- const mutationKey = {
196
- name: getName(operation, { type: "const", suffix: "MutationKey" }),
197
- typeName: getName(operation, { type: "type", suffix: "MutationKey" })
198
- };
199
- if (!isMutation) {
200
- return null;
201
- }
202
- return /* @__PURE__ */ jsxRuntime.jsxs(
203
- react.File,
204
- {
205
- baseName: mutation.file.baseName,
206
- path: mutation.file.path,
207
- meta: mutation.file.meta,
208
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
209
- footer: utils.getFooter({ oas, output }),
210
- children: [
211
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: mutation.file.path, path: zod.file.path }),
212
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWRMutation", path: importPath }),
213
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRMutationResponse"], path: importPath, isTypeOnly: true }),
214
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
215
- !!hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: mutation.file.path, path: client.file.path }),
216
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
217
- /* @__PURE__ */ jsxRuntime.jsx(
218
- react.File.Import,
219
- {
220
- name: [
221
- type.schemas.request?.name,
222
- type.schemas.response.name,
223
- type.schemas.pathParams?.name,
224
- type.schemas.queryParams?.name,
225
- type.schemas.headerParams?.name,
226
- ...type.schemas.statusCodes?.map((item) => item.name) || []
227
- ].filter(Boolean),
228
- root: mutation.file.path,
229
- path: type.file.path,
230
- isTypeOnly: true
231
- }
232
- ),
233
- /* @__PURE__ */ jsxRuntime.jsx(
234
- chunkMNOTKHSE_cjs.MutationKey,
235
- {
236
- name: mutationKey.name,
237
- typeName: mutationKey.typeName,
238
- operation,
239
- pathParamsType: options.pathParamsType,
240
- typeSchemas: type.schemas,
241
- paramsCasing: options.paramsCasing,
242
- transformer: options.mutationKey
243
- }
244
- ),
245
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
246
- components.Client,
247
- {
248
- name: client.name,
249
- baseURL: options.client.baseURL,
250
- operation,
251
- typeSchemas: type.schemas,
252
- zodSchemas: zod.schemas,
253
- dataReturnType: options.client.dataReturnType,
254
- paramsCasing: options.paramsCasing,
255
- paramsType: options.paramsType,
256
- pathParamsType: options.pathParamsType,
257
- parser: options.parser
258
- }
259
- ),
260
- options.mutation && /* @__PURE__ */ jsxRuntime.jsx(
261
- chunkMNOTKHSE_cjs.Mutation,
262
- {
263
- name: mutation.name,
264
- clientName: client.name,
265
- typeName: mutation.typeName,
266
- typeSchemas: type.schemas,
267
- operation,
268
- dataReturnType: options.client.dataReturnType,
269
- paramsType: options.paramsType,
270
- paramsCasing: options.paramsCasing,
271
- pathParamsType: options.pathParamsType,
272
- mutationKeyName: mutationKey.name,
273
- mutationKeyTypeName: mutationKey.typeName
274
- }
275
- )
276
- ]
277
- }
278
- );
279
- }
280
- });
281
-
282
- exports.mutationGenerator = mutationGenerator;
283
- exports.queryGenerator = queryGenerator;
284
- //# sourceMappingURL=chunk-2N4Q32XH.cjs.map
285
- //# sourceMappingURL=chunk-2N4Q32XH.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","difference","pluginClientName","pluginTsName","pluginZodName","jsxs","File","getBanner","getFooter","jsx","QueryKey","Client","QueryOptions","Fragment","Query","MutationKey","Mutation"],"mappings":";;;;;;;;;;;;;;AAaO,IAAM,iBAAiBA,8BAAgC,CAAA;AAAA,EAC5D,IAAM,EAAA,WAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO;AAAA,OACpB;AAAA,MACA;AAAA,QACEC,YAAkB,EAAA;AACtB,IAAA,MAAM,MAAMC,YAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA;AAE7D,IAAA,MAAM,OAAU,GAAA,OAAO,OAAQ,CAAA,KAAA,KAAU,YAAY,IAAO,GAAA,OAAA,CAAQ,KAAO,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAC,MAAW,KAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC/H,IAAA,MAAM,aAAaC,iBAAW,CAAA,OAAA,CAAQ,QAAW,GAAA,OAAA,CAAQ,SAAS,OAAU,GAAA,EAAI,EAAA,OAAA,CAAQ,QAAQ,OAAQ,CAAA,KAAA,CAAM,OAAU,GAAA,EAAE,CAAE,CAAA,IAAA;AAAA,MAC1H,CAAC,MAAW,KAAA,SAAA,CAAU,MAAW,KAAA;AAAA,KACnC;AACA,IAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,KAAQ,GAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,cAAA;AAE9D,IAAA,MAAM,KAAQ,GAAA;AAAA,MACZ,IAAA,EAAM,QAAQ,SAAW,EAAA,EAAE,MAAM,UA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,YAAA;AAAA,cACtB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,cACxB,iBAAiB,WAAY,CAAA,IAAA;AAAA,cAC7B,qBAAqB,WAAY,CAAA;AAAA;AAAA;AACnC;AAAA;AAAA,KAEJ;AAAA;AAGN,CAAC","file":"chunk-2N4Q32XH.cjs","sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryOptions } from '../components'\nimport { QueryKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSwr>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { MutationKey } from '../components'\nimport { Mutation } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSwr>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationResponse']} path={importPath} isTypeOnly />\n {<File.Import name={'fetch'} path={options.client.importPath} />}\n {!!hasClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n />\n )}\n </File>\n )\n },\n})\n"]}