@tanstack/vue-query 5.97.0 → 5.99.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/build/legacy/_tsup-dts-rollup.d.cts +71 -11
- package/build/legacy/_tsup-dts-rollup.d.ts +71 -11
- package/build/legacy/index.cjs +9 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +7 -2
- package/build/legacy/index.d.ts +7 -2
- package/build/legacy/index.js +6 -0
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/mutationOptions.cjs +33 -0
- package/build/legacy/mutationOptions.cjs.map +1 -0
- package/build/legacy/mutationOptions.d.cts +1 -0
- package/build/legacy/mutationOptions.d.ts +1 -0
- package/build/legacy/mutationOptions.js +8 -0
- package/build/legacy/mutationOptions.js.map +1 -0
- package/build/legacy/queryClient.cjs +6 -2
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.js +6 -2
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +3 -0
- package/build/legacy/queryOptions.d.ts +3 -0
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -0
- package/build/legacy/types.d.ts +2 -0
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +55 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +2 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +2 -0
- package/build/legacy/usePrefetchInfiniteQuery.js +30 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -0
- package/build/legacy/usePrefetchQuery.cjs +53 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -0
- package/build/legacy/usePrefetchQuery.d.cts +2 -0
- package/build/legacy/usePrefetchQuery.d.ts +2 -0
- package/build/legacy/usePrefetchQuery.js +28 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -0
- package/build/legacy/useQuery.d.cts +2 -2
- package/build/legacy/useQuery.d.ts +2 -2
- package/build/legacy/utils.cjs +5 -0
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -0
- package/build/legacy/utils.d.ts +1 -0
- package/build/legacy/utils.js +4 -0
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.cts +71 -11
- package/build/modern/_tsup-dts-rollup.d.ts +71 -11
- package/build/modern/index.cjs +9 -0
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +7 -2
- package/build/modern/index.d.ts +7 -2
- package/build/modern/index.js +6 -0
- package/build/modern/index.js.map +1 -1
- package/build/modern/mutationOptions.cjs +33 -0
- package/build/modern/mutationOptions.cjs.map +1 -0
- package/build/modern/mutationOptions.d.cts +1 -0
- package/build/modern/mutationOptions.d.ts +1 -0
- package/build/modern/mutationOptions.js +8 -0
- package/build/modern/mutationOptions.js.map +1 -0
- package/build/modern/queryClient.cjs +6 -2
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.js +6 -2
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +3 -0
- package/build/modern/queryOptions.d.ts +3 -0
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -0
- package/build/modern/types.d.ts +2 -0
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +55 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.d.cts +2 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts +2 -0
- package/build/modern/usePrefetchInfiniteQuery.js +30 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -0
- package/build/modern/usePrefetchQuery.cjs +53 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -0
- package/build/modern/usePrefetchQuery.d.cts +2 -0
- package/build/modern/usePrefetchQuery.d.ts +2 -0
- package/build/modern/usePrefetchQuery.js +28 -0
- package/build/modern/usePrefetchQuery.js.map +1 -0
- package/build/modern/useQuery.d.cts +2 -2
- package/build/modern/useQuery.d.ts +2 -2
- package/build/modern/utils.cjs +5 -0
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -0
- package/build/modern/utils.d.ts +1 -0
- package/build/modern/utils.js +4 -0
- package/build/modern/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +7 -0
- package/src/mutationOptions.ts +62 -0
- package/src/queryClient.ts +24 -8
- package/src/queryOptions.ts +93 -4
- package/src/types.ts +13 -0
- package/src/useMutation.ts +3 -14
- package/src/usePrefetchInfiniteQuery.ts +113 -0
- package/src/usePrefetchQuery.ts +69 -0
- package/src/utils.ts +4 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/usePrefetchInfiniteQuery.ts
|
|
2
|
+
import { getCurrentScope, unref, watchEffect } from "vue-demi";
|
|
3
|
+
import { useQueryClient } from "./useQueryClient.js";
|
|
4
|
+
import { cloneDeepUnref } from "./utils.js";
|
|
5
|
+
function isGetter(value) {
|
|
6
|
+
return typeof value === "function";
|
|
7
|
+
}
|
|
8
|
+
function usePrefetchInfiniteQuery(options, queryClient) {
|
|
9
|
+
if (process.env.NODE_ENV === "development") {
|
|
10
|
+
if (!getCurrentScope()) {
|
|
11
|
+
console.warn(
|
|
12
|
+
'vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.'
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const client = queryClient || useQueryClient();
|
|
17
|
+
watchEffect(() => {
|
|
18
|
+
const resolvedOptions = isGetter(options) ? options() : unref(options);
|
|
19
|
+
const clonedOptions = cloneDeepUnref(resolvedOptions);
|
|
20
|
+
if (!client.getQueryState(clonedOptions.queryKey)) {
|
|
21
|
+
void client.prefetchInfiniteQuery(
|
|
22
|
+
clonedOptions
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
usePrefetchInfiniteQuery
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=usePrefetchInfiniteQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/usePrefetchInfiniteQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n FetchInfiniteQueryOptions,\n FetchQueryOptions,\n GetNextPageParamFunction,\n InfiniteData,\n InitialPageParam,\n OmitKeyof,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\ntype PrefetchInfinitePages<TQueryFnData, TPageParam> =\n | {\n pages?: never\n getNextPageParam?: GetNextPageParamFunction<TPageParam, TQueryFnData>\n }\n | {\n pages: number\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n }\n\nexport type UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TPageParam,\n> = OmitKeyof<\n FetchQueryOptions<\n TQueryFnData,\n TError,\n InfiniteData<TData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n 'queryFn' | 'initialPageParam'\n> &\n InitialPageParam<TPageParam> & {\n queryFn?: Exclude<\n FetchQueryOptions<\n TQueryFnData,\n TError,\n InfiniteData<TData, TPageParam>,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken\n >\n } & PrefetchInfinitePages<TQueryFnData, TPageParam>\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchInfiniteQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.prefetchInfiniteQuery(\n clonedOptions as FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n )\n }\n })\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,OAAO,mBAAmB;AACpD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAsD/B,SAAS,SAAY,OAA8C;AACjE,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,yBAOd,SAWA,aACM;AACN,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,gBAAgB,GAAG;AACtB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,eAAe,eAAe;AAE7C,cAAY,MAAM;AAChB,UAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;AACrE,UAAM,gBAMF,eAAe,eAAe;AAElC,QAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAAG;AACjD,WAAK,OAAO;AAAA,QACV;AAAA,MAOF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/usePrefetchQuery.ts
|
|
21
|
+
var usePrefetchQuery_exports = {};
|
|
22
|
+
__export(usePrefetchQuery_exports, {
|
|
23
|
+
usePrefetchQuery: () => usePrefetchQuery
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(usePrefetchQuery_exports);
|
|
26
|
+
var import_vue_demi = require("vue-demi");
|
|
27
|
+
var import_useQueryClient = require("./useQueryClient.cjs");
|
|
28
|
+
var import_utils = require("./utils.cjs");
|
|
29
|
+
function isGetter(value) {
|
|
30
|
+
return typeof value === "function";
|
|
31
|
+
}
|
|
32
|
+
function usePrefetchQuery(options, queryClient) {
|
|
33
|
+
if (process.env.NODE_ENV === "development") {
|
|
34
|
+
if (!(0, import_vue_demi.getCurrentScope)()) {
|
|
35
|
+
console.warn(
|
|
36
|
+
'vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const client = queryClient || (0, import_useQueryClient.useQueryClient)();
|
|
41
|
+
(0, import_vue_demi.watchEffect)(() => {
|
|
42
|
+
const resolvedOptions = isGetter(options) ? options() : (0, import_vue_demi.unref)(options);
|
|
43
|
+
const clonedOptions = (0, import_utils.cloneDeepUnref)(resolvedOptions);
|
|
44
|
+
if (!client.getQueryState(clonedOptions.queryKey)) {
|
|
45
|
+
void client.prefetchQuery(clonedOptions);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
usePrefetchQuery
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=usePrefetchQuery.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n FetchQueryOptions,\n OmitKeyof,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.prefetchQuery(clonedOptions)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoD;AACpD,4BAA+B;AAC/B,mBAA+B;AA0B/B,SAAS,SAAY,OAA8C;AACjE,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,iBAMd,SAKA,aACM;AACN,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,KAAC,iCAAgB,GAAG;AACtB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,mBAAe,sCAAe;AAE7C,mCAAY,MAAM;AAChB,UAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,QAAI,uBAAM,OAAO;AACrE,UAAM,oBAKF,6BAAe,eAAe;AAElC,QAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAAG;AACjD,WAAK,OAAO,cAAc,aAAa;AAAA,IACzC;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/usePrefetchQuery.ts
|
|
2
|
+
import { getCurrentScope, unref, watchEffect } from "vue-demi";
|
|
3
|
+
import { useQueryClient } from "./useQueryClient.js";
|
|
4
|
+
import { cloneDeepUnref } from "./utils.js";
|
|
5
|
+
function isGetter(value) {
|
|
6
|
+
return typeof value === "function";
|
|
7
|
+
}
|
|
8
|
+
function usePrefetchQuery(options, queryClient) {
|
|
9
|
+
if (process.env.NODE_ENV === "development") {
|
|
10
|
+
if (!getCurrentScope()) {
|
|
11
|
+
console.warn(
|
|
12
|
+
'vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.'
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const client = queryClient || useQueryClient();
|
|
17
|
+
watchEffect(() => {
|
|
18
|
+
const resolvedOptions = isGetter(options) ? options() : unref(options);
|
|
19
|
+
const clonedOptions = cloneDeepUnref(resolvedOptions);
|
|
20
|
+
if (!client.getQueryState(clonedOptions.queryKey)) {
|
|
21
|
+
void client.prefetchQuery(clonedOptions);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
usePrefetchQuery
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=usePrefetchQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/usePrefetchQuery.ts"],"sourcesContent":["import { getCurrentScope, unref, watchEffect } from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type {\n DefaultError,\n FetchQueryOptions,\n OmitKeyof,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep, MaybeRefOrGetter } from './types'\n\nexport type UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n> = OmitKeyof<\n FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken\n >\n}\n\nfunction isGetter<T>(value: MaybeRefOrGetter<T>): value is () => T {\n return typeof value === 'function'\n}\n\nexport function usePrefetchQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n MaybeRefDeep<\n UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n >\n >,\n queryClient?: QueryClient,\n): void {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n watchEffect(() => {\n const resolvedOptions = isGetter(options) ? options() : unref(options)\n const clonedOptions: UsePrefetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n > = cloneDeepUnref(resolvedOptions)\n\n if (!client.getQueryState(clonedOptions.queryKey)) {\n void client.prefetchQuery(clonedOptions)\n }\n })\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,OAAO,mBAAmB;AACpD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AA0B/B,SAAS,SAAY,OAA8C;AACjE,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,iBAMd,SAKA,aACM;AACN,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,gBAAgB,GAAG;AACtB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,eAAe,eAAe;AAE7C,cAAY,MAAM;AAChB,UAAM,kBAAkB,SAAS,OAAO,IAAI,QAAQ,IAAI,MAAM,OAAO;AACrE,UAAM,gBAKF,eAAe,eAAe;AAElC,QAAI,CAAC,OAAO,cAAc,cAAc,QAAQ,GAAG;AACjD,WAAK,OAAO,cAAc,aAAa;AAAA,IACzC;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useQuery_alias_1 as useQuery } from './_tsup-dts-rollup.cjs';
|
|
2
2
|
export { UseQueryOptions_alias_1 as UseQueryOptions } from './_tsup-dts-rollup.cjs';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { UndefinedInitialQueryOptions_alias_2 as UndefinedInitialQueryOptions } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { DefinedInitialQueryOptions_alias_2 as DefinedInitialQueryOptions } from './_tsup-dts-rollup.cjs';
|
|
5
5
|
export { UseQueryReturnType_alias_1 as UseQueryReturnType } from './_tsup-dts-rollup.cjs';
|
|
6
6
|
export { UseQueryDefinedReturnType_alias_1 as UseQueryDefinedReturnType } from './_tsup-dts-rollup.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { useQuery_alias_1 as useQuery } from './_tsup-dts-rollup.js';
|
|
2
2
|
export { UseQueryOptions_alias_1 as UseQueryOptions } from './_tsup-dts-rollup.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { UndefinedInitialQueryOptions_alias_2 as UndefinedInitialQueryOptions } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { DefinedInitialQueryOptions_alias_2 as DefinedInitialQueryOptions } from './_tsup-dts-rollup.js';
|
|
5
5
|
export { UseQueryReturnType_alias_1 as UseQueryReturnType } from './_tsup-dts-rollup.js';
|
|
6
6
|
export { UseQueryDefinedReturnType_alias_1 as UseQueryDefinedReturnType } from './_tsup-dts-rollup.js';
|
package/build/modern/utils.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(utils_exports, {
|
|
|
24
24
|
cloneDeep: () => cloneDeep,
|
|
25
25
|
cloneDeepUnref: () => cloneDeepUnref,
|
|
26
26
|
getClientKey: () => getClientKey,
|
|
27
|
+
toValueDeep: () => toValueDeep,
|
|
27
28
|
updateState: () => updateState
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -89,12 +90,16 @@ function isPlainObject(value) {
|
|
|
89
90
|
function isFunction(value) {
|
|
90
91
|
return typeof value === "function";
|
|
91
92
|
}
|
|
93
|
+
function toValueDeep(source) {
|
|
94
|
+
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
95
|
+
}
|
|
92
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
93
97
|
0 && (module.exports = {
|
|
94
98
|
VUE_QUERY_CLIENT,
|
|
95
99
|
cloneDeep,
|
|
96
100
|
cloneDeepUnref,
|
|
97
101
|
getClientKey,
|
|
102
|
+
toValueDeep,
|
|
98
103
|
updateState
|
|
99
104
|
});
|
|
100
105
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6B;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,OACA,QACM;AACN,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,UAAM,GAAG,IAAI,OAAO,GAAG;AAAA,EACzB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;AACH,MAAI,WAAW;AACb,UAAM,SAAS,UAAU,OAAO,YAAY,YAAY;AACxD,QAAI,WAAW,cAAa,uBAAM,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,CAAC,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;AACrD,UAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM;AAAA,MACxD;AAAA,MACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC;AAAA,IAClD,CAAC;AACD,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,UACd,OACA,WAKG;AACH,SAAO,WAAW,OAAO,SAAS;AACpC;AAEO,SAAS,eACd,KACA,eAAe,OACZ;AACH,SAAO,UAAU,KAAK,CAAC,KAAK,KAAK,UAAU;AAKzC,QAAI,UAAU,KAAK,QAAQ,YAAY;AACrC,aAAO,eAAe,KAAK,IAAI;AAAA,IACjC;AAGA,QAAI,gBAAgB,WAAW,GAAG,GAAG;AAGnC,aAAO,eAAgB,IAAiB,GAAG,YAAY;AAAA,IACzD;AAGA,YAAI,uBAAM,GAAG,GAAG;AACd,aAAO,mBAAe,uBAAM,GAAG,GAAG,YAAY;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;AACtD,MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6B;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,OACA,QACM;AACN,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,UAAM,GAAG,IAAI,OAAO,GAAG;AAAA,EACzB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;AACH,MAAI,WAAW;AACb,UAAM,SAAS,UAAU,OAAO,YAAY,YAAY;AACxD,QAAI,WAAW,cAAa,uBAAM,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,CAAC,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;AACrD,UAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM;AAAA,MACxD;AAAA,MACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC;AAAA,IAClD,CAAC;AACD,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,UACd,OACA,WAKG;AACH,SAAO,WAAW,OAAO,SAAS;AACpC;AAEO,SAAS,eACd,KACA,eAAe,OACZ;AACH,SAAO,UAAU,KAAK,CAAC,KAAK,KAAK,UAAU;AAKzC,QAAI,UAAU,KAAK,QAAQ,YAAY;AACrC,aAAO,eAAe,KAAK,IAAI;AAAA,IACjC;AAGA,QAAI,gBAAgB,WAAW,GAAG,GAAG;AAGnC,aAAO,eAAgB,IAAiB,GAAG,YAAY;AAAA,IACzD;AAGA,YAAI,uBAAM,GAAG,GAAG;AACd,aAAO,mBAAe,uBAAM,GAAG,GAAG,YAAY;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;AACtD,MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,YAAe,QAAwC;AACrE,SAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D;","names":[]}
|
package/build/modern/utils.d.cts
CHANGED
|
@@ -2,4 +2,5 @@ export { getClientKey } from './_tsup-dts-rollup.cjs';
|
|
|
2
2
|
export { updateState } from './_tsup-dts-rollup.cjs';
|
|
3
3
|
export { cloneDeep } from './_tsup-dts-rollup.cjs';
|
|
4
4
|
export { cloneDeepUnref } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { toValueDeep } from './_tsup-dts-rollup.cjs';
|
|
5
6
|
export { VUE_QUERY_CLIENT_alias_1 as VUE_QUERY_CLIENT } from './_tsup-dts-rollup.cjs';
|
package/build/modern/utils.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { getClientKey } from './_tsup-dts-rollup.js';
|
|
|
2
2
|
export { updateState } from './_tsup-dts-rollup.js';
|
|
3
3
|
export { cloneDeep } from './_tsup-dts-rollup.js';
|
|
4
4
|
export { cloneDeepUnref } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { toValueDeep } from './_tsup-dts-rollup.js';
|
|
5
6
|
export { VUE_QUERY_CLIENT_alias_1 as VUE_QUERY_CLIENT } from './_tsup-dts-rollup.js';
|
package/build/modern/utils.js
CHANGED
|
@@ -61,11 +61,15 @@ function isPlainObject(value) {
|
|
|
61
61
|
function isFunction(value) {
|
|
62
62
|
return typeof value === "function";
|
|
63
63
|
}
|
|
64
|
+
function toValueDeep(source) {
|
|
65
|
+
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
66
|
+
}
|
|
64
67
|
export {
|
|
65
68
|
VUE_QUERY_CLIENT,
|
|
66
69
|
cloneDeep,
|
|
67
70
|
cloneDeepUnref,
|
|
68
71
|
getClientKey,
|
|
72
|
+
toValueDeep,
|
|
69
73
|
updateState
|
|
70
74
|
};
|
|
71
75
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n"],"mappings":";AAAA,SAAS,OAAO,aAAa;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,OACA,QACM;AACN,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,UAAM,GAAG,IAAI,OAAO,GAAG;AAAA,EACzB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;AACH,MAAI,WAAW;AACb,UAAM,SAAS,UAAU,OAAO,YAAY,YAAY;AACxD,QAAI,WAAW,UAAa,MAAM,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,CAAC,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;AACrD,UAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM;AAAA,MACxD;AAAA,MACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC;AAAA,IAClD,CAAC;AACD,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,UACd,OACA,WAKG;AACH,SAAO,WAAW,OAAO,SAAS;AACpC;AAEO,SAAS,eACd,KACA,eAAe,OACZ;AACH,SAAO,UAAU,KAAK,CAAC,KAAK,KAAK,UAAU;AAKzC,QAAI,UAAU,KAAK,QAAQ,YAAY;AACrC,aAAO,eAAe,KAAK,IAAI;AAAA,IACjC;AAGA,QAAI,gBAAgB,WAAW,GAAG,GAAG;AAGnC,aAAO,eAAgB,IAAiB,GAAG,YAAY;AAAA,IACzD;AAGA,QAAI,MAAM,GAAG,GAAG;AACd,aAAO,eAAe,MAAM,GAAG,GAAG,YAAY;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;AACtD,MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";AAAA,SAAS,OAAO,aAAa;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,OACA,QACM;AACN,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,UAAM,GAAG,IAAI,OAAO,GAAG;AAAA,EACzB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;AACH,MAAI,WAAW;AACb,UAAM,SAAS,UAAU,OAAO,YAAY,YAAY;AACxD,QAAI,WAAW,UAAa,MAAM,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,CAAC,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;AACrD,UAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM;AAAA,MACxD;AAAA,MACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC;AAAA,IAClD,CAAC;AACD,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,UACd,OACA,WAKG;AACH,SAAO,WAAW,OAAO,SAAS;AACpC;AAEO,SAAS,eACd,KACA,eAAe,OACZ;AACH,SAAO,UAAU,KAAK,CAAC,KAAK,KAAK,UAAU;AAKzC,QAAI,UAAU,KAAK,QAAQ,YAAY;AACrC,aAAO,eAAe,KAAK,IAAI;AAAA,IACjC;AAGA,QAAI,gBAAgB,WAAW,GAAG,GAAG;AAGnC,aAAO,eAAgB,IAAiB,GAAG,YAAY;AAAA,IACzD;AAGA,QAAI,MAAM,GAAG,GAAG;AACd,aAAO,eAAe,MAAM,GAAG,GAAG,YAAY;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;AACtD,MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,YAAe,QAAwC;AACrE,SAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.99.0",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
43
43
|
"@vue/devtools-api": "^6.6.3",
|
|
44
44
|
"vue-demi": "^0.14.10",
|
|
45
|
-
"@tanstack/query-core": "5.
|
|
45
|
+
"@tanstack/query-core": "5.99.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@vitejs/plugin-vue": "^5.2.4",
|
package/src/index.ts
CHANGED
|
@@ -6,20 +6,26 @@ export { VueQueryPlugin } from './vueQueryPlugin'
|
|
|
6
6
|
export { QueryClient } from './queryClient'
|
|
7
7
|
export { QueryCache } from './queryCache'
|
|
8
8
|
export { queryOptions } from './queryOptions'
|
|
9
|
+
export { type QueryOptions } from './queryOptions'
|
|
9
10
|
export { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
10
11
|
export type {
|
|
11
12
|
DefinedInitialDataInfiniteOptions,
|
|
12
13
|
UndefinedInitialDataInfiniteOptions,
|
|
13
14
|
} from './infiniteQueryOptions'
|
|
14
15
|
export { MutationCache } from './mutationCache'
|
|
16
|
+
export { mutationOptions } from './mutationOptions'
|
|
15
17
|
export { useQuery } from './useQuery'
|
|
16
18
|
export { useQueries } from './useQueries'
|
|
17
19
|
export { useInfiniteQuery } from './useInfiniteQuery'
|
|
20
|
+
export { usePrefetchQuery } from './usePrefetchQuery'
|
|
21
|
+
export { usePrefetchInfiniteQuery } from './usePrefetchInfiniteQuery'
|
|
18
22
|
export { useMutation } from './useMutation'
|
|
19
23
|
export { useIsFetching } from './useIsFetching'
|
|
20
24
|
export { useIsMutating, useMutationState } from './useMutationState'
|
|
21
25
|
export { VUE_QUERY_CLIENT } from './utils'
|
|
22
26
|
|
|
27
|
+
export type { UsePrefetchQueryOptions } from './usePrefetchQuery'
|
|
28
|
+
export type { UsePrefetchInfiniteQueryOptions } from './usePrefetchInfiniteQuery'
|
|
23
29
|
export type {
|
|
24
30
|
UseQueryOptions,
|
|
25
31
|
UseQueryReturnType,
|
|
@@ -32,6 +38,7 @@ export type {
|
|
|
32
38
|
UseInfiniteQueryReturnType,
|
|
33
39
|
} from './useInfiniteQuery'
|
|
34
40
|
export type { UseMutationOptions, UseMutationReturnType } from './useMutation'
|
|
41
|
+
export type { MutationOptions } from './types'
|
|
35
42
|
export type { UseQueriesOptions, UseQueriesResults } from './useQueries'
|
|
36
43
|
export type { MutationFilters, MutationStateOptions } from './useMutationState'
|
|
37
44
|
export type { QueryFilters } from './useIsFetching'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DefaultError, WithRequired } from '@tanstack/query-core'
|
|
2
|
+
import type { MutationOptions } from './types'
|
|
3
|
+
|
|
4
|
+
export function mutationOptions<
|
|
5
|
+
TData = unknown,
|
|
6
|
+
TError = DefaultError,
|
|
7
|
+
TVariables = void,
|
|
8
|
+
TOnMutateResult = unknown,
|
|
9
|
+
>(
|
|
10
|
+
options: WithRequired<
|
|
11
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
12
|
+
'mutationKey'
|
|
13
|
+
>,
|
|
14
|
+
): WithRequired<
|
|
15
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
16
|
+
'mutationKey'
|
|
17
|
+
>
|
|
18
|
+
export function mutationOptions<
|
|
19
|
+
TData = unknown,
|
|
20
|
+
TError = DefaultError,
|
|
21
|
+
TVariables = void,
|
|
22
|
+
TOnMutateResult = unknown,
|
|
23
|
+
>(
|
|
24
|
+
options: () => WithRequired<
|
|
25
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
26
|
+
'mutationKey'
|
|
27
|
+
>,
|
|
28
|
+
): () => WithRequired<
|
|
29
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
30
|
+
'mutationKey'
|
|
31
|
+
>
|
|
32
|
+
export function mutationOptions<
|
|
33
|
+
TData = unknown,
|
|
34
|
+
TError = DefaultError,
|
|
35
|
+
TVariables = void,
|
|
36
|
+
TOnMutateResult = unknown,
|
|
37
|
+
>(
|
|
38
|
+
options: Omit<
|
|
39
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
40
|
+
'mutationKey'
|
|
41
|
+
>,
|
|
42
|
+
): Omit<
|
|
43
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
44
|
+
'mutationKey'
|
|
45
|
+
>
|
|
46
|
+
export function mutationOptions<
|
|
47
|
+
TData = unknown,
|
|
48
|
+
TError = DefaultError,
|
|
49
|
+
TVariables = void,
|
|
50
|
+
TOnMutateResult = unknown,
|
|
51
|
+
>(
|
|
52
|
+
options: () => Omit<
|
|
53
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
54
|
+
'mutationKey'
|
|
55
|
+
>,
|
|
56
|
+
): () => Omit<
|
|
57
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
58
|
+
'mutationKey'
|
|
59
|
+
>
|
|
60
|
+
export function mutationOptions(options: unknown) {
|
|
61
|
+
return options
|
|
62
|
+
}
|
package/src/queryClient.ts
CHANGED
|
@@ -202,15 +202,23 @@ export class QueryClient extends QC {
|
|
|
202
202
|
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
203
203
|
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
204
204
|
>(
|
|
205
|
-
filters?:
|
|
205
|
+
filters?:
|
|
206
|
+
| InvalidateQueryFilters<TTaggedQueryKey>
|
|
207
|
+
| (() => InvalidateQueryFilters<TTaggedQueryKey>),
|
|
206
208
|
options?: MaybeRefDeep<InvalidateOptions>,
|
|
207
209
|
): Promise<void>
|
|
208
210
|
invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
|
|
209
|
-
filters:
|
|
210
|
-
|
|
211
|
+
filters:
|
|
212
|
+
| MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>
|
|
213
|
+
| (() => InvalidateQueryFilters<TTaggedQueryKey>) = {},
|
|
214
|
+
options: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) = {},
|
|
211
215
|
): Promise<void> {
|
|
212
|
-
const filtersCloned = cloneDeepUnref(
|
|
213
|
-
|
|
216
|
+
const filtersCloned = cloneDeepUnref(
|
|
217
|
+
filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,
|
|
218
|
+
)
|
|
219
|
+
const optionsCloned = cloneDeepUnref(
|
|
220
|
+
options as MaybeRefDeep<InvalidateOptions>,
|
|
221
|
+
)
|
|
214
222
|
|
|
215
223
|
super.invalidateQueries(
|
|
216
224
|
{ ...filtersCloned, refetchType: 'none' },
|
|
@@ -275,9 +283,17 @@ export class QueryClient extends QC {
|
|
|
275
283
|
TQueryKey extends QueryKey = QueryKey,
|
|
276
284
|
TPageParam = never,
|
|
277
285
|
>(
|
|
278
|
-
options:
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
options:
|
|
287
|
+
| MaybeRefDeep<
|
|
288
|
+
FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
|
|
289
|
+
>
|
|
290
|
+
| (() => FetchQueryOptions<
|
|
291
|
+
TQueryFnData,
|
|
292
|
+
TError,
|
|
293
|
+
TData,
|
|
294
|
+
TQueryKey,
|
|
295
|
+
TPageParam
|
|
296
|
+
>),
|
|
281
297
|
): Promise<TData>
|
|
282
298
|
fetchQuery<
|
|
283
299
|
TQueryFnData,
|
package/src/queryOptions.ts
CHANGED
|
@@ -1,8 +1,60 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeepUnwrapRef, ShallowOption } from './types'
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
DataTag,
|
|
4
|
+
DefaultError,
|
|
5
|
+
Enabled,
|
|
6
|
+
InitialDataFunction,
|
|
7
|
+
NonUndefinedGuard,
|
|
8
|
+
QueryKey,
|
|
9
|
+
QueryObserverOptions,
|
|
10
|
+
} from '@tanstack/query-core'
|
|
11
|
+
|
|
12
|
+
export type QueryOptions<
|
|
13
|
+
TQueryFnData = unknown,
|
|
14
|
+
TError = DefaultError,
|
|
15
|
+
TData = TQueryFnData,
|
|
16
|
+
TQueryData = TQueryFnData,
|
|
17
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
18
|
+
> = {
|
|
19
|
+
[Property in keyof QueryObserverOptions<
|
|
20
|
+
TQueryFnData,
|
|
21
|
+
TError,
|
|
22
|
+
TData,
|
|
23
|
+
TQueryData,
|
|
24
|
+
TQueryKey
|
|
25
|
+
>]: Property extends 'enabled'
|
|
26
|
+
? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>
|
|
27
|
+
: QueryObserverOptions<
|
|
28
|
+
TQueryFnData,
|
|
29
|
+
TError,
|
|
30
|
+
TData,
|
|
31
|
+
TQueryData,
|
|
32
|
+
DeepUnwrapRef<TQueryKey>
|
|
33
|
+
>[Property]
|
|
34
|
+
} & ShallowOption
|
|
35
|
+
|
|
36
|
+
export type UndefinedInitialQueryOptions<
|
|
37
|
+
TQueryFnData = unknown,
|
|
38
|
+
TError = DefaultError,
|
|
39
|
+
TData = TQueryFnData,
|
|
40
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
41
|
+
> = QueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey> & {
|
|
42
|
+
initialData?:
|
|
43
|
+
| undefined
|
|
44
|
+
| InitialDataFunction<NonUndefinedGuard<TQueryFnData>>
|
|
45
|
+
| NonUndefinedGuard<TQueryFnData>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type DefinedInitialQueryOptions<
|
|
49
|
+
TQueryFnData = unknown,
|
|
50
|
+
TError = DefaultError,
|
|
51
|
+
TData = TQueryFnData,
|
|
52
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
53
|
+
> = QueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey> & {
|
|
54
|
+
initialData:
|
|
55
|
+
| NonUndefinedGuard<TQueryFnData>
|
|
56
|
+
| (() => NonUndefinedGuard<TQueryFnData>)
|
|
57
|
+
}
|
|
6
58
|
|
|
7
59
|
export function queryOptions<
|
|
8
60
|
TQueryFnData = unknown,
|
|
@@ -15,6 +67,22 @@ export function queryOptions<
|
|
|
15
67
|
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
16
68
|
}
|
|
17
69
|
|
|
70
|
+
export function queryOptions<
|
|
71
|
+
TQueryFnData = unknown,
|
|
72
|
+
TError = DefaultError,
|
|
73
|
+
TData = TQueryFnData,
|
|
74
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
75
|
+
>(
|
|
76
|
+
options: () => DefinedInitialQueryOptions<
|
|
77
|
+
TQueryFnData,
|
|
78
|
+
TError,
|
|
79
|
+
TData,
|
|
80
|
+
TQueryKey
|
|
81
|
+
>,
|
|
82
|
+
): () => DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
83
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
84
|
+
}
|
|
85
|
+
|
|
18
86
|
export function queryOptions<
|
|
19
87
|
TQueryFnData = unknown,
|
|
20
88
|
TError = DefaultError,
|
|
@@ -26,6 +94,27 @@ export function queryOptions<
|
|
|
26
94
|
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
27
95
|
}
|
|
28
96
|
|
|
97
|
+
export function queryOptions<
|
|
98
|
+
TQueryFnData = unknown,
|
|
99
|
+
TError = DefaultError,
|
|
100
|
+
TData = TQueryFnData,
|
|
101
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
102
|
+
>(
|
|
103
|
+
options: () => UndefinedInitialQueryOptions<
|
|
104
|
+
TQueryFnData,
|
|
105
|
+
TError,
|
|
106
|
+
TData,
|
|
107
|
+
TQueryKey
|
|
108
|
+
>,
|
|
109
|
+
): () => UndefinedInitialQueryOptions<
|
|
110
|
+
TQueryFnData,
|
|
111
|
+
TError,
|
|
112
|
+
TData,
|
|
113
|
+
TQueryKey
|
|
114
|
+
> & {
|
|
115
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>
|
|
116
|
+
}
|
|
117
|
+
|
|
29
118
|
export function queryOptions(options: unknown) {
|
|
30
119
|
return options
|
|
31
120
|
}
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,8 @@ type UnwrapLeaf =
|
|
|
22
22
|
| Set<any>
|
|
23
23
|
| WeakSet<any>
|
|
24
24
|
|
|
25
|
+
export type MaybeGetter<T> = T | (() => T)
|
|
26
|
+
|
|
25
27
|
export type MaybeRef<T> = Ref<T> | ComputedRef<T> | T
|
|
26
28
|
|
|
27
29
|
export type MaybeRefOrGetter<T> = MaybeRef<T> | (() => T)
|
|
@@ -62,6 +64,17 @@ export type ShallowOption = {
|
|
|
62
64
|
shallow?: boolean
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
export type MutationOptions<
|
|
68
|
+
TData = unknown,
|
|
69
|
+
TError = DefaultError,
|
|
70
|
+
TVariables = void,
|
|
71
|
+
TOnMutateResult = unknown,
|
|
72
|
+
> = OmitKeyof<
|
|
73
|
+
MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
74
|
+
'_defaulted'
|
|
75
|
+
> &
|
|
76
|
+
ShallowOption
|
|
77
|
+
|
|
65
78
|
export interface DefaultOptions<TError = DefaultError> {
|
|
66
79
|
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'> &
|
|
67
80
|
ShallowOption
|
package/src/useMutation.ts
CHANGED
|
@@ -18,11 +18,9 @@ import type {
|
|
|
18
18
|
DistributiveOmit,
|
|
19
19
|
MutateFunction,
|
|
20
20
|
MutateOptions,
|
|
21
|
-
MutationObserverOptions,
|
|
22
21
|
MutationObserverResult,
|
|
23
|
-
OmitKeyof,
|
|
24
22
|
} from '@tanstack/query-core'
|
|
25
|
-
import type { MaybeRefDeep,
|
|
23
|
+
import type { MaybeRefDeep, MutationOptions } from './types'
|
|
26
24
|
import type { QueryClient } from './queryClient'
|
|
27
25
|
|
|
28
26
|
type MutationResult<TData, TError, TVariables, TOnMutateResult> =
|
|
@@ -31,24 +29,15 @@ type MutationResult<TData, TError, TVariables, TOnMutateResult> =
|
|
|
31
29
|
'mutate' | 'reset'
|
|
32
30
|
>
|
|
33
31
|
|
|
34
|
-
type UseMutationOptionsBase<TData, TError, TVariables, TOnMutateResult> =
|
|
35
|
-
OmitKeyof<
|
|
36
|
-
MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
37
|
-
'_defaulted'
|
|
38
|
-
> &
|
|
39
|
-
ShallowOption
|
|
40
|
-
|
|
41
32
|
export type UseMutationOptions<
|
|
42
33
|
TData = unknown,
|
|
43
34
|
TError = DefaultError,
|
|
44
35
|
TVariables = void,
|
|
45
36
|
TOnMutateResult = unknown,
|
|
46
37
|
> =
|
|
47
|
-
| MaybeRefDeep<
|
|
48
|
-
UseMutationOptionsBase<TData, TError, TVariables, TOnMutateResult>
|
|
49
|
-
>
|
|
38
|
+
| MaybeRefDeep<MutationOptions<TData, TError, TVariables, TOnMutateResult>>
|
|
50
39
|
| (() => MaybeRefDeep<
|
|
51
|
-
|
|
40
|
+
MutationOptions<TData, TError, TVariables, TOnMutateResult>
|
|
52
41
|
>)
|
|
53
42
|
|
|
54
43
|
type MutateSyncFunction<
|