@capawesome/cli 0.0.7 → 0.0.8
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/CHANGELOG.md +8 -0
- package/dist/commands/apps/bundles/create.js +9 -16
- package/dist/commands/apps/bundles/delete.js +9 -10
- package/dist/commands/apps/bundles/update.js +9 -10
- package/dist/commands/apps/channels/create.js +9 -10
- package/dist/commands/apps/channels/delete.js +9 -10
- package/dist/commands/apps/create.js +3 -8
- package/dist/commands/apps/delete.js +7 -8
- package/dist/commands/apps/devices/delete.js +9 -10
- package/dist/utils/error.js +29 -0
- package/package.json +1 -1
- /package/dist/services/{app-bundle.js → app-bundles.js} +0 -0
- /package/dist/services/{app-channel.js → app-channels.js} +0 -0
- /package/dist/services/{app-device.js → app-devices.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.0.8](https://github.com/capawesome-team/cli/compare/v0.0.7...v0.0.8) (2024-06-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* improve error handling ([e67e94b](https://github.com/capawesome-team/cli/commit/e67e94b50308fe227275a9ce83097f67423d0fbd))
|
|
11
|
+
* throw error if no app exists ([930857c](https://github.com/capawesome-team/cli/commit/930857cf735e102ebf1be7e8772cc251a3ddc1a2))
|
|
12
|
+
|
|
5
13
|
## [0.0.7](https://github.com/capawesome-team/cli/compare/v0.0.6...v0.0.7) (2024-05-27)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -15,13 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const prompt_1 = require("../../../utils/prompt");
|
|
18
|
-
const axios_1 = require("axios");
|
|
19
18
|
const zip_1 = __importDefault(require("../../../utils/zip"));
|
|
20
19
|
const form_data_1 = __importDefault(require("form-data"));
|
|
21
20
|
const node_fs_1 = require("node:fs");
|
|
22
21
|
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
23
22
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
24
|
-
const
|
|
23
|
+
const app_bundles_1 = __importDefault(require("../../../services/app-bundles"));
|
|
24
|
+
const error_1 = require("../../../utils/error");
|
|
25
25
|
exports.default = (0, citty_1.defineCommand)({
|
|
26
26
|
meta: {
|
|
27
27
|
description: 'Create a new app bundle.',
|
|
@@ -61,7 +61,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
var _a, _b, _c;
|
|
65
64
|
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
66
65
|
consola_1.default.error('You must be logged in to run this command.');
|
|
67
66
|
return;
|
|
@@ -77,6 +76,10 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
77
76
|
}
|
|
78
77
|
if (!appId) {
|
|
79
78
|
const apps = yield apps_1.default.findAll();
|
|
79
|
+
if (!apps.length) {
|
|
80
|
+
consola_1.default.error('You must create an app before creating a bundle.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
80
83
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
81
84
|
appId = yield (0, prompt_1.prompt)('Which app do you want to deploy to:', {
|
|
82
85
|
type: 'select',
|
|
@@ -130,23 +133,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
130
133
|
consola_1.default.start('Uploading...');
|
|
131
134
|
// Upload the bundle
|
|
132
135
|
try {
|
|
133
|
-
const response = yield
|
|
136
|
+
const response = yield app_bundles_1.default.create({ appId: appId, formData: formData });
|
|
134
137
|
consola_1.default.success('Bundle successfully created.');
|
|
135
138
|
consola_1.default.info(`Bundle ID: ${response.id}`);
|
|
136
139
|
}
|
|
137
140
|
catch (error) {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
141
|
-
consola_1.default.error('Your token is no longer valid. Please sign in again.');
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
consola_1.default.error(((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || defaultErrorMessage);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
consola_1.default.error(defaultErrorMessage);
|
|
149
|
-
}
|
|
141
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
142
|
+
consola_1.default.error(message);
|
|
150
143
|
}
|
|
151
144
|
}),
|
|
152
145
|
});
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const axios_1 = require("axios");
|
|
18
17
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
19
18
|
const prompt_1 = require("../../../utils/prompt");
|
|
20
|
-
const
|
|
19
|
+
const app_bundles_1 = __importDefault(require("../../../services/app-bundles"));
|
|
20
|
+
const error_1 = require("../../../utils/error");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
23
23
|
description: 'Delete an app bundle.',
|
|
@@ -33,12 +33,15 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
36
|
// Prompt for missing arguments
|
|
38
37
|
let appId = ctx.args.appId;
|
|
39
38
|
let bundleId = ctx.args.bundleId;
|
|
40
39
|
if (!appId) {
|
|
41
40
|
const apps = yield apps_1.default.findAll();
|
|
41
|
+
if (!apps.length) {
|
|
42
|
+
consola_1.default.error('You must create an app before deleting a bundle.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
42
45
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
43
46
|
appId = yield (0, prompt_1.prompt)('Which app do you want to delete the bundle from?', {
|
|
44
47
|
type: 'select',
|
|
@@ -59,19 +62,15 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
59
62
|
}
|
|
60
63
|
// Delete bundle
|
|
61
64
|
try {
|
|
62
|
-
yield
|
|
65
|
+
yield app_bundles_1.default.delete({
|
|
63
66
|
appId,
|
|
64
67
|
bundleId,
|
|
65
68
|
});
|
|
66
69
|
consola_1.default.success('Bundle deleted successfully.');
|
|
67
70
|
}
|
|
68
71
|
catch (error) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
consola_1.default.error('Failed to delete bundle.');
|
|
74
|
-
}
|
|
72
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
73
|
+
consola_1.default.error(message);
|
|
75
74
|
}
|
|
76
75
|
}),
|
|
77
76
|
});
|
|
@@ -15,10 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const prompt_1 = require("../../../utils/prompt");
|
|
18
|
-
const axios_1 = require("axios");
|
|
19
18
|
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
20
19
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
21
|
-
const
|
|
20
|
+
const app_bundles_1 = __importDefault(require("../../../services/app-bundles"));
|
|
21
|
+
const error_1 = require("../../../utils/error");
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
description: 'Update an app bundle.',
|
|
@@ -54,7 +54,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
56
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
var _a;
|
|
58
57
|
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
59
58
|
consola_1.default.error('You must be logged in to run this command.');
|
|
60
59
|
return;
|
|
@@ -65,6 +64,10 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
65
64
|
let bundleId = ctx.args.bundleId;
|
|
66
65
|
if (!appId) {
|
|
67
66
|
const apps = yield apps_1.default.findAll();
|
|
67
|
+
if (!apps.length) {
|
|
68
|
+
consola_1.default.error('You must create an app before updating a bundle.');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
68
71
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
69
72
|
appId = yield (0, prompt_1.prompt)('Which app do you want to update the bundle for?', {
|
|
70
73
|
type: 'select',
|
|
@@ -79,7 +82,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
79
82
|
// Update bundle
|
|
80
83
|
try {
|
|
81
84
|
const rolloutAsNumber = parseFloat(rollout);
|
|
82
|
-
yield
|
|
85
|
+
yield app_bundles_1.default.update({
|
|
83
86
|
appId,
|
|
84
87
|
bundleId,
|
|
85
88
|
maxAndroidAppVersionCode: androidMax,
|
|
@@ -91,12 +94,8 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
91
94
|
consola_1.default.success('Bundle updated successfully.');
|
|
92
95
|
}
|
|
93
96
|
catch (error) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
consola_1.default.error('Failed to delete bundle.');
|
|
99
|
-
}
|
|
97
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
98
|
+
consola_1.default.error(message);
|
|
100
99
|
}
|
|
101
100
|
}),
|
|
102
101
|
});
|
|
@@ -16,8 +16,8 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const prompt_1 = require("../../../utils/prompt");
|
|
18
18
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const app_channels_1 = __importDefault(require("../../../services/app-channels"));
|
|
20
|
+
const error_1 = require("../../../utils/error");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
23
23
|
description: 'Create a new app channel.',
|
|
@@ -33,10 +33,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
36
|
let appId = ctx.args.appId;
|
|
38
37
|
if (!appId) {
|
|
39
38
|
const apps = yield apps_1.default.findAll();
|
|
39
|
+
if (!apps.length) {
|
|
40
|
+
consola_1.default.error('You must create an app before creating a channel.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
40
43
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
41
44
|
appId = yield (0, prompt_1.prompt)('Which app do you want to delete the channel from?', {
|
|
42
45
|
type: 'select',
|
|
@@ -48,7 +51,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
48
51
|
name = yield (0, prompt_1.prompt)('Enter the name of the channel:', { type: 'text' });
|
|
49
52
|
}
|
|
50
53
|
try {
|
|
51
|
-
const response = yield
|
|
54
|
+
const response = yield app_channels_1.default.create({
|
|
52
55
|
appId,
|
|
53
56
|
name,
|
|
54
57
|
});
|
|
@@ -56,12 +59,8 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
56
59
|
consola_1.default.info(`Channel ID: ${response.id}`);
|
|
57
60
|
}
|
|
58
61
|
catch (error) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
consola_1.default.error('Failed to create channel.');
|
|
64
|
-
}
|
|
62
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
63
|
+
consola_1.default.error(message);
|
|
65
64
|
}
|
|
66
65
|
}),
|
|
67
66
|
});
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const axios_1 = require("axios");
|
|
18
17
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
19
18
|
const prompt_1 = require("../../../utils/prompt");
|
|
20
|
-
const
|
|
19
|
+
const app_channels_1 = __importDefault(require("../../../services/app-channels"));
|
|
20
|
+
const error_1 = require("../../../utils/error");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
23
23
|
description: 'Delete an app channel.',
|
|
@@ -33,10 +33,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
36
|
let appId = ctx.args.appId;
|
|
38
37
|
if (!appId) {
|
|
39
38
|
const apps = yield apps_1.default.findAll();
|
|
39
|
+
if (!apps.length) {
|
|
40
|
+
consola_1.default.error('You must create an app before deleting a bundle.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
40
43
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
41
44
|
appId = yield (0, prompt_1.prompt)('Which app do you want to delete the channel from?', {
|
|
42
45
|
type: 'select',
|
|
@@ -60,19 +63,15 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
65
|
try {
|
|
63
|
-
yield
|
|
66
|
+
yield app_channels_1.default.delete({
|
|
64
67
|
appId,
|
|
65
68
|
name: channel,
|
|
66
69
|
});
|
|
67
70
|
consola_1.default.success('Channel deleted successfully.');
|
|
68
71
|
}
|
|
69
72
|
catch (error) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
consola_1.default.error('Failed to delete channel.');
|
|
75
|
-
}
|
|
73
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
74
|
+
consola_1.default.error(message);
|
|
76
75
|
}
|
|
77
76
|
}),
|
|
78
77
|
});
|
|
@@ -16,7 +16,7 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const prompt_1 = require("../../utils/prompt");
|
|
18
18
|
const apps_1 = __importDefault(require("../../services/apps"));
|
|
19
|
-
const
|
|
19
|
+
const error_1 = require("../../utils/error");
|
|
20
20
|
exports.default = (0, citty_1.defineCommand)({
|
|
21
21
|
meta: {
|
|
22
22
|
description: 'Create a new app.',
|
|
@@ -28,7 +28,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
31
|
let name = ctx.args.name;
|
|
33
32
|
if (!name) {
|
|
34
33
|
name = yield (0, prompt_1.prompt)('Enter the name of the app:', { type: 'text' });
|
|
@@ -39,12 +38,8 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
39
38
|
consola_1.default.info(`App ID: ${response.id}`);
|
|
40
39
|
}
|
|
41
40
|
catch (error) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
consola_1.default.error('Failed to create app.');
|
|
47
|
-
}
|
|
41
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
42
|
+
consola_1.default.error(message);
|
|
48
43
|
}
|
|
49
44
|
}),
|
|
50
45
|
});
|
|
@@ -16,7 +16,7 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const prompt_1 = require("../../utils/prompt");
|
|
18
18
|
const apps_1 = __importDefault(require("../../services/apps"));
|
|
19
|
-
const
|
|
19
|
+
const error_1 = require("../../utils/error");
|
|
20
20
|
exports.default = (0, citty_1.defineCommand)({
|
|
21
21
|
meta: {
|
|
22
22
|
description: 'Delete an app.',
|
|
@@ -28,10 +28,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
31
|
let appId = ctx.args.appId;
|
|
33
32
|
if (!appId) {
|
|
34
33
|
const apps = yield apps_1.default.findAll();
|
|
34
|
+
if (!apps.length) {
|
|
35
|
+
consola_1.default.error('You must create an app before deleting it.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
35
38
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
36
39
|
appId = yield (0, prompt_1.prompt)('Which app do you want to delete?', {
|
|
37
40
|
type: 'select',
|
|
@@ -49,12 +52,8 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
49
52
|
consola_1.default.success('App deleted successfully.');
|
|
50
53
|
}
|
|
51
54
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
consola_1.default.error('Failed to delete app.');
|
|
57
|
-
}
|
|
55
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
56
|
+
consola_1.default.error(message);
|
|
58
57
|
}
|
|
59
58
|
}),
|
|
60
59
|
});
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const axios_1 = require("axios");
|
|
18
17
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
19
18
|
const prompt_1 = require("../../../utils/prompt");
|
|
20
|
-
const
|
|
19
|
+
const app_devices_1 = __importDefault(require("../../../services/app-devices"));
|
|
20
|
+
const error_1 = require("../../../utils/error");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
23
23
|
description: 'Delete an app device.',
|
|
@@ -33,10 +33,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
36
|
let appId = ctx.args.appId;
|
|
38
37
|
if (!appId) {
|
|
39
38
|
const apps = yield apps_1.default.findAll();
|
|
39
|
+
if (!apps.length) {
|
|
40
|
+
consola_1.default.error('You must create an app before deleting a device.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
40
43
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
41
44
|
appId = yield (0, prompt_1.prompt)('Which app do you want to delete the device from?', {
|
|
42
45
|
type: 'select',
|
|
@@ -56,19 +59,15 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
try {
|
|
59
|
-
yield
|
|
62
|
+
yield app_devices_1.default.delete({
|
|
60
63
|
appId,
|
|
61
64
|
deviceId,
|
|
62
65
|
});
|
|
63
66
|
consola_1.default.success('Device deleted successfully.');
|
|
64
67
|
}
|
|
65
68
|
catch (error) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
consola_1.default.error('Failed to delete device.');
|
|
71
|
-
}
|
|
69
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
70
|
+
consola_1.default.error(message);
|
|
72
71
|
}
|
|
73
72
|
}),
|
|
74
73
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMessageFromUnknownError = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const getMessageFromUnknownError = (error) => {
|
|
6
|
+
let message = 'An unknown error has occurred.';
|
|
7
|
+
if (error instanceof axios_1.AxiosError) {
|
|
8
|
+
message = getErrorMessageFromAxiosError(error);
|
|
9
|
+
}
|
|
10
|
+
else if (error instanceof Error) {
|
|
11
|
+
message = error.message;
|
|
12
|
+
}
|
|
13
|
+
return message;
|
|
14
|
+
};
|
|
15
|
+
exports.getMessageFromUnknownError = getMessageFromUnknownError;
|
|
16
|
+
const getErrorMessageFromAxiosError = (error) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
18
|
+
let message = 'An unknown network error has occurred.';
|
|
19
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
20
|
+
message = 'Your token is no longer valid. Please sign in again.';
|
|
21
|
+
}
|
|
22
|
+
else if ((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) {
|
|
23
|
+
message = (_e = (_d = error.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.message;
|
|
24
|
+
}
|
|
25
|
+
else if ((_j = (_h = (_g = (_f = error.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.issues[0]) === null || _j === void 0 ? void 0 : _j.message) {
|
|
26
|
+
message = ((_k = error.response) === null || _k === void 0 ? void 0 : _k.data).error.issues[0].message;
|
|
27
|
+
}
|
|
28
|
+
return message;
|
|
29
|
+
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|