1- import {
1+ import type {
2+ CancelOptions ,
23 DefaultError ,
34 FetchStatus ,
45 InfiniteData ,
@@ -14,7 +15,7 @@ import {
1415 SetDataOptions ,
1516 Updater ,
1617} from '@tanstack/query-core' ;
17- import {
18+ import type {
1819 DefinedInitialDataInfiniteOptions ,
1920 DefinedInitialDataOptions ,
2021 DefinedUseInfiniteQueryResult ,
@@ -63,7 +64,8 @@ export interface ServiceOperationQuery<
6364 ServiceOperationGetInfiniteQueryData < TSchema , TData , TParams > ,
6465 ServiceOperationSetQueryData < TSchema , TData , TParams > ,
6566 ServiceOperationSetInfiniteQueryData < TSchema , TData , TParams > ,
66- ServiceOperationInvalidateQueries < TSchema , TData , TParams , TError > {
67+ ServiceOperationInvalidateQueries < TSchema , TData , TParams , TError > ,
68+ ServiceOperationCancelQueries < TSchema , TData , TParams , TError > {
6769 schema : TSchema ;
6870 types : {
6971 parameters : TParams ;
@@ -144,7 +146,7 @@ interface ServiceOperationUseQueries<
144146
145147type QueryTypeFilter = 'all' | 'active' | 'inactive' ;
146148
147- interface InvalidateQueryFiltersBase <
149+ interface QueryFiltersBase <
148150 TSchema extends { url : string ; method : string } ,
149151 TData ,
150152 TParams = { } ,
@@ -178,56 +180,65 @@ interface InvalidateQueryFiltersBase<
178180 * Include queries matching their fetchStatus
179181 */
180182 fetchStatus ?: FetchStatus ;
181-
182- refetchType ?: QueryTypeFilter | 'none' ;
183183}
184184
185- interface InvalidateQueryFiltersByQueryKey <
185+ interface QueryFiltersByQueryKey <
186186 TSchema extends { url : string ; method : string } ,
187187 TData ,
188188 TParams = { } ,
189189 TError = DefaultError ,
190- > extends InvalidateQueryFiltersBase < TSchema , TData , TParams , TError > {
190+ > extends QueryFiltersBase < TSchema , TData , TParams , TError > {
191191 /**
192192 * Include queries matching this query key
193193 */
194194 queryKey ?: ServiceOperationQueryKey < TSchema , TParams > ;
195195}
196196
197- interface InvalidateQueryFiltersByParameters <
197+ interface QueryFiltersByParameters <
198198 TSchema extends { url : string ; method : string } ,
199199 TData ,
200200 TParams = { } ,
201201 TError = DefaultError ,
202- > extends InvalidateQueryFiltersBase < TSchema , TData , TParams , TError > {
202+ > extends QueryFiltersBase < TSchema , TData , TParams , TError > {
203203 /**
204204 * Include queries matching parameters
205205 */
206206 parameters ?: TParams ;
207207}
208208
209+ type InvalidateQueryFilters <
210+ TSchema extends { url : string ; method : string } ,
211+ TData ,
212+ TParams = { } ,
213+ TError = DefaultError ,
214+ > = (
215+ | QueryFiltersByParameters < TSchema , TData , TParams , TError >
216+ | QueryFiltersByQueryKey < TSchema , TData , TParams , TError >
217+ ) & {
218+ refetchType ?: QueryTypeFilter | 'none' ;
219+ } ;
220+
209221interface ServiceOperationInvalidateQueries <
210222 TSchema extends { url : string ; method : string } ,
211223 TData ,
212224 TParams = { } ,
213225 TError = DefaultError ,
214226> {
215227 invalidateQueries (
216- filters :
217- | InvalidateQueryFiltersByParameters < TSchema , TData , TParams , TError >
218- | InvalidateQueryFiltersByQueryKey < TSchema , TData , TParams , TError > ,
228+ filters : InvalidateQueryFilters < TSchema , TData , TParams , TError > ,
219229 options : InvalidateOptions ,
220230 queryClient : QueryClient
221231 ) : Promise < void > ;
222232 invalidateQueries (
223- filters :
224- | InvalidateQueryFiltersByParameters < TSchema , TData , TParams , TError >
225- | InvalidateQueryFiltersByQueryKey < TSchema , TData , TParams , TError > ,
233+ filters : InvalidateQueryFilters < TSchema , TData , TParams , TError > ,
226234 queryClient : QueryClient
227235 ) : Promise < void > ;
228236 invalidateQueries ( queryClient : QueryClient ) : Promise < void > ;
229237}
230238
239+ /**
240+ * @internal
241+ */
231242export interface ServiceOperationInvalidateQueriesCallback <
232243 TSchema extends { url : string ; method : string } ,
233244 TData ,
@@ -236,14 +247,55 @@ export interface ServiceOperationInvalidateQueriesCallback<
236247> extends ServiceOperationInvalidateQueries < TSchema , TData , TParams , TError > {
237248 invalidateQueries (
238249 filters :
239- | InvalidateQueryFiltersByParameters < TSchema , TData , TParams , TError >
240- | InvalidateQueryFiltersByQueryKey < TSchema , TData , TParams , TError >
250+ | QueryFiltersByParameters < TSchema , TData , TParams , TError >
251+ | QueryFiltersByQueryKey < TSchema , TData , TParams , TError >
241252 | QueryClient ,
242253 options ?: InvalidateOptions | QueryClient ,
243254 queryClient ?: QueryClient
244255 ) : Promise < void > ;
245256}
246257
258+ interface ServiceOperationCancelQueries <
259+ TSchema extends { url : string ; method : string } ,
260+ TData ,
261+ TParams = { } ,
262+ TError = DefaultError ,
263+ > {
264+ cancelQueries (
265+ filters :
266+ | QueryFiltersByParameters < TSchema , TData , TParams , TError >
267+ | QueryFiltersByQueryKey < TSchema , TData , TParams , TError > ,
268+ options : CancelOptions ,
269+ queryClient : QueryClient
270+ ) : Promise < void > ;
271+ cancelQueries (
272+ filters :
273+ | QueryFiltersByParameters < TSchema , TData , TParams , TError >
274+ | QueryFiltersByQueryKey < TSchema , TData , TParams , TError > ,
275+ queryClient : QueryClient
276+ ) : Promise < void > ;
277+ cancelQueries ( queryClient : QueryClient ) : Promise < void > ;
278+ }
279+
280+ /**
281+ * @internal
282+ */
283+ export interface ServiceOperationCancelQueriesCallback <
284+ TSchema extends { url : string ; method : string } ,
285+ TData ,
286+ TParams = { } ,
287+ TError = DefaultError ,
288+ > extends ServiceOperationCancelQueries < TSchema , TData , TParams , TError > {
289+ cancelQueries (
290+ filters :
291+ | QueryFiltersByParameters < TSchema , TData , TParams , TError >
292+ | QueryFiltersByQueryKey < TSchema , TData , TParams , TError >
293+ | QueryClient ,
294+ options ?: CancelOptions | QueryClient ,
295+ queryClient ?: QueryClient
296+ ) : Promise < void > ;
297+ }
298+
247299interface ServiceOperationUseSuspenseQueries <
248300 TSchema extends { url : string ; method : string } ,
249301 TData ,
0 commit comments