@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.
- package/dist/components-BQIcQmn3.js +435 -0
- package/dist/components-BQIcQmn3.js.map +1 -0
- package/dist/components-Zv6v8ZAm.cjs +493 -0
- package/dist/components-Zv6v8ZAm.cjs.map +1 -0
- package/dist/components.cjs +6 -27
- package/dist/components.d.cts +177 -78
- package/dist/components.d.ts +177 -78
- package/dist/components.js +3 -3
- package/dist/generators-B-fWjDXL.js +328 -0
- package/dist/generators-B-fWjDXL.js.map +1 -0
- package/dist/generators-ByyKDjyt.cjs +339 -0
- package/dist/generators-ByyKDjyt.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +8 -9
- package/dist/generators.d.ts +8 -9
- package/dist/generators.js +4 -4
- package/dist/index.cjs +107 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +107 -130
- package/dist/index.js.map +1 -1
- package/dist/types-CSnGy9Uj.d.ts +1355 -0
- package/dist/types-CjDGkyWH.d.cts +1355 -0
- package/package.json +25 -30
- package/dist/chunk-2N4Q32XH.cjs +0 -285
- package/dist/chunk-2N4Q32XH.cjs.map +0 -1
- package/dist/chunk-GWLPXHRE.js +0 -282
- package/dist/chunk-GWLPXHRE.js.map +0 -1
- package/dist/chunk-MNOTKHSE.cjs +0 -367
- package/dist/chunk-MNOTKHSE.cjs.map +0 -1
- package/dist/chunk-RZTUH4QW.js +0 -361
- package/dist/chunk-RZTUH4QW.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-DVQ2siUx.d.cts +0 -134
- package/dist/types-DVQ2siUx.d.ts +0 -134
package/dist/chunk-GWLPXHRE.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { QueryKey, QueryOptions, Query, MutationKey, Mutation } from './chunk-RZTUH4QW.js';
|
|
2
|
-
import { pluginClientName } from '@kubb/plugin-client';
|
|
3
|
-
import { Client } from '@kubb/plugin-client/components';
|
|
4
|
-
import { createReactGenerator } from '@kubb/plugin-oas';
|
|
5
|
-
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
6
|
-
import { getFooter, getBanner } from '@kubb/plugin-oas/utils';
|
|
7
|
-
import { pluginTsName } from '@kubb/plugin-ts';
|
|
8
|
-
import { pluginZodName } from '@kubb/plugin-zod';
|
|
9
|
-
import { useApp, File } from '@kubb/react';
|
|
10
|
-
import { difference } from 'remeda';
|
|
11
|
-
import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
|
|
12
|
-
|
|
13
|
-
var queryGenerator = createReactGenerator({
|
|
14
|
-
name: "swr-query",
|
|
15
|
-
Operation({ options, operation }) {
|
|
16
|
-
const {
|
|
17
|
-
plugin: {
|
|
18
|
-
options: { output }
|
|
19
|
-
},
|
|
20
|
-
pluginManager
|
|
21
|
-
} = useApp();
|
|
22
|
-
const oas = useOas();
|
|
23
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
24
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
25
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
26
|
-
(method) => operation.method === method
|
|
27
|
-
);
|
|
28
|
-
const importPath = options.query ? options.query.importPath : "swr/mutation";
|
|
29
|
-
const query = {
|
|
30
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
31
|
-
typeName: getName(operation, { type: "type" }),
|
|
32
|
-
file: getFile(operation, { prefix: "use" })
|
|
33
|
-
};
|
|
34
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
35
|
-
const client = {
|
|
36
|
-
name: hasClientPlugin ? getName(operation, {
|
|
37
|
-
type: "function",
|
|
38
|
-
pluginKey: [pluginClientName]
|
|
39
|
-
}) : getName(operation, {
|
|
40
|
-
type: "function"
|
|
41
|
-
}),
|
|
42
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
43
|
-
};
|
|
44
|
-
const queryOptions = {
|
|
45
|
-
name: getName(operation, { type: "function", suffix: "QueryOptions" })
|
|
46
|
-
};
|
|
47
|
-
const queryKey = {
|
|
48
|
-
name: getName(operation, { type: "const", suffix: "QueryKey" }),
|
|
49
|
-
typeName: getName(operation, { type: "type", suffix: "QueryKey" })
|
|
50
|
-
};
|
|
51
|
-
const type = {
|
|
52
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
53
|
-
//todo remove type?
|
|
54
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
55
|
-
};
|
|
56
|
-
const zod = {
|
|
57
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
58
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
59
|
-
};
|
|
60
|
-
if (!isQuery || isMutation) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return /* @__PURE__ */ jsxs(
|
|
64
|
-
File,
|
|
65
|
-
{
|
|
66
|
-
baseName: query.file.baseName,
|
|
67
|
-
path: query.file.path,
|
|
68
|
-
meta: query.file.meta,
|
|
69
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
70
|
-
footer: getFooter({ oas, output }),
|
|
71
|
-
children: [
|
|
72
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
|
|
73
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
74
|
-
!!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
|
|
75
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
76
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
77
|
-
/* @__PURE__ */ jsx(
|
|
78
|
-
File.Import,
|
|
79
|
-
{
|
|
80
|
-
name: [
|
|
81
|
-
type.schemas.request?.name,
|
|
82
|
-
type.schemas.response.name,
|
|
83
|
-
type.schemas.pathParams?.name,
|
|
84
|
-
type.schemas.queryParams?.name,
|
|
85
|
-
type.schemas.headerParams?.name,
|
|
86
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
87
|
-
].filter(Boolean),
|
|
88
|
-
root: query.file.path,
|
|
89
|
-
path: type.file.path,
|
|
90
|
-
isTypeOnly: true
|
|
91
|
-
}
|
|
92
|
-
),
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
QueryKey,
|
|
95
|
-
{
|
|
96
|
-
name: queryKey.name,
|
|
97
|
-
typeName: queryKey.typeName,
|
|
98
|
-
operation,
|
|
99
|
-
pathParamsType: options.pathParamsType,
|
|
100
|
-
typeSchemas: type.schemas,
|
|
101
|
-
paramsCasing: options.paramsCasing,
|
|
102
|
-
transformer: options.queryKey
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
106
|
-
Client,
|
|
107
|
-
{
|
|
108
|
-
name: client.name,
|
|
109
|
-
baseURL: options.client.baseURL,
|
|
110
|
-
operation,
|
|
111
|
-
typeSchemas: type.schemas,
|
|
112
|
-
zodSchemas: zod.schemas,
|
|
113
|
-
dataReturnType: options.client.dataReturnType,
|
|
114
|
-
paramsCasing: options.paramsCasing,
|
|
115
|
-
paramsType: options.paramsType,
|
|
116
|
-
pathParamsType: options.pathParamsType,
|
|
117
|
-
parser: options.parser
|
|
118
|
-
}
|
|
119
|
-
),
|
|
120
|
-
/* @__PURE__ */ jsx(
|
|
121
|
-
QueryOptions,
|
|
122
|
-
{
|
|
123
|
-
name: queryOptions.name,
|
|
124
|
-
clientName: client.name,
|
|
125
|
-
typeSchemas: type.schemas,
|
|
126
|
-
paramsType: options.paramsType,
|
|
127
|
-
paramsCasing: options.paramsCasing,
|
|
128
|
-
pathParamsType: options.pathParamsType
|
|
129
|
-
}
|
|
130
|
-
),
|
|
131
|
-
options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
132
|
-
/* @__PURE__ */ jsx(File.Import, { name: "useSWR", path: importPath }),
|
|
133
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["SWRResponse"], path: importPath, isTypeOnly: true }),
|
|
134
|
-
/* @__PURE__ */ jsx(
|
|
135
|
-
Query,
|
|
136
|
-
{
|
|
137
|
-
name: query.name,
|
|
138
|
-
queryOptionsName: queryOptions.name,
|
|
139
|
-
typeSchemas: type.schemas,
|
|
140
|
-
paramsType: options.paramsType,
|
|
141
|
-
pathParamsType: options.pathParamsType,
|
|
142
|
-
operation,
|
|
143
|
-
dataReturnType: options.client.dataReturnType,
|
|
144
|
-
queryKeyName: queryKey.name,
|
|
145
|
-
paramsCasing: options.paramsCasing,
|
|
146
|
-
queryKeyTypeName: queryKey.typeName
|
|
147
|
-
}
|
|
148
|
-
)
|
|
149
|
-
] })
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
var mutationGenerator = createReactGenerator({
|
|
156
|
-
name: "swr-mutation",
|
|
157
|
-
Operation({ options, operation }) {
|
|
158
|
-
const {
|
|
159
|
-
plugin: {
|
|
160
|
-
options: { output }
|
|
161
|
-
},
|
|
162
|
-
pluginManager
|
|
163
|
-
} = useApp();
|
|
164
|
-
const oas = useOas();
|
|
165
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
166
|
-
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
|
|
167
|
-
const isMutation = !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
168
|
-
const importPath = options.mutation ? options.mutation.importPath : "swr";
|
|
169
|
-
const mutation = {
|
|
170
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
171
|
-
typeName: getName(operation, { type: "type" }),
|
|
172
|
-
file: getFile(operation, { prefix: "use" })
|
|
173
|
-
};
|
|
174
|
-
const type = {
|
|
175
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
176
|
-
//todo remove type?
|
|
177
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
178
|
-
};
|
|
179
|
-
const zod = {
|
|
180
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
181
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
182
|
-
};
|
|
183
|
-
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
|
|
184
|
-
const client = {
|
|
185
|
-
name: hasClientPlugin ? getName(operation, {
|
|
186
|
-
type: "function",
|
|
187
|
-
pluginKey: [pluginClientName]
|
|
188
|
-
}) : getName(operation, {
|
|
189
|
-
type: "function"
|
|
190
|
-
}),
|
|
191
|
-
file: getFile(operation, { pluginKey: [pluginClientName] })
|
|
192
|
-
};
|
|
193
|
-
const mutationKey = {
|
|
194
|
-
name: getName(operation, { type: "const", suffix: "MutationKey" }),
|
|
195
|
-
typeName: getName(operation, { type: "type", suffix: "MutationKey" })
|
|
196
|
-
};
|
|
197
|
-
if (!isMutation) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
return /* @__PURE__ */ jsxs(
|
|
201
|
-
File,
|
|
202
|
-
{
|
|
203
|
-
baseName: mutation.file.baseName,
|
|
204
|
-
path: mutation.file.path,
|
|
205
|
-
meta: mutation.file.meta,
|
|
206
|
-
banner: getBanner({ oas, output, config: pluginManager.config }),
|
|
207
|
-
footer: getFooter({ oas, output }),
|
|
208
|
-
children: [
|
|
209
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: mutation.file.path, path: zod.file.path }),
|
|
210
|
-
/* @__PURE__ */ jsx(File.Import, { name: "useSWRMutation", path: importPath }),
|
|
211
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["SWRMutationResponse"], path: importPath, isTypeOnly: true }),
|
|
212
|
-
/* @__PURE__ */ jsx(File.Import, { name: "fetch", path: options.client.importPath }),
|
|
213
|
-
!!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, { name: [client.name], root: mutation.file.path, path: client.file.path }),
|
|
214
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
215
|
-
/* @__PURE__ */ jsx(
|
|
216
|
-
File.Import,
|
|
217
|
-
{
|
|
218
|
-
name: [
|
|
219
|
-
type.schemas.request?.name,
|
|
220
|
-
type.schemas.response.name,
|
|
221
|
-
type.schemas.pathParams?.name,
|
|
222
|
-
type.schemas.queryParams?.name,
|
|
223
|
-
type.schemas.headerParams?.name,
|
|
224
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
225
|
-
].filter(Boolean),
|
|
226
|
-
root: mutation.file.path,
|
|
227
|
-
path: type.file.path,
|
|
228
|
-
isTypeOnly: true
|
|
229
|
-
}
|
|
230
|
-
),
|
|
231
|
-
/* @__PURE__ */ jsx(
|
|
232
|
-
MutationKey,
|
|
233
|
-
{
|
|
234
|
-
name: mutationKey.name,
|
|
235
|
-
typeName: mutationKey.typeName,
|
|
236
|
-
operation,
|
|
237
|
-
pathParamsType: options.pathParamsType,
|
|
238
|
-
typeSchemas: type.schemas,
|
|
239
|
-
paramsCasing: options.paramsCasing,
|
|
240
|
-
transformer: options.mutationKey
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
!hasClientPlugin && /* @__PURE__ */ jsx(
|
|
244
|
-
Client,
|
|
245
|
-
{
|
|
246
|
-
name: client.name,
|
|
247
|
-
baseURL: options.client.baseURL,
|
|
248
|
-
operation,
|
|
249
|
-
typeSchemas: type.schemas,
|
|
250
|
-
zodSchemas: zod.schemas,
|
|
251
|
-
dataReturnType: options.client.dataReturnType,
|
|
252
|
-
paramsCasing: options.paramsCasing,
|
|
253
|
-
paramsType: options.paramsType,
|
|
254
|
-
pathParamsType: options.pathParamsType,
|
|
255
|
-
parser: options.parser
|
|
256
|
-
}
|
|
257
|
-
),
|
|
258
|
-
options.mutation && /* @__PURE__ */ jsx(
|
|
259
|
-
Mutation,
|
|
260
|
-
{
|
|
261
|
-
name: mutation.name,
|
|
262
|
-
clientName: client.name,
|
|
263
|
-
typeName: mutation.typeName,
|
|
264
|
-
typeSchemas: type.schemas,
|
|
265
|
-
operation,
|
|
266
|
-
dataReturnType: options.client.dataReturnType,
|
|
267
|
-
paramsType: options.paramsType,
|
|
268
|
-
paramsCasing: options.paramsCasing,
|
|
269
|
-
pathParamsType: options.pathParamsType,
|
|
270
|
-
mutationKeyName: mutationKey.name,
|
|
271
|
-
mutationKeyTypeName: mutationKey.typeName
|
|
272
|
-
}
|
|
273
|
-
)
|
|
274
|
-
]
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
export { mutationGenerator, queryGenerator };
|
|
281
|
-
//# sourceMappingURL=chunk-GWLPXHRE.js.map
|
|
282
|
-
//# sourceMappingURL=chunk-GWLPXHRE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","difference","pluginTsName","pluginZodName","pluginClientName","jsxs","File","getBanner","getFooter","jsx","Client"],"mappings":";;;;;;;;;;;;AAaO,IAAM,iBAAiB,oBAAgC,CAAA;AAAA,EAC5D,IAAM,EAAA,WAAA;AAAA,EACN,SAAU,CAAA,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,cACtB,aAAa,OAAQ,CAAA;AAAA;AAAA,WACvB;AAAA,UAEC,CAAC,mCACAA,GAAAA;AAAA,YAACC,MAAAA;AAAA,YAAA;AAAA,cACC,MAAM,MAAO,CAAA,IAAA;AAAA,cACb,OAAA,EAAS,QAAQ,MAAO,CAAA,OAAA;AAAA,cACxB,SAAA;AAAA,cACA,aAAa,IAAK,CAAA,OAAA;AAAA,cAClB,YAAY,GAAI,CAAA,OAAA;AAAA,cAChB,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,cAC/B,cAAc,OAAQ,CAAA,YAAA;AAAA,cACtB,YAAY,OAAQ,CAAA,UAAA;AAAA,cACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,cACxB,QAAQ,OAAQ,CAAA;AAAA;AAAA,WAClB;AAAA,UAED,OAAA,CAAQ,4BACPD,GAAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,MAAM,QAAS,CAAA,IAAA;AAAA,cACf,YAAY,MAAO,CAAA,IAAA;AAAA,cACnB,UAAU,QAAS,CAAA,QAAA;AAAA,cACnB,aAAa,IAAK,CAAA,OAAA;AAAA,cAClB,SAAA;AAAA,cACA,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,cAC/B,YAAY,OAAQ,CAAA,UAAA;AAAA,cACpB,cAAc,OAAQ,CAAA,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-GWLPXHRE.js","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"]}
|