@kubb/plugin-react-query 3.0.0-beta.9 → 3.0.1
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-U35NELYJ.js → chunk-ARL3PQR3.js} +259 -41
- package/dist/chunk-ARL3PQR3.js.map +1 -0
- package/dist/{chunk-D5PFCZWQ.cjs → chunk-FYBD7BZP.cjs} +259 -41
- package/dist/chunk-FYBD7BZP.cjs.map +1 -0
- package/dist/{chunk-JKG4EZID.cjs → chunk-WMQRQT7P.cjs} +158 -116
- package/dist/chunk-WMQRQT7P.cjs.map +1 -0
- package/dist/{chunk-3OOSVEDM.js → chunk-WYNK6OE2.js} +147 -105
- package/dist/chunk-WYNK6OE2.js.map +1 -0
- package/dist/components.cjs +9 -9
- package/dist/components.d.cts +29 -16
- package/dist/components.d.ts +29 -16
- package/dist/components.js +1 -1
- package/dist/generators.cjs +6 -6
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +25 -25
- 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 +24 -24
- package/dist/index.js.map +1 -1
- package/dist/{types-LhwfnVo7.d.cts → types-IuxCCG1K.d.cts} +46 -16
- package/dist/{types-LhwfnVo7.d.ts → types-IuxCCG1K.d.ts} +46 -16
- package/package.json +13 -12
- package/src/components/InfiniteQuery.tsx +53 -6
- package/src/components/InfiniteQueryOptions.tsx +47 -6
- package/src/components/Mutation.tsx +3 -1
- package/src/components/MutationKey.tsx +11 -5
- package/src/components/Query.tsx +62 -6
- package/src/components/QueryKey.tsx +17 -7
- package/src/components/QueryOptions.tsx +47 -7
- package/src/components/SuspenseQuery.tsx +52 -5
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTags.ts +3 -3
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +3 -3
- package/src/generators/__snapshots__/postAsQuery.ts +1 -1
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +1 -3
- package/src/generators/infiniteQueryGenerator.tsx +48 -30
- package/src/generators/mutationGenerator.tsx +30 -18
- package/src/generators/queryGenerator.tsx +29 -17
- package/src/generators/suspenseQueryGenerator.tsx +34 -19
- package/src/plugin.ts +31 -25
- package/src/types.ts +35 -15
- package/dist/chunk-3OOSVEDM.js.map +0 -1
- package/dist/chunk-D5PFCZWQ.cjs.map +0 -1
- package/dist/chunk-JKG4EZID.cjs.map +0 -1
- package/dist/chunk-U35NELYJ.js.map +0 -1
|
@@ -5,12 +5,40 @@ import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
|
|
|
5
5
|
import { jsx, jsxs, Fragment } from '@kubb/react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
// src/components/Mutation.tsx
|
|
8
|
-
function getParams({ pathParamsType, typeSchemas }) {
|
|
8
|
+
function getParams({ paramsType, pathParamsType, typeSchemas }) {
|
|
9
|
+
if (paramsType === "object") {
|
|
10
|
+
return FunctionParams.factory({
|
|
11
|
+
data: {
|
|
12
|
+
mode: "object",
|
|
13
|
+
children: {
|
|
14
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
15
|
+
data: typeSchemas.request?.name ? {
|
|
16
|
+
type: typeSchemas.request?.name,
|
|
17
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
18
|
+
} : void 0,
|
|
19
|
+
params: typeSchemas.queryParams?.name ? {
|
|
20
|
+
type: typeSchemas.queryParams?.name,
|
|
21
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
22
|
+
} : void 0,
|
|
23
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
24
|
+
type: typeSchemas.headerParams?.name,
|
|
25
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
26
|
+
} : void 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
config: {
|
|
30
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
|
|
31
|
+
default: "{}"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
9
35
|
return FunctionParams.factory({
|
|
10
|
-
pathParams: {
|
|
36
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
11
37
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
12
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
13
|
-
|
|
38
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
39
|
+
type: typeSchemas.pathParams?.name,
|
|
40
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
41
|
+
} : void 0,
|
|
14
42
|
data: typeSchemas.request?.name ? {
|
|
15
43
|
type: typeSchemas.request?.name,
|
|
16
44
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -38,6 +66,7 @@ function Client({
|
|
|
38
66
|
dataReturnType,
|
|
39
67
|
parser,
|
|
40
68
|
zodSchemas,
|
|
69
|
+
paramsType,
|
|
41
70
|
pathParamsType,
|
|
42
71
|
operation
|
|
43
72
|
}) {
|
|
@@ -53,7 +82,7 @@ function Client({
|
|
|
53
82
|
typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error",
|
|
54
83
|
typeSchemas.request?.name || "unknown"
|
|
55
84
|
].filter(Boolean);
|
|
56
|
-
const params = getParams({ pathParamsType, typeSchemas });
|
|
85
|
+
const params = getParams({ paramsType, pathParamsType, typeSchemas });
|
|
57
86
|
const clientParams = FunctionParams.factory({
|
|
58
87
|
config: {
|
|
59
88
|
mode: "object",
|
|
@@ -127,16 +156,20 @@ function Operations({ name, operations }) {
|
|
|
127
156
|
function getParams2({}) {
|
|
128
157
|
return FunctionParams.factory({});
|
|
129
158
|
}
|
|
130
|
-
|
|
159
|
+
var getTransformer = ({ operation }) => {
|
|
131
160
|
const path = new URLPath(operation.path);
|
|
161
|
+
return [JSON.stringify({ url: path.path })].filter(Boolean);
|
|
162
|
+
};
|
|
163
|
+
function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }) {
|
|
132
164
|
const params = getParams2({ pathParamsType, typeSchemas });
|
|
133
|
-
const keys =
|
|
165
|
+
const keys = transformer({ operation, schemas: typeSchemas });
|
|
134
166
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
135
|
-
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${
|
|
167
|
+
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }),
|
|
136
168
|
/* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
|
|
137
169
|
] });
|
|
138
170
|
}
|
|
139
171
|
MutationKey.getParams = getParams2;
|
|
172
|
+
MutationKey.getTransformer = getTransformer;
|
|
140
173
|
function getParams3({ dataReturnType, typeSchemas }) {
|
|
141
174
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
142
175
|
const mutationParams = FunctionParams.factory({
|
|
@@ -168,7 +201,7 @@ function getParams3({ dataReturnType, typeSchemas }) {
|
|
|
168
201
|
}
|
|
169
202
|
});
|
|
170
203
|
}
|
|
171
|
-
function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
204
|
+
function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
172
205
|
const mutationKeyParams = MutationKey.getParams({
|
|
173
206
|
pathParamsType,
|
|
174
207
|
typeSchemas
|
|
@@ -179,6 +212,7 @@ function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchema
|
|
|
179
212
|
typeSchemas
|
|
180
213
|
});
|
|
181
214
|
const clientParams = Client.getParams({
|
|
215
|
+
paramsType,
|
|
182
216
|
typeSchemas,
|
|
183
217
|
pathParamsType
|
|
184
218
|
});
|
|
@@ -256,29 +290,65 @@ function getParams4({ pathParamsType, typeSchemas }) {
|
|
|
256
290
|
} : void 0
|
|
257
291
|
});
|
|
258
292
|
}
|
|
259
|
-
|
|
293
|
+
var getTransformer2 = ({ operation, schemas }) => {
|
|
260
294
|
const path = new URLPath(operation.path);
|
|
261
|
-
const params = getParams4({ pathParamsType, typeSchemas });
|
|
262
295
|
const keys = [
|
|
263
296
|
path.toObject({
|
|
264
297
|
type: "path",
|
|
265
298
|
stringify: true
|
|
266
299
|
}),
|
|
267
|
-
|
|
268
|
-
|
|
300
|
+
schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
|
|
301
|
+
schemas.request?.name ? "...(data ? [data] : [])" : void 0
|
|
269
302
|
].filter(Boolean);
|
|
303
|
+
return keys;
|
|
304
|
+
};
|
|
305
|
+
function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer2 }) {
|
|
306
|
+
const params = getParams4({ pathParamsType, typeSchemas });
|
|
307
|
+
const keys = transformer({
|
|
308
|
+
operation,
|
|
309
|
+
schemas: typeSchemas
|
|
310
|
+
});
|
|
270
311
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
271
|
-
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${
|
|
312
|
+
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }),
|
|
272
313
|
/* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
|
|
273
314
|
] });
|
|
274
315
|
}
|
|
275
316
|
QueryKey.getParams = getParams4;
|
|
276
|
-
|
|
317
|
+
QueryKey.getTransformer = getTransformer2;
|
|
318
|
+
function getParams5({ paramsType, pathParamsType, typeSchemas }) {
|
|
319
|
+
if (paramsType === "object") {
|
|
320
|
+
return FunctionParams.factory({
|
|
321
|
+
data: {
|
|
322
|
+
mode: "object",
|
|
323
|
+
children: {
|
|
324
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
325
|
+
data: typeSchemas.request?.name ? {
|
|
326
|
+
type: typeSchemas.request?.name,
|
|
327
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
328
|
+
} : void 0,
|
|
329
|
+
params: typeSchemas.queryParams?.name ? {
|
|
330
|
+
type: typeSchemas.queryParams?.name,
|
|
331
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
332
|
+
} : void 0,
|
|
333
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
334
|
+
type: typeSchemas.headerParams?.name,
|
|
335
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
336
|
+
} : void 0
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
config: {
|
|
340
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
|
|
341
|
+
default: "{}"
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
277
345
|
return FunctionParams.factory({
|
|
278
|
-
pathParams: {
|
|
346
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
279
347
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
280
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
281
|
-
|
|
348
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
349
|
+
type: typeSchemas.pathParams?.name,
|
|
350
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
351
|
+
} : void 0,
|
|
282
352
|
data: typeSchemas.request?.name ? {
|
|
283
353
|
type: typeSchemas.request?.name,
|
|
284
354
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -297,10 +367,11 @@ function getParams5({ pathParamsType, typeSchemas }) {
|
|
|
297
367
|
}
|
|
298
368
|
});
|
|
299
369
|
}
|
|
300
|
-
function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }) {
|
|
301
|
-
const params = getParams5({ pathParamsType, typeSchemas });
|
|
370
|
+
function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }) {
|
|
371
|
+
const params = getParams5({ paramsType, pathParamsType, typeSchemas });
|
|
302
372
|
const clientParams = Client.getParams({
|
|
303
373
|
typeSchemas,
|
|
374
|
+
paramsType,
|
|
304
375
|
pathParamsType
|
|
305
376
|
});
|
|
306
377
|
const queryKeyParams = QueryKey.getParams({
|
|
@@ -322,13 +393,46 @@ function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyN
|
|
|
322
393
|
` }) });
|
|
323
394
|
}
|
|
324
395
|
QueryOptions.getParams = getParams5;
|
|
325
|
-
function getParams6({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
396
|
+
function getParams6({ paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
326
397
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
398
|
+
if (paramsType === "object") {
|
|
399
|
+
return FunctionParams.factory({
|
|
400
|
+
data: {
|
|
401
|
+
mode: "object",
|
|
402
|
+
children: {
|
|
403
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
404
|
+
data: typeSchemas.request?.name ? {
|
|
405
|
+
type: typeSchemas.request?.name,
|
|
406
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
407
|
+
} : void 0,
|
|
408
|
+
params: typeSchemas.queryParams?.name ? {
|
|
409
|
+
type: typeSchemas.queryParams?.name,
|
|
410
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
411
|
+
} : void 0,
|
|
412
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
413
|
+
type: typeSchemas.headerParams?.name,
|
|
414
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
415
|
+
} : void 0
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
options: {
|
|
419
|
+
type: `
|
|
420
|
+
{
|
|
421
|
+
query?: Partial<QueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", "TData", "TQueryData", "TQueryKey"].join(", ")}>>,
|
|
422
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
|
|
423
|
+
}
|
|
424
|
+
`,
|
|
425
|
+
default: "{}"
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
327
429
|
return FunctionParams.factory({
|
|
328
|
-
pathParams: {
|
|
430
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
329
431
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
330
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
331
|
-
|
|
432
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
433
|
+
type: typeSchemas.pathParams?.name,
|
|
434
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
435
|
+
} : void 0,
|
|
332
436
|
data: typeSchemas.request?.name ? {
|
|
333
437
|
type: typeSchemas.request?.name,
|
|
334
438
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -352,7 +456,17 @@ function getParams6({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
|
352
456
|
}
|
|
353
457
|
});
|
|
354
458
|
}
|
|
355
|
-
function Query({
|
|
459
|
+
function Query({
|
|
460
|
+
name,
|
|
461
|
+
queryKeyTypeName,
|
|
462
|
+
queryOptionsName,
|
|
463
|
+
queryKeyName,
|
|
464
|
+
paramsType,
|
|
465
|
+
pathParamsType,
|
|
466
|
+
dataReturnType,
|
|
467
|
+
typeSchemas,
|
|
468
|
+
operation
|
|
469
|
+
}) {
|
|
356
470
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
357
471
|
const returnType = `UseQueryResult<${["TData", typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"].join(", ")}> & { queryKey: TQueryKey }`;
|
|
358
472
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
|
|
@@ -361,10 +475,12 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathPar
|
|
|
361
475
|
typeSchemas
|
|
362
476
|
});
|
|
363
477
|
const queryOptionsParams = QueryOptions.getParams({
|
|
478
|
+
paramsType,
|
|
364
479
|
pathParamsType,
|
|
365
480
|
typeSchemas
|
|
366
481
|
});
|
|
367
482
|
const params = getParams6({
|
|
483
|
+
paramsType,
|
|
368
484
|
pathParamsType,
|
|
369
485
|
dataReturnType,
|
|
370
486
|
typeSchemas
|
|
@@ -398,12 +514,40 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathPar
|
|
|
398
514
|
) });
|
|
399
515
|
}
|
|
400
516
|
Query.getParams = getParams6;
|
|
401
|
-
function getParams7({ pathParamsType, typeSchemas }) {
|
|
517
|
+
function getParams7({ paramsType, pathParamsType, typeSchemas }) {
|
|
518
|
+
if (paramsType === "object") {
|
|
519
|
+
return FunctionParams.factory({
|
|
520
|
+
data: {
|
|
521
|
+
mode: "object",
|
|
522
|
+
children: {
|
|
523
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
524
|
+
data: typeSchemas.request?.name ? {
|
|
525
|
+
type: typeSchemas.request?.name,
|
|
526
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
527
|
+
} : void 0,
|
|
528
|
+
params: typeSchemas.queryParams?.name ? {
|
|
529
|
+
type: typeSchemas.queryParams?.name,
|
|
530
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
531
|
+
} : void 0,
|
|
532
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
533
|
+
type: typeSchemas.headerParams?.name,
|
|
534
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
535
|
+
} : void 0
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
config: {
|
|
539
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
|
|
540
|
+
default: "{}"
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
402
544
|
return FunctionParams.factory({
|
|
403
|
-
pathParams: {
|
|
545
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
404
546
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
405
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
406
|
-
|
|
547
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
548
|
+
type: typeSchemas.pathParams?.name,
|
|
549
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
550
|
+
} : void 0,
|
|
407
551
|
data: typeSchemas.request?.name ? {
|
|
408
552
|
type: typeSchemas.request?.name,
|
|
409
553
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -428,14 +572,16 @@ function InfiniteQueryOptions({
|
|
|
428
572
|
initialPageParam,
|
|
429
573
|
cursorParam,
|
|
430
574
|
typeSchemas,
|
|
575
|
+
paramsType,
|
|
431
576
|
dataReturnType,
|
|
432
577
|
pathParamsType,
|
|
433
578
|
queryParam,
|
|
434
579
|
queryKeyName
|
|
435
580
|
}) {
|
|
436
|
-
const params = getParams7({ pathParamsType, typeSchemas });
|
|
581
|
+
const params = getParams7({ paramsType, pathParamsType, typeSchemas });
|
|
437
582
|
const clientParams = Client.getParams({
|
|
438
583
|
typeSchemas,
|
|
584
|
+
paramsType,
|
|
439
585
|
pathParamsType
|
|
440
586
|
});
|
|
441
587
|
const queryKeyParams = QueryKey.getParams({
|
|
@@ -485,13 +631,46 @@ function InfiniteQueryOptions({
|
|
|
485
631
|
] }) });
|
|
486
632
|
}
|
|
487
633
|
InfiniteQueryOptions.getParams = getParams7;
|
|
488
|
-
function getParams8({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
634
|
+
function getParams8({ paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
489
635
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
636
|
+
if (paramsType === "object") {
|
|
637
|
+
return FunctionParams.factory({
|
|
638
|
+
data: {
|
|
639
|
+
mode: "object",
|
|
640
|
+
children: {
|
|
641
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
642
|
+
data: typeSchemas.request?.name ? {
|
|
643
|
+
type: typeSchemas.request?.name,
|
|
644
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
645
|
+
} : void 0,
|
|
646
|
+
params: typeSchemas.queryParams?.name ? {
|
|
647
|
+
type: typeSchemas.queryParams?.name,
|
|
648
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
649
|
+
} : void 0,
|
|
650
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
651
|
+
type: typeSchemas.headerParams?.name,
|
|
652
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
653
|
+
} : void 0
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
options: {
|
|
657
|
+
type: `
|
|
658
|
+
{
|
|
659
|
+
query?: Partial<InfiniteQueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", "TData", "TQueryData", "TQueryKey"].join(", ")}>>,
|
|
660
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
|
|
661
|
+
}
|
|
662
|
+
`,
|
|
663
|
+
default: "{}"
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
490
667
|
return FunctionParams.factory({
|
|
491
|
-
pathParams: {
|
|
668
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
492
669
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
493
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
494
|
-
|
|
670
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
671
|
+
type: typeSchemas.pathParams?.name,
|
|
672
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
673
|
+
} : void 0,
|
|
495
674
|
data: typeSchemas.request?.name ? {
|
|
496
675
|
type: typeSchemas.request?.name,
|
|
497
676
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -520,6 +699,7 @@ function InfiniteQuery({
|
|
|
520
699
|
queryKeyTypeName,
|
|
521
700
|
queryOptionsName,
|
|
522
701
|
queryKeyName,
|
|
702
|
+
paramsType,
|
|
523
703
|
pathParamsType,
|
|
524
704
|
dataReturnType,
|
|
525
705
|
typeSchemas,
|
|
@@ -527,16 +707,18 @@ function InfiniteQuery({
|
|
|
527
707
|
}) {
|
|
528
708
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
529
709
|
const returnType = `UseInfiniteQueryResult<${["TData", typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"].join(", ")}> & { queryKey: TQueryKey }`;
|
|
530
|
-
const generics = [`TData =
|
|
710
|
+
const generics = [`TData = InfiniteData<${TData}>`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
|
|
531
711
|
const queryKeyParams = QueryKey.getParams({
|
|
532
712
|
pathParamsType,
|
|
533
713
|
typeSchemas
|
|
534
714
|
});
|
|
535
715
|
const queryOptionsParams = QueryOptions.getParams({
|
|
716
|
+
paramsType,
|
|
536
717
|
pathParamsType,
|
|
537
718
|
typeSchemas
|
|
538
719
|
});
|
|
539
720
|
const params = getParams8({
|
|
721
|
+
paramsType,
|
|
540
722
|
pathParamsType,
|
|
541
723
|
dataReturnType,
|
|
542
724
|
typeSchemas
|
|
@@ -570,13 +752,46 @@ function InfiniteQuery({
|
|
|
570
752
|
) });
|
|
571
753
|
}
|
|
572
754
|
InfiniteQuery.getParams = getParams8;
|
|
573
|
-
function getParams9({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
755
|
+
function getParams9({ paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
574
756
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
757
|
+
if (paramsType === "object") {
|
|
758
|
+
return FunctionParams.factory({
|
|
759
|
+
data: {
|
|
760
|
+
mode: "object",
|
|
761
|
+
children: {
|
|
762
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
763
|
+
data: typeSchemas.request?.name ? {
|
|
764
|
+
type: typeSchemas.request?.name,
|
|
765
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
766
|
+
} : void 0,
|
|
767
|
+
params: typeSchemas.queryParams?.name ? {
|
|
768
|
+
type: typeSchemas.queryParams?.name,
|
|
769
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
770
|
+
} : void 0,
|
|
771
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
772
|
+
type: typeSchemas.headerParams?.name,
|
|
773
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
774
|
+
} : void 0
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
options: {
|
|
778
|
+
type: `
|
|
779
|
+
{
|
|
780
|
+
query?: Partial<UseSuspenseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", "TData", "TQueryKey"].join(", ")}>>,
|
|
781
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"}
|
|
782
|
+
}
|
|
783
|
+
`,
|
|
784
|
+
default: "{}"
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
575
788
|
return FunctionParams.factory({
|
|
576
|
-
pathParams: {
|
|
789
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
577
790
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
578
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
579
|
-
|
|
791
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
792
|
+
type: typeSchemas.pathParams?.name,
|
|
793
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
794
|
+
} : void 0,
|
|
580
795
|
data: typeSchemas.request?.name ? {
|
|
581
796
|
type: typeSchemas.request?.name,
|
|
582
797
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -605,6 +820,7 @@ function SuspenseQuery({
|
|
|
605
820
|
queryKeyTypeName,
|
|
606
821
|
queryOptionsName,
|
|
607
822
|
queryKeyName,
|
|
823
|
+
paramsType,
|
|
608
824
|
pathParamsType,
|
|
609
825
|
dataReturnType,
|
|
610
826
|
typeSchemas,
|
|
@@ -618,10 +834,12 @@ function SuspenseQuery({
|
|
|
618
834
|
typeSchemas
|
|
619
835
|
});
|
|
620
836
|
const queryOptionsParams = QueryOptions.getParams({
|
|
837
|
+
paramsType,
|
|
621
838
|
pathParamsType,
|
|
622
839
|
typeSchemas
|
|
623
840
|
});
|
|
624
841
|
const params = getParams9({
|
|
842
|
+
paramsType,
|
|
625
843
|
pathParamsType,
|
|
626
844
|
dataReturnType,
|
|
627
845
|
typeSchemas
|
|
@@ -657,5 +875,5 @@ function SuspenseQuery({
|
|
|
657
875
|
SuspenseQuery.getParams = getParams9;
|
|
658
876
|
|
|
659
877
|
export { Client, InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Operations, Query, QueryKey, QueryOptions, SuspenseQuery };
|
|
660
|
-
//# sourceMappingURL=chunk-
|
|
661
|
-
//# sourceMappingURL=chunk-
|
|
878
|
+
//# sourceMappingURL=chunk-ARL3PQR3.js.map
|
|
879
|
+
//# sourceMappingURL=chunk-ARL3PQR3.js.map
|