@livequery/rest 1.0.21 → 1.0.22
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transporter, QueryOption, QueryStream } from '@livequery/types';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
export type RestTransporterConfig = {
|
|
4
4
|
websocket_url: () => MaybePromise<string>;
|
|
5
5
|
base_url: () => MaybePromise<string>;
|
|
6
6
|
headers?: () => Promise<{
|
package/build/RestTransporter.js
CHANGED
|
@@ -67,7 +67,13 @@ class RestTransporter {
|
|
|
67
67
|
'Content-Type': 'application/json'
|
|
68
68
|
} : {}), this.socket ? { socket_id: this.socket.socket_session } : {});
|
|
69
69
|
try {
|
|
70
|
-
|
|
70
|
+
const result = yield fetch(`${this.config.base_url()}/${url}${__classPrivateFieldGet(this, _RestTransporter_instances, "m", _RestTransporter_encode_query).call(this, query)}`, Object.assign({ method, headers: headers }, payload ? { body: JSON.stringify(payload) } : {})).then(r => r.text());
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(result);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
catch (error) {
|
|
73
79
|
throw error;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"repository": {
|
|
4
4
|
"url": "https://github.com/livequery/rest"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.22",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "build/index.js",
|
|
9
9
|
"types": "build/index.d.ts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"@types/uuid": "^8.3.0",
|
|
15
15
|
"query-string": "^7.0.1",
|
|
16
16
|
"rxjs": "^7.1.0",
|
|
17
|
+
"typescript": "4.9.5",
|
|
17
18
|
"uuid": "^8.3.2"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|