@kubb/plugin-vue-query 0.0.0-canary-20241104172400

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-A7SD37VK.cjs +584 -0
  4. package/dist/chunk-A7SD37VK.cjs.map +1 -0
  5. package/dist/chunk-DHJLKFYS.js +827 -0
  6. package/dist/chunk-DHJLKFYS.js.map +1 -0
  7. package/dist/chunk-J4RZRRHQ.cjs +837 -0
  8. package/dist/chunk-J4RZRRHQ.cjs.map +1 -0
  9. package/dist/chunk-O4EGNKUX.js +576 -0
  10. package/dist/chunk-O4EGNKUX.js.map +1 -0
  11. package/dist/components.cjs +36 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +150 -0
  14. package/dist/components.d.ts +150 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +21 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +12 -0
  20. package/dist/generators.d.ts +12 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +134 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +127 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-C8LfCZUP.d.cts +389 -0
  30. package/dist/types-C8LfCZUP.d.ts +389 -0
  31. package/package.json +102 -0
  32. package/src/components/InfiniteQuery.tsx +190 -0
  33. package/src/components/InfiniteQueryOptions.tsx +185 -0
  34. package/src/components/Mutation.tsx +167 -0
  35. package/src/components/MutationKey.tsx +54 -0
  36. package/src/components/Query.tsx +191 -0
  37. package/src/components/QueryKey.tsx +91 -0
  38. package/src/components/QueryOptions.tsx +152 -0
  39. package/src/components/index.ts +7 -0
  40. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +53 -0
  41. package/src/generators/__snapshots__/clientGetImportPath.ts +53 -0
  42. package/src/generators/__snapshots__/clientPostImportPath.ts +45 -0
  43. package/src/generators/__snapshots__/findByTags.ts +53 -0
  44. package/src/generators/__snapshots__/findByTagsObject.ts +62 -0
  45. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +53 -0
  46. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +53 -0
  47. package/src/generators/__snapshots__/findByTagsWithZod.ts +53 -0
  48. package/src/generators/__snapshots__/findInfiniteByTags.ts +58 -0
  49. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +58 -0
  50. package/src/generators/__snapshots__/postAsQuery.ts +52 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +45 -0
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +45 -0
  53. package/src/generators/index.ts +3 -0
  54. package/src/generators/infiniteQueryGenerator.tsx +137 -0
  55. package/src/generators/mutationGenerator.tsx +116 -0
  56. package/src/generators/queryGenerator.tsx +129 -0
  57. package/src/index.ts +2 -0
  58. package/src/plugin.ts +149 -0
  59. package/src/types.ts +159 -0
@@ -0,0 +1,584 @@
1
+ 'use strict';
2
+
3
+ var chunkJ4RZRRHQ_cjs = require('./chunk-J4RZRRHQ.cjs');
4
+ var path = require('path');
5
+ var core = require('@kubb/core');
6
+ var transformers = require('@kubb/core/transformers');
7
+ var pluginOas = require('@kubb/plugin-oas');
8
+ var pluginZod = require('@kubb/plugin-zod');
9
+ var hooks = require('@kubb/plugin-oas/hooks');
10
+ var pluginTs = require('@kubb/plugin-ts');
11
+ var react = require('@kubb/react');
12
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
+
16
+ var path__default = /*#__PURE__*/_interopDefault(path);
17
+
18
+ var clientGenerator = pluginOas.createReactGenerator({
19
+ name: "client",
20
+ Operation({ options, operation }) {
21
+ const {
22
+ plugin: {
23
+ options: { output }
24
+ }
25
+ } = react.useApp();
26
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
27
+ const client = {
28
+ name: getName(operation, { type: "function" }),
29
+ file: getFile(operation)
30
+ };
31
+ const type = {
32
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
33
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
34
+ };
35
+ const zod = {
36
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
37
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
38
+ };
39
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, banner: output?.banner, footer: output?.footer, children: [
40
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.importPath }),
41
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.importPath, isTypeOnly: true }),
42
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
43
+ /* @__PURE__ */ jsxRuntime.jsx(
44
+ react.File.Import,
45
+ {
46
+ name: [
47
+ type.schemas.request?.name,
48
+ type.schemas.response.name,
49
+ type.schemas.pathParams?.name,
50
+ type.schemas.queryParams?.name,
51
+ type.schemas.headerParams?.name,
52
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
53
+ ].filter(Boolean),
54
+ root: client.file.path,
55
+ path: type.file.path,
56
+ isTypeOnly: true
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxRuntime.jsx(
60
+ chunkJ4RZRRHQ_cjs.Client,
61
+ {
62
+ name: client.name,
63
+ baseURL: options.baseURL,
64
+ dataReturnType: options.dataReturnType,
65
+ pathParamsType: options.pathParamsType,
66
+ paramsType: options.paramsType,
67
+ typeSchemas: type.schemas,
68
+ operation,
69
+ parser: options.parser,
70
+ zodSchemas: zod.schemas
71
+ }
72
+ )
73
+ ] });
74
+ }
75
+ });
76
+ var operationsGenerator = pluginOas.createReactGenerator({
77
+ name: "client",
78
+ Operations({ operations }) {
79
+ const {
80
+ pluginManager,
81
+ plugin: {
82
+ options: { output }
83
+ }
84
+ } = react.useApp();
85
+ const name = "operations";
86
+ const file = pluginManager.getFile({ name, extname: ".ts", pluginKey: [pluginClientName] });
87
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsxRuntime.jsx(chunkJ4RZRRHQ_cjs.Operations, { name, operations }) });
88
+ }
89
+ });
90
+ var groupedClientGenerator = pluginOas.createReactGenerator({
91
+ name: "groupedClient",
92
+ Operations({ operations }) {
93
+ const {
94
+ pluginManager,
95
+ plugin: { options }
96
+ } = react.useApp();
97
+ const { getName, getFile } = hooks.useOperationManager();
98
+ const controllers = operations.reduce(
99
+ (acc, operation) => {
100
+ if (options.group?.type === "tag") {
101
+ const tag = operation.getTags().at(0)?.name;
102
+ const name = tag ? options.group?.name?.({ group: transformers.camelCase(tag) }) : void 0;
103
+ if (!tag || !name) {
104
+ return acc;
105
+ }
106
+ const file = pluginManager.getFile({
107
+ name,
108
+ extname: ".ts",
109
+ pluginKey: [pluginClientName],
110
+ options: { tag }
111
+ });
112
+ const client = {
113
+ name: getName(operation, { type: "function" }),
114
+ file: getFile(operation)
115
+ };
116
+ const previousFile = acc.find((item) => item.file.path === file.path);
117
+ if (previousFile) {
118
+ previousFile.clients.push(client);
119
+ } else {
120
+ acc.push({ name, file, clients: [client] });
121
+ }
122
+ }
123
+ return acc;
124
+ },
125
+ []
126
+ );
127
+ return controllers.map(({ name, file, clients }) => {
128
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: options.output?.banner, footer: options.output?.footer, children: [
129
+ clients.map((client) => /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: file.path, path: client.file.path }, client.name)),
130
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { export: true, name, children: `return { ${clients.map((client) => client.name).join(", ")} }` }) })
131
+ ] }, file.path);
132
+ });
133
+ }
134
+ });
135
+
136
+ // ../plugin-client/src/plugin.ts
137
+ var pluginClientName = "plugin-client";
138
+ core.createPlugin((options) => {
139
+ const {
140
+ output = { path: "clients", barrelType: "named" },
141
+ group,
142
+ exclude = [],
143
+ include,
144
+ override = [],
145
+ transformers: transformers$1 = {},
146
+ dataReturnType = "data",
147
+ pathParamsType = "inline",
148
+ paramsType = "inline",
149
+ operations = false,
150
+ baseURL,
151
+ generators = [clientGenerator, group ? groupedClientGenerator : void 0, operations ? operationsGenerator : void 0].filter(Boolean),
152
+ importPath = "@kubb/plugin-client/client",
153
+ parser = "client"
154
+ } = options;
155
+ return {
156
+ name: pluginClientName,
157
+ options: {
158
+ output,
159
+ group,
160
+ parser,
161
+ dataReturnType,
162
+ importPath,
163
+ paramsType,
164
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType,
165
+ baseURL
166
+ },
167
+ pre: [pluginOas.pluginOasName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
168
+ resolvePath(baseName, pathMode, options2) {
169
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
170
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
171
+ if (options2?.tag && group?.type === "tag") {
172
+ const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
173
+ return path__default.default.resolve(root, output.path, groupName({ group: transformers.camelCase(options2.tag) }), baseName);
174
+ }
175
+ if (mode === "single") {
176
+ return path__default.default.resolve(root, output.path);
177
+ }
178
+ return path__default.default.resolve(root, output.path, baseName);
179
+ },
180
+ resolveName(name, type) {
181
+ const resolvedName = transformers.camelCase(name, { isFile: type === "file" });
182
+ if (type) {
183
+ return transformers$1?.name?.(resolvedName, type) || resolvedName;
184
+ }
185
+ return resolvedName;
186
+ },
187
+ async buildStart() {
188
+ const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
189
+ const oas = await swaggerPlugin.context.getOas();
190
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
191
+ const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
192
+ const baseURL2 = await swaggerPlugin.context.getBaseURL();
193
+ const operationGenerator = new pluginOas.OperationGenerator(
194
+ baseURL2 ? {
195
+ ...this.plugin.options,
196
+ baseURL: baseURL2
197
+ } : this.plugin.options,
198
+ {
199
+ oas,
200
+ pluginManager: this.pluginManager,
201
+ plugin: this.plugin,
202
+ contentType: swaggerPlugin.context.contentType,
203
+ exclude,
204
+ include,
205
+ override,
206
+ mode
207
+ }
208
+ );
209
+ const files = await operationGenerator.build(...generators);
210
+ await this.addFile(...files);
211
+ const barrelFiles = await this.fileManager.getBarrelFiles({
212
+ type: output.barrelType ?? "named",
213
+ root,
214
+ output,
215
+ files: this.fileManager.files,
216
+ meta: {
217
+ pluginKey: this.plugin.key
218
+ },
219
+ logger: this.logger
220
+ });
221
+ await this.addFile(...barrelFiles);
222
+ }
223
+ };
224
+ });
225
+ var queryGenerator = pluginOas.createReactGenerator({
226
+ name: "vue-query",
227
+ Operation({ options, operation }) {
228
+ const {
229
+ plugin: {
230
+ options: { output }
231
+ }
232
+ } = react.useApp();
233
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
234
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
235
+ const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
236
+ const query = {
237
+ name: getName(operation, { type: "function", prefix: "use" }),
238
+ typeName: getName(operation, { type: "type" }),
239
+ file: getFile(operation, { prefix: "use" })
240
+ };
241
+ const client = {
242
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
243
+ };
244
+ const queryOptions = {
245
+ name: getName(operation, { type: "function", suffix: "QueryOptions" })
246
+ };
247
+ const queryKey = {
248
+ name: getName(operation, { type: "const", suffix: "QueryKey" }),
249
+ typeName: getName(operation, { type: "type", suffix: "QueryKey" })
250
+ };
251
+ const type = {
252
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
253
+ //todo remove type?
254
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
255
+ };
256
+ const zod = {
257
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
258
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
259
+ };
260
+ if (!isQuery) {
261
+ return null;
262
+ }
263
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
264
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
265
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["unref"], path: "vue" }),
266
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
267
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
268
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
269
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
270
+ /* @__PURE__ */ jsxRuntime.jsx(
271
+ react.File.Import,
272
+ {
273
+ name: [
274
+ type.schemas.request?.name,
275
+ type.schemas.response.name,
276
+ type.schemas.pathParams?.name,
277
+ type.schemas.queryParams?.name,
278
+ type.schemas.headerParams?.name,
279
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
280
+ ].filter(Boolean),
281
+ root: query.file.path,
282
+ path: type.file.path,
283
+ isTypeOnly: true
284
+ }
285
+ ),
286
+ /* @__PURE__ */ jsxRuntime.jsx(
287
+ chunkJ4RZRRHQ_cjs.QueryKey,
288
+ {
289
+ name: queryKey.name,
290
+ typeName: queryKey.typeName,
291
+ operation,
292
+ pathParamsType: options.pathParamsType,
293
+ typeSchemas: type.schemas,
294
+ transformer: options.queryKey
295
+ }
296
+ ),
297
+ /* @__PURE__ */ jsxRuntime.jsx(
298
+ chunkJ4RZRRHQ_cjs.Client,
299
+ {
300
+ name: client.name,
301
+ isExportable: false,
302
+ isIndexable: false,
303
+ baseURL: options.client.baseURL,
304
+ operation,
305
+ typeSchemas: type.schemas,
306
+ zodSchemas: zod.schemas,
307
+ dataReturnType: options.client.dataReturnType,
308
+ paramsType: options.paramsType,
309
+ pathParamsType: options.pathParamsType,
310
+ parser: options.parser
311
+ }
312
+ ),
313
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
314
+ /* @__PURE__ */ jsxRuntime.jsx(
315
+ chunkJ4RZRRHQ_cjs.QueryOptions,
316
+ {
317
+ name: queryOptions.name,
318
+ clientName: client.name,
319
+ queryKeyName: queryKey.name,
320
+ typeSchemas: type.schemas,
321
+ paramsType: options.paramsType,
322
+ pathParamsType: options.pathParamsType
323
+ }
324
+ ),
325
+ options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
326
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useQuery"], path: importPath }),
327
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryObserverOptions", "UseQueryReturnType"], path: importPath, isTypeOnly: true }),
328
+ /* @__PURE__ */ jsxRuntime.jsx(
329
+ chunkJ4RZRRHQ_cjs.Query,
330
+ {
331
+ name: query.name,
332
+ queryOptionsName: queryOptions.name,
333
+ typeSchemas: type.schemas,
334
+ paramsType: options.paramsType,
335
+ pathParamsType: options.pathParamsType,
336
+ operation,
337
+ dataReturnType: options.client.dataReturnType,
338
+ queryKeyName: queryKey.name,
339
+ queryKeyTypeName: queryKey.typeName
340
+ }
341
+ )
342
+ ] })
343
+ ] });
344
+ }
345
+ });
346
+ var mutationGenerator = pluginOas.createReactGenerator({
347
+ name: "vue-query",
348
+ Operation({ options, operation }) {
349
+ const {
350
+ plugin: {
351
+ options: { output }
352
+ }
353
+ } = react.useApp();
354
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
355
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
356
+ const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
357
+ const importPath = options.mutation ? options.mutation.importPath : "@tanstack/vue-query";
358
+ const mutation = {
359
+ name: getName(operation, { type: "function", prefix: "use" }),
360
+ typeName: getName(operation, { type: "type" }),
361
+ file: getFile(operation, { prefix: "use" })
362
+ };
363
+ const type = {
364
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
365
+ //todo remove type?
366
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
367
+ };
368
+ const zod = {
369
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
370
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
371
+ };
372
+ const client = {
373
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
374
+ };
375
+ const mutationKey = {
376
+ name: getName(operation, { type: "const", suffix: "MutationKey" }),
377
+ typeName: getName(operation, { type: "type", suffix: "MutationKey" })
378
+ };
379
+ if (!isMutation) {
380
+ return null;
381
+ }
382
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
383
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
384
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
385
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
386
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
387
+ /* @__PURE__ */ jsxRuntime.jsx(
388
+ react.File.Import,
389
+ {
390
+ name: [
391
+ type.schemas.request?.name,
392
+ type.schemas.response.name,
393
+ type.schemas.pathParams?.name,
394
+ type.schemas.queryParams?.name,
395
+ type.schemas.headerParams?.name,
396
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
397
+ ].filter(Boolean),
398
+ root: mutation.file.path,
399
+ path: type.file.path,
400
+ isTypeOnly: true
401
+ }
402
+ ),
403
+ /* @__PURE__ */ jsxRuntime.jsx(
404
+ chunkJ4RZRRHQ_cjs.MutationKey,
405
+ {
406
+ name: mutationKey.name,
407
+ typeName: mutationKey.typeName,
408
+ operation,
409
+ pathParamsType: options.pathParamsType,
410
+ typeSchemas: type.schemas,
411
+ transformer: options.mutationKey
412
+ }
413
+ ),
414
+ /* @__PURE__ */ jsxRuntime.jsx(
415
+ chunkJ4RZRRHQ_cjs.Client,
416
+ {
417
+ name: client.name,
418
+ isExportable: false,
419
+ isIndexable: false,
420
+ baseURL: options.client.baseURL,
421
+ operation,
422
+ typeSchemas: type.schemas,
423
+ zodSchemas: zod.schemas,
424
+ dataReturnType: options.client.dataReturnType,
425
+ paramsType: options.paramsType,
426
+ pathParamsType: options.pathParamsType,
427
+ parser: options.parser
428
+ }
429
+ ),
430
+ options.mutation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
431
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useMutation"], path: importPath }),
432
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["MutationObserverOptions"], path: importPath, isTypeOnly: true }),
433
+ /* @__PURE__ */ jsxRuntime.jsx(
434
+ chunkJ4RZRRHQ_cjs.Mutation,
435
+ {
436
+ name: mutation.name,
437
+ clientName: client.name,
438
+ typeName: mutation.typeName,
439
+ typeSchemas: type.schemas,
440
+ operation,
441
+ dataReturnType: options.client.dataReturnType,
442
+ paramsType: options.paramsType,
443
+ pathParamsType: options.pathParamsType,
444
+ mutationKeyName: mutationKey.name
445
+ }
446
+ )
447
+ ] })
448
+ ] });
449
+ }
450
+ });
451
+ var infiniteQueryGenerator = pluginOas.createReactGenerator({
452
+ name: "vue-infinite-query",
453
+ Operation({ options, operation }) {
454
+ const {
455
+ plugin: {
456
+ options: { output }
457
+ }
458
+ } = react.useApp();
459
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
460
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
461
+ const isInfinite = isQuery && !!options.infinite;
462
+ const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
463
+ const query = {
464
+ name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
465
+ typeName: getName(operation, { type: "type" }),
466
+ file: getFile(operation, { prefix: "use", suffix: "infinite" })
467
+ };
468
+ const client = {
469
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
470
+ };
471
+ const queryOptions = {
472
+ name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" })
473
+ };
474
+ const queryKey = {
475
+ name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }),
476
+ typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" })
477
+ };
478
+ const type = {
479
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
480
+ //todo remove type?
481
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
482
+ };
483
+ const zod = {
484
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
485
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
486
+ };
487
+ if (!isQuery || !isInfinite) {
488
+ return null;
489
+ }
490
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
491
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
492
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["unref"], path: "vue" }),
493
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
494
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
495
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
496
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
497
+ /* @__PURE__ */ jsxRuntime.jsx(
498
+ react.File.Import,
499
+ {
500
+ name: [
501
+ type.schemas.request?.name,
502
+ type.schemas.response.name,
503
+ type.schemas.pathParams?.name,
504
+ type.schemas.queryParams?.name,
505
+ type.schemas.headerParams?.name,
506
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
507
+ ].filter(Boolean),
508
+ root: query.file.path,
509
+ path: type.file.path,
510
+ isTypeOnly: true
511
+ }
512
+ ),
513
+ /* @__PURE__ */ jsxRuntime.jsx(
514
+ chunkJ4RZRRHQ_cjs.QueryKey,
515
+ {
516
+ name: queryKey.name,
517
+ typeName: queryKey.typeName,
518
+ operation,
519
+ pathParamsType: options.pathParamsType,
520
+ typeSchemas: type.schemas,
521
+ transformer: options.queryKey
522
+ }
523
+ ),
524
+ /* @__PURE__ */ jsxRuntime.jsx(
525
+ chunkJ4RZRRHQ_cjs.Client,
526
+ {
527
+ name: client.name,
528
+ isExportable: false,
529
+ isIndexable: false,
530
+ baseURL: options.client.baseURL,
531
+ operation,
532
+ typeSchemas: type.schemas,
533
+ zodSchemas: zod.schemas,
534
+ dataReturnType: options.client.dataReturnType,
535
+ paramsType: options.paramsType,
536
+ pathParamsType: options.pathParamsType,
537
+ parser: options.parser
538
+ }
539
+ ),
540
+ options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
541
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["infiniteQueryOptions"], path: importPath }),
542
+ /* @__PURE__ */ jsxRuntime.jsx(
543
+ chunkJ4RZRRHQ_cjs.InfiniteQueryOptions,
544
+ {
545
+ name: queryOptions.name,
546
+ clientName: client.name,
547
+ queryKeyName: queryKey.name,
548
+ typeSchemas: type.schemas,
549
+ paramsType: options.paramsType,
550
+ pathParamsType: options.pathParamsType,
551
+ dataReturnType: options.client.dataReturnType,
552
+ cursorParam: options.infinite.cursorParam,
553
+ initialPageParam: options.infinite.initialPageParam,
554
+ queryParam: options.infinite.queryParam
555
+ }
556
+ )
557
+ ] }),
558
+ options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
559
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useInfiniteQuery"], path: importPath }),
560
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "InfiniteQueryObserverOptions", "UseInfiniteQueryReturnType"], path: importPath, isTypeOnly: true }),
561
+ /* @__PURE__ */ jsxRuntime.jsx(
562
+ chunkJ4RZRRHQ_cjs.InfiniteQuery,
563
+ {
564
+ name: query.name,
565
+ queryOptionsName: queryOptions.name,
566
+ typeSchemas: type.schemas,
567
+ paramsType: options.paramsType,
568
+ pathParamsType: options.pathParamsType,
569
+ operation,
570
+ dataReturnType: options.client.dataReturnType,
571
+ queryKeyName: queryKey.name,
572
+ queryKeyTypeName: queryKey.typeName
573
+ }
574
+ )
575
+ ] })
576
+ ] });
577
+ }
578
+ });
579
+
580
+ exports.infiniteQueryGenerator = infiniteQueryGenerator;
581
+ exports.mutationGenerator = mutationGenerator;
582
+ exports.queryGenerator = queryGenerator;
583
+ //# sourceMappingURL=chunk-A7SD37VK.cjs.map
584
+ //# sourceMappingURL=chunk-A7SD37VK.cjs.map