@swimlane/turbine-sdk 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -658
- package/README.md +784 -125
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/oclif.manifest.json +1 -0
- package/package.json +98 -79
- package/dist/Sensor/BaseSensor.d.ts +0 -9
- package/dist/Sensor/BaseSensor.js +0 -10
- package/dist/Sensor/HttpSensorAgentInterface.d.ts +0 -21
- package/dist/Sensor/HttpSensorAgentInterface.js +0 -81
- package/dist/Sensor/MockSensorAgentInterface.d.ts +0 -22
- package/dist/Sensor/MockSensorAgentInterface.js +0 -76
- package/dist/Sensor/SensorAgentInterface.d.ts +0 -17
- package/dist/Sensor/SensorAgentInterface.js +0 -24
- package/dist/Sensor/SensorConfig.d.ts +0 -24
- package/dist/Sensor/SensorConfig.js +0 -3
- package/dist/Sensor/index.d.ts +0 -5
- package/dist/Sensor/index.js +0 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -7
- package/node_modules/axios/CHANGELOG.md +0 -348
- package/node_modules/axios/LICENSE +0 -19
- package/node_modules/axios/README.md +0 -684
- package/node_modules/axios/UPGRADE_GUIDE.md +0 -162
- package/node_modules/axios/dist/axios.js +0 -1668
- package/node_modules/axios/dist/axios.map +0 -1
- package/node_modules/axios/dist/axios.min.js +0 -9
- package/node_modules/axios/dist/axios.min.map +0 -1
- package/node_modules/axios/index.d.ts +0 -152
- package/node_modules/axios/index.js +0 -1
- package/node_modules/axios/lib/adapters/README.md +0 -37
- package/node_modules/axios/lib/adapters/http.js +0 -275
- package/node_modules/axios/lib/adapters/xhr.js +0 -174
- package/node_modules/axios/lib/axios.js +0 -53
- package/node_modules/axios/lib/cancel/Cancel.js +0 -19
- package/node_modules/axios/lib/cancel/CancelToken.js +0 -57
- package/node_modules/axios/lib/cancel/isCancel.js +0 -5
- package/node_modules/axios/lib/core/Axios.js +0 -86
- package/node_modules/axios/lib/core/InterceptorManager.js +0 -52
- package/node_modules/axios/lib/core/README.md +0 -7
- package/node_modules/axios/lib/core/createError.js +0 -18
- package/node_modules/axios/lib/core/dispatchRequest.js +0 -86
- package/node_modules/axios/lib/core/enhanceError.js +0 -42
- package/node_modules/axios/lib/core/mergeConfig.js +0 -51
- package/node_modules/axios/lib/core/settle.js +0 -25
- package/node_modules/axios/lib/core/transformData.js +0 -20
- package/node_modules/axios/lib/defaults.js +0 -98
- package/node_modules/axios/lib/helpers/README.md +0 -7
- package/node_modules/axios/lib/helpers/bind.js +0 -11
- package/node_modules/axios/lib/helpers/buildURL.js +0 -71
- package/node_modules/axios/lib/helpers/combineURLs.js +0 -14
- package/node_modules/axios/lib/helpers/cookies.js +0 -53
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -24
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -14
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -68
- package/node_modules/axios/lib/helpers/normalizeHeaderName.js +0 -12
- package/node_modules/axios/lib/helpers/parseHeaders.js +0 -53
- package/node_modules/axios/lib/helpers/spread.js +0 -27
- package/node_modules/axios/lib/utils.js +0 -334
- package/node_modules/axios/package.json +0 -115
- package/node_modules/debug/.coveralls.yml +0 -1
- package/node_modules/debug/.eslintrc +0 -14
- package/node_modules/debug/.npmignore +0 -9
- package/node_modules/debug/.travis.yml +0 -20
- package/node_modules/debug/CHANGELOG.md +0 -395
- package/node_modules/debug/LICENSE +0 -19
- package/node_modules/debug/Makefile +0 -58
- package/node_modules/debug/README.md +0 -368
- package/node_modules/debug/karma.conf.js +0 -70
- package/node_modules/debug/node.js +0 -1
- package/node_modules/debug/package.json +0 -87
- package/node_modules/debug/src/browser.js +0 -195
- package/node_modules/debug/src/debug.js +0 -225
- package/node_modules/debug/src/index.js +0 -10
- package/node_modules/debug/src/node.js +0 -186
- package/node_modules/follow-redirects/LICENSE +0 -18
- package/node_modules/follow-redirects/README.md +0 -155
- package/node_modules/follow-redirects/http.js +0 -1
- package/node_modules/follow-redirects/https.js +0 -1
- package/node_modules/follow-redirects/index.js +0 -322
- package/node_modules/follow-redirects/package.json +0 -99
- package/node_modules/is-buffer/LICENSE +0 -21
- package/node_modules/is-buffer/README.md +0 -56
- package/node_modules/is-buffer/index.d.ts +0 -2
- package/node_modules/is-buffer/index.js +0 -11
- package/node_modules/is-buffer/package.json +0 -81
- package/node_modules/ms/index.js +0 -152
- package/node_modules/ms/license.md +0 -21
- package/node_modules/ms/package.json +0 -73
- package/node_modules/ms/readme.md +0 -51
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
export interface AxiosTransformer {
|
|
2
|
-
(data: any, headers?: any): any;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface AxiosAdapter {
|
|
6
|
-
(config: AxiosRequestConfig): AxiosPromise<any>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AxiosBasicCredentials {
|
|
10
|
-
username: string;
|
|
11
|
-
password: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface AxiosProxyConfig {
|
|
15
|
-
host: string;
|
|
16
|
-
port: number;
|
|
17
|
-
auth?: {
|
|
18
|
-
username: string;
|
|
19
|
-
password:string;
|
|
20
|
-
};
|
|
21
|
-
protocol?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type Method =
|
|
25
|
-
| 'get' | 'GET'
|
|
26
|
-
| 'delete' | 'DELETE'
|
|
27
|
-
| 'head' | 'HEAD'
|
|
28
|
-
| 'options' | 'OPTIONS'
|
|
29
|
-
| 'post' | 'POST'
|
|
30
|
-
| 'put' | 'PUT'
|
|
31
|
-
| 'patch' | 'PATCH'
|
|
32
|
-
|
|
33
|
-
export type ResponseType =
|
|
34
|
-
| 'arraybuffer'
|
|
35
|
-
| 'blob'
|
|
36
|
-
| 'document'
|
|
37
|
-
| 'json'
|
|
38
|
-
| 'text'
|
|
39
|
-
| 'stream'
|
|
40
|
-
|
|
41
|
-
export interface AxiosRequestConfig {
|
|
42
|
-
url?: string;
|
|
43
|
-
method?: Method;
|
|
44
|
-
baseURL?: string;
|
|
45
|
-
transformRequest?: AxiosTransformer | AxiosTransformer[];
|
|
46
|
-
transformResponse?: AxiosTransformer | AxiosTransformer[];
|
|
47
|
-
headers?: any;
|
|
48
|
-
params?: any;
|
|
49
|
-
paramsSerializer?: (params: any) => string;
|
|
50
|
-
data?: any;
|
|
51
|
-
timeout?: number;
|
|
52
|
-
withCredentials?: boolean;
|
|
53
|
-
adapter?: AxiosAdapter;
|
|
54
|
-
auth?: AxiosBasicCredentials;
|
|
55
|
-
responseType?: ResponseType;
|
|
56
|
-
xsrfCookieName?: string;
|
|
57
|
-
xsrfHeaderName?: string;
|
|
58
|
-
onUploadProgress?: (progressEvent: any) => void;
|
|
59
|
-
onDownloadProgress?: (progressEvent: any) => void;
|
|
60
|
-
maxContentLength?: number;
|
|
61
|
-
validateStatus?: (status: number) => boolean;
|
|
62
|
-
maxRedirects?: number;
|
|
63
|
-
socketPath?: string | null;
|
|
64
|
-
httpAgent?: any;
|
|
65
|
-
httpsAgent?: any;
|
|
66
|
-
proxy?: AxiosProxyConfig | false;
|
|
67
|
-
cancelToken?: CancelToken;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface AxiosResponse<T = any> {
|
|
71
|
-
data: T;
|
|
72
|
-
status: number;
|
|
73
|
-
statusText: string;
|
|
74
|
-
headers: any;
|
|
75
|
-
config: AxiosRequestConfig;
|
|
76
|
-
request?: any;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface AxiosError<T = any> extends Error {
|
|
80
|
-
config: AxiosRequestConfig;
|
|
81
|
-
code?: string;
|
|
82
|
-
request?: any;
|
|
83
|
-
response?: AxiosResponse<T>;
|
|
84
|
-
isAxiosError: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface CancelStatic {
|
|
91
|
-
new (message?: string): Cancel;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface Cancel {
|
|
95
|
-
message: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface Canceler {
|
|
99
|
-
(message?: string): void;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface CancelTokenStatic {
|
|
103
|
-
new (executor: (cancel: Canceler) => void): CancelToken;
|
|
104
|
-
source(): CancelTokenSource;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface CancelToken {
|
|
108
|
-
promise: Promise<Cancel>;
|
|
109
|
-
reason?: Cancel;
|
|
110
|
-
throwIfRequested(): void;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface CancelTokenSource {
|
|
114
|
-
token: CancelToken;
|
|
115
|
-
cancel: Canceler;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface AxiosInterceptorManager<V> {
|
|
119
|
-
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
|
|
120
|
-
eject(id: number): void;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface AxiosInstance {
|
|
124
|
-
(config: AxiosRequestConfig): AxiosPromise;
|
|
125
|
-
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
|
126
|
-
defaults: AxiosRequestConfig;
|
|
127
|
-
interceptors: {
|
|
128
|
-
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
|
129
|
-
response: AxiosInterceptorManager<AxiosResponse>;
|
|
130
|
-
};
|
|
131
|
-
getUri(config?: AxiosRequestConfig): string;
|
|
132
|
-
request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
|
|
133
|
-
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
134
|
-
delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
135
|
-
head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
136
|
-
post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
137
|
-
put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
138
|
-
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface AxiosStatic extends AxiosInstance {
|
|
142
|
-
create(config?: AxiosRequestConfig): AxiosInstance;
|
|
143
|
-
Cancel: CancelStatic;
|
|
144
|
-
CancelToken: CancelTokenStatic;
|
|
145
|
-
isCancel(value: any): boolean;
|
|
146
|
-
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
|
147
|
-
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
declare const Axios: AxiosStatic;
|
|
151
|
-
|
|
152
|
-
export default Axios;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/axios');
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# axios // adapters
|
|
2
|
-
|
|
3
|
-
The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
|
|
4
|
-
|
|
5
|
-
## Example
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
var settle = require('./../core/settle');
|
|
9
|
-
|
|
10
|
-
module.exports = function myAdapter(config) {
|
|
11
|
-
// At this point:
|
|
12
|
-
// - config has been merged with defaults
|
|
13
|
-
// - request transformers have already run
|
|
14
|
-
// - request interceptors have already run
|
|
15
|
-
|
|
16
|
-
// Make the request using config provided
|
|
17
|
-
// Upon response settle the Promise
|
|
18
|
-
|
|
19
|
-
return new Promise(function(resolve, reject) {
|
|
20
|
-
|
|
21
|
-
var response = {
|
|
22
|
-
data: responseData,
|
|
23
|
-
status: request.status,
|
|
24
|
-
statusText: request.statusText,
|
|
25
|
-
headers: responseHeaders,
|
|
26
|
-
config: config,
|
|
27
|
-
request: request
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
settle(resolve, reject, response);
|
|
31
|
-
|
|
32
|
-
// From here:
|
|
33
|
-
// - response transformers will run
|
|
34
|
-
// - response interceptors will run
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
```
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('./../utils');
|
|
4
|
-
var settle = require('./../core/settle');
|
|
5
|
-
var buildURL = require('./../helpers/buildURL');
|
|
6
|
-
var http = require('http');
|
|
7
|
-
var https = require('https');
|
|
8
|
-
var httpFollow = require('follow-redirects').http;
|
|
9
|
-
var httpsFollow = require('follow-redirects').https;
|
|
10
|
-
var url = require('url');
|
|
11
|
-
var zlib = require('zlib');
|
|
12
|
-
var pkg = require('./../../package.json');
|
|
13
|
-
var createError = require('../core/createError');
|
|
14
|
-
var enhanceError = require('../core/enhanceError');
|
|
15
|
-
|
|
16
|
-
var isHttps = /https:?/;
|
|
17
|
-
|
|
18
|
-
/*eslint consistent-return:0*/
|
|
19
|
-
module.exports = function httpAdapter(config) {
|
|
20
|
-
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
|
21
|
-
var timer;
|
|
22
|
-
var resolve = function resolve(value) {
|
|
23
|
-
clearTimeout(timer);
|
|
24
|
-
resolvePromise(value);
|
|
25
|
-
};
|
|
26
|
-
var reject = function reject(value) {
|
|
27
|
-
clearTimeout(timer);
|
|
28
|
-
rejectPromise(value);
|
|
29
|
-
};
|
|
30
|
-
var data = config.data;
|
|
31
|
-
var headers = config.headers;
|
|
32
|
-
|
|
33
|
-
// Set User-Agent (required by some servers)
|
|
34
|
-
// Only set header if it hasn't been set in config
|
|
35
|
-
// See https://github.com/axios/axios/issues/69
|
|
36
|
-
if (!headers['User-Agent'] && !headers['user-agent']) {
|
|
37
|
-
headers['User-Agent'] = 'axios/' + pkg.version;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (data && !utils.isStream(data)) {
|
|
41
|
-
if (Buffer.isBuffer(data)) {
|
|
42
|
-
// Nothing to do...
|
|
43
|
-
} else if (utils.isArrayBuffer(data)) {
|
|
44
|
-
data = Buffer.from(new Uint8Array(data));
|
|
45
|
-
} else if (utils.isString(data)) {
|
|
46
|
-
data = Buffer.from(data, 'utf-8');
|
|
47
|
-
} else {
|
|
48
|
-
return reject(createError(
|
|
49
|
-
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
|
50
|
-
config
|
|
51
|
-
));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Add Content-Length header if data exists
|
|
55
|
-
headers['Content-Length'] = data.length;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// HTTP basic authentication
|
|
59
|
-
var auth = undefined;
|
|
60
|
-
if (config.auth) {
|
|
61
|
-
var username = config.auth.username || '';
|
|
62
|
-
var password = config.auth.password || '';
|
|
63
|
-
auth = username + ':' + password;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Parse url
|
|
67
|
-
var parsed = url.parse(config.url);
|
|
68
|
-
var protocol = parsed.protocol || 'http:';
|
|
69
|
-
|
|
70
|
-
if (!auth && parsed.auth) {
|
|
71
|
-
var urlAuth = parsed.auth.split(':');
|
|
72
|
-
var urlUsername = urlAuth[0] || '';
|
|
73
|
-
var urlPassword = urlAuth[1] || '';
|
|
74
|
-
auth = urlUsername + ':' + urlPassword;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (auth) {
|
|
78
|
-
delete headers.Authorization;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var isHttpsRequest = isHttps.test(protocol);
|
|
82
|
-
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
83
|
-
|
|
84
|
-
var options = {
|
|
85
|
-
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
|
86
|
-
method: config.method.toUpperCase(),
|
|
87
|
-
headers: headers,
|
|
88
|
-
agent: agent,
|
|
89
|
-
auth: auth
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
if (config.socketPath) {
|
|
93
|
-
options.socketPath = config.socketPath;
|
|
94
|
-
} else {
|
|
95
|
-
options.hostname = parsed.hostname;
|
|
96
|
-
options.port = parsed.port;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var proxy = config.proxy;
|
|
100
|
-
if (!proxy && proxy !== false) {
|
|
101
|
-
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
|
102
|
-
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
|
|
103
|
-
if (proxyUrl) {
|
|
104
|
-
var parsedProxyUrl = url.parse(proxyUrl);
|
|
105
|
-
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
|
|
106
|
-
var shouldProxy = true;
|
|
107
|
-
|
|
108
|
-
if (noProxyEnv) {
|
|
109
|
-
var noProxy = noProxyEnv.split(',').map(function trim(s) {
|
|
110
|
-
return s.trim();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
|
|
114
|
-
if (!proxyElement) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (proxyElement === '*') {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
if (proxyElement[0] === '.' &&
|
|
121
|
-
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement &&
|
|
122
|
-
proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return parsed.hostname === proxyElement;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (shouldProxy) {
|
|
132
|
-
proxy = {
|
|
133
|
-
host: parsedProxyUrl.hostname,
|
|
134
|
-
port: parsedProxyUrl.port
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
if (parsedProxyUrl.auth) {
|
|
138
|
-
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
|
|
139
|
-
proxy.auth = {
|
|
140
|
-
username: proxyUrlAuth[0],
|
|
141
|
-
password: proxyUrlAuth[1]
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (proxy) {
|
|
149
|
-
options.hostname = proxy.host;
|
|
150
|
-
options.host = proxy.host;
|
|
151
|
-
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
|
|
152
|
-
options.port = proxy.port;
|
|
153
|
-
options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
|
|
154
|
-
|
|
155
|
-
// Basic proxy authorization
|
|
156
|
-
if (proxy.auth) {
|
|
157
|
-
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
|
|
158
|
-
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
var transport;
|
|
163
|
-
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
|
|
164
|
-
if (config.transport) {
|
|
165
|
-
transport = config.transport;
|
|
166
|
-
} else if (config.maxRedirects === 0) {
|
|
167
|
-
transport = isHttpsProxy ? https : http;
|
|
168
|
-
} else {
|
|
169
|
-
if (config.maxRedirects) {
|
|
170
|
-
options.maxRedirects = config.maxRedirects;
|
|
171
|
-
}
|
|
172
|
-
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (config.maxContentLength && config.maxContentLength > -1) {
|
|
176
|
-
options.maxBodyLength = config.maxContentLength;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Create the request
|
|
180
|
-
var req = transport.request(options, function handleResponse(res) {
|
|
181
|
-
if (req.aborted) return;
|
|
182
|
-
|
|
183
|
-
// uncompress the response body transparently if required
|
|
184
|
-
var stream = res;
|
|
185
|
-
switch (res.headers['content-encoding']) {
|
|
186
|
-
/*eslint default-case:0*/
|
|
187
|
-
case 'gzip':
|
|
188
|
-
case 'compress':
|
|
189
|
-
case 'deflate':
|
|
190
|
-
// add the unzipper to the body stream processing pipeline
|
|
191
|
-
stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
|
|
192
|
-
|
|
193
|
-
// remove the content-encoding in order to not confuse downstream operations
|
|
194
|
-
delete res.headers['content-encoding'];
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// return the last request in case of redirects
|
|
199
|
-
var lastRequest = res.req || req;
|
|
200
|
-
|
|
201
|
-
var response = {
|
|
202
|
-
status: res.statusCode,
|
|
203
|
-
statusText: res.statusMessage,
|
|
204
|
-
headers: res.headers,
|
|
205
|
-
config: config,
|
|
206
|
-
request: lastRequest
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
if (config.responseType === 'stream') {
|
|
210
|
-
response.data = stream;
|
|
211
|
-
settle(resolve, reject, response);
|
|
212
|
-
} else {
|
|
213
|
-
var responseBuffer = [];
|
|
214
|
-
stream.on('data', function handleStreamData(chunk) {
|
|
215
|
-
responseBuffer.push(chunk);
|
|
216
|
-
|
|
217
|
-
// make sure the content length is not over the maxContentLength if specified
|
|
218
|
-
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
|
|
219
|
-
stream.destroy();
|
|
220
|
-
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
221
|
-
config, null, lastRequest));
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
stream.on('error', function handleStreamError(err) {
|
|
226
|
-
if (req.aborted) return;
|
|
227
|
-
reject(enhanceError(err, config, null, lastRequest));
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
stream.on('end', function handleStreamEnd() {
|
|
231
|
-
var responseData = Buffer.concat(responseBuffer);
|
|
232
|
-
if (config.responseType !== 'arraybuffer') {
|
|
233
|
-
responseData = responseData.toString(config.responseEncoding);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
response.data = responseData;
|
|
237
|
-
settle(resolve, reject, response);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// Handle errors
|
|
243
|
-
req.on('error', function handleRequestError(err) {
|
|
244
|
-
if (req.aborted) return;
|
|
245
|
-
reject(enhanceError(err, config, null, req));
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// Handle request timeout
|
|
249
|
-
if (config.timeout) {
|
|
250
|
-
timer = setTimeout(function handleRequestTimeout() {
|
|
251
|
-
req.abort();
|
|
252
|
-
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
|
|
253
|
-
}, config.timeout);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (config.cancelToken) {
|
|
257
|
-
// Handle cancellation
|
|
258
|
-
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
259
|
-
if (req.aborted) return;
|
|
260
|
-
|
|
261
|
-
req.abort();
|
|
262
|
-
reject(cancel);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Send the request
|
|
267
|
-
if (utils.isStream(data)) {
|
|
268
|
-
data.on('error', function handleStreamError(err) {
|
|
269
|
-
reject(enhanceError(err, config, null, req));
|
|
270
|
-
}).pipe(req);
|
|
271
|
-
} else {
|
|
272
|
-
req.end(data);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('./../utils');
|
|
4
|
-
var settle = require('./../core/settle');
|
|
5
|
-
var buildURL = require('./../helpers/buildURL');
|
|
6
|
-
var parseHeaders = require('./../helpers/parseHeaders');
|
|
7
|
-
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
|
|
8
|
-
var createError = require('../core/createError');
|
|
9
|
-
|
|
10
|
-
module.exports = function xhrAdapter(config) {
|
|
11
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
12
|
-
var requestData = config.data;
|
|
13
|
-
var requestHeaders = config.headers;
|
|
14
|
-
|
|
15
|
-
if (utils.isFormData(requestData)) {
|
|
16
|
-
delete requestHeaders['Content-Type']; // Let the browser set it
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var request = new XMLHttpRequest();
|
|
20
|
-
|
|
21
|
-
// HTTP basic authentication
|
|
22
|
-
if (config.auth) {
|
|
23
|
-
var username = config.auth.username || '';
|
|
24
|
-
var password = config.auth.password || '';
|
|
25
|
-
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
|
|
29
|
-
|
|
30
|
-
// Set the request timeout in MS
|
|
31
|
-
request.timeout = config.timeout;
|
|
32
|
-
|
|
33
|
-
// Listen for ready state
|
|
34
|
-
request.onreadystatechange = function handleLoad() {
|
|
35
|
-
if (!request || request.readyState !== 4) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// The request errored out and we didn't get a response, this will be
|
|
40
|
-
// handled by onerror instead
|
|
41
|
-
// With one exception: request that using file: protocol, most browsers
|
|
42
|
-
// will return status as 0 even though it's a successful request
|
|
43
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Prepare the response
|
|
48
|
-
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
|
49
|
-
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
|
50
|
-
var response = {
|
|
51
|
-
data: responseData,
|
|
52
|
-
status: request.status,
|
|
53
|
-
statusText: request.statusText,
|
|
54
|
-
headers: responseHeaders,
|
|
55
|
-
config: config,
|
|
56
|
-
request: request
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
settle(resolve, reject, response);
|
|
60
|
-
|
|
61
|
-
// Clean up request
|
|
62
|
-
request = null;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
66
|
-
request.onabort = function handleAbort() {
|
|
67
|
-
if (!request) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
reject(createError('Request aborted', config, 'ECONNABORTED', request));
|
|
72
|
-
|
|
73
|
-
// Clean up request
|
|
74
|
-
request = null;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Handle low level network errors
|
|
78
|
-
request.onerror = function handleError() {
|
|
79
|
-
// Real errors are hidden from us by the browser
|
|
80
|
-
// onerror should only fire if it's a network error
|
|
81
|
-
reject(createError('Network Error', config, null, request));
|
|
82
|
-
|
|
83
|
-
// Clean up request
|
|
84
|
-
request = null;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// Handle timeout
|
|
88
|
-
request.ontimeout = function handleTimeout() {
|
|
89
|
-
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
|
|
90
|
-
request));
|
|
91
|
-
|
|
92
|
-
// Clean up request
|
|
93
|
-
request = null;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// Add xsrf header
|
|
97
|
-
// This is only done if running in a standard browser environment.
|
|
98
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
99
|
-
if (utils.isStandardBrowserEnv()) {
|
|
100
|
-
var cookies = require('./../helpers/cookies');
|
|
101
|
-
|
|
102
|
-
// Add xsrf header
|
|
103
|
-
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
|
|
104
|
-
cookies.read(config.xsrfCookieName) :
|
|
105
|
-
undefined;
|
|
106
|
-
|
|
107
|
-
if (xsrfValue) {
|
|
108
|
-
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Add headers to the request
|
|
113
|
-
if ('setRequestHeader' in request) {
|
|
114
|
-
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
115
|
-
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
|
116
|
-
// Remove Content-Type if data is undefined
|
|
117
|
-
delete requestHeaders[key];
|
|
118
|
-
} else {
|
|
119
|
-
// Otherwise add header to the request
|
|
120
|
-
request.setRequestHeader(key, val);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Add withCredentials to request if needed
|
|
126
|
-
if (config.withCredentials) {
|
|
127
|
-
request.withCredentials = true;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Add responseType to request if needed
|
|
131
|
-
if (config.responseType) {
|
|
132
|
-
try {
|
|
133
|
-
request.responseType = config.responseType;
|
|
134
|
-
} catch (e) {
|
|
135
|
-
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
|
|
136
|
-
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
|
|
137
|
-
if (config.responseType !== 'json') {
|
|
138
|
-
throw e;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Handle progress if needed
|
|
144
|
-
if (typeof config.onDownloadProgress === 'function') {
|
|
145
|
-
request.addEventListener('progress', config.onDownloadProgress);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Not all browsers support upload events
|
|
149
|
-
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
|
150
|
-
request.upload.addEventListener('progress', config.onUploadProgress);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (config.cancelToken) {
|
|
154
|
-
// Handle cancellation
|
|
155
|
-
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
156
|
-
if (!request) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
request.abort();
|
|
161
|
-
reject(cancel);
|
|
162
|
-
// Clean up request
|
|
163
|
-
request = null;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (requestData === undefined) {
|
|
168
|
-
requestData = null;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Send the request
|
|
172
|
-
request.send(requestData);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('./utils');
|
|
4
|
-
var bind = require('./helpers/bind');
|
|
5
|
-
var Axios = require('./core/Axios');
|
|
6
|
-
var mergeConfig = require('./core/mergeConfig');
|
|
7
|
-
var defaults = require('./defaults');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create an instance of Axios
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} defaultConfig The default config for the instance
|
|
13
|
-
* @return {Axios} A new instance of Axios
|
|
14
|
-
*/
|
|
15
|
-
function createInstance(defaultConfig) {
|
|
16
|
-
var context = new Axios(defaultConfig);
|
|
17
|
-
var instance = bind(Axios.prototype.request, context);
|
|
18
|
-
|
|
19
|
-
// Copy axios.prototype to instance
|
|
20
|
-
utils.extend(instance, Axios.prototype, context);
|
|
21
|
-
|
|
22
|
-
// Copy context to instance
|
|
23
|
-
utils.extend(instance, context);
|
|
24
|
-
|
|
25
|
-
return instance;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Create the default instance to be exported
|
|
29
|
-
var axios = createInstance(defaults);
|
|
30
|
-
|
|
31
|
-
// Expose Axios class to allow class inheritance
|
|
32
|
-
axios.Axios = Axios;
|
|
33
|
-
|
|
34
|
-
// Factory for creating new instances
|
|
35
|
-
axios.create = function create(instanceConfig) {
|
|
36
|
-
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Expose Cancel & CancelToken
|
|
40
|
-
axios.Cancel = require('./cancel/Cancel');
|
|
41
|
-
axios.CancelToken = require('./cancel/CancelToken');
|
|
42
|
-
axios.isCancel = require('./cancel/isCancel');
|
|
43
|
-
|
|
44
|
-
// Expose all/spread
|
|
45
|
-
axios.all = function all(promises) {
|
|
46
|
-
return Promise.all(promises);
|
|
47
|
-
};
|
|
48
|
-
axios.spread = require('./helpers/spread');
|
|
49
|
-
|
|
50
|
-
module.exports = axios;
|
|
51
|
-
|
|
52
|
-
// Allow use of default import syntax in TypeScript
|
|
53
|
-
module.exports.default = axios;
|