@xapp/stentor-service 1.40.277 → 1.40.279
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/lib/FetchService.d.ts +7 -7
- package/lib/FetchService.js +2 -7
- package/lib/FetchService.js.map +1 -1
- package/package.json +2 -2
package/lib/FetchService.d.ts
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
import "isomorphic-fetch";
|
|
3
3
|
import "abort-controller/polyfill";
|
|
4
4
|
import { AbstractService } from "./Service";
|
|
5
|
+
export interface WithTimeout {
|
|
6
|
+
/**
|
|
7
|
+
* Timeout in milliseconds
|
|
8
|
+
*/
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
5
11
|
export declare class TimeoutError extends Error {
|
|
6
12
|
constructor(message: string);
|
|
7
13
|
}
|
|
@@ -20,12 +26,6 @@ export declare abstract class FetchService extends AbstractService {
|
|
|
20
26
|
* Wrapper around fetch to add some basic diagnostics
|
|
21
27
|
*
|
|
22
28
|
* Will throw a TimeoutError if the timeout is reached.
|
|
23
|
-
*
|
|
24
|
-
* @protected
|
|
25
|
-
* @param {string} url
|
|
26
|
-
* @param {RequestInit} options
|
|
27
|
-
* @returns {Promise<Response>}
|
|
28
|
-
* @memberof AbstractResourceService
|
|
29
29
|
*/
|
|
30
|
-
protected fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
30
|
+
protected fetch(url: string, options?: RequestInit & WithTimeout): Promise<Response>;
|
|
31
31
|
}
|
package/lib/FetchService.js
CHANGED
|
@@ -29,12 +29,6 @@ class FetchService extends Service_1.AbstractService {
|
|
|
29
29
|
* Wrapper around fetch to add some basic diagnostics
|
|
30
30
|
*
|
|
31
31
|
* Will throw a TimeoutError if the timeout is reached.
|
|
32
|
-
*
|
|
33
|
-
* @protected
|
|
34
|
-
* @param {string} url
|
|
35
|
-
* @param {RequestInit} options
|
|
36
|
-
* @returns {Promise<Response>}
|
|
37
|
-
* @memberof AbstractResourceService
|
|
38
32
|
*/
|
|
39
33
|
fetch(url, options) {
|
|
40
34
|
const start = now();
|
|
@@ -49,9 +43,10 @@ class FetchService extends Service_1.AbstractService {
|
|
|
49
43
|
signal: controller.signal
|
|
50
44
|
};
|
|
51
45
|
}
|
|
46
|
+
const timeoutInMS = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
|
|
52
47
|
const timeout = setTimeout(() => {
|
|
53
48
|
controller.abort();
|
|
54
|
-
},
|
|
49
|
+
}, timeoutInMS);
|
|
55
50
|
return fetch(url, options).then(response => {
|
|
56
51
|
const end = now();
|
|
57
52
|
if (this.logs) {
|
package/lib/FetchService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchService.js","sourceRoot":"","sources":["../src/FetchService.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,4BAA0B;AAC1B,qCAAkC;AAElC,uCAA4C;AAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchService.js","sourceRoot":"","sources":["../src/FetchService.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,4BAA0B;AAC1B,qCAAkC;AAElC,uCAA4C;AAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AASvC,MAAa,YAAa,SAAQ,KAAK;IAEnC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACJ;AAPD,oCAOC;AAED;;;;;;;;;GASG;AACH,MAAsB,YAAa,SAAQ,yBAAe;IACtD;;;;OAIG;IACO,KAAK,CAAC,GAAW,EAAE,OAAmC;QAC5D,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC;QAEpB,MAAM,UAAU,GAAG,IAAI,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1.40.279",
|
|
8
8
|
"description": "Base service to be extended for making API calls",
|
|
9
9
|
"types": "lib/index",
|
|
10
10
|
"main": "lib/index",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"clean": "rm -rf ./lib/*",
|
|
62
62
|
"ftest": "mocha --recursive -r ts-node/register \"./src/**/*.ftest.ts\""
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3789695c3bbd39523f7d6668901c67c189e6ee6d"
|
|
65
65
|
}
|