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

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