@kubb/plugin-vue-query 3.0.0-alpha.20

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-3HD4DCDR.js +505 -0
  4. package/dist/chunk-3HD4DCDR.js.map +1 -0
  5. package/dist/chunk-4YY5DUPV.cjs +514 -0
  6. package/dist/chunk-4YY5DUPV.cjs.map +1 -0
  7. package/dist/chunk-BKYBSBUA.js +567 -0
  8. package/dist/chunk-BKYBSBUA.js.map +1 -0
  9. package/dist/chunk-FRKJLBA5.cjs +576 -0
  10. package/dist/chunk-FRKJLBA5.cjs.map +1 -0
  11. package/dist/components.cjs +32 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +121 -0
  14. package/dist/components.d.ts +121 -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 +138 -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 +131 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-CmetQDTc.d.cts +173 -0
  30. package/dist/types-CmetQDTc.d.ts +173 -0
  31. package/package.json +102 -0
  32. package/src/components/InfiniteQuery.tsx +137 -0
  33. package/src/components/InfiniteQueryOptions.tsx +129 -0
  34. package/src/components/Mutation.tsx +141 -0
  35. package/src/components/Query.tsx +128 -0
  36. package/src/components/QueryKey.tsx +81 -0
  37. package/src/components/QueryOptions.tsx +88 -0
  38. package/src/components/index.ts +6 -0
  39. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +52 -0
  40. package/src/generators/__snapshots__/clientGetImportPath.ts +52 -0
  41. package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
  42. package/src/generators/__snapshots__/findByTags.ts +52 -0
  43. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +52 -0
  44. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +52 -0
  45. package/src/generators/__snapshots__/findByTagsWithZod.ts +52 -0
  46. package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
  47. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
  48. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  49. package/src/generators/__snapshots__/updatePetById.ts +38 -0
  50. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +40 -0
  51. package/src/generators/index.ts +3 -0
  52. package/src/generators/infiniteQueryGenerator.tsx +131 -0
  53. package/src/generators/mutationGenerator.tsx +96 -0
  54. package/src/generators/queryGenerator.tsx +124 -0
  55. package/src/index.ts +2 -0
  56. package/src/plugin.ts +152 -0
  57. package/src/types.ts +179 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stijn Van Hulle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ <div align="center">
2
+
3
+ <!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
4
+ <h1>@kubb/plugin-vue-query</h1>
5
+
6
+ <p>
7
+ Swagger integration for React-Query to generate all the different hooks based on an OpenAPI specification.
8
+ </p>
9
+ <img src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/banner.png" alt="logo" height="auto" />
10
+
11
+ [![npm version][npm-version-src]][npm-version-href]
12
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
13
+ [![Coverage][coverage-src]][coverage-href]
14
+ [![License][license-src]][license-href]
15
+
16
+ <h4>
17
+ <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
18
+ <span> · </span>
19
+ <a href="https://kubb.dev/" target="_blank">Documentation</a>
20
+ <span> · </span>
21
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
22
+ <span> · </span>
23
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
24
+ </h4>
25
+ </div>
26
+
27
+ ## Supporting Kubb
28
+
29
+ Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
30
+
31
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/sponsors/stijnvanhulle">
35
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
36
+ </a>
37
+ </p>
38
+
39
+
40
+ <!-- Badges -->
41
+
42
+ [npm-version-src]: https://img.shields.io/npm/v/@kubb/plugin-vue-query?flat&colorA=18181B&colorB=f58517
43
+ [npm-version-href]: https://npmjs.com/package/@kubb/plugin-vue-query
44
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/plugin-vue-query?flat&colorA=18181B&colorB=f58517
45
+ [npm-downloads-href]: https://npmjs.com/package/@kubb/plugin-vue-query
46
+ [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
47
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
48
+ [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
49
+ [build-href]: https://www.npmjs.com/package/@kubb/plugin-vue-query
50
+ [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/plugin-vue-query?style=flat&colorA=18181B&colorB=f58517
51
+ [minified-href]: https://www.npmjs.com/package/@kubb/plugin-vue-query
52
+ [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
53
+ [coverage-href]: https://www.npmjs.com/package/@kubb/plugin-vue-query
54
+
55
+ ## options query
56
+
57
+ ### v4
58
+
59
+ UseBaseQueryOptions => react-query only
60
+ UseQueryOptions => vue-query only
61
+ CreateQueryOptions => solid-query only
62
+ CreateQueryOptions => svelte-query only
63
+
64
+ ### v5
65
+
66
+ UseBaseQueryOptions => react-query only https://github.com/TanStack/query/blob/ce1305c27e7ac7988656d171d882a665a286cc6a/packages/react-query/src/types.ts#L18
67
+ QueryObserverOptions => vue-query only https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L24
68
+ UseQueryOptions => solid-query only
69
+
70
+ ## result query
71
+
72
+ ### v4
73
+
74
+ UseQueryResult => react-query only
75
+ UseQueryReturnType => vue-query only
76
+ CreateQueryResult => solid-query only
77
+ CreateQueryResult => svelte-query only
78
+
79
+ ### v5
80
+
81
+ UseQueryResult => react-query only
82
+ UseQueryReturnType => vue-query only
83
+
84
+ ## queryOptions() query
85
+
86
+ ### v5
87
+
88
+ queryOptions => react-query only
89
+
90
+ ```typescript
91
+ {
92
+ query: {
93
+ types: {
94
+ options: 'UseBaseQueryOptions'
95
+ result: 'UseQueryResult'
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## options mutation
102
+
103
+ ### v4
104
+
105
+ UseMutationOptions => react-query only
106
+ VueMutationObserverOptions => vue-query only
107
+
108
+ ### v5
109
+
110
+ UseMutationOptions => react-query only
111
+ MutationObserverOptions => vue-query only
112
+
113
+ ## result mutation
114
+
115
+ ### v4
116
+
117
+ UseMutationResult => react-query only
118
+ UseMutationReturnType => vue-query only
119
+
120
+ ### v5
121
+
122
+ UseMutationResult => react-query only
123
+ UseMutationReturnType => vue-query only
@@ -0,0 +1,505 @@
1
+ import { Client, Operations, QueryKey, QueryOptions, Query, Mutation, InfiniteQueryOptions, InfiniteQuery } from './chunk-BKYBSBUA.js';
2
+ import transformers, { camelCase } from '@kubb/core/transformers';
3
+ import path from 'node:path';
4
+ import { createPlugin, FileManager, PluginManager } from '@kubb/core';
5
+ import { renderTemplate } from '@kubb/core/utils';
6
+ import { createReactGenerator, pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
7
+ import { pluginZodName } from '@kubb/plugin-zod';
8
+ import { useOperationManager } from '@kubb/plugin-oas/hooks';
9
+ import { pluginTsName } from '@kubb/plugin-ts';
10
+ import { useApp, File } from '@kubb/react';
11
+ import { jsxs, jsx } from '@kubb/react/jsx-runtime';
12
+
13
+ var clientGenerator = createReactGenerator({
14
+ name: "client",
15
+ Operation({ options, operation }) {
16
+ const {
17
+ plugin: {
18
+ options: { output }
19
+ }
20
+ } = useApp();
21
+ const { getSchemas, getName, getFile } = useOperationManager();
22
+ const client = {
23
+ name: getName(operation, { type: "function" }),
24
+ file: getFile(operation)
25
+ };
26
+ const type = {
27
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
28
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
29
+ };
30
+ const zod = {
31
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
32
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
33
+ };
34
+ return /* @__PURE__ */ jsxs(File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, banner: output?.banner, footer: output?.footer, children: [
35
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.importPath }),
36
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.importPath, isTypeOnly: true }),
37
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
38
+ /* @__PURE__ */ jsx(
39
+ File.Import,
40
+ {
41
+ extName: output?.extName,
42
+ name: [
43
+ type.schemas.request?.name,
44
+ type.schemas.response.name,
45
+ type.schemas.pathParams?.name,
46
+ type.schemas.queryParams?.name,
47
+ type.schemas.headerParams?.name,
48
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
49
+ ].filter(Boolean),
50
+ root: client.file.path,
51
+ path: type.file.path,
52
+ isTypeOnly: true
53
+ }
54
+ ),
55
+ /* @__PURE__ */ jsx(
56
+ Client,
57
+ {
58
+ name: client.name,
59
+ baseURL: options.baseURL,
60
+ dataReturnType: options.dataReturnType,
61
+ pathParamsType: options.pathParamsType,
62
+ typeSchemas: type.schemas,
63
+ operation,
64
+ parser: options.parser,
65
+ zodSchemas: zod.schemas
66
+ }
67
+ )
68
+ ] });
69
+ }
70
+ });
71
+ var operationsGenerator = createReactGenerator({
72
+ name: "client",
73
+ Operations({ operations }) {
74
+ const {
75
+ pluginManager,
76
+ plugin: {
77
+ options: { output }
78
+ }
79
+ } = useApp();
80
+ const name = "operations";
81
+ const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: [pluginClientName] });
82
+ return /* @__PURE__ */ jsx(File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsx(Operations, { name, operations }) });
83
+ }
84
+ });
85
+
86
+ // ../plugin-client/src/plugin.ts
87
+ var pluginClientName = "plugin-client";
88
+ createPlugin((options) => {
89
+ const {
90
+ output = { path: "clients" },
91
+ group,
92
+ exclude = [],
93
+ include,
94
+ override = [],
95
+ transformers: transformers3 = {},
96
+ dataReturnType = "data",
97
+ pathParamsType = "inline",
98
+ operations = false,
99
+ importPath = "@kubb/plugin-client/client",
100
+ parser = "client"
101
+ } = options;
102
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
103
+ return {
104
+ name: pluginClientName,
105
+ options: {
106
+ output: {
107
+ exportType: "barrelNamed",
108
+ ...output
109
+ },
110
+ parser,
111
+ dataReturnType,
112
+ importPath,
113
+ pathParamsType,
114
+ baseURL: void 0
115
+ },
116
+ pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
117
+ resolvePath(baseName, pathMode, options2) {
118
+ const root = path.resolve(this.config.root, this.config.output.path);
119
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
120
+ if (mode === "single") {
121
+ return path.resolve(root, output.path);
122
+ }
123
+ if (options2?.tag && group?.type === "tag") {
124
+ const tag = camelCase(options2.tag);
125
+ return path.resolve(root, renderTemplate(template, { tag }), baseName);
126
+ }
127
+ return path.resolve(root, output.path, baseName);
128
+ },
129
+ resolveName(name, type) {
130
+ const resolvedName = camelCase(name, { isFile: type === "file" });
131
+ if (type) {
132
+ return transformers3?.name?.(resolvedName, type) || resolvedName;
133
+ }
134
+ return resolvedName;
135
+ },
136
+ async buildStart() {
137
+ const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
138
+ const oas = await swaggerPlugin.context.getOas();
139
+ const root = path.resolve(this.config.root, this.config.output.path);
140
+ const mode = FileManager.getMode(path.resolve(root, output.path));
141
+ const baseURL = await swaggerPlugin.context.getBaseURL();
142
+ const operationGenerator = new OperationGenerator(
143
+ {
144
+ ...this.plugin.options,
145
+ baseURL
146
+ },
147
+ {
148
+ oas,
149
+ pluginManager: this.pluginManager,
150
+ plugin: this.plugin,
151
+ contentType: swaggerPlugin.context.contentType,
152
+ exclude,
153
+ include,
154
+ override,
155
+ mode
156
+ }
157
+ );
158
+ const files = await operationGenerator.build(...[clientGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
159
+ await this.addFile(...files);
160
+ if (this.config.output.exportType) {
161
+ const barrelFiles = await this.fileManager.getBarrelFiles({
162
+ root,
163
+ output,
164
+ files: this.fileManager.files,
165
+ meta: {
166
+ pluginKey: this.plugin.key
167
+ },
168
+ logger: this.logger
169
+ });
170
+ await this.addFile(...barrelFiles);
171
+ }
172
+ }
173
+ };
174
+ });
175
+ var queryGenerator = createReactGenerator({
176
+ name: "vue-query",
177
+ Operation({ options, operation }) {
178
+ const {
179
+ plugin: {
180
+ options: { output }
181
+ }
182
+ } = useApp();
183
+ const { getSchemas, getName, getFile } = useOperationManager();
184
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
185
+ !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
186
+ const query = {
187
+ name: getName(operation, { type: "function", prefix: "use" }),
188
+ typeName: getName(operation, { type: "type" }),
189
+ file: getFile(operation, { prefix: "use" })
190
+ };
191
+ const client = {
192
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
193
+ };
194
+ const queryOptions = {
195
+ name: transformers.camelCase(`${operation.getOperationId()} QueryOptions`)
196
+ };
197
+ const queryKey = {
198
+ name: transformers.camelCase(`${operation.getOperationId()} QueryKey`),
199
+ typeName: transformers.pascalCase(`${operation.getOperationId()} QueryKey`)
200
+ };
201
+ const type = {
202
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
203
+ //todo remove type?
204
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
205
+ };
206
+ const zod = {
207
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
208
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
209
+ };
210
+ if (!isQuery || typeof options.query === "boolean") {
211
+ return null;
212
+ }
213
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
214
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
215
+ /* @__PURE__ */ jsx(File.Import, { name: ["useQuery", "queryOptions"], path: options.query.importPath }),
216
+ /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired", "QueryObserverOptions", "UseQueryReturnType"], path: options.query.importPath, isTypeOnly: true }),
217
+ /* @__PURE__ */ jsx(File.Import, { name: ["unref"], path: "vue" }),
218
+ /* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
219
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
220
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
221
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
222
+ /* @__PURE__ */ jsx(
223
+ File.Import,
224
+ {
225
+ extName: output?.extName,
226
+ name: [
227
+ type.schemas.request?.name,
228
+ type.schemas.response.name,
229
+ type.schemas.pathParams?.name,
230
+ type.schemas.queryParams?.name,
231
+ type.schemas.headerParams?.name,
232
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
233
+ ].filter(Boolean),
234
+ root: query.file.path,
235
+ path: type.file.path,
236
+ isTypeOnly: true
237
+ }
238
+ ),
239
+ /* @__PURE__ */ jsx(
240
+ QueryKey,
241
+ {
242
+ name: queryKey.name,
243
+ typeName: queryKey.typeName,
244
+ operation,
245
+ pathParamsType: options.pathParamsType,
246
+ typeSchemas: type.schemas,
247
+ keysFn: options.query.key
248
+ }
249
+ ),
250
+ /* @__PURE__ */ jsx(
251
+ Client,
252
+ {
253
+ name: client.name,
254
+ isExportable: false,
255
+ isIndexable: false,
256
+ baseURL: options.baseURL,
257
+ operation,
258
+ typeSchemas: type.schemas,
259
+ zodSchemas: zod.schemas,
260
+ dataReturnType: options.client.dataReturnType,
261
+ pathParamsType: options.pathParamsType,
262
+ parser: options.parser
263
+ }
264
+ ),
265
+ /* @__PURE__ */ jsx(
266
+ QueryOptions,
267
+ {
268
+ name: queryOptions.name,
269
+ clientName: client.name,
270
+ queryKeyName: queryKey.name,
271
+ typeSchemas: type.schemas,
272
+ pathParamsType: options.pathParamsType
273
+ }
274
+ ),
275
+ /* @__PURE__ */ jsx(
276
+ Query,
277
+ {
278
+ name: query.name,
279
+ queryOptionsName: queryOptions.name,
280
+ typeSchemas: type.schemas,
281
+ pathParamsType: options.pathParamsType,
282
+ operation,
283
+ dataReturnType: options.client.dataReturnType,
284
+ queryKeyName: queryKey.name,
285
+ queryKeyTypeName: queryKey.typeName
286
+ }
287
+ )
288
+ ] });
289
+ }
290
+ });
291
+ var mutationGenerator = createReactGenerator({
292
+ name: "vue-query",
293
+ Operation({ options, operation }) {
294
+ const {
295
+ plugin: {
296
+ options: { output }
297
+ }
298
+ } = useApp();
299
+ const { getSchemas, getName, getFile } = useOperationManager();
300
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
301
+ const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
302
+ const mutation = {
303
+ name: getName(operation, { type: "function", prefix: "use" }),
304
+ typeName: getName(operation, { type: "type" }),
305
+ file: getFile(operation, { prefix: "use" })
306
+ };
307
+ const type = {
308
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
309
+ //todo remove type?
310
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
311
+ };
312
+ const zod = {
313
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
314
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
315
+ };
316
+ const client = {
317
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
318
+ };
319
+ if (!isMutation || typeof options.mutation === "boolean") {
320
+ return null;
321
+ }
322
+ return /* @__PURE__ */ jsxs(File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
323
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
324
+ /* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: options.mutation.importPath }),
325
+ /* @__PURE__ */ jsx(File.Import, { name: ["UseMutationOptions"], path: options.mutation.importPath, isTypeOnly: true }),
326
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
327
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
328
+ /* @__PURE__ */ jsx(
329
+ File.Import,
330
+ {
331
+ extName: output?.extName,
332
+ name: [
333
+ type.schemas.request?.name,
334
+ type.schemas.response.name,
335
+ type.schemas.pathParams?.name,
336
+ type.schemas.queryParams?.name,
337
+ type.schemas.headerParams?.name,
338
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
339
+ ].filter(Boolean),
340
+ root: mutation.file.path,
341
+ path: type.file.path,
342
+ isTypeOnly: true
343
+ }
344
+ ),
345
+ /* @__PURE__ */ jsx(
346
+ Client,
347
+ {
348
+ name: client.name,
349
+ isExportable: false,
350
+ isIndexable: false,
351
+ baseURL: options.baseURL,
352
+ operation,
353
+ typeSchemas: type.schemas,
354
+ zodSchemas: zod.schemas,
355
+ dataReturnType: options.client.dataReturnType,
356
+ pathParamsType: options.pathParamsType,
357
+ parser: options.parser
358
+ }
359
+ ),
360
+ /* @__PURE__ */ jsx(
361
+ Mutation,
362
+ {
363
+ name: mutation.name,
364
+ clientName: client.name,
365
+ typeName: mutation.typeName,
366
+ typeSchemas: type.schemas,
367
+ operation,
368
+ dataReturnType: options.client.dataReturnType,
369
+ pathParamsType: options.pathParamsType
370
+ }
371
+ )
372
+ ] });
373
+ }
374
+ });
375
+ var infiniteQueryGenerator = createReactGenerator({
376
+ name: "vue-infinite-query",
377
+ Operation({ options, operation }) {
378
+ const {
379
+ plugin: {
380
+ options: { output }
381
+ }
382
+ } = useApp();
383
+ const { getSchemas, getName, getFile } = useOperationManager();
384
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
385
+ const isInfinite = isQuery && !!options.infinite;
386
+ const query = {
387
+ name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
388
+ typeName: getName(operation, { type: "type" }),
389
+ file: getFile(operation, { prefix: "use", suffix: "infinite" })
390
+ };
391
+ const client = {
392
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
393
+ };
394
+ const queryOptions = {
395
+ name: transformers.camelCase(`${operation.getOperationId()} InfiniteQueryOptions`)
396
+ };
397
+ const queryKey = {
398
+ name: transformers.camelCase(`${operation.getOperationId()} InfiniteQueryKey`),
399
+ typeName: transformers.pascalCase(`${operation.getOperationId()} InfiniteQueryKey`)
400
+ };
401
+ const type = {
402
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
403
+ //todo remove type?
404
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
405
+ };
406
+ const zod = {
407
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
408
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
409
+ };
410
+ if (!isQuery || !isInfinite || typeof options.query === "boolean" || typeof options.infinite === "boolean") {
411
+ return null;
412
+ }
413
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
414
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
415
+ /* @__PURE__ */ jsx(File.Import, { name: ["useInfiniteQuery", "infiniteQueryOptions"], path: options.query.importPath }),
416
+ /* @__PURE__ */ jsx(
417
+ File.Import,
418
+ {
419
+ name: ["QueryKey", "WithRequired", "InfiniteQueryObserverOptions", "UseInfiniteQueryReturnType"],
420
+ path: options.query.importPath,
421
+ isTypeOnly: true
422
+ }
423
+ ),
424
+ /* @__PURE__ */ jsx(File.Import, { name: ["unref"], path: "vue" }),
425
+ /* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
426
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
427
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
428
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
429
+ /* @__PURE__ */ jsx(
430
+ File.Import,
431
+ {
432
+ extName: output?.extName,
433
+ name: [
434
+ type.schemas.request?.name,
435
+ type.schemas.response.name,
436
+ type.schemas.pathParams?.name,
437
+ type.schemas.queryParams?.name,
438
+ type.schemas.headerParams?.name,
439
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
440
+ ].filter(Boolean),
441
+ root: query.file.path,
442
+ path: type.file.path,
443
+ isTypeOnly: true
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsx(
447
+ QueryKey,
448
+ {
449
+ name: queryKey.name,
450
+ typeName: queryKey.typeName,
451
+ operation,
452
+ pathParamsType: options.pathParamsType,
453
+ typeSchemas: type.schemas,
454
+ keysFn: options.query.key
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx(
458
+ Client,
459
+ {
460
+ name: client.name,
461
+ isExportable: false,
462
+ isIndexable: false,
463
+ baseURL: options.baseURL,
464
+ operation,
465
+ typeSchemas: type.schemas,
466
+ zodSchemas: zod.schemas,
467
+ dataReturnType: options.client.dataReturnType,
468
+ pathParamsType: options.pathParamsType,
469
+ parser: options.parser
470
+ }
471
+ ),
472
+ /* @__PURE__ */ jsx(
473
+ InfiniteQueryOptions,
474
+ {
475
+ name: queryOptions.name,
476
+ clientName: client.name,
477
+ queryKeyName: queryKey.name,
478
+ typeSchemas: type.schemas,
479
+ pathParamsType: options.pathParamsType,
480
+ dataReturnType: options.client.dataReturnType,
481
+ cursorParam: options.infinite.cursorParam,
482
+ initialPageParam: options.infinite.initialPageParam,
483
+ queryParam: options.infinite.queryParam
484
+ }
485
+ ),
486
+ /* @__PURE__ */ jsx(
487
+ InfiniteQuery,
488
+ {
489
+ name: query.name,
490
+ queryOptionsName: queryOptions.name,
491
+ typeSchemas: type.schemas,
492
+ pathParamsType: options.pathParamsType,
493
+ operation,
494
+ dataReturnType: options.client.dataReturnType,
495
+ queryKeyName: queryKey.name,
496
+ queryKeyTypeName: queryKey.typeName
497
+ }
498
+ )
499
+ ] });
500
+ }
501
+ });
502
+
503
+ export { infiniteQueryGenerator, mutationGenerator, queryGenerator };
504
+ //# sourceMappingURL=chunk-3HD4DCDR.js.map
505
+ //# sourceMappingURL=chunk-3HD4DCDR.js.map