/
http-client-types.ts
78 lines (69 loc) · 1.5 KB
/
http-client-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
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import * as http from 'http';
import { MapType } from '@sap-cloud-sdk/util';
export interface DestinationHttpRequestConfig {
baseURL: string;
headers: MapType<string>;
httpAgent?: http.Agent;
httpsAgent?: http.Agent;
}
type Method =
| 'get'
| 'GET'
| 'delete'
| 'DELETE'
| 'head'
| 'HEAD'
| 'options'
| 'OPTIONS'
| 'post'
| 'POST'
| 'put'
| 'PUT'
| 'patch'
| 'PATCH';
/**
* @deprecated Since v1.20.0. Use method string directly, e. g. 'get' or 'GET'.
*/
export enum HttpMethod {
GET = 'GET',
DELETE = 'DELETE',
HEAD = 'HEAD',
OPTIONS = 'OPTIONS',
POST = 'POST',
PUT = 'PUT',
PATCH = 'PATCH'
}
/**
* This interface is compatible with AxiosRequestConfig.
*/
export interface HttpRequestConfig {
url?: string;
method: Method;
data?: any;
params?: MapType<string>;
timeout?: number;
maxContentLength?: number;
headers?: any;
proxy?: false;
httpAgent?: any;
httpsAgent?: any;
}
export type HttpRequest = DestinationHttpRequestConfig & HttpRequestConfig;
export type ExecuteHttpRequestFn = (
request: HttpRequest
) => Promise<HttpResponse>;
interface KnownHttpResponseFields {
data: any;
status: number;
headers: any;
}
export interface HttpResponse extends KnownHttpResponseFields {
[otherKey: string]: any;
}
/**
* @deprecated Since v1.6.4. Use [[HttpResponse]] instead.
*/
export interface HttpReponse extends KnownHttpResponseFields {
[otherKey: string]: any;
}