@tanstack/vue-query 5.0.5 → 5.4.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/index.cjs +3 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +2 -1
- package/build/legacy/index.d.ts +2 -1
- package/build/legacy/index.js +2 -0
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/queryOptions.cjs +33 -0
- package/build/legacy/queryOptions.cjs.map +1 -0
- package/build/legacy/queryOptions.d.cts +14 -0
- package/build/legacy/queryOptions.d.ts +14 -0
- package/build/legacy/queryOptions.js +8 -0
- package/build/legacy/queryOptions.js.map +1 -0
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useQueries.d.cts +1 -1
- package/build/legacy/useQueries.d.ts +1 -1
- package/build/legacy/{useQuery-ee0d2f3e.d.ts → useQuery-45f53b2f.d.ts} +1 -1
- package/build/legacy/{useQuery-83bce497.d.ts → useQuery-eb363283.d.ts} +1 -1
- package/build/legacy/useQuery.d.cts +1 -1
- package/build/legacy/useQuery.d.ts +1 -1
- package/build/modern/index.cjs +3 -0
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +2 -1
- package/build/modern/index.d.ts +2 -1
- package/build/modern/index.js +2 -0
- package/build/modern/index.js.map +1 -1
- package/build/modern/queryOptions.cjs +33 -0
- package/build/modern/queryOptions.cjs.map +1 -0
- package/build/modern/queryOptions.d.cts +14 -0
- package/build/modern/queryOptions.d.ts +14 -0
- package/build/modern/queryOptions.js +8 -0
- package/build/modern/queryOptions.js.map +1 -0
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useQueries.d.cts +1 -1
- package/build/modern/useQueries.d.ts +1 -1
- package/build/modern/{useQuery-ee0d2f3e.d.ts → useQuery-45f53b2f.d.ts} +1 -1
- package/build/modern/{useQuery-83bce497.d.ts → useQuery-eb363283.d.ts} +1 -1
- package/build/modern/useQuery.d.cts +1 -1
- package/build/modern/useQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/queryOptions.types.test.ts +142 -0
- package/src/__tests__/useInfiniteQuery.types.test.tsx +1 -1
- package/src/__tests__/useMutation.types.test.tsx +1 -1
- package/src/__tests__/useQuery.types.test.ts +277 -0
- package/src/index.ts +1 -0
- package/src/queryOptions.ts +31 -0
- package/src/__tests__/useQuery.types.test.tsx +0 -89
package/build/legacy/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(src_exports, {
|
|
|
26
26
|
QueryClient: () => import_queryClient.QueryClient,
|
|
27
27
|
VUE_QUERY_CLIENT: () => import_utils.VUE_QUERY_CLIENT,
|
|
28
28
|
VueQueryPlugin: () => import_vueQueryPlugin.VueQueryPlugin,
|
|
29
|
+
queryOptions: () => import_queryOptions.queryOptions,
|
|
29
30
|
useInfiniteQuery: () => import_useInfiniteQuery.useInfiniteQuery,
|
|
30
31
|
useIsFetching: () => import_useIsFetching.useIsFetching,
|
|
31
32
|
useIsMutating: () => import_useMutationState.useIsMutating,
|
|
@@ -41,6 +42,7 @@ var import_useQueryClient = require("./useQueryClient.cjs");
|
|
|
41
42
|
var import_vueQueryPlugin = require("./vueQueryPlugin.cjs");
|
|
42
43
|
var import_queryClient = require("./queryClient.cjs");
|
|
43
44
|
var import_queryCache = require("./queryCache.cjs");
|
|
45
|
+
var import_queryOptions = require("./queryOptions.cjs");
|
|
44
46
|
var import_mutationCache = require("./mutationCache.cjs");
|
|
45
47
|
var import_useQuery = require("./useQuery.cjs");
|
|
46
48
|
var import_useQueries = require("./useQueries.cjs");
|
|
@@ -56,6 +58,7 @@ var import_utils = require("./utils.cjs");
|
|
|
56
58
|
QueryClient,
|
|
57
59
|
VUE_QUERY_CLIENT,
|
|
58
60
|
VueQueryPlugin,
|
|
61
|
+
queryOptions,
|
|
59
62
|
useInfiniteQuery,
|
|
60
63
|
useIsFetching,
|
|
61
64
|
useIsMutating,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AAEA,4BAA+B;AAC/B,4BAA+B;AAE/B,yBAA4B;AAC5B,wBAA2B;AAC3B,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;AAC3B,8BAAiC;AACjC,yBAA4B;AAC5B,2BAA8B;AAC9B,8BAAgD;AAChD,mBAAiC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { queryOptions } from './queryOptions'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AAEA,4BAA+B;AAC/B,4BAA+B;AAE/B,yBAA4B;AAC5B,wBAA2B;AAC3B,0BAA6B;AAC7B,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;AAC3B,8BAAiC;AACjC,yBAA4B;AAC5B,2BAA8B;AAC9B,8BAAgD;AAChD,mBAAiC;","names":[]}
|
package/build/legacy/index.d.cts
CHANGED
|
@@ -3,8 +3,9 @@ export { useQueryClient } from './useQueryClient.cjs';
|
|
|
3
3
|
export { VueQueryPlugin, VueQueryPluginOptions } from './vueQueryPlugin.cjs';
|
|
4
4
|
export { QueryClient } from './queryClient.cjs';
|
|
5
5
|
export { QueryCache } from './queryCache.cjs';
|
|
6
|
+
export { queryOptions } from './queryOptions.cjs';
|
|
6
7
|
export { MutationCache } from './mutationCache.cjs';
|
|
7
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-
|
|
8
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-eb363283.js';
|
|
8
9
|
export { UseQueriesOptions, UseQueriesResults, useQueries } from './useQueries.cjs';
|
|
9
10
|
export { UseMutationOptions, UseMutationReturnType, useMutation } from './useMutation.cjs';
|
|
10
11
|
export { QueryFilters, useIsFetching } from './useIsFetching.cjs';
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { useQueryClient } from './useQueryClient.js';
|
|
|
3
3
|
export { VueQueryPlugin, VueQueryPluginOptions } from './vueQueryPlugin.js';
|
|
4
4
|
export { QueryClient } from './queryClient.js';
|
|
5
5
|
export { QueryCache } from './queryCache.js';
|
|
6
|
+
export { queryOptions } from './queryOptions.js';
|
|
6
7
|
export { MutationCache } from './mutationCache.js';
|
|
7
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-
|
|
8
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-45f53b2f.js';
|
|
8
9
|
export { UseQueriesOptions, UseQueriesResults, useQueries } from './useQueries.js';
|
|
9
10
|
export { UseMutationOptions, UseMutationReturnType, useMutation } from './useMutation.js';
|
|
10
11
|
export { QueryFilters, useIsFetching } from './useIsFetching.js';
|
package/build/legacy/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useQueryClient } from "./useQueryClient.js";
|
|
|
4
4
|
import { VueQueryPlugin } from "./vueQueryPlugin.js";
|
|
5
5
|
import { QueryClient } from "./queryClient.js";
|
|
6
6
|
import { QueryCache } from "./queryCache.js";
|
|
7
|
+
import { queryOptions } from "./queryOptions.js";
|
|
7
8
|
import { MutationCache } from "./mutationCache.js";
|
|
8
9
|
import { useQuery } from "./useQuery.js";
|
|
9
10
|
import { useQueries } from "./useQueries.js";
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
QueryClient,
|
|
19
20
|
VUE_QUERY_CLIENT,
|
|
20
21
|
VueQueryPlugin,
|
|
22
|
+
queryOptions,
|
|
21
23
|
useInfiniteQuery,
|
|
22
24
|
useIsFetching,
|
|
23
25
|
useIsMutating,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";AAAA,cAAc;AAEd,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,wBAAwB;AAChD,SAAS,wBAAwB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { queryOptions } from './queryOptions'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";AAAA,cAAc;AAEd,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,wBAAwB;AAChD,SAAS,wBAAwB;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
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/queryOptions.ts
|
|
21
|
+
var queryOptions_exports = {};
|
|
22
|
+
__export(queryOptions_exports, {
|
|
23
|
+
queryOptions: () => queryOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(queryOptions_exports);
|
|
26
|
+
function queryOptions(options) {
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
queryOptions
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=queryOptions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n} from './useQuery'\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError, QueryKey, DataTag } from '@tanstack/query-core';
|
|
2
|
+
import { f as UndefinedInitialQueryOptions, D as DefinedInitialQueryOptions } from './useQuery-eb363283.js';
|
|
3
|
+
import 'vue-demi';
|
|
4
|
+
import './queryClient.cjs';
|
|
5
|
+
import './types.cjs';
|
|
6
|
+
|
|
7
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
8
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
9
|
+
};
|
|
10
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
11
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { queryOptions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError, QueryKey, DataTag } from '@tanstack/query-core';
|
|
2
|
+
import { f as UndefinedInitialQueryOptions, D as DefinedInitialQueryOptions } from './useQuery-45f53b2f.js';
|
|
3
|
+
import 'vue-demi';
|
|
4
|
+
import './queryClient.js';
|
|
5
|
+
import './types.js';
|
|
6
|
+
|
|
7
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
8
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
9
|
+
};
|
|
10
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
11
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { queryOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n} from './useQuery'\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AA4BO,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
3
|
import './queryClient.cjs';
|
|
4
|
-
export {
|
|
4
|
+
export { g as UseBaseQueryReturnType, h as useBaseQuery } from './useQuery-eb363283.js';
|
|
5
5
|
import './types.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
3
|
import './queryClient.js';
|
|
4
|
-
export {
|
|
4
|
+
export { g as UseBaseQueryReturnType, h as useBaseQuery } from './useQuery-45f53b2f.js';
|
|
5
5
|
import './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@tanstack/query-core';
|
|
2
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-
|
|
2
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-eb363283.js';
|
|
3
3
|
import './types.cjs';
|
|
4
4
|
import './queryClient.cjs';
|
|
5
5
|
import 'vue-demi';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@tanstack/query-core';
|
|
2
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-
|
|
2
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-45f53b2f.js';
|
|
3
3
|
import './types.js';
|
|
4
4
|
import './queryClient.js';
|
|
5
5
|
import 'vue-demi';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue-demi';
|
|
2
2
|
import { QueryObserverResult, QueryKey, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError, DefaultError } from '@tanstack/query-core';
|
|
3
|
-
import { U as UseQueryOptions } from './useQuery-
|
|
3
|
+
import { U as UseQueryOptions } from './useQuery-eb363283.js';
|
|
4
4
|
import { QueryClient } from './queryClient.cjs';
|
|
5
5
|
import { MaybeRefDeep, DistributiveOmit } from './types.cjs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue-demi';
|
|
2
2
|
import { QueryObserverResult, QueryKey, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError, DefaultError } from '@tanstack/query-core';
|
|
3
|
-
import { U as UseQueryOptions } from './useQuery-
|
|
3
|
+
import { U as UseQueryOptions } from './useQuery-45f53b2f.js';
|
|
4
4
|
import { QueryClient } from './queryClient.js';
|
|
5
5
|
import { MaybeRefDeep, DistributiveOmit } from './types.js';
|
|
6
6
|
|
|
@@ -43,4 +43,4 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
|
|
|
43
43
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryDefinedReturnType<TData, TError>;
|
|
44
44
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, queryClient?: QueryClient): UseQueryReturnType<TData, TError>;
|
|
45
45
|
|
|
46
|
-
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e,
|
|
46
|
+
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e, UndefinedInitialQueryOptions as f, UseBaseQueryReturnType as g, useBaseQuery as h, useQuery as u };
|
|
@@ -43,4 +43,4 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
|
|
|
43
43
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryDefinedReturnType<TData, TError>;
|
|
44
44
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, queryClient?: QueryClient): UseQueryReturnType<TData, TError>;
|
|
45
45
|
|
|
46
|
-
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e,
|
|
46
|
+
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e, UndefinedInitialQueryOptions as f, UseBaseQueryReturnType as g, useBaseQuery as h, useQuery as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
|
-
export { D as DefinedInitialQueryOptions,
|
|
3
|
+
export { D as DefinedInitialQueryOptions, f as UndefinedInitialQueryOptions, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, u as useQuery } from './useQuery-eb363283.js';
|
|
4
4
|
import './types.cjs';
|
|
5
5
|
import './queryClient.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
|
-
export { D as DefinedInitialQueryOptions,
|
|
3
|
+
export { D as DefinedInitialQueryOptions, f as UndefinedInitialQueryOptions, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, u as useQuery } from './useQuery-45f53b2f.js';
|
|
4
4
|
import './types.js';
|
|
5
5
|
import './queryClient.js';
|
package/build/modern/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(src_exports, {
|
|
|
26
26
|
QueryClient: () => import_queryClient.QueryClient,
|
|
27
27
|
VUE_QUERY_CLIENT: () => import_utils.VUE_QUERY_CLIENT,
|
|
28
28
|
VueQueryPlugin: () => import_vueQueryPlugin.VueQueryPlugin,
|
|
29
|
+
queryOptions: () => import_queryOptions.queryOptions,
|
|
29
30
|
useInfiniteQuery: () => import_useInfiniteQuery.useInfiniteQuery,
|
|
30
31
|
useIsFetching: () => import_useIsFetching.useIsFetching,
|
|
31
32
|
useIsMutating: () => import_useMutationState.useIsMutating,
|
|
@@ -41,6 +42,7 @@ var import_useQueryClient = require("./useQueryClient.cjs");
|
|
|
41
42
|
var import_vueQueryPlugin = require("./vueQueryPlugin.cjs");
|
|
42
43
|
var import_queryClient = require("./queryClient.cjs");
|
|
43
44
|
var import_queryCache = require("./queryCache.cjs");
|
|
45
|
+
var import_queryOptions = require("./queryOptions.cjs");
|
|
44
46
|
var import_mutationCache = require("./mutationCache.cjs");
|
|
45
47
|
var import_useQuery = require("./useQuery.cjs");
|
|
46
48
|
var import_useQueries = require("./useQueries.cjs");
|
|
@@ -56,6 +58,7 @@ var import_utils = require("./utils.cjs");
|
|
|
56
58
|
QueryClient,
|
|
57
59
|
VUE_QUERY_CLIENT,
|
|
58
60
|
VueQueryPlugin,
|
|
61
|
+
queryOptions,
|
|
59
62
|
useInfiniteQuery,
|
|
60
63
|
useIsFetching,
|
|
61
64
|
useIsMutating,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AAEA,4BAA+B;AAC/B,4BAA+B;AAE/B,yBAA4B;AAC5B,wBAA2B;AAC3B,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;AAC3B,8BAAiC;AACjC,yBAA4B;AAC5B,2BAA8B;AAC9B,8BAAgD;AAChD,mBAAiC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { queryOptions } from './queryOptions'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AAEA,4BAA+B;AAC/B,4BAA+B;AAE/B,yBAA4B;AAC5B,wBAA2B;AAC3B,0BAA6B;AAC7B,2BAA8B;AAC9B,sBAAyB;AACzB,wBAA2B;AAC3B,8BAAiC;AACjC,yBAA4B;AAC5B,2BAA8B;AAC9B,8BAAgD;AAChD,mBAAiC;","names":[]}
|
package/build/modern/index.d.cts
CHANGED
|
@@ -3,8 +3,9 @@ export { useQueryClient } from './useQueryClient.cjs';
|
|
|
3
3
|
export { VueQueryPlugin, VueQueryPluginOptions } from './vueQueryPlugin.cjs';
|
|
4
4
|
export { QueryClient } from './queryClient.cjs';
|
|
5
5
|
export { QueryCache } from './queryCache.cjs';
|
|
6
|
+
export { queryOptions } from './queryOptions.cjs';
|
|
6
7
|
export { MutationCache } from './mutationCache.cjs';
|
|
7
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-
|
|
8
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-eb363283.js';
|
|
8
9
|
export { UseQueriesOptions, UseQueriesResults, useQueries } from './useQueries.cjs';
|
|
9
10
|
export { UseMutationOptions, UseMutationReturnType, useMutation } from './useMutation.cjs';
|
|
10
11
|
export { QueryFilters, useIsFetching } from './useIsFetching.cjs';
|
package/build/modern/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { useQueryClient } from './useQueryClient.js';
|
|
|
3
3
|
export { VueQueryPlugin, VueQueryPluginOptions } from './vueQueryPlugin.js';
|
|
4
4
|
export { QueryClient } from './queryClient.js';
|
|
5
5
|
export { QueryCache } from './queryCache.js';
|
|
6
|
+
export { queryOptions } from './queryOptions.js';
|
|
6
7
|
export { MutationCache } from './mutationCache.js';
|
|
7
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-
|
|
8
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, a as useInfiniteQuery, u as useQuery } from './useQuery-45f53b2f.js';
|
|
8
9
|
export { UseQueriesOptions, UseQueriesResults, useQueries } from './useQueries.js';
|
|
9
10
|
export { UseMutationOptions, UseMutationReturnType, useMutation } from './useMutation.js';
|
|
10
11
|
export { QueryFilters, useIsFetching } from './useIsFetching.js';
|
package/build/modern/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useQueryClient } from "./useQueryClient.js";
|
|
|
4
4
|
import { VueQueryPlugin } from "./vueQueryPlugin.js";
|
|
5
5
|
import { QueryClient } from "./queryClient.js";
|
|
6
6
|
import { QueryCache } from "./queryCache.js";
|
|
7
|
+
import { queryOptions } from "./queryOptions.js";
|
|
7
8
|
import { MutationCache } from "./mutationCache.js";
|
|
8
9
|
import { useQuery } from "./useQuery.js";
|
|
9
10
|
import { useQueries } from "./useQueries.js";
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
QueryClient,
|
|
19
20
|
VUE_QUERY_CLIENT,
|
|
20
21
|
VueQueryPlugin,
|
|
22
|
+
queryOptions,
|
|
21
23
|
useInfiniteQuery,
|
|
22
24
|
useIsFetching,
|
|
23
25
|
useIsMutating,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";AAAA,cAAc;AAEd,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,wBAAwB;AAChD,SAAS,wBAAwB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@tanstack/query-core'\n\nexport { useQueryClient } from './useQueryClient'\nexport { VueQueryPlugin } from './vueQueryPlugin'\n\nexport { QueryClient } from './queryClient'\nexport { QueryCache } from './queryCache'\nexport { queryOptions } from './queryOptions'\nexport { MutationCache } from './mutationCache'\nexport { useQuery } from './useQuery'\nexport { useQueries } from './useQueries'\nexport { useInfiniteQuery } from './useInfiniteQuery'\nexport { useMutation } from './useMutation'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsMutating, useMutationState } from './useMutationState'\nexport { VUE_QUERY_CLIENT } from './utils'\n\nexport type {\n UseQueryOptions,\n UseQueryReturnType,\n UseQueryDefinedReturnType,\n} from './useQuery'\nexport type {\n UseInfiniteQueryOptions,\n UseInfiniteQueryReturnType,\n} from './useInfiniteQuery'\nexport type { UseMutationOptions, UseMutationReturnType } from './useMutation'\nexport type { UseQueriesOptions, UseQueriesResults } from './useQueries'\nexport type { MutationFilters, MutationStateOptions } from './useMutationState'\nexport type { QueryFilters } from './useIsFetching'\nexport type { VueQueryPluginOptions } from './vueQueryPlugin'\n"],"mappings":";AAAA,cAAc;AAEd,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,wBAAwB;AAChD,SAAS,wBAAwB;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
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/queryOptions.ts
|
|
21
|
+
var queryOptions_exports = {};
|
|
22
|
+
__export(queryOptions_exports, {
|
|
23
|
+
queryOptions: () => queryOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(queryOptions_exports);
|
|
26
|
+
function queryOptions(options) {
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
queryOptions
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=queryOptions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n} from './useQuery'\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError, QueryKey, DataTag } from '@tanstack/query-core';
|
|
2
|
+
import { f as UndefinedInitialQueryOptions, D as DefinedInitialQueryOptions } from './useQuery-eb363283.js';
|
|
3
|
+
import 'vue-demi';
|
|
4
|
+
import './queryClient.cjs';
|
|
5
|
+
import './types.cjs';
|
|
6
|
+
|
|
7
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
8
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
9
|
+
};
|
|
10
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
11
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { queryOptions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultError, QueryKey, DataTag } from '@tanstack/query-core';
|
|
2
|
+
import { f as UndefinedInitialQueryOptions, D as DefinedInitialQueryOptions } from './useQuery-45f53b2f.js';
|
|
3
|
+
import 'vue-demi';
|
|
4
|
+
import './queryClient.js';
|
|
5
|
+
import './types.js';
|
|
6
|
+
|
|
7
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
8
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
9
|
+
};
|
|
10
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
11
|
+
queryKey: DataTag<TQueryKey, TData>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { queryOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n} from './useQuery'\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TData>\n}\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AA4BO,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
3
|
import './queryClient.cjs';
|
|
4
|
-
export {
|
|
4
|
+
export { g as UseBaseQueryReturnType, h as useBaseQuery } from './useQuery-eb363283.js';
|
|
5
5
|
import './types.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
3
|
import './queryClient.js';
|
|
4
|
-
export {
|
|
4
|
+
export { g as UseBaseQueryReturnType, h as useBaseQuery } from './useQuery-45f53b2f.js';
|
|
5
5
|
import './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@tanstack/query-core';
|
|
2
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-
|
|
2
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-eb363283.js';
|
|
3
3
|
import './types.cjs';
|
|
4
4
|
import './queryClient.cjs';
|
|
5
5
|
import 'vue-demi';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@tanstack/query-core';
|
|
2
|
-
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-
|
|
2
|
+
export { d as UseInfiniteQueryOptions, e as UseInfiniteQueryReturnType, a as useInfiniteQuery } from './useQuery-45f53b2f.js';
|
|
3
3
|
import './types.js';
|
|
4
4
|
import './queryClient.js';
|
|
5
5
|
import 'vue-demi';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue-demi';
|
|
2
2
|
import { QueryObserverResult, QueryKey, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError, DefaultError } from '@tanstack/query-core';
|
|
3
|
-
import { U as UseQueryOptions } from './useQuery-
|
|
3
|
+
import { U as UseQueryOptions } from './useQuery-eb363283.js';
|
|
4
4
|
import { QueryClient } from './queryClient.cjs';
|
|
5
5
|
import { MaybeRefDeep, DistributiveOmit } from './types.cjs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue-demi';
|
|
2
2
|
import { QueryObserverResult, QueryKey, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError, DefaultError } from '@tanstack/query-core';
|
|
3
|
-
import { U as UseQueryOptions } from './useQuery-
|
|
3
|
+
import { U as UseQueryOptions } from './useQuery-45f53b2f.js';
|
|
4
4
|
import { QueryClient } from './queryClient.js';
|
|
5
5
|
import { MaybeRefDeep, DistributiveOmit } from './types.js';
|
|
6
6
|
|
|
@@ -43,4 +43,4 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
|
|
|
43
43
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryDefinedReturnType<TData, TError>;
|
|
44
44
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, queryClient?: QueryClient): UseQueryReturnType<TData, TError>;
|
|
45
45
|
|
|
46
|
-
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e,
|
|
46
|
+
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e, UndefinedInitialQueryOptions as f, UseBaseQueryReturnType as g, useBaseQuery as h, useQuery as u };
|
|
@@ -43,4 +43,4 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
|
|
|
43
43
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryDefinedReturnType<TData, TError>;
|
|
44
44
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, queryClient?: QueryClient): UseQueryReturnType<TData, TError>;
|
|
45
45
|
|
|
46
|
-
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e,
|
|
46
|
+
export { DefinedInitialQueryOptions as D, UseQueryOptions as U, useInfiniteQuery as a, UseQueryReturnType as b, UseQueryDefinedReturnType as c, UseInfiniteQueryOptions as d, UseInfiniteQueryReturnType as e, UndefinedInitialQueryOptions as f, UseBaseQueryReturnType as g, useBaseQuery as h, useQuery as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
|
-
export { D as DefinedInitialQueryOptions,
|
|
3
|
+
export { D as DefinedInitialQueryOptions, f as UndefinedInitialQueryOptions, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, u as useQuery } from './useQuery-eb363283.js';
|
|
4
4
|
import './types.cjs';
|
|
5
5
|
import './queryClient.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'vue-demi';
|
|
2
2
|
import '@tanstack/query-core';
|
|
3
|
-
export { D as DefinedInitialQueryOptions,
|
|
3
|
+
export { D as DefinedInitialQueryOptions, f as UndefinedInitialQueryOptions, c as UseQueryDefinedReturnType, U as UseQueryOptions, b as UseQueryReturnType, u as useQuery } from './useQuery-45f53b2f.js';
|
|
4
4
|
import './types.js';
|
|
5
5
|
import './queryClient.js';
|
package/package.json
CHANGED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { describe, it } from 'vitest'
|
|
2
|
+
import { QueryClient } from '@tanstack/query-core'
|
|
3
|
+
import { reactive } from 'vue-demi'
|
|
4
|
+
import { queryOptions } from '../queryOptions'
|
|
5
|
+
import { useQuery } from '../useQuery'
|
|
6
|
+
import { doNotExecute } from './test-utils'
|
|
7
|
+
import type { dataTagSymbol } from '@tanstack/query-core'
|
|
8
|
+
import type { Equal, Expect } from './test-utils'
|
|
9
|
+
|
|
10
|
+
describe('queryOptions', () => {
|
|
11
|
+
it('should not allow excess properties', () => {
|
|
12
|
+
doNotExecute(() => {
|
|
13
|
+
return queryOptions({
|
|
14
|
+
queryKey: ['key'],
|
|
15
|
+
queryFn: () => Promise.resolve(5),
|
|
16
|
+
// @ts-expect-error this is a good error, because stallTime does not exist!
|
|
17
|
+
stallTime: 1000,
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
it('should infer types for callbacks', () => {
|
|
22
|
+
doNotExecute(() => {
|
|
23
|
+
return queryOptions({
|
|
24
|
+
queryKey: ['key'],
|
|
25
|
+
queryFn: () => Promise.resolve(5),
|
|
26
|
+
staleTime: 1000,
|
|
27
|
+
select: (data) => {
|
|
28
|
+
const result: Expect<Equal<number, typeof data>> = true
|
|
29
|
+
return result
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
it('should work when passed to useQuery', () => {
|
|
35
|
+
doNotExecute(() => {
|
|
36
|
+
const options = queryOptions({
|
|
37
|
+
queryKey: ['key'],
|
|
38
|
+
queryFn: () => Promise.resolve(5),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const { data } = reactive(useQuery(options))
|
|
42
|
+
|
|
43
|
+
const result: Expect<Equal<typeof data, number | undefined>> = true
|
|
44
|
+
|
|
45
|
+
return result
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
it('should tag the queryKey with the result type of the QueryFn', () => {
|
|
49
|
+
doNotExecute(() => {
|
|
50
|
+
const { queryKey } = queryOptions({
|
|
51
|
+
queryKey: ['key'],
|
|
52
|
+
queryFn: () => Promise.resolve(5),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const result: Expect<
|
|
56
|
+
Equal<(typeof queryKey)[typeof dataTagSymbol], number>
|
|
57
|
+
> = true
|
|
58
|
+
return result
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('should tag the queryKey even if no promise is returned', () => {
|
|
62
|
+
doNotExecute(() => {
|
|
63
|
+
const { queryKey } = queryOptions({
|
|
64
|
+
queryKey: ['key'],
|
|
65
|
+
queryFn: () => 5,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const result: Expect<
|
|
69
|
+
Equal<(typeof queryKey)[typeof dataTagSymbol], number>
|
|
70
|
+
> = true
|
|
71
|
+
return result
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('should tag the queryKey with unknown if there is no queryFn', () => {
|
|
76
|
+
doNotExecute(() => {
|
|
77
|
+
const { queryKey } = queryOptions({
|
|
78
|
+
queryKey: ['key'],
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const result: Expect<
|
|
82
|
+
Equal<(typeof queryKey)[typeof dataTagSymbol], unknown>
|
|
83
|
+
> = true
|
|
84
|
+
return result
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should return the proper type when passed to getQueryData', () => {
|
|
89
|
+
doNotExecute(() => {
|
|
90
|
+
const { queryKey } = queryOptions({
|
|
91
|
+
queryKey: ['key'],
|
|
92
|
+
queryFn: () => Promise.resolve(5),
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const queryClient = new QueryClient()
|
|
96
|
+
const data = queryClient.getQueryData(queryKey)
|
|
97
|
+
|
|
98
|
+
const result: Expect<Equal<typeof data, number | undefined>> = true
|
|
99
|
+
return result
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('should properly type updaterFn when passed to setQueryData', () => {
|
|
104
|
+
doNotExecute(() => {
|
|
105
|
+
const { queryKey } = queryOptions({
|
|
106
|
+
queryKey: ['key'],
|
|
107
|
+
queryFn: () => Promise.resolve(5),
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const queryClient = new QueryClient()
|
|
111
|
+
const data = queryClient.setQueryData(queryKey, (prev) => {
|
|
112
|
+
const result: Expect<Equal<typeof prev, number | undefined>> = true
|
|
113
|
+
return result ? prev : 1
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const result: Expect<Equal<typeof data, number | undefined>> = true
|
|
117
|
+
return result
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should properly type value when passed to setQueryData', () => {
|
|
122
|
+
doNotExecute(() => {
|
|
123
|
+
const { queryKey } = queryOptions({
|
|
124
|
+
queryKey: ['key'],
|
|
125
|
+
queryFn: () => Promise.resolve(5),
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const queryClient = new QueryClient()
|
|
129
|
+
|
|
130
|
+
// @ts-expect-error value should be a number
|
|
131
|
+
queryClient.setQueryData(queryKey, '5')
|
|
132
|
+
// @ts-expect-error value should be a number
|
|
133
|
+
queryClient.setQueryData(queryKey, () => '5')
|
|
134
|
+
|
|
135
|
+
const data = queryClient.setQueryData(queryKey, 5)
|
|
136
|
+
|
|
137
|
+
const result: Expect<Equal<typeof data, number | undefined>> = true
|
|
138
|
+
return result
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it } from 'vitest'
|
|
2
|
-
import { reactive } from 'vue'
|
|
2
|
+
import { reactive } from 'vue-demi'
|
|
3
3
|
import { useInfiniteQuery } from '../useInfiniteQuery'
|
|
4
4
|
import { doNotExecute, simpleFetcher } from './test-utils'
|
|
5
5
|
import type { Equal, Expect } from './test-utils'
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { describe, it } from 'vitest'
|
|
2
|
+
import { reactive } from 'vue-demi'
|
|
3
|
+
import { useQuery } from '../useQuery'
|
|
4
|
+
import { queryOptions } from '../queryOptions'
|
|
5
|
+
import { doNotExecute, simpleFetcher } from './test-utils'
|
|
6
|
+
import type { UseQueryOptions } from '../useQuery'
|
|
7
|
+
import type { Equal, Expect } from './test-utils'
|
|
8
|
+
|
|
9
|
+
describe('initialData', () => {
|
|
10
|
+
describe('Config object overload', () => {
|
|
11
|
+
it('TData should always be defined when initialData is provided as an object', () => {
|
|
12
|
+
doNotExecute(() => {
|
|
13
|
+
const { data } = reactive(
|
|
14
|
+
useQuery({
|
|
15
|
+
queryKey: ['key'],
|
|
16
|
+
queryFn: () => {
|
|
17
|
+
return {
|
|
18
|
+
wow: true,
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
initialData: {
|
|
22
|
+
wow: true,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
28
|
+
|
|
29
|
+
return result
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('TData should be defined when passed through queryOptions', () => {
|
|
34
|
+
doNotExecute(() => {
|
|
35
|
+
const options = queryOptions({
|
|
36
|
+
queryKey: ['key'],
|
|
37
|
+
queryFn: () => {
|
|
38
|
+
return {
|
|
39
|
+
wow: true,
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
initialData: {
|
|
43
|
+
wow: true,
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
const { data } = reactive(useQuery(options))
|
|
47
|
+
|
|
48
|
+
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
49
|
+
return result
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('it should be possible to define a different TData than TQueryFnData using select with queryOptions spread into useQuery', () => {
|
|
54
|
+
doNotExecute(() => {
|
|
55
|
+
const options = queryOptions({
|
|
56
|
+
queryKey: ['key'],
|
|
57
|
+
queryFn: () => Promise.resolve(1),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const query = reactive(
|
|
61
|
+
useQuery({
|
|
62
|
+
...options,
|
|
63
|
+
select: (data) => data > 1,
|
|
64
|
+
}),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const result: Expect<Equal<boolean | undefined, typeof query.data>> =
|
|
68
|
+
true
|
|
69
|
+
return result
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('TData should always be defined when initialData is provided as a function which ALWAYS returns the data', () => {
|
|
74
|
+
doNotExecute(() => {
|
|
75
|
+
const { data } = reactive(
|
|
76
|
+
useQuery({
|
|
77
|
+
queryKey: ['key'],
|
|
78
|
+
queryFn: () => {
|
|
79
|
+
return {
|
|
80
|
+
wow: true,
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
initialData: () => ({
|
|
84
|
+
wow: true,
|
|
85
|
+
}),
|
|
86
|
+
}),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
90
|
+
return result
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('TData should have undefined in the union when initialData is NOT provided', () => {
|
|
95
|
+
doNotExecute(() => {
|
|
96
|
+
const { data } = reactive(
|
|
97
|
+
useQuery({
|
|
98
|
+
queryKey: ['key'],
|
|
99
|
+
queryFn: () => {
|
|
100
|
+
return {
|
|
101
|
+
wow: true,
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
108
|
+
true
|
|
109
|
+
return result
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('TData should have undefined in the union when initialData is provided as a function which can return undefined', () => {
|
|
114
|
+
doNotExecute(() => {
|
|
115
|
+
const { data } = reactive(
|
|
116
|
+
useQuery({
|
|
117
|
+
queryKey: ['key'],
|
|
118
|
+
queryFn: () => {
|
|
119
|
+
return {
|
|
120
|
+
wow: true,
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
initialData: () => undefined as { wow: boolean } | undefined,
|
|
124
|
+
}),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
const result: Expect<Equal<{ wow: boolean } | undefined, typeof data>> =
|
|
128
|
+
true
|
|
129
|
+
return result
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('TData should be narrowed after an isSuccess check when initialData is provided as a function which can return undefined', () => {
|
|
134
|
+
doNotExecute(() => {
|
|
135
|
+
const { data, isSuccess } = reactive(
|
|
136
|
+
useQuery({
|
|
137
|
+
queryKey: ['key'],
|
|
138
|
+
queryFn: () => {
|
|
139
|
+
return {
|
|
140
|
+
wow: true,
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
initialData: () => undefined as { wow: boolean } | undefined,
|
|
144
|
+
}),
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
if (isSuccess) {
|
|
148
|
+
const result: Expect<Equal<{ wow: boolean }, typeof data>> = true
|
|
149
|
+
return result
|
|
150
|
+
}
|
|
151
|
+
return false
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
describe('custom composables', () => {
|
|
157
|
+
it('should allow custom composables using UseQueryOptions', () => {
|
|
158
|
+
doNotExecute(() => {
|
|
159
|
+
type Data = string
|
|
160
|
+
|
|
161
|
+
const useCustomQuery = (
|
|
162
|
+
options?: Omit<UseQueryOptions<Data>, 'queryKey' | 'queryFn'>,
|
|
163
|
+
) => {
|
|
164
|
+
return useQuery({
|
|
165
|
+
...options,
|
|
166
|
+
queryKey: ['todos-key'],
|
|
167
|
+
queryFn: () => Promise.resolve('data'),
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const { data } = reactive(useCustomQuery())
|
|
172
|
+
|
|
173
|
+
const result: Expect<Equal<Data | undefined, typeof data>> = true
|
|
174
|
+
return result
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('structuralSharing', () => {
|
|
180
|
+
it('should restrict to same types', () => {
|
|
181
|
+
doNotExecute(() => {
|
|
182
|
+
useQuery({
|
|
183
|
+
queryKey: ['key'],
|
|
184
|
+
queryFn: () => 5,
|
|
185
|
+
structuralSharing: (_oldData, newData) => {
|
|
186
|
+
return newData
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
describe('Discriminated union return type', () => {
|
|
194
|
+
it('data should be possibly undefined by default', () => {
|
|
195
|
+
doNotExecute(() => {
|
|
196
|
+
const query = reactive(
|
|
197
|
+
useQuery({
|
|
198
|
+
queryKey: ['key'],
|
|
199
|
+
queryFn: simpleFetcher,
|
|
200
|
+
}),
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
const result: Expect<Equal<string | undefined, typeof query.data>> =
|
|
204
|
+
true
|
|
205
|
+
return result
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('data should be defined when query is success', () => {
|
|
210
|
+
doNotExecute(() => {
|
|
211
|
+
const query = reactive(
|
|
212
|
+
useQuery({
|
|
213
|
+
queryKey: ['key'],
|
|
214
|
+
queryFn: simpleFetcher,
|
|
215
|
+
}),
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if (query.isSuccess) {
|
|
219
|
+
const result: Expect<Equal<string, typeof query.data>> = true
|
|
220
|
+
return result
|
|
221
|
+
}
|
|
222
|
+
return
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it('error should be null when query is success', () => {
|
|
227
|
+
doNotExecute(() => {
|
|
228
|
+
const query = reactive(
|
|
229
|
+
useQuery({
|
|
230
|
+
queryKey: ['key'],
|
|
231
|
+
queryFn: simpleFetcher,
|
|
232
|
+
}),
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
if (query.isSuccess) {
|
|
236
|
+
const result: Expect<Equal<null, typeof query.error>> = true
|
|
237
|
+
return result
|
|
238
|
+
}
|
|
239
|
+
return
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it('data should be undefined when query is pending', () => {
|
|
244
|
+
doNotExecute(() => {
|
|
245
|
+
const query = reactive(
|
|
246
|
+
useQuery({
|
|
247
|
+
queryKey: ['key'],
|
|
248
|
+
queryFn: simpleFetcher,
|
|
249
|
+
}),
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
if (query.isPending) {
|
|
253
|
+
const result: Expect<Equal<undefined, typeof query.data>> = true
|
|
254
|
+
return result
|
|
255
|
+
}
|
|
256
|
+
return
|
|
257
|
+
})
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
it('error should be defined when query is error', () => {
|
|
261
|
+
doNotExecute(() => {
|
|
262
|
+
const query = reactive(
|
|
263
|
+
useQuery({
|
|
264
|
+
queryKey: ['key'],
|
|
265
|
+
queryFn: simpleFetcher,
|
|
266
|
+
}),
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
if (query.isError) {
|
|
270
|
+
const result: Expect<Equal<Error, typeof query.error>> = true
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
273
|
+
return
|
|
274
|
+
})
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { VueQueryPlugin } from './vueQueryPlugin'
|
|
|
5
5
|
|
|
6
6
|
export { QueryClient } from './queryClient'
|
|
7
7
|
export { QueryCache } from './queryCache'
|
|
8
|
+
export { queryOptions } from './queryOptions'
|
|
8
9
|
export { MutationCache } from './mutationCache'
|
|
9
10
|
export { useQuery } from './useQuery'
|
|
10
11
|
export { useQueries } from './useQueries'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'
|
|
2
|
+
import type {
|
|
3
|
+
DefinedInitialQueryOptions,
|
|
4
|
+
UndefinedInitialQueryOptions,
|
|
5
|
+
} from './useQuery'
|
|
6
|
+
|
|
7
|
+
export function queryOptions<
|
|
8
|
+
TQueryFnData = unknown,
|
|
9
|
+
TError = DefaultError,
|
|
10
|
+
TData = TQueryFnData,
|
|
11
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
12
|
+
>(
|
|
13
|
+
options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
14
|
+
): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
15
|
+
queryKey: DataTag<TQueryKey, TData>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function queryOptions<
|
|
19
|
+
TQueryFnData = unknown,
|
|
20
|
+
TError = DefaultError,
|
|
21
|
+
TData = TQueryFnData,
|
|
22
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
23
|
+
>(
|
|
24
|
+
options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
25
|
+
): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
26
|
+
queryKey: DataTag<TQueryKey, TData>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function queryOptions(options: unknown) {
|
|
30
|
+
return options
|
|
31
|
+
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'vitest'
|
|
2
|
-
import { reactive } from 'vue'
|
|
3
|
-
import { useQuery } from '../useQuery'
|
|
4
|
-
import { doNotExecute, simpleFetcher } from './test-utils'
|
|
5
|
-
import type { Equal, Expect } from './test-utils'
|
|
6
|
-
|
|
7
|
-
describe('Discriminated union return type', () => {
|
|
8
|
-
it('data should be possibly undefined by default', () => {
|
|
9
|
-
doNotExecute(() => {
|
|
10
|
-
const query = reactive(
|
|
11
|
-
useQuery({
|
|
12
|
-
queryKey: ['key'],
|
|
13
|
-
queryFn: simpleFetcher,
|
|
14
|
-
}),
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const result: Expect<Equal<string | undefined, typeof query.data>> = true
|
|
18
|
-
return result
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('data should be defined when query is success', () => {
|
|
23
|
-
doNotExecute(() => {
|
|
24
|
-
const query = reactive(
|
|
25
|
-
useQuery({
|
|
26
|
-
queryKey: ['key'],
|
|
27
|
-
queryFn: simpleFetcher,
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
if (query.isSuccess) {
|
|
32
|
-
const result: Expect<Equal<string, typeof query.data>> = true
|
|
33
|
-
return result
|
|
34
|
-
}
|
|
35
|
-
return
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('error should be null when query is success', () => {
|
|
40
|
-
doNotExecute(() => {
|
|
41
|
-
const query = reactive(
|
|
42
|
-
useQuery({
|
|
43
|
-
queryKey: ['key'],
|
|
44
|
-
queryFn: simpleFetcher,
|
|
45
|
-
}),
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
if (query.isSuccess) {
|
|
49
|
-
const result: Expect<Equal<null, typeof query.error>> = true
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
52
|
-
return
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('data should be undefined when query is pending', () => {
|
|
57
|
-
doNotExecute(() => {
|
|
58
|
-
const query = reactive(
|
|
59
|
-
useQuery({
|
|
60
|
-
queryKey: ['key'],
|
|
61
|
-
queryFn: simpleFetcher,
|
|
62
|
-
}),
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
if (query.isPending) {
|
|
66
|
-
const result: Expect<Equal<undefined, typeof query.data>> = true
|
|
67
|
-
return result
|
|
68
|
-
}
|
|
69
|
-
return
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('error should be defined when query is error', () => {
|
|
74
|
-
doNotExecute(() => {
|
|
75
|
-
const query = reactive(
|
|
76
|
-
useQuery({
|
|
77
|
-
queryKey: ['key'],
|
|
78
|
-
queryFn: simpleFetcher,
|
|
79
|
-
}),
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
if (query.isError) {
|
|
83
|
-
const result: Expect<Equal<Error, typeof query.error>> = true
|
|
84
|
-
return result
|
|
85
|
-
}
|
|
86
|
-
return
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
})
|