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

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