@equos/node-sdk 0.0.10 → 0.0.12
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/apis/avatar.js +10 -5
- package/dist/apis/session.js +17 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/error.type.d.ts +5 -0
- package/dist/types/error.type.js +14 -0
- package/dist/utils/error.utils.d.ts +5 -0
- package/dist/utils/error.utils.js +18 -0
- package/package.json +1 -1
package/dist/apis/avatar.js
CHANGED
|
@@ -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
|
|
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
|
|
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;
|
package/dist/apis/session.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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,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;
|