@kubb/plugin-vue-query 5.0.0-beta.81 → 5.0.0-beta.85
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/index.cjs +82 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.cjs
CHANGED
|
@@ -26,11 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
//#endregion
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
-
let
|
|
29
|
+
let kubb_kit = require("kubb/kit");
|
|
30
30
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
31
|
+
let kubb_jsx = require("kubb/jsx");
|
|
32
|
+
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
34
33
|
//#region ../../internals/utils/src/casing.ts
|
|
35
34
|
/**
|
|
36
35
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -567,11 +566,11 @@ function MutationKey({ name, node, transformer }) {
|
|
|
567
566
|
node,
|
|
568
567
|
casing: "camelcase"
|
|
569
568
|
});
|
|
570
|
-
return /* @__PURE__ */ (0,
|
|
569
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
571
570
|
name,
|
|
572
571
|
isExportable: true,
|
|
573
572
|
isIndexable: true,
|
|
574
|
-
children: /* @__PURE__ */ (0,
|
|
573
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
575
574
|
name,
|
|
576
575
|
export: true,
|
|
577
576
|
params: paramsSignature,
|
|
@@ -820,23 +819,23 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
820
819
|
node,
|
|
821
820
|
casing: "camelcase"
|
|
822
821
|
});
|
|
823
|
-
return /* @__PURE__ */ (0,
|
|
822
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
824
823
|
name,
|
|
825
824
|
isExportable: true,
|
|
826
825
|
isIndexable: true,
|
|
827
|
-
children: /* @__PURE__ */ (0,
|
|
826
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
828
827
|
name,
|
|
829
828
|
export: true,
|
|
830
829
|
params: paramsSignature,
|
|
831
830
|
singleLine: true,
|
|
832
831
|
children: `[${keys.join(", ")}] as const`
|
|
833
832
|
})
|
|
834
|
-
}), /* @__PURE__ */ (0,
|
|
833
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
835
834
|
name: typeName,
|
|
836
835
|
isExportable: true,
|
|
837
836
|
isIndexable: true,
|
|
838
837
|
isTypeOnly: true,
|
|
839
|
-
children: /* @__PURE__ */ (0,
|
|
838
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
840
839
|
name: typeName,
|
|
841
840
|
export: true,
|
|
842
841
|
children: `ReturnType<typeof ${name}>`
|
|
@@ -868,11 +867,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
|
|
|
868
867
|
signal: true
|
|
869
868
|
})}
|
|
870
869
|
return data`;
|
|
871
|
-
return /* @__PURE__ */ (0,
|
|
870
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
872
871
|
name,
|
|
873
872
|
isExportable: true,
|
|
874
873
|
isIndexable: true,
|
|
875
|
-
children: /* @__PURE__ */ (0,
|
|
874
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
876
875
|
name,
|
|
877
876
|
export: true,
|
|
878
877
|
params: paramsSignature,
|
|
@@ -934,11 +933,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
934
933
|
const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
|
|
935
934
|
const paramsNode = buildInfiniteQueryParamsNode(node, { resolver: tsResolver });
|
|
936
935
|
const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
|
|
937
|
-
return /* @__PURE__ */ (0,
|
|
936
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
938
937
|
name,
|
|
939
938
|
isExportable: true,
|
|
940
939
|
isIndexable: true,
|
|
941
|
-
children: /* @__PURE__ */ (0,
|
|
940
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
942
941
|
name,
|
|
943
942
|
export: true,
|
|
944
943
|
generics: generics.join(", "),
|
|
@@ -995,8 +994,8 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
995
994
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
996
995
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
997
996
|
if (hasNewParams) {
|
|
998
|
-
const nextAccessor = nextParam ?
|
|
999
|
-
const prevAccessor = previousParam ?
|
|
997
|
+
const nextAccessor = nextParam ? kubb_kit.ast.getNestedAccessor(nextParam, "lastPage") : null;
|
|
998
|
+
const prevAccessor = previousParam ? kubb_kit.ast.getNestedAccessor(previousParam, "firstPage") : null;
|
|
1000
999
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1001
1000
|
}
|
|
1002
1001
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1011,11 +1010,11 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1011
1010
|
...(query ?? {}),
|
|
1012
1011
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1013
1012
|
} as ${queryParamsTypeName}` : "";
|
|
1014
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1013
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1015
1014
|
name,
|
|
1016
1015
|
isExportable: true,
|
|
1017
1016
|
isIndexable: true,
|
|
1018
|
-
children: /* @__PURE__ */ (0,
|
|
1017
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1019
1018
|
name,
|
|
1020
1019
|
export: true,
|
|
1021
1020
|
params: paramsSignature,
|
|
@@ -1032,11 +1031,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1032
1031
|
`
|
|
1033
1032
|
})
|
|
1034
1033
|
});
|
|
1035
|
-
return /* @__PURE__ */ (0,
|
|
1034
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1036
1035
|
name,
|
|
1037
1036
|
isExportable: true,
|
|
1038
1037
|
isIndexable: true,
|
|
1039
|
-
children: /* @__PURE__ */ (0,
|
|
1038
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1040
1039
|
name,
|
|
1041
1040
|
export: true,
|
|
1042
1041
|
params: paramsSignature,
|
|
@@ -1104,11 +1103,11 @@ function Mutation({ name, clientName, node, tsResolver, mutationKeyName }) {
|
|
|
1104
1103
|
const mutationKeyParamsCall = callPrinter$1.print(mutationKeyParamsNode) ?? "";
|
|
1105
1104
|
const paramsNode = buildMutationParamsNode(node, { resolver: tsResolver });
|
|
1106
1105
|
const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
|
|
1107
|
-
return /* @__PURE__ */ (0,
|
|
1106
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1108
1107
|
name,
|
|
1109
1108
|
isExportable: true,
|
|
1110
1109
|
isIndexable: true,
|
|
1111
|
-
children: /* @__PURE__ */ (0,
|
|
1110
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1112
1111
|
name,
|
|
1113
1112
|
export: true,
|
|
1114
1113
|
params: paramsSignature,
|
|
@@ -1176,11 +1175,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1176
1175
|
const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
|
|
1177
1176
|
const paramsNode = buildQueryParamsNode(node, { resolver: tsResolver });
|
|
1178
1177
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
1179
|
-
return /* @__PURE__ */ (0,
|
|
1178
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1180
1179
|
name,
|
|
1181
1180
|
isExportable: true,
|
|
1182
1181
|
isIndexable: true,
|
|
1183
|
-
children: /* @__PURE__ */ (0,
|
|
1182
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1184
1183
|
name,
|
|
1185
1184
|
export: true,
|
|
1186
1185
|
generics: generics.join(", "),
|
|
@@ -1212,11 +1211,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1212
1211
|
* composable per query operation, wiring the configured cursor path into
|
|
1213
1212
|
* TanStack Query's cursor-based pagination.
|
|
1214
1213
|
*/
|
|
1215
|
-
const infiniteQueryGenerator = (0,
|
|
1214
|
+
const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1216
1215
|
name: "vue-query-infinite",
|
|
1217
|
-
renderer:
|
|
1216
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1218
1217
|
operation(node, ctx) {
|
|
1219
|
-
if (!
|
|
1218
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1220
1219
|
const { config, driver, resolver, root } = ctx;
|
|
1221
1220
|
const { output, query, mutation, infinite, client, group, hooks } = ctx.options;
|
|
1222
1221
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1269,7 +1268,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1269
1268
|
})
|
|
1270
1269
|
].filter((name) => Boolean(name));
|
|
1271
1270
|
const calledClientName = contractOp.name;
|
|
1272
|
-
return /* @__PURE__ */ (0,
|
|
1271
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1273
1272
|
baseName: meta.file.baseName,
|
|
1274
1273
|
path: meta.file.path,
|
|
1275
1274
|
meta: meta.file.meta,
|
|
@@ -1290,49 +1289,49 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1290
1289
|
}
|
|
1291
1290
|
}),
|
|
1292
1291
|
children: [
|
|
1293
|
-
/* @__PURE__ */ (0,
|
|
1292
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1294
1293
|
name: [contractOp.name],
|
|
1295
1294
|
root: meta.file.path,
|
|
1296
1295
|
path: contractOp.path
|
|
1297
1296
|
}),
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
1297
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1299
1298
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1300
1299
|
root: meta.file.path,
|
|
1301
1300
|
path: contractOp.clientPath,
|
|
1302
1301
|
isTypeOnly: true
|
|
1303
1302
|
}),
|
|
1304
|
-
/* @__PURE__ */ (0,
|
|
1303
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1305
1304
|
name: ["toValue"],
|
|
1306
1305
|
path: "vue"
|
|
1307
1306
|
}),
|
|
1308
|
-
/* @__PURE__ */ (0,
|
|
1307
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1309
1308
|
name: ["MaybeRefOrGetter"],
|
|
1310
1309
|
path: "vue",
|
|
1311
1310
|
isTypeOnly: true
|
|
1312
1311
|
}),
|
|
1313
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1312
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1314
1313
|
name: Array.from(new Set(importedTypeNames)),
|
|
1315
1314
|
root: meta.file.path,
|
|
1316
1315
|
path: meta.fileTs.path,
|
|
1317
1316
|
isTypeOnly: true
|
|
1318
1317
|
}),
|
|
1319
|
-
/* @__PURE__ */ (0,
|
|
1318
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1320
1319
|
name: queryKeyName,
|
|
1321
1320
|
typeName: queryKeyTypeName,
|
|
1322
1321
|
node,
|
|
1323
1322
|
tsResolver,
|
|
1324
1323
|
transformer: ctx.options.queryKey
|
|
1325
1324
|
}),
|
|
1326
|
-
/* @__PURE__ */ (0,
|
|
1325
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1327
1326
|
name: ["InfiniteData"],
|
|
1328
1327
|
isTypeOnly: true,
|
|
1329
1328
|
path: importPath
|
|
1330
1329
|
}),
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1330
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1332
1331
|
name: ["infiniteQueryOptions"],
|
|
1333
1332
|
path: importPath
|
|
1334
1333
|
}),
|
|
1335
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQueryOptions, {
|
|
1336
1335
|
name: queryOptionsName,
|
|
1337
1336
|
clientName: calledClientName,
|
|
1338
1337
|
queryKeyName,
|
|
@@ -1344,12 +1343,12 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1344
1343
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1345
1344
|
queryParam: infiniteOptions.queryParam
|
|
1346
1345
|
}),
|
|
1347
|
-
hooks && /* @__PURE__ */ (0,
|
|
1348
|
-
/* @__PURE__ */ (0,
|
|
1346
|
+
hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1347
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1349
1348
|
name: ["useInfiniteQuery"],
|
|
1350
1349
|
path: importPath
|
|
1351
1350
|
}),
|
|
1352
|
-
/* @__PURE__ */ (0,
|
|
1351
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1353
1352
|
name: [
|
|
1354
1353
|
"QueryKey",
|
|
1355
1354
|
"QueryClient",
|
|
@@ -1359,7 +1358,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1359
1358
|
path: importPath,
|
|
1360
1359
|
isTypeOnly: true
|
|
1361
1360
|
}),
|
|
1362
|
-
/* @__PURE__ */ (0,
|
|
1361
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1363
1362
|
name: queryName,
|
|
1364
1363
|
queryOptionsName,
|
|
1365
1364
|
queryKeyName,
|
|
@@ -1381,11 +1380,11 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1381
1380
|
* `useFooMutation` composable per POST/PUT/DELETE operation (configurable
|
|
1382
1381
|
* via `mutation.methods`) plus the matching `fooMutationKey` helper.
|
|
1383
1382
|
*/
|
|
1384
|
-
const mutationGenerator = (0,
|
|
1383
|
+
const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
1385
1384
|
name: "vue-query-mutation",
|
|
1386
|
-
renderer:
|
|
1385
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1387
1386
|
operation(node, ctx) {
|
|
1388
|
-
if (!
|
|
1387
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1389
1388
|
const { config, driver, resolver, root } = ctx;
|
|
1390
1389
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1391
1390
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1425,7 +1424,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1425
1424
|
const calledClientName = contractOp.name;
|
|
1426
1425
|
const groups = getRequestGroups(node);
|
|
1427
1426
|
const hasRequestGroups = groups.path || groups.query || groups.body || groups.headers;
|
|
1428
|
-
return /* @__PURE__ */ (0,
|
|
1427
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1429
1428
|
baseName: meta.file.baseName,
|
|
1430
1429
|
path: meta.file.path,
|
|
1431
1430
|
meta: meta.file.meta,
|
|
@@ -1446,48 +1445,48 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1446
1445
|
}
|
|
1447
1446
|
}),
|
|
1448
1447
|
children: [
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1448
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1450
1449
|
name: [contractOp.name],
|
|
1451
1450
|
root: meta.file.path,
|
|
1452
1451
|
path: contractOp.path
|
|
1453
1452
|
}),
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1453
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1455
1454
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1456
1455
|
root: meta.file.path,
|
|
1457
1456
|
path: contractOp.clientPath,
|
|
1458
1457
|
isTypeOnly: true
|
|
1459
1458
|
}),
|
|
1460
|
-
hasRequestGroups && /* @__PURE__ */ (0,
|
|
1459
|
+
hasRequestGroups && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1461
1460
|
name: ["toValue"],
|
|
1462
1461
|
path: "vue"
|
|
1463
1462
|
}),
|
|
1464
|
-
/* @__PURE__ */ (0,
|
|
1463
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1465
1464
|
name: ["MaybeRefOrGetter"],
|
|
1466
1465
|
path: "vue",
|
|
1467
1466
|
isTypeOnly: true
|
|
1468
1467
|
}),
|
|
1469
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1468
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1470
1469
|
name: Array.from(new Set(importedTypeNames)),
|
|
1471
1470
|
root: meta.file.path,
|
|
1472
1471
|
path: meta.fileTs.path,
|
|
1473
1472
|
isTypeOnly: true
|
|
1474
1473
|
}),
|
|
1475
|
-
/* @__PURE__ */ (0,
|
|
1474
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationKey, {
|
|
1476
1475
|
name: mutationKeyName,
|
|
1477
1476
|
node,
|
|
1478
1477
|
transformer: ctx.options.mutationKey
|
|
1479
1478
|
}),
|
|
1480
|
-
mutation && hooks && /* @__PURE__ */ (0,
|
|
1481
|
-
/* @__PURE__ */ (0,
|
|
1479
|
+
mutation && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1480
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1482
1481
|
name: ["useMutation"],
|
|
1483
1482
|
path: importPath
|
|
1484
1483
|
}),
|
|
1485
|
-
/* @__PURE__ */ (0,
|
|
1484
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1486
1485
|
name: ["MutationObserverOptions", "QueryClient"],
|
|
1487
1486
|
path: importPath,
|
|
1488
1487
|
isTypeOnly: true
|
|
1489
1488
|
}),
|
|
1490
|
-
/* @__PURE__ */ (0,
|
|
1489
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Mutation, {
|
|
1491
1490
|
name: mutationHookName,
|
|
1492
1491
|
clientName: calledClientName,
|
|
1493
1492
|
typeName: mutationTypeName,
|
|
@@ -1507,11 +1506,11 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1507
1506
|
* composable per GET operation (configurable via `query.methods`) plus the
|
|
1508
1507
|
* matching `fooQueryKey` / `fooQueryOptions` helpers.
|
|
1509
1508
|
*/
|
|
1510
|
-
const queryGenerator = (0,
|
|
1509
|
+
const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1511
1510
|
name: "vue-query",
|
|
1512
|
-
renderer:
|
|
1511
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1513
1512
|
operation(node, ctx) {
|
|
1514
|
-
if (!
|
|
1513
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1515
1514
|
const { config, driver, resolver, root } = ctx;
|
|
1516
1515
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1517
1516
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1552,7 +1551,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1552
1551
|
includeParams: false
|
|
1553
1552
|
})].filter((name) => Boolean(name));
|
|
1554
1553
|
const calledClientName = contractOp.name;
|
|
1555
|
-
return /* @__PURE__ */ (0,
|
|
1554
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1556
1555
|
baseName: meta.file.baseName,
|
|
1557
1556
|
path: meta.file.path,
|
|
1558
1557
|
meta: meta.file.meta,
|
|
@@ -1573,56 +1572,56 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1573
1572
|
}
|
|
1574
1573
|
}),
|
|
1575
1574
|
children: [
|
|
1576
|
-
/* @__PURE__ */ (0,
|
|
1575
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1577
1576
|
name: [contractOp.name],
|
|
1578
1577
|
root: meta.file.path,
|
|
1579
1578
|
path: contractOp.path
|
|
1580
1579
|
}),
|
|
1581
|
-
/* @__PURE__ */ (0,
|
|
1580
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1582
1581
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1583
1582
|
root: meta.file.path,
|
|
1584
1583
|
path: contractOp.clientPath,
|
|
1585
1584
|
isTypeOnly: true
|
|
1586
1585
|
}),
|
|
1587
|
-
/* @__PURE__ */ (0,
|
|
1586
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1588
1587
|
name: ["toValue"],
|
|
1589
1588
|
path: "vue"
|
|
1590
1589
|
}),
|
|
1591
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1592
1591
|
name: ["MaybeRefOrGetter"],
|
|
1593
1592
|
path: "vue",
|
|
1594
1593
|
isTypeOnly: true
|
|
1595
1594
|
}),
|
|
1596
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1595
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1597
1596
|
name: Array.from(new Set(importedTypeNames)),
|
|
1598
1597
|
root: meta.file.path,
|
|
1599
1598
|
path: meta.fileTs.path,
|
|
1600
1599
|
isTypeOnly: true
|
|
1601
1600
|
}),
|
|
1602
|
-
/* @__PURE__ */ (0,
|
|
1601
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1603
1602
|
name: queryKeyName,
|
|
1604
1603
|
typeName: queryKeyTypeName,
|
|
1605
1604
|
node,
|
|
1606
1605
|
tsResolver,
|
|
1607
1606
|
transformer: ctx.options.queryKey
|
|
1608
1607
|
}),
|
|
1609
|
-
/* @__PURE__ */ (0,
|
|
1608
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1610
1609
|
name: ["queryOptions"],
|
|
1611
1610
|
path: importPath
|
|
1612
1611
|
}),
|
|
1613
|
-
/* @__PURE__ */ (0,
|
|
1612
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
1614
1613
|
name: queryOptionsName,
|
|
1615
1614
|
clientName: calledClientName,
|
|
1616
1615
|
queryKeyName,
|
|
1617
1616
|
node,
|
|
1618
1617
|
tsResolver
|
|
1619
1618
|
}),
|
|
1620
|
-
query && hooks && /* @__PURE__ */ (0,
|
|
1621
|
-
/* @__PURE__ */ (0,
|
|
1619
|
+
query && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1620
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1622
1621
|
name: ["useQuery"],
|
|
1623
1622
|
path: importPath
|
|
1624
1623
|
}),
|
|
1625
|
-
/* @__PURE__ */ (0,
|
|
1624
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1626
1625
|
name: [
|
|
1627
1626
|
"QueryKey",
|
|
1628
1627
|
"QueryClient",
|
|
@@ -1632,7 +1631,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1632
1631
|
path: importPath,
|
|
1633
1632
|
isTypeOnly: true
|
|
1634
1633
|
}),
|
|
1635
|
-
/* @__PURE__ */ (0,
|
|
1634
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Query, {
|
|
1636
1635
|
name: queryName,
|
|
1637
1636
|
queryOptionsName,
|
|
1638
1637
|
queryKeyName,
|
|
@@ -1652,8 +1651,8 @@ function capitalize(name) {
|
|
|
1652
1651
|
}
|
|
1653
1652
|
/**
|
|
1654
1653
|
* Default resolver used by `@kubb/plugin-vue-query`. Decides the names and
|
|
1655
|
-
* file paths for every generated TanStack Query composable (`
|
|
1656
|
-
* `
|
|
1654
|
+
* file paths for every generated TanStack Query composable (`useFoo`,
|
|
1655
|
+
* `useFooInfinite`) and its companion helpers.
|
|
1657
1656
|
*
|
|
1658
1657
|
* Functions and files use camelCase; composables get the `use` prefix.
|
|
1659
1658
|
*
|
|
@@ -1666,7 +1665,7 @@ function capitalize(name) {
|
|
|
1666
1665
|
* resolverVueQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'
|
|
1667
1666
|
* ```
|
|
1668
1667
|
*/
|
|
1669
|
-
const resolverVueQuery = (0,
|
|
1668
|
+
const resolverVueQuery = (0, kubb_kit.defineResolver)(() => ({
|
|
1670
1669
|
name: "default",
|
|
1671
1670
|
pluginName: "plugin-vue-query",
|
|
1672
1671
|
default(name, type) {
|
|
@@ -1727,13 +1726,13 @@ const resolverVueQuery = (0, _kubb_core.defineResolver)(() => ({
|
|
|
1727
1726
|
const pluginVueQueryName = "plugin-vue-query";
|
|
1728
1727
|
/**
|
|
1729
1728
|
* Generates one TanStack Query composable per OpenAPI operation for Vue's
|
|
1730
|
-
* Composition API. Queries become `
|
|
1731
|
-
* `
|
|
1729
|
+
* Composition API. Queries become `useFoo` (and optionally
|
|
1730
|
+
* `useFooInfinite`). Mutations become `useFoo` as well. Each composable
|
|
1732
1731
|
* is fully typed end to end.
|
|
1733
1732
|
*
|
|
1734
1733
|
* @example
|
|
1735
1734
|
* ```ts
|
|
1736
|
-
* import { defineConfig } from 'kubb'
|
|
1735
|
+
* import { defineConfig } from 'kubb/config'
|
|
1737
1736
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1738
1737
|
* import { pluginVueQuery } from '@kubb/plugin-vue-query'
|
|
1739
1738
|
*
|
|
@@ -1749,7 +1748,7 @@ const pluginVueQueryName = "plugin-vue-query";
|
|
|
1749
1748
|
* })
|
|
1750
1749
|
* ```
|
|
1751
1750
|
*/
|
|
1752
|
-
const pluginVueQuery = (0,
|
|
1751
|
+
const pluginVueQuery = (0, kubb_kit.definePlugin)((options) => {
|
|
1753
1752
|
const { output = {
|
|
1754
1753
|
path: "hooks",
|
|
1755
1754
|
barrel: { type: "named" }
|
|
@@ -1784,17 +1783,17 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1784
1783
|
queryKey,
|
|
1785
1784
|
query: query === false ? false : {
|
|
1786
1785
|
importPath: "@tanstack/vue-query",
|
|
1787
|
-
methods: ["
|
|
1786
|
+
methods: ["GET"],
|
|
1788
1787
|
...query
|
|
1789
1788
|
},
|
|
1790
1789
|
mutationKey,
|
|
1791
1790
|
mutation: mutation === false ? false : {
|
|
1792
1791
|
importPath: "@tanstack/vue-query",
|
|
1793
1792
|
methods: [
|
|
1794
|
-
"
|
|
1795
|
-
"
|
|
1796
|
-
"
|
|
1797
|
-
"
|
|
1793
|
+
"POST",
|
|
1794
|
+
"PUT",
|
|
1795
|
+
"PATCH",
|
|
1796
|
+
"DELETE"
|
|
1798
1797
|
],
|
|
1799
1798
|
...mutation
|
|
1800
1799
|
},
|