attlaz-client 1.6.1 → 1.6.4
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/OAuthClient.js +9 -2
- package/dist/Model/Result/DataResult.js +13 -3
- package/dist/Model/Result/DataResult.spec.d.ts +1 -0
- package/dist/Model/Result/DataResult.spec.js +6 -0
- package/dist/Model/Worker/Platform.d.ts +1 -1
- package/dist/Model/Worker/PlatformImage.d.ts +1 -1
- package/dist/Utils.d.ts +1 -0
- package/dist/Utils.js +7 -0
- package/dist/Utils.spec.js +13 -0
- package/package.json +1 -1
package/dist/Http/OAuthClient.js
CHANGED
|
@@ -90,8 +90,15 @@ class OAuthClient {
|
|
|
90
90
|
const response = await HttpClient_1.HttpClient.request2(requestData);
|
|
91
91
|
return response.body;
|
|
92
92
|
}
|
|
93
|
-
catch (
|
|
94
|
-
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (this.debug) {
|
|
95
|
+
console.error('[Client error]', error);
|
|
96
|
+
}
|
|
97
|
+
const clientError = ClientError_1.ClientError.fromError(error);
|
|
98
|
+
if (this.debug) {
|
|
99
|
+
console.error('[Client error]', clientError);
|
|
100
|
+
}
|
|
101
|
+
throw clientError;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
104
|
}
|
|
@@ -8,9 +8,19 @@ class DataResult {
|
|
|
8
8
|
}
|
|
9
9
|
static parse(raw) {
|
|
10
10
|
const result = new DataResult();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (raw === null || raw === undefined) {
|
|
12
|
+
throw new Error('Unable to parse DataResult: result: empty');
|
|
13
|
+
}
|
|
14
|
+
if (!raw.hasOwnProperty('data') || raw.data === undefined) {
|
|
15
|
+
throw new Error('Unable to parse DataResult: data is not defined');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
result.setData(raw.data);
|
|
19
|
+
}
|
|
20
|
+
if (!raw.hasOwnProperty('errors') || raw.errors === undefined || raw.errors === null) {
|
|
21
|
+
console.error('Unable to parse DataResult (ignore for now, not setting any errors): errors is not defined');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
14
24
|
const errors = raw.errors;
|
|
15
25
|
for (const error of errors) {
|
|
16
26
|
result.addError(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/Utils.d.ts
CHANGED
package/dist/Utils.js
CHANGED
|
@@ -50,5 +50,12 @@ class Utils {
|
|
|
50
50
|
}
|
|
51
51
|
return Buffer.from(encodedString, 'base64').toString();
|
|
52
52
|
}
|
|
53
|
+
static isIterable(variable) {
|
|
54
|
+
if (Utils.isNullOrUndefined(variable) || typeof variable === 'string') {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return Symbol.iterator in Object(variable);
|
|
58
|
+
// return typeof obj[Symbol.iterator] === 'function';
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
exports.Utils = Utils;
|
package/dist/Utils.spec.js
CHANGED
|
@@ -25,3 +25,16 @@ test('Test base64 encode/decode', () => {
|
|
|
25
25
|
expect(Utils_1.Utils.base64encode('Lorem ipsum')).toBe('TG9yZW0gaXBzdW0=');
|
|
26
26
|
expect(Utils_1.Utils.base64decode('TG9yZW0gaXBzdW0=')).toBe('Lorem ipsum');
|
|
27
27
|
});
|
|
28
|
+
test('Test if iterable', async () => {
|
|
29
|
+
expect(Utils_1.Utils.isIterable(null)).toBe(false);
|
|
30
|
+
expect(Utils_1.Utils.isIterable('')).toBe(false);
|
|
31
|
+
expect(Utils_1.Utils.isIterable('Lorem')).toBe(false);
|
|
32
|
+
expect(Utils_1.Utils.isIterable(false)).toBe(false);
|
|
33
|
+
expect(Utils_1.Utils.isIterable(true)).toBe(false);
|
|
34
|
+
expect(Utils_1.Utils.isIterable(undefined)).toBe(false);
|
|
35
|
+
expect(Utils_1.Utils.isIterable(12)).toBe(false);
|
|
36
|
+
expect(Utils_1.Utils.isIterable([])).toBe(true);
|
|
37
|
+
expect(Utils_1.Utils.isIterable(['L', 'O', 'R', 'E', 'M'])).toBe(true);
|
|
38
|
+
expect(Utils_1.Utils.isIterable({})).toBe(false);
|
|
39
|
+
expect(Utils_1.Utils.isIterable({ a: 'a', b: 'b' })).toBe(false);
|
|
40
|
+
});
|