react-query-kit 1.4.4 → 1.4.5
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 +7 -3
- package/build/lib/createBaseQuery.esm.js +16 -27
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +16 -27
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +16 -27
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createInfiniteQuery.d.ts +5 -6
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +1 -2
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.d.ts +2 -3
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/index.d.ts +1 -1
- package/build/lib/types.d.ts +27 -22
- package/build/stats-html.html +1 -1
- package/build/stats.json +46 -71
- package/build/umd/index.development.js +16 -30
- 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 +7 -3
- package/src/createBaseQuery.ts +21 -37
- package/src/createInfiniteQuery.ts +11 -7
- package/src/createMutation.ts +1 -1
- package/src/createQuery.tsx +3 -3
- package/src/index.ts +2 -0
- package/src/types.ts +76 -45
- package/build/lib/utils.d.ts +0 -1
- package/build/lib/utils.esm.js +0 -6
- package/build/lib/utils.esm.js.map +0 -1
- package/build/lib/utils.js +0 -10
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.mjs +0 -6
- package/build/lib/utils.mjs.map +0 -1
- package/src/utils.ts +0 -3
package/src/createMutation.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
MutationHookOptions,
|
|
7
7
|
} from './types'
|
|
8
8
|
|
|
9
|
-
interface CreateMutationOptions<TData, TError, TVariables, TContext>
|
|
9
|
+
export interface CreateMutationOptions<TData, TError, TVariables, TContext>
|
|
10
10
|
extends UseMutationOptions<TData, TError, TVariables, TContext> {
|
|
11
11
|
useDefaultOptions?: () => MutationHookOptions<
|
|
12
12
|
TData,
|
package/src/createQuery.tsx
CHANGED
|
@@ -6,12 +6,12 @@ import type {
|
|
|
6
6
|
CompatibleWithV4,
|
|
7
7
|
QueryHook,
|
|
8
8
|
QueryHookOptions,
|
|
9
|
-
|
|
9
|
+
inferQueryKey,
|
|
10
10
|
} from './types'
|
|
11
11
|
|
|
12
|
-
interface CreateQueryOptions<TFnData, TVariables, Error>
|
|
12
|
+
export interface CreateQueryOptions<TFnData, TVariables = any, Error = unknown>
|
|
13
13
|
extends Omit<
|
|
14
|
-
UseQueryOptions<TFnData, Error, TFnData,
|
|
14
|
+
UseQueryOptions<TFnData, Error, TFnData, inferQueryKey<TVariables>>,
|
|
15
15
|
'queryKey' | 'queryFn' | 'enabled' | 'select'
|
|
16
16
|
>,
|
|
17
17
|
AdditionalCreateOptions<TFnData, TVariables> {}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
export declare type DataUpdateFunction<TInput, TOutput> = (
|
|
18
18
|
input: TInput
|
|
19
19
|
) => TOutput
|
|
20
|
+
|
|
20
21
|
export declare type Updater<TInput, TOutput> =
|
|
21
22
|
| TOutput
|
|
22
23
|
| DataUpdateFunction<TInput, TOutput>
|
|
@@ -48,7 +49,7 @@ export type CompatibleUseInfiniteQueryOptions<
|
|
|
48
49
|
Error,
|
|
49
50
|
InfiniteData<TFnData>,
|
|
50
51
|
TFnData,
|
|
51
|
-
|
|
52
|
+
inferQueryKey<TVariables>,
|
|
52
53
|
TPageParam
|
|
53
54
|
>,
|
|
54
55
|
UseInfiniteQueryOptions<
|
|
@@ -56,30 +57,40 @@ export type CompatibleUseInfiniteQueryOptions<
|
|
|
56
57
|
Error,
|
|
57
58
|
TFnData,
|
|
58
59
|
TFnData,
|
|
59
|
-
|
|
60
|
+
inferQueryKey<TVariables>
|
|
60
61
|
>
|
|
61
62
|
>
|
|
62
63
|
|
|
63
|
-
export type
|
|
64
|
+
export type inferQueryKey<TVariables> = TVariables extends void
|
|
64
65
|
? [string]
|
|
65
66
|
: [string, TVariables]
|
|
66
67
|
|
|
68
|
+
type inferEnabled<TFnData, TVariables, TPageParam = never> =
|
|
69
|
+
| boolean
|
|
70
|
+
| ([TPageParam] extends [never]
|
|
71
|
+
? (data: TFnData | undefined, variables: TVariables) => boolean
|
|
72
|
+
: (
|
|
73
|
+
data: InfiniteData<TFnData> | undefined,
|
|
74
|
+
variables: TVariables
|
|
75
|
+
) => boolean)
|
|
76
|
+
|
|
67
77
|
export type AdditionalCreateOptions<TFnData, TVariables, TPageParam = never> = {
|
|
68
78
|
primaryKey: string
|
|
69
|
-
queryFn: CompatibleQueryFunction<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
queryFn: CompatibleQueryFunction<
|
|
80
|
+
TFnData,
|
|
81
|
+
inferQueryKey<TVariables>,
|
|
82
|
+
TPageParam
|
|
83
|
+
>
|
|
84
|
+
enabled?: inferEnabled<TFnData, TVariables, TPageParam>
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
export type AdditionalQueryHookOptions<
|
|
76
88
|
TFnData,
|
|
77
89
|
TVariables,
|
|
90
|
+
TPageParam = never,
|
|
78
91
|
TOptVariables = TVariables
|
|
79
92
|
> = {
|
|
80
|
-
enabled?:
|
|
81
|
-
| boolean
|
|
82
|
-
| ((data: TFnData | undefined, variables: TVariables) => boolean)
|
|
93
|
+
enabled?: inferEnabled<TFnData, TVariables, TPageParam>
|
|
83
94
|
} & (TOptVariables extends void
|
|
84
95
|
? {
|
|
85
96
|
variables?: TVariables
|
|
@@ -88,7 +99,7 @@ export type AdditionalQueryHookOptions<
|
|
|
88
99
|
variables: TVariables
|
|
89
100
|
})
|
|
90
101
|
|
|
91
|
-
type
|
|
102
|
+
type inferPartialQueryKey<TVariables> = TVariables extends Record<any, any>
|
|
92
103
|
?
|
|
93
104
|
| {
|
|
94
105
|
[P in keyof TVariables]?: TVariables[P]
|
|
@@ -98,11 +109,15 @@ type PartialQueryKitKey<TVariables> = TVariables extends Record<any, any>
|
|
|
98
109
|
|
|
99
110
|
export type ExposeMethods<TFnData, TVariables, TPageParam = never> = {
|
|
100
111
|
getPrimaryKey: () => string
|
|
101
|
-
getKey: <V extends
|
|
112
|
+
getKey: <V extends inferPartialQueryKey<TVariables> | void = void>(
|
|
102
113
|
variables?: V
|
|
103
|
-
) =>
|
|
104
|
-
queryFn: CompatibleQueryFunction<
|
|
105
|
-
|
|
114
|
+
) => inferQueryKey<V>
|
|
115
|
+
queryFn: CompatibleQueryFunction<
|
|
116
|
+
TFnData,
|
|
117
|
+
inferQueryKey<TVariables>,
|
|
118
|
+
TPageParam
|
|
119
|
+
>
|
|
120
|
+
queryKeyHashFn: QueryKeyHashFunction<inferQueryKey<TVariables>>
|
|
106
121
|
}
|
|
107
122
|
|
|
108
123
|
export type QueryHookOptions<
|
|
@@ -112,42 +127,50 @@ export type QueryHookOptions<
|
|
|
112
127
|
TVariables,
|
|
113
128
|
TOptVariables = TVariables
|
|
114
129
|
> = Omit<
|
|
115
|
-
UseQueryOptions<TFnData, Error, TData,
|
|
130
|
+
UseQueryOptions<TFnData, Error, TData, inferQueryKey<TVariables>>,
|
|
116
131
|
'queryKey' | 'queryFn' | 'queryKeyHashFn' | 'enabled'
|
|
117
132
|
> &
|
|
118
133
|
AdditionalQueryHookOptions<TFnData, TVariables, TOptVariables>
|
|
119
134
|
|
|
135
|
+
export type QueryHookResult<
|
|
136
|
+
TFnData,
|
|
137
|
+
TVariables,
|
|
138
|
+
TError = unknown,
|
|
139
|
+
TData = TFnData
|
|
140
|
+
> = UseQueryResult<TData, TError> & {
|
|
141
|
+
queryKey: inferQueryKey<TVariables>
|
|
142
|
+
variables: TVariables
|
|
143
|
+
setData: (
|
|
144
|
+
updater: Updater<TFnData | undefined, TFnData>,
|
|
145
|
+
options?: SetDataOptions | undefined
|
|
146
|
+
) => TFnData | undefined
|
|
147
|
+
}
|
|
148
|
+
|
|
120
149
|
export interface QueryHook<
|
|
121
150
|
TFnData,
|
|
122
151
|
TVariables,
|
|
123
|
-
|
|
152
|
+
TError = unknown,
|
|
124
153
|
TOptVariables = TVariables
|
|
125
154
|
> extends ExposeMethods<TFnData, TVariables> {
|
|
126
155
|
<TData = TFnData>(
|
|
127
156
|
options: TOptVariables extends void
|
|
128
157
|
? QueryHookOptions<
|
|
129
158
|
TFnData,
|
|
130
|
-
|
|
159
|
+
TError,
|
|
131
160
|
TData,
|
|
132
161
|
TVariables,
|
|
133
162
|
TOptVariables
|
|
134
163
|
> | void
|
|
135
|
-
: QueryHookOptions<TFnData,
|
|
136
|
-
):
|
|
137
|
-
queryKey: QueryKitKey<TVariables>
|
|
138
|
-
setData: (
|
|
139
|
-
updater: Updater<TFnData | undefined, TFnData>,
|
|
140
|
-
options?: SetDataOptions | undefined
|
|
141
|
-
) => TFnData | undefined
|
|
142
|
-
}
|
|
164
|
+
: QueryHookOptions<TFnData, TError, TData, TVariables, TOptVariables>
|
|
165
|
+
): QueryHookResult<TFnData, TVariables, TError, TData>
|
|
143
166
|
}
|
|
144
167
|
|
|
145
168
|
export type InfiniteQueryHookOptions<
|
|
146
169
|
TFnData,
|
|
147
170
|
Error,
|
|
148
171
|
TVariables,
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
TPageParam = number,
|
|
173
|
+
TOptVariables = TVariables
|
|
151
174
|
> = Omit<
|
|
152
175
|
CompatibleUseInfiniteQueryOptions<TFnData, TVariables, Error, TPageParam>,
|
|
153
176
|
| 'queryKey'
|
|
@@ -158,38 +181,46 @@ export type InfiniteQueryHookOptions<
|
|
|
158
181
|
| 'getPreviousPageParam'
|
|
159
182
|
| 'getNextPageParam'
|
|
160
183
|
> &
|
|
161
|
-
AdditionalQueryHookOptions<TFnData, TVariables, TOptVariables>
|
|
184
|
+
AdditionalQueryHookOptions<TFnData, TVariables, TPageParam, TOptVariables>
|
|
185
|
+
|
|
186
|
+
export type InfiniteQueryHookResult<
|
|
187
|
+
TFnData,
|
|
188
|
+
TVariables,
|
|
189
|
+
TError = unknown,
|
|
190
|
+
TData = InfiniteData<TFnData>
|
|
191
|
+
> = UseInfiniteQueryResult<CompatibleWithV4<TData, TFnData>, TError> & {
|
|
192
|
+
queryKey: inferQueryKey<TVariables>
|
|
193
|
+
variables: TVariables
|
|
194
|
+
setData: (
|
|
195
|
+
updater: Updater<TData | undefined, TData | undefined>,
|
|
196
|
+
options?: SetDataOptions
|
|
197
|
+
) => TData | undefined
|
|
198
|
+
}
|
|
162
199
|
|
|
163
200
|
export interface InfiniteQueryHook<
|
|
164
201
|
TFnData,
|
|
165
202
|
TVariables,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
203
|
+
TError = unknown,
|
|
204
|
+
TPageParam = number,
|
|
205
|
+
TOptVariables = TVariables
|
|
169
206
|
> extends ExposeMethods<TFnData, TVariables, TPageParam> {
|
|
170
207
|
<TData = InfiniteData<TFnData>>(
|
|
171
208
|
options: TOptVariables extends void
|
|
172
209
|
? InfiniteQueryHookOptions<
|
|
173
210
|
TFnData,
|
|
174
|
-
|
|
211
|
+
TError,
|
|
175
212
|
TVariables,
|
|
176
|
-
|
|
177
|
-
|
|
213
|
+
TPageParam,
|
|
214
|
+
TOptVariables
|
|
178
215
|
> | void
|
|
179
216
|
: InfiniteQueryHookOptions<
|
|
180
217
|
TFnData,
|
|
181
|
-
|
|
218
|
+
TError,
|
|
182
219
|
TVariables,
|
|
183
|
-
|
|
184
|
-
|
|
220
|
+
TPageParam,
|
|
221
|
+
TOptVariables
|
|
185
222
|
>
|
|
186
|
-
):
|
|
187
|
-
queryKey: QueryKitKey<TVariables>
|
|
188
|
-
setData: (
|
|
189
|
-
updater: Updater<TData | undefined, TData | undefined>,
|
|
190
|
-
options?: SetDataOptions
|
|
191
|
-
) => TData | undefined
|
|
192
|
-
}
|
|
223
|
+
): InfiniteQueryHookResult<TFnData, TVariables, TError, TData>
|
|
193
224
|
}
|
|
194
225
|
|
|
195
226
|
export type MutationHookOptions<TData, TError, TVariables, TContext> = Omit<
|
package/build/lib/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUndefined(value: any): value is undefined;
|
package/build/lib/utils.esm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.esm.js","sources":["../../src/utils.ts"],"sourcesContent":["export function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined'\n}\n"],"names":["isUndefined","value"],"mappings":"AAAO,SAASA,WAAT,CAAqBC,KAArB,EAAqD;EAC1D,OAAO,OAAOA,KAAP,KAAiB,WAAxB,CAAA;AACD;;;;"}
|
package/build/lib/utils.js
DELETED
package/build/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["export function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined'\n}\n"],"names":["isUndefined","value"],"mappings":";;;;AAAO,SAASA,WAAT,CAAqBC,KAArB,EAAqD;EAC1D,OAAO,OAAOA,KAAP,KAAiB,WAAxB,CAAA;AACD;;;;"}
|
package/build/lib/utils.mjs
DELETED
package/build/lib/utils.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["export function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined'\n}\n"],"names":["isUndefined","value"],"mappings":"AAAO,SAASA,WAAT,CAAqBC,KAArB,EAAqD;EAC1D,OAAO,OAAOA,KAAP,KAAiB,WAAxB,CAAA;AACD;;;;"}
|
package/src/utils.ts
DELETED