@tanstack/preact-query 0.0.1 → 5.91.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/LICENSE +21 -0
- package/README.md +48 -45
- package/build/codemods/src/utils/index.cjs +208 -0
- package/build/codemods/src/utils/transformers/query-cache-transformer.cjs +124 -0
- package/build/codemods/src/utils/transformers/query-client-transformer.cjs +53 -0
- package/build/codemods/src/utils/transformers/use-query-like-transformer.cjs +38 -0
- package/build/codemods/src/v4/key-transformation.cjs +181 -0
- package/build/codemods/src/v4/replace-import-specifier.cjs +25 -0
- package/build/codemods/src/v4/utils/replacers/key-replacer.cjs +164 -0
- package/build/codemods/src/v5/is-loading/is-loading.cjs +244 -0
- package/build/codemods/src/v5/keep-previous-data/README.md +32 -0
- package/build/codemods/src/v5/keep-previous-data/keep-previous-data.cjs +271 -0
- package/build/codemods/src/v5/keep-previous-data/utils/already-has-placeholder-data-property.cjs +26 -0
- package/build/codemods/src/v5/remove-overloads/remove-overloads.cjs +58 -0
- package/build/codemods/src/v5/remove-overloads/transformers/filter-aware-usage-transformer.cjs +271 -0
- package/build/codemods/src/v5/remove-overloads/transformers/query-fn-aware-usage-transformer.cjs +185 -0
- package/build/codemods/src/v5/remove-overloads/utils/index.cjs +123 -0
- package/build/codemods/src/v5/remove-overloads/utils/unknown-usage-error.cjs +27 -0
- package/build/codemods/src/v5/rename-hydrate/rename-hydrate.cjs +55 -0
- package/build/codemods/src/v5/rename-properties/rename-properties.cjs +41 -0
- package/build/legacy/HydrationBoundary.cjs +80 -0
- package/build/legacy/HydrationBoundary.cjs.map +1 -0
- package/build/legacy/HydrationBoundary.d.cts +14 -0
- package/build/legacy/HydrationBoundary.d.ts +14 -0
- package/build/legacy/HydrationBoundary.js +55 -0
- package/build/legacy/HydrationBoundary.js.map +1 -0
- package/build/legacy/IsRestoringProvider.cjs +37 -0
- package/build/legacy/IsRestoringProvider.cjs.map +1 -0
- package/build/legacy/IsRestoringProvider.d.cts +6 -0
- package/build/legacy/IsRestoringProvider.d.ts +6 -0
- package/build/legacy/IsRestoringProvider.js +11 -0
- package/build/legacy/IsRestoringProvider.js.map +1 -0
- package/build/legacy/QueryClientProvider.cjs +62 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -0
- package/build/legacy/QueryClientProvider.d.cts +13 -0
- package/build/legacy/QueryClientProvider.d.ts +13 -0
- package/build/legacy/QueryClientProvider.js +35 -0
- package/build/legacy/QueryClientProvider.js.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.cjs +57 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts +19 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts +19 -0
- package/build/legacy/QueryErrorResetBoundary.js +31 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -0
- package/build/legacy/errorBoundaryUtils.cjs +57 -0
- package/build/legacy/errorBoundaryUtils.cjs.map +1 -0
- package/build/legacy/errorBoundaryUtils.d.cts +15 -0
- package/build/legacy/errorBoundaryUtils.d.ts +15 -0
- package/build/legacy/errorBoundaryUtils.js +30 -0
- package/build/legacy/errorBoundaryUtils.js.map +1 -0
- package/build/legacy/index.cjs +97 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +21 -0
- package/build/legacy/index.d.ts +21 -0
- package/build/legacy/index.js +54 -0
- package/build/legacy/index.js.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs +33 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -0
- package/build/legacy/infiniteQueryOptions.d.cts +23 -0
- package/build/legacy/infiniteQueryOptions.d.ts +23 -0
- package/build/legacy/infiniteQueryOptions.js +8 -0
- package/build/legacy/infiniteQueryOptions.js.map +1 -0
- package/build/legacy/mutationOptions.cjs +33 -0
- package/build/legacy/mutationOptions.cjs.map +1 -0
- package/build/legacy/mutationOptions.d.cts +7 -0
- package/build/legacy/mutationOptions.d.ts +7 -0
- package/build/legacy/mutationOptions.js +8 -0
- package/build/legacy/mutationOptions.js.map +1 -0
- package/build/legacy/queryOptions.cjs +33 -0
- package/build/legacy/queryOptions.cjs.map +1 -0
- package/build/legacy/queryOptions.d.cts +24 -0
- package/build/legacy/queryOptions.d.ts +24 -0
- package/build/legacy/queryOptions.js +8 -0
- package/build/legacy/queryOptions.js.map +1 -0
- package/build/legacy/suspense.cjs +58 -0
- package/build/legacy/suspense.cjs.map +1 -0
- package/build/legacy/suspense.d.cts +11 -0
- package/build/legacy/suspense.d.ts +11 -0
- package/build/legacy/suspense.js +29 -0
- package/build/legacy/suspense.js.map +1 -0
- package/build/legacy/types.cjs +19 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/legacy/types.d.cts +52 -0
- package/build/legacy/types.d.ts +52 -0
- package/build/legacy/types.js +1 -0
- package/build/legacy/types.js.map +1 -0
- package/build/legacy/useBaseQuery.cjs +121 -0
- package/build/legacy/useBaseQuery.cjs.map +1 -0
- package/build/legacy/useBaseQuery.d.cts +6 -0
- package/build/legacy/useBaseQuery.d.ts +6 -0
- package/build/legacy/useBaseQuery.js +105 -0
- package/build/legacy/useBaseQuery.js.map +1 -0
- package/build/legacy/useInfiniteQuery.cjs +39 -0
- package/build/legacy/useInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useInfiniteQuery.d.cts +9 -0
- package/build/legacy/useInfiniteQuery.d.ts +9 -0
- package/build/legacy/useInfiniteQuery.js +14 -0
- package/build/legacy/useInfiniteQuery.js.map +1 -0
- package/build/legacy/useIsFetching.cjs +45 -0
- package/build/legacy/useIsFetching.cjs.map +1 -0
- package/build/legacy/useIsFetching.d.cts +5 -0
- package/build/legacy/useIsFetching.d.ts +5 -0
- package/build/legacy/useIsFetching.js +20 -0
- package/build/legacy/useIsFetching.js.map +1 -0
- package/build/legacy/useMutation.cjs +63 -0
- package/build/legacy/useMutation.cjs.map +1 -0
- package/build/legacy/useMutation.d.cts +6 -0
- package/build/legacy/useMutation.d.ts +6 -0
- package/build/legacy/useMutation.js +43 -0
- package/build/legacy/useMutation.js.map +1 -0
- package/build/legacy/useMutationState.cjs +75 -0
- package/build/legacy/useMutationState.cjs.map +1 -0
- package/build/legacy/useMutationState.d.cts +10 -0
- package/build/legacy/useMutationState.d.ts +10 -0
- package/build/legacy/useMutationState.js +49 -0
- package/build/legacy/useMutationState.js.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs +37 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +5 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +5 -0
- package/build/legacy/usePrefetchInfiniteQuery.js +12 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -0
- package/build/legacy/usePrefetchQuery.cjs +37 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -0
- package/build/legacy/usePrefetchQuery.d.cts +6 -0
- package/build/legacy/usePrefetchQuery.d.ts +6 -0
- package/build/legacy/usePrefetchQuery.js +12 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -0
- package/build/legacy/useQueries.cjs +120 -0
- package/build/legacy/useQueries.cjs.map +1 -0
- package/build/legacy/useQueries.d.cts +76 -0
- package/build/legacy/useQueries.d.ts +76 -0
- package/build/legacy/useQueries.js +109 -0
- package/build/legacy/useQueries.js.map +1 -0
- package/build/legacy/useQuery.cjs +35 -0
- package/build/legacy/useQuery.cjs.map +1 -0
- package/build/legacy/useQuery.d.cts +9 -0
- package/build/legacy/useQuery.d.ts +9 -0
- package/build/legacy/useQuery.js +10 -0
- package/build/legacy/useQuery.js.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs +50 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -0
- package/build/legacy/useSuspenseInfiniteQuery.js +25 -0
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -0
- package/build/legacy/useSuspenseQueries.cjs +55 -0
- package/build/legacy/useSuspenseQueries.cjs.map +1 -0
- package/build/legacy/useSuspenseQueries.d.cts +79 -0
- package/build/legacy/useSuspenseQueries.d.ts +79 -0
- package/build/legacy/useSuspenseQueries.js +30 -0
- package/build/legacy/useSuspenseQueries.js.map +1 -0
- package/build/legacy/useSuspenseQuery.cjs +51 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -0
- package/build/legacy/useSuspenseQuery.d.cts +6 -0
- package/build/legacy/useSuspenseQuery.d.ts +6 -0
- package/build/legacy/useSuspenseQuery.js +26 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -0
- package/build/legacy/utils.cjs +79 -0
- package/build/legacy/utils.cjs.map +1 -0
- package/build/legacy/utils.d.cts +4 -0
- package/build/legacy/utils.d.ts +4 -0
- package/build/legacy/utils.js +53 -0
- package/build/legacy/utils.js.map +1 -0
- package/build/modern/HydrationBoundary.cjs +80 -0
- package/build/modern/HydrationBoundary.cjs.map +1 -0
- package/build/modern/HydrationBoundary.d.cts +14 -0
- package/build/modern/HydrationBoundary.d.ts +14 -0
- package/build/modern/HydrationBoundary.js +55 -0
- package/build/modern/HydrationBoundary.js.map +1 -0
- package/build/modern/IsRestoringProvider.cjs +37 -0
- package/build/modern/IsRestoringProvider.cjs.map +1 -0
- package/build/modern/IsRestoringProvider.d.cts +6 -0
- package/build/modern/IsRestoringProvider.d.ts +6 -0
- package/build/modern/IsRestoringProvider.js +11 -0
- package/build/modern/IsRestoringProvider.js.map +1 -0
- package/build/modern/QueryClientProvider.cjs +62 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -0
- package/build/modern/QueryClientProvider.d.cts +13 -0
- package/build/modern/QueryClientProvider.d.ts +13 -0
- package/build/modern/QueryClientProvider.js +35 -0
- package/build/modern/QueryClientProvider.js.map +1 -0
- package/build/modern/QueryErrorResetBoundary.cjs +57 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/modern/QueryErrorResetBoundary.d.cts +19 -0
- package/build/modern/QueryErrorResetBoundary.d.ts +19 -0
- package/build/modern/QueryErrorResetBoundary.js +31 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -0
- package/build/modern/errorBoundaryUtils.cjs +57 -0
- package/build/modern/errorBoundaryUtils.cjs.map +1 -0
- package/build/modern/errorBoundaryUtils.d.cts +15 -0
- package/build/modern/errorBoundaryUtils.d.ts +15 -0
- package/build/modern/errorBoundaryUtils.js +30 -0
- package/build/modern/errorBoundaryUtils.js.map +1 -0
- package/build/modern/index.cjs +97 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +21 -0
- package/build/modern/index.d.ts +21 -0
- package/build/modern/index.js +54 -0
- package/build/modern/index.js.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs +33 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -0
- package/build/modern/infiniteQueryOptions.d.cts +23 -0
- package/build/modern/infiniteQueryOptions.d.ts +23 -0
- package/build/modern/infiniteQueryOptions.js +8 -0
- package/build/modern/infiniteQueryOptions.js.map +1 -0
- package/build/modern/mutationOptions.cjs +33 -0
- package/build/modern/mutationOptions.cjs.map +1 -0
- package/build/modern/mutationOptions.d.cts +7 -0
- package/build/modern/mutationOptions.d.ts +7 -0
- package/build/modern/mutationOptions.js +8 -0
- package/build/modern/mutationOptions.js.map +1 -0
- package/build/modern/queryOptions.cjs +33 -0
- package/build/modern/queryOptions.cjs.map +1 -0
- package/build/modern/queryOptions.d.cts +24 -0
- package/build/modern/queryOptions.d.ts +24 -0
- package/build/modern/queryOptions.js +8 -0
- package/build/modern/queryOptions.js.map +1 -0
- package/build/modern/suspense.cjs +58 -0
- package/build/modern/suspense.cjs.map +1 -0
- package/build/modern/suspense.d.cts +11 -0
- package/build/modern/suspense.d.ts +11 -0
- package/build/modern/suspense.js +29 -0
- package/build/modern/suspense.js.map +1 -0
- package/build/modern/types.cjs +19 -0
- package/build/modern/types.cjs.map +1 -0
- package/build/modern/types.d.cts +52 -0
- package/build/modern/types.d.ts +52 -0
- package/build/modern/types.js +1 -0
- package/build/modern/types.js.map +1 -0
- package/build/modern/useBaseQuery.cjs +118 -0
- package/build/modern/useBaseQuery.cjs.map +1 -0
- package/build/modern/useBaseQuery.d.cts +6 -0
- package/build/modern/useBaseQuery.d.ts +6 -0
- package/build/modern/useBaseQuery.js +102 -0
- package/build/modern/useBaseQuery.js.map +1 -0
- package/build/modern/useInfiniteQuery.cjs +39 -0
- package/build/modern/useInfiniteQuery.cjs.map +1 -0
- package/build/modern/useInfiniteQuery.d.cts +9 -0
- package/build/modern/useInfiniteQuery.d.ts +9 -0
- package/build/modern/useInfiniteQuery.js +14 -0
- package/build/modern/useInfiniteQuery.js.map +1 -0
- package/build/modern/useIsFetching.cjs +45 -0
- package/build/modern/useIsFetching.cjs.map +1 -0
- package/build/modern/useIsFetching.d.cts +5 -0
- package/build/modern/useIsFetching.d.ts +5 -0
- package/build/modern/useIsFetching.js +20 -0
- package/build/modern/useIsFetching.js.map +1 -0
- package/build/modern/useMutation.cjs +63 -0
- package/build/modern/useMutation.cjs.map +1 -0
- package/build/modern/useMutation.d.cts +6 -0
- package/build/modern/useMutation.d.ts +6 -0
- package/build/modern/useMutation.js +43 -0
- package/build/modern/useMutation.js.map +1 -0
- package/build/modern/useMutationState.cjs +75 -0
- package/build/modern/useMutationState.cjs.map +1 -0
- package/build/modern/useMutationState.d.cts +10 -0
- package/build/modern/useMutationState.d.ts +10 -0
- package/build/modern/useMutationState.js +49 -0
- package/build/modern/useMutationState.js.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs +37 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -0
- package/build/modern/usePrefetchInfiniteQuery.d.cts +5 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts +5 -0
- package/build/modern/usePrefetchInfiniteQuery.js +12 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -0
- package/build/modern/usePrefetchQuery.cjs +37 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -0
- package/build/modern/usePrefetchQuery.d.cts +6 -0
- package/build/modern/usePrefetchQuery.d.ts +6 -0
- package/build/modern/usePrefetchQuery.js +12 -0
- package/build/modern/usePrefetchQuery.js.map +1 -0
- package/build/modern/useQueries.cjs +120 -0
- package/build/modern/useQueries.cjs.map +1 -0
- package/build/modern/useQueries.d.cts +76 -0
- package/build/modern/useQueries.d.ts +76 -0
- package/build/modern/useQueries.js +109 -0
- package/build/modern/useQueries.js.map +1 -0
- package/build/modern/useQuery.cjs +35 -0
- package/build/modern/useQuery.cjs.map +1 -0
- package/build/modern/useQuery.d.cts +9 -0
- package/build/modern/useQuery.d.ts +9 -0
- package/build/modern/useQuery.js +10 -0
- package/build/modern/useQuery.js.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs +50 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -0
- package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -0
- package/build/modern/useSuspenseInfiniteQuery.js +25 -0
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -0
- package/build/modern/useSuspenseQueries.cjs +55 -0
- package/build/modern/useSuspenseQueries.cjs.map +1 -0
- package/build/modern/useSuspenseQueries.d.cts +79 -0
- package/build/modern/useSuspenseQueries.d.ts +79 -0
- package/build/modern/useSuspenseQueries.js +30 -0
- package/build/modern/useSuspenseQueries.js.map +1 -0
- package/build/modern/useSuspenseQuery.cjs +51 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -0
- package/build/modern/useSuspenseQuery.d.cts +6 -0
- package/build/modern/useSuspenseQuery.d.ts +6 -0
- package/build/modern/useSuspenseQuery.js +26 -0
- package/build/modern/useSuspenseQuery.js.map +1 -0
- package/build/modern/utils.cjs +79 -0
- package/build/modern/utils.cjs.map +1 -0
- package/build/modern/utils.d.cts +4 -0
- package/build/modern/utils.d.ts +4 -0
- package/build/modern/utils.js +53 -0
- package/build/modern/utils.js.map +1 -0
- package/build/query-codemods/eslint.config.js +18 -0
- package/build/query-codemods/package.json +38 -0
- package/build/query-codemods/root.eslint.config.js +64 -0
- package/build/query-codemods/tsconfig.json +8 -0
- package/build/query-codemods/vite.config.ts +30 -0
- package/package.json +82 -8
- package/src/HydrationBoundary.tsx +108 -0
- package/src/IsRestoringProvider.ts +7 -0
- package/src/QueryClientProvider.tsx +45 -0
- package/src/QueryErrorResetBoundary.tsx +57 -0
- package/src/errorBoundaryUtils.ts +76 -0
- package/src/index.ts +56 -0
- package/src/infiniteQueryOptions.ts +150 -0
- package/src/mutationOptions.ts +42 -0
- package/src/queryOptions.ts +88 -0
- package/src/suspense.ts +81 -0
- package/src/types.ts +241 -0
- package/src/useBaseQuery.ts +169 -0
- package/src/useInfiniteQuery.ts +81 -0
- package/src/useIsFetching.ts +23 -0
- package/src/useMutation.ts +69 -0
- package/src/useMutationState.ts +74 -0
- package/src/usePrefetchInfiniteQuery.tsx +31 -0
- package/src/usePrefetchQuery.tsx +20 -0
- package/src/useQueries.ts +331 -0
- package/src/useQuery.ts +52 -0
- package/src/useSuspenseInfiniteQuery.ts +50 -0
- package/src/useSuspenseQueries.ts +211 -0
- package/src/useSuspenseQuery.ts +34 -0
- package/src/utils.ts +88 -0
package/package.json
CHANGED
|
@@ -1,10 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-query",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
"version": "5.91.0",
|
|
4
|
+
"description": "Hooks for managing, caching and syncing asynchronous and remote data in preact",
|
|
5
|
+
"author": "tannerlinsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/TanStack/query.git",
|
|
10
|
+
"directory": "packages/preact-query"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://tanstack.com/query",
|
|
13
|
+
"funding": {
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"types": "build/legacy/index.d.ts",
|
|
19
|
+
"main": "build/legacy/index.cjs",
|
|
20
|
+
"module": "build/legacy/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"@tanstack/custom-condition": "./src/index.ts",
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./build/modern/index.d.ts",
|
|
26
|
+
"default": "./build/modern/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./build/modern/index.d.cts",
|
|
30
|
+
"default": "./build/modern/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"files": [
|
|
37
|
+
"build",
|
|
38
|
+
"src",
|
|
39
|
+
"!src/__tests__",
|
|
40
|
+
"!build/codemods/node_modules",
|
|
41
|
+
"!build/codemods/vite.config.ts",
|
|
42
|
+
"!build/codemods/**/__testfixtures__",
|
|
43
|
+
"!build/codemods/**/__tests__"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@tanstack/query-core": "5.90.20"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@preact/preset-vite": "^2.10.2",
|
|
50
|
+
"@testing-library/preact": "^3.2.4",
|
|
51
|
+
"cpy-cli": "^5.0.0",
|
|
52
|
+
"eslint-config-preact": "^2.0.0",
|
|
53
|
+
"npm-run-all2": "^5.0.0",
|
|
54
|
+
"preact": "^10.28.0",
|
|
55
|
+
"preact-render-to-string": "^6.6.4",
|
|
56
|
+
"typescript-eslint": "^8.54.0",
|
|
57
|
+
"@tanstack/query-test-utils": "0.0.0",
|
|
58
|
+
"@tanstack/query-persist-client-core": "5.91.19"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"preact": "^10.0.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"clean": "premove ./build ./coverage ./dist-ts",
|
|
65
|
+
"compile": "tsc --build",
|
|
66
|
+
"test:eslint": "eslint --concurrency=auto ./src",
|
|
67
|
+
"test:types": "npm-run-all --serial test:types:*",
|
|
68
|
+
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js --build tsconfig.legacy.json",
|
|
69
|
+
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js --build tsconfig.legacy.json",
|
|
70
|
+
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js --build tsconfig.legacy.json",
|
|
71
|
+
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js --build tsconfig.legacy.json",
|
|
72
|
+
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
|
|
73
|
+
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
|
|
74
|
+
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
|
|
75
|
+
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
|
|
76
|
+
"test:types:tscurrent": "tsc --build",
|
|
77
|
+
"test:lib": "vitest",
|
|
78
|
+
"test:lib:dev": "pnpm run test:lib --watch",
|
|
79
|
+
"test:build": "publint --strict && attw --pack",
|
|
80
|
+
"build": "pnpm build:tsup && pnpm build:codemods",
|
|
81
|
+
"build:tsup": "tsup --tsconfig tsconfig.prod.json",
|
|
82
|
+
"build:codemods": "cpy ../query-codemods/* ./build/codemods"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { hydrate } from '@tanstack/query-core'
|
|
2
|
+
import type {
|
|
3
|
+
DehydratedState,
|
|
4
|
+
HydrateOptions,
|
|
5
|
+
OmitKeyof,
|
|
6
|
+
QueryClient,
|
|
7
|
+
} from '@tanstack/query-core'
|
|
8
|
+
import type { ComponentChildren } from 'preact'
|
|
9
|
+
import { useEffect, useMemo, useRef } from 'preact/hooks'
|
|
10
|
+
|
|
11
|
+
import { useQueryClient } from './QueryClientProvider'
|
|
12
|
+
|
|
13
|
+
export interface HydrationBoundaryProps {
|
|
14
|
+
state: DehydratedState | null | undefined
|
|
15
|
+
options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {
|
|
16
|
+
defaultOptions?: OmitKeyof<
|
|
17
|
+
Exclude<HydrateOptions['defaultOptions'], undefined>,
|
|
18
|
+
'mutations'
|
|
19
|
+
>
|
|
20
|
+
}
|
|
21
|
+
children?: ComponentChildren
|
|
22
|
+
queryClient?: QueryClient
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const HydrationBoundary = ({
|
|
26
|
+
children,
|
|
27
|
+
options = {},
|
|
28
|
+
state,
|
|
29
|
+
queryClient,
|
|
30
|
+
}: HydrationBoundaryProps) => {
|
|
31
|
+
const client = useQueryClient(queryClient)
|
|
32
|
+
|
|
33
|
+
const optionsRef = useRef(options)
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
optionsRef.current = options
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// This useMemo is for performance reasons only, everything inside it must
|
|
39
|
+
// be safe to run in every render and code here should be read as "in render".
|
|
40
|
+
//
|
|
41
|
+
// This code needs to happen during the render phase, because after initial
|
|
42
|
+
// SSR, hydration needs to happen _before_ children render. Also, if hydrating
|
|
43
|
+
// during a transition, we want to hydrate as much as is safe in render so
|
|
44
|
+
// we can prerender as much as possible.
|
|
45
|
+
//
|
|
46
|
+
// For any queries that already exist in the cache, we want to hold back on
|
|
47
|
+
// hydrating until _after_ the render phase. The reason for this is that during
|
|
48
|
+
// transitions, we don't want the existing queries and observers to update to
|
|
49
|
+
// the new data on the current page, only _after_ the transition is committed.
|
|
50
|
+
// If the transition is aborted, we will have hydrated any _new_ queries, but
|
|
51
|
+
// we throw away the fresh data for any existing ones to avoid unexpectedly
|
|
52
|
+
// updating the UI.
|
|
53
|
+
const hydrationQueue: DehydratedState['queries'] | undefined = useMemo(() => {
|
|
54
|
+
if (state) {
|
|
55
|
+
if (typeof state !== 'object') {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const queryCache = client.getQueryCache()
|
|
60
|
+
// State is supplied from the outside and we might as well fail
|
|
61
|
+
// gracefully if it has the wrong shape, so while we type `queries`
|
|
62
|
+
// as required, we still provide a fallback.
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
64
|
+
const queries = state.queries || []
|
|
65
|
+
|
|
66
|
+
const newQueries: DehydratedState['queries'] = []
|
|
67
|
+
const existingQueries: DehydratedState['queries'] = []
|
|
68
|
+
for (const dehydratedQuery of queries) {
|
|
69
|
+
const existingQuery = queryCache.get(dehydratedQuery.queryHash)
|
|
70
|
+
|
|
71
|
+
if (!existingQuery) {
|
|
72
|
+
newQueries.push(dehydratedQuery)
|
|
73
|
+
} else {
|
|
74
|
+
const hydrationIsNewer =
|
|
75
|
+
dehydratedQuery.state.dataUpdatedAt >
|
|
76
|
+
existingQuery.state.dataUpdatedAt ||
|
|
77
|
+
(dehydratedQuery.promise &&
|
|
78
|
+
existingQuery.state.status !== 'pending' &&
|
|
79
|
+
existingQuery.state.fetchStatus !== 'fetching' &&
|
|
80
|
+
dehydratedQuery.dehydratedAt !== undefined &&
|
|
81
|
+
dehydratedQuery.dehydratedAt > existingQuery.state.dataUpdatedAt)
|
|
82
|
+
|
|
83
|
+
if (hydrationIsNewer) {
|
|
84
|
+
existingQueries.push(dehydratedQuery)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (newQueries.length > 0) {
|
|
90
|
+
// It's actually fine to call this with queries/state that already exists
|
|
91
|
+
// in the cache, or is older. hydrate() is idempotent for queries.
|
|
92
|
+
hydrate(client, { queries: newQueries }, optionsRef.current)
|
|
93
|
+
}
|
|
94
|
+
if (existingQueries.length > 0) {
|
|
95
|
+
return existingQueries
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return undefined
|
|
99
|
+
}, [client, state])
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (hydrationQueue) {
|
|
103
|
+
hydrate(client, { queries: hydrationQueue }, optionsRef.current)
|
|
104
|
+
}
|
|
105
|
+
}, [client, hydrationQueue])
|
|
106
|
+
|
|
107
|
+
return children as ComponentChildren
|
|
108
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from 'preact'
|
|
2
|
+
import { useContext } from 'preact/hooks'
|
|
3
|
+
|
|
4
|
+
const IsRestoringContext = createContext(false)
|
|
5
|
+
|
|
6
|
+
export const useIsRestoring = () => useContext(IsRestoringContext)
|
|
7
|
+
export const IsRestoringProvider = IsRestoringContext.Provider
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/query-core'
|
|
2
|
+
import { createContext } from 'preact'
|
|
3
|
+
import type { ComponentChildren, VNode } from 'preact'
|
|
4
|
+
import { useContext, useEffect } from 'preact/hooks'
|
|
5
|
+
|
|
6
|
+
export const QueryClientContext = createContext<QueryClient | undefined>(
|
|
7
|
+
undefined,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
export const useQueryClient = (queryClient?: QueryClient) => {
|
|
11
|
+
const client = useContext(QueryClientContext)
|
|
12
|
+
|
|
13
|
+
if (queryClient) {
|
|
14
|
+
return queryClient
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!client) {
|
|
18
|
+
throw new Error('No QueryClient set, use QueryClientProvider to set one')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return client
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type QueryClientProviderProps = {
|
|
25
|
+
client: QueryClient
|
|
26
|
+
children?: ComponentChildren
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const QueryClientProvider = ({
|
|
30
|
+
client,
|
|
31
|
+
children,
|
|
32
|
+
}: QueryClientProviderProps): VNode => {
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
client.mount()
|
|
35
|
+
return () => {
|
|
36
|
+
client.unmount()
|
|
37
|
+
}
|
|
38
|
+
}, [client])
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<QueryClientContext.Provider value={client}>
|
|
42
|
+
{children}
|
|
43
|
+
</QueryClientContext.Provider>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createContext } from 'preact'
|
|
2
|
+
import type { ComponentChildren } from 'preact'
|
|
3
|
+
import { useContext, useState } from 'preact/hooks'
|
|
4
|
+
|
|
5
|
+
// CONTEXT
|
|
6
|
+
export type QueryErrorResetFunction = () => void
|
|
7
|
+
export type QueryErrorIsResetFunction = () => boolean
|
|
8
|
+
export type QueryErrorClearResetFunction = () => void
|
|
9
|
+
|
|
10
|
+
export interface QueryErrorResetBoundaryValue {
|
|
11
|
+
clearReset: QueryErrorClearResetFunction
|
|
12
|
+
isReset: QueryErrorIsResetFunction
|
|
13
|
+
reset: QueryErrorResetFunction
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createValue(): QueryErrorResetBoundaryValue {
|
|
17
|
+
let isReset = false
|
|
18
|
+
return {
|
|
19
|
+
clearReset: () => {
|
|
20
|
+
isReset = false
|
|
21
|
+
},
|
|
22
|
+
reset: () => {
|
|
23
|
+
isReset = true
|
|
24
|
+
},
|
|
25
|
+
isReset: () => {
|
|
26
|
+
return isReset
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const QueryErrorResetBoundaryContext = createContext(createValue())
|
|
32
|
+
|
|
33
|
+
// HOOK
|
|
34
|
+
|
|
35
|
+
export const useQueryErrorResetBoundary = () =>
|
|
36
|
+
useContext(QueryErrorResetBoundaryContext)
|
|
37
|
+
|
|
38
|
+
// COMPONENT
|
|
39
|
+
|
|
40
|
+
export type QueryErrorResetBoundaryFunction = (
|
|
41
|
+
value: QueryErrorResetBoundaryValue,
|
|
42
|
+
) => ComponentChildren
|
|
43
|
+
|
|
44
|
+
export interface QueryErrorResetBoundaryProps {
|
|
45
|
+
children: QueryErrorResetBoundaryFunction | ComponentChildren
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const QueryErrorResetBoundary = ({
|
|
49
|
+
children,
|
|
50
|
+
}: QueryErrorResetBoundaryProps) => {
|
|
51
|
+
const [value] = useState(() => createValue())
|
|
52
|
+
return (
|
|
53
|
+
<QueryErrorResetBoundaryContext.Provider value={value}>
|
|
54
|
+
{typeof children === 'function' ? children(value) : children}
|
|
55
|
+
</QueryErrorResetBoundaryContext.Provider>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { shouldThrowError } from '@tanstack/query-core'
|
|
2
|
+
import type {
|
|
3
|
+
DefaultedQueryObserverOptions,
|
|
4
|
+
Query,
|
|
5
|
+
QueryKey,
|
|
6
|
+
QueryObserverResult,
|
|
7
|
+
ThrowOnError,
|
|
8
|
+
} from '@tanstack/query-core'
|
|
9
|
+
import { useEffect } from 'preact/hooks'
|
|
10
|
+
|
|
11
|
+
import type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'
|
|
12
|
+
|
|
13
|
+
export const ensurePreventErrorBoundaryRetry = <
|
|
14
|
+
TQueryFnData,
|
|
15
|
+
TError,
|
|
16
|
+
TData,
|
|
17
|
+
TQueryData,
|
|
18
|
+
TQueryKey extends QueryKey,
|
|
19
|
+
>(
|
|
20
|
+
options: DefaultedQueryObserverOptions<
|
|
21
|
+
TQueryFnData,
|
|
22
|
+
TError,
|
|
23
|
+
TData,
|
|
24
|
+
TQueryData,
|
|
25
|
+
TQueryKey
|
|
26
|
+
>,
|
|
27
|
+
errorResetBoundary: QueryErrorResetBoundaryValue,
|
|
28
|
+
) => {
|
|
29
|
+
if (
|
|
30
|
+
options.suspense ||
|
|
31
|
+
options.throwOnError ||
|
|
32
|
+
options.experimental_prefetchInRender
|
|
33
|
+
) {
|
|
34
|
+
// Prevent retrying failed query if the error boundary has not been reset yet
|
|
35
|
+
if (!errorResetBoundary.isReset()) {
|
|
36
|
+
options.retryOnMount = false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const useClearResetErrorBoundary = (
|
|
42
|
+
errorResetBoundary: QueryErrorResetBoundaryValue,
|
|
43
|
+
) => {
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
errorResetBoundary.clearReset()
|
|
46
|
+
}, [errorResetBoundary])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getHasError = <
|
|
50
|
+
TData,
|
|
51
|
+
TError,
|
|
52
|
+
TQueryFnData,
|
|
53
|
+
TQueryData,
|
|
54
|
+
TQueryKey extends QueryKey,
|
|
55
|
+
>({
|
|
56
|
+
result,
|
|
57
|
+
errorResetBoundary,
|
|
58
|
+
throwOnError,
|
|
59
|
+
query,
|
|
60
|
+
suspense,
|
|
61
|
+
}: {
|
|
62
|
+
result: QueryObserverResult<TData, TError>
|
|
63
|
+
errorResetBoundary: QueryErrorResetBoundaryValue
|
|
64
|
+
throwOnError: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>
|
|
65
|
+
query: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined
|
|
66
|
+
suspense: boolean | undefined
|
|
67
|
+
}) => {
|
|
68
|
+
return (
|
|
69
|
+
result.isError &&
|
|
70
|
+
!errorResetBoundary.isReset() &&
|
|
71
|
+
!result.isFetching &&
|
|
72
|
+
query &&
|
|
73
|
+
((suspense && result.data === undefined) ||
|
|
74
|
+
shouldThrowError(throwOnError, [result.error, query]))
|
|
75
|
+
)
|
|
76
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
|
|
3
|
+
// Re-export core
|
|
4
|
+
export * from '@tanstack/query-core'
|
|
5
|
+
|
|
6
|
+
// Preact Query
|
|
7
|
+
export * from './types'
|
|
8
|
+
export { useQueries } from './useQueries'
|
|
9
|
+
export type { QueriesResults, QueriesOptions } from './useQueries'
|
|
10
|
+
export { useQuery } from './useQuery'
|
|
11
|
+
export { useSuspenseQuery } from './useSuspenseQuery'
|
|
12
|
+
export { useSuspenseInfiniteQuery } from './useSuspenseInfiniteQuery'
|
|
13
|
+
export { useSuspenseQueries } from './useSuspenseQueries'
|
|
14
|
+
export type {
|
|
15
|
+
SuspenseQueriesResults,
|
|
16
|
+
SuspenseQueriesOptions,
|
|
17
|
+
} from './useSuspenseQueries'
|
|
18
|
+
export { usePrefetchQuery } from './usePrefetchQuery'
|
|
19
|
+
export { usePrefetchInfiniteQuery } from './usePrefetchInfiniteQuery'
|
|
20
|
+
export { queryOptions } from './queryOptions'
|
|
21
|
+
export type {
|
|
22
|
+
DefinedInitialDataOptions,
|
|
23
|
+
UndefinedInitialDataOptions,
|
|
24
|
+
UnusedSkipTokenOptions,
|
|
25
|
+
} from './queryOptions'
|
|
26
|
+
export { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
27
|
+
export type {
|
|
28
|
+
DefinedInitialDataInfiniteOptions,
|
|
29
|
+
UndefinedInitialDataInfiniteOptions,
|
|
30
|
+
UnusedSkipTokenInfiniteOptions,
|
|
31
|
+
} from './infiniteQueryOptions'
|
|
32
|
+
export {
|
|
33
|
+
QueryClientContext,
|
|
34
|
+
QueryClientProvider,
|
|
35
|
+
useQueryClient,
|
|
36
|
+
} from './QueryClientProvider'
|
|
37
|
+
export type { QueryClientProviderProps } from './QueryClientProvider'
|
|
38
|
+
export type { QueryErrorResetBoundaryProps } from './QueryErrorResetBoundary'
|
|
39
|
+
export { HydrationBoundary } from './HydrationBoundary'
|
|
40
|
+
export type { HydrationBoundaryProps } from './HydrationBoundary'
|
|
41
|
+
export type {
|
|
42
|
+
QueryErrorClearResetFunction,
|
|
43
|
+
QueryErrorIsResetFunction,
|
|
44
|
+
QueryErrorResetBoundaryFunction,
|
|
45
|
+
QueryErrorResetFunction,
|
|
46
|
+
} from './QueryErrorResetBoundary'
|
|
47
|
+
export {
|
|
48
|
+
QueryErrorResetBoundary,
|
|
49
|
+
useQueryErrorResetBoundary,
|
|
50
|
+
} from './QueryErrorResetBoundary'
|
|
51
|
+
export { useIsFetching } from './useIsFetching'
|
|
52
|
+
export { useIsMutating, useMutationState } from './useMutationState'
|
|
53
|
+
export { useMutation } from './useMutation'
|
|
54
|
+
export { mutationOptions } from './mutationOptions'
|
|
55
|
+
export { useInfiniteQuery } from './useInfiniteQuery'
|
|
56
|
+
export { useIsRestoring, IsRestoringProvider } from './IsRestoringProvider'
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DataTag,
|
|
3
|
+
DefaultError,
|
|
4
|
+
InfiniteData,
|
|
5
|
+
InitialDataFunction,
|
|
6
|
+
NonUndefinedGuard,
|
|
7
|
+
OmitKeyof,
|
|
8
|
+
QueryKey,
|
|
9
|
+
SkipToken,
|
|
10
|
+
} from '@tanstack/query-core'
|
|
11
|
+
|
|
12
|
+
import type { UseInfiniteQueryOptions } from './types'
|
|
13
|
+
|
|
14
|
+
export type UndefinedInitialDataInfiniteOptions<
|
|
15
|
+
TQueryFnData,
|
|
16
|
+
TError = DefaultError,
|
|
17
|
+
TData = InfiniteData<TQueryFnData>,
|
|
18
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
19
|
+
TPageParam = unknown,
|
|
20
|
+
> = UseInfiniteQueryOptions<
|
|
21
|
+
TQueryFnData,
|
|
22
|
+
TError,
|
|
23
|
+
TData,
|
|
24
|
+
TQueryKey,
|
|
25
|
+
TPageParam
|
|
26
|
+
> & {
|
|
27
|
+
initialData?:
|
|
28
|
+
| undefined
|
|
29
|
+
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
30
|
+
| InitialDataFunction<
|
|
31
|
+
NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
32
|
+
>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type UnusedSkipTokenInfiniteOptions<
|
|
36
|
+
TQueryFnData,
|
|
37
|
+
TError = DefaultError,
|
|
38
|
+
TData = InfiniteData<TQueryFnData>,
|
|
39
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
40
|
+
TPageParam = unknown,
|
|
41
|
+
> = OmitKeyof<
|
|
42
|
+
UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
43
|
+
'queryFn'
|
|
44
|
+
> & {
|
|
45
|
+
queryFn?: Exclude<
|
|
46
|
+
UseInfiniteQueryOptions<
|
|
47
|
+
TQueryFnData,
|
|
48
|
+
TError,
|
|
49
|
+
TData,
|
|
50
|
+
TQueryKey,
|
|
51
|
+
TPageParam
|
|
52
|
+
>['queryFn'],
|
|
53
|
+
SkipToken | undefined
|
|
54
|
+
>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type DefinedInitialDataInfiniteOptions<
|
|
58
|
+
TQueryFnData,
|
|
59
|
+
TError = DefaultError,
|
|
60
|
+
TData = InfiniteData<TQueryFnData>,
|
|
61
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
62
|
+
TPageParam = unknown,
|
|
63
|
+
> = UseInfiniteQueryOptions<
|
|
64
|
+
TQueryFnData,
|
|
65
|
+
TError,
|
|
66
|
+
TData,
|
|
67
|
+
TQueryKey,
|
|
68
|
+
TPageParam
|
|
69
|
+
> & {
|
|
70
|
+
initialData:
|
|
71
|
+
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
72
|
+
| (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
|
|
73
|
+
| undefined
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function infiniteQueryOptions<
|
|
77
|
+
TQueryFnData,
|
|
78
|
+
TError = DefaultError,
|
|
79
|
+
TData = InfiniteData<TQueryFnData>,
|
|
80
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
81
|
+
TPageParam = unknown,
|
|
82
|
+
>(
|
|
83
|
+
options: DefinedInitialDataInfiniteOptions<
|
|
84
|
+
TQueryFnData,
|
|
85
|
+
TError,
|
|
86
|
+
TData,
|
|
87
|
+
TQueryKey,
|
|
88
|
+
TPageParam
|
|
89
|
+
>,
|
|
90
|
+
): DefinedInitialDataInfiniteOptions<
|
|
91
|
+
TQueryFnData,
|
|
92
|
+
TError,
|
|
93
|
+
TData,
|
|
94
|
+
TQueryKey,
|
|
95
|
+
TPageParam
|
|
96
|
+
> & {
|
|
97
|
+
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function infiniteQueryOptions<
|
|
101
|
+
TQueryFnData,
|
|
102
|
+
TError = DefaultError,
|
|
103
|
+
TData = InfiniteData<TQueryFnData>,
|
|
104
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
105
|
+
TPageParam = unknown,
|
|
106
|
+
>(
|
|
107
|
+
options: UnusedSkipTokenInfiniteOptions<
|
|
108
|
+
TQueryFnData,
|
|
109
|
+
TError,
|
|
110
|
+
TData,
|
|
111
|
+
TQueryKey,
|
|
112
|
+
TPageParam
|
|
113
|
+
>,
|
|
114
|
+
): UnusedSkipTokenInfiniteOptions<
|
|
115
|
+
TQueryFnData,
|
|
116
|
+
TError,
|
|
117
|
+
TData,
|
|
118
|
+
TQueryKey,
|
|
119
|
+
TPageParam
|
|
120
|
+
> & {
|
|
121
|
+
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function infiniteQueryOptions<
|
|
125
|
+
TQueryFnData,
|
|
126
|
+
TError = DefaultError,
|
|
127
|
+
TData = InfiniteData<TQueryFnData>,
|
|
128
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
129
|
+
TPageParam = unknown,
|
|
130
|
+
>(
|
|
131
|
+
options: UndefinedInitialDataInfiniteOptions<
|
|
132
|
+
TQueryFnData,
|
|
133
|
+
TError,
|
|
134
|
+
TData,
|
|
135
|
+
TQueryKey,
|
|
136
|
+
TPageParam
|
|
137
|
+
>,
|
|
138
|
+
): UndefinedInitialDataInfiniteOptions<
|
|
139
|
+
TQueryFnData,
|
|
140
|
+
TError,
|
|
141
|
+
TData,
|
|
142
|
+
TQueryKey,
|
|
143
|
+
TPageParam
|
|
144
|
+
> & {
|
|
145
|
+
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function infiniteQueryOptions(options: unknown) {
|
|
149
|
+
return options
|
|
150
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DefaultError, WithRequired } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import type { UseMutationOptions } from './types'
|
|
4
|
+
|
|
5
|
+
export function mutationOptions<
|
|
6
|
+
TData = unknown,
|
|
7
|
+
TError = DefaultError,
|
|
8
|
+
TVariables = void,
|
|
9
|
+
TOnMutateResult = unknown,
|
|
10
|
+
>(
|
|
11
|
+
options: WithRequired<
|
|
12
|
+
UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
13
|
+
'mutationKey'
|
|
14
|
+
>,
|
|
15
|
+
): WithRequired<
|
|
16
|
+
UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
17
|
+
'mutationKey'
|
|
18
|
+
>
|
|
19
|
+
export function mutationOptions<
|
|
20
|
+
TData = unknown,
|
|
21
|
+
TError = DefaultError,
|
|
22
|
+
TVariables = void,
|
|
23
|
+
TOnMutateResult = unknown,
|
|
24
|
+
>(
|
|
25
|
+
options: Omit<
|
|
26
|
+
UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
27
|
+
'mutationKey'
|
|
28
|
+
>,
|
|
29
|
+
): Omit<
|
|
30
|
+
UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
31
|
+
'mutationKey'
|
|
32
|
+
>
|
|
33
|
+
export function mutationOptions<
|
|
34
|
+
TData = unknown,
|
|
35
|
+
TError = DefaultError,
|
|
36
|
+
TVariables = void,
|
|
37
|
+
TOnMutateResult = unknown,
|
|
38
|
+
>(
|
|
39
|
+
options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,
|
|
40
|
+
): UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
41
|
+
return options
|
|
42
|
+
}
|