@kubb/plugin-react-query 3.0.0-beta.8 → 3.0.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.
- package/dist/{chunk-C2H3KPHM.cjs → chunk-EOG7AHFO.cjs} +276 -44
- package/dist/chunk-EOG7AHFO.cjs.map +1 -0
- package/dist/{chunk-Y3DM2P6L.js → chunk-EY5KE7R7.js} +276 -44
- package/dist/chunk-EY5KE7R7.js.map +1 -0
- package/dist/{chunk-3U5EOLDD.cjs → chunk-NBC6BPMV.cjs} +141 -110
- package/dist/chunk-NBC6BPMV.cjs.map +1 -0
- package/dist/{chunk-ES4YRHDI.js → chunk-NZKAIPYC.js} +130 -99
- package/dist/chunk-NZKAIPYC.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 +24 -24
- 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 +23 -23
- 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 -13
- package/src/components/InfiniteQuery.tsx +52 -5
- package/src/components/InfiniteQueryOptions.tsx +62 -7
- package/src/components/Mutation.tsx +9 -3
- 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 +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +1 -1
- package/src/generators/__snapshots__/postAsQuery.ts +1 -1
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +1 -3
- package/src/generators/infiniteQueryGenerator.tsx +40 -28
- package/src/generators/mutationGenerator.tsx +25 -16
- package/src/generators/queryGenerator.tsx +24 -17
- package/src/generators/suspenseQueryGenerator.tsx +26 -16
- package/src/plugin.ts +23 -20
- package/src/types.ts +35 -15
- package/dist/chunk-3U5EOLDD.cjs.map +0 -1
- package/dist/chunk-C2H3KPHM.cjs.map +0 -1
- package/dist/chunk-ES4YRHDI.js.map +0 -1
- package/dist/chunk-Y3DM2P6L.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({
|
|
@@ -155,7 +188,7 @@ function getParams3({ dataReturnType, typeSchemas }) {
|
|
|
155
188
|
} : void 0
|
|
156
189
|
});
|
|
157
190
|
const TRequest = mutationParams.toConstructor({ valueAsType: true });
|
|
158
|
-
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", `{${TRequest}}`].join(", ");
|
|
191
|
+
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", TRequest ? `{${TRequest}}` : void 0].filter(Boolean).join(", ");
|
|
159
192
|
return FunctionParams.factory({
|
|
160
193
|
options: {
|
|
161
194
|
type: `
|
|
@@ -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
|
});
|
|
@@ -215,7 +249,7 @@ function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchema
|
|
|
215
249
|
});
|
|
216
250
|
const TRequest = mutationParams.toConstructor({ valueAsType: true });
|
|
217
251
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
218
|
-
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", `{${TRequest}}`].join(", ");
|
|
252
|
+
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", TRequest ? `{${TRequest}}` : void 0].filter(Boolean).join(", ");
|
|
219
253
|
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
|
|
220
254
|
Function,
|
|
221
255
|
{
|
|
@@ -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({
|
|
@@ -456,7 +602,8 @@ function InfiniteQueryOptions({
|
|
|
456
602
|
}` : "";
|
|
457
603
|
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
|
|
458
604
|
const enabledText = enabled ? `enabled: !!(${enabled})` : "";
|
|
459
|
-
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxs(Function, { name, export: true, params: params.toConstructor(), children: [
|
|
606
|
+
infiniteOverrideParams && `
|
|
460
607
|
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
461
608
|
return infiniteQueryOptions({
|
|
462
609
|
${enabledText}
|
|
@@ -468,16 +615,62 @@ function InfiniteQueryOptions({
|
|
|
468
615
|
},
|
|
469
616
|
${queryOptions.join("\n")}
|
|
470
617
|
})
|
|
471
|
-
|
|
618
|
+
`,
|
|
619
|
+
!infiniteOverrideParams && `
|
|
620
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
621
|
+
return infiniteQueryOptions({
|
|
622
|
+
${enabledText}
|
|
623
|
+
queryKey,
|
|
624
|
+
queryFn: async ({ signal }) => {
|
|
625
|
+
config.signal = signal
|
|
626
|
+
return ${clientName}(${clientParams.toCall()})
|
|
627
|
+
},
|
|
628
|
+
${queryOptions.join("\n")}
|
|
629
|
+
})
|
|
630
|
+
`
|
|
631
|
+
] }) });
|
|
472
632
|
}
|
|
473
633
|
InfiniteQueryOptions.getParams = getParams7;
|
|
474
|
-
function getParams8({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
634
|
+
function getParams8({ paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
475
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
|
+
}
|
|
476
667
|
return FunctionParams.factory({
|
|
477
|
-
pathParams: {
|
|
668
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
478
669
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
479
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
480
|
-
|
|
670
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
671
|
+
type: typeSchemas.pathParams?.name,
|
|
672
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
673
|
+
} : void 0,
|
|
481
674
|
data: typeSchemas.request?.name ? {
|
|
482
675
|
type: typeSchemas.request?.name,
|
|
483
676
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -506,6 +699,7 @@ function InfiniteQuery({
|
|
|
506
699
|
queryKeyTypeName,
|
|
507
700
|
queryOptionsName,
|
|
508
701
|
queryKeyName,
|
|
702
|
+
paramsType,
|
|
509
703
|
pathParamsType,
|
|
510
704
|
dataReturnType,
|
|
511
705
|
typeSchemas,
|
|
@@ -519,10 +713,12 @@ function InfiniteQuery({
|
|
|
519
713
|
typeSchemas
|
|
520
714
|
});
|
|
521
715
|
const queryOptionsParams = QueryOptions.getParams({
|
|
716
|
+
paramsType,
|
|
522
717
|
pathParamsType,
|
|
523
718
|
typeSchemas
|
|
524
719
|
});
|
|
525
720
|
const params = getParams8({
|
|
721
|
+
paramsType,
|
|
526
722
|
pathParamsType,
|
|
527
723
|
dataReturnType,
|
|
528
724
|
typeSchemas
|
|
@@ -556,13 +752,46 @@ function InfiniteQuery({
|
|
|
556
752
|
) });
|
|
557
753
|
}
|
|
558
754
|
InfiniteQuery.getParams = getParams8;
|
|
559
|
-
function getParams9({ pathParamsType, dataReturnType, typeSchemas }) {
|
|
755
|
+
function getParams9({ paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
560
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
|
+
}
|
|
561
788
|
return FunctionParams.factory({
|
|
562
|
-
pathParams: {
|
|
789
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
563
790
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
564
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true })
|
|
565
|
-
|
|
791
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
792
|
+
type: typeSchemas.pathParams?.name,
|
|
793
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
794
|
+
} : void 0,
|
|
566
795
|
data: typeSchemas.request?.name ? {
|
|
567
796
|
type: typeSchemas.request?.name,
|
|
568
797
|
optional: isOptional(typeSchemas.request?.schema)
|
|
@@ -591,6 +820,7 @@ function SuspenseQuery({
|
|
|
591
820
|
queryKeyTypeName,
|
|
592
821
|
queryOptionsName,
|
|
593
822
|
queryKeyName,
|
|
823
|
+
paramsType,
|
|
594
824
|
pathParamsType,
|
|
595
825
|
dataReturnType,
|
|
596
826
|
typeSchemas,
|
|
@@ -604,10 +834,12 @@ function SuspenseQuery({
|
|
|
604
834
|
typeSchemas
|
|
605
835
|
});
|
|
606
836
|
const queryOptionsParams = QueryOptions.getParams({
|
|
837
|
+
paramsType,
|
|
607
838
|
pathParamsType,
|
|
608
839
|
typeSchemas
|
|
609
840
|
});
|
|
610
841
|
const params = getParams9({
|
|
842
|
+
paramsType,
|
|
611
843
|
pathParamsType,
|
|
612
844
|
dataReturnType,
|
|
613
845
|
typeSchemas
|
|
@@ -643,5 +875,5 @@ function SuspenseQuery({
|
|
|
643
875
|
SuspenseQuery.getParams = getParams9;
|
|
644
876
|
|
|
645
877
|
export { Client, InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Operations, Query, QueryKey, QueryOptions, SuspenseQuery };
|
|
646
|
-
//# sourceMappingURL=chunk-
|
|
647
|
-
//# sourceMappingURL=chunk-
|
|
878
|
+
//# sourceMappingURL=chunk-EY5KE7R7.js.map
|
|
879
|
+
//# sourceMappingURL=chunk-EY5KE7R7.js.map
|