react-query-kit 1.4.9 → 1.5.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/README.md +88 -56
- package/build/lib/createBaseQuery.d.ts +1 -1
- package/build/lib/createBaseQuery.esm.js +31 -24
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +31 -24
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +31 -24
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createImmutableQuery.d.ts +5 -12
- package/build/lib/createImmutableQuery.esm.js +2 -2
- package/build/lib/createImmutableQuery.esm.js.map +1 -1
- package/build/lib/createImmutableQuery.js +2 -2
- package/build/lib/createImmutableQuery.js.map +1 -1
- package/build/lib/createImmutableQuery.mjs +2 -2
- package/build/lib/createImmutableQuery.mjs.map +1 -1
- package/build/lib/createInfiniteQuery.d.ts +4 -12
- package/build/lib/createInfiniteQuery.esm.js +2 -2
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js +2 -2
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs +2 -2
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +5 -5
- package/build/lib/createMutation.esm.js +3 -12
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js +3 -12
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs +3 -12
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.d.ts +5 -12
- package/build/lib/createQuery.esm.js +2 -2
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js +2 -2
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs +2 -2
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.d.ts +4 -12
- package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.d.ts +5 -12
- package/build/lib/createSuspenseQuery.esm.js +2 -2
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +2 -2
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +2 -2
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/index.d.ts +2 -1
- package/build/lib/index.esm.js +1 -0
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +2 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1 -0
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/types.d.ts +51 -36
- package/build/lib/utils.d.ts +8 -0
- package/build/lib/utils.esm.js +40 -0
- package/build/lib/utils.esm.js.map +1 -0
- package/build/lib/utils.js +46 -0
- package/build/lib/utils.js.map +1 -0
- package/build/lib/utils.mjs +40 -0
- package/build/lib/utils.mjs.map +1 -0
- package/build/stats-html.html +1 -1
- package/build/stats.json +129 -91
- package/build/umd/index.development.js +79 -45
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -1
- package/src/createBaseQuery.ts +51 -33
- package/src/createImmutableQuery.tsx +14 -42
- package/src/createInfiniteQuery.ts +13 -66
- package/src/createMutation.ts +21 -38
- package/src/createQuery.tsx +17 -34
- package/src/createSuspenseInfiniteQuery.ts +14 -73
- package/src/createSuspenseQuery.ts +17 -34
- package/src/index.ts +2 -0
- package/src/types.ts +146 -194
- package/src/utils.ts +48 -0
package/src/createQuery.tsx
CHANGED
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UseQueryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { useQuery } from '@tanstack/react-query'
|
|
3
|
+
|
|
3
4
|
import { createBaseQuery } from './createBaseQuery'
|
|
4
5
|
import type {
|
|
5
6
|
AdditionalCreateOptions,
|
|
6
|
-
|
|
7
|
+
DefaultError,
|
|
8
|
+
Middleware,
|
|
7
9
|
QueryHook,
|
|
8
|
-
QueryHookOptions,
|
|
9
10
|
inferQueryKey,
|
|
10
11
|
} from './types'
|
|
11
12
|
|
|
12
|
-
export interface CreateQueryOptions<
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export interface CreateQueryOptions<
|
|
14
|
+
TFnData = unknown,
|
|
15
|
+
TVariables = any,
|
|
16
|
+
TError = DefaultError
|
|
17
|
+
> extends Omit<
|
|
18
|
+
UseQueryOptions<TFnData, TError, TFnData, inferQueryKey<TVariables>>,
|
|
15
19
|
'queryKey' | 'queryFn' | 'enabled' | 'select'
|
|
16
20
|
>,
|
|
17
|
-
AdditionalCreateOptions<TFnData, TVariables> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
options: CreateQueryOptions<TFnData, TVariables, Error> & {
|
|
21
|
-
useDefaultOptions: () => Omit<
|
|
22
|
-
QueryHookOptions<TFnData, Error, TFnData, TVariables>,
|
|
23
|
-
'select'
|
|
24
|
-
> & { variables: TVariables }
|
|
25
|
-
},
|
|
26
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
27
|
-
): QueryHook<TFnData, TVariables, Error, TVariables | void>
|
|
28
|
-
|
|
29
|
-
export function createQuery<TFnData, TVariables = any, Error = unknown>(
|
|
30
|
-
options: CreateQueryOptions<TFnData, TVariables, Error> & {
|
|
31
|
-
useDefaultOptions: () => Omit<
|
|
32
|
-
QueryHookOptions<TFnData, Error, TFnData, TVariables>,
|
|
33
|
-
'select' | 'variables'
|
|
34
|
-
>
|
|
35
|
-
},
|
|
36
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
37
|
-
): QueryHook<TFnData, TVariables, Error, TVariables>
|
|
38
|
-
|
|
39
|
-
export function createQuery<TFnData, TVariables = any, Error = unknown>(
|
|
40
|
-
options: CreateQueryOptions<TFnData, TVariables, Error>,
|
|
41
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
42
|
-
): QueryHook<TFnData, TVariables, Error, TVariables>
|
|
21
|
+
AdditionalCreateOptions<TFnData, TVariables> {
|
|
22
|
+
use?: Middleware<QueryHook<TFnData, TVariables, TError>>[]
|
|
23
|
+
}
|
|
43
24
|
|
|
44
|
-
export function createQuery
|
|
45
|
-
|
|
25
|
+
export function createQuery<TFnData, TVariables = any, TError = DefaultError>(
|
|
26
|
+
options: CreateQueryOptions<TFnData, TVariables, TError>
|
|
27
|
+
): QueryHook<TFnData, TVariables, TError> {
|
|
28
|
+
return createBaseQuery(options, useQuery)
|
|
46
29
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { QueryClient } from '@tanstack/react-query'
|
|
2
1
|
import { useInfiniteQuery } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
3
|
import { createBaseQuery } from './createBaseQuery'
|
|
4
4
|
import type {
|
|
5
5
|
AdditionalCreateOptions,
|
|
6
6
|
CompatibleUseInfiniteQueryOptions,
|
|
7
|
-
|
|
7
|
+
DefaultError,
|
|
8
|
+
Middleware,
|
|
8
9
|
SuspenseInfiniteQueryHook,
|
|
9
|
-
SuspenseInfiniteQueryHookOptions,
|
|
10
10
|
} from './types'
|
|
11
11
|
|
|
12
12
|
export interface CreateSuspenseInfiniteQueryOptions<
|
|
13
|
-
TFnData,
|
|
13
|
+
TFnData = unknown,
|
|
14
14
|
TVariables = any,
|
|
15
|
-
|
|
15
|
+
TError = DefaultError,
|
|
16
16
|
TPageParam = number
|
|
17
17
|
> extends Omit<
|
|
18
18
|
CompatibleUseInfiniteQueryOptions<
|
|
19
19
|
TFnData,
|
|
20
20
|
TVariables,
|
|
21
21
|
TFnData,
|
|
22
|
-
|
|
22
|
+
TError,
|
|
23
23
|
TPageParam
|
|
24
24
|
>,
|
|
25
25
|
| 'queryKey'
|
|
@@ -32,83 +32,24 @@ export interface CreateSuspenseInfiniteQueryOptions<
|
|
|
32
32
|
| 'keepPreviousData'
|
|
33
33
|
| 'useErrorBoundary'
|
|
34
34
|
>,
|
|
35
|
-
Omit<AdditionalCreateOptions<TFnData, TVariables, TPageParam>, 'enabled'> {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
TFnData,
|
|
39
|
-
TVariables = any,
|
|
40
|
-
Error = unknown,
|
|
41
|
-
TPageParam = number
|
|
42
|
-
>(
|
|
43
|
-
options: CreateSuspenseInfiniteQueryOptions<
|
|
44
|
-
TFnData,
|
|
45
|
-
TVariables,
|
|
46
|
-
Error,
|
|
47
|
-
TPageParam
|
|
48
|
-
> & {
|
|
49
|
-
useDefaultOptions: () => Omit<
|
|
50
|
-
SuspenseInfiniteQueryHookOptions<
|
|
51
|
-
TFnData,
|
|
52
|
-
Error,
|
|
53
|
-
TVariables,
|
|
54
|
-
TVariables,
|
|
55
|
-
TPageParam
|
|
56
|
-
>,
|
|
57
|
-
'select'
|
|
58
|
-
> & { variables: TVariables }
|
|
59
|
-
},
|
|
60
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
61
|
-
): SuspenseInfiniteQueryHook<
|
|
62
|
-
TFnData,
|
|
63
|
-
TVariables,
|
|
64
|
-
Error,
|
|
65
|
-
TPageParam,
|
|
66
|
-
TVariables | void
|
|
67
|
-
>
|
|
68
|
-
|
|
69
|
-
export function createSuspenseInfiniteQuery<
|
|
70
|
-
TFnData,
|
|
71
|
-
TVariables = any,
|
|
72
|
-
Error = unknown,
|
|
73
|
-
TPageParam = number
|
|
74
|
-
>(
|
|
75
|
-
options: CreateSuspenseInfiniteQueryOptions<
|
|
76
|
-
TFnData,
|
|
77
|
-
TVariables,
|
|
78
|
-
Error,
|
|
79
|
-
TPageParam
|
|
80
|
-
> & {
|
|
81
|
-
useDefaultOptions: () => Omit<
|
|
82
|
-
SuspenseInfiniteQueryHookOptions<
|
|
83
|
-
TFnData,
|
|
84
|
-
Error,
|
|
85
|
-
TVariables,
|
|
86
|
-
TPageParam,
|
|
87
|
-
TVariables
|
|
88
|
-
>,
|
|
89
|
-
'select' | 'variables'
|
|
90
|
-
>
|
|
91
|
-
},
|
|
92
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
93
|
-
): SuspenseInfiniteQueryHook<TFnData, TVariables, Error, TPageParam, TVariables>
|
|
35
|
+
Omit<AdditionalCreateOptions<TFnData, TVariables, TPageParam>, 'enabled'> {
|
|
36
|
+
use?: Middleware<SuspenseInfiniteQueryHook<TFnData, TVariables, TVariables>>[]
|
|
37
|
+
}
|
|
94
38
|
|
|
95
39
|
export function createSuspenseInfiniteQuery<
|
|
96
40
|
TFnData,
|
|
97
41
|
TVariables = any,
|
|
98
|
-
|
|
42
|
+
TError = DefaultError,
|
|
99
43
|
TPageParam = number
|
|
100
44
|
>(
|
|
101
45
|
options: CreateSuspenseInfiniteQueryOptions<
|
|
102
46
|
TFnData,
|
|
103
47
|
TVariables,
|
|
104
|
-
|
|
48
|
+
TError,
|
|
105
49
|
TPageParam
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
export function createSuspenseInfiniteQuery(options: any, queryClient?: any) {
|
|
111
|
-
return createBaseQuery(options, useInfiniteQuery, queryClient, {
|
|
50
|
+
>
|
|
51
|
+
): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> {
|
|
52
|
+
return createBaseQuery(options, useInfiniteQuery, {
|
|
112
53
|
enabled: true,
|
|
113
54
|
suspense: true,
|
|
114
55
|
throwOnError: true,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DefaultError, UseQueryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { useQuery } from '@tanstack/react-query'
|
|
3
|
+
|
|
3
4
|
import { createBaseQuery } from './createBaseQuery'
|
|
4
5
|
import type {
|
|
5
6
|
AdditionalCreateOptions,
|
|
6
|
-
|
|
7
|
+
Middleware,
|
|
7
8
|
SuspenseQueryHook,
|
|
8
|
-
SuspenseQueryHookOptions,
|
|
9
9
|
inferQueryKey,
|
|
10
10
|
} from './types'
|
|
11
11
|
|
|
12
12
|
export interface CreateSuspenseQueryOptions<
|
|
13
|
-
TFnData,
|
|
13
|
+
TFnData = unknown,
|
|
14
14
|
TVariables = any,
|
|
15
|
-
|
|
15
|
+
TError = DefaultError
|
|
16
16
|
> extends Omit<
|
|
17
|
-
UseQueryOptions<TFnData,
|
|
17
|
+
UseQueryOptions<TFnData, TError, TFnData, inferQueryKey<TVariables>>,
|
|
18
18
|
| 'queryKey'
|
|
19
19
|
| 'queryFn'
|
|
20
20
|
| 'enabled'
|
|
@@ -25,35 +25,18 @@ export interface CreateSuspenseQueryOptions<
|
|
|
25
25
|
| 'keepPreviousData'
|
|
26
26
|
| 'useErrorBoundary'
|
|
27
27
|
>,
|
|
28
|
-
Omit<AdditionalCreateOptions<TFnData, TVariables>, 'enabled'> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
options: CreateSuspenseQueryOptions<TFnData, TVariables, Error> & {
|
|
32
|
-
useDefaultOptions: () => Omit<
|
|
33
|
-
SuspenseQueryHookOptions<TFnData, Error, TFnData, TVariables>,
|
|
34
|
-
'select'
|
|
35
|
-
> & { variables: TVariables }
|
|
36
|
-
},
|
|
37
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
38
|
-
): SuspenseQueryHook<TFnData, TVariables, Error, TVariables | void>
|
|
39
|
-
|
|
40
|
-
export function createSuspenseQuery<TFnData, TVariables = any, Error = unknown>(
|
|
41
|
-
options: CreateSuspenseQueryOptions<TFnData, TVariables, Error> & {
|
|
42
|
-
useDefaultOptions: () => Omit<
|
|
43
|
-
SuspenseQueryHookOptions<TFnData, Error, TFnData, TVariables>,
|
|
44
|
-
'select' | 'variables'
|
|
45
|
-
>
|
|
46
|
-
},
|
|
47
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
48
|
-
): SuspenseQueryHook<TFnData, TVariables, Error, TVariables>
|
|
49
|
-
|
|
50
|
-
export function createSuspenseQuery<TFnData, TVariables = any, Error = unknown>(
|
|
51
|
-
options: CreateSuspenseQueryOptions<TFnData, TVariables, Error>,
|
|
52
|
-
queryClient?: CompatibleWithV4<QueryClient, void>
|
|
53
|
-
): SuspenseQueryHook<TFnData, TVariables, Error, TVariables>
|
|
28
|
+
Omit<AdditionalCreateOptions<TFnData, TVariables>, 'enabled'> {
|
|
29
|
+
use?: Middleware<SuspenseQueryHook<TFnData, TVariables, TVariables>>[]
|
|
30
|
+
}
|
|
54
31
|
|
|
55
|
-
export function createSuspenseQuery
|
|
56
|
-
|
|
32
|
+
export function createSuspenseQuery<
|
|
33
|
+
TFnData,
|
|
34
|
+
TVariables = any,
|
|
35
|
+
TError = DefaultError
|
|
36
|
+
>(
|
|
37
|
+
options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>
|
|
38
|
+
): SuspenseQueryHook<TFnData, TVariables, TError> {
|
|
39
|
+
return createBaseQuery(options, useQuery, {
|
|
57
40
|
enabled: true,
|
|
58
41
|
suspense: true,
|
|
59
42
|
throwOnError: true,
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './createSuspenseQuery'
|
|
|
4
4
|
export * from './createInfiniteQuery'
|
|
5
5
|
export * from './createSuspenseInfiniteQuery'
|
|
6
6
|
export * from './createMutation'
|
|
7
|
+
export { getQueryKey } from './utils'
|
|
7
8
|
export type {
|
|
8
9
|
QueryHookOptions,
|
|
9
10
|
QueryHook,
|
|
@@ -25,4 +26,5 @@ export type {
|
|
|
25
26
|
inferVariables,
|
|
26
27
|
inferData,
|
|
27
28
|
inferFnData,
|
|
29
|
+
Middleware,
|
|
28
30
|
} from './types'
|