@capawesome/cli 0.0.3 → 0.0.5
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 +20 -0
- package/dist/commands/apps/bundles/create.js +14 -8
- package/dist/commands/apps/bundles/delete.js +2 -7
- package/dist/commands/apps/channels/create.js +2 -7
- package/dist/commands/apps/channels/delete.js +2 -7
- package/dist/commands/apps/create.js +1 -6
- package/dist/commands/apps/delete.js +1 -6
- package/dist/commands/apps/devices/delete.js +2 -7
- package/dist/commands/login.js +41 -23
- package/dist/commands/logout.js +1 -4
- package/dist/commands/whoami.js +11 -4
- package/dist/{service → services}/authorization-service.js +1 -5
- package/dist/services/users.js +36 -0
- package/dist/types/index.js +1 -0
- package/dist/types/user.js +2 -0
- package/package.json +1 -1
- /package/dist/{service → services}/app-bundle.js +0 -0
- /package/dist/{service → services}/app-channel.js +0 -0
- /package/dist/{service → services}/app-device.js +0 -0
- /package/dist/{service → services}/apps.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.5](https://github.com/capawesome-team/cli/compare/v0.0.4...v0.0.5) (2024-05-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **login:** add `--token` option ([2cdd649](https://github.com/capawesome-team/cli/commit/2cdd649bec96fbdb8a43e16a08b256b16a98a662))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* allow execution of commands in ci ([4ce7ea6](https://github.com/capawesome-team/cli/commit/4ce7ea6e23c5cb15543df8a215274287134682e8))
|
|
16
|
+
* read user config in ci ([f404989](https://github.com/capawesome-team/cli/commit/f4049890e5ebac15af5491d4ee04e7fcb6e15235))
|
|
17
|
+
|
|
18
|
+
## [0.0.4](https://github.com/capawesome-team/cli/compare/v0.0.3...v0.0.4) (2024-04-30)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **apps:** improve error message for `apps:bundles:create` ([79dc82c](https://github.com/capawesome-team/cli/commit/79dc82ce7ce7600fa3885f42b4af73a368e3249a))
|
|
24
|
+
|
|
5
25
|
## [0.0.3](https://github.com/capawesome-team/cli/compare/v0.0.2...v0.0.3) (2024-04-27)
|
|
6
26
|
|
|
7
27
|
|
|
@@ -19,9 +19,9 @@ const axios_1 = require("axios");
|
|
|
19
19
|
const zip_1 = __importDefault(require("../../../utils/zip"));
|
|
20
20
|
const form_data_1 = __importDefault(require("form-data"));
|
|
21
21
|
const node_fs_1 = require("node:fs");
|
|
22
|
-
const authorization_service_1 = __importDefault(require("../../../
|
|
23
|
-
const apps_1 = __importDefault(require("../../../
|
|
24
|
-
const app_bundle_1 = __importDefault(require("../../../
|
|
22
|
+
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
23
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
24
|
+
const app_bundle_1 = __importDefault(require("../../../services/app-bundle"));
|
|
25
25
|
exports.default = (0, citty_1.defineCommand)({
|
|
26
26
|
meta: {
|
|
27
27
|
description: 'Create a new app bundle.',
|
|
@@ -41,7 +41,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b, _c;
|
|
45
45
|
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
46
46
|
consola_1.default.error('You must be logged in to run this command.');
|
|
47
47
|
return;
|
|
@@ -83,10 +83,10 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
83
83
|
const zipBuffer = yield zip_1.default.zipFolder(path);
|
|
84
84
|
formData.append('file', zipBuffer, { filename: 'bundle.zip' });
|
|
85
85
|
}
|
|
86
|
-
consola_1.default.start('Uploading...');
|
|
87
86
|
if (channelName) {
|
|
88
87
|
formData.append('channelName', channelName);
|
|
89
88
|
}
|
|
89
|
+
consola_1.default.start('Uploading...');
|
|
90
90
|
// Upload the bundle
|
|
91
91
|
try {
|
|
92
92
|
const response = yield app_bundle_1.default.create({ appId: appId, formData: formData });
|
|
@@ -94,11 +94,17 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
94
94
|
consola_1.default.info(`Bundle ID: ${response.id}`);
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
const defaultErrorMessage = 'Failed to create bundle.';
|
|
98
|
+
if (error instanceof axios_1.AxiosError) {
|
|
99
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
100
|
+
consola_1.default.error('Your token is no longer valid. Please sign in again.');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
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);
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
106
|
else {
|
|
101
|
-
consola_1.default.error(
|
|
107
|
+
consola_1.default.error(defaultErrorMessage);
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
}),
|
|
@@ -15,10 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const
|
|
19
|
-
const apps_1 = __importDefault(require("../../../service/apps"));
|
|
18
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_bundle_1 = __importDefault(require("../../../
|
|
20
|
+
const app_bundle_1 = __importDefault(require("../../../services/app-bundle"));
|
|
22
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
22
|
meta: {
|
|
24
23
|
description: 'Delete an app bundle.',
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -13,12 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../../
|
|
18
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const axios_1 = require("axios");
|
|
21
|
-
const app_channel_1 = __importDefault(require("../../../
|
|
20
|
+
const app_channel_1 = __importDefault(require("../../../services/app-channel"));
|
|
22
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
22
|
meta: {
|
|
24
23
|
description: 'Create a new app channel.',
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -15,10 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const
|
|
19
|
-
const apps_1 = __importDefault(require("../../../service/apps"));
|
|
18
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_channel_1 = __importDefault(require("../../../
|
|
20
|
+
const app_channel_1 = __importDefault(require("../../../services/app-channel"));
|
|
22
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
22
|
meta: {
|
|
24
23
|
description: 'Delete an app channel.',
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -13,10 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../
|
|
18
|
+
const apps_1 = __importDefault(require("../../services/apps"));
|
|
20
19
|
const axios_1 = require("axios");
|
|
21
20
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
21
|
meta: {
|
|
@@ -30,10 +29,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
30
29
|
},
|
|
31
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
31
|
var _a;
|
|
33
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
34
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
32
|
let name = ctx.args.name;
|
|
38
33
|
if (!name) {
|
|
39
34
|
name = yield (0, prompt_1.prompt)('Enter the name of the app:', { type: 'text' });
|
|
@@ -13,10 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../
|
|
18
|
+
const apps_1 = __importDefault(require("../../services/apps"));
|
|
20
19
|
const axios_1 = require("axios");
|
|
21
20
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
21
|
meta: {
|
|
@@ -30,10 +29,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
30
29
|
},
|
|
31
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
31
|
var _a;
|
|
33
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
34
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
32
|
let appId = ctx.args.appId;
|
|
38
33
|
if (!appId) {
|
|
39
34
|
const apps = yield apps_1.default.findAll();
|
|
@@ -15,10 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const
|
|
19
|
-
const apps_1 = __importDefault(require("../../../service/apps"));
|
|
18
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_device_1 = __importDefault(require("../../../
|
|
20
|
+
const app_device_1 = __importDefault(require("../../../services/app-device"));
|
|
22
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
22
|
meta: {
|
|
24
23
|
description: 'Delete an app device.',
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
package/dist/commands/login.js
CHANGED
|
@@ -18,37 +18,55 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
18
18
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
19
19
|
const config_1 = require("../config");
|
|
20
20
|
const prompt_1 = require("../utils/prompt");
|
|
21
|
-
const
|
|
21
|
+
const users_1 = __importDefault(require("../services/users"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
name: 'login',
|
|
25
25
|
description: 'Sign in to the Capawesome Cloud Console.',
|
|
26
26
|
},
|
|
27
|
+
args: {
|
|
28
|
+
token: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Token to use for authentication.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
27
33
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const email = yield (0, prompt_1.prompt)('Enter your email:', { type: 'text' });
|
|
33
|
-
const password = yield (0, prompt_1.passwordPrompt)('Enter your password:');
|
|
34
|
-
consola_1.default.start('Logging in...');
|
|
35
|
-
let sessionId;
|
|
36
|
-
try {
|
|
37
|
-
const sessionResponse = yield axios_1.default.post(`${config_1.API_URL}/sessions`, {
|
|
38
|
-
email: email,
|
|
39
|
-
password: password,
|
|
34
|
+
let token = ctx.args.token;
|
|
35
|
+
if (token) {
|
|
36
|
+
userConfig_1.default.write({
|
|
37
|
+
token: token,
|
|
40
38
|
});
|
|
41
|
-
|
|
39
|
+
try {
|
|
40
|
+
yield users_1.default.me();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
userConfig_1.default.write({});
|
|
44
|
+
consola_1.default.error('Invalid token.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
consola_1.default.success(`Successfully signed in.`);
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
else {
|
|
50
|
+
const email = yield (0, prompt_1.prompt)('Enter your email:', { type: 'text' });
|
|
51
|
+
const password = yield (0, prompt_1.passwordPrompt)('Enter your password:');
|
|
52
|
+
consola_1.default.start('Logging in...');
|
|
53
|
+
let sessionId;
|
|
54
|
+
try {
|
|
55
|
+
const sessionResponse = yield axios_1.default.post(`${config_1.API_URL}/sessions`, {
|
|
56
|
+
email: email,
|
|
57
|
+
password: password,
|
|
58
|
+
});
|
|
59
|
+
sessionId = sessionResponse.data.id;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
consola_1.default.error('Invalid email or password.');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const tokenResponse = yield axios_1.default.post(`${config_1.API_URL}/tokens`, { name: 'Capawesome CLI' }, { headers: { Authorization: `Bearer ${sessionId}` } });
|
|
66
|
+
userConfig_1.default.write({
|
|
67
|
+
token: tokenResponse.data.token,
|
|
68
|
+
});
|
|
69
|
+
consola_1.default.success(`Successfully signed in.`);
|
|
46
70
|
}
|
|
47
|
-
const tokenResponse = yield axios_1.default.post(`${config_1.API_URL}/tokens`, { name: 'Capawesome CLI' }, { headers: { Authorization: `Bearer ${sessionId}` } });
|
|
48
|
-
userConfig_1.default.write({
|
|
49
|
-
username: email,
|
|
50
|
-
token: tokenResponse.data.token,
|
|
51
|
-
});
|
|
52
|
-
consola_1.default.success(`Successfully signed in.`);
|
|
53
71
|
}),
|
|
54
72
|
});
|
package/dist/commands/logout.js
CHANGED
|
@@ -22,10 +22,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
22
22
|
},
|
|
23
23
|
args: {},
|
|
24
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
delete config.username;
|
|
27
|
-
delete config.token;
|
|
28
|
-
userConfig_1.default.write(config);
|
|
25
|
+
userConfig_1.default.write({});
|
|
29
26
|
consola_1.default.success('Successfully signed out.');
|
|
30
27
|
}),
|
|
31
28
|
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -15,18 +15,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
18
|
+
const users_1 = __importDefault(require("../services/users"));
|
|
18
19
|
exports.default = (0, citty_1.defineCommand)({
|
|
19
20
|
meta: {
|
|
20
21
|
name: 'whoami',
|
|
21
22
|
description: 'Show current user',
|
|
22
23
|
},
|
|
23
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
const {
|
|
25
|
-
if (
|
|
26
|
-
|
|
25
|
+
const { token } = userConfig_1.default.read();
|
|
26
|
+
if (token) {
|
|
27
|
+
try {
|
|
28
|
+
const user = yield users_1.default.me();
|
|
29
|
+
consola_1.default.info(`Logged in as ${user.email}.`);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
consola_1.default.error('Token is invalid. Please sign in again.');
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
35
|
else {
|
|
29
|
-
consola_1.default.
|
|
36
|
+
consola_1.default.error('Not logged in.');
|
|
30
37
|
}
|
|
31
38
|
}),
|
|
32
39
|
});
|
|
@@ -3,17 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ci_1 = require("../utils/ci");
|
|
7
6
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
8
7
|
class AuthorizationServiceImpl {
|
|
9
8
|
constructor(userConfig) {
|
|
10
9
|
this.userConfig = userConfig;
|
|
11
10
|
}
|
|
12
11
|
getCurrentAuthorizationToken() {
|
|
13
|
-
|
|
14
|
-
return process.env.CAPAWESOME_TOKEN || null;
|
|
15
|
-
}
|
|
16
|
-
return this.userConfig.read().token || null;
|
|
12
|
+
return this.userConfig.read().token || process.env.CAPAWESOME_TOKEN || null;
|
|
17
13
|
}
|
|
18
14
|
hasAuthorizationToken() {
|
|
19
15
|
return !!this.getCurrentAuthorizationToken();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class UsersServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
me() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const response = yield this.httpClient.get('/users/me', {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.success) {
|
|
29
|
+
throw response.error;
|
|
30
|
+
}
|
|
31
|
+
return response.data;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const usersService = new UsersServiceImpl(http_client_1.default);
|
|
36
|
+
exports.default = usersService;
|
package/dist/types/index.js
CHANGED
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|