@equos/node-sdk 0.0.10 → 0.0.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.
@@ -1,19 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EquosAvatar = void 0;
4
+ const error_utils_1 = require("../utils/error.utils");
4
5
  class EquosAvatar {
5
6
  http;
6
7
  constructor(http) {
7
8
  this.http = http;
8
9
  }
9
- create(name, dataUrl) {
10
- return this.http.post('/avatars', {
10
+ async create(name, dataUrl) {
11
+ return this.http
12
+ .post('/avatars', {
11
13
  name,
12
14
  refImage: dataUrl,
13
- });
15
+ })
16
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
14
17
  }
15
- list(skip = 0, take = 10) {
16
- return this.http.get(`/avatars?skip=${skip}&take=${take}`);
18
+ async list(skip = 0, take = 10) {
19
+ return this.http
20
+ .get(`/avatars?skip=${skip}&take=${take}`)
21
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
17
22
  }
18
23
  }
19
24
  exports.EquosAvatar = EquosAvatar;
@@ -1,22 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EquosSession = void 0;
4
+ const error_utils_1 = require("../utils/error.utils");
4
5
  class EquosSession {
5
6
  http;
6
7
  constructor(http) {
7
8
  this.http = http;
8
9
  }
9
- get(id) {
10
- return this.http.get(`/sessions/${id}`);
10
+ async get(id) {
11
+ return this.http
12
+ .get(`/sessions/${id}`)
13
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
11
14
  }
12
- create(data) {
13
- return this.http.post('/sessions', data);
15
+ async create(data) {
16
+ return this.http
17
+ .post('/sessions', data)
18
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
14
19
  }
15
- list(skip = 0, take = 10) {
16
- return this.http.get(`/sessions?skip=${skip}&take=${take}`);
20
+ async list(skip = 0, take = 10) {
21
+ return this.http
22
+ .get(`/sessions?skip=${skip}&take=${take}`)
23
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
17
24
  }
18
- stop(id) {
19
- return this.http.patch(`/sessions/${id}/stop`, {});
25
+ async stop(id) {
26
+ return this.http
27
+ .patch(`/sessions/${id}/stop`, {})
28
+ .catch(error_utils_1.ErrorUtils.convertToEquosError);
20
29
  }
21
30
  }
22
31
  exports.EquosSession = EquosSession;
@@ -0,0 +1,5 @@
1
+ export declare class EquosError extends Error {
2
+ readonly message: string;
3
+ readonly code?: string | undefined;
4
+ constructor(message: string, code?: string | undefined);
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EquosError = void 0;
4
+ class EquosError extends Error {
5
+ message;
6
+ code;
7
+ constructor(message, code) {
8
+ super(message);
9
+ this.message = message;
10
+ this.code = code;
11
+ this.name = 'EquosError';
12
+ }
13
+ }
14
+ exports.EquosError = EquosError;
@@ -0,0 +1,5 @@
1
+ import { EquosError } from '../types/error.type';
2
+ export declare class ErrorUtils {
3
+ static UNKNOWN_ERROR: EquosError;
4
+ static convertToEquosError(e: unknown): never;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorUtils = void 0;
4
+ const axios_1 = require("axios");
5
+ const error_type_1 = require("../types/error.type");
6
+ class ErrorUtils {
7
+ static UNKNOWN_ERROR = new error_type_1.EquosError('An unknown error occurred', 'UNKNOWN_ERROR');
8
+ static convertToEquosError(e) {
9
+ if (e instanceof axios_1.AxiosError) {
10
+ throw new error_type_1.EquosError(e.response?.data?.message, e.code);
11
+ }
12
+ else if (e instanceof Error) {
13
+ throw new error_type_1.EquosError(e.message);
14
+ }
15
+ throw ErrorUtils.UNKNOWN_ERROR;
16
+ }
17
+ }
18
+ exports.ErrorUtils = ErrorUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equos/node-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Equos.ai node.js official SDK.",
5
5
  "keywords": [
6
6
  "ai",