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

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