@kubb/plugin-react-query 3.5.6 → 3.5.8
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.
- package/dist/{chunk-CO3KLAV4.js → chunk-E74AC4FE.js} +8 -7
- package/dist/chunk-E74AC4FE.js.map +1 -0
- package/dist/chunk-LVGRZJKZ.js +72 -72
- package/dist/chunk-LVGRZJKZ.js.map +1 -1
- package/dist/chunk-ODTL4QSL.cjs +72 -72
- package/dist/chunk-ODTL4QSL.cjs.map +1 -1
- package/dist/{chunk-ZVI74AOG.cjs → chunk-QTUDIPE6.cjs} +8 -7
- package/dist/chunk-QTUDIPE6.cjs.map +1 -0
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +7 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-18y-1Kmu.d.cts → types-BBUEQBBf.d.cts} +11 -1
- package/dist/{types-18y-1Kmu.d.ts → types-BBUEQBBf.d.ts} +11 -1
- package/package.json +12 -12
- package/src/plugin.ts +2 -1
- package/src/types.ts +6 -1
- package/dist/chunk-CO3KLAV4.js.map +0 -1
- package/dist/chunk-ZVI74AOG.cjs.map +0 -1
package/dist/chunk-ODTL4QSL.cjs
CHANGED
|
@@ -23,7 +23,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
23
23
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
24
24
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
25
25
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
26
|
-
} :
|
|
26
|
+
} : undefined
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }) {
|
|
@@ -42,15 +42,15 @@ function getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
42
42
|
data: typeSchemas.request?.name ? {
|
|
43
43
|
type: typeSchemas.request?.name,
|
|
44
44
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
45
|
-
} :
|
|
45
|
+
} : undefined,
|
|
46
46
|
params: typeSchemas.queryParams?.name ? {
|
|
47
47
|
type: typeSchemas.queryParams?.name,
|
|
48
48
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
49
|
-
} :
|
|
49
|
+
} : undefined,
|
|
50
50
|
headers: typeSchemas.headerParams?.name ? {
|
|
51
51
|
type: typeSchemas.headerParams?.name,
|
|
52
52
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
53
|
-
} :
|
|
53
|
+
} : undefined
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
config: {
|
|
@@ -64,19 +64,19 @@ function getParams2({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
64
64
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
65
65
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
66
66
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
67
|
-
} :
|
|
67
|
+
} : undefined,
|
|
68
68
|
data: typeSchemas.request?.name ? {
|
|
69
69
|
type: typeSchemas.request?.name,
|
|
70
70
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
71
|
-
} :
|
|
71
|
+
} : undefined,
|
|
72
72
|
params: typeSchemas.queryParams?.name ? {
|
|
73
73
|
type: typeSchemas.queryParams?.name,
|
|
74
74
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
75
|
-
} :
|
|
75
|
+
} : undefined,
|
|
76
76
|
headers: typeSchemas.headerParams?.name ? {
|
|
77
77
|
type: typeSchemas.headerParams?.name,
|
|
78
78
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
79
|
-
} :
|
|
79
|
+
} : undefined,
|
|
80
80
|
config: {
|
|
81
81
|
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : "Partial<RequestConfig> & { client?: typeof client }",
|
|
82
82
|
default: "{}"
|
|
@@ -102,8 +102,8 @@ function Client({
|
|
|
102
102
|
const contentType = operation.getContentType();
|
|
103
103
|
const isFormData = contentType === "multipart/form-data";
|
|
104
104
|
const headers = [
|
|
105
|
-
contentType !== "application/json" ? `'Content-Type': '${contentType}'` :
|
|
106
|
-
typeSchemas.headerParams?.name ? "...headers" :
|
|
105
|
+
contentType !== "application/json" ? `'Content-Type': '${contentType}'` : undefined,
|
|
106
|
+
typeSchemas.headerParams?.name ? "...headers" : undefined
|
|
107
107
|
].filter(Boolean);
|
|
108
108
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
109
109
|
const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || "unknown"].filter(Boolean);
|
|
@@ -126,14 +126,14 @@ function Client({
|
|
|
126
126
|
},
|
|
127
127
|
baseURL: baseURL && !urlName ? {
|
|
128
128
|
value: JSON.stringify(baseURL)
|
|
129
|
-
} :
|
|
130
|
-
params: typeSchemas.queryParams?.name ? {} :
|
|
129
|
+
} : undefined,
|
|
130
|
+
params: typeSchemas.queryParams?.name ? {} : undefined,
|
|
131
131
|
data: typeSchemas.request?.name ? {
|
|
132
|
-
value: isFormData ? "formData" :
|
|
133
|
-
} :
|
|
132
|
+
value: isFormData ? "formData" : undefined
|
|
133
|
+
} : undefined,
|
|
134
134
|
headers: headers.length ? {
|
|
135
|
-
value: headers.length ? `{ ${headers.join(", ")}, ...requestConfig.headers }` :
|
|
136
|
-
} :
|
|
135
|
+
value: headers.length ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : undefined
|
|
136
|
+
} : undefined,
|
|
137
137
|
requestConfig: {
|
|
138
138
|
mode: "inlineSpread"
|
|
139
139
|
}
|
|
@@ -185,7 +185,7 @@ function Operations({ name, operations }) {
|
|
|
185
185
|
method: operation.method
|
|
186
186
|
};
|
|
187
187
|
});
|
|
188
|
-
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,
|
|
188
|
+
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, undefined, 2) }) });
|
|
189
189
|
}
|
|
190
190
|
function getParams3({}) {
|
|
191
191
|
return react.FunctionParams.factory({});
|
|
@@ -211,19 +211,19 @@ function getParams4({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
|
211
211
|
data: typeSchemas.request?.name ? {
|
|
212
212
|
type: typeSchemas.request?.name,
|
|
213
213
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
214
|
-
} :
|
|
214
|
+
} : undefined,
|
|
215
215
|
params: typeSchemas.queryParams?.name ? {
|
|
216
216
|
type: typeSchemas.queryParams?.name,
|
|
217
217
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
218
|
-
} :
|
|
218
|
+
} : undefined,
|
|
219
219
|
headers: typeSchemas.headerParams?.name ? {
|
|
220
220
|
type: typeSchemas.headerParams?.name,
|
|
221
221
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
222
|
-
} :
|
|
222
|
+
} : undefined
|
|
223
223
|
});
|
|
224
224
|
const TRequest = mutationParams.toConstructor({ valueAsType: true });
|
|
225
225
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
226
|
-
const generics = [TData, TError, TRequest ? `{${TRequest}}` :
|
|
226
|
+
const generics = [TData, TError, TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(", ");
|
|
227
227
|
return react.FunctionParams.factory({
|
|
228
228
|
options: {
|
|
229
229
|
type: `
|
|
@@ -268,15 +268,15 @@ function Mutation({
|
|
|
268
268
|
data: typeSchemas.request?.name ? {
|
|
269
269
|
type: typeSchemas.request?.name,
|
|
270
270
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
271
|
-
} :
|
|
271
|
+
} : undefined,
|
|
272
272
|
params: typeSchemas.queryParams?.name ? {
|
|
273
273
|
type: typeSchemas.queryParams?.name,
|
|
274
274
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
275
|
-
} :
|
|
275
|
+
} : undefined,
|
|
276
276
|
headers: typeSchemas.headerParams?.name ? {
|
|
277
277
|
type: typeSchemas.headerParams?.name,
|
|
278
278
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
279
|
-
} :
|
|
279
|
+
} : undefined
|
|
280
280
|
});
|
|
281
281
|
const dataParams = react.FunctionParams.factory({
|
|
282
282
|
data: {
|
|
@@ -287,7 +287,7 @@ function Mutation({
|
|
|
287
287
|
if (value) {
|
|
288
288
|
acc[key] = {
|
|
289
289
|
...value,
|
|
290
|
-
type:
|
|
290
|
+
type: undefined
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
return acc;
|
|
@@ -297,7 +297,7 @@ function Mutation({
|
|
|
297
297
|
const TRequest = mutationParams.toConstructor({ valueAsType: true });
|
|
298
298
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
299
299
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
300
|
-
const generics = [TData, TError, TRequest ? `{${TRequest}}` :
|
|
300
|
+
const generics = [TData, TError, TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(", ");
|
|
301
301
|
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
302
302
|
react.Function,
|
|
303
303
|
{
|
|
@@ -331,11 +331,11 @@ function getParams5({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
|
331
331
|
data: typeSchemas.request?.name ? {
|
|
332
332
|
type: typeSchemas.request?.name,
|
|
333
333
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
334
|
-
} :
|
|
334
|
+
} : undefined,
|
|
335
335
|
params: typeSchemas.queryParams?.name ? {
|
|
336
336
|
type: typeSchemas.queryParams?.name,
|
|
337
337
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
338
|
-
} :
|
|
338
|
+
} : undefined
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
var getTransformer2 = ({ operation, schemas, casing }) => {
|
|
@@ -345,8 +345,8 @@ var getTransformer2 = ({ operation, schemas, casing }) => {
|
|
|
345
345
|
type: "path",
|
|
346
346
|
stringify: true
|
|
347
347
|
}),
|
|
348
|
-
schemas.queryParams?.name ? "...(params ? [params] : [])" :
|
|
349
|
-
schemas.request?.name ? "...(data ? [data] : [])" :
|
|
348
|
+
schemas.queryParams?.name ? "...(params ? [params] : [])" : undefined,
|
|
349
|
+
schemas.request?.name ? "...(data ? [data] : [])" : undefined
|
|
350
350
|
].filter(Boolean);
|
|
351
351
|
return keys;
|
|
352
352
|
};
|
|
@@ -374,15 +374,15 @@ function getParams6({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
374
374
|
data: typeSchemas.request?.name ? {
|
|
375
375
|
type: typeSchemas.request?.name,
|
|
376
376
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
377
|
-
} :
|
|
377
|
+
} : undefined,
|
|
378
378
|
params: typeSchemas.queryParams?.name ? {
|
|
379
379
|
type: typeSchemas.queryParams?.name,
|
|
380
380
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
381
|
-
} :
|
|
381
|
+
} : undefined,
|
|
382
382
|
headers: typeSchemas.headerParams?.name ? {
|
|
383
383
|
type: typeSchemas.headerParams?.name,
|
|
384
384
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
385
|
-
} :
|
|
385
|
+
} : undefined
|
|
386
386
|
}
|
|
387
387
|
},
|
|
388
388
|
config: {
|
|
@@ -396,19 +396,19 @@ function getParams6({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
396
396
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
397
397
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
398
398
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
399
|
-
} :
|
|
399
|
+
} : undefined,
|
|
400
400
|
data: typeSchemas.request?.name ? {
|
|
401
401
|
type: typeSchemas.request?.name,
|
|
402
402
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
403
|
-
} :
|
|
403
|
+
} : undefined,
|
|
404
404
|
params: typeSchemas.queryParams?.name ? {
|
|
405
405
|
type: typeSchemas.queryParams?.name,
|
|
406
406
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
407
|
-
} :
|
|
407
|
+
} : undefined,
|
|
408
408
|
headers: typeSchemas.headerParams?.name ? {
|
|
409
409
|
type: typeSchemas.headerParams?.name,
|
|
410
410
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
411
|
-
} :
|
|
411
|
+
} : undefined,
|
|
412
412
|
config: {
|
|
413
413
|
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : "Partial<RequestConfig> & { client?: typeof client }",
|
|
414
414
|
default: "{}"
|
|
@@ -430,7 +430,7 @@ function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCas
|
|
|
430
430
|
typeSchemas,
|
|
431
431
|
paramsCasing
|
|
432
432
|
});
|
|
433
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key :
|
|
433
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : undefined).filter(Boolean).join("&& ");
|
|
434
434
|
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
435
435
|
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: `
|
|
436
436
|
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
@@ -457,15 +457,15 @@ function getParams7({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
457
457
|
data: typeSchemas.request?.name ? {
|
|
458
458
|
type: typeSchemas.request?.name,
|
|
459
459
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
460
|
-
} :
|
|
460
|
+
} : undefined,
|
|
461
461
|
params: typeSchemas.queryParams?.name ? {
|
|
462
462
|
type: typeSchemas.queryParams?.name,
|
|
463
463
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
464
|
-
} :
|
|
464
|
+
} : undefined,
|
|
465
465
|
headers: typeSchemas.headerParams?.name ? {
|
|
466
466
|
type: typeSchemas.headerParams?.name,
|
|
467
467
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
468
|
-
} :
|
|
468
|
+
} : undefined
|
|
469
469
|
}
|
|
470
470
|
},
|
|
471
471
|
options: {
|
|
@@ -484,19 +484,19 @@ function getParams7({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
484
484
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
485
485
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
486
486
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
487
|
-
} :
|
|
487
|
+
} : undefined,
|
|
488
488
|
data: typeSchemas.request?.name ? {
|
|
489
489
|
type: typeSchemas.request?.name,
|
|
490
490
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
491
|
-
} :
|
|
491
|
+
} : undefined,
|
|
492
492
|
params: typeSchemas.queryParams?.name ? {
|
|
493
493
|
type: typeSchemas.queryParams?.name,
|
|
494
494
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
495
|
-
} :
|
|
495
|
+
} : undefined,
|
|
496
496
|
headers: typeSchemas.headerParams?.name ? {
|
|
497
497
|
type: typeSchemas.headerParams?.name,
|
|
498
498
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
499
|
-
} :
|
|
499
|
+
} : undefined,
|
|
500
500
|
options: {
|
|
501
501
|
type: `
|
|
502
502
|
{
|
|
@@ -581,15 +581,15 @@ function getParams8({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
581
581
|
data: typeSchemas.request?.name ? {
|
|
582
582
|
type: typeSchemas.request?.name,
|
|
583
583
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
584
|
-
} :
|
|
584
|
+
} : undefined,
|
|
585
585
|
params: typeSchemas.queryParams?.name ? {
|
|
586
586
|
type: typeSchemas.queryParams?.name,
|
|
587
587
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
588
|
-
} :
|
|
588
|
+
} : undefined,
|
|
589
589
|
headers: typeSchemas.headerParams?.name ? {
|
|
590
590
|
type: typeSchemas.headerParams?.name,
|
|
591
591
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
592
|
-
} :
|
|
592
|
+
} : undefined
|
|
593
593
|
}
|
|
594
594
|
},
|
|
595
595
|
config: {
|
|
@@ -603,19 +603,19 @@ function getParams8({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
603
603
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
604
604
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
605
605
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
606
|
-
} :
|
|
606
|
+
} : undefined,
|
|
607
607
|
data: typeSchemas.request?.name ? {
|
|
608
608
|
type: typeSchemas.request?.name,
|
|
609
609
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
610
|
-
} :
|
|
610
|
+
} : undefined,
|
|
611
611
|
params: typeSchemas.queryParams?.name ? {
|
|
612
612
|
type: typeSchemas.queryParams?.name,
|
|
613
613
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
614
|
-
} :
|
|
614
|
+
} : undefined,
|
|
615
615
|
headers: typeSchemas.headerParams?.name ? {
|
|
616
616
|
type: typeSchemas.headerParams?.name,
|
|
617
617
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
618
|
-
} :
|
|
618
|
+
} : undefined,
|
|
619
619
|
config: {
|
|
620
620
|
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }` : "Partial<RequestConfig> & { client?: typeof client }",
|
|
621
621
|
default: "{}"
|
|
@@ -651,17 +651,17 @@ function InfiniteQueryOptions({
|
|
|
651
651
|
});
|
|
652
652
|
const queryOptions = [
|
|
653
653
|
`initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
|
|
654
|
-
cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` :
|
|
655
|
-
cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` :
|
|
656
|
-
!cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" :
|
|
657
|
-
!cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" :
|
|
658
|
-
!cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" :
|
|
654
|
+
cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` : undefined,
|
|
655
|
+
cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` : undefined,
|
|
656
|
+
!cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : undefined,
|
|
657
|
+
!cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : undefined,
|
|
658
|
+
!cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : undefined
|
|
659
659
|
].filter(Boolean);
|
|
660
660
|
const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
|
|
661
661
|
if(params) {
|
|
662
662
|
params['${queryParam}'] = pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}']
|
|
663
663
|
}` : "";
|
|
664
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key :
|
|
664
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : undefined).filter(Boolean).join("&& ");
|
|
665
665
|
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
666
666
|
if (infiniteOverrideParams) {
|
|
667
667
|
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: `
|
|
@@ -704,15 +704,15 @@ function getParams9({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
704
704
|
data: typeSchemas.request?.name ? {
|
|
705
705
|
type: typeSchemas.request?.name,
|
|
706
706
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
707
|
-
} :
|
|
707
|
+
} : undefined,
|
|
708
708
|
params: typeSchemas.queryParams?.name ? {
|
|
709
709
|
type: typeSchemas.queryParams?.name,
|
|
710
710
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
711
|
-
} :
|
|
711
|
+
} : undefined,
|
|
712
712
|
headers: typeSchemas.headerParams?.name ? {
|
|
713
713
|
type: typeSchemas.headerParams?.name,
|
|
714
714
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
715
|
-
} :
|
|
715
|
+
} : undefined
|
|
716
716
|
}
|
|
717
717
|
},
|
|
718
718
|
options: {
|
|
@@ -731,19 +731,19 @@ function getParams9({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
731
731
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
732
732
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
733
733
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
734
|
-
} :
|
|
734
|
+
} : undefined,
|
|
735
735
|
data: typeSchemas.request?.name ? {
|
|
736
736
|
type: typeSchemas.request?.name,
|
|
737
737
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
738
|
-
} :
|
|
738
|
+
} : undefined,
|
|
739
739
|
params: typeSchemas.queryParams?.name ? {
|
|
740
740
|
type: typeSchemas.queryParams?.name,
|
|
741
741
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
742
|
-
} :
|
|
742
|
+
} : undefined,
|
|
743
743
|
headers: typeSchemas.headerParams?.name ? {
|
|
744
744
|
type: typeSchemas.headerParams?.name,
|
|
745
745
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
746
|
-
} :
|
|
746
|
+
} : undefined,
|
|
747
747
|
options: {
|
|
748
748
|
type: `
|
|
749
749
|
{
|
|
@@ -830,15 +830,15 @@ function getParams10({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
830
830
|
data: typeSchemas.request?.name ? {
|
|
831
831
|
type: typeSchemas.request?.name,
|
|
832
832
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
833
|
-
} :
|
|
833
|
+
} : undefined,
|
|
834
834
|
params: typeSchemas.queryParams?.name ? {
|
|
835
835
|
type: typeSchemas.queryParams?.name,
|
|
836
836
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
837
|
-
} :
|
|
837
|
+
} : undefined,
|
|
838
838
|
headers: typeSchemas.headerParams?.name ? {
|
|
839
839
|
type: typeSchemas.headerParams?.name,
|
|
840
840
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
841
|
-
} :
|
|
841
|
+
} : undefined
|
|
842
842
|
}
|
|
843
843
|
},
|
|
844
844
|
options: {
|
|
@@ -857,19 +857,19 @@ function getParams10({ paramsType, paramsCasing, pathParamsType, dataReturnType,
|
|
|
857
857
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
858
858
|
children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
859
859
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
860
|
-
} :
|
|
860
|
+
} : undefined,
|
|
861
861
|
data: typeSchemas.request?.name ? {
|
|
862
862
|
type: typeSchemas.request?.name,
|
|
863
863
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
864
|
-
} :
|
|
864
|
+
} : undefined,
|
|
865
865
|
params: typeSchemas.queryParams?.name ? {
|
|
866
866
|
type: typeSchemas.queryParams?.name,
|
|
867
867
|
optional: oas.isOptional(typeSchemas.queryParams?.schema)
|
|
868
|
-
} :
|
|
868
|
+
} : undefined,
|
|
869
869
|
headers: typeSchemas.headerParams?.name ? {
|
|
870
870
|
type: typeSchemas.headerParams?.name,
|
|
871
871
|
optional: oas.isOptional(typeSchemas.headerParams?.schema)
|
|
872
|
-
} :
|
|
872
|
+
} : undefined,
|
|
873
873
|
options: {
|
|
874
874
|
type: `
|
|
875
875
|
{
|