@kubb/plugin-react-query 3.0.0-alpha.3 → 3.0.0-alpha.30

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