@suspensive/react-query-4 2.17.1 → 2.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OmitKeyof-CFsZLI4k.d.cts +3 -0
- package/dist/OmitKeyof-CFsZLI4k.d.ts +3 -0
- package/dist/QueryClientConsumer.cjs.map +1 -1
- package/dist/QueryClientConsumer.d.cts +2 -2
- package/dist/QueryClientConsumer.d.ts +2 -2
- package/dist/QueryClientConsumer.js +1 -1
- package/dist/QueryErrorBoundary.d.cts +1 -2
- package/dist/QueryErrorBoundary.d.ts +1 -2
- package/dist/RequiredKeyof-CHKtWddC.d.cts +5 -0
- package/dist/RequiredKeyof-CHKtWddC.d.ts +5 -0
- package/dist/SuspenseInfiniteQuery.cjs.map +1 -1
- package/dist/SuspenseInfiniteQuery.d.cts +1 -1
- package/dist/SuspenseInfiniteQuery.d.ts +1 -1
- package/dist/SuspenseInfiniteQuery.js +2 -2
- package/dist/SuspenseQueries.d.cts +1 -1
- package/dist/SuspenseQueries.d.ts +1 -1
- package/dist/SuspenseQuery.cjs.map +1 -1
- package/dist/SuspenseQuery.d.cts +1 -1
- package/dist/SuspenseQuery.d.ts +1 -1
- package/dist/SuspenseQuery.js +2 -2
- package/dist/{chunk-BCBH6GA5.js → chunk-6XT2ZR45.js} +1 -1
- package/dist/chunk-6XT2ZR45.js.map +1 -0
- package/dist/{chunk-W3SOIIM5.js → chunk-7W5RLGLW.js} +1 -1
- package/dist/chunk-7W5RLGLW.js.map +1 -0
- package/dist/{chunk-Q4KHEUPO.js → chunk-IJZNOFTF.js} +1 -1
- package/dist/chunk-IJZNOFTF.js.map +1 -0
- package/dist/{chunk-KUEXE4AF.js → chunk-QAYUXNHC.js} +1 -1
- package/dist/chunk-QAYUXNHC.js.map +1 -0
- package/dist/{chunk-4AU4A5TK.js → chunk-QZMJUP74.js} +2 -2
- package/dist/{chunk-7LC5EH5R.js → chunk-UX5DVBYP.js} +2 -2
- package/dist/{chunk-NKKRZH3C.js → chunk-XZJPNI2I.js} +1 -1
- package/dist/chunk-XZJPNI2I.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -7
- package/dist/infiniteQueryOptions.cjs.map +1 -1
- package/dist/infiniteQueryOptions.d.cts +2 -1
- package/dist/infiniteQueryOptions.d.ts +2 -1
- package/dist/infiniteQueryOptions.js +1 -1
- package/dist/queryOptions.cjs.map +1 -1
- package/dist/queryOptions.d.cts +2 -1
- package/dist/queryOptions.d.ts +2 -1
- package/dist/queryOptions.js +1 -1
- package/dist/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/dist/useSuspenseInfiniteQuery.d.cts +2 -3
- package/dist/useSuspenseInfiniteQuery.d.ts +2 -3
- package/dist/useSuspenseInfiniteQuery.js +1 -1
- package/dist/useSuspenseQueries.d.cts +1 -1
- package/dist/useSuspenseQueries.d.ts +1 -1
- package/dist/useSuspenseQuery.cjs.map +1 -1
- package/dist/useSuspenseQuery.d.cts +2 -3
- package/dist/useSuspenseQuery.d.ts +2 -3
- package/dist/useSuspenseQuery.js +1 -1
- package/package.json +4 -7
- package/src/PrefetchInfiniteQuery.test-d.tsx +1 -1
- package/src/PrefetchQuery.test-d.tsx +1 -1
- package/src/QueryClientConsumer.tsx +2 -2
- package/src/SuspenseInfiniteQuery.test-d.tsx +1 -1
- package/src/SuspenseQueries.test-d.tsx +1 -1
- package/src/SuspenseQuery.test-d.tsx +1 -1
- package/src/infiniteQueryOptions.test-d.tsx +1 -1
- package/src/infiniteQueryOptions.ts +1 -1
- package/src/queryOptions.test-d.tsx +1 -1
- package/src/queryOptions.ts +1 -1
- package/src/test-utils/index.ts +4 -0
- package/src/useSuspenseInfiniteQuery.test-d.ts +1 -1
- package/src/useSuspenseInfiniteQuery.ts +6 -6
- package/src/useSuspenseQueries.test-d.ts +1 -1
- package/src/useSuspenseQuery.test-d.ts +1 -1
- package/src/useSuspenseQuery.ts +6 -6
- package/src/utility-types/OmitKeyof.test-d.ts +175 -0
- package/src/utility-types/OmitKeyof.ts +11 -0
- package/src/utility-types/RequiredKeyof.ts +3 -0
- package/src/utility-types/index.ts +2 -0
- package/dist/chunk-BCBH6GA5.js.map +0 -1
- package/dist/chunk-KUEXE4AF.js.map +0 -1
- package/dist/chunk-NKKRZH3C.js.map +0 -1
- package/dist/chunk-Q4KHEUPO.js.map +0 -1
- package/dist/chunk-W3SOIIM5.js.map +0 -1
- /package/dist/{chunk-4AU4A5TK.js.map → chunk-QZMJUP74.js.map} +0 -0
- /package/dist/{chunk-7LC5EH5R.js.map → chunk-UX5DVBYP.js.map} +0 -0
package/dist/queryOptions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { RequiredKeyof, OmitKeyof } from '@suspensive/utils';
|
|
2
1
|
import { QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { O as OmitKeyof } from './OmitKeyof-CFsZLI4k.js';
|
|
3
|
+
import { R as RequiredKeyof } from './RequiredKeyof-CHKtWddC.js';
|
|
3
4
|
|
|
4
5
|
type SelectedQueryOptions<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = RequiredKeyof<OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'getNextPageParam' | 'getPreviousPageParam' | 'queryKeyHashFn' | '_defaulted' | 'behavior' | 'structuralSharing' | 'isDataEqual' | 'onSuccess' | 'onError' | 'onSettled' | 'enabled' | 'refetchInterval' | 'initialData'>, 'queryKey' | 'queryFn'> & {
|
|
5
6
|
select: (data: TQueryFnData) => TData;
|
package/dist/queryOptions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useSuspenseInfiniteQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/useSuspenseInfiniteQuery.ts"],"sourcesContent":["import {\n type InfiniteData,\n type QueryKey,\n type UseInfiniteQueryOptions,\n type UseInfiniteQueryResult,\n useInfiniteQuery,\n} from '@tanstack/react-query'\nimport type { OmitKeyof } from './utility-types'\n\nexport interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknown>\n extends OmitKeyof<\n UseInfiniteQueryResult<TData, TError>,\n keyof Pick<UseInfiniteQueryResult<TData, TError>, 'isPlaceholderData'>\n > {\n data: InfiniteData<TData>\n status: 'success'\n}\n\nexport type UseSuspenseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'\n>\n\n/**\n * This hook is wrapping useInfiniteQuery of `@tanstack/react-query` v4 with default suspense option.\n * @see {@link https://suspensive.org/docs/react-query/useSuspenseInfiniteQuery}\n */\nexport function useSuspenseInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n): UseSuspenseInfiniteQueryResult<TData, TError> {\n return useInfiniteQuery({\n ...options,\n enabled: true,\n suspense: true,\n useErrorBoundary: true,\n }) as UseSuspenseInfiniteQueryResult<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAMO;AA0BA,SAAS,yBAMd,SAC+C;AAC/C,aAAO,qCAAiB,iCACnB,UADmB;AAAA,IAEtB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,kBAAkB;AAAA,EACpB,EAAC;AACH;","names":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OmitKeyof } from '@suspensive/utils';
|
|
2
1
|
import { UseInfiniteQueryResult, InfiniteData, QueryKey, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { O as OmitKeyof } from './OmitKeyof-CFsZLI4k.cjs';
|
|
3
3
|
|
|
4
4
|
interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknown> extends OmitKeyof<UseInfiniteQueryResult<TData, TError>, keyof Pick<UseInfiniteQueryResult<TData, TError>, 'isPlaceholderData'>> {
|
|
5
5
|
data: InfiniteData<TData>;
|
|
6
6
|
status: 'success';
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
type UseSuspenseInfiniteQueryOptions<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'>;
|
|
10
9
|
/**
|
|
11
10
|
* This hook is wrapping useInfiniteQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
12
11
|
* @see {@link https://suspensive.org/docs/react-query/useSuspenseInfiniteQuery}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OmitKeyof } from '@suspensive/utils';
|
|
2
1
|
import { UseInfiniteQueryResult, InfiniteData, QueryKey, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { O as OmitKeyof } from './OmitKeyof-CFsZLI4k.js';
|
|
3
3
|
|
|
4
4
|
interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknown> extends OmitKeyof<UseInfiniteQueryResult<TData, TError>, keyof Pick<UseInfiniteQueryResult<TData, TError>, 'isPlaceholderData'>> {
|
|
5
5
|
data: InfiniteData<TData>;
|
|
6
6
|
status: 'success';
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
type UseSuspenseInfiniteQueryOptions<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'>;
|
|
10
9
|
/**
|
|
11
10
|
* This hook is wrapping useInfiniteQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
12
11
|
* @see {@link https://suspensive.org/docs/react-query/useSuspenseInfiniteQuery}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseQueryOptions, QueryFunction } from '@tanstack/react-query';
|
|
2
2
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './useSuspenseQuery.cjs';
|
|
3
|
-
import '
|
|
3
|
+
import './OmitKeyof-CFsZLI4k.cjs';
|
|
4
4
|
|
|
5
5
|
type MAXIMUM_DEPTH = 20;
|
|
6
6
|
type GetSuspenseOptions<T> = T extends {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseQueryOptions, QueryFunction } from '@tanstack/react-query';
|
|
2
2
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './useSuspenseQuery.js';
|
|
3
|
-
import '
|
|
3
|
+
import './OmitKeyof-CFsZLI4k.js';
|
|
4
4
|
|
|
5
5
|
type MAXIMUM_DEPTH = 20;
|
|
6
6
|
type GetSuspenseOptions<T> = T extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":["import { type QueryKey, type UseQueryOptions, type UseQueryResult, useQuery } from '@tanstack/react-query'\nimport type { OmitKeyof } from './utility-types'\n\nexport interface UseSuspenseQueryResult<TData = unknown, TError = unknown>\n extends OmitKeyof<UseQueryResult<TData, TError>, keyof Pick<UseQueryResult, 'isPlaceholderData'>> {\n data: TData\n status: 'success'\n}\n\nexport type UseSuspenseQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'\n>\n\n/**\n * This hook is wrapping useQuery of `@tanstack/react-query` v4 with default suspense option.\n * @see {@link https://suspensive.org/docs/react-query/useSuspenseQuery}\n */\nexport function useSuspenseQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n return useQuery<TQueryFnData, TError, TData, TQueryKey>({\n ...options,\n enabled: true,\n useErrorBoundary: true,\n suspense: true,\n }) as UseSuspenseQueryResult<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmF;AAuB5E,SAAS,iBAKd,SAA0E;AAC1E,aAAO,6BAAiD,iCACnD,UADmD;AAAA,IAEtD,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,UAAU;AAAA,EACZ,EAAC;AACH;","names":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OmitKeyof } from '@suspensive/utils';
|
|
2
1
|
import { UseQueryResult, QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { O as OmitKeyof } from './OmitKeyof-CFsZLI4k.cjs';
|
|
3
3
|
|
|
4
4
|
interface UseSuspenseQueryResult<TData = unknown, TError = unknown> extends OmitKeyof<UseQueryResult<TData, TError>, keyof Pick<UseQueryResult, 'isPlaceholderData'>> {
|
|
5
5
|
data: TData;
|
|
6
6
|
status: 'success';
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
type UseSuspenseQueryOptions<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'>;
|
|
10
9
|
/**
|
|
11
10
|
* This hook is wrapping useQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
12
11
|
* @see {@link https://suspensive.org/docs/react-query/useSuspenseQuery}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OmitKeyof } from '@suspensive/utils';
|
|
2
1
|
import { UseQueryResult, QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { O as OmitKeyof } from './OmitKeyof-CFsZLI4k.js';
|
|
3
3
|
|
|
4
4
|
interface UseSuspenseQueryResult<TData = unknown, TError = unknown> extends OmitKeyof<UseQueryResult<TData, TError>, keyof Pick<UseQueryResult, 'isPlaceholderData'>> {
|
|
5
5
|
data: TData;
|
|
6
6
|
status: 'success';
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
type UseSuspenseQueryOptions<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'>;
|
|
10
9
|
/**
|
|
11
10
|
* This hook is wrapping useQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
12
11
|
* @see {@link https://suspensive.org/docs/react-query/useSuspenseQuery}
|
package/dist/useSuspenseQuery.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suspensive/react-query-4",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.3",
|
|
4
4
|
"description": "Suspensive interfaces for @tanstack/react-query@4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suspensive",
|
|
@@ -38,20 +38,17 @@
|
|
|
38
38
|
"dist",
|
|
39
39
|
"src"
|
|
40
40
|
],
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@suspensive/utils": "2.17.1"
|
|
43
|
-
},
|
|
44
41
|
"devDependencies": {
|
|
45
42
|
"@tanstack/react-query": "^4.36.1",
|
|
46
|
-
"@types/react": "^18.3.
|
|
43
|
+
"@types/react": "^18.3.10",
|
|
47
44
|
"react": "^18.3.1",
|
|
48
45
|
"@suspensive/eslint-config": "0.0.0",
|
|
49
|
-
"@suspensive/react": "2.17.
|
|
46
|
+
"@suspensive/react": "2.17.3",
|
|
50
47
|
"@suspensive/tsconfig": "0.0.0-development",
|
|
51
48
|
"@suspensive/tsup": "0.0.0"
|
|
52
49
|
},
|
|
53
50
|
"peerDependencies": {
|
|
54
|
-
"@suspensive/react": "^2.17.
|
|
51
|
+
"@suspensive/react": "^2.17.3",
|
|
55
52
|
"@tanstack/react-query": "^4",
|
|
56
53
|
"react": "^18"
|
|
57
54
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { ReactNode } from 'react'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
5
4
|
import { PrefetchInfiniteQuery } from './PrefetchInfiniteQuery'
|
|
5
|
+
import { queryFn, queryKey } from './test-utils'
|
|
6
6
|
|
|
7
7
|
describe('<PrefetchInfiniteQuery/>', () => {
|
|
8
8
|
it('type check', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { ReactNode } from 'react'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { PrefetchQuery } from './PrefetchQuery'
|
|
5
4
|
import { queryOptions } from './queryOptions'
|
|
5
|
+
import { queryFn, queryKey } from './test-utils'
|
|
6
6
|
|
|
7
7
|
describe('<PrefetchQuery/>', () => {
|
|
8
8
|
it('type check', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type QueryClient, useQueryClient } from '@tanstack/react-query'
|
|
2
|
-
import type { ReactNode } from 'react'
|
|
2
|
+
import type { Context, ReactNode } from 'react'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @experimental This is experimental feature.
|
|
@@ -9,7 +9,7 @@ export function QueryClientConsumer({
|
|
|
9
9
|
context,
|
|
10
10
|
}: {
|
|
11
11
|
children: (queryClient: QueryClient) => ReactNode
|
|
12
|
-
context?:
|
|
12
|
+
context?: Context<QueryClient | undefined>
|
|
13
13
|
}) {
|
|
14
14
|
return <>{children(useQueryClient({ context }))}</>
|
|
15
15
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { InfiniteData } from '@tanstack/react-query'
|
|
3
2
|
import type { ReactNode } from 'react'
|
|
4
3
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
5
4
|
import { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
6
5
|
import { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery'
|
|
6
|
+
import { queryFn, queryKey } from './test-utils'
|
|
7
7
|
import type { UseSuspenseInfiniteQueryResult } from './useSuspenseInfiniteQuery'
|
|
8
8
|
|
|
9
9
|
describe('<SuspenseInfiniteQuery/>', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { ReactNode } from 'react'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { queryOptions } from './queryOptions'
|
|
5
4
|
import { SuspenseQueries } from './SuspenseQueries'
|
|
5
|
+
import { queryFn, queryKey } from './test-utils'
|
|
6
6
|
import type { UseSuspenseQueryResult } from './useSuspenseQuery'
|
|
7
7
|
|
|
8
8
|
describe('<SuspenseQueries/>', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { ReactNode } from 'react'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { queryOptions } from './queryOptions'
|
|
5
4
|
import { SuspenseQuery } from './SuspenseQuery'
|
|
5
|
+
import { queryFn, queryKey } from './test-utils'
|
|
6
6
|
import type { UseSuspenseQueryResult } from './useSuspenseQuery'
|
|
7
7
|
|
|
8
8
|
describe('<SuspenseQuery/>', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryKey } from '@suspensive/utils'
|
|
2
1
|
import { type InfiniteData, type UseInfiniteQueryResult, useInfiniteQuery, useQueryClient } from '@tanstack/react-query'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
5
4
|
import { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery'
|
|
5
|
+
import { queryKey } from './test-utils'
|
|
6
6
|
import { usePrefetchInfiniteQuery } from './usePrefetchInfiniteQuery'
|
|
7
7
|
import { type UseSuspenseInfiniteQueryResult, useSuspenseInfiniteQuery } from './useSuspenseInfiniteQuery'
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OmitKeyof, RequiredKeyof } from '@suspensive/utils'
|
|
2
1
|
import type { InfiniteData, QueryKey, UseInfiniteQueryOptions } from '@tanstack/react-query'
|
|
2
|
+
import type { OmitKeyof, RequiredKeyof } from './utility-types'
|
|
3
3
|
|
|
4
4
|
export type SelectedInfiniteOptions<
|
|
5
5
|
TQueryFnData,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queryKey } from '@suspensive/utils'
|
|
2
1
|
import { type UseQueryResult, useQueries, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
3
2
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
4
3
|
import { queryOptions } from './queryOptions'
|
|
5
4
|
import { SuspenseQuery } from './SuspenseQuery'
|
|
5
|
+
import { queryKey } from './test-utils'
|
|
6
6
|
import { usePrefetchQuery } from './usePrefetchQuery'
|
|
7
7
|
import { useSuspenseQueries } from './useSuspenseQueries'
|
|
8
8
|
import { type UseSuspenseQueryResult, useSuspenseQuery } from './useSuspenseQuery'
|
package/src/queryOptions.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const queryKey = ['key'] as const
|
|
2
|
+
const sleep = (ms: number) => new Promise<undefined>((resolve) => setTimeout(() => resolve(undefined), ms))
|
|
3
|
+
export const queryFn = () => sleep(10).then(() => ({ text: 'response' }))
|
|
4
|
+
export const select = (data: Awaited<ReturnType<typeof queryFn>>) => data.text
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import type { InfiniteData } from '@tanstack/react-query'
|
|
3
2
|
import { infiniteQueryOptions } from './infiniteQueryOptions'
|
|
3
|
+
import { queryFn, queryKey } from './test-utils'
|
|
4
4
|
import { type UseSuspenseInfiniteQueryResult, useSuspenseInfiniteQuery } from './useSuspenseInfiniteQuery'
|
|
5
5
|
|
|
6
6
|
describe('useSuspenseInfiniteQuery', () => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OmitKeyof } from '@suspensive/utils'
|
|
2
1
|
import {
|
|
3
2
|
type InfiniteData,
|
|
4
3
|
type QueryKey,
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
type UseInfiniteQueryResult,
|
|
7
6
|
useInfiniteQuery,
|
|
8
7
|
} from '@tanstack/react-query'
|
|
8
|
+
import type { OmitKeyof } from './utility-types'
|
|
9
9
|
|
|
10
10
|
export interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknown>
|
|
11
11
|
extends OmitKeyof<
|
|
@@ -16,15 +16,15 @@ export interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknow
|
|
|
16
16
|
status: 'success'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export type UseSuspenseInfiniteQueryOptions<
|
|
20
20
|
TQueryFnData = unknown,
|
|
21
21
|
TError = unknown,
|
|
22
22
|
TData = TQueryFnData,
|
|
23
23
|
TQueryKey extends QueryKey = QueryKey,
|
|
24
|
-
>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
> = OmitKeyof<
|
|
25
|
+
UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,
|
|
26
|
+
'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'
|
|
27
|
+
>
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* This hook is wrapping useInfiniteQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { queryFn, queryKey, select } from '@suspensive/utils'
|
|
2
1
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
3
2
|
import { queryOptions } from './queryOptions'
|
|
3
|
+
import { queryFn, queryKey, select } from './test-utils'
|
|
4
4
|
import { useSuspenseQueries } from './useSuspenseQueries'
|
|
5
5
|
import type { UseSuspenseQueryResult } from './useSuspenseQuery'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { queryFn, queryKey } from '@suspensive/utils'
|
|
2
1
|
import { describe, expectTypeOf, it } from 'vitest'
|
|
3
2
|
import { queryOptions } from './queryOptions'
|
|
3
|
+
import { queryFn, queryKey } from './test-utils'
|
|
4
4
|
import { type UseSuspenseQueryResult, useSuspenseQuery } from './useSuspenseQuery'
|
|
5
5
|
|
|
6
6
|
describe('useSuspenseQuery', () => {
|
package/src/useSuspenseQuery.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OmitKeyof } from '@suspensive/utils'
|
|
2
1
|
import { type QueryKey, type UseQueryOptions, type UseQueryResult, useQuery } from '@tanstack/react-query'
|
|
2
|
+
import type { OmitKeyof } from './utility-types'
|
|
3
3
|
|
|
4
4
|
export interface UseSuspenseQueryResult<TData = unknown, TError = unknown>
|
|
5
5
|
extends OmitKeyof<UseQueryResult<TData, TError>, keyof Pick<UseQueryResult, 'isPlaceholderData'>> {
|
|
@@ -7,15 +7,15 @@ export interface UseSuspenseQueryResult<TData = unknown, TError = unknown>
|
|
|
7
7
|
status: 'success'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export type UseSuspenseQueryOptions<
|
|
11
11
|
TQueryFnData = unknown,
|
|
12
12
|
TError = unknown,
|
|
13
13
|
TData = TQueryFnData,
|
|
14
14
|
TQueryKey extends QueryKey = QueryKey,
|
|
15
|
-
>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
> = OmitKeyof<
|
|
16
|
+
UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
17
|
+
'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'
|
|
18
|
+
>
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* This hook is wrapping useQuery of `@tanstack/react-query` v4 with default suspense option.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { OmitKeyof } from './OmitKeyof'
|
|
2
|
+
|
|
3
|
+
describe('OmitKeyof', () => {
|
|
4
|
+
it("'s string key type check", () => {
|
|
5
|
+
type A = {
|
|
6
|
+
x: string
|
|
7
|
+
y: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ExpectedType = {
|
|
11
|
+
x: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Bad point
|
|
15
|
+
// 1. original Omit can use 'z' as type parameter with no type error
|
|
16
|
+
// 2. original Omit have no auto complete for 2nd type parameter
|
|
17
|
+
expectTypeOf<Omit<A, 'z' | 'y'>>().toEqualTypeOf<ExpectedType>()
|
|
18
|
+
|
|
19
|
+
// Solution
|
|
20
|
+
|
|
21
|
+
// 1. strictly
|
|
22
|
+
expectTypeOf<
|
|
23
|
+
OmitKeyof<
|
|
24
|
+
A,
|
|
25
|
+
// OmitKeyof can't use 'z' as type parameter with type error because A don't have key 'z'
|
|
26
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
27
|
+
'z' | 'y'
|
|
28
|
+
>
|
|
29
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
30
|
+
expectTypeOf<
|
|
31
|
+
OmitKeyof<
|
|
32
|
+
A,
|
|
33
|
+
// OmitKeyof can't use 'z' as type parameter with type error because A don't have key 'z'
|
|
34
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
35
|
+
'z' | 'y',
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
|
|
37
|
+
'strictly'
|
|
38
|
+
>
|
|
39
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
40
|
+
|
|
41
|
+
// 2. safely
|
|
42
|
+
expectTypeOf<
|
|
43
|
+
OmitKeyof<
|
|
44
|
+
A,
|
|
45
|
+
// OmitKeyof can't use 'z' as type parameter type error with strictly parameter or default parameter
|
|
46
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
47
|
+
'z' | 'y'
|
|
48
|
+
>
|
|
49
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
50
|
+
expectTypeOf<
|
|
51
|
+
OmitKeyof<
|
|
52
|
+
A,
|
|
53
|
+
// With 'safely', OmitKeyof can use 'z' as type parameter like original Omit but This support autocomplete too yet for DX.
|
|
54
|
+
'z' | 'y',
|
|
55
|
+
'safely'
|
|
56
|
+
>
|
|
57
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it("'s number key type check", () => {
|
|
61
|
+
type A = {
|
|
62
|
+
[1]: string
|
|
63
|
+
[2]: number
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type ExpectedType = {
|
|
67
|
+
[1]: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Bad point
|
|
71
|
+
// 1. original Omit can use 3 as type parameter with no type error
|
|
72
|
+
// 2. original Omit have no auto complete for 2nd type parameter
|
|
73
|
+
expectTypeOf<Omit<A, 3 | 2>>().toEqualTypeOf<ExpectedType>()
|
|
74
|
+
|
|
75
|
+
// Solution
|
|
76
|
+
|
|
77
|
+
// 1. strictly
|
|
78
|
+
expectTypeOf<
|
|
79
|
+
OmitKeyof<
|
|
80
|
+
A,
|
|
81
|
+
// OmitKeyof can't use 3 as type parameter with type error because A don't have key 3
|
|
82
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
83
|
+
3 | 2
|
|
84
|
+
>
|
|
85
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
86
|
+
expectTypeOf<
|
|
87
|
+
OmitKeyof<
|
|
88
|
+
A,
|
|
89
|
+
// OmitKeyof can't use 3 as type parameter with type error because A don't have key 3
|
|
90
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
91
|
+
3 | 2,
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
|
|
93
|
+
'strictly'
|
|
94
|
+
>
|
|
95
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
96
|
+
|
|
97
|
+
// 2. safely
|
|
98
|
+
expectTypeOf<
|
|
99
|
+
OmitKeyof<
|
|
100
|
+
A,
|
|
101
|
+
// OmitKeyof can't use 3 as type parameter type error with strictly parameter or default parameter
|
|
102
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
103
|
+
3 | 2
|
|
104
|
+
>
|
|
105
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
106
|
+
expectTypeOf<
|
|
107
|
+
OmitKeyof<
|
|
108
|
+
A,
|
|
109
|
+
// With 'safely', OmitKeyof can use 3 as type parameter like original Omit but This support autocomplete too yet for DX.
|
|
110
|
+
3 | 2,
|
|
111
|
+
'safely'
|
|
112
|
+
>
|
|
113
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it("'s symbol key type check", () => {
|
|
117
|
+
const symbol1 = Symbol()
|
|
118
|
+
const symbol2 = Symbol()
|
|
119
|
+
const symbol3 = Symbol()
|
|
120
|
+
|
|
121
|
+
type A = {
|
|
122
|
+
[symbol1]: string
|
|
123
|
+
[symbol2]: number
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type ExpectedType = {
|
|
127
|
+
[symbol1]: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Bad point
|
|
131
|
+
// 1. original Omit can use symbol3 as type parameter with no type error
|
|
132
|
+
// 2. original Omit have no auto complete for 2nd type parameter
|
|
133
|
+
expectTypeOf<Omit<A, typeof symbol3 | typeof symbol2>>().toEqualTypeOf<ExpectedType>()
|
|
134
|
+
|
|
135
|
+
// Solution
|
|
136
|
+
|
|
137
|
+
// 1. strictly
|
|
138
|
+
expectTypeOf<
|
|
139
|
+
OmitKeyof<
|
|
140
|
+
A,
|
|
141
|
+
// OmitKeyof can't use symbol3 as type parameter with type error because A don't have key symbol3
|
|
142
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
143
|
+
typeof symbol3 | typeof symbol2
|
|
144
|
+
>
|
|
145
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
146
|
+
expectTypeOf<
|
|
147
|
+
OmitKeyof<
|
|
148
|
+
A,
|
|
149
|
+
// OmitKeyof can't use symbol3 as type parameter with type error because A don't have key symbol3
|
|
150
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
151
|
+
typeof symbol3 | typeof symbol2,
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
|
|
153
|
+
'strictly'
|
|
154
|
+
>
|
|
155
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
156
|
+
|
|
157
|
+
// 2. safely
|
|
158
|
+
expectTypeOf<
|
|
159
|
+
OmitKeyof<
|
|
160
|
+
A,
|
|
161
|
+
// OmitKeyof can't use symbol3 as type parameter type error with strictly parameter or default parameter
|
|
162
|
+
// @ts-expect-error Type does not satisfy the constraint keyof A
|
|
163
|
+
typeof symbol3 | typeof symbol2
|
|
164
|
+
>
|
|
165
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
166
|
+
expectTypeOf<
|
|
167
|
+
OmitKeyof<
|
|
168
|
+
A,
|
|
169
|
+
// With 'safely', OmitKeyof can use symbol3 as type parameter like original Omit but This support autocomplete too yet for DX.
|
|
170
|
+
typeof symbol3 | typeof symbol2,
|
|
171
|
+
'safely'
|
|
172
|
+
>
|
|
173
|
+
>().toEqualTypeOf<ExpectedType>()
|
|
174
|
+
})
|
|
175
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type OmitKeyof<
|
|
2
|
+
TObject,
|
|
3
|
+
TKey extends TStrictly extends 'safely'
|
|
4
|
+
?
|
|
5
|
+
| keyof TObject
|
|
6
|
+
| (string & Record<never, never>)
|
|
7
|
+
| (number & Record<never, never>)
|
|
8
|
+
| (symbol & Record<never, never>)
|
|
9
|
+
: keyof TObject,
|
|
10
|
+
TStrictly extends 'strictly' | 'safely' = 'strictly',
|
|
11
|
+
> = Omit<TObject, TKey>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/infiniteQueryOptions.ts"],"sourcesContent":["import type { OmitKeyof, RequiredKeyof } from '@suspensive/utils'\nimport type { InfiniteData, QueryKey, UseInfiniteQueryOptions } from '@tanstack/react-query'\n\nexport type SelectedInfiniteOptions<\n TQueryFnData,\n TError = unknown,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n> = RequiredKeyof<\n OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n | 'queryKeyHashFn'\n | '_defaulted'\n | 'behavior'\n | 'structuralSharing'\n | 'isDataEqual'\n | 'onSuccess'\n | 'onError'\n | 'onSettled'\n | 'enabled'\n | 'refetchInterval'\n | 'initialData'\n >,\n 'queryKey' | 'queryFn'\n> & {\n select: (data: InfiniteData<TQueryFnData>) => InfiniteData<TData>\n}\n\nexport type UnSelectedInfiniteOptions<\n TQueryFnData,\n TError = unknown,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n> = RequiredKeyof<\n OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n | 'queryKeyHashFn'\n | '_defaulted'\n | 'behavior'\n | 'structuralSharing'\n | 'isDataEqual'\n | 'onSuccess'\n | 'onError'\n | 'onSettled'\n | 'enabled'\n | 'refetchInterval'\n | 'initialData'\n >,\n 'queryKey' | 'queryFn'\n> & {\n select?: undefined\n}\n\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = unknown,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: SelectedInfiniteOptions<TQueryFnData, TError, TData, TQueryKey>\n): SelectedInfiniteOptions<TQueryFnData, TError, TData, TQueryKey>\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = unknown,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnSelectedInfiniteOptions<TQueryFnData, TError, TData, TQueryKey>\n): UnSelectedInfiniteOptions<TQueryFnData, TError, TData, TQueryKey>\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;;AAqEO,SAAS,qBAAqB,SAAkB;AACrD,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/QueryClientConsumer.tsx"],"sourcesContent":["import { type QueryClient, useQueryClient } from '@tanstack/react-query'\nimport type { ReactNode } from 'react'\n\n/**\n * @experimental This is experimental feature.\n */\nexport function QueryClientConsumer({\n children,\n context,\n}: {\n children: (queryClient: QueryClient) => ReactNode\n context?: React.Context<QueryClient | undefined>\n}) {\n return <>{children(useQueryClient({ context }))}</>\n}\n"],"mappings":";;;AAAA,SAA2B,sBAAsB;AAaxC;AAPF,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACD,SAAO,gCAAG,mBAAS,eAAe,EAAE,QAAQ,CAAC,CAAC,GAAE;AAClD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useSuspenseQuery.ts"],"sourcesContent":["import type { OmitKeyof } from '@suspensive/utils'\nimport { type QueryKey, type UseQueryOptions, type UseQueryResult, useQuery } from '@tanstack/react-query'\n\nexport interface UseSuspenseQueryResult<TData = unknown, TError = unknown>\n extends OmitKeyof<UseQueryResult<TData, TError>, keyof Pick<UseQueryResult, 'isPlaceholderData'>> {\n data: TData\n status: 'success'\n}\n\nexport interface UseSuspenseQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'\n > {}\n\n/**\n * This hook is wrapping useQuery of `@tanstack/react-query` v4 with default suspense option.\n * @see {@link https://suspensive.org/docs/react-query/useSuspenseQuery}\n */\nexport function useSuspenseQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n return useQuery<TQueryFnData, TError, TData, TQueryKey>({\n ...options,\n enabled: true,\n useErrorBoundary: true,\n suspense: true,\n }) as UseSuspenseQueryResult<TData, TError>\n}\n"],"mappings":";;;;;;;AACA,SAAmE,gBAAgB;AAsB5E,SAAS,iBAKd,SAA0E;AAC1E,SAAO,SAAiD,iCACnD,UADmD;AAAA,IAEtD,SAAS;AAAA,IACT,kBAAkB;AAAA,IAClB,UAAU;AAAA,EACZ,EAAC;AACH;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/queryOptions.ts"],"sourcesContent":["import type { OmitKeyof, RequiredKeyof } from '@suspensive/utils'\nimport type { QueryKey, UseQueryOptions } from '@tanstack/react-query'\n\nexport type SelectedQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = RequiredKeyof<\n OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n | 'getNextPageParam'\n | 'getPreviousPageParam'\n | 'queryKeyHashFn'\n | '_defaulted'\n | 'behavior'\n | 'structuralSharing'\n | 'isDataEqual'\n | 'onSuccess'\n | 'onError'\n | 'onSettled'\n | 'enabled'\n | 'refetchInterval'\n | 'initialData'\n >,\n 'queryKey' | 'queryFn'\n> & {\n select: (data: TQueryFnData) => TData\n}\n\nexport type UnSelectedQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = RequiredKeyof<\n OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n | 'getNextPageParam'\n | 'getPreviousPageParam'\n | 'queryKeyHashFn'\n | '_defaulted'\n | 'behavior'\n | 'structuralSharing'\n | 'isDataEqual'\n | 'onSuccess'\n | 'onError'\n | 'onSettled'\n | 'enabled'\n | 'refetchInterval'\n | 'initialData'\n >,\n 'queryKey' | 'queryFn'\n> & {\n select?: undefined\n}\n\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: SelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n): SelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnSelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n): UnSelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options:\n | SelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n | UnSelectedQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n) {\n return options\n}\n"],"mappings":";;;AAyEO,SAAS,aAMd,SAGA;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useSuspenseInfiniteQuery.ts"],"sourcesContent":["import type { OmitKeyof } from '@suspensive/utils'\nimport {\n type InfiniteData,\n type QueryKey,\n type UseInfiniteQueryOptions,\n type UseInfiniteQueryResult,\n useInfiniteQuery,\n} from '@tanstack/react-query'\n\nexport interface UseSuspenseInfiniteQueryResult<TData = unknown, TError = unknown>\n extends OmitKeyof<\n UseInfiniteQueryResult<TData, TError>,\n keyof Pick<UseInfiniteQueryResult<TData, TError>, 'isPlaceholderData'>\n > {\n data: InfiniteData<TData>\n status: 'success'\n}\n\nexport interface UseSuspenseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'suspense' | 'useErrorBoundary' | 'enabled' | 'placeholderData'\n > {}\n\n/**\n * This hook is wrapping useInfiniteQuery of `@tanstack/react-query` v4 with default suspense option.\n * @see {@link https://suspensive.org/docs/react-query/useSuspenseInfiniteQuery}\n */\nexport function useSuspenseInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>\n): UseSuspenseInfiniteQueryResult<TData, TError> {\n return useInfiniteQuery({\n ...options,\n enabled: true,\n suspense: true,\n useErrorBoundary: true,\n }) as UseSuspenseInfiniteQueryResult<TData, TError>\n}\n"],"mappings":";;;;;;;AACA;AAAA,EAKE;AAAA,OACK;AAyBA,SAAS,yBAMd,SAC+C;AAC/C,SAAO,iBAAiB,iCACnB,UADmB;AAAA,IAEtB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,kBAAkB;AAAA,EACpB,EAAC;AACH;","names":[]}
|
|
File without changes
|
|
File without changes
|