attlaz-client 1.6.10 → 1.6.11
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/dist/Http/HttpClient.d.ts +0 -1
- package/dist/Http/HttpClient.js +0 -20
- package/dist/Http/OAuthClient.js +5 -5
- package/dist/test.js +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,5 @@ export declare class HttpClient {
|
|
|
10
10
|
static HTTP_INTERNAL_SERVER_ERROR: number;
|
|
11
11
|
static HTTP_UNAVAILABLE: number;
|
|
12
12
|
static get(url: string, requestData?: any): Promise<any>;
|
|
13
|
-
static request(request: HttpClientRequest): Promise<any>;
|
|
14
13
|
static request2(request: HttpClientRequest): Promise<HttpClientResponse>;
|
|
15
14
|
}
|
package/dist/Http/HttpClient.js
CHANGED
|
@@ -6,40 +6,20 @@ const Utils_1 = require("../Utils");
|
|
|
6
6
|
// import {ClientError} from '..';
|
|
7
7
|
const HttpClientResponse_1 = require("./HttpClientResponse");
|
|
8
8
|
const ClientError_1 = require("../Model/Error/ClientError");
|
|
9
|
-
// import {NegotiateHttpVersion} from 'popsicle-transport-http';
|
|
10
9
|
class HttpClient {
|
|
11
10
|
static async get(url, requestData = {}) {
|
|
12
11
|
if (Utils_1.Utils.isNullOrUndefined(requestData)) {
|
|
13
12
|
requestData = {};
|
|
14
13
|
}
|
|
15
|
-
// TODO: how to pass this?
|
|
16
|
-
// const x: TransportOptions = {
|
|
17
|
-
// negotiateHttpVersion: NegotiateHttpVersion.HTTP1_ONLY
|
|
18
|
-
// }
|
|
19
|
-
// const controller = new AbortController();
|
|
20
14
|
const response = await (0, popsicle_1.fetch)(url, requestData);
|
|
21
15
|
//TODO: validate status
|
|
22
16
|
const error = ClientError_1.ClientError.byStatus(response.status, response.statusText);
|
|
23
17
|
if (!Utils_1.Utils.isNullOrUndefined(error)) {
|
|
24
|
-
// const body: string = await response.text();
|
|
25
|
-
// console.log('Text' + body);
|
|
26
|
-
//
|
|
27
|
-
// console.log(response);
|
|
28
18
|
throw error;
|
|
29
19
|
}
|
|
30
20
|
// TODO: make it possible to do request without parsing the json
|
|
31
21
|
return await response.json();
|
|
32
22
|
}
|
|
33
|
-
static async request(request) {
|
|
34
|
-
const rawRequest = {
|
|
35
|
-
url: request.getFullUrl(),
|
|
36
|
-
method: request.method,
|
|
37
|
-
headers: request.headers,
|
|
38
|
-
omitDefaultHeaders: true,
|
|
39
|
-
body: request.body
|
|
40
|
-
};
|
|
41
|
-
return HttpClient.get(request.getFullUrl(), rawRequest);
|
|
42
|
-
}
|
|
43
23
|
static async request2(request) {
|
|
44
24
|
const rawRequest = {
|
|
45
25
|
url: request.getFullUrl(),
|
package/dist/Http/OAuthClient.js
CHANGED
|
@@ -84,19 +84,19 @@ class OAuthClient {
|
|
|
84
84
|
}
|
|
85
85
|
const requestData = this.createRequestData(action, parameters, method, signWithOauthToken);
|
|
86
86
|
if (this.debug) {
|
|
87
|
-
console.
|
|
87
|
+
console.debug('[Client] Request: ' + requestData.getFullUrl());
|
|
88
88
|
}
|
|
89
89
|
try {
|
|
90
90
|
const response = await HttpClient_1.HttpClient.request2(requestData);
|
|
91
|
-
if (this.debug) {
|
|
92
|
-
|
|
93
|
-
}
|
|
91
|
+
// if (this.debug) {
|
|
92
|
+
// console.info('[Client response] ', {body: response.body});
|
|
93
|
+
// }
|
|
94
94
|
return response.body;
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
97
|
const clientError = ClientError_1.ClientError.fromError(error);
|
|
98
98
|
if (this.debug) {
|
|
99
|
-
console.error('[Client
|
|
99
|
+
console.error('[Client] Error:', { error, clientError });
|
|
100
100
|
}
|
|
101
101
|
throw clientError;
|
|
102
102
|
}
|
package/dist/test.js
CHANGED
|
@@ -132,7 +132,7 @@ async function testHTTPAuth() {
|
|
|
132
132
|
requestData.setJsonHeader();
|
|
133
133
|
requestData.setBasicAuth('attlaz', '4$0x51eIaF9w');
|
|
134
134
|
try {
|
|
135
|
-
const res = await HttpClient_1.HttpClient.
|
|
135
|
+
const res = await HttpClient_1.HttpClient.request2(requestData);
|
|
136
136
|
console.log(res);
|
|
137
137
|
}
|
|
138
138
|
catch (e) {
|