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.
@@ -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 (e) {
94
- throw ClientError_1.ClientError.fromError(e);
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
- const data = raw.data;
12
- result.setData(data);
13
- if (data.hasOwnProperty('errors')) {
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 {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DataResult_1 = require("./DataResult");
4
+ test('Test parsing', () => {
5
+ expect(DataResult_1.DataResult.parse(null)).toBe(null);
6
+ });
@@ -3,7 +3,7 @@ import { StateAware } from '../StateAware';
3
3
  export declare class Platform implements StateAware {
4
4
  id: number;
5
5
  name: string;
6
- languageId: string;
6
+ languageId: number;
7
7
  released: Date;
8
8
  endOfSupport: Date;
9
9
  endOfLife: Date;
@@ -2,7 +2,7 @@ import { State } from '../State';
2
2
  import { StateAware } from '../StateAware';
3
3
  export declare class PlatformImage implements StateAware {
4
4
  id: number;
5
- platformId: string;
5
+ platformId: number;
6
6
  image: string;
7
7
  version: string;
8
8
  languageVersion: string;
package/dist/Utils.d.ts CHANGED
@@ -5,4 +5,5 @@ export declare class Utils {
5
5
  static parseEnum<T>(input: string, Enum: any): T | null;
6
6
  static base64encode(input: string): string;
7
7
  static base64decode(encodedString: string): string;
8
+ static isIterable(variable: any): boolean;
8
9
  }
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;
@@ -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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.6.1",
3
+ "version": "1.6.4",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",