@kubb/plugin-react-query 5.9.0-canary.20261029T145027 → 5.10.0-canary.20261103T075950
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 +83 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +83 -45
- package/dist/index.js.map +1 -1
- package/docs/options.md +32 -0
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -510,7 +510,7 @@ var compatibility = {
|
|
|
510
510
|
"node": ">=22.22"
|
|
511
511
|
};
|
|
512
512
|
// package.json
|
|
513
|
-
var version = "5.
|
|
513
|
+
var version = "5.10.0-canary.20261103T075950";
|
|
514
514
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
515
515
|
/**
|
|
516
516
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
@@ -759,8 +759,16 @@ function resolveClientOperation(options) {
|
|
|
759
759
|
* `pluginZod({ inferred: 'codec' })`), banner and footer.
|
|
760
760
|
*/
|
|
761
761
|
function resolveHookFile(node, ctx, options) {
|
|
762
|
-
const { name, output, group, contractOp, keyTypeName, extraTypeNames = [] } = options;
|
|
762
|
+
const { name, output, group, contractOp, keyTypeName, extraTypeNames = [], returnType = "data" } = options;
|
|
763
763
|
const { config, root, resolver } = ctx;
|
|
764
|
+
if (returnType !== "data" && contractOp.returnType === "data") throw new _kubb_kit.Diagnostics.Error({
|
|
765
|
+
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
766
|
+
severity: "error",
|
|
767
|
+
message: `Option \`returnType\` is '${returnType}' for ${node.operationId}, but the client plugin has \`returnType: 'data'\` and only returns the response body.`,
|
|
768
|
+
help: "Set the client plugin's `returnType` to 'full', or set the hook plugin's `returnType` to 'data'.",
|
|
769
|
+
location: { kind: "config" },
|
|
770
|
+
plugin: resolver.pluginName
|
|
771
|
+
});
|
|
764
772
|
const types = resolveOperationTypes(ctx.driver, resolver.pluginName);
|
|
765
773
|
const tsResolver = types.resolver;
|
|
766
774
|
const file = resolver.file({
|
|
@@ -779,9 +787,10 @@ function resolveHookFile(node, ctx, options) {
|
|
|
779
787
|
});
|
|
780
788
|
const importedTypeNames = [
|
|
781
789
|
tsResolver.response.options(node),
|
|
790
|
+
tsResolver.response.responses(node),
|
|
782
791
|
...extraTypeNames,
|
|
783
792
|
...resolveOperationTypeNames(node, tsResolver, {
|
|
784
|
-
exclude: keyTypeName ?
|
|
793
|
+
exclude: [keyTypeName, returnType !== "data" ? tsResolver.response.response(node) : null].filter((name) => Boolean(name)),
|
|
785
794
|
order: "body-response-first",
|
|
786
795
|
includeParams: false
|
|
787
796
|
})
|
|
@@ -796,6 +805,7 @@ function resolveHookFile(node, ctx, options) {
|
|
|
796
805
|
tsResolver,
|
|
797
806
|
contractOp,
|
|
798
807
|
importedTypeNames,
|
|
808
|
+
returnType,
|
|
799
809
|
banner: resolver.default.banner(ctx.meta, {
|
|
800
810
|
output,
|
|
801
811
|
config,
|
|
@@ -826,7 +836,11 @@ function HookFile({ hook, imports, children }) {
|
|
|
826
836
|
path: contractOp.path
|
|
827
837
|
}),
|
|
828
838
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
829
|
-
name: [
|
|
839
|
+
name: [
|
|
840
|
+
"RequestConfig",
|
|
841
|
+
"ResponseErrorConfig",
|
|
842
|
+
"RequestResult"
|
|
843
|
+
],
|
|
830
844
|
root: contractOp.clientPathIsFile ? file.path : void 0,
|
|
831
845
|
path: contractOp.clientPath,
|
|
832
846
|
isTypeOnly: true
|
|
@@ -956,11 +970,12 @@ function buildClientCall(node, options) {
|
|
|
956
970
|
}
|
|
957
971
|
/**
|
|
958
972
|
* Builds the query/mutation body that resolves a `buildClientCall` expression down to the bare
|
|
959
|
-
* success body. `
|
|
973
|
+
* success body. `clientReturnType` mirrors the registered client plugin's own `returnType` option: with
|
|
960
974
|
* `'data'` the call already resolves to the bare body, so it is returned directly; with `'full'`
|
|
961
975
|
* (the default) the call carries `unwrap()`, so the body calls it instead of destructuring `data`
|
|
962
976
|
* off the full result by hand. With `'plain'` (plugin-client) the call resolves to the user's
|
|
963
|
-
* `RequestResult`, so the body awaits it and reads `data`.
|
|
977
|
+
* `RequestResult`, so the body awaits it and reads `data`. With `returnType` `'full'` the body
|
|
978
|
+
* resolves to the whole `RequestResult`; `resolveHookFile` rejects that for a client that already stripped it.
|
|
964
979
|
*
|
|
965
980
|
* @example
|
|
966
981
|
* ```ts
|
|
@@ -969,22 +984,24 @@ function buildClientCall(node, options) {
|
|
|
969
984
|
* ```
|
|
970
985
|
*/
|
|
971
986
|
function buildCallResultBody(call, options = {}) {
|
|
972
|
-
const {
|
|
973
|
-
if (returnType === "data") return `return
|
|
974
|
-
if (
|
|
987
|
+
const { clientReturnType = "full", returnType = "data" } = options;
|
|
988
|
+
if (returnType !== "data" || clientReturnType === "data") return `return ${call}`;
|
|
989
|
+
if (clientReturnType === "plain") return `return (await ${call}).data`;
|
|
975
990
|
return `return ${call}.unwrap()`;
|
|
976
991
|
}
|
|
977
992
|
/**
|
|
978
993
|
* Builds the `TData` / `TError` type expressions shared by every generated hook, joining the resolved
|
|
979
994
|
* success responses into `TData` and wrapping the error responses in `ResponseErrorConfig<...>`.
|
|
995
|
+
* With `returnType` `'full'`, `TData` is the client's `RequestResult` over the operation's responses record.
|
|
980
996
|
*/
|
|
981
|
-
function buildResponseTypes(node, resolver) {
|
|
982
|
-
|
|
997
|
+
function buildResponseTypes(node, resolver, options = {}) {
|
|
998
|
+
const { returnType = "data" } = options;
|
|
999
|
+
return resolver.memo(`responseTypes:${returnType}:${node.method}\0${node.path}`, () => {
|
|
983
1000
|
const successNames = resolveSuccessNames(node, resolver);
|
|
984
1001
|
const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
|
|
985
1002
|
const errorNames = resolveErrorNames(node, resolver);
|
|
986
1003
|
return {
|
|
987
|
-
TData: responseName,
|
|
1004
|
+
TData: returnType !== "data" ? `RequestResult<${resolver.response.responses(node)}, true>` : responseName,
|
|
988
1005
|
TError: `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`
|
|
989
1006
|
};
|
|
990
1007
|
});
|
|
@@ -1213,8 +1230,9 @@ function buildResolvedRequestParams(node) {
|
|
|
1213
1230
|
// ../../internals/tanstack-query/src/components/InfiniteQueryOptions.tsx
|
|
1214
1231
|
const declarationPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
1215
1232
|
const callPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
1216
|
-
function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitInitialPageParam, cursorParam, nextParam, previousParam, getNextPageParam, getPreviousPageParam, node, tsResolver, queryParam, queryKeyName, queryKeyType = "typeof queryKey", memberTypeWrapper, unwrapName, returnType
|
|
1217
|
-
const { TData: queryFnDataType, TError: errorType } = buildResponseTypes(node, tsResolver);
|
|
1233
|
+
function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitInitialPageParam, cursorParam, nextParam, previousParam, getNextPageParam, getPreviousPageParam, node, tsResolver, queryParam, queryKeyName, queryKeyType = "typeof queryKey", memberTypeWrapper, unwrapName, clientReturnType, returnType }) {
|
|
1234
|
+
const { TData: queryFnDataType, TError: errorType } = buildResponseTypes(node, tsResolver, { returnType });
|
|
1235
|
+
const dataSuffix = returnType === "data" ? "" : ".data";
|
|
1218
1236
|
const { queryParamsTypeName, pageParamType } = resolvePageParamType(node, {
|
|
1219
1237
|
resolver: tsResolver,
|
|
1220
1238
|
initialPageParam,
|
|
@@ -1236,21 +1254,24 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitI
|
|
|
1236
1254
|
clientName,
|
|
1237
1255
|
signal: true,
|
|
1238
1256
|
unwrapName
|
|
1239
|
-
}), {
|
|
1257
|
+
}), {
|
|
1258
|
+
clientReturnType,
|
|
1259
|
+
returnType
|
|
1260
|
+
});
|
|
1240
1261
|
const initialPageParamLiteral = typeof initialPageParam === "string" || typeof initialPageParam === "object" && initialPageParam !== null ? JSON.stringify(initialPageParam) : String(initialPageParam === void 0 ? 0 : initialPageParam);
|
|
1241
1262
|
const serializedGetNextPageParam = typeof getNextPageParam === "function" ? getNextPageParam.toString() : getNextPageParam;
|
|
1242
1263
|
const getNextPageParamExpr = (() => {
|
|
1243
1264
|
if (serializedGetNextPageParam) return `getNextPageParam: ${serializedGetNextPageParam}`;
|
|
1244
|
-
if (nextParam) return `getNextPageParam: (lastPage) => ${getNestedAccessor(nextParam,
|
|
1245
|
-
if (cursorParam) return `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
|
|
1246
|
-
return
|
|
1265
|
+
if (nextParam) return `getNextPageParam: (lastPage) => ${getNestedAccessor(nextParam, `lastPage${dataSuffix}`)}`;
|
|
1266
|
+
if (cursorParam) return `getNextPageParam: (lastPage) => lastPage${dataSuffix}['${cursorParam}']`;
|
|
1267
|
+
return `getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage${dataSuffix}) && lastPage${dataSuffix}.length === 0 ? undefined : lastPageParam + 1`;
|
|
1247
1268
|
})();
|
|
1248
1269
|
const serializedGetPreviousPageParam = typeof getPreviousPageParam === "function" ? getPreviousPageParam.toString() : getPreviousPageParam;
|
|
1249
1270
|
const defaultPreviousThreshold = hasExplicitInitialPageParam ? initialPageParamLiteral : "1";
|
|
1250
1271
|
const getPreviousPageParamExpr = (() => {
|
|
1251
1272
|
if (serializedGetPreviousPageParam) return `getPreviousPageParam: ${serializedGetPreviousPageParam}`;
|
|
1252
|
-
if (previousParam) return `getPreviousPageParam: (firstPage) => ${getNestedAccessor(previousParam,
|
|
1253
|
-
if (cursorParam) return `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
|
|
1273
|
+
if (previousParam) return `getPreviousPageParam: (firstPage) => ${getNestedAccessor(previousParam, `firstPage${dataSuffix}`)}`;
|
|
1274
|
+
if (cursorParam) return `getPreviousPageParam: (firstPage) => firstPage${dataSuffix}['${cursorParam}']`;
|
|
1254
1275
|
if (serializedGetNextPageParam || nextParam) return null;
|
|
1255
1276
|
return `getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= ${defaultPreviousThreshold} ? undefined : firstPageParam - 1`;
|
|
1256
1277
|
})();
|
|
@@ -1690,7 +1711,7 @@ function buildHookTypes({ node, tsResolver, infinite, suspense, TData, TError, q
|
|
|
1690
1711
|
`TPageParam = ${pageParamType}`
|
|
1691
1712
|
],
|
|
1692
1713
|
observerOptionsType: `${observerOptionsName}<TQueryFnData, TError, TData, TQueryKey, TPageParam>`,
|
|
1693
|
-
|
|
1714
|
+
resultType: `${resultTypeName}<TData, TError> & { queryKey: TQueryKey }`
|
|
1694
1715
|
};
|
|
1695
1716
|
}
|
|
1696
1717
|
return {
|
|
@@ -1711,15 +1732,15 @@ function buildHookTypes({ node, tsResolver, infinite, suspense, TData, TError, q
|
|
|
1711
1732
|
"TQueryData",
|
|
1712
1733
|
"TQueryKey"
|
|
1713
1734
|
]).join(", ")}>`,
|
|
1714
|
-
|
|
1735
|
+
resultType: `${resultTypeName}<TData, ${TError}> & { queryKey: TQueryKey }`
|
|
1715
1736
|
};
|
|
1716
1737
|
}
|
|
1717
|
-
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver, customOptions, suspense, infinite }) {
|
|
1718
|
-
const { TData, TError } = buildResponseTypes(node, tsResolver);
|
|
1738
|
+
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver, customOptions, suspense, infinite, returnType }) {
|
|
1739
|
+
const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
|
|
1719
1740
|
const prefix = suspense ? "UseSuspense" : "Use";
|
|
1720
1741
|
const hookName = `${suspense ? "useSuspense" : "use"}${infinite ? "InfiniteQuery" : "Query"}`;
|
|
1721
1742
|
const observerOptionsName = OBSERVER_OPTIONS_NAMES[infinite ? "infinite" : "plain"][suspense ? "suspense" : "standard"];
|
|
1722
|
-
const { generics, observerOptionsType,
|
|
1743
|
+
const { generics, observerOptionsType, resultType } = buildHookTypes({
|
|
1723
1744
|
node,
|
|
1724
1745
|
tsResolver,
|
|
1725
1746
|
infinite,
|
|
@@ -1763,7 +1784,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1763
1784
|
...${queryOptionsName}(${queryOptionsArgs}),${customOptions ? "\n ...customOptions," : ""}
|
|
1764
1785
|
...resolvedOptions,
|
|
1765
1786
|
queryKey,
|
|
1766
|
-
} as unknown as ${castType}, queryClient) as ${
|
|
1787
|
+
} as unknown as ${castType}, queryClient) as ${resultType}
|
|
1767
1788
|
|
|
1768
1789
|
queryResult.queryKey = queryKey as TQueryKey
|
|
1769
1790
|
|
|
@@ -1775,8 +1796,8 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1775
1796
|
// src/components/QueryOptions.tsx
|
|
1776
1797
|
const declarationPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
1777
1798
|
const callPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
1778
|
-
function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, returnType
|
|
1779
|
-
const { TData, TError } = buildResponseTypes(node, tsResolver);
|
|
1799
|
+
function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, clientReturnType, returnType }) {
|
|
1800
|
+
const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
|
|
1780
1801
|
const queryKeyParamsNode = buildQueryKeyParams(node, { resolver: tsResolver });
|
|
1781
1802
|
const queryKeyParamsCall = callPrinter$2.print(queryKeyParamsNode) ?? "";
|
|
1782
1803
|
const paramsNode = buildQueryOptionsParams(node, { resolver: tsResolver });
|
|
@@ -1784,7 +1805,10 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, return
|
|
|
1784
1805
|
const queryFnBody = buildCallResultBody(buildClientCall(node, {
|
|
1785
1806
|
clientName,
|
|
1786
1807
|
signal: true
|
|
1787
|
-
}), {
|
|
1808
|
+
}), {
|
|
1809
|
+
clientReturnType,
|
|
1810
|
+
returnType
|
|
1811
|
+
});
|
|
1788
1812
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1789
1813
|
name,
|
|
1790
1814
|
isExportable: true,
|
|
@@ -1871,6 +1895,7 @@ function createQueryGenerator({ name, variant }) {
|
|
|
1871
1895
|
output,
|
|
1872
1896
|
group,
|
|
1873
1897
|
contractOp,
|
|
1898
|
+
returnType: ctx.options.returnType,
|
|
1874
1899
|
keyTypeName: queryKeyTypeName,
|
|
1875
1900
|
extraTypeNames: infiniteOptions ? [resolvePageParamType(node, {
|
|
1876
1901
|
resolver: tsResolver,
|
|
@@ -1917,7 +1942,8 @@ function createQueryGenerator({ name, variant }) {
|
|
|
1917
1942
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1918
1943
|
hasExplicitInitialPageParam: infiniteOptions.hasExplicitInitialPageParam,
|
|
1919
1944
|
queryParam: infiniteOptions.queryParam,
|
|
1920
|
-
|
|
1945
|
+
clientReturnType: contractOp.returnType,
|
|
1946
|
+
returnType: hook.returnType
|
|
1921
1947
|
})
|
|
1922
1948
|
] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1923
1949
|
name: ["queryOptions"],
|
|
@@ -1928,7 +1954,8 @@ function createQueryGenerator({ name, variant }) {
|
|
|
1928
1954
|
queryKeyName,
|
|
1929
1955
|
node,
|
|
1930
1956
|
tsResolver: hook.tsResolver,
|
|
1931
|
-
|
|
1957
|
+
clientReturnType: contractOp.returnType,
|
|
1958
|
+
returnType: hook.returnType
|
|
1932
1959
|
})] }),
|
|
1933
1960
|
(variant !== "query" || query && hooks) && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1934
1961
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
@@ -1952,6 +1979,7 @@ function createQueryGenerator({ name, variant }) {
|
|
|
1952
1979
|
node,
|
|
1953
1980
|
tsResolver: hook.tsResolver,
|
|
1954
1981
|
customOptions,
|
|
1982
|
+
returnType: hook.returnType,
|
|
1955
1983
|
suspense,
|
|
1956
1984
|
infinite: infiniteOptions ? {
|
|
1957
1985
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
@@ -1986,8 +2014,8 @@ function buildMutationConfigParamsNode(node) {
|
|
|
1986
2014
|
default: "{}"
|
|
1987
2015
|
})] });
|
|
1988
2016
|
}
|
|
1989
|
-
function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName, returnType
|
|
1990
|
-
const { TData, TError } = buildResponseTypes(node, tsResolver);
|
|
2017
|
+
function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName, clientReturnType, returnType }) {
|
|
2018
|
+
const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
|
|
1991
2019
|
const configParamsNode = buildMutationConfigParamsNode(node);
|
|
1992
2020
|
const paramsSignature = declarationPrinter$1.print(configParamsNode) ?? "";
|
|
1993
2021
|
const groupedParam = buildGroupedRequestParam(node, {
|
|
@@ -2002,8 +2030,11 @@ function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName,
|
|
|
2002
2030
|
clientName,
|
|
2003
2031
|
signal: false,
|
|
2004
2032
|
withContentType: true,
|
|
2033
|
+
returnType: clientReturnType
|
|
2034
|
+
}), {
|
|
2035
|
+
clientReturnType,
|
|
2005
2036
|
returnType
|
|
2006
|
-
})
|
|
2037
|
+
});
|
|
2007
2038
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
2008
2039
|
name,
|
|
2009
2040
|
isExportable: true,
|
|
@@ -2029,8 +2060,8 @@ function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName,
|
|
|
2029
2060
|
const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
2030
2061
|
const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
2031
2062
|
function buildMutationParamsNode(node, options) {
|
|
2032
|
-
const { resolver } = options;
|
|
2033
|
-
const { TData, TError } = buildResponseTypes(node, resolver);
|
|
2063
|
+
const { resolver, returnType } = options;
|
|
2064
|
+
const { TData, TError } = buildResponseTypes(node, resolver, { returnType });
|
|
2034
2065
|
return buildHookParams(node, {
|
|
2035
2066
|
resolver,
|
|
2036
2067
|
withRequest: false,
|
|
@@ -2045,18 +2076,21 @@ function buildMutationParamsNode(node, options) {
|
|
|
2045
2076
|
}`
|
|
2046
2077
|
});
|
|
2047
2078
|
}
|
|
2048
|
-
function Mutation({ name, mutationOptionsName, node, tsResolver, mutationKeyName, customOptions }) {
|
|
2049
|
-
const { TData, TError } = buildResponseTypes(node, tsResolver);
|
|
2079
|
+
function Mutation({ name, mutationOptionsName, node, tsResolver, mutationKeyName, customOptions, returnType }) {
|
|
2080
|
+
const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
|
|
2050
2081
|
const generics = [
|
|
2051
2082
|
TData,
|
|
2052
2083
|
TError,
|
|
2053
2084
|
resolveMutationRequestType(node, tsResolver),
|
|
2054
2085
|
"TContext"
|
|
2055
2086
|
].join(", ");
|
|
2056
|
-
const
|
|
2087
|
+
const resultType = `UseMutationResult<${generics}>`;
|
|
2057
2088
|
const mutationOptionsConfigNode = buildMutationConfigParamsNode(node);
|
|
2058
2089
|
const mutationOptionsParamsCall = callPrinter.print(mutationOptionsConfigNode) ?? "";
|
|
2059
|
-
const paramsNode = buildMutationParamsNode(node, {
|
|
2090
|
+
const paramsNode = buildMutationParamsNode(node, {
|
|
2091
|
+
resolver: tsResolver,
|
|
2092
|
+
returnType
|
|
2093
|
+
});
|
|
2060
2094
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
2061
2095
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
2062
2096
|
name,
|
|
@@ -2079,7 +2113,7 @@ function Mutation({ name, mutationOptionsName, node, tsResolver, mutationKeyName
|
|
|
2079
2113
|
...baseOptions,${customOptions ? "\n ...customOptions," : ""}
|
|
2080
2114
|
mutationKey,
|
|
2081
2115
|
...mutationOptions,
|
|
2082
|
-
}, queryClient) as ${
|
|
2116
|
+
}, queryClient) as ${resultType}
|
|
2083
2117
|
`
|
|
2084
2118
|
})
|
|
2085
2119
|
});
|
|
@@ -2123,7 +2157,8 @@ const mutationGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
2123
2157
|
name: mutationHookName,
|
|
2124
2158
|
output,
|
|
2125
2159
|
group,
|
|
2126
|
-
contractOp
|
|
2160
|
+
contractOp,
|
|
2161
|
+
returnType: ctx.options.returnType
|
|
2127
2162
|
});
|
|
2128
2163
|
const { tsResolver } = hook;
|
|
2129
2164
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(HookFile, {
|
|
@@ -2148,7 +2183,8 @@ const mutationGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
2148
2183
|
mutationKeyName,
|
|
2149
2184
|
node,
|
|
2150
2185
|
tsResolver,
|
|
2151
|
-
|
|
2186
|
+
clientReturnType: contractOp.returnType,
|
|
2187
|
+
returnType: hook.returnType
|
|
2152
2188
|
}),
|
|
2153
2189
|
mutation && hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
2154
2190
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
@@ -2170,7 +2206,8 @@ const mutationGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
2170
2206
|
mutationKeyName,
|
|
2171
2207
|
node,
|
|
2172
2208
|
tsResolver,
|
|
2173
|
-
customOptions
|
|
2209
|
+
customOptions,
|
|
2210
|
+
returnType: hook.returnType
|
|
2174
2211
|
})
|
|
2175
2212
|
] })
|
|
2176
2213
|
]
|
|
@@ -2305,7 +2342,7 @@ const pluginReactQuery = (0, _kubb_kit.defineExtension)({
|
|
|
2305
2342
|
const { output = {
|
|
2306
2343
|
path: "hooks",
|
|
2307
2344
|
barrel: { type: "named" }
|
|
2308
|
-
}, group, exclude = [], include, override = [], suspense = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, customOptions, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
2345
|
+
}, group, exclude = [], include, override = [], suspense = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, customOptions, hooks = false, client, returnType = "data", resolver: userResolver, macros: userMacros } = options;
|
|
2309
2346
|
const resolver = userResolver ? _kubb_kit.Resolver.merge(resolverReactQuery, userResolver) : resolverReactQuery;
|
|
2310
2347
|
(0, _kubb_kit.setResolver)(resolver);
|
|
2311
2348
|
if (userMacros?.length) (0, _kubb_kit.setMacros)(userMacros);
|
|
@@ -2317,6 +2354,7 @@ const pluginReactQuery = (0, _kubb_kit.defineExtension)({
|
|
|
2317
2354
|
client,
|
|
2318
2355
|
plugins: (0, _kubb_kit.useConfig)().plugins
|
|
2319
2356
|
}),
|
|
2357
|
+
returnType,
|
|
2320
2358
|
queryKey,
|
|
2321
2359
|
query: resolveQueryConfig(query, { importPath: "@tanstack/react-query" }),
|
|
2322
2360
|
mutationKey,
|