@kubb/plugin-react-query 3.16.1 → 3.16.3

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 (38) hide show
  1. package/dist/components-CuByb-hX.js +903 -0
  2. package/dist/components-CuByb-hX.js.map +1 -0
  3. package/dist/components-DHfUELJ3.cjs +979 -0
  4. package/dist/components-DHfUELJ3.cjs.map +1 -0
  5. package/dist/components.cjs +10 -40
  6. package/dist/components.d.cts +306 -146
  7. package/dist/components.d.ts +306 -146
  8. package/dist/components.js +3 -3
  9. package/dist/generators-CNHKYwqU.js +722 -0
  10. package/dist/generators-CNHKYwqU.js.map +1 -0
  11. package/dist/generators-kx0B_Nkc.cjs +745 -0
  12. package/dist/{chunk-2LUZUNTA.js.map → generators-kx0B_Nkc.cjs.map} +1 -1
  13. package/dist/generators.cjs +6 -24
  14. package/dist/generators.d.cts +14 -13
  15. package/dist/generators.d.ts +14 -13
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +120 -145
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -8
  20. package/dist/index.d.ts +6 -8
  21. package/dist/index.js +120 -139
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-5X0s8utE.d.cts +1391 -0
  24. package/dist/types-BTEmPwHJ.d.ts +1391 -0
  25. package/package.json +25 -30
  26. package/dist/chunk-2LUZUNTA.js +0 -588
  27. package/dist/chunk-7VVTPMRL.cjs +0 -788
  28. package/dist/chunk-7VVTPMRL.cjs.map +0 -1
  29. package/dist/chunk-LT467H44.js +0 -779
  30. package/dist/chunk-LT467H44.js.map +0 -1
  31. package/dist/chunk-PIAL3C5M.cjs +0 -593
  32. package/dist/chunk-PIAL3C5M.cjs.map +0 -1
  33. package/dist/components.cjs.map +0 -1
  34. package/dist/components.js.map +0 -1
  35. package/dist/generators.cjs.map +0 -1
  36. package/dist/generators.js.map +0 -1
  37. package/dist/types-BdjqYAq1.d.cts +0 -170
  38. package/dist/types-BdjqYAq1.d.ts +0 -170
@@ -1,593 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk7VVTPMRL_cjs = require('./chunk-7VVTPMRL.cjs');
4
- var pluginClient = require('@kubb/plugin-client');
5
- var components = require('@kubb/plugin-client/components');
6
- var pluginOas = require('@kubb/plugin-oas');
7
- var hooks = require('@kubb/plugin-oas/hooks');
8
- var utils = require('@kubb/plugin-oas/utils');
9
- var pluginTs = require('@kubb/plugin-ts');
10
- var pluginZod = require('@kubb/plugin-zod');
11
- var react = require('@kubb/react');
12
- var remeda = require('remeda');
13
- var jsxRuntime = require('@kubb/react/jsx-runtime');
14
-
15
- var queryGenerator = pluginOas.createReactGenerator({
16
- name: "react-query",
17
- Operation({ options, operation }) {
18
- const {
19
- plugin: {
20
- options: { output }
21
- },
22
- pluginManager
23
- } = react.useApp();
24
- const oas = hooks.useOas();
25
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
26
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
27
- const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
28
- (method) => operation.method === method
29
- );
30
- const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
31
- const query = {
32
- name: getName(operation, { type: "function", prefix: "use" }),
33
- typeName: getName(operation, { type: "type" }),
34
- file: getFile(operation, { prefix: "use" })
35
- };
36
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
37
- const client = {
38
- name: hasClientPlugin ? getName(operation, {
39
- type: "function",
40
- pluginKey: [pluginClient.pluginClientName]
41
- }) : getName(operation, {
42
- type: "function"
43
- }),
44
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
45
- };
46
- const queryOptions = {
47
- name: getName(operation, { type: "function", suffix: "QueryOptions" })
48
- };
49
- const queryKey = {
50
- name: getName(operation, { type: "const", suffix: "QueryKey" }),
51
- typeName: getName(operation, { type: "type", suffix: "QueryKey" })
52
- };
53
- const type = {
54
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
55
- //todo remove type?
56
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
57
- };
58
- const zod = {
59
- // grouping is coming from react-query instead of zod option, we need to pass the options of zod instead
60
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
61
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
62
- };
63
- if (!isQuery || isMutation) {
64
- return null;
65
- }
66
- return /* @__PURE__ */ jsxRuntime.jsxs(
67
- react.File,
68
- {
69
- baseName: query.file.baseName,
70
- path: query.file.path,
71
- meta: query.file.meta,
72
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
73
- footer: utils.getFooter({ oas, output }),
74
- children: [
75
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
76
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
77
- hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
78
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
79
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
80
- /* @__PURE__ */ jsxRuntime.jsx(
81
- react.File.Import,
82
- {
83
- name: [
84
- type.schemas.request?.name,
85
- type.schemas.response.name,
86
- type.schemas.pathParams?.name,
87
- type.schemas.queryParams?.name,
88
- type.schemas.headerParams?.name,
89
- ...type.schemas.statusCodes?.map((item) => item.name) || []
90
- ].filter(Boolean),
91
- root: query.file.path,
92
- path: type.file.path,
93
- isTypeOnly: true
94
- }
95
- ),
96
- /* @__PURE__ */ jsxRuntime.jsx(
97
- chunk7VVTPMRL_cjs.QueryKey,
98
- {
99
- name: queryKey.name,
100
- typeName: queryKey.typeName,
101
- operation,
102
- pathParamsType: options.pathParamsType,
103
- typeSchemas: type.schemas,
104
- paramsCasing: options.paramsCasing,
105
- transformer: options.queryKey
106
- }
107
- ),
108
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
109
- components.Client,
110
- {
111
- name: client.name,
112
- baseURL: options.client.baseURL,
113
- operation,
114
- typeSchemas: type.schemas,
115
- zodSchemas: zod.schemas,
116
- dataReturnType: options.client.dataReturnType,
117
- paramsType: options.paramsType,
118
- paramsCasing: options.paramsCasing,
119
- pathParamsType: options.pathParamsType,
120
- parser: options.parser
121
- }
122
- ),
123
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
124
- /* @__PURE__ */ jsxRuntime.jsx(
125
- chunk7VVTPMRL_cjs.QueryOptions,
126
- {
127
- name: queryOptions.name,
128
- clientName: client.name,
129
- queryKeyName: queryKey.name,
130
- typeSchemas: type.schemas,
131
- paramsCasing: options.paramsCasing,
132
- paramsType: options.paramsType,
133
- pathParamsType: options.pathParamsType,
134
- dataReturnType: options.client.dataReturnType
135
- }
136
- ),
137
- options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
138
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useQuery"], path: importPath }),
139
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryClient", "QueryObserverOptions", "UseQueryResult", "QueryClient"], path: importPath, isTypeOnly: true }),
140
- /* @__PURE__ */ jsxRuntime.jsx(
141
- chunk7VVTPMRL_cjs.Query,
142
- {
143
- name: query.name,
144
- queryOptionsName: queryOptions.name,
145
- typeSchemas: type.schemas,
146
- paramsCasing: options.paramsCasing,
147
- paramsType: options.paramsType,
148
- pathParamsType: options.pathParamsType,
149
- operation,
150
- dataReturnType: options.client.dataReturnType,
151
- queryKeyName: queryKey.name,
152
- queryKeyTypeName: queryKey.typeName
153
- }
154
- )
155
- ] })
156
- ]
157
- }
158
- );
159
- }
160
- });
161
- var mutationGenerator = pluginOas.createReactGenerator({
162
- name: "react-query",
163
- Operation({ options, operation }) {
164
- const {
165
- plugin: {
166
- options: { output }
167
- },
168
- pluginManager
169
- } = react.useApp();
170
- const oas = hooks.useOas();
171
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
172
- const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
173
- const isMutation = !isQuery && remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
174
- const importPath = options.mutation ? options.mutation.importPath : "@tanstack/react-query";
175
- const mutation = {
176
- name: getName(operation, { type: "function", prefix: "use" }),
177
- typeName: getName(operation, { type: "type" }),
178
- file: getFile(operation, { prefix: "use" })
179
- };
180
- const type = {
181
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
182
- //todo remove type?
183
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
184
- };
185
- const zod = {
186
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
187
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
188
- };
189
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
190
- const client = {
191
- name: hasClientPlugin ? getName(operation, {
192
- type: "function",
193
- pluginKey: [pluginClient.pluginClientName]
194
- }) : getName(operation, {
195
- type: "function"
196
- }),
197
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
198
- };
199
- const mutationKey = {
200
- name: getName(operation, { type: "const", suffix: "MutationKey" }),
201
- typeName: getName(operation, { type: "type", suffix: "MutationKey" })
202
- };
203
- if (!isMutation) {
204
- return null;
205
- }
206
- return /* @__PURE__ */ jsxRuntime.jsxs(
207
- react.File,
208
- {
209
- baseName: mutation.file.baseName,
210
- path: mutation.file.path,
211
- meta: mutation.file.meta,
212
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
213
- footer: utils.getFooter({ oas, output }),
214
- children: [
215
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: mutation.file.path, path: zod.file.path }),
216
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
217
- !!hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: mutation.file.path, path: client.file.path }),
218
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
219
- /* @__PURE__ */ jsxRuntime.jsx(
220
- react.File.Import,
221
- {
222
- name: [
223
- type.schemas.request?.name,
224
- type.schemas.response.name,
225
- type.schemas.pathParams?.name,
226
- type.schemas.queryParams?.name,
227
- type.schemas.headerParams?.name,
228
- ...type.schemas.statusCodes?.map((item) => item.name) || []
229
- ].filter(Boolean),
230
- root: mutation.file.path,
231
- path: type.file.path,
232
- isTypeOnly: true
233
- }
234
- ),
235
- /* @__PURE__ */ jsxRuntime.jsx(
236
- chunk7VVTPMRL_cjs.MutationKey,
237
- {
238
- name: mutationKey.name,
239
- typeName: mutationKey.typeName,
240
- operation,
241
- pathParamsType: options.pathParamsType,
242
- typeSchemas: type.schemas,
243
- paramsCasing: options.paramsCasing,
244
- transformer: options.mutationKey
245
- }
246
- ),
247
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
248
- components.Client,
249
- {
250
- name: client.name,
251
- baseURL: options.client.baseURL,
252
- operation,
253
- typeSchemas: type.schemas,
254
- zodSchemas: zod.schemas,
255
- dataReturnType: options.client.dataReturnType,
256
- paramsCasing: options.paramsCasing,
257
- paramsType: options.paramsType,
258
- pathParamsType: options.pathParamsType,
259
- parser: options.parser
260
- }
261
- ),
262
- options.mutation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
263
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useMutation"], path: importPath }),
264
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["UseMutationOptions", "QueryClient"], path: importPath, isTypeOnly: true }),
265
- /* @__PURE__ */ jsxRuntime.jsx(
266
- chunk7VVTPMRL_cjs.Mutation,
267
- {
268
- name: mutation.name,
269
- clientName: client.name,
270
- typeName: mutation.typeName,
271
- typeSchemas: type.schemas,
272
- operation,
273
- dataReturnType: options.client.dataReturnType,
274
- paramsCasing: options.paramsCasing,
275
- paramsType: options.paramsType,
276
- pathParamsType: options.pathParamsType,
277
- mutationKeyName: mutationKey.name
278
- }
279
- )
280
- ] })
281
- ]
282
- }
283
- );
284
- }
285
- });
286
- var infiniteQueryGenerator = pluginOas.createReactGenerator({
287
- name: "react-infinite-query",
288
- Operation({ options, operation }) {
289
- const {
290
- plugin: {
291
- options: { output }
292
- },
293
- pluginManager
294
- } = react.useApp();
295
- const oas = hooks.useOas();
296
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
297
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
298
- const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
299
- (method) => operation.method === method
300
- );
301
- const isInfinite = !!options.infinite;
302
- const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
303
- const query = {
304
- name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
305
- typeName: getName(operation, { type: "type" }),
306
- file: getFile(operation, { prefix: "use", suffix: "infinite" })
307
- };
308
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
309
- const client = {
310
- name: hasClientPlugin ? getName(operation, {
311
- type: "function",
312
- pluginKey: [pluginClient.pluginClientName]
313
- }) : getName(operation, {
314
- type: "function",
315
- suffix: "infinite"
316
- }),
317
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
318
- };
319
- const queryOptions = {
320
- name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" })
321
- };
322
- const queryKey = {
323
- name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }),
324
- typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" })
325
- };
326
- const type = {
327
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
328
- //todo remove type?
329
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
330
- };
331
- const zod = {
332
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
333
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
334
- };
335
- if (!isQuery || isMutation || !isInfinite) {
336
- return null;
337
- }
338
- return /* @__PURE__ */ jsxRuntime.jsxs(
339
- react.File,
340
- {
341
- baseName: query.file.baseName,
342
- path: query.file.path,
343
- meta: query.file.meta,
344
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
345
- footer: utils.getFooter({ oas, output }),
346
- children: [
347
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
348
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
349
- hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
350
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
351
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
352
- /* @__PURE__ */ jsxRuntime.jsx(
353
- react.File.Import,
354
- {
355
- name: [
356
- type.schemas.request?.name,
357
- type.schemas.response.name,
358
- type.schemas.pathParams?.name,
359
- type.schemas.queryParams?.name,
360
- type.schemas.headerParams?.name,
361
- ...type.schemas.statusCodes?.map((item) => item.name) || []
362
- ].filter(Boolean),
363
- root: query.file.path,
364
- path: type.file.path,
365
- isTypeOnly: true
366
- }
367
- ),
368
- /* @__PURE__ */ jsxRuntime.jsx(
369
- chunk7VVTPMRL_cjs.QueryKey,
370
- {
371
- name: queryKey.name,
372
- typeName: queryKey.typeName,
373
- operation,
374
- paramsCasing: options.paramsCasing,
375
- pathParamsType: options.pathParamsType,
376
- typeSchemas: type.schemas,
377
- transformer: options.queryKey
378
- }
379
- ),
380
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
381
- components.Client,
382
- {
383
- name: client.name,
384
- baseURL: options.client.baseURL,
385
- operation,
386
- typeSchemas: type.schemas,
387
- zodSchemas: zod.schemas,
388
- dataReturnType: options.client.dataReturnType,
389
- paramsCasing: options.paramsCasing,
390
- paramsType: options.paramsType,
391
- pathParamsType: options.pathParamsType,
392
- parser: options.parser
393
- }
394
- ),
395
- options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
396
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["InfiniteData"], isTypeOnly: true, path: importPath }),
397
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["infiniteQueryOptions"], path: importPath }),
398
- /* @__PURE__ */ jsxRuntime.jsx(
399
- chunk7VVTPMRL_cjs.InfiniteQueryOptions,
400
- {
401
- name: queryOptions.name,
402
- clientName: client.name,
403
- queryKeyName: queryKey.name,
404
- typeSchemas: type.schemas,
405
- paramsCasing: options.paramsCasing,
406
- paramsType: options.paramsType,
407
- pathParamsType: options.pathParamsType,
408
- dataReturnType: options.client.dataReturnType,
409
- cursorParam: options.infinite.cursorParam,
410
- initialPageParam: options.infinite.initialPageParam,
411
- queryParam: options.infinite.queryParam
412
- }
413
- )
414
- ] }),
415
- options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
416
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useInfiniteQuery"], path: importPath }),
417
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryClient", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: importPath, isTypeOnly: true }),
418
- /* @__PURE__ */ jsxRuntime.jsx(
419
- chunk7VVTPMRL_cjs.InfiniteQuery,
420
- {
421
- name: query.name,
422
- queryOptionsName: queryOptions.name,
423
- typeSchemas: type.schemas,
424
- paramsCasing: options.paramsCasing,
425
- paramsType: options.paramsType,
426
- pathParamsType: options.pathParamsType,
427
- operation,
428
- dataReturnType: options.client.dataReturnType,
429
- queryKeyName: queryKey.name,
430
- queryKeyTypeName: queryKey.typeName
431
- }
432
- )
433
- ] })
434
- ]
435
- }
436
- );
437
- }
438
- });
439
- var suspenseQueryGenerator = pluginOas.createReactGenerator({
440
- name: "react-suspense-query",
441
- Operation({ options, operation }) {
442
- const {
443
- plugin: {
444
- options: { output }
445
- },
446
- pluginManager
447
- } = react.useApp();
448
- const oas = hooks.useOas();
449
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
450
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
451
- const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
452
- (method) => operation.method === method
453
- );
454
- const isSuspense = !!options.suspense;
455
- const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
456
- const query = {
457
- name: getName(operation, { type: "function", prefix: "use", suffix: "suspense" }),
458
- typeName: getName(operation, { type: "type" }),
459
- file: getFile(operation, { prefix: "use", suffix: "suspense" })
460
- };
461
- const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClient.pluginClientName]);
462
- const client = {
463
- name: hasClientPlugin ? getName(operation, {
464
- type: "function",
465
- pluginKey: [pluginClient.pluginClientName]
466
- }) : getName(operation, {
467
- type: "function",
468
- suffix: "suspense"
469
- }),
470
- file: getFile(operation, { pluginKey: [pluginClient.pluginClientName] })
471
- };
472
- const queryOptions = {
473
- name: getName(operation, { type: "function", suffix: "SuspenseQueryOptions" })
474
- };
475
- const queryKey = {
476
- name: getName(operation, { type: "const", suffix: "SuspenseQueryKey" }),
477
- typeName: getName(operation, { type: "type", suffix: "SuspenseQueryKey" })
478
- };
479
- const type = {
480
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
481
- //todo remove type?
482
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
483
- };
484
- const zod = {
485
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
486
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
487
- };
488
- if (!isQuery || isMutation || !isSuspense) {
489
- return null;
490
- }
491
- return /* @__PURE__ */ jsxRuntime.jsxs(
492
- react.File,
493
- {
494
- baseName: query.file.baseName,
495
- path: query.file.path,
496
- meta: query.file.meta,
497
- banner: utils.getBanner({ oas, output, config: pluginManager.config }),
498
- footer: utils.getFooter({ oas, output }),
499
- children: [
500
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean), root: query.file.path, path: zod.file.path }),
501
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "fetch", path: options.client.importPath }),
502
- hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: query.file.path, path: client.file.path }),
503
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
504
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
505
- /* @__PURE__ */ jsxRuntime.jsx(
506
- react.File.Import,
507
- {
508
- name: [
509
- type.schemas.request?.name,
510
- type.schemas.response.name,
511
- type.schemas.pathParams?.name,
512
- type.schemas.queryParams?.name,
513
- type.schemas.headerParams?.name,
514
- ...type.schemas.statusCodes?.map((item) => item.name) || []
515
- ].filter(Boolean),
516
- root: query.file.path,
517
- path: type.file.path,
518
- isTypeOnly: true
519
- }
520
- ),
521
- /* @__PURE__ */ jsxRuntime.jsx(
522
- chunk7VVTPMRL_cjs.QueryKey,
523
- {
524
- name: queryKey.name,
525
- typeName: queryKey.typeName,
526
- operation,
527
- paramsCasing: options.paramsCasing,
528
- pathParamsType: options.pathParamsType,
529
- typeSchemas: type.schemas,
530
- transformer: options.queryKey
531
- }
532
- ),
533
- !hasClientPlugin && /* @__PURE__ */ jsxRuntime.jsx(
534
- components.Client,
535
- {
536
- name: client.name,
537
- baseURL: options.client.baseURL,
538
- operation,
539
- typeSchemas: type.schemas,
540
- zodSchemas: zod.schemas,
541
- dataReturnType: options.client.dataReturnType,
542
- paramsCasing: options.paramsCasing,
543
- paramsType: options.paramsType,
544
- pathParamsType: options.pathParamsType,
545
- parser: options.parser
546
- }
547
- ),
548
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
549
- /* @__PURE__ */ jsxRuntime.jsx(
550
- chunk7VVTPMRL_cjs.QueryOptions,
551
- {
552
- name: queryOptions.name,
553
- clientName: client.name,
554
- queryKeyName: queryKey.name,
555
- typeSchemas: type.schemas,
556
- paramsCasing: options.paramsCasing,
557
- paramsType: options.paramsType,
558
- pathParamsType: options.pathParamsType,
559
- dataReturnType: options.client.dataReturnType
560
- }
561
- ),
562
- options.suspense && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
563
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useSuspenseQuery"], path: importPath }),
564
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryClient", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: importPath, isTypeOnly: true }),
565
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
566
- /* @__PURE__ */ jsxRuntime.jsx(
567
- chunk7VVTPMRL_cjs.SuspenseQuery,
568
- {
569
- name: query.name,
570
- queryOptionsName: queryOptions.name,
571
- typeSchemas: type.schemas,
572
- paramsType: options.paramsType,
573
- paramsCasing: options.paramsCasing,
574
- pathParamsType: options.pathParamsType,
575
- operation,
576
- dataReturnType: options.client.dataReturnType,
577
- queryKeyName: queryKey.name,
578
- queryKeyTypeName: queryKey.typeName
579
- }
580
- )
581
- ] })
582
- ]
583
- }
584
- );
585
- }
586
- });
587
-
588
- exports.infiniteQueryGenerator = infiniteQueryGenerator;
589
- exports.mutationGenerator = mutationGenerator;
590
- exports.queryGenerator = queryGenerator;
591
- exports.suspenseQueryGenerator = suspenseQueryGenerator;
592
- //# sourceMappingURL=chunk-PIAL3C5M.cjs.map
593
- //# sourceMappingURL=chunk-PIAL3C5M.cjs.map