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

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