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

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