@kubb/plugin-vue-query 3.0.0-alpha.20

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-3HD4DCDR.js +505 -0
  4. package/dist/chunk-3HD4DCDR.js.map +1 -0
  5. package/dist/chunk-4YY5DUPV.cjs +514 -0
  6. package/dist/chunk-4YY5DUPV.cjs.map +1 -0
  7. package/dist/chunk-BKYBSBUA.js +567 -0
  8. package/dist/chunk-BKYBSBUA.js.map +1 -0
  9. package/dist/chunk-FRKJLBA5.cjs +576 -0
  10. package/dist/chunk-FRKJLBA5.cjs.map +1 -0
  11. package/dist/components.cjs +32 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +121 -0
  14. package/dist/components.d.ts +121 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +21 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +12 -0
  20. package/dist/generators.d.ts +12 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +138 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +131 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-CmetQDTc.d.cts +173 -0
  30. package/dist/types-CmetQDTc.d.ts +173 -0
  31. package/package.json +102 -0
  32. package/src/components/InfiniteQuery.tsx +137 -0
  33. package/src/components/InfiniteQueryOptions.tsx +129 -0
  34. package/src/components/Mutation.tsx +141 -0
  35. package/src/components/Query.tsx +128 -0
  36. package/src/components/QueryKey.tsx +81 -0
  37. package/src/components/QueryOptions.tsx +88 -0
  38. package/src/components/index.ts +6 -0
  39. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +52 -0
  40. package/src/generators/__snapshots__/clientGetImportPath.ts +52 -0
  41. package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
  42. package/src/generators/__snapshots__/findByTags.ts +52 -0
  43. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +52 -0
  44. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +52 -0
  45. package/src/generators/__snapshots__/findByTagsWithZod.ts +52 -0
  46. package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
  47. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
  48. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  49. package/src/generators/__snapshots__/updatePetById.ts +38 -0
  50. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +40 -0
  51. package/src/generators/index.ts +3 -0
  52. package/src/generators/infiniteQueryGenerator.tsx +131 -0
  53. package/src/generators/mutationGenerator.tsx +96 -0
  54. package/src/generators/queryGenerator.tsx +124 -0
  55. package/src/index.ts +2 -0
  56. package/src/plugin.ts +152 -0
  57. package/src/types.ts +179 -0
@@ -0,0 +1,576 @@
1
+ 'use strict';
2
+
3
+ var react = require('@kubb/react');
4
+ var oas = require('@kubb/oas');
5
+ var utils = require('@kubb/core/utils');
6
+ var utils$1 = require('@kubb/plugin-oas/utils');
7
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
8
+
9
+ // src/components/Mutation.tsx
10
+ function getParams({ pathParamsType, typeSchemas }) {
11
+ return react.FunctionParams.factory({
12
+ pathParams: {
13
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
14
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
15
+ },
16
+ data: typeSchemas.request?.name ? {
17
+ type: typeSchemas.request?.name,
18
+ optional: oas.isOptional(typeSchemas.request?.schema)
19
+ } : void 0,
20
+ params: typeSchemas.queryParams?.name ? {
21
+ type: typeSchemas.queryParams?.name,
22
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
23
+ } : void 0,
24
+ headers: typeSchemas.headerParams?.name ? {
25
+ type: typeSchemas.headerParams?.name,
26
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
27
+ } : void 0,
28
+ config: {
29
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
30
+ default: "{}"
31
+ }
32
+ });
33
+ }
34
+ function Client({
35
+ name,
36
+ isExportable = true,
37
+ isIndexable = true,
38
+ typeSchemas,
39
+ baseURL,
40
+ dataReturnType,
41
+ parser,
42
+ zodSchemas,
43
+ pathParamsType,
44
+ operation
45
+ }) {
46
+ const path = new utils.URLPath(operation.path);
47
+ const contentType = operation.getContentType();
48
+ const isFormData = contentType === "multipart/form-data";
49
+ const headers = [
50
+ contentType !== "application/json" ? `'Content-Type': '${contentType}'` : void 0,
51
+ typeSchemas.headerParams?.name ? "...headers" : void 0
52
+ ].filter(Boolean);
53
+ const generics = [
54
+ typeSchemas.response.name,
55
+ typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown",
56
+ typeSchemas.request?.name || "unknown"
57
+ ].filter(Boolean);
58
+ const params = getParams({ pathParamsType, typeSchemas });
59
+ const clientParams = react.FunctionParams.factory({
60
+ config: {
61
+ mode: "object",
62
+ children: {
63
+ method: {
64
+ value: JSON.stringify(operation.method)
65
+ },
66
+ url: {
67
+ value: path.template
68
+ },
69
+ baseURL: baseURL ? {
70
+ value: JSON.stringify(baseURL)
71
+ } : void 0,
72
+ params: typeSchemas.queryParams?.name ? {} : void 0,
73
+ data: typeSchemas.request?.name ? {
74
+ value: isFormData ? "formData" : void 0
75
+ } : void 0,
76
+ headers: headers.length ? {
77
+ value: headers.length ? `{ ${headers.join(", ")}, ...config.headers }` : void 0
78
+ } : void 0,
79
+ config: {
80
+ mode: "inlineSpread"
81
+ }
82
+ }
83
+ }
84
+ });
85
+ const formData = isFormData ? `
86
+ const formData = new FormData()
87
+ if(data) {
88
+ Object.keys(data).forEach((key) => {
89
+ const value = data[key];
90
+ if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
91
+ formData.append(key, value);
92
+ }
93
+ })
94
+ }
95
+ ` : "";
96
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable, isIndexable, children: /* @__PURE__ */ jsxRuntime.jsxs(
97
+ react.Function,
98
+ {
99
+ name,
100
+ async: true,
101
+ export: isExportable,
102
+ params: params.toConstructor(),
103
+ JSDoc: {
104
+ comments: utils$1.getComments(operation)
105
+ },
106
+ children: [
107
+ formData,
108
+ `const res = await client<${generics.join(", ")}>(${clientParams.toCall()})`,
109
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
110
+ dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
111
+ dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
112
+ dataReturnType === "full" && parser === "client" && "return res",
113
+ dataReturnType === "data" && parser === "client" && "return res.data"
114
+ ]
115
+ }
116
+ ) });
117
+ }
118
+ Client.getParams = getParams;
119
+ function Operations({ name, operations }) {
120
+ const operationsObject = {};
121
+ operations.forEach((operation) => {
122
+ operationsObject[operation.getOperationId()] = {
123
+ path: new utils.URLPath(operation.path).URL,
124
+ method: operation.method
125
+ };
126
+ });
127
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Const, { name, export: true, asConst: true, children: JSON.stringify(operationsObject, void 0, 2) }) });
128
+ }
129
+ function getParams2({ dataReturnType, typeSchemas }) {
130
+ const mutateParams = react.FunctionParams.factory({
131
+ ...utils$1.getPathParams(typeSchemas.pathParams, {
132
+ typed: true,
133
+ override(item) {
134
+ return {
135
+ ...item,
136
+ type: `MaybeRef<${item.type}>`
137
+ };
138
+ }
139
+ }),
140
+ data: typeSchemas.request?.name ? {
141
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
142
+ optional: oas.isOptional(typeSchemas.request?.schema)
143
+ } : void 0,
144
+ params: typeSchemas.queryParams?.name ? {
145
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
146
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
147
+ } : void 0,
148
+ headers: typeSchemas.headerParams?.name ? {
149
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
150
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
151
+ } : void 0
152
+ });
153
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
154
+ const TRequest = mutateParams.toConstructor({ valueAsType: true });
155
+ return react.FunctionParams.factory({
156
+ options: {
157
+ type: `
158
+ {
159
+ mutation?: UseMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", `{${TRequest}`].join(", ")}>,
160
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"},
161
+ }
162
+ `,
163
+ default: "{}"
164
+ }
165
+ });
166
+ }
167
+ function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation }) {
168
+ const params = getParams2({
169
+ pathParamsType,
170
+ dataReturnType,
171
+ typeSchemas
172
+ });
173
+ const clientParams = Client.getParams({
174
+ typeSchemas,
175
+ pathParamsType
176
+ });
177
+ const mutationParams = react.FunctionParams.factory({
178
+ data: {
179
+ // No use of pathParams because useMutation can only take one argument in object form,
180
+ // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
181
+ mode: "object",
182
+ //TODO rename with value
183
+ children: {
184
+ ...utils$1.getPathParams(typeSchemas.pathParams, { typed: true }),
185
+ data: typeSchemas.request?.name ? {
186
+ type: typeSchemas.request?.name,
187
+ optional: oas.isOptional(typeSchemas.request?.schema)
188
+ } : void 0,
189
+ params: typeSchemas.queryParams?.name ? {
190
+ type: typeSchemas.queryParams?.name,
191
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
192
+ } : void 0,
193
+ headers: typeSchemas.headerParams?.name ? {
194
+ type: typeSchemas.headerParams?.name,
195
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
196
+ } : void 0
197
+ }
198
+ }
199
+ });
200
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
201
+ react.Function,
202
+ {
203
+ name,
204
+ export: true,
205
+ params: params.toConstructor(),
206
+ JSDoc: {
207
+ comments: utils$1.getComments(operation)
208
+ },
209
+ children: `
210
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
211
+
212
+ return useMutation({
213
+ mutationFn: async(${mutationParams.toConstructor()}) => {
214
+ return ${clientName}(${clientParams.toCall()})
215
+ },
216
+ ...mutationOptions
217
+ })
218
+ `
219
+ }
220
+ ) });
221
+ }
222
+ function getParams3({ pathParamsType, typeSchemas }) {
223
+ return react.FunctionParams.factory({
224
+ pathParams: {
225
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
226
+ children: utils$1.getPathParams(typeSchemas.pathParams, {
227
+ typed: true,
228
+ override(item) {
229
+ return {
230
+ ...item,
231
+ type: `MaybeRef<${item.type}>`
232
+ };
233
+ }
234
+ })
235
+ },
236
+ data: typeSchemas.request?.name ? {
237
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
238
+ optional: oas.isOptional(typeSchemas.request?.schema)
239
+ } : void 0,
240
+ params: typeSchemas.queryParams?.name ? {
241
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
242
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
243
+ } : void 0
244
+ });
245
+ }
246
+ function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name2) => name2 }) {
247
+ const path = new utils.URLPath(operation.path);
248
+ const params = getParams3({ pathParamsType, typeSchemas });
249
+ const keys = [
250
+ path.toObject({
251
+ type: "path",
252
+ stringify: true
253
+ }),
254
+ typeSchemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
255
+ typeSchemas.request?.name ? "...(data ? [data] : [])" : void 0
256
+ ].filter(Boolean);
257
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
258
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keysFn(keys).join(", ")}] as const` }) }),
259
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
260
+ ] });
261
+ }
262
+ QueryKey.getParams = getParams3;
263
+ function getParams4({ pathParamsType, typeSchemas }) {
264
+ return react.FunctionParams.factory({
265
+ pathParams: {
266
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
267
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
268
+ },
269
+ data: typeSchemas.request?.name ? {
270
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
271
+ optional: oas.isOptional(typeSchemas.request?.schema)
272
+ } : void 0,
273
+ params: typeSchemas.queryParams?.name ? {
274
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
275
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
276
+ } : void 0,
277
+ headers: typeSchemas.headerParams?.name ? {
278
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
279
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
280
+ } : void 0,
281
+ config: {
282
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
283
+ default: "{}"
284
+ }
285
+ });
286
+ }
287
+ function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }) {
288
+ const params = getParams4({ pathParamsType, typeSchemas });
289
+ const clientParams = Client.getParams({
290
+ typeSchemas,
291
+ pathParamsType
292
+ });
293
+ const queryKeyParams = QueryKey.getParams({
294
+ pathParamsType,
295
+ typeSchemas
296
+ });
297
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, params: params.toConstructor(), children: `
298
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
299
+ return queryOptions({
300
+ queryKey,
301
+ queryFn: async () => {
302
+ return ${clientName}(${clientParams.toCall({
303
+ transformName(name2) {
304
+ return `unref(${name2})`;
305
+ }
306
+ })})
307
+ },
308
+ })
309
+ ` }) });
310
+ }
311
+ QueryOptions.getParams = getParams4;
312
+ function getParams5({ pathParamsType, dataReturnType, typeSchemas }) {
313
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
314
+ return react.FunctionParams.factory({
315
+ pathParams: {
316
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
317
+ children: utils$1.getPathParams(typeSchemas.pathParams, {
318
+ typed: true,
319
+ override(item) {
320
+ return {
321
+ ...item,
322
+ type: `MaybeRef<${item.type}>`
323
+ };
324
+ }
325
+ })
326
+ },
327
+ data: typeSchemas.request?.name ? {
328
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
329
+ optional: oas.isOptional(typeSchemas.request?.schema)
330
+ } : void 0,
331
+ params: typeSchemas.queryParams?.name ? {
332
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
333
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
334
+ } : void 0,
335
+ headers: typeSchemas.headerParams?.name ? {
336
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
337
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
338
+ } : void 0,
339
+ options: {
340
+ type: `
341
+ {
342
+ query?: Partial<QueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", "TData", "TQueryData", "TQueryKey"].join(", ")}>>,
343
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
344
+ }
345
+ `,
346
+ default: "{}"
347
+ }
348
+ });
349
+ }
350
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }) {
351
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
352
+ const returnType = `UseQueryReturnType<${["TData", typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown"].join(", ")}> & { queryKey: TQueryKey }`;
353
+ const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
354
+ const queryKeyParams = QueryKey.getParams({
355
+ pathParamsType,
356
+ typeSchemas
357
+ });
358
+ const queryOptionsParams = QueryOptions.getParams({
359
+ pathParamsType,
360
+ typeSchemas
361
+ });
362
+ const params = getParams5({
363
+ pathParamsType,
364
+ dataReturnType,
365
+ typeSchemas
366
+ });
367
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as QueryObserverOptions`;
368
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
369
+ react.Function,
370
+ {
371
+ name,
372
+ export: true,
373
+ generics: generics.join(", "),
374
+ params: params.toConstructor(),
375
+ JSDoc: {
376
+ comments: utils$1.getComments(operation)
377
+ },
378
+ children: `
379
+ const { query: queryOptions, client: config = {} } = options ?? {}
380
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
381
+
382
+ const query = useQuery({
383
+ ...${queryOptions},
384
+ queryKey,
385
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
386
+ }) as ${returnType}
387
+
388
+ query.queryKey = queryKey as TQueryKey
389
+
390
+ return query
391
+ `
392
+ }
393
+ ) });
394
+ }
395
+ Query.getParams = getParams5;
396
+ function getParams6({ pathParamsType, typeSchemas }) {
397
+ return react.FunctionParams.factory({
398
+ pathParams: {
399
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
400
+ children: utils$1.getPathParams(typeSchemas.pathParams, {
401
+ typed: true,
402
+ override(item) {
403
+ return {
404
+ ...item,
405
+ type: `MaybeRef<${item.type}>`
406
+ };
407
+ }
408
+ })
409
+ },
410
+ data: typeSchemas.request?.name ? {
411
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
412
+ optional: oas.isOptional(typeSchemas.request?.schema)
413
+ } : void 0,
414
+ params: typeSchemas.queryParams?.name ? {
415
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
416
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
417
+ } : void 0,
418
+ headers: typeSchemas.headerParams?.name ? {
419
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
420
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
421
+ } : void 0,
422
+ config: {
423
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
424
+ default: "{}"
425
+ }
426
+ });
427
+ }
428
+ function InfiniteQueryOptions({
429
+ name,
430
+ clientName,
431
+ initialPageParam,
432
+ cursorParam,
433
+ typeSchemas,
434
+ dataReturnType,
435
+ pathParamsType,
436
+ queryParam,
437
+ queryKeyName
438
+ }) {
439
+ const params = getParams6({ pathParamsType, typeSchemas });
440
+ const clientParams = Client.getParams({
441
+ typeSchemas,
442
+ pathParamsType
443
+ });
444
+ const queryKeyParams = QueryKey.getParams({
445
+ pathParamsType,
446
+ typeSchemas
447
+ });
448
+ const queryOptions = [
449
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
450
+ cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` : void 0,
451
+ cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` : void 0,
452
+ !cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : void 0,
453
+ !cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : void 0,
454
+ !cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : void 0
455
+ ].filter(Boolean);
456
+ const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
457
+ if(params) {
458
+ params['${queryParam}'] = pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}']
459
+ }` : "";
460
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, params: params.toConstructor(), children: `
461
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
462
+ return infiniteQueryOptions({
463
+ queryKey,
464
+ queryFn: async ({ pageParam }) => {
465
+ ${infiniteOverrideParams}
466
+ return ${clientName}(${clientParams.toCall()})
467
+ },
468
+ ${queryOptions.join("\n")}
469
+ })
470
+ ` }) });
471
+ }
472
+ InfiniteQueryOptions.getParams = getParams6;
473
+ function getParams7({ pathParamsType, dataReturnType, typeSchemas }) {
474
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
475
+ return react.FunctionParams.factory({
476
+ pathParams: {
477
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
478
+ children: utils$1.getPathParams(typeSchemas.pathParams, {
479
+ typed: true,
480
+ override(item) {
481
+ return {
482
+ ...item,
483
+ type: `MaybeRef<${item.type}>`
484
+ };
485
+ }
486
+ })
487
+ },
488
+ data: typeSchemas.request?.name ? {
489
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
490
+ optional: oas.isOptional(typeSchemas.request?.schema)
491
+ } : void 0,
492
+ params: typeSchemas.queryParams?.name ? {
493
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
494
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
495
+ } : void 0,
496
+ headers: typeSchemas.headerParams?.name ? {
497
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
498
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
499
+ } : void 0,
500
+ options: {
501
+ type: `
502
+ {
503
+ query?: Partial<InfiniteQueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", "TData", "TQueryData", "TQueryKey"].join(", ")}>>,
504
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
505
+ }
506
+ `,
507
+ default: "{}"
508
+ }
509
+ });
510
+ }
511
+ function InfiniteQuery({
512
+ name,
513
+ queryKeyTypeName,
514
+ queryOptionsName,
515
+ queryKeyName,
516
+ pathParamsType,
517
+ dataReturnType,
518
+ typeSchemas,
519
+ operation
520
+ }) {
521
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
522
+ const returnType = `UseInfiniteQueryReturnType<${["TData", typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown"].join(", ")}> & { queryKey: TQueryKey }`;
523
+ const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
524
+ const queryKeyParams = QueryKey.getParams({
525
+ pathParamsType,
526
+ typeSchemas
527
+ });
528
+ const queryOptionsParams = QueryOptions.getParams({
529
+ pathParamsType,
530
+ typeSchemas
531
+ });
532
+ const params = getParams7({
533
+ pathParamsType,
534
+ dataReturnType,
535
+ typeSchemas
536
+ });
537
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()}) as unknown as InfiniteQueryObserverOptions`;
538
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
539
+ react.Function,
540
+ {
541
+ name,
542
+ export: true,
543
+ generics: generics.join(", "),
544
+ params: params.toConstructor(),
545
+ JSDoc: {
546
+ comments: utils$1.getComments(operation)
547
+ },
548
+ children: `
549
+ const { query: queryOptions, client: config = {} } = options ?? {}
550
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
551
+
552
+ const query = useInfiniteQuery({
553
+ ...${queryOptions},
554
+ queryKey,
555
+ ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
556
+ }) as ${returnType}
557
+
558
+ query.queryKey = queryKey as TQueryKey
559
+
560
+ return query
561
+ `
562
+ }
563
+ ) });
564
+ }
565
+ InfiniteQuery.getParams = getParams7;
566
+
567
+ exports.Client = Client;
568
+ exports.InfiniteQuery = InfiniteQuery;
569
+ exports.InfiniteQueryOptions = InfiniteQueryOptions;
570
+ exports.Mutation = Mutation;
571
+ exports.Operations = Operations;
572
+ exports.Query = Query;
573
+ exports.QueryKey = QueryKey;
574
+ exports.QueryOptions = QueryOptions;
575
+ //# sourceMappingURL=chunk-FRKJLBA5.cjs.map
576
+ //# sourceMappingURL=chunk-FRKJLBA5.cjs.map