@openfn/language-dhis2 2.0.10 → 3.0.0-3
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 +189 -2491
- package/lib/Adaptor.js +542 -1588
- package/lib/Client.js +48 -0
- package/lib/Utils.js +58 -179
- 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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/follow-redirects)
|
|
6
|
-
[](https://github.com/follow-redirects/follow-redirects/actions)
|
|
7
7
|
[](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)
|
|
8
8
|
[](https://www.npmjs.com/package/follow-redirects)
|
|
9
9
|
[](https://github.com/sponsors/RubenVerborgh)
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
var debug;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
module.exports = function () {
|
|
4
|
+
if (!debug) {
|
|
5
|
+
try {
|
|
6
|
+
/* eslint global-require: off */
|
|
7
|
+
debug = require("debug")("follow-redirects");
|
|
8
|
+
}
|
|
9
|
+
catch (error) { /* */ }
|
|
10
|
+
if (typeof debug !== "function") {
|
|
11
|
+
debug = function () { /* */ };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
debug.apply(null, arguments);
|
|
15
|
+
};
|
|
@@ -7,8 +7,9 @@ var assert = require("assert");
|
|
|
7
7
|
var debug = require("./debug");
|
|
8
8
|
|
|
9
9
|
// Create handlers that pass events from native requests
|
|
10
|
+
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
|
10
11
|
var eventHandlers = Object.create(null);
|
|
11
|
-
|
|
12
|
+
events.forEach(function (event) {
|
|
12
13
|
eventHandlers[event] = function (arg1, arg2, arg3) {
|
|
13
14
|
this._redirectable.emit(event, arg1, arg2, arg3);
|
|
14
15
|
};
|
|
@@ -17,7 +18,7 @@ var eventHandlers = Object.create(null);
|
|
|
17
18
|
// Error types with codes
|
|
18
19
|
var RedirectionError = createErrorType(
|
|
19
20
|
"ERR_FR_REDIRECTION_FAILURE",
|
|
20
|
-
""
|
|
21
|
+
"Redirected request failed"
|
|
21
22
|
);
|
|
22
23
|
var TooManyRedirectsError = createErrorType(
|
|
23
24
|
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
@@ -61,6 +62,11 @@ function RedirectableRequest(options, responseCallback) {
|
|
|
61
62
|
}
|
|
62
63
|
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
|
63
64
|
|
|
65
|
+
RedirectableRequest.prototype.abort = function () {
|
|
66
|
+
abortRequest(this._currentRequest);
|
|
67
|
+
this.emit("abort");
|
|
68
|
+
};
|
|
69
|
+
|
|
64
70
|
// Writes buffered data to the current native request
|
|
65
71
|
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
|
66
72
|
// Writing is not allowed if end has been called
|
|
@@ -140,40 +146,72 @@ RedirectableRequest.prototype.removeHeader = function (name) {
|
|
|
140
146
|
|
|
141
147
|
// Global timeout for all underlying requests
|
|
142
148
|
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
|
149
|
+
var self = this;
|
|
150
|
+
|
|
151
|
+
// Destroys the socket on timeout
|
|
152
|
+
function destroyOnTimeout(socket) {
|
|
153
|
+
socket.setTimeout(msecs);
|
|
154
|
+
socket.removeListener("timeout", socket.destroy);
|
|
155
|
+
socket.addListener("timeout", socket.destroy);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Sets up a timer to trigger a timeout event
|
|
159
|
+
function startTimer(socket) {
|
|
160
|
+
if (self._timeout) {
|
|
161
|
+
clearTimeout(self._timeout);
|
|
162
|
+
}
|
|
163
|
+
self._timeout = setTimeout(function () {
|
|
164
|
+
self.emit("timeout");
|
|
165
|
+
clearTimer();
|
|
166
|
+
}, msecs);
|
|
167
|
+
destroyOnTimeout(socket);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Stops a timeout from triggering
|
|
171
|
+
function clearTimer() {
|
|
172
|
+
// Clear the timeout
|
|
173
|
+
if (self._timeout) {
|
|
174
|
+
clearTimeout(self._timeout);
|
|
175
|
+
self._timeout = null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Clean up all attached listeners
|
|
179
|
+
self.removeListener("abort", clearTimer);
|
|
180
|
+
self.removeListener("error", clearTimer);
|
|
181
|
+
self.removeListener("response", clearTimer);
|
|
182
|
+
if (callback) {
|
|
183
|
+
self.removeListener("timeout", callback);
|
|
184
|
+
}
|
|
185
|
+
if (!self.socket) {
|
|
186
|
+
self._currentRequest.removeListener("socket", startTimer);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Attach callback if passed
|
|
143
191
|
if (callback) {
|
|
144
|
-
this.
|
|
192
|
+
this.on("timeout", callback);
|
|
145
193
|
}
|
|
146
194
|
|
|
195
|
+
// Start the timer if or when the socket is opened
|
|
147
196
|
if (this.socket) {
|
|
148
|
-
startTimer(this
|
|
197
|
+
startTimer(this.socket);
|
|
149
198
|
}
|
|
150
199
|
else {
|
|
151
|
-
|
|
152
|
-
this._currentRequest.once("socket", function () {
|
|
153
|
-
startTimer(self, msecs);
|
|
154
|
-
});
|
|
200
|
+
this._currentRequest.once("socket", startTimer);
|
|
155
201
|
}
|
|
156
202
|
|
|
157
|
-
|
|
158
|
-
this.
|
|
203
|
+
// Clean up on events
|
|
204
|
+
this.on("socket", destroyOnTimeout);
|
|
205
|
+
this.on("abort", clearTimer);
|
|
206
|
+
this.on("error", clearTimer);
|
|
207
|
+
this.on("response", clearTimer);
|
|
159
208
|
|
|
160
209
|
return this;
|
|
161
210
|
};
|
|
162
211
|
|
|
163
|
-
function startTimer(request, msecs) {
|
|
164
|
-
clearTimeout(request._timeout);
|
|
165
|
-
request._timeout = setTimeout(function () {
|
|
166
|
-
request.emit("timeout");
|
|
167
|
-
}, msecs);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function clearTimer() {
|
|
171
|
-
clearTimeout(this._timeout);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
212
|
// Proxy all other public ClientRequest methods
|
|
175
213
|
[
|
|
176
|
-
"
|
|
214
|
+
"flushHeaders", "getHeader",
|
|
177
215
|
"setNoDelay", "setSocketKeepAlive",
|
|
178
216
|
].forEach(function (method) {
|
|
179
217
|
RedirectableRequest.prototype[method] = function (a, b) {
|
|
@@ -243,11 +281,8 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
|
243
281
|
|
|
244
282
|
// Set up event handlers
|
|
245
283
|
request._redirectable = this;
|
|
246
|
-
for (var
|
|
247
|
-
|
|
248
|
-
if (event) {
|
|
249
|
-
request.on(event, eventHandlers[event]);
|
|
250
|
-
}
|
|
284
|
+
for (var e = 0; e < events.length; e++) {
|
|
285
|
+
request.on(events[e], eventHandlers[events[e]]);
|
|
251
286
|
}
|
|
252
287
|
|
|
253
288
|
// End a redirected request
|
|
@@ -305,9 +340,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
305
340
|
if (location && this._options.followRedirects !== false &&
|
|
306
341
|
statusCode >= 300 && statusCode < 400) {
|
|
307
342
|
// Abort the current request
|
|
308
|
-
this._currentRequest
|
|
309
|
-
this._currentRequest.on("error", noop);
|
|
310
|
-
this._currentRequest.abort();
|
|
343
|
+
abortRequest(this._currentRequest);
|
|
311
344
|
// Discard the remainder of the response to avoid waiting for data
|
|
312
345
|
response.destroy();
|
|
313
346
|
|
|
@@ -335,18 +368,32 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
335
368
|
}
|
|
336
369
|
|
|
337
370
|
// Drop the Host header, as the redirect might lead to a different host
|
|
338
|
-
var
|
|
339
|
-
|
|
371
|
+
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
|
372
|
+
|
|
373
|
+
// If the redirect is relative, carry over the host of the last request
|
|
374
|
+
var currentUrlParts = url.parse(this._currentUrl);
|
|
375
|
+
var currentHost = currentHostHeader || currentUrlParts.host;
|
|
376
|
+
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
|
377
|
+
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
|
378
|
+
|
|
379
|
+
// Determine the URL of the redirection
|
|
380
|
+
var redirectUrl;
|
|
381
|
+
try {
|
|
382
|
+
redirectUrl = url.resolve(currentUrl, location);
|
|
383
|
+
}
|
|
384
|
+
catch (cause) {
|
|
385
|
+
this.emit("error", new RedirectionError(cause));
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
340
388
|
|
|
341
389
|
// Create the redirected request
|
|
342
|
-
var redirectUrl = url.resolve(this._currentUrl, location);
|
|
343
390
|
debug("redirecting to", redirectUrl);
|
|
344
391
|
this._isRedirect = true;
|
|
345
392
|
var redirectUrlParts = url.parse(redirectUrl);
|
|
346
393
|
Object.assign(this._options, redirectUrlParts);
|
|
347
394
|
|
|
348
|
-
// Drop the Authorization header if redirecting to another
|
|
349
|
-
if (redirectUrlParts.
|
|
395
|
+
// Drop the Authorization header if redirecting to another domain
|
|
396
|
+
if (!(redirectUrlParts.host === currentHost || isSubdomainOf(redirectUrlParts.host, currentHost))) {
|
|
350
397
|
removeMatchingHeaders(/^authorization$/i, this._options.headers);
|
|
351
398
|
}
|
|
352
399
|
|
|
@@ -368,9 +415,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
368
415
|
this._performRequest();
|
|
369
416
|
}
|
|
370
417
|
catch (cause) {
|
|
371
|
-
|
|
372
|
-
error.cause = cause;
|
|
373
|
-
this.emit("error", error);
|
|
418
|
+
this.emit("error", new RedirectionError(cause));
|
|
374
419
|
}
|
|
375
420
|
}
|
|
376
421
|
else {
|
|
@@ -484,13 +529,20 @@ function removeMatchingHeaders(regex, headers) {
|
|
|
484
529
|
delete headers[header];
|
|
485
530
|
}
|
|
486
531
|
}
|
|
487
|
-
return lastValue
|
|
532
|
+
return (lastValue === null || typeof lastValue === "undefined") ?
|
|
533
|
+
undefined : String(lastValue).trim();
|
|
488
534
|
}
|
|
489
535
|
|
|
490
536
|
function createErrorType(code, defaultMessage) {
|
|
491
|
-
function CustomError(
|
|
537
|
+
function CustomError(cause) {
|
|
492
538
|
Error.captureStackTrace(this, this.constructor);
|
|
493
|
-
|
|
539
|
+
if (!cause) {
|
|
540
|
+
this.message = defaultMessage;
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
this.message = defaultMessage + ": " + cause.message;
|
|
544
|
+
this.cause = cause;
|
|
545
|
+
}
|
|
494
546
|
}
|
|
495
547
|
CustomError.prototype = new Error();
|
|
496
548
|
CustomError.prototype.constructor = CustomError;
|
|
@@ -499,6 +551,19 @@ function createErrorType(code, defaultMessage) {
|
|
|
499
551
|
return CustomError;
|
|
500
552
|
}
|
|
501
553
|
|
|
554
|
+
function abortRequest(request) {
|
|
555
|
+
for (var e = 0; e < events.length; e++) {
|
|
556
|
+
request.removeListener(events[e], eventHandlers[events[e]]);
|
|
557
|
+
}
|
|
558
|
+
request.on("error", noop);
|
|
559
|
+
request.abort();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function isSubdomainOf(subdomain, domain) {
|
|
563
|
+
const dot = subdomain.length - domain.length - 1;
|
|
564
|
+
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
565
|
+
}
|
|
566
|
+
|
|
502
567
|
// Exports
|
|
503
568
|
module.exports = wrap({ http: http, https: https });
|
|
504
569
|
module.exports.wrap = wrap;
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"follow-redirects@1.13.1",
|
|
5
|
-
"/home/taylor/devtools/adaptors/language-dhis2"
|
|
6
|
-
]
|
|
7
|
-
],
|
|
8
|
-
"_from": "follow-redirects@1.13.1",
|
|
9
|
-
"_id": "follow-redirects@1.13.1",
|
|
2
|
+
"_from": "follow-redirects@^1.14.4",
|
|
3
|
+
"_id": "follow-redirects@1.14.6",
|
|
10
4
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
|
|
12
6
|
"_location": "/follow-redirects",
|
|
13
7
|
"_phantomChildren": {},
|
|
14
8
|
"_requested": {
|
|
15
|
-
"type": "
|
|
9
|
+
"type": "range",
|
|
16
10
|
"registry": true,
|
|
17
|
-
"raw": "follow-redirects
|
|
11
|
+
"raw": "follow-redirects@^1.14.4",
|
|
18
12
|
"name": "follow-redirects",
|
|
19
13
|
"escapedName": "follow-redirects",
|
|
20
|
-
"rawSpec": "1.
|
|
14
|
+
"rawSpec": "^1.14.4",
|
|
21
15
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "1.
|
|
16
|
+
"fetchSpec": "^1.14.4"
|
|
23
17
|
},
|
|
24
18
|
"_requiredBy": [
|
|
25
19
|
"/axios"
|
|
26
20
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
"_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz",
|
|
22
|
+
"_shasum": "8cfb281bbc035b3c067d6cd975b0f6ade6e855cd",
|
|
23
|
+
"_spec": "follow-redirects@^1.14.4",
|
|
24
|
+
"_where": "/Users/taylor/devtools/adaptors/language-dhis2/node_modules/axios",
|
|
30
25
|
"author": {
|
|
31
26
|
"name": "Ruben Verborgh",
|
|
32
27
|
"email": "ruben@verborgh.org",
|
|
@@ -35,6 +30,7 @@
|
|
|
35
30
|
"bugs": {
|
|
36
31
|
"url": "https://github.com/follow-redirects/follow-redirects/issues"
|
|
37
32
|
},
|
|
33
|
+
"bundleDependencies": false,
|
|
38
34
|
"contributors": [
|
|
39
35
|
{
|
|
40
36
|
"name": "Olivier Lalonde",
|
|
@@ -46,6 +42,7 @@
|
|
|
46
42
|
"email": "james@talmage.io"
|
|
47
43
|
}
|
|
48
44
|
],
|
|
45
|
+
"deprecated": false,
|
|
49
46
|
"description": "HTTP and HTTPS modules that follow redirects.",
|
|
50
47
|
"devDependencies": {
|
|
51
48
|
"concat-stream": "^2.0.0",
|
|
@@ -94,5 +91,5 @@
|
|
|
94
91
|
"mocha": "nyc mocha",
|
|
95
92
|
"test": "npm run lint && npm run mocha"
|
|
96
93
|
},
|
|
97
|
-
"version": "1.
|
|
94
|
+
"version": "1.14.6"
|
|
98
95
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
4
|
"lodash@4.17.21",
|
|
5
|
-
"/
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-dhis2"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
"_from": "lodash@4.17.21",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
],
|
|
35
35
|
"_resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
|
36
36
|
"_spec": "4.17.21",
|
|
37
|
-
"_where": "/
|
|
37
|
+
"_where": "/Users/taylor/devtools/adaptors/language-dhis2",
|
|
38
38
|
"author": {
|
|
39
39
|
"name": "John-David Dalton",
|
|
40
40
|
"email": "john.david.dalton@gmail.com"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-dhis2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-3",
|
|
4
4
|
"description": "DHIS2 Language Pack for OpenFn",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
},
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test:watch": "mocha -w --require @babel/register",
|
|
12
|
+
"test:watch": "mocha -w --require @babel/register test/index.js",
|
|
13
13
|
"build": "node_modules/.bin/babel src -d lib && npm run ast",
|
|
14
|
-
"test": "mocha --require @babel/register",
|
|
14
|
+
"test": "mocha --require @babel/register test/index.js",
|
|
15
|
+
"integration-test": "mocha --require @babel/register test/integration.js",
|
|
15
16
|
"ast": "simple-ast --adaptor ./src/Adaptor.js --output ast.json",
|
|
16
17
|
"postversion": "git push && git push --tags",
|
|
17
18
|
"version": "npm run build && git add -A lib ast.json"
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"@openfn/language-common": "1.4.1",
|
|
27
|
-
"axios": "^0.
|
|
28
|
+
"axios": "^0.24.0",
|
|
28
29
|
"lodash": "^4.17.19"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|