/
types.ts
87 lines (72 loc) · 1.88 KB
/
types.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
import type { IncomingHttpHeaders } from 'http';
import type {
OptionsOfBufferResponseBody,
OptionsOfJSONResponseBody,
} from 'got';
export type GotContextOptions = {
authType?: string;
} & Record<string, unknown>;
// TODO: Move options to context
export type GotOptions = GotBufferOptions | GotJSONOptions;
export type GotBufferOptions = OptionsOfBufferResponseBody & GotExtraOptions;
export type GotJSONOptions = OptionsOfJSONResponseBody & GotExtraOptions;
export type GotExtraOptions = {
abortOnError?: boolean;
abortIgnoreStatusCodes?: number[];
token?: string;
hostType?: string;
enabled?: boolean;
useCache?: boolean;
noAuth?: boolean;
context?: GotContextOptions;
};
export interface RequestStats {
method: string;
url: string;
duration: number;
queueDuration: number;
statusCode: number;
}
export type OutgoingHttpHeaders = Record<string, string | string[] | undefined>;
export interface GraphqlVariables {
[k: string]: unknown;
}
export interface GraphqlOptions {
variables?: GraphqlVariables;
paginate?: boolean;
count?: number;
limit?: number;
cursor?: string | null;
acceptHeader?: string;
}
export interface HttpOptions {
body?: any;
username?: string;
password?: string;
baseUrl?: string;
headers?: OutgoingHttpHeaders;
/**
* Do not use authentication
*/
noAuth?: boolean;
throwHttpErrors?: boolean;
token?: string;
useCache?: boolean;
}
export interface HttpPostOptions extends HttpOptions {
body: unknown;
}
export interface InternalHttpOptions extends HttpOptions {
json?: Record<string, unknown>;
responseType?: 'json' | 'buffer';
method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head';
}
export interface HttpHeaders extends IncomingHttpHeaders {
link?: string | undefined;
}
export interface HttpResponse<T = string> {
statusCode: number;
body: T;
headers: HttpHeaders;
authorization?: boolean;
}