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