@kubb/plugin-react-query 3.0.0-alpha.3 → 3.0.0-alpha.30

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 (81) hide show
  1. package/README.md +13 -4
  2. package/dist/chunk-2D27Y6L5.js +618 -0
  3. package/dist/chunk-2D27Y6L5.js.map +1 -0
  4. package/dist/chunk-C2H3KPHM.cjs +658 -0
  5. package/dist/chunk-C2H3KPHM.cjs.map +1 -0
  6. package/dist/chunk-JW3GZUSC.cjs +627 -0
  7. package/dist/chunk-JW3GZUSC.cjs.map +1 -0
  8. package/dist/chunk-Y3DM2P6L.js +647 -0
  9. package/dist/chunk-Y3DM2P6L.js.map +1 -0
  10. package/dist/components.cjs +39 -14
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +161 -7
  13. package/dist/components.d.ts +161 -7
  14. package/dist/components.js +2 -14
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +25 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +14 -0
  19. package/dist/generators.d.ts +14 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +75 -154
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +1 -5
  25. package/dist/index.d.ts +1 -5
  26. package/dist/index.js +54 -140
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-rJasmoxy.d.cts +187 -0
  29. package/dist/types-rJasmoxy.d.ts +187 -0
  30. package/package.json +22 -17
  31. package/src/components/InfiniteQuery.tsx +129 -0
  32. package/src/components/InfiniteQueryOptions.tsx +130 -0
  33. package/src/components/Mutation.tsx +138 -322
  34. package/src/components/MutationKey.tsx +48 -0
  35. package/src/components/Query.tsx +91 -598
  36. package/src/components/QueryKey.tsx +51 -178
  37. package/src/components/QueryOptions.tsx +72 -466
  38. package/src/components/SuspenseQuery.tsx +129 -0
  39. package/src/components/index.ts +4 -1
  40. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  41. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  42. package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
  43. package/src/generators/__snapshots__/findByTags.ts +51 -0
  44. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  45. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  46. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  47. package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
  48. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
  49. package/src/generators/__snapshots__/getAsMutation.ts +31 -0
  50. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +44 -0
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -0
  53. package/src/generators/index.ts +4 -0
  54. package/src/generators/infiniteQueryGenerator.tsx +124 -0
  55. package/src/generators/mutationGenerator.tsx +108 -0
  56. package/src/generators/queryGenerator.tsx +121 -0
  57. package/src/generators/suspenseQueryGenerator.tsx +120 -0
  58. package/src/plugin.ts +51 -75
  59. package/src/types.ts +49 -88
  60. package/dist/chunk-5IL6M74X.js +0 -1504
  61. package/dist/chunk-5IL6M74X.js.map +0 -1
  62. package/dist/chunk-JFX7DCS7.cjs +0 -1504
  63. package/dist/chunk-JFX7DCS7.cjs.map +0 -1
  64. package/dist/index-C9fwRDH7.d.cts +0 -579
  65. package/dist/index-C9fwRDH7.d.ts +0 -579
  66. package/src/OperationGenerator.tsx +0 -86
  67. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -64
  68. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -57
  69. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -63
  70. package/src/__snapshots__/queryOptions/getPetById.ts +0 -37
  71. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -47
  72. package/src/__snapshots__/upload/UploadFile.ts +0 -67
  73. package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -44
  74. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -21
  75. package/src/components/Operations.tsx +0 -74
  76. package/src/components/QueryImports.tsx +0 -167
  77. package/src/components/SchemaType.tsx +0 -55
  78. package/src/components/__snapshots__/gen/showPetById.ts +0 -57
  79. package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
  80. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -47
  81. package/src/utils.ts +0 -96
package/README.md CHANGED
@@ -13,10 +13,6 @@
13
13
  [![Coverage][coverage-src]][coverage-href]
14
14
  [![License][license-src]][license-href]
15
15
 
16
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
- </p>
19
-
20
16
  <h4>
21
17
  <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
22
18
  <span> · </span>
@@ -28,6 +24,19 @@
28
24
  </h4>
29
25
  </div>
30
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
+
31
40
  <!-- Badges -->
32
41
 
33
42
  [npm-version-src]: https://img.shields.io/npm/v/@kubb/plugin-tanstack-query?flat&colorA=18181B&colorB=f58517
@@ -0,0 +1,618 @@
1
+ import { Client, Operations, QueryKey, QueryOptions, Query, MutationKey, Mutation, InfiniteQueryOptions, InfiniteQuery, SuspenseQuery } from './chunk-Y3DM2P6L.js';
2
+ import { 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, { name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
38
+ /* @__PURE__ */ jsx(
39
+ File.Import,
40
+ {
41
+ name: [
42
+ type.schemas.request?.name,
43
+ type.schemas.response.name,
44
+ type.schemas.pathParams?.name,
45
+ type.schemas.queryParams?.name,
46
+ type.schemas.headerParams?.name,
47
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
48
+ ].filter(Boolean),
49
+ root: client.file.path,
50
+ path: type.file.path,
51
+ isTypeOnly: true
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ Client,
56
+ {
57
+ name: client.name,
58
+ baseURL: options.baseURL,
59
+ dataReturnType: options.dataReturnType,
60
+ pathParamsType: options.pathParamsType,
61
+ typeSchemas: type.schemas,
62
+ operation,
63
+ parser: options.parser,
64
+ zodSchemas: zod.schemas
65
+ }
66
+ )
67
+ ] });
68
+ }
69
+ });
70
+ var operationsGenerator = createReactGenerator({
71
+ name: "client",
72
+ Operations({ operations }) {
73
+ const {
74
+ pluginManager,
75
+ plugin: {
76
+ options: { output }
77
+ }
78
+ } = useApp();
79
+ const name = "operations";
80
+ const file = pluginManager.getFile({ name, extname: ".ts", pluginKey: [pluginClientName] });
81
+ 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 }) });
82
+ }
83
+ });
84
+
85
+ // ../plugin-client/src/plugin.ts
86
+ var pluginClientName = "plugin-client";
87
+ createPlugin((options) => {
88
+ const {
89
+ output = { path: "clients", barrelType: "named" },
90
+ group,
91
+ exclude = [],
92
+ include,
93
+ override = [],
94
+ transformers: transformers5 = {},
95
+ dataReturnType = "data",
96
+ pathParamsType = "inline",
97
+ operations = false,
98
+ generators = [clientGenerator, operations ? operationsGenerator : void 0].filter(Boolean),
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
+ ...output
108
+ },
109
+ parser,
110
+ dataReturnType,
111
+ importPath,
112
+ pathParamsType,
113
+ baseURL: void 0
114
+ },
115
+ pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
116
+ resolvePath(baseName, pathMode, options2) {
117
+ const root = path.resolve(this.config.root, this.config.output.path);
118
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
119
+ if (mode === "single") {
120
+ return path.resolve(root, output.path);
121
+ }
122
+ if (options2?.tag && group?.type === "tag") {
123
+ const tag = camelCase(options2.tag);
124
+ return path.resolve(root, renderTemplate(template, { tag }), baseName);
125
+ }
126
+ return path.resolve(root, output.path, baseName);
127
+ },
128
+ resolveName(name, type) {
129
+ const resolvedName = camelCase(name, { isFile: type === "file" });
130
+ if (type) {
131
+ return transformers5?.name?.(resolvedName, type) || resolvedName;
132
+ }
133
+ return resolvedName;
134
+ },
135
+ async buildStart() {
136
+ const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
137
+ const oas = await swaggerPlugin.context.getOas();
138
+ const root = path.resolve(this.config.root, this.config.output.path);
139
+ const mode = FileManager.getMode(path.resolve(root, output.path));
140
+ const baseURL = await swaggerPlugin.context.getBaseURL();
141
+ const operationGenerator = new OperationGenerator(
142
+ {
143
+ ...this.plugin.options,
144
+ baseURL
145
+ },
146
+ {
147
+ oas,
148
+ pluginManager: this.pluginManager,
149
+ plugin: this.plugin,
150
+ contentType: swaggerPlugin.context.contentType,
151
+ exclude,
152
+ include,
153
+ override,
154
+ mode
155
+ }
156
+ );
157
+ const files = await operationGenerator.build(...generators);
158
+ await this.addFile(...files);
159
+ const barrelFiles = await this.fileManager.getBarrelFiles({
160
+ type: output.barrelType ?? "named",
161
+ root,
162
+ output,
163
+ files: this.fileManager.files,
164
+ meta: {
165
+ pluginKey: this.plugin.key
166
+ },
167
+ logger: this.logger
168
+ });
169
+ await this.addFile(...barrelFiles);
170
+ }
171
+ };
172
+ });
173
+ var queryGenerator = createReactGenerator({
174
+ name: "react-query",
175
+ Operation({ options, operation }) {
176
+ const {
177
+ plugin: {
178
+ options: { output }
179
+ }
180
+ } = useApp();
181
+ const { getSchemas, getName, getFile } = useOperationManager();
182
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
183
+ !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
184
+ const query = {
185
+ name: getName(operation, { type: "function", prefix: "use" }),
186
+ typeName: getName(operation, { type: "type" }),
187
+ file: getFile(operation, { prefix: "use" })
188
+ };
189
+ const client = {
190
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
191
+ };
192
+ const queryOptions = {
193
+ name: getName(operation, { type: "function", suffix: "QueryOptions" })
194
+ };
195
+ const queryKey = {
196
+ name: getName(operation, { type: "const", suffix: "QueryKey" }),
197
+ typeName: getName(operation, { type: "type", suffix: "QueryKey" })
198
+ };
199
+ const type = {
200
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
201
+ //todo remove type?
202
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
203
+ };
204
+ const zod = {
205
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
206
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
207
+ };
208
+ if (!isQuery || typeof options.query === "boolean") {
209
+ return null;
210
+ }
211
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
212
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
213
+ /* @__PURE__ */ jsx(File.Import, { name: ["useQuery", "queryOptions"], path: options.query.importPath }),
214
+ /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired", "QueryObserverOptions", "UseQueryResult"], path: options.query.importPath, isTypeOnly: true }),
215
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
216
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
217
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
218
+ /* @__PURE__ */ jsx(
219
+ File.Import,
220
+ {
221
+ name: [
222
+ type.schemas.request?.name,
223
+ type.schemas.response.name,
224
+ type.schemas.pathParams?.name,
225
+ type.schemas.queryParams?.name,
226
+ type.schemas.headerParams?.name,
227
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
228
+ ].filter(Boolean),
229
+ root: query.file.path,
230
+ path: type.file.path,
231
+ isTypeOnly: true
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsx(
235
+ QueryKey,
236
+ {
237
+ name: queryKey.name,
238
+ typeName: queryKey.typeName,
239
+ operation,
240
+ pathParamsType: options.pathParamsType,
241
+ typeSchemas: type.schemas,
242
+ keysFn: options.query.key
243
+ }
244
+ ),
245
+ /* @__PURE__ */ jsx(
246
+ Client,
247
+ {
248
+ name: client.name,
249
+ isExportable: false,
250
+ isIndexable: false,
251
+ baseURL: options.baseURL,
252
+ operation,
253
+ typeSchemas: type.schemas,
254
+ zodSchemas: zod.schemas,
255
+ dataReturnType: options.client.dataReturnType,
256
+ pathParamsType: options.pathParamsType,
257
+ parser: options.parser
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsx(
261
+ QueryOptions,
262
+ {
263
+ name: queryOptions.name,
264
+ clientName: client.name,
265
+ queryKeyName: queryKey.name,
266
+ typeSchemas: type.schemas,
267
+ pathParamsType: options.pathParamsType
268
+ }
269
+ ),
270
+ /* @__PURE__ */ jsx(
271
+ Query,
272
+ {
273
+ name: query.name,
274
+ queryOptionsName: queryOptions.name,
275
+ typeSchemas: type.schemas,
276
+ pathParamsType: options.pathParamsType,
277
+ operation,
278
+ dataReturnType: options.client.dataReturnType,
279
+ queryKeyName: queryKey.name,
280
+ queryKeyTypeName: queryKey.typeName
281
+ }
282
+ )
283
+ ] });
284
+ }
285
+ });
286
+ var mutationGenerator = createReactGenerator({
287
+ name: "react-query",
288
+ Operation({ options, operation }) {
289
+ const {
290
+ plugin: {
291
+ options: { output }
292
+ }
293
+ } = useApp();
294
+ const { getSchemas, getName, getFile } = useOperationManager();
295
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
296
+ const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
297
+ const mutation = {
298
+ name: getName(operation, { type: "function", prefix: "use" }),
299
+ typeName: getName(operation, { type: "type" }),
300
+ file: getFile(operation, { prefix: "use" })
301
+ };
302
+ const type = {
303
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
304
+ //todo remove type?
305
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
306
+ };
307
+ const zod = {
308
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
309
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
310
+ };
311
+ const client = {
312
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
313
+ };
314
+ const mutationKey = {
315
+ name: getName(operation, { type: "const", suffix: "MutationKey" }),
316
+ typeName: getName(operation, { type: "type", suffix: "MutationKey" })
317
+ };
318
+ if (!isMutation || typeof options.mutation === "boolean") {
319
+ return null;
320
+ }
321
+ return /* @__PURE__ */ jsxs(File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
322
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
323
+ /* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: options.mutation.importPath }),
324
+ /* @__PURE__ */ jsx(File.Import, { name: ["UseMutationOptions"], path: options.mutation.importPath, isTypeOnly: true }),
325
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
326
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
327
+ /* @__PURE__ */ jsx(
328
+ File.Import,
329
+ {
330
+ name: [
331
+ type.schemas.request?.name,
332
+ type.schemas.response.name,
333
+ type.schemas.pathParams?.name,
334
+ type.schemas.queryParams?.name,
335
+ type.schemas.headerParams?.name,
336
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
337
+ ].filter(Boolean),
338
+ root: mutation.file.path,
339
+ path: type.file.path,
340
+ isTypeOnly: true
341
+ }
342
+ ),
343
+ /* @__PURE__ */ jsx(
344
+ MutationKey,
345
+ {
346
+ name: mutationKey.name,
347
+ typeName: mutationKey.typeName,
348
+ operation,
349
+ pathParamsType: options.pathParamsType,
350
+ typeSchemas: type.schemas,
351
+ keysFn: options.mutation.key
352
+ }
353
+ ),
354
+ /* @__PURE__ */ jsx(
355
+ Client,
356
+ {
357
+ name: client.name,
358
+ isExportable: false,
359
+ isIndexable: false,
360
+ baseURL: options.baseURL,
361
+ operation,
362
+ typeSchemas: type.schemas,
363
+ zodSchemas: zod.schemas,
364
+ dataReturnType: options.client.dataReturnType,
365
+ pathParamsType: options.pathParamsType,
366
+ parser: options.parser
367
+ }
368
+ ),
369
+ /* @__PURE__ */ jsx(
370
+ Mutation,
371
+ {
372
+ name: mutation.name,
373
+ clientName: client.name,
374
+ typeName: mutation.typeName,
375
+ typeSchemas: type.schemas,
376
+ operation,
377
+ dataReturnType: options.client.dataReturnType,
378
+ pathParamsType: options.pathParamsType,
379
+ mutationKeyName: mutationKey.name
380
+ }
381
+ )
382
+ ] });
383
+ }
384
+ });
385
+ var infiniteQueryGenerator = createReactGenerator({
386
+ name: "react-infinite-query",
387
+ Operation({ options, operation }) {
388
+ const {
389
+ plugin: {
390
+ options: { output }
391
+ }
392
+ } = useApp();
393
+ const { getSchemas, getName, getFile } = useOperationManager();
394
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
395
+ const isInfinite = isQuery && !!options.infinite;
396
+ const query = {
397
+ name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
398
+ typeName: getName(operation, { type: "type" }),
399
+ file: getFile(operation, { prefix: "use", suffix: "infinite" })
400
+ };
401
+ const client = {
402
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
403
+ };
404
+ const queryOptions = {
405
+ name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" })
406
+ };
407
+ const queryKey = {
408
+ name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }),
409
+ typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" })
410
+ };
411
+ const type = {
412
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
413
+ //todo remove type?
414
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
415
+ };
416
+ const zod = {
417
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
418
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
419
+ };
420
+ if (!isQuery || !isInfinite || typeof options.query === "boolean" || typeof options.infinite === "boolean") {
421
+ return null;
422
+ }
423
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
424
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
425
+ /* @__PURE__ */ jsx(File.Import, { name: ["useInfiniteQuery", "infiniteQueryOptions"], path: options.query.importPath }),
426
+ /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: options.query.importPath, isTypeOnly: true }),
427
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
428
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
429
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
430
+ /* @__PURE__ */ jsx(
431
+ File.Import,
432
+ {
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
+ var suspenseQueryGenerator = createReactGenerator({
503
+ name: "react-suspense-query",
504
+ Operation({ options, operation }) {
505
+ const {
506
+ plugin: {
507
+ options: { output }
508
+ }
509
+ } = useApp();
510
+ const { getSchemas, getName, getFile } = useOperationManager();
511
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
512
+ const isSuspense = isQuery && !!options.suspense;
513
+ const query = {
514
+ name: getName(operation, { type: "function", prefix: "use", suffix: "suspense" }),
515
+ typeName: getName(operation, { type: "type" }),
516
+ file: getFile(operation, { prefix: "use", suffix: "suspense" })
517
+ };
518
+ const client = {
519
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
520
+ };
521
+ const queryOptions = {
522
+ name: getName(operation, { type: "function", suffix: "SuspenseQueryOptions" })
523
+ };
524
+ const queryKey = {
525
+ name: getName(operation, { type: "const", suffix: "SuspenseQueryKey" }),
526
+ typeName: getName(operation, { type: "type", suffix: "SuspenseQueryKey" })
527
+ };
528
+ const type = {
529
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
530
+ //todo remove type?
531
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
532
+ };
533
+ const zod = {
534
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
535
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
536
+ };
537
+ if (!isQuery || !isSuspense || typeof options.query === "boolean") {
538
+ return null;
539
+ }
540
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
541
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
542
+ /* @__PURE__ */ jsx(File.Import, { name: ["useSuspenseQuery", "queryOptions"], path: options.query.importPath }),
543
+ /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: options.query.importPath, isTypeOnly: true }),
544
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
545
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
546
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
547
+ /* @__PURE__ */ jsx(
548
+ File.Import,
549
+ {
550
+ name: [
551
+ type.schemas.request?.name,
552
+ type.schemas.response.name,
553
+ type.schemas.pathParams?.name,
554
+ type.schemas.queryParams?.name,
555
+ type.schemas.headerParams?.name,
556
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
557
+ ].filter(Boolean),
558
+ root: query.file.path,
559
+ path: type.file.path,
560
+ isTypeOnly: true
561
+ }
562
+ ),
563
+ /* @__PURE__ */ jsx(
564
+ QueryKey,
565
+ {
566
+ name: queryKey.name,
567
+ typeName: queryKey.typeName,
568
+ operation,
569
+ pathParamsType: options.pathParamsType,
570
+ typeSchemas: type.schemas,
571
+ keysFn: options.query.key
572
+ }
573
+ ),
574
+ /* @__PURE__ */ jsx(
575
+ Client,
576
+ {
577
+ name: client.name,
578
+ isExportable: false,
579
+ isIndexable: false,
580
+ baseURL: options.baseURL,
581
+ operation,
582
+ typeSchemas: type.schemas,
583
+ zodSchemas: zod.schemas,
584
+ dataReturnType: options.client.dataReturnType,
585
+ pathParamsType: options.pathParamsType,
586
+ parser: options.parser
587
+ }
588
+ ),
589
+ /* @__PURE__ */ jsx(
590
+ QueryOptions,
591
+ {
592
+ name: queryOptions.name,
593
+ clientName: client.name,
594
+ queryKeyName: queryKey.name,
595
+ typeSchemas: type.schemas,
596
+ pathParamsType: options.pathParamsType
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsx(
600
+ SuspenseQuery,
601
+ {
602
+ name: query.name,
603
+ queryOptionsName: queryOptions.name,
604
+ typeSchemas: type.schemas,
605
+ pathParamsType: options.pathParamsType,
606
+ operation,
607
+ dataReturnType: options.client.dataReturnType,
608
+ queryKeyName: queryKey.name,
609
+ queryKeyTypeName: queryKey.typeName
610
+ }
611
+ )
612
+ ] });
613
+ }
614
+ });
615
+
616
+ export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator };
617
+ //# sourceMappingURL=chunk-2D27Y6L5.js.map
618
+ //# sourceMappingURL=chunk-2D27Y6L5.js.map