@kubb/plugin-react-query 3.0.0-alpha.15 → 3.0.0-alpha.16

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