@napp/dti-client 4.2.3 → 4.3.2
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/caller.d.ts +1 -0
- package/caller.js +7 -2
- package/errorhandle.d.ts +1 -1
- package/errorhandle.js +25 -9
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -3
package/caller.d.ts
CHANGED
package/caller.js
CHANGED
|
@@ -87,6 +87,12 @@ class DtiClientCaller {
|
|
|
87
87
|
return { meta: this.meta, param };
|
|
88
88
|
}
|
|
89
89
|
call(param) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
let resp = yield this.callRaw(param);
|
|
92
|
+
return yield (0, errorhandle_1.responseHandle)(resp);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
callRaw(param) {
|
|
90
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
97
|
this.validate(param);
|
|
92
98
|
let url = this.getUrl();
|
|
@@ -94,10 +100,9 @@ class DtiClientCaller {
|
|
|
94
100
|
let method = this.getMethod();
|
|
95
101
|
let headers = this.getHeaders(param);
|
|
96
102
|
let body = this.getBody(param);
|
|
97
|
-
|
|
103
|
+
return yield (0, cross_fetch_1.fetch)(url + (query ? `?${query}` : ''), {
|
|
98
104
|
method, headers, body
|
|
99
105
|
});
|
|
100
|
-
return (0, errorhandle_1.responseHandle)(resp);
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
108
|
}
|
package/errorhandle.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function responseHandle(resp: Response): Promise<any>;
|
|
1
|
+
export declare function responseHandle<T>(resp: Response): Promise<any>;
|
package/errorhandle.js
CHANGED
|
@@ -14,21 +14,37 @@ const exception_1 = require("@napp/exception");
|
|
|
14
14
|
function responseHandle(resp) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
|
-
let
|
|
17
|
+
let rsu = yield resp.text();
|
|
18
18
|
if (resp.ok) {
|
|
19
|
+
if (rsu) {
|
|
20
|
+
try {
|
|
21
|
+
let value = JSON.parse(rsu);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new exception_1.Exception(rsu, {
|
|
26
|
+
name: exception_1.ExceptionNames.Server,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
if (rsu) {
|
|
33
|
+
let err;
|
|
19
34
|
try {
|
|
20
|
-
|
|
35
|
+
let errObject = JSON.parse(rsu);
|
|
36
|
+
err = exception_1.Exception.from(errObject);
|
|
21
37
|
}
|
|
22
38
|
catch (error) {
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
err = new exception_1.Exception(rsu, {
|
|
40
|
+
name: exception_1.ExceptionNames.Server,
|
|
41
|
+
});
|
|
25
42
|
}
|
|
43
|
+
throw err;
|
|
26
44
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
throw new exception_1.Exception(resp.statusText).setStatus(resp.status);
|
|
45
|
+
throw new exception_1.Exception(`status=${resp.status}. ${resp.statusText}`, {
|
|
46
|
+
name: exception_1.ExceptionNames.Server,
|
|
47
|
+
});
|
|
32
48
|
}
|
|
33
49
|
catch (error) {
|
|
34
50
|
throw exception_1.Exception.from(error);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napp/dti-client",
|
|
3
|
-
"version": "4.2
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "data transaction interface client library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"author": "Farcek <farcek@gmail.com>",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@napp/exception": "^
|
|
20
|
-
"@napp/dti-core": "4.2
|
|
19
|
+
"@napp/exception": "^5.1.7",
|
|
20
|
+
"@napp/dti-core": "4.3.2",
|
|
21
21
|
"cross-fetch": "latest"
|
|
22
22
|
}
|
|
23
23
|
}
|