@openfn/language-dhis2 2.0.11 → 3.0.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/README.md +39 -4
- package/ast.json +270 -2458
- package/lib/Adaptor.js +469 -1533
- package/lib/Client.js +32 -0
- package/lib/Utils.js +124 -175
- package/lib/index.js +4 -6
- package/node_modules/@openfn/language-common/node_modules/axios/package.json +20 -0
- package/node_modules/@openfn/language-common/node_modules/follow-redirects/package.json +20 -0
- package/node_modules/@openfn/language-common/node_modules/jsonpath-plus/package.json +20 -0
- package/node_modules/@openfn/language-common/node_modules/lodash/package.json +20 -0
- package/node_modules/@openfn/language-common/package.json +8 -4
- package/node_modules/axios/CHANGELOG.md +159 -8
- package/node_modules/axios/README.md +98 -6
- package/node_modules/axios/SECURITY.md +5 -0
- package/node_modules/axios/dist/axios.js +2101 -1582
- package/node_modules/axios/dist/axios.map +1 -1
- package/node_modules/axios/dist/axios.min.js +1 -2
- package/node_modules/axios/dist/axios.min.map +1 -1
- package/node_modules/axios/index.d.ts +76 -31
- package/node_modules/axios/lib/adapters/http.js +74 -14
- package/node_modules/axios/lib/adapters/xhr.js +66 -33
- package/node_modules/axios/lib/axios.js +6 -5
- package/node_modules/axios/lib/cancel/CancelToken.js +62 -0
- package/node_modules/axios/lib/core/Axios.js +60 -7
- package/node_modules/axios/lib/core/InterceptorManager.js +4 -2
- package/node_modules/axios/lib/core/README.md +1 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +11 -3
- package/node_modules/axios/lib/core/enhanceError.js +2 -1
- package/node_modules/axios/lib/core/mergeConfig.js +50 -38
- package/node_modules/axios/lib/core/transformData.js +3 -1
- package/node_modules/axios/lib/defaults.js +48 -12
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/data.js +3 -0
- package/node_modules/axios/lib/helpers/validator.js +82 -0
- package/node_modules/axios/lib/utils.js +1 -3
- package/node_modules/axios/package.json +37 -40
- package/node_modules/axios/tsconfig.json +14 -0
- package/node_modules/axios/tslint.json +6 -0
- package/node_modules/follow-redirects/README.md +1 -1
- package/node_modules/follow-redirects/debug.js +14 -8
- package/node_modules/follow-redirects/index.js +106 -41
- package/node_modules/follow-redirects/package.json +14 -17
- package/node_modules/lodash/package.json +2 -2
- package/package.json +5 -4
|
@@ -5,7 +5,9 @@ var buildURL = require('../helpers/buildURL');
|
|
|
5
5
|
var InterceptorManager = require('./InterceptorManager');
|
|
6
6
|
var dispatchRequest = require('./dispatchRequest');
|
|
7
7
|
var mergeConfig = require('./mergeConfig');
|
|
8
|
+
var validator = require('../helpers/validator');
|
|
8
9
|
|
|
10
|
+
var validators = validator.validators;
|
|
9
11
|
/**
|
|
10
12
|
* Create a new instance of Axios
|
|
11
13
|
*
|
|
@@ -45,20 +47,71 @@ Axios.prototype.request = function request(config) {
|
|
|
45
47
|
config.method = 'get';
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
var chain = [dispatchRequest, undefined];
|
|
50
|
-
var promise = Promise.resolve(config);
|
|
50
|
+
var transitional = config.transitional;
|
|
51
51
|
|
|
52
|
+
if (transitional !== undefined) {
|
|
53
|
+
validator.assertOptions(transitional, {
|
|
54
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
55
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
56
|
+
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
57
|
+
}, false);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// filter out skipped interceptors
|
|
61
|
+
var requestInterceptorChain = [];
|
|
62
|
+
var synchronousRequestInterceptors = true;
|
|
52
63
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
53
|
-
|
|
64
|
+
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
69
|
+
|
|
70
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
54
71
|
});
|
|
55
72
|
|
|
73
|
+
var responseInterceptorChain = [];
|
|
56
74
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
57
|
-
|
|
75
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
58
76
|
});
|
|
59
77
|
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
var promise;
|
|
79
|
+
|
|
80
|
+
if (!synchronousRequestInterceptors) {
|
|
81
|
+
var chain = [dispatchRequest, undefined];
|
|
82
|
+
|
|
83
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
84
|
+
chain = chain.concat(responseInterceptorChain);
|
|
85
|
+
|
|
86
|
+
promise = Promise.resolve(config);
|
|
87
|
+
while (chain.length) {
|
|
88
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return promise;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
var newConfig = config;
|
|
96
|
+
while (requestInterceptorChain.length) {
|
|
97
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
98
|
+
var onRejected = requestInterceptorChain.shift();
|
|
99
|
+
try {
|
|
100
|
+
newConfig = onFulfilled(newConfig);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
onRejected(error);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
promise = dispatchRequest(newConfig);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return Promise.reject(error);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
while (responseInterceptorChain.length) {
|
|
114
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
62
115
|
}
|
|
63
116
|
|
|
64
117
|
return promise;
|
|
@@ -14,10 +14,12 @@ function InterceptorManager() {
|
|
|
14
14
|
*
|
|
15
15
|
* @return {Number} An ID used to remove interceptor later
|
|
16
16
|
*/
|
|
17
|
-
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
|
17
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
|
|
18
18
|
this.handlers.push({
|
|
19
19
|
fulfilled: fulfilled,
|
|
20
|
-
rejected: rejected
|
|
20
|
+
rejected: rejected,
|
|
21
|
+
synchronous: options ? options.synchronous : false,
|
|
22
|
+
runWhen: options ? options.runWhen : null
|
|
21
23
|
});
|
|
22
24
|
return this.handlers.length - 1;
|
|
23
25
|
};
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
|
|
4
4
|
|
|
5
5
|
- Dispatching requests
|
|
6
|
+
- Requests sent via `adapters/` (see lib/adapters/README.md)
|
|
6
7
|
- Managing interceptors
|
|
7
8
|
- Handling config
|
|
@@ -4,6 +4,7 @@ var utils = require('./../utils');
|
|
|
4
4
|
var transformData = require('./transformData');
|
|
5
5
|
var isCancel = require('../cancel/isCancel');
|
|
6
6
|
var defaults = require('../defaults');
|
|
7
|
+
var Cancel = require('../cancel/Cancel');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Throws a `Cancel` if cancellation has been requested.
|
|
@@ -12,6 +13,10 @@ function throwIfCancellationRequested(config) {
|
|
|
12
13
|
if (config.cancelToken) {
|
|
13
14
|
config.cancelToken.throwIfRequested();
|
|
14
15
|
}
|
|
16
|
+
|
|
17
|
+
if (config.signal && config.signal.aborted) {
|
|
18
|
+
throw new Cancel('canceled');
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
/**
|
|
@@ -27,7 +32,8 @@ module.exports = function dispatchRequest(config) {
|
|
|
27
32
|
config.headers = config.headers || {};
|
|
28
33
|
|
|
29
34
|
// Transform request data
|
|
30
|
-
config.data = transformData(
|
|
35
|
+
config.data = transformData.call(
|
|
36
|
+
config,
|
|
31
37
|
config.data,
|
|
32
38
|
config.headers,
|
|
33
39
|
config.transformRequest
|
|
@@ -53,7 +59,8 @@ module.exports = function dispatchRequest(config) {
|
|
|
53
59
|
throwIfCancellationRequested(config);
|
|
54
60
|
|
|
55
61
|
// Transform response data
|
|
56
|
-
response.data = transformData(
|
|
62
|
+
response.data = transformData.call(
|
|
63
|
+
config,
|
|
57
64
|
response.data,
|
|
58
65
|
response.headers,
|
|
59
66
|
config.transformResponse
|
|
@@ -66,7 +73,8 @@ module.exports = function dispatchRequest(config) {
|
|
|
66
73
|
|
|
67
74
|
// Transform response data
|
|
68
75
|
if (reason && reason.response) {
|
|
69
|
-
reason.response.data = transformData(
|
|
76
|
+
reason.response.data = transformData.call(
|
|
77
|
+
config,
|
|
70
78
|
reason.response.data,
|
|
71
79
|
reason.response.headers,
|
|
72
80
|
config.transformResponse
|
|
@@ -35,7 +35,8 @@ module.exports = function enhanceError(error, config, code, request, response) {
|
|
|
35
35
|
stack: this.stack,
|
|
36
36
|
// Axios
|
|
37
37
|
config: this.config,
|
|
38
|
-
code: this.code
|
|
38
|
+
code: this.code,
|
|
39
|
+
status: this.response && this.response.status ? this.response.status : null
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
return error;
|
|
@@ -15,17 +15,6 @@ module.exports = function mergeConfig(config1, config2) {
|
|
|
15
15
|
config2 = config2 || {};
|
|
16
16
|
var config = {};
|
|
17
17
|
|
|
18
|
-
var valueFromConfig2Keys = ['url', 'method', 'data'];
|
|
19
|
-
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
|
|
20
|
-
var defaultToConfig2Keys = [
|
|
21
|
-
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
|
|
22
|
-
'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
|
23
|
-
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
|
|
24
|
-
'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
|
|
25
|
-
'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
|
|
26
|
-
];
|
|
27
|
-
var directMergeKeys = ['validateStatus'];
|
|
28
|
-
|
|
29
18
|
function getMergedValue(target, source) {
|
|
30
19
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
31
20
|
return utils.merge(target, source);
|
|
@@ -37,51 +26,74 @@ module.exports = function mergeConfig(config1, config2) {
|
|
|
37
26
|
return source;
|
|
38
27
|
}
|
|
39
28
|
|
|
29
|
+
// eslint-disable-next-line consistent-return
|
|
40
30
|
function mergeDeepProperties(prop) {
|
|
41
31
|
if (!utils.isUndefined(config2[prop])) {
|
|
42
|
-
|
|
32
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
43
33
|
} else if (!utils.isUndefined(config1[prop])) {
|
|
44
|
-
|
|
34
|
+
return getMergedValue(undefined, config1[prop]);
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
// eslint-disable-next-line consistent-return
|
|
39
|
+
function valueFromConfig2(prop) {
|
|
49
40
|
if (!utils.isUndefined(config2[prop])) {
|
|
50
|
-
|
|
41
|
+
return getMergedValue(undefined, config2[prop]);
|
|
51
42
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
|
43
|
+
}
|
|
55
44
|
|
|
56
|
-
|
|
45
|
+
// eslint-disable-next-line consistent-return
|
|
46
|
+
function defaultToConfig2(prop) {
|
|
57
47
|
if (!utils.isUndefined(config2[prop])) {
|
|
58
|
-
|
|
48
|
+
return getMergedValue(undefined, config2[prop]);
|
|
59
49
|
} else if (!utils.isUndefined(config1[prop])) {
|
|
60
|
-
|
|
50
|
+
return getMergedValue(undefined, config1[prop]);
|
|
61
51
|
}
|
|
62
|
-
}
|
|
52
|
+
}
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
// eslint-disable-next-line consistent-return
|
|
55
|
+
function mergeDirectKeys(prop) {
|
|
65
56
|
if (prop in config2) {
|
|
66
|
-
|
|
57
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
67
58
|
} else if (prop in config1) {
|
|
68
|
-
|
|
59
|
+
return getMergedValue(undefined, config1[prop]);
|
|
69
60
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var axiosKeys = valueFromConfig2Keys
|
|
73
|
-
.concat(mergeDeepPropertiesKeys)
|
|
74
|
-
.concat(defaultToConfig2Keys)
|
|
75
|
-
.concat(directMergeKeys);
|
|
61
|
+
}
|
|
76
62
|
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
var mergeMap = {
|
|
64
|
+
'url': valueFromConfig2,
|
|
65
|
+
'method': valueFromConfig2,
|
|
66
|
+
'data': valueFromConfig2,
|
|
67
|
+
'baseURL': defaultToConfig2,
|
|
68
|
+
'transformRequest': defaultToConfig2,
|
|
69
|
+
'transformResponse': defaultToConfig2,
|
|
70
|
+
'paramsSerializer': defaultToConfig2,
|
|
71
|
+
'timeout': defaultToConfig2,
|
|
72
|
+
'timeoutMessage': defaultToConfig2,
|
|
73
|
+
'withCredentials': defaultToConfig2,
|
|
74
|
+
'adapter': defaultToConfig2,
|
|
75
|
+
'responseType': defaultToConfig2,
|
|
76
|
+
'xsrfCookieName': defaultToConfig2,
|
|
77
|
+
'xsrfHeaderName': defaultToConfig2,
|
|
78
|
+
'onUploadProgress': defaultToConfig2,
|
|
79
|
+
'onDownloadProgress': defaultToConfig2,
|
|
80
|
+
'decompress': defaultToConfig2,
|
|
81
|
+
'maxContentLength': defaultToConfig2,
|
|
82
|
+
'maxBodyLength': defaultToConfig2,
|
|
83
|
+
'transport': defaultToConfig2,
|
|
84
|
+
'httpAgent': defaultToConfig2,
|
|
85
|
+
'httpsAgent': defaultToConfig2,
|
|
86
|
+
'cancelToken': defaultToConfig2,
|
|
87
|
+
'socketPath': defaultToConfig2,
|
|
88
|
+
'responseEncoding': defaultToConfig2,
|
|
89
|
+
'validateStatus': mergeDirectKeys
|
|
90
|
+
};
|
|
83
91
|
|
|
84
|
-
utils.forEach(
|
|
92
|
+
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
93
|
+
var merge = mergeMap[prop] || mergeDeepProperties;
|
|
94
|
+
var configValue = merge(prop);
|
|
95
|
+
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
96
|
+
});
|
|
85
97
|
|
|
86
98
|
return config;
|
|
87
99
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('./../utils');
|
|
4
|
+
var defaults = require('./../defaults');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Transform the data for a request or a response
|
|
@@ -11,9 +12,10 @@ var utils = require('./../utils');
|
|
|
11
12
|
* @returns {*} The resulting transformed data
|
|
12
13
|
*/
|
|
13
14
|
module.exports = function transformData(data, headers, fns) {
|
|
15
|
+
var context = this || defaults;
|
|
14
16
|
/*eslint no-param-reassign:0*/
|
|
15
17
|
utils.forEach(fns, function transform(fn) {
|
|
16
|
-
data = fn(data, headers);
|
|
18
|
+
data = fn.call(context, data, headers);
|
|
17
19
|
});
|
|
18
20
|
|
|
19
21
|
return data;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require('./utils');
|
|
4
4
|
var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
|
5
|
+
var enhanceError = require('./core/enhanceError');
|
|
5
6
|
|
|
6
7
|
var DEFAULT_CONTENT_TYPE = {
|
|
7
8
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
@@ -25,12 +26,35 @@ function getDefaultAdapter() {
|
|
|
25
26
|
return adapter;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
30
|
+
if (utils.isString(rawValue)) {
|
|
31
|
+
try {
|
|
32
|
+
(parser || JSON.parse)(rawValue);
|
|
33
|
+
return utils.trim(rawValue);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
if (e.name !== 'SyntaxError') {
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
var defaults = {
|
|
45
|
+
|
|
46
|
+
transitional: {
|
|
47
|
+
silentJSONParsing: true,
|
|
48
|
+
forcedJSONParsing: true,
|
|
49
|
+
clarifyTimeoutError: false
|
|
50
|
+
},
|
|
51
|
+
|
|
29
52
|
adapter: getDefaultAdapter(),
|
|
30
53
|
|
|
31
54
|
transformRequest: [function transformRequest(data, headers) {
|
|
32
55
|
normalizeHeaderName(headers, 'Accept');
|
|
33
56
|
normalizeHeaderName(headers, 'Content-Type');
|
|
57
|
+
|
|
34
58
|
if (utils.isFormData(data) ||
|
|
35
59
|
utils.isArrayBuffer(data) ||
|
|
36
60
|
utils.isBuffer(data) ||
|
|
@@ -47,20 +71,32 @@ var defaults = {
|
|
|
47
71
|
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
|
48
72
|
return data.toString();
|
|
49
73
|
}
|
|
50
|
-
if (utils.isObject(data)) {
|
|
51
|
-
setContentTypeIfUnset(headers, 'application/json
|
|
52
|
-
return
|
|
74
|
+
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
|
|
75
|
+
setContentTypeIfUnset(headers, 'application/json');
|
|
76
|
+
return stringifySafely(data);
|
|
53
77
|
}
|
|
54
78
|
return data;
|
|
55
79
|
}],
|
|
56
80
|
|
|
57
81
|
transformResponse: [function transformResponse(data) {
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
var transitional = this.transitional || defaults.transitional;
|
|
83
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
84
|
+
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
85
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
|
|
86
|
+
|
|
87
|
+
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
|
60
88
|
try {
|
|
61
|
-
|
|
62
|
-
} catch (e) {
|
|
89
|
+
return JSON.parse(data);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
if (strictJSONParsing) {
|
|
92
|
+
if (e.name === 'SyntaxError') {
|
|
93
|
+
throw enhanceError(e, this, 'E_JSON_PARSE');
|
|
94
|
+
}
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
63
98
|
}
|
|
99
|
+
|
|
64
100
|
return data;
|
|
65
101
|
}],
|
|
66
102
|
|
|
@@ -78,12 +114,12 @@ var defaults = {
|
|
|
78
114
|
|
|
79
115
|
validateStatus: function validateStatus(status) {
|
|
80
116
|
return status >= 200 && status < 300;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
117
|
+
},
|
|
83
118
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
119
|
+
headers: {
|
|
120
|
+
common: {
|
|
121
|
+
'Accept': 'application/json, text/plain, */*'
|
|
122
|
+
}
|
|
87
123
|
}
|
|
88
124
|
};
|
|
89
125
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var VERSION = require('../env/data').version;
|
|
4
|
+
|
|
5
|
+
var validators = {};
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line func-names
|
|
8
|
+
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
|
|
9
|
+
validators[type] = function validator(thing) {
|
|
10
|
+
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
var deprecatedWarnings = {};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Transitional option validator
|
|
18
|
+
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
19
|
+
* @param {string?} version - deprecated version / removed since version
|
|
20
|
+
* @param {string?} message - some message with additional info
|
|
21
|
+
* @returns {function}
|
|
22
|
+
*/
|
|
23
|
+
validators.transitional = function transitional(validator, version, message) {
|
|
24
|
+
function formatMessage(opt, desc) {
|
|
25
|
+
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line func-names
|
|
29
|
+
return function(value, opt, opts) {
|
|
30
|
+
if (validator === false) {
|
|
31
|
+
throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (version && !deprecatedWarnings[opt]) {
|
|
35
|
+
deprecatedWarnings[opt] = true;
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.warn(
|
|
38
|
+
formatMessage(
|
|
39
|
+
opt,
|
|
40
|
+
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return validator ? validator(value, opt, opts) : true;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Assert object's properties type
|
|
51
|
+
* @param {object} options
|
|
52
|
+
* @param {object} schema
|
|
53
|
+
* @param {boolean?} allowUnknown
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
57
|
+
if (typeof options !== 'object') {
|
|
58
|
+
throw new TypeError('options must be an object');
|
|
59
|
+
}
|
|
60
|
+
var keys = Object.keys(options);
|
|
61
|
+
var i = keys.length;
|
|
62
|
+
while (i-- > 0) {
|
|
63
|
+
var opt = keys[i];
|
|
64
|
+
var validator = schema[opt];
|
|
65
|
+
if (validator) {
|
|
66
|
+
var value = options[opt];
|
|
67
|
+
var result = value === undefined || validator(value, opt, options);
|
|
68
|
+
if (result !== true) {
|
|
69
|
+
throw new TypeError('option ' + opt + ' must be ' + result);
|
|
70
|
+
}
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (allowUnknown !== true) {
|
|
74
|
+
throw Error('Unknown option ' + opt);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
assertOptions: assertOptions,
|
|
81
|
+
validators: validators
|
|
82
|
+
};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var bind = require('./helpers/bind');
|
|
4
4
|
|
|
5
|
-
/*global toString:true*/
|
|
6
|
-
|
|
7
5
|
// utils is a library of generic helper functions non-specific to axios
|
|
8
6
|
|
|
9
7
|
var toString = Object.prototype.toString;
|
|
@@ -187,7 +185,7 @@ function isURLSearchParams(val) {
|
|
|
187
185
|
* @returns {String} The String freed of excess whitespace
|
|
188
186
|
*/
|
|
189
187
|
function trim(str) {
|
|
190
|
-
return str.
|
|
188
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
/**
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"axios@0.21.1",
|
|
5
|
-
"/home/taylor/devtools/adaptors/language-dhis2"
|
|
6
|
-
]
|
|
7
|
-
],
|
|
8
|
-
"_from": "axios@0.21.1",
|
|
9
|
-
"_id": "axios@0.21.1",
|
|
2
|
+
"_from": "axios@^0.24.0",
|
|
3
|
+
"_id": "axios@0.24.0",
|
|
10
4
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
|
|
12
6
|
"_location": "/axios",
|
|
13
7
|
"_phantomChildren": {},
|
|
14
8
|
"_requested": {
|
|
15
|
-
"type": "
|
|
9
|
+
"type": "range",
|
|
16
10
|
"registry": true,
|
|
17
|
-
"raw": "axios
|
|
11
|
+
"raw": "axios@^0.24.0",
|
|
18
12
|
"name": "axios",
|
|
19
13
|
"escapedName": "axios",
|
|
20
|
-
"rawSpec": "0.
|
|
14
|
+
"rawSpec": "^0.24.0",
|
|
21
15
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "0.
|
|
16
|
+
"fetchSpec": "^0.24.0"
|
|
23
17
|
},
|
|
24
18
|
"_requiredBy": [
|
|
25
19
|
"/"
|
|
26
20
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/axios/-/axios-0.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
"_resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
|
|
22
|
+
"_shasum": "804e6fa1e4b9c5288501dd9dff56a7a0940d20d6",
|
|
23
|
+
"_spec": "axios@^0.24.0",
|
|
24
|
+
"_where": "/Users/taylor/devtools/adaptors/language-dhis2",
|
|
30
25
|
"author": {
|
|
31
26
|
"name": "Matt Zabriskie"
|
|
32
27
|
},
|
|
@@ -36,6 +31,7 @@
|
|
|
36
31
|
"bugs": {
|
|
37
32
|
"url": "https://github.com/axios/axios/issues"
|
|
38
33
|
},
|
|
34
|
+
"bundleDependencies": false,
|
|
39
35
|
"bundlesize": [
|
|
40
36
|
{
|
|
41
37
|
"path": "./dist/axios.min.js",
|
|
@@ -43,47 +39,47 @@
|
|
|
43
39
|
}
|
|
44
40
|
],
|
|
45
41
|
"dependencies": {
|
|
46
|
-
"follow-redirects": "^1.
|
|
42
|
+
"follow-redirects": "^1.14.4"
|
|
47
43
|
},
|
|
44
|
+
"deprecated": false,
|
|
48
45
|
"description": "Promise based HTTP client for the browser and node.js",
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"
|
|
47
|
+
"abortcontroller-polyfill": "^1.5.0",
|
|
51
48
|
"coveralls": "^3.0.0",
|
|
49
|
+
"dtslint": "^4.1.6",
|
|
52
50
|
"es6-promise": "^4.2.4",
|
|
53
|
-
"grunt": "^1.0
|
|
51
|
+
"grunt": "^1.3.0",
|
|
54
52
|
"grunt-banner": "^0.6.0",
|
|
55
53
|
"grunt-cli": "^1.2.0",
|
|
56
54
|
"grunt-contrib-clean": "^1.1.0",
|
|
57
55
|
"grunt-contrib-watch": "^1.0.0",
|
|
58
|
-
"grunt-eslint": "^
|
|
59
|
-
"grunt-karma": "^
|
|
56
|
+
"grunt-eslint": "^23.0.0",
|
|
57
|
+
"grunt-karma": "^4.0.0",
|
|
60
58
|
"grunt-mocha-test": "^0.13.3",
|
|
61
|
-
"grunt-
|
|
62
|
-
"grunt-webpack": "^1.0.18",
|
|
59
|
+
"grunt-webpack": "^4.0.2",
|
|
63
60
|
"istanbul-instrumenter-loader": "^1.0.0",
|
|
64
61
|
"jasmine-core": "^2.4.1",
|
|
65
|
-
"karma": "^
|
|
66
|
-
"karma-chrome-launcher": "^
|
|
67
|
-
"karma-
|
|
68
|
-
"karma-firefox-launcher": "^1.1.0",
|
|
62
|
+
"karma": "^6.3.2",
|
|
63
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
64
|
+
"karma-firefox-launcher": "^2.1.0",
|
|
69
65
|
"karma-jasmine": "^1.1.1",
|
|
70
66
|
"karma-jasmine-ajax": "^0.1.13",
|
|
71
|
-
"karma-opera-launcher": "^1.0.0",
|
|
72
67
|
"karma-safari-launcher": "^1.0.0",
|
|
73
|
-
"karma-sauce-launcher": "^
|
|
68
|
+
"karma-sauce-launcher": "^4.3.6",
|
|
74
69
|
"karma-sinon": "^1.0.5",
|
|
75
|
-
"karma-sourcemap-loader": "^0.3.
|
|
76
|
-
"karma-webpack": "^
|
|
70
|
+
"karma-sourcemap-loader": "^0.3.8",
|
|
71
|
+
"karma-webpack": "^4.0.2",
|
|
77
72
|
"load-grunt-tasks": "^3.5.2",
|
|
78
73
|
"minimist": "^1.2.0",
|
|
79
|
-
"mocha": "^
|
|
74
|
+
"mocha": "^8.2.1",
|
|
80
75
|
"sinon": "^4.5.0",
|
|
81
|
-
"
|
|
76
|
+
"terser-webpack-plugin": "^4.2.3",
|
|
77
|
+
"typescript": "^4.0.5",
|
|
82
78
|
"url-search-params": "^0.10.0",
|
|
83
|
-
"webpack": "^
|
|
84
|
-
"webpack-dev-server": "^
|
|
79
|
+
"webpack": "^4.44.2",
|
|
80
|
+
"webpack-dev-server": "^3.11.0"
|
|
85
81
|
},
|
|
86
|
-
"homepage": "https://
|
|
82
|
+
"homepage": "https://axios-http.com",
|
|
87
83
|
"jsdelivr": "dist/axios.min.js",
|
|
88
84
|
"keywords": [
|
|
89
85
|
"xhr",
|
|
@@ -105,12 +101,13 @@
|
|
|
105
101
|
"examples": "node ./examples/server.js",
|
|
106
102
|
"fix": "eslint --fix lib/**/*.js",
|
|
107
103
|
"postversion": "git push && git push --tags",
|
|
108
|
-
"preversion": "npm test",
|
|
104
|
+
"preversion": "grunt version && npm test",
|
|
109
105
|
"start": "node ./sandbox/server.js",
|
|
110
|
-
"test": "grunt test &&
|
|
111
|
-
"version": "npm run build &&
|
|
106
|
+
"test": "grunt test && dtslint",
|
|
107
|
+
"version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json"
|
|
112
108
|
},
|
|
109
|
+
"types": "index.d.ts",
|
|
113
110
|
"typings": "./index.d.ts",
|
|
114
111
|
"unpkg": "dist/axios.min.js",
|
|
115
|
-
"version": "0.
|
|
112
|
+
"version": "0.24.0"
|
|
116
113
|
}
|