-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterceptors.d.ts
51 lines (49 loc) · 1.92 KB
/
interceptors.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { I as InvokeFetchResponse, a as InvokeFetchProperties } from './invoke-fetch-types-BXn-uSF5.js';
import './auth-types-PkN9CAF_.js';
/**
* The RestInterceptor type is a function that can be used to intercept requests and responses
*/
type RestInterceptor = <T extends InvokeFetchResponse>(request: InvokeFetchProperties, proceed: (props: InvokeFetchProperties) => Promise<T>, id?: string) => Promise<T>;
declare function createInterceptors(): InterceptorsAPI;
declare function addDefaultInterceptors(): void;
/**
* Adds an interceptor to the global interceptor stack
* Returns the newly added interceptor
* @param interceptor the interceptor to add
* @returns the newly added interceptor
*/
declare function addInterceptor(interceptor: RestInterceptor): RestInterceptor;
/**
* Removes an interceptor from the global interceptor stack
* @param interceptor the interceptor remove
*/
declare function removeInterceptor(interceptor: RestInterceptor): RestInterceptor | null;
/**
* Gets all registered interceptors
*/
declare function getInterceptors(): RestInterceptor[];
interface InterceptorsAPI {
/**
* Adds an interceptor to the global interceptor stack
* Returns the newly added interceptor
* @param interceptor the interceptor to add
* @returns the newly added interceptor
*/
addInterceptor: typeof addInterceptor;
/**
* Removes an interceptor from the global interceptor stack
* @param interceptor the interceptor remove
*/
removeInterceptor: typeof removeInterceptor;
/**
* Gets all registered interceptors
*/
getInterceptors: typeof getInterceptors;
}
/**
* The interceptors API
*/
declare const interceptors: InterceptorsAPI & {
createInterceptors: typeof createInterceptors;
};
export { type InterceptorsAPI, type RestInterceptor, addDefaultInterceptors, addInterceptor, createInterceptors, interceptors as default, getInterceptors, removeInterceptor };