@kubb/plugin-react-query 3.0.0-alpha.9 → 3.0.0-beta.2

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