@tanstack/vue-query 5.0.0-alpha.50 → 5.0.0-alpha.51
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/lib/devtools/{devtools.mjs → devtools.cjs} +19 -17
- package/build/lib/devtools/{devtools.mjs.map → devtools.cjs.map} +1 -1
- package/build/lib/devtools/devtools.js +16 -18
- package/build/lib/devtools/devtools.js.map +1 -1
- package/build/lib/devtools/{utils.mjs → utils.cjs} +8 -2
- package/build/lib/devtools/utils.cjs.map +1 -0
- package/build/lib/devtools/utils.js +1 -7
- package/build/lib/devtools/utils.js.map +1 -1
- package/build/lib/index.cjs +38 -0
- package/build/lib/index.cjs.map +1 -0
- package/build/lib/index.js +13 -37
- package/build/lib/index.js.map +1 -1
- package/build/lib/mutationCache.cjs +16 -0
- package/build/lib/{mutationCache.mjs.map → mutationCache.cjs.map} +1 -1
- package/build/lib/mutationCache.js +6 -8
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/queryCache.cjs +16 -0
- package/build/lib/{queryCache.mjs.map → queryCache.cjs.map} +1 -1
- package/build/lib/queryCache.js +6 -8
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryClient.cjs +86 -0
- package/build/lib/{queryClient.mjs.map → queryClient.cjs.map} +1 -1
- package/build/lib/queryClient.js +32 -34
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/{useBaseQuery.mjs → useBaseQuery.cjs} +19 -17
- package/build/lib/{useBaseQuery.mjs.map → useBaseQuery.cjs.map} +1 -1
- package/build/lib/useBaseQuery.js +16 -18
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/{useInfiniteQuery.mjs → useInfiniteQuery.cjs} +8 -6
- package/build/lib/{useInfiniteQuery.mjs.map → useInfiniteQuery.cjs.map} +1 -1
- package/build/lib/useInfiniteQuery.js +5 -7
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useIsFetching.cjs +26 -0
- package/build/lib/{useIsFetching.mjs.map → useIsFetching.cjs.map} +1 -1
- package/build/lib/useIsFetching.js +9 -11
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useMutation.cjs +41 -0
- package/build/lib/{useMutation.mjs.map → useMutation.cjs.map} +1 -1
- package/build/lib/useMutation.js +14 -16
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutationState.cjs +36 -0
- package/build/lib/{useMutationState.mjs.map → useMutationState.cjs.map} +1 -1
- package/build/lib/useMutationState.js +12 -15
- package/build/lib/useMutationState.js.map +1 -1
- package/build/lib/{useQueries.mjs → useQueries.cjs} +17 -15
- package/build/lib/{useQueries.mjs.map → useQueries.cjs.map} +1 -1
- package/build/lib/useQueries.js +14 -16
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQuery.cjs +15 -0
- package/build/lib/{useQuery.mjs.map → useQuery.cjs.map} +1 -1
- package/build/lib/useQuery.js +4 -6
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/{useQueryClient.mjs → useQueryClient.cjs} +9 -7
- package/build/lib/{useQueryClient.mjs.map → useQueryClient.cjs.map} +1 -1
- package/build/lib/useQueryClient.js +6 -8
- package/build/lib/useQueryClient.js.map +1 -1
- package/build/lib/{utils.mjs → utils.cjs} +12 -6
- package/build/lib/{utils.mjs.map → utils.cjs.map} +1 -1
- package/build/lib/utils.js +5 -11
- package/build/lib/utils.js.map +1 -1
- package/build/lib/{vueQueryPlugin.mjs → vueQueryPlugin.cjs} +15 -13
- package/build/lib/{vueQueryPlugin.mjs.map → vueQueryPlugin.cjs.map} +1 -1
- package/build/lib/vueQueryPlugin.js +12 -14
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/package.json +8 -7
- package/build/lib/devtools/utils.mjs.map +0 -1
- package/build/lib/index.mjs +0 -14
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/mutationCache.mjs +0 -14
- package/build/lib/queryCache.mjs +0 -14
- package/build/lib/queryClient.mjs +0 -84
- package/build/lib/useIsFetching.mjs +0 -24
- package/build/lib/useMutation.mjs +0 -39
- package/build/lib/useMutationState.mjs +0 -33
- package/build/lib/useQuery.mjs +0 -13
package/build/lib/queryCache.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { QueryCache as QueryCache$1 } from '@tanstack/query-core';
|
|
2
|
-
import { cloneDeepUnref } from './utils.mjs';
|
|
3
|
-
|
|
4
|
-
class QueryCache extends QueryCache$1 {
|
|
5
|
-
find(filters) {
|
|
6
|
-
return super.find(cloneDeepUnref(filters));
|
|
7
|
-
}
|
|
8
|
-
findAll(filters = {}) {
|
|
9
|
-
return super.findAll(cloneDeepUnref(filters));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { QueryCache };
|
|
14
|
-
//# sourceMappingURL=queryCache.mjs.map
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue-demi';
|
|
2
|
-
import { QueryClient as QueryClient$1 } from '@tanstack/query-core';
|
|
3
|
-
import { cloneDeepUnref } from './utils.mjs';
|
|
4
|
-
import { QueryCache } from './queryCache.mjs';
|
|
5
|
-
import { MutationCache } from './mutationCache.mjs';
|
|
6
|
-
|
|
7
|
-
class QueryClient extends QueryClient$1 {
|
|
8
|
-
constructor(config = {}) {
|
|
9
|
-
const unreffedConfig = cloneDeepUnref(config);
|
|
10
|
-
const vueQueryConfig = {
|
|
11
|
-
defaultOptions: unreffedConfig.defaultOptions,
|
|
12
|
-
queryCache: unreffedConfig.queryCache || new QueryCache(),
|
|
13
|
-
mutationCache: unreffedConfig.mutationCache || new MutationCache()
|
|
14
|
-
};
|
|
15
|
-
super(vueQueryConfig);
|
|
16
|
-
}
|
|
17
|
-
isRestoring = ref(false);
|
|
18
|
-
isFetching(filters = {}) {
|
|
19
|
-
return super.isFetching(cloneDeepUnref(filters));
|
|
20
|
-
}
|
|
21
|
-
isMutating(filters = {}) {
|
|
22
|
-
return super.isMutating(cloneDeepUnref(filters));
|
|
23
|
-
}
|
|
24
|
-
getQueryData(queryKey) {
|
|
25
|
-
return super.getQueryData(cloneDeepUnref(queryKey));
|
|
26
|
-
}
|
|
27
|
-
getQueriesData(filters) {
|
|
28
|
-
return super.getQueriesData(cloneDeepUnref(filters));
|
|
29
|
-
}
|
|
30
|
-
setQueryData(queryKey, updater, options = {}) {
|
|
31
|
-
return super.setQueryData(cloneDeepUnref(queryKey), updater, cloneDeepUnref(options));
|
|
32
|
-
}
|
|
33
|
-
setQueriesData(filters, updater, options = {}) {
|
|
34
|
-
return super.setQueriesData(cloneDeepUnref(filters), updater, cloneDeepUnref(options));
|
|
35
|
-
}
|
|
36
|
-
getQueryState(queryKey) {
|
|
37
|
-
return super.getQueryState(cloneDeepUnref(queryKey));
|
|
38
|
-
}
|
|
39
|
-
removeQueries(filters = {}) {
|
|
40
|
-
return super.removeQueries(cloneDeepUnref(filters));
|
|
41
|
-
}
|
|
42
|
-
resetQueries(filters = {}, options = {}) {
|
|
43
|
-
return super.resetQueries(cloneDeepUnref(filters), cloneDeepUnref(options));
|
|
44
|
-
}
|
|
45
|
-
cancelQueries(filters = {}, options = {}) {
|
|
46
|
-
return super.cancelQueries(cloneDeepUnref(filters), cloneDeepUnref(options));
|
|
47
|
-
}
|
|
48
|
-
invalidateQueries(filters = {}, options = {}) {
|
|
49
|
-
return super.invalidateQueries(cloneDeepUnref(filters), cloneDeepUnref(options));
|
|
50
|
-
}
|
|
51
|
-
refetchQueries(filters = {}, options = {}) {
|
|
52
|
-
return super.refetchQueries(cloneDeepUnref(filters), cloneDeepUnref(options));
|
|
53
|
-
}
|
|
54
|
-
fetchQuery(options) {
|
|
55
|
-
return super.fetchQuery(cloneDeepUnref(options));
|
|
56
|
-
}
|
|
57
|
-
prefetchQuery(options) {
|
|
58
|
-
return super.prefetchQuery(cloneDeepUnref(options));
|
|
59
|
-
}
|
|
60
|
-
fetchInfiniteQuery(options) {
|
|
61
|
-
return super.fetchInfiniteQuery(cloneDeepUnref(options));
|
|
62
|
-
}
|
|
63
|
-
prefetchInfiniteQuery(options) {
|
|
64
|
-
return super.prefetchInfiniteQuery(cloneDeepUnref(options));
|
|
65
|
-
}
|
|
66
|
-
setDefaultOptions(options) {
|
|
67
|
-
super.setDefaultOptions(cloneDeepUnref(options));
|
|
68
|
-
}
|
|
69
|
-
setQueryDefaults(queryKey, options) {
|
|
70
|
-
super.setQueryDefaults(cloneDeepUnref(queryKey), cloneDeepUnref(options));
|
|
71
|
-
}
|
|
72
|
-
getQueryDefaults(queryKey) {
|
|
73
|
-
return super.getQueryDefaults(cloneDeepUnref(queryKey));
|
|
74
|
-
}
|
|
75
|
-
setMutationDefaults(mutationKey, options) {
|
|
76
|
-
super.setMutationDefaults(cloneDeepUnref(mutationKey), cloneDeepUnref(options));
|
|
77
|
-
}
|
|
78
|
-
getMutationDefaults(mutationKey) {
|
|
79
|
-
return super.getMutationDefaults(cloneDeepUnref(mutationKey));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { QueryClient };
|
|
84
|
-
//# sourceMappingURL=queryClient.mjs.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { computed, ref, watch, onScopeDispose } from 'vue-demi';
|
|
2
|
-
import { useQueryClient } from './useQueryClient.mjs';
|
|
3
|
-
import { cloneDeepUnref } from './utils.mjs';
|
|
4
|
-
|
|
5
|
-
function useIsFetching(fetchingFilters = {}, queryClient) {
|
|
6
|
-
const filters = computed(() => cloneDeepUnref(fetchingFilters));
|
|
7
|
-
const client = queryClient || useQueryClient();
|
|
8
|
-
const isFetching = ref(client.isFetching(filters));
|
|
9
|
-
const unsubscribe = client.getQueryCache().subscribe(() => {
|
|
10
|
-
isFetching.value = client.isFetching(filters);
|
|
11
|
-
});
|
|
12
|
-
watch(filters, () => {
|
|
13
|
-
isFetching.value = client.isFetching(filters);
|
|
14
|
-
}, {
|
|
15
|
-
deep: true
|
|
16
|
-
});
|
|
17
|
-
onScopeDispose(() => {
|
|
18
|
-
unsubscribe();
|
|
19
|
-
});
|
|
20
|
-
return isFetching;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { useIsFetching };
|
|
24
|
-
//# sourceMappingURL=useIsFetching.mjs.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { computed, reactive, watch, onScopeDispose, toRefs, readonly } from 'vue-demi';
|
|
2
|
-
import { MutationObserver } from '@tanstack/query-core';
|
|
3
|
-
import { cloneDeepUnref, updateState } from './utils.mjs';
|
|
4
|
-
import { useQueryClient } from './useQueryClient.mjs';
|
|
5
|
-
|
|
6
|
-
function useMutation(mutationOptions, queryClient) {
|
|
7
|
-
const client = queryClient || useQueryClient();
|
|
8
|
-
const options = computed(() => {
|
|
9
|
-
return client.defaultMutationOptions(cloneDeepUnref(mutationOptions));
|
|
10
|
-
});
|
|
11
|
-
const observer = new MutationObserver(client, options.value);
|
|
12
|
-
const state = reactive(observer.getCurrentResult());
|
|
13
|
-
const unsubscribe = observer.subscribe(result => {
|
|
14
|
-
updateState(state, result);
|
|
15
|
-
});
|
|
16
|
-
const mutate = (variables, mutateOptions) => {
|
|
17
|
-
observer.mutate(variables, mutateOptions).catch(() => {
|
|
18
|
-
// This is intentional
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
watch(options, () => {
|
|
22
|
-
observer.setOptions(options.value);
|
|
23
|
-
}, {
|
|
24
|
-
deep: true
|
|
25
|
-
});
|
|
26
|
-
onScopeDispose(() => {
|
|
27
|
-
unsubscribe();
|
|
28
|
-
});
|
|
29
|
-
const resultRefs = toRefs(readonly(state));
|
|
30
|
-
return {
|
|
31
|
-
...resultRefs,
|
|
32
|
-
mutate,
|
|
33
|
-
mutateAsync: state.mutate,
|
|
34
|
-
reset: state.reset
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { useMutation };
|
|
39
|
-
//# sourceMappingURL=useMutation.mjs.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { computed, ref, onScopeDispose, readonly } from 'vue-demi';
|
|
2
|
-
import { useQueryClient } from './useQueryClient.mjs';
|
|
3
|
-
import { cloneDeepUnref } from './utils.mjs';
|
|
4
|
-
|
|
5
|
-
function useIsMutating(filters = {}, queryClient) {
|
|
6
|
-
const client = queryClient || useQueryClient();
|
|
7
|
-
const unreffedFilters = computed(() => ({
|
|
8
|
-
...cloneDeepUnref(filters),
|
|
9
|
-
status: 'pending'
|
|
10
|
-
}));
|
|
11
|
-
const length = computed(() => useMutationState({
|
|
12
|
-
filters: unreffedFilters
|
|
13
|
-
}, client).value.length);
|
|
14
|
-
return length;
|
|
15
|
-
}
|
|
16
|
-
function getResult(mutationCache, options) {
|
|
17
|
-
return mutationCache.findAll(options.filters).map(mutation => options.select ? options.select(mutation) : mutation.state);
|
|
18
|
-
}
|
|
19
|
-
function useMutationState(options = {}, queryClient) {
|
|
20
|
-
const mutationCache = (queryClient || useQueryClient()).getMutationCache();
|
|
21
|
-
const state = ref(getResult(mutationCache, options));
|
|
22
|
-
const unsubscribe = mutationCache.subscribe(() => {
|
|
23
|
-
const result = getResult(mutationCache, options);
|
|
24
|
-
state.value = result;
|
|
25
|
-
});
|
|
26
|
-
onScopeDispose(() => {
|
|
27
|
-
unsubscribe();
|
|
28
|
-
});
|
|
29
|
-
return readonly(state);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { useIsMutating, useMutationState };
|
|
33
|
-
//# sourceMappingURL=useMutationState.mjs.map
|
package/build/lib/useQuery.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { QueryObserver } from '@tanstack/query-core';
|
|
2
|
-
import { useBaseQuery } from './useBaseQuery.mjs';
|
|
3
|
-
|
|
4
|
-
function useQuery(options, queryClient) {
|
|
5
|
-
const result = useBaseQuery(QueryObserver, options, queryClient);
|
|
6
|
-
return {
|
|
7
|
-
...result,
|
|
8
|
-
refetch: result.refetch.value
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { useQuery };
|
|
13
|
-
//# sourceMappingURL=useQuery.mjs.map
|