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