@kubb/plugin-react-query 4.4.0 → 4.5.0

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 (34) hide show
  1. package/dist/{components-CbVTS6aF.js → components-By3fyxDp.js} +2 -2
  2. package/dist/{components-CbVTS6aF.js.map → components-By3fyxDp.js.map} +1 -1
  3. package/dist/{components-B_-p18Ak.cjs → components-DtLglQ1w.cjs} +3 -3
  4. package/dist/{components-B_-p18Ak.cjs.map → components-DtLglQ1w.cjs.map} +1 -1
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.cts +1 -1
  7. package/dist/components.d.ts +1 -1
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-hTZEzfNP.cjs → generators-BIuKpozF.cjs} +260 -182
  10. package/dist/generators-BIuKpozF.cjs.map +1 -0
  11. package/dist/{generators-egdl4EOg.js → generators-BTb-fJYl.js} +257 -180
  12. package/dist/generators-BTb-fJYl.js.map +1 -0
  13. package/dist/generators.cjs +2 -2
  14. package/dist/generators.d.cts +5 -5
  15. package/dist/generators.d.ts +5 -5
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +17 -3
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +15 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-L74GEs-s.d.cts → types-DgN61fGy.d.ts} +189 -311
  24. package/dist/{types-CsOfyJFc.d.ts → types-XOFOCTil.d.cts} +189 -311
  25. package/package.json +18 -14
  26. package/src/generators/index.ts +2 -2
  27. package/src/generators/infiniteQueryGenerator.tsx +36 -11
  28. package/src/generators/mutationGenerator.tsx +35 -10
  29. package/src/generators/queryGenerator.tsx +36 -11
  30. package/src/generators/suspenseQueryGenerator.tsx +34 -11
  31. package/src/plugin.ts +22 -1
  32. package/src/types.ts +4 -3
  33. package/dist/generators-egdl4EOg.js.map +0 -1
  34. package/dist/generators-hTZEzfNP.cjs.map +0 -1
@@ -1,55 +1,64 @@
1
- import { a as MutationKey, c as QueryOptions, i as MutationOptions, l as QueryKey, n as Query, o as InfiniteQueryOptions, r as Mutation, s as InfiniteQuery, t as SuspenseQuery } from "./components-CbVTS6aF.js";
2
- import { createReactGenerator } from "@kubb/plugin-oas";
1
+ import { a as MutationKey, c as QueryOptions, i as MutationOptions, l as QueryKey, n as Query, o as InfiniteQueryOptions, r as Mutation, s as InfiniteQuery, t as SuspenseQuery } from "./components-By3fyxDp.js";
2
+ import path from "node:path";
3
+ import { pluginClientName } from "@kubb/plugin-client";
3
4
  import { pluginTsName } from "@kubb/plugin-ts";
4
5
  import { pluginZodName } from "@kubb/plugin-zod";
5
6
  import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
6
7
  import { File } from "@kubb/react-fabric";
7
8
  import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
8
9
  import { Client } from "@kubb/plugin-client/components";
9
- import { usePlugin, usePluginManager } from "@kubb/core/hooks";
10
- import { pluginClientName } from "@kubb/plugin-client";
10
+ import { usePluginManager } from "@kubb/core/hooks";
11
+ import { createReactGenerator } from "@kubb/plugin-oas/generators";
11
12
  import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
12
13
  import { difference } from "remeda";
13
14
 
14
- //#region src/generators/queryGenerator.tsx
15
- const queryGenerator = createReactGenerator({
16
- name: "react-query",
17
- Operation({ options, operation }) {
18
- const { options: { output } } = usePlugin();
15
+ //#region src/generators/infiniteQueryGenerator.tsx
16
+ const infiniteQueryGenerator = createReactGenerator({
17
+ name: "react-infinite-query",
18
+ Operation({ config, operation, generator, plugin }) {
19
+ const { options, options: { output } } = plugin;
19
20
  const pluginManager = usePluginManager();
20
21
  const oas = useOas();
21
- const { getSchemas, getName, getFile } = useOperationManager();
22
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
22
23
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
23
24
  const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
25
+ const infiniteOptions = options.infinite && typeof options.infinite === "object" ? options.infinite : void 0;
24
26
  const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
25
27
  const query = {
26
28
  name: getName(operation, {
27
29
  type: "function",
28
- prefix: "use"
30
+ prefix: "use",
31
+ suffix: "infinite"
29
32
  }),
30
33
  typeName: getName(operation, { type: "type" }),
31
- file: getFile(operation, { prefix: "use" })
34
+ file: getFile(operation, {
35
+ prefix: "use",
36
+ suffix: "infinite"
37
+ })
32
38
  };
33
39
  const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
34
40
  const client = {
35
41
  name: hasClientPlugin ? getName(operation, {
36
42
  type: "function",
37
43
  pluginKey: [pluginClientName]
38
- }) : getName(operation, { type: "function" }),
44
+ }) : getName(operation, {
45
+ type: "function",
46
+ suffix: "infinite"
47
+ }),
39
48
  file: getFile(operation, { pluginKey: [pluginClientName] })
40
49
  };
41
50
  const queryOptions = { name: getName(operation, {
42
51
  type: "function",
43
- suffix: "QueryOptions"
52
+ suffix: "InfiniteQueryOptions"
44
53
  }) };
45
54
  const queryKey = {
46
55
  name: getName(operation, {
47
56
  type: "const",
48
- suffix: "QueryKey"
57
+ suffix: "InfiniteQueryKey"
49
58
  }),
50
59
  typeName: getName(operation, {
51
60
  type: "type",
52
- suffix: "QueryKey"
61
+ suffix: "InfiniteQueryKey"
53
62
  })
54
63
  };
55
64
  const type = {
@@ -66,7 +75,15 @@ const queryGenerator = createReactGenerator({
66
75
  type: "function"
67
76
  })
68
77
  };
69
- if (!isQuery || isMutation) return null;
78
+ if (!isQuery || isMutation || !infiniteOptions) return null;
79
+ const normalizeKey = (key) => (key ?? "").replace(/\?$/, "");
80
+ const queryParam = infiniteOptions.queryParam;
81
+ const cursorParam = infiniteOptions.cursorParam;
82
+ const queryParamKeys = type.schemas.queryParams?.keys ?? [];
83
+ const responseKeys = [...type.schemas.responses?.flatMap((item) => item.keys ?? []) ?? [], ...type.schemas.response?.keys ?? []];
84
+ const hasQueryParam = queryParam ? queryParamKeys.some((key) => normalizeKey(key) === queryParam) : false;
85
+ const hasCursorParam = cursorParam ? responseKeys.some((key) => normalizeKey(key) === cursorParam) : true;
86
+ if (!hasQueryParam || !hasCursorParam) return null;
70
87
  return /* @__PURE__ */ jsxs(File, {
71
88
  baseName: query.file.baseName,
72
89
  path: query.file.path,
@@ -86,25 +103,45 @@ const queryGenerator = createReactGenerator({
86
103
  root: query.file.path,
87
104
  path: zod.file.path
88
105
  }),
89
- /* @__PURE__ */ jsx(File.Import, {
90
- name: "fetch",
91
- path: options.client.importPath
92
- }),
106
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
107
+ /* @__PURE__ */ jsx(File.Import, {
108
+ name: "fetch",
109
+ path: options.client.importPath
110
+ }),
111
+ /* @__PURE__ */ jsx(File.Import, {
112
+ name: ["RequestConfig", "ResponseErrorConfig"],
113
+ path: options.client.importPath,
114
+ isTypeOnly: true
115
+ }),
116
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
117
+ name: ["ResponseConfig"],
118
+ path: options.client.importPath,
119
+ isTypeOnly: true
120
+ })
121
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
122
+ /* @__PURE__ */ jsx(File.Import, {
123
+ name: "fetch",
124
+ root: query.file.path,
125
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
126
+ }),
127
+ /* @__PURE__ */ jsx(File.Import, {
128
+ name: ["RequestConfig", "ResponseErrorConfig"],
129
+ root: query.file.path,
130
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
131
+ isTypeOnly: true
132
+ }),
133
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
134
+ name: ["ResponseConfig"],
135
+ root: query.file.path,
136
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
137
+ isTypeOnly: true
138
+ })
139
+ ] }),
93
140
  hasClientPlugin && /* @__PURE__ */ jsx(File.Import, {
94
141
  name: [client.name],
95
142
  root: query.file.path,
96
143
  path: client.file.path
97
144
  }),
98
- /* @__PURE__ */ jsx(File.Import, {
99
- name: ["RequestConfig", "ResponseErrorConfig"],
100
- path: options.client.importPath,
101
- isTypeOnly: true
102
- }),
103
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
104
- name: ["ResponseConfig"],
105
- path: options.client.importPath,
106
- isTypeOnly: true
107
- }),
108
145
  /* @__PURE__ */ jsx(File.Import, {
109
146
  name: [
110
147
  type.schemas.request?.name,
@@ -122,9 +159,9 @@ const queryGenerator = createReactGenerator({
122
159
  name: queryKey.name,
123
160
  typeName: queryKey.typeName,
124
161
  operation,
162
+ paramsCasing: options.paramsCasing,
125
163
  pathParamsType: options.pathParamsType,
126
164
  typeSchemas: type.schemas,
127
- paramsCasing: options.paramsCasing,
128
165
  transformer: options.queryKey
129
166
  }),
130
167
  !hasClientPlugin && /* @__PURE__ */ jsx(Client, {
@@ -133,43 +170,52 @@ const queryGenerator = createReactGenerator({
133
170
  operation,
134
171
  typeSchemas: type.schemas,
135
172
  zodSchemas: zod.schemas,
136
- dataReturnType: options.client.dataReturnType,
137
- paramsType: options.paramsType,
138
- paramsCasing: options.paramsCasing,
139
- pathParamsType: options.pathParamsType,
140
- parser: options.parser
141
- }),
142
- /* @__PURE__ */ jsx(File.Import, {
143
- name: ["queryOptions"],
144
- path: importPath
145
- }),
146
- /* @__PURE__ */ jsx(QueryOptions, {
147
- name: queryOptions.name,
148
- clientName: client.name,
149
- queryKeyName: queryKey.name,
150
- typeSchemas: type.schemas,
173
+ dataReturnType: options.client.dataReturnType || "data",
151
174
  paramsCasing: options.paramsCasing,
152
175
  paramsType: options.paramsType,
153
176
  pathParamsType: options.pathParamsType,
154
- dataReturnType: options.client.dataReturnType
177
+ parser: options.parser
155
178
  }),
156
- options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
179
+ infiniteOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
157
180
  /* @__PURE__ */ jsx(File.Import, {
158
- name: ["useQuery"],
181
+ name: ["InfiniteData"],
182
+ isTypeOnly: true,
183
+ path: importPath
184
+ }),
185
+ /* @__PURE__ */ jsx(File.Import, {
186
+ name: ["infiniteQueryOptions"],
187
+ path: importPath
188
+ }),
189
+ /* @__PURE__ */ jsx(InfiniteQueryOptions, {
190
+ name: queryOptions.name,
191
+ clientName: client.name,
192
+ queryKeyName: queryKey.name,
193
+ typeSchemas: type.schemas,
194
+ paramsCasing: options.paramsCasing,
195
+ paramsType: options.paramsType,
196
+ pathParamsType: options.pathParamsType,
197
+ dataReturnType: options.client.dataReturnType || "data",
198
+ cursorParam: infiniteOptions.cursorParam,
199
+ initialPageParam: infiniteOptions.initialPageParam,
200
+ queryParam: infiniteOptions.queryParam
201
+ })
202
+ ] }),
203
+ infiniteOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
204
+ /* @__PURE__ */ jsx(File.Import, {
205
+ name: ["useInfiniteQuery"],
159
206
  path: importPath
160
207
  }),
161
208
  /* @__PURE__ */ jsx(File.Import, {
162
209
  name: [
163
210
  "QueryKey",
164
211
  "QueryClient",
165
- "QueryObserverOptions",
166
- "UseQueryResult",
167
- "QueryClient"
212
+ "InfiniteQueryObserverOptions",
213
+ "UseInfiniteQueryResult"
168
214
  ],
169
215
  path: importPath,
170
216
  isTypeOnly: true
171
217
  }),
172
- /* @__PURE__ */ jsx(Query, {
218
+ /* @__PURE__ */ jsx(InfiniteQuery, {
173
219
  name: query.name,
174
220
  queryOptionsName: queryOptions.name,
175
221
  typeSchemas: type.schemas,
@@ -177,9 +223,11 @@ const queryGenerator = createReactGenerator({
177
223
  paramsType: options.paramsType,
178
224
  pathParamsType: options.pathParamsType,
179
225
  operation,
180
- dataReturnType: options.client.dataReturnType,
226
+ dataReturnType: options.client.dataReturnType || "data",
181
227
  queryKeyName: queryKey.name,
182
- queryKeyTypeName: queryKey.typeName
228
+ queryKeyTypeName: queryKey.typeName,
229
+ initialPageParam: infiniteOptions.initialPageParam,
230
+ queryParam: infiniteOptions.queryParam
183
231
  })
184
232
  ] })
185
233
  ]
@@ -191,11 +239,11 @@ const queryGenerator = createReactGenerator({
191
239
  //#region src/generators/mutationGenerator.tsx
192
240
  const mutationGenerator = createReactGenerator({
193
241
  name: "react-query",
194
- Operation({ options, operation }) {
195
- const { options: { output } } = usePlugin();
242
+ Operation({ config, plugin, operation, generator }) {
243
+ const { options, options: { output } } = plugin;
196
244
  const pluginManager = usePluginManager();
197
245
  const oas = useOas();
198
- const { getSchemas, getName, getFile } = useOperationManager();
246
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
199
247
  const isMutation = !(!!options.query && options.query?.methods.some((method) => operation.method === method)) && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
200
248
  const importPath = options.mutation ? options.mutation.importPath : "@tanstack/react-query";
201
249
  const mutation = {
@@ -262,24 +310,45 @@ const mutationGenerator = createReactGenerator({
262
310
  root: mutation.file.path,
263
311
  path: zod.file.path
264
312
  }),
265
- /* @__PURE__ */ jsx(File.Import, {
266
- name: "fetch",
267
- path: options.client.importPath
268
- }),
313
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
314
+ /* @__PURE__ */ jsx(File.Import, {
315
+ name: "fetch",
316
+ path: options.client.importPath
317
+ }),
318
+ /* @__PURE__ */ jsx(File.Import, {
319
+ name: ["RequestConfig", "ResponseErrorConfig"],
320
+ path: options.client.importPath,
321
+ isTypeOnly: true
322
+ }),
323
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
324
+ name: ["ResponseConfig"],
325
+ path: options.client.importPath,
326
+ isTypeOnly: true
327
+ })
328
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
329
+ /* @__PURE__ */ jsx(File.Import, {
330
+ name: "fetch",
331
+ root: mutation.file.path,
332
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
333
+ }),
334
+ /* @__PURE__ */ jsx(File.Import, {
335
+ name: ["RequestConfig", "ResponseErrorConfig"],
336
+ root: mutation.file.path,
337
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
338
+ isTypeOnly: true
339
+ }),
340
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
341
+ name: ["ResponseConfig"],
342
+ root: mutation.file.path,
343
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
344
+ isTypeOnly: true
345
+ })
346
+ ] }),
269
347
  !!hasClientPlugin && /* @__PURE__ */ jsx(File.Import, {
270
348
  name: [client.name],
271
349
  root: mutation.file.path,
272
350
  path: client.file.path
273
351
  }),
274
- /* @__PURE__ */ jsx(File.Import, {
275
- name: [
276
- "RequestConfig",
277
- "ResponseConfig",
278
- "ResponseErrorConfig"
279
- ],
280
- path: options.client.importPath,
281
- isTypeOnly: true
282
- }),
283
352
  /* @__PURE__ */ jsx(File.Import, {
284
353
  name: [
285
354
  type.schemas.request?.name,
@@ -308,7 +377,7 @@ const mutationGenerator = createReactGenerator({
308
377
  operation,
309
378
  typeSchemas: type.schemas,
310
379
  zodSchemas: zod.schemas,
311
- dataReturnType: options.client.dataReturnType,
380
+ dataReturnType: options.client.dataReturnType || "data",
312
381
  paramsCasing: options.paramsCasing,
313
382
  paramsType: options.paramsType,
314
383
  pathParamsType: options.pathParamsType,
@@ -326,7 +395,7 @@ const mutationGenerator = createReactGenerator({
326
395
  paramsCasing: options.paramsCasing,
327
396
  paramsType: options.paramsType,
328
397
  pathParamsType: options.pathParamsType,
329
- dataReturnType: options.client.dataReturnType
398
+ dataReturnType: options.client.dataReturnType || "data"
330
399
  }),
331
400
  options.mutation && /* @__PURE__ */ jsxs(Fragment, { children: [
332
401
  /* @__PURE__ */ jsx(File.Import, {
@@ -348,7 +417,7 @@ const mutationGenerator = createReactGenerator({
348
417
  typeName: mutation.typeName,
349
418
  typeSchemas: type.schemas,
350
419
  operation,
351
- dataReturnType: options.client.dataReturnType,
420
+ dataReturnType: options.client.dataReturnType || "data",
352
421
  paramsCasing: options.paramsCasing,
353
422
  pathParamsType: options.pathParamsType,
354
423
  mutationKeyName: mutationKey.name
@@ -360,53 +429,45 @@ const mutationGenerator = createReactGenerator({
360
429
  });
361
430
 
362
431
  //#endregion
363
- //#region src/generators/infiniteQueryGenerator.tsx
364
- const infiniteQueryGenerator = createReactGenerator({
365
- name: "react-infinite-query",
366
- Operation({ options, operation }) {
367
- const { options: { output } } = usePlugin();
432
+ //#region src/generators/queryGenerator.tsx
433
+ const queryGenerator = createReactGenerator({
434
+ name: "react-query",
435
+ Operation({ config, plugin, operation, generator }) {
436
+ const { options, options: { output } } = plugin;
368
437
  const pluginManager = usePluginManager();
369
438
  const oas = useOas();
370
- const { getSchemas, getName, getFile } = useOperationManager();
439
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
371
440
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
372
441
  const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
373
- const infiniteOptions = options.infinite && typeof options.infinite === "object" ? options.infinite : void 0;
374
442
  const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
375
443
  const query = {
376
444
  name: getName(operation, {
377
445
  type: "function",
378
- prefix: "use",
379
- suffix: "infinite"
446
+ prefix: "use"
380
447
  }),
381
448
  typeName: getName(operation, { type: "type" }),
382
- file: getFile(operation, {
383
- prefix: "use",
384
- suffix: "infinite"
385
- })
449
+ file: getFile(operation, { prefix: "use" })
386
450
  };
387
451
  const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName]);
388
452
  const client = {
389
453
  name: hasClientPlugin ? getName(operation, {
390
454
  type: "function",
391
455
  pluginKey: [pluginClientName]
392
- }) : getName(operation, {
393
- type: "function",
394
- suffix: "infinite"
395
- }),
456
+ }) : getName(operation, { type: "function" }),
396
457
  file: getFile(operation, { pluginKey: [pluginClientName] })
397
458
  };
398
459
  const queryOptions = { name: getName(operation, {
399
460
  type: "function",
400
- suffix: "InfiniteQueryOptions"
461
+ suffix: "QueryOptions"
401
462
  }) };
402
463
  const queryKey = {
403
464
  name: getName(operation, {
404
465
  type: "const",
405
- suffix: "InfiniteQueryKey"
466
+ suffix: "QueryKey"
406
467
  }),
407
468
  typeName: getName(operation, {
408
469
  type: "type",
409
- suffix: "InfiniteQueryKey"
470
+ suffix: "QueryKey"
410
471
  })
411
472
  };
412
473
  const type = {
@@ -423,15 +484,7 @@ const infiniteQueryGenerator = createReactGenerator({
423
484
  type: "function"
424
485
  })
425
486
  };
426
- if (!isQuery || isMutation || !infiniteOptions) return null;
427
- const normalizeKey = (key) => (key ?? "").replace(/\?$/, "");
428
- const queryParam = infiniteOptions.queryParam;
429
- const cursorParam = infiniteOptions.cursorParam;
430
- const queryParamKeys = type.schemas.queryParams?.keys ?? [];
431
- const responseKeys = [...type.schemas.responses?.flatMap((item) => item.keys ?? []) ?? [], ...type.schemas.response?.keys ?? []];
432
- const hasQueryParam = queryParam ? queryParamKeys.some((key) => normalizeKey(key) === queryParam) : false;
433
- const hasCursorParam = cursorParam ? responseKeys.some((key) => normalizeKey(key) === cursorParam) : true;
434
- if (!hasQueryParam || !hasCursorParam) return null;
487
+ if (!isQuery || isMutation) return null;
435
488
  return /* @__PURE__ */ jsxs(File, {
436
489
  baseName: query.file.baseName,
437
490
  path: query.file.path,
@@ -451,25 +504,45 @@ const infiniteQueryGenerator = createReactGenerator({
451
504
  root: query.file.path,
452
505
  path: zod.file.path
453
506
  }),
454
- /* @__PURE__ */ jsx(File.Import, {
455
- name: "fetch",
456
- path: options.client.importPath
457
- }),
507
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
508
+ /* @__PURE__ */ jsx(File.Import, {
509
+ name: "fetch",
510
+ path: options.client.importPath
511
+ }),
512
+ /* @__PURE__ */ jsx(File.Import, {
513
+ name: ["RequestConfig", "ResponseErrorConfig"],
514
+ path: options.client.importPath,
515
+ isTypeOnly: true
516
+ }),
517
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
518
+ name: ["ResponseConfig"],
519
+ path: options.client.importPath,
520
+ isTypeOnly: true
521
+ })
522
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
523
+ /* @__PURE__ */ jsx(File.Import, {
524
+ name: "fetch",
525
+ root: query.file.path,
526
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
527
+ }),
528
+ /* @__PURE__ */ jsx(File.Import, {
529
+ name: ["RequestConfig", "ResponseErrorConfig"],
530
+ root: query.file.path,
531
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
532
+ isTypeOnly: true
533
+ }),
534
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
535
+ name: ["ResponseConfig"],
536
+ root: query.file.path,
537
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
538
+ isTypeOnly: true
539
+ })
540
+ ] }),
458
541
  hasClientPlugin && /* @__PURE__ */ jsx(File.Import, {
459
542
  name: [client.name],
460
543
  root: query.file.path,
461
544
  path: client.file.path
462
545
  }),
463
- /* @__PURE__ */ jsx(File.Import, {
464
- name: ["RequestConfig", "ResponseErrorConfig"],
465
- path: options.client.importPath,
466
- isTypeOnly: true
467
- }),
468
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
469
- name: ["ResponseConfig"],
470
- path: options.client.importPath,
471
- isTypeOnly: true
472
- }),
473
546
  /* @__PURE__ */ jsx(File.Import, {
474
547
  name: [
475
548
  type.schemas.request?.name,
@@ -487,9 +560,9 @@ const infiniteQueryGenerator = createReactGenerator({
487
560
  name: queryKey.name,
488
561
  typeName: queryKey.typeName,
489
562
  operation,
490
- paramsCasing: options.paramsCasing,
491
563
  pathParamsType: options.pathParamsType,
492
564
  typeSchemas: type.schemas,
565
+ paramsCasing: options.paramsCasing,
493
566
  transformer: options.queryKey
494
567
  }),
495
568
  !hasClientPlugin && /* @__PURE__ */ jsx(Client, {
@@ -498,52 +571,43 @@ const infiniteQueryGenerator = createReactGenerator({
498
571
  operation,
499
572
  typeSchemas: type.schemas,
500
573
  zodSchemas: zod.schemas,
501
- dataReturnType: options.client.dataReturnType,
502
- paramsCasing: options.paramsCasing,
574
+ dataReturnType: options.client.dataReturnType || "data",
503
575
  paramsType: options.paramsType,
576
+ paramsCasing: options.paramsCasing,
504
577
  pathParamsType: options.pathParamsType,
505
578
  parser: options.parser
506
579
  }),
507
- infiniteOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
508
- /* @__PURE__ */ jsx(File.Import, {
509
- name: ["InfiniteData"],
510
- isTypeOnly: true,
511
- path: importPath
512
- }),
513
- /* @__PURE__ */ jsx(File.Import, {
514
- name: ["infiniteQueryOptions"],
515
- path: importPath
516
- }),
517
- /* @__PURE__ */ jsx(InfiniteQueryOptions, {
518
- name: queryOptions.name,
519
- clientName: client.name,
520
- queryKeyName: queryKey.name,
521
- typeSchemas: type.schemas,
522
- paramsCasing: options.paramsCasing,
523
- paramsType: options.paramsType,
524
- pathParamsType: options.pathParamsType,
525
- dataReturnType: options.client.dataReturnType,
526
- cursorParam: infiniteOptions.cursorParam,
527
- initialPageParam: infiniteOptions.initialPageParam,
528
- queryParam: infiniteOptions.queryParam
529
- })
530
- ] }),
531
- infiniteOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
580
+ /* @__PURE__ */ jsx(File.Import, {
581
+ name: ["queryOptions"],
582
+ path: importPath
583
+ }),
584
+ /* @__PURE__ */ jsx(QueryOptions, {
585
+ name: queryOptions.name,
586
+ clientName: client.name,
587
+ queryKeyName: queryKey.name,
588
+ typeSchemas: type.schemas,
589
+ paramsCasing: options.paramsCasing,
590
+ paramsType: options.paramsType,
591
+ pathParamsType: options.pathParamsType,
592
+ dataReturnType: options.client.dataReturnType || "data"
593
+ }),
594
+ options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
532
595
  /* @__PURE__ */ jsx(File.Import, {
533
- name: ["useInfiniteQuery"],
596
+ name: ["useQuery"],
534
597
  path: importPath
535
598
  }),
536
599
  /* @__PURE__ */ jsx(File.Import, {
537
600
  name: [
538
601
  "QueryKey",
539
602
  "QueryClient",
540
- "InfiniteQueryObserverOptions",
541
- "UseInfiniteQueryResult"
603
+ "QueryObserverOptions",
604
+ "UseQueryResult",
605
+ "QueryClient"
542
606
  ],
543
607
  path: importPath,
544
608
  isTypeOnly: true
545
609
  }),
546
- /* @__PURE__ */ jsx(InfiniteQuery, {
610
+ /* @__PURE__ */ jsx(Query, {
547
611
  name: query.name,
548
612
  queryOptionsName: queryOptions.name,
549
613
  typeSchemas: type.schemas,
@@ -551,11 +615,9 @@ const infiniteQueryGenerator = createReactGenerator({
551
615
  paramsType: options.paramsType,
552
616
  pathParamsType: options.pathParamsType,
553
617
  operation,
554
- dataReturnType: options.client.dataReturnType,
618
+ dataReturnType: options.client.dataReturnType || "data",
555
619
  queryKeyName: queryKey.name,
556
- queryKeyTypeName: queryKey.typeName,
557
- initialPageParam: infiniteOptions.initialPageParam,
558
- queryParam: infiniteOptions.queryParam
620
+ queryKeyTypeName: queryKey.typeName
559
621
  })
560
622
  ] })
561
623
  ]
@@ -567,11 +629,11 @@ const infiniteQueryGenerator = createReactGenerator({
567
629
  //#region src/generators/suspenseQueryGenerator.tsx
568
630
  const suspenseQueryGenerator = createReactGenerator({
569
631
  name: "react-suspense-query",
570
- Operation({ options, operation }) {
571
- const { options: { output } } = usePlugin();
632
+ Operation({ config, operation, generator, plugin }) {
633
+ const { options, options: { output } } = plugin;
572
634
  const pluginManager = usePluginManager();
573
635
  const oas = useOas();
574
- const { getSchemas, getName, getFile } = useOperationManager();
636
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
575
637
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
576
638
  const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
577
639
  const isSuspense = !!options.suspense;
@@ -647,25 +709,45 @@ const suspenseQueryGenerator = createReactGenerator({
647
709
  root: query.file.path,
648
710
  path: zod.file.path
649
711
  }),
650
- /* @__PURE__ */ jsx(File.Import, {
651
- name: "fetch",
652
- path: options.client.importPath
653
- }),
712
+ options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
713
+ /* @__PURE__ */ jsx(File.Import, {
714
+ name: "fetch",
715
+ path: options.client.importPath
716
+ }),
717
+ /* @__PURE__ */ jsx(File.Import, {
718
+ name: ["RequestConfig", "ResponseErrorConfig"],
719
+ path: options.client.importPath,
720
+ isTypeOnly: true
721
+ }),
722
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
723
+ name: ["ResponseConfig"],
724
+ path: options.client.importPath,
725
+ isTypeOnly: true
726
+ })
727
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
728
+ /* @__PURE__ */ jsx(File.Import, {
729
+ name: "fetch",
730
+ root: query.file.path,
731
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
732
+ }),
733
+ /* @__PURE__ */ jsx(File.Import, {
734
+ name: ["RequestConfig", "ResponseErrorConfig"],
735
+ root: query.file.path,
736
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
737
+ isTypeOnly: true
738
+ }),
739
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
740
+ name: ["ResponseConfig"],
741
+ root: query.file.path,
742
+ path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
743
+ isTypeOnly: true
744
+ })
745
+ ] }),
654
746
  hasClientPlugin && /* @__PURE__ */ jsx(File.Import, {
655
747
  name: [client.name],
656
748
  root: query.file.path,
657
749
  path: client.file.path
658
750
  }),
659
- /* @__PURE__ */ jsx(File.Import, {
660
- name: ["RequestConfig", "ResponseErrorConfig"],
661
- path: options.client.importPath,
662
- isTypeOnly: true
663
- }),
664
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
665
- name: ["ResponseConfig"],
666
- path: options.client.importPath,
667
- isTypeOnly: true
668
- }),
669
751
  /* @__PURE__ */ jsx(File.Import, {
670
752
  name: [
671
753
  type.schemas.request?.name,
@@ -694,7 +776,7 @@ const suspenseQueryGenerator = createReactGenerator({
694
776
  operation,
695
777
  typeSchemas: type.schemas,
696
778
  zodSchemas: zod.schemas,
697
- dataReturnType: options.client.dataReturnType,
779
+ dataReturnType: options.client.dataReturnType || "data",
698
780
  paramsCasing: options.paramsCasing,
699
781
  paramsType: options.paramsType,
700
782
  pathParamsType: options.pathParamsType,
@@ -729,11 +811,6 @@ const suspenseQueryGenerator = createReactGenerator({
729
811
  path: importPath,
730
812
  isTypeOnly: true
731
813
  }),
732
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
733
- name: ["ResponseConfig"],
734
- path: options.client.importPath,
735
- isTypeOnly: true
736
- }),
737
814
  /* @__PURE__ */ jsx(SuspenseQuery, {
738
815
  name: query.name,
739
816
  queryOptionsName: queryOptions.name,
@@ -742,7 +819,7 @@ const suspenseQueryGenerator = createReactGenerator({
742
819
  paramsCasing: options.paramsCasing,
743
820
  pathParamsType: options.pathParamsType,
744
821
  operation,
745
- dataReturnType: options.client.dataReturnType,
822
+ dataReturnType: options.client.dataReturnType || "data",
746
823
  queryKeyName: queryKey.name,
747
824
  queryKeyTypeName: queryKey.typeName
748
825
  })
@@ -753,5 +830,5 @@ const suspenseQueryGenerator = createReactGenerator({
753
830
  });
754
831
 
755
832
  //#endregion
756
- export { queryGenerator as i, infiniteQueryGenerator as n, mutationGenerator as r, suspenseQueryGenerator as t };
757
- //# sourceMappingURL=generators-egdl4EOg.js.map
833
+ export { infiniteQueryGenerator as i, queryGenerator as n, mutationGenerator as r, suspenseQueryGenerator as t };
834
+ //# sourceMappingURL=generators-BTb-fJYl.js.map