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