@kubb/plugin-vue-query 5.0.0-alpha.8 → 5.0.0-beta.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 (46) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +1 -3
  3. package/dist/components-D1UhYFgY.js +1277 -0
  4. package/dist/components-D1UhYFgY.js.map +1 -0
  5. package/dist/components-qfOFRSoM.cjs +1367 -0
  6. package/dist/components-qfOFRSoM.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +118 -109
  9. package/dist/components.js +1 -1
  10. package/dist/generators-C4gs_P1i.cjs +726 -0
  11. package/dist/generators-C4gs_P1i.cjs.map +1 -0
  12. package/dist/generators-CbnIVBgY.js +709 -0
  13. package/dist/generators-CbnIVBgY.js.map +1 -0
  14. package/dist/generators.cjs +1 -1
  15. package/dist/generators.d.ts +5 -472
  16. package/dist/generators.js +1 -1
  17. package/dist/index.cjs +106 -121
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +102 -121
  21. package/dist/index.js.map +1 -1
  22. package/dist/types-nVDTfuS1.d.ts +194 -0
  23. package/package.json +61 -64
  24. package/src/components/InfiniteQuery.tsx +104 -153
  25. package/src/components/InfiniteQueryOptions.tsx +122 -162
  26. package/src/components/Mutation.tsx +110 -136
  27. package/src/components/Query.tsx +102 -151
  28. package/src/components/QueryKey.tsx +68 -58
  29. package/src/components/QueryOptions.tsx +147 -139
  30. package/src/generators/infiniteQueryGenerator.tsx +165 -170
  31. package/src/generators/mutationGenerator.tsx +117 -124
  32. package/src/generators/queryGenerator.tsx +138 -136
  33. package/src/index.ts +1 -1
  34. package/src/plugin.ts +124 -175
  35. package/src/resolvers/resolverVueQuery.ts +19 -0
  36. package/src/types.ts +68 -48
  37. package/src/utils.ts +37 -0
  38. package/dist/components-Yjoe78Y7.cjs +0 -1119
  39. package/dist/components-Yjoe78Y7.cjs.map +0 -1
  40. package/dist/components-_AMBl0g-.js +0 -1029
  41. package/dist/components-_AMBl0g-.js.map +0 -1
  42. package/dist/generators-CR34GjVu.js +0 -661
  43. package/dist/generators-CR34GjVu.js.map +0 -1
  44. package/dist/generators-DH8VkK1q.cjs +0 -678
  45. package/dist/generators-DH8VkK1q.cjs.map +0 -1
  46. package/dist/types-CgDFUvfZ.d.ts +0 -211
@@ -1,678 +0,0 @@
1
- const require_components = require("./components-Yjoe78Y7.cjs");
2
- let node_path = require("node:path");
3
- node_path = require_components.__toESM(node_path);
4
- let _kubb_plugin_client = require("@kubb/plugin-client");
5
- let _kubb_plugin_ts = require("@kubb/plugin-ts");
6
- let _kubb_plugin_zod = require("@kubb/plugin-zod");
7
- let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
8
- let _kubb_react_fabric = require("@kubb/react-fabric");
9
- let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
10
- let _kubb_plugin_client_components = require("@kubb/plugin-client/components");
11
- let _kubb_core_hooks = require("@kubb/core/hooks");
12
- let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
13
- let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
14
- let remeda = require("remeda");
15
- //#region src/generators/infiniteQueryGenerator.tsx
16
- const infiniteQueryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
17
- name: "vue-infinite-query",
18
- Operation({ config, operation, generator, plugin }) {
19
- const { options, options: { output } } = plugin;
20
- const driver = (0, _kubb_core_hooks.usePluginDriver)();
21
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
22
- const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
23
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
24
- const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
25
- const isInfinite = isQuery && !!options.infinite;
26
- const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
27
- const query = {
28
- name: getName(operation, {
29
- type: "function",
30
- prefix: "use",
31
- suffix: "infinite"
32
- }),
33
- typeName: getName(operation, { type: "type" }),
34
- file: getFile(operation, {
35
- prefix: "use",
36
- suffix: "infinite"
37
- })
38
- };
39
- const shouldUseClientPlugin = !!driver.getPluginByName(_kubb_plugin_client.pluginClientName) && options.client.clientType !== "class";
40
- const client = {
41
- name: shouldUseClientPlugin ? getName(operation, {
42
- type: "function",
43
- pluginName: _kubb_plugin_client.pluginClientName
44
- }) : getName(operation, {
45
- type: "function",
46
- suffix: "infinite"
47
- }),
48
- file: getFile(operation, { pluginName: _kubb_plugin_client.pluginClientName })
49
- };
50
- const queryOptions = { name: getName(operation, {
51
- type: "function",
52
- suffix: "InfiniteQueryOptions"
53
- }) };
54
- const queryKey = {
55
- name: getName(operation, {
56
- type: "const",
57
- suffix: "InfiniteQueryKey"
58
- }),
59
- typeName: getName(operation, {
60
- type: "type",
61
- suffix: "InfiniteQueryKey"
62
- })
63
- };
64
- const type = {
65
- file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
66
- schemas: getSchemas(operation, {
67
- pluginName: _kubb_plugin_ts.pluginTsName,
68
- type: "type"
69
- })
70
- };
71
- const zod = {
72
- file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName }),
73
- schemas: getSchemas(operation, {
74
- pluginName: _kubb_plugin_zod.pluginZodName,
75
- type: "function"
76
- })
77
- };
78
- if (!isQuery || isMutation || !isInfinite) return null;
79
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
80
- baseName: query.file.baseName,
81
- path: query.file.path,
82
- meta: query.file.meta,
83
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
84
- oas,
85
- output,
86
- config: driver.config
87
- }),
88
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
89
- oas,
90
- output
91
- }),
92
- children: [
93
- options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
94
- name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
95
- root: query.file.path,
96
- path: zod.file.path
97
- }),
98
- options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
99
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
100
- name: "fetch",
101
- path: options.client.importPath
102
- }),
103
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
104
- name: [
105
- "Client",
106
- "RequestConfig",
107
- "ResponseErrorConfig"
108
- ],
109
- path: options.client.importPath,
110
- isTypeOnly: true
111
- }),
112
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
113
- name: ["ResponseConfig"],
114
- path: options.client.importPath,
115
- isTypeOnly: true
116
- })
117
- ] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
118
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
119
- name: ["fetch"],
120
- root: query.file.path,
121
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
122
- }),
123
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
124
- name: [
125
- "Client",
126
- "RequestConfig",
127
- "ResponseErrorConfig"
128
- ],
129
- root: query.file.path,
130
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
131
- isTypeOnly: true
132
- }),
133
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
134
- name: ["ResponseConfig"],
135
- root: query.file.path,
136
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
137
- isTypeOnly: true
138
- })
139
- ] }),
140
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
141
- name: ["toValue"],
142
- path: "vue"
143
- }),
144
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
145
- name: ["MaybeRefOrGetter"],
146
- path: "vue",
147
- isTypeOnly: true
148
- }),
149
- shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
150
- name: [client.name],
151
- root: query.file.path,
152
- path: client.file.path
153
- }),
154
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
155
- name: ["buildFormData"],
156
- root: query.file.path,
157
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
158
- }),
159
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
160
- name: [
161
- type.schemas.request?.name,
162
- type.schemas.response.name,
163
- type.schemas.pathParams?.name,
164
- type.schemas.queryParams?.name,
165
- type.schemas.headerParams?.name,
166
- ...type.schemas.statusCodes?.map((item) => item.name) || []
167
- ].filter(Boolean),
168
- root: query.file.path,
169
- path: type.file.path,
170
- isTypeOnly: true
171
- }),
172
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
173
- name: queryKey.name,
174
- typeName: queryKey.typeName,
175
- operation,
176
- paramsCasing: options.paramsCasing,
177
- pathParamsType: options.pathParamsType,
178
- typeSchemas: type.schemas,
179
- transformer: options.queryKey
180
- }),
181
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
182
- name: client.name,
183
- baseURL: options.client.baseURL,
184
- operation,
185
- typeSchemas: type.schemas,
186
- zodSchemas: zod.schemas,
187
- dataReturnType: options.client.dataReturnType || "data",
188
- paramsCasing: options.client?.paramsCasing || options.paramsCasing,
189
- paramsType: options.paramsType,
190
- pathParamsType: options.pathParamsType,
191
- parser: options.parser
192
- }),
193
- options.infinite && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
194
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
195
- name: ["InfiniteData"],
196
- isTypeOnly: true,
197
- path: importPath
198
- }),
199
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
200
- name: ["infiniteQueryOptions"],
201
- path: importPath
202
- }),
203
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQueryOptions, {
204
- name: queryOptions.name,
205
- clientName: client.name,
206
- queryKeyName: queryKey.name,
207
- typeSchemas: type.schemas,
208
- paramsType: options.paramsType,
209
- paramsCasing: options.paramsCasing,
210
- pathParamsType: options.pathParamsType,
211
- dataReturnType: options.client.dataReturnType || "data",
212
- cursorParam: options.infinite.cursorParam,
213
- nextParam: options.infinite.nextParam,
214
- previousParam: options.infinite.previousParam,
215
- initialPageParam: options.infinite.initialPageParam,
216
- queryParam: options.infinite.queryParam
217
- })
218
- ] }),
219
- options.infinite && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
220
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
221
- name: ["useInfiniteQuery"],
222
- path: importPath
223
- }),
224
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
225
- name: [
226
- "QueryKey",
227
- "QueryClient",
228
- "UseInfiniteQueryOptions",
229
- "UseInfiniteQueryReturnType"
230
- ],
231
- path: importPath,
232
- isTypeOnly: true
233
- }),
234
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQuery, {
235
- name: query.name,
236
- queryOptionsName: queryOptions.name,
237
- typeSchemas: type.schemas,
238
- paramsCasing: options.paramsCasing,
239
- paramsType: options.paramsType,
240
- pathParamsType: options.pathParamsType,
241
- operation,
242
- dataReturnType: options.client.dataReturnType || "data",
243
- queryKeyName: queryKey.name,
244
- queryKeyTypeName: queryKey.typeName
245
- })
246
- ] })
247
- ]
248
- });
249
- }
250
- });
251
- //#endregion
252
- //#region src/generators/mutationGenerator.tsx
253
- const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
254
- name: "vue-query",
255
- Operation({ config, operation, generator, plugin }) {
256
- const { options, options: { output } } = plugin;
257
- const driver = (0, _kubb_core_hooks.usePluginDriver)();
258
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
259
- const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
260
- const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
261
- const isMutation = options.mutation !== false && !isQuery && (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
262
- const importPath = options.mutation ? options.mutation.importPath : "@tanstack/vue-query";
263
- const mutation = {
264
- name: getName(operation, {
265
- type: "function",
266
- prefix: "use"
267
- }),
268
- typeName: getName(operation, { type: "type" }),
269
- file: getFile(operation, { prefix: "use" })
270
- };
271
- const type = {
272
- file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
273
- schemas: getSchemas(operation, {
274
- pluginName: _kubb_plugin_ts.pluginTsName,
275
- type: "type"
276
- })
277
- };
278
- const zod = {
279
- file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName }),
280
- schemas: getSchemas(operation, {
281
- pluginName: _kubb_plugin_zod.pluginZodName,
282
- type: "function"
283
- })
284
- };
285
- const shouldUseClientPlugin = !!driver.getPluginByName(_kubb_plugin_client.pluginClientName) && options.client.clientType !== "class";
286
- const client = {
287
- name: shouldUseClientPlugin ? getName(operation, {
288
- type: "function",
289
- pluginName: _kubb_plugin_client.pluginClientName
290
- }) : getName(operation, { type: "function" }),
291
- file: getFile(operation, { pluginName: _kubb_plugin_client.pluginClientName })
292
- };
293
- const mutationKey = {
294
- name: getName(operation, {
295
- type: "const",
296
- suffix: "MutationKey"
297
- }),
298
- typeName: getName(operation, {
299
- type: "type",
300
- suffix: "MutationKey"
301
- })
302
- };
303
- if (!isMutation) return null;
304
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
305
- baseName: mutation.file.baseName,
306
- path: mutation.file.path,
307
- meta: mutation.file.meta,
308
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
309
- oas,
310
- output,
311
- config: driver.config
312
- }),
313
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
314
- oas,
315
- output
316
- }),
317
- children: [
318
- options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
319
- name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
320
- root: mutation.file.path,
321
- path: zod.file.path
322
- }),
323
- options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
324
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
325
- name: "fetch",
326
- path: options.client.importPath
327
- }),
328
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
329
- name: [
330
- "Client",
331
- "RequestConfig",
332
- "ResponseErrorConfig"
333
- ],
334
- path: options.client.importPath,
335
- isTypeOnly: true
336
- }),
337
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
338
- name: ["ResponseConfig"],
339
- path: options.client.importPath,
340
- isTypeOnly: true
341
- })
342
- ] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
343
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
344
- name: ["fetch"],
345
- root: mutation.file.path,
346
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
347
- }),
348
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
349
- name: [
350
- "Client",
351
- "RequestConfig",
352
- "ResponseErrorConfig"
353
- ],
354
- root: mutation.file.path,
355
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
356
- isTypeOnly: true
357
- }),
358
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
359
- name: ["ResponseConfig"],
360
- root: mutation.file.path,
361
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
362
- isTypeOnly: true
363
- })
364
- ] }),
365
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
366
- name: ["MaybeRefOrGetter"],
367
- path: "vue",
368
- isTypeOnly: true
369
- }),
370
- shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
371
- name: [client.name],
372
- root: mutation.file.path,
373
- path: client.file.path
374
- }),
375
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
376
- name: ["buildFormData"],
377
- root: mutation.file.path,
378
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
379
- }),
380
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
381
- name: [
382
- type.schemas.request?.name,
383
- type.schemas.response.name,
384
- type.schemas.pathParams?.name,
385
- type.schemas.queryParams?.name,
386
- type.schemas.headerParams?.name,
387
- ...type.schemas.statusCodes?.map((item) => item.name) || []
388
- ].filter(Boolean),
389
- root: mutation.file.path,
390
- path: type.file.path,
391
- isTypeOnly: true
392
- }),
393
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.MutationKey, {
394
- name: mutationKey.name,
395
- typeName: mutationKey.typeName,
396
- operation,
397
- pathParamsType: options.pathParamsType,
398
- paramsCasing: options.paramsCasing,
399
- typeSchemas: type.schemas,
400
- transformer: options.mutationKey
401
- }),
402
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
403
- name: client.name,
404
- baseURL: options.client.baseURL,
405
- operation,
406
- typeSchemas: type.schemas,
407
- zodSchemas: zod.schemas,
408
- dataReturnType: options.client.dataReturnType || "data",
409
- paramsCasing: options.client?.paramsCasing || options.paramsCasing,
410
- paramsType: options.paramsType,
411
- pathParamsType: options.pathParamsType,
412
- parser: options.parser
413
- }),
414
- options.mutation && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
415
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
416
- name: ["useMutation"],
417
- path: importPath
418
- }),
419
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
420
- name: ["MutationObserverOptions", "QueryClient"],
421
- path: importPath,
422
- isTypeOnly: true
423
- }),
424
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Mutation, {
425
- name: mutation.name,
426
- clientName: client.name,
427
- typeName: mutation.typeName,
428
- typeSchemas: type.schemas,
429
- operation,
430
- paramsCasing: options.paramsCasing,
431
- dataReturnType: options.client.dataReturnType || "data",
432
- paramsType: options.paramsType,
433
- pathParamsType: options.pathParamsType,
434
- mutationKeyName: mutationKey.name
435
- })
436
- ] })
437
- ]
438
- });
439
- }
440
- });
441
- //#endregion
442
- //#region src/generators/queryGenerator.tsx
443
- const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
444
- name: "vue-query",
445
- Operation({ config, operation, generator, plugin }) {
446
- const { options, options: { output } } = plugin;
447
- const driver = (0, _kubb_core_hooks.usePluginDriver)();
448
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
449
- const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
450
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
451
- const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
452
- const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
453
- const query = {
454
- name: getName(operation, {
455
- type: "function",
456
- prefix: "use"
457
- }),
458
- typeName: getName(operation, { type: "type" }),
459
- file: getFile(operation, { prefix: "use" })
460
- };
461
- const shouldUseClientPlugin = !!driver.getPluginByName(_kubb_plugin_client.pluginClientName) && options.client.clientType !== "class";
462
- const client = {
463
- name: shouldUseClientPlugin ? getName(operation, {
464
- type: "function",
465
- pluginName: _kubb_plugin_client.pluginClientName
466
- }) : getName(operation, { type: "function" }),
467
- file: getFile(operation, { pluginName: _kubb_plugin_client.pluginClientName })
468
- };
469
- const queryOptions = { name: getName(operation, {
470
- type: "function",
471
- suffix: "QueryOptions"
472
- }) };
473
- const queryKey = {
474
- name: getName(operation, {
475
- type: "const",
476
- suffix: "QueryKey"
477
- }),
478
- typeName: getName(operation, {
479
- type: "type",
480
- suffix: "QueryKey"
481
- })
482
- };
483
- const type = {
484
- file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
485
- schemas: getSchemas(operation, {
486
- pluginName: _kubb_plugin_ts.pluginTsName,
487
- type: "type"
488
- })
489
- };
490
- const zod = {
491
- file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName }),
492
- schemas: getSchemas(operation, {
493
- pluginName: _kubb_plugin_zod.pluginZodName,
494
- type: "function"
495
- })
496
- };
497
- if (!isQuery || isMutation) return null;
498
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
499
- baseName: query.file.baseName,
500
- path: query.file.path,
501
- meta: query.file.meta,
502
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
503
- oas,
504
- output,
505
- config: driver.config
506
- }),
507
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
508
- oas,
509
- output
510
- }),
511
- children: [
512
- options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
513
- name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
514
- root: query.file.path,
515
- path: zod.file.path
516
- }),
517
- options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
518
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
519
- name: "fetch",
520
- path: options.client.importPath
521
- }),
522
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
523
- name: [
524
- "Client",
525
- "RequestConfig",
526
- "ResponseErrorConfig"
527
- ],
528
- path: options.client.importPath,
529
- isTypeOnly: true
530
- }),
531
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
532
- name: ["ResponseConfig"],
533
- path: options.client.importPath,
534
- isTypeOnly: true
535
- })
536
- ] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
537
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
538
- name: ["fetch"],
539
- root: query.file.path,
540
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
541
- }),
542
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
543
- name: [
544
- "Client",
545
- "RequestConfig",
546
- "ResponseErrorConfig"
547
- ],
548
- root: query.file.path,
549
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
550
- isTypeOnly: true
551
- }),
552
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
553
- name: ["ResponseConfig"],
554
- root: query.file.path,
555
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
556
- isTypeOnly: true
557
- })
558
- ] }),
559
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
560
- name: ["toValue"],
561
- path: "vue"
562
- }),
563
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
564
- name: ["MaybeRefOrGetter"],
565
- path: "vue",
566
- isTypeOnly: true
567
- }),
568
- shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
569
- name: [client.name],
570
- root: query.file.path,
571
- path: client.file.path
572
- }),
573
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
574
- name: ["buildFormData"],
575
- root: query.file.path,
576
- path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
577
- }),
578
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
579
- name: [
580
- type.schemas.request?.name,
581
- type.schemas.response.name,
582
- type.schemas.pathParams?.name,
583
- type.schemas.queryParams?.name,
584
- type.schemas.headerParams?.name,
585
- ...type.schemas.statusCodes?.map((item) => item.name) || []
586
- ].filter(Boolean),
587
- root: query.file.path,
588
- path: type.file.path,
589
- isTypeOnly: true
590
- }),
591
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
592
- name: queryKey.name,
593
- typeName: queryKey.typeName,
594
- operation,
595
- paramsCasing: options.paramsCasing,
596
- pathParamsType: options.pathParamsType,
597
- typeSchemas: type.schemas,
598
- transformer: options.queryKey
599
- }),
600
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
601
- name: client.name,
602
- baseURL: options.client.baseURL,
603
- operation,
604
- typeSchemas: type.schemas,
605
- zodSchemas: zod.schemas,
606
- dataReturnType: options.client.dataReturnType || "data",
607
- paramsCasing: options.client?.paramsCasing || options.paramsCasing,
608
- paramsType: options.paramsType,
609
- pathParamsType: options.pathParamsType,
610
- parser: options.parser
611
- }),
612
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
613
- name: ["queryOptions"],
614
- path: importPath
615
- }),
616
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
617
- name: queryOptions.name,
618
- clientName: client.name,
619
- queryKeyName: queryKey.name,
620
- paramsCasing: options.paramsCasing,
621
- typeSchemas: type.schemas,
622
- paramsType: options.paramsType,
623
- pathParamsType: options.pathParamsType,
624
- dataReturnType: options.client.dataReturnType || "data"
625
- }),
626
- options.query && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
627
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
628
- name: ["useQuery"],
629
- path: importPath
630
- }),
631
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
632
- name: [
633
- "QueryKey",
634
- "QueryClient",
635
- "UseQueryOptions",
636
- "UseQueryReturnType"
637
- ],
638
- path: importPath,
639
- isTypeOnly: true
640
- }),
641
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Query, {
642
- name: query.name,
643
- queryOptionsName: queryOptions.name,
644
- typeSchemas: type.schemas,
645
- paramsCasing: options.paramsCasing,
646
- paramsType: options.paramsType,
647
- pathParamsType: options.pathParamsType,
648
- operation,
649
- dataReturnType: options.client.dataReturnType || "data",
650
- queryKeyName: queryKey.name,
651
- queryKeyTypeName: queryKey.typeName
652
- })
653
- ] })
654
- ]
655
- });
656
- }
657
- });
658
- //#endregion
659
- Object.defineProperty(exports, "infiniteQueryGenerator", {
660
- enumerable: true,
661
- get: function() {
662
- return infiniteQueryGenerator;
663
- }
664
- });
665
- Object.defineProperty(exports, "mutationGenerator", {
666
- enumerable: true,
667
- get: function() {
668
- return mutationGenerator;
669
- }
670
- });
671
- Object.defineProperty(exports, "queryGenerator", {
672
- enumerable: true,
673
- get: function() {
674
- return queryGenerator;
675
- }
676
- });
677
-
678
- //# sourceMappingURL=generators-DH8VkK1q.cjs.map