1 | import type { EndpointDefinitions, QueryDefinition, MutationDefinition, QueryArgFrom, ResultTypeFrom } from '../endpointDefinitions';
|
2 | import type { QueryThunk, MutationThunk, QueryThunkArg } from './buildThunks';
|
3 | import type { AnyAction, ThunkAction, SerializedError } from '@reduxjs/toolkit';
|
4 | import type { SubscriptionOptions } from './apiState';
|
5 | import type { InternalSerializeQueryArgs } from '../defaultSerializeQueryArgs';
|
6 | import type { Api, ApiContext } from '../apiTypes';
|
7 | import type { BaseQueryError, QueryReturnValue } from '../baseQueryTypes';
|
8 | import type { QueryResultSelectorResult } from './buildSelectors';
|
9 | import type { Dispatch } from 'redux';
|
10 | declare module './module' {
|
11 | interface ApiEndpointQuery<Definition extends QueryDefinition<any, any, any, any, any>, Definitions extends EndpointDefinitions> {
|
12 | initiate: StartQueryActionCreator<Definition>;
|
13 | }
|
14 | interface ApiEndpointMutation<Definition extends MutationDefinition<any, any, any, any, any>, Definitions extends EndpointDefinitions> {
|
15 | initiate: StartMutationActionCreator<Definition>;
|
16 | }
|
17 | }
|
18 | export declare const forceQueryFnSymbol: unique symbol;
|
19 | export declare const isUpsertQuery: (arg: QueryThunkArg) => boolean;
|
20 | export interface StartQueryActionCreatorOptions {
|
21 | subscribe?: boolean;
|
22 | forceRefetch?: boolean | number;
|
23 | subscriptionOptions?: SubscriptionOptions;
|
24 | [forceQueryFnSymbol]?: () => QueryReturnValue;
|
25 | }
|
26 | declare type StartQueryActionCreator<D extends QueryDefinition<any, any, any, any, any>> = (arg: QueryArgFrom<D>, options?: StartQueryActionCreatorOptions) => ThunkAction<QueryActionCreatorResult<D>, any, any, AnyAction>;
|
27 | export declare type QueryActionCreatorResult<D extends QueryDefinition<any, any, any, any>> = Promise<QueryResultSelectorResult<D>> & {
|
28 | arg: QueryArgFrom<D>;
|
29 | requestId: string;
|
30 | subscriptionOptions: SubscriptionOptions | undefined;
|
31 | abort(): void;
|
32 | unwrap(): Promise<ResultTypeFrom<D>>;
|
33 | unsubscribe(): void;
|
34 | refetch(): QueryActionCreatorResult<D>;
|
35 | updateSubscriptionOptions(options: SubscriptionOptions): void;
|
36 | queryCacheKey: string;
|
37 | };
|
38 | declare type StartMutationActionCreator<D extends MutationDefinition<any, any, any, any>> = (arg: QueryArgFrom<D>, options?: {
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | track?: boolean;
|
46 | fixedCacheKey?: string;
|
47 | }) => ThunkAction<MutationActionCreatorResult<D>, any, any, AnyAction>;
|
48 | export declare type MutationActionCreatorResult<D extends MutationDefinition<any, any, any, any>> = Promise<{
|
49 | data: ResultTypeFrom<D>;
|
50 | } | {
|
51 | error: Exclude<BaseQueryError<D extends MutationDefinition<any, infer BaseQuery, any, any> ? BaseQuery : never>, undefined> | SerializedError;
|
52 | }> & {
|
53 |
|
54 | arg: {
|
55 | |
56 |
|
57 |
|
58 | endpointName: string;
|
59 | |
60 |
|
61 |
|
62 | originalArgs: QueryArgFrom<D>;
|
63 | |
64 |
|
65 |
|
66 | track?: boolean;
|
67 | fixedCacheKey?: string;
|
68 | };
|
69 | |
70 |
|
71 |
|
72 | requestId: string;
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | abort(): void;
|
101 | |
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | unwrap(): Promise<ResultTypeFrom<D>>;
|
128 | |
129 |
|
130 |
|
131 |
|
132 | reset(): void;
|
133 |
|
134 | unsubscribe(): void;
|
135 | };
|
136 | export declare function buildInitiate({ serializeQueryArgs, queryThunk, mutationThunk, api, context, }: {
|
137 | serializeQueryArgs: InternalSerializeQueryArgs;
|
138 | queryThunk: QueryThunk;
|
139 | mutationThunk: MutationThunk;
|
140 | api: Api<any, EndpointDefinitions, any, any>;
|
141 | context: ApiContext<EndpointDefinitions>;
|
142 | }): {
|
143 | buildInitiateQuery: (endpointName: string, endpointDefinition: QueryDefinition<any, any, any, any>) => StartQueryActionCreator<any>;
|
144 | buildInitiateMutation: (endpointName: string) => StartMutationActionCreator<any>;
|
145 | getRunningQueryThunk: (endpointName: string, queryArgs: any) => (dispatch: Dispatch) => QueryActionCreatorResult<never> | undefined;
|
146 | getRunningMutationThunk: (_endpointName: string, fixedCacheKeyOrRequestId: string) => (dispatch: Dispatch) => MutationActionCreatorResult<never> | undefined;
|
147 | getRunningQueriesThunk: () => (dispatch: Dispatch) => QueryActionCreatorResult<any>[];
|
148 | getRunningMutationsThunk: () => (dispatch: Dispatch) => MutationActionCreatorResult<any>[];
|
149 | getRunningOperationPromises: () => (QueryActionCreatorResult<any> | MutationActionCreatorResult<any>)[];
|
150 | removalWarning: () => never;
|
151 | };
|
152 | export {};
|