-
Notifications
You must be signed in to change notification settings - Fork 0
/
dame.d.ts
123 lines (123 loc) · 3.41 KB
/
dame.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
52
53
54
55
56
57
58
59
60
61
62
63
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
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
119
120
121
122
123
declare module "utils/buildUrl" {
function _exports(url: any, dameInstance: any): any;
export = _exports;
}
declare module "utils/buildHeaders" {
function _exports(config: any, dameInstance?: {}): any;
export = _exports;
}
declare module "utils/buildTimeout" {
function _exports(config: any, instance: any): any;
export = _exports;
}
declare module "utils/raceTimeout" {
function _exports(promise: any, options: any, dameInstance: any): any;
export = _exports;
}
declare module "utils/checkIsError" {
function _exports(code: any): boolean;
export = _exports;
}
declare module "utils/buildMaxRedirects" {
function _exports(config: any, instance: any): any;
export = _exports;
}
declare module "utils/requestWeb" {
function _exports({ method, fullUrl, body, config, instance, }: RequestWebOptions): Promise<ResponseWeb>;
export = _exports;
export type RequestWebOptions = {
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
fullUrl: string;
body: any;
config: any;
/**
* Dame instance
*/
instance: any;
};
export type ResponseWeb = {
isError: boolean;
code: number;
status: string;
response: any;
error: any | null;
};
}
declare module "utils/requestNode" {
function _exports({ method, fullUrl, body, config, instance, }: RequestNodeOptions): Promise<ResponseNode>;
export = _exports;
export type RequestNodeOptions = {
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
fullUrl: string;
body: any;
config: any;
/**
* Dame instance
*/
instance: any;
};
export type ResponseNode = {
isError: boolean;
code: number;
status: string;
response: any;
error: any | null;
};
}
declare module "src/dame" {
export = dame;
/**
* @type {DameInstance}
*/
const dame: DameInstance;
namespace dame {
export { Response, Config, GetFnc, PostFnc, NewFnc, DameInstance };
}
type DameInstance = {
get: GetFnc;
post: PostFnc;
put: PostFnc;
patch: PostFnc;
delete: GetFnc;
new: NewFnc;
instances: Array<DameInstance>;
baseUrl: string;
options: any;
headers: any;
checkIsError: Function;
timeout: number;
maxRedirects: number;
};
type Response = {
isError: boolean;
code: number;
status: string;
response: any;
error: any | null;
};
type Config = {
headers: any;
/**
* Number of miliseconds for the timeout.
*/
timeout?: number;
/**
* Max redirects to follow. Default 20. Use 0 to disable redirects.
*/
maxRedirects?: number;
/**
* **Browser only**. Default `"json"`. Type of the data that the server will respond with.
*/
responseType?: "arraybuffer" | "stream" | "json" | "text";
/**
* Request or fetch extra options.
*/
requestOptions: any;
};
type GetFnc = (url: Url, config?: Config) => Promise<Response>;
type PostFnc = (url: Url, body: any, config?: Config) => Promise<Response>;
/**
* Creates a new instance of dame with pre-set configuration.
*/
type NewFnc = (config: Config, instanceName?: string) => DameInstance;
}