@capawesome/cli 1.13.2 → 1.14.0-dev.3b0fc7e.1755934102
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 +7 -0
- package/README.md +7 -3
- package/dist/commands/apps/bundles/create.js +218 -234
- package/dist/commands/apps/bundles/create.test.js +276 -0
- package/dist/commands/apps/bundles/delete.js +47 -55
- package/dist/commands/apps/bundles/delete.test.js +139 -0
- package/dist/commands/apps/bundles/update.js +73 -84
- package/dist/commands/apps/bundles/update.test.js +141 -0
- package/dist/commands/apps/channels/create.js +57 -70
- package/dist/commands/apps/channels/create.test.js +119 -0
- package/dist/commands/apps/channels/delete.js +58 -64
- package/dist/commands/apps/channels/delete.test.js +141 -0
- package/dist/commands/apps/channels/get.js +52 -94
- package/dist/commands/apps/channels/get.test.js +135 -0
- package/dist/commands/apps/channels/list.js +37 -82
- package/dist/commands/apps/channels/list.test.js +121 -0
- package/dist/commands/apps/channels/update.js +50 -77
- package/dist/commands/apps/channels/update.test.js +138 -0
- package/dist/commands/apps/create.js +39 -42
- package/dist/commands/apps/create.test.js +117 -0
- package/dist/commands/apps/delete.js +41 -45
- package/dist/commands/apps/delete.test.js +120 -0
- package/dist/commands/apps/devices/delete.js +47 -55
- package/dist/commands/apps/devices/delete.test.js +139 -0
- package/dist/commands/doctor.js +12 -29
- package/dist/commands/doctor.test.js +52 -0
- package/dist/commands/login.js +50 -71
- package/dist/commands/login.test.js +116 -0
- package/dist/commands/logout.js +13 -31
- package/dist/commands/logout.test.js +47 -0
- package/dist/commands/manifests/generate.js +20 -38
- package/dist/commands/manifests/generate.test.js +60 -0
- package/dist/commands/organizations/create.js +25 -0
- package/dist/commands/organizations/create.test.js +80 -0
- package/dist/commands/whoami.js +20 -31
- package/dist/commands/whoami.test.js +30 -0
- package/dist/config/consts.js +4 -5
- package/dist/config/index.js +1 -17
- package/dist/index.js +54 -80
- package/dist/services/app-bundle-files.js +117 -136
- package/dist/services/app-bundles.js +22 -41
- package/dist/services/app-channels.js +54 -77
- package/dist/services/app-devices.js +10 -25
- package/dist/services/apps.js +25 -41
- package/dist/services/authorization-service.js +4 -8
- package/dist/services/config.js +15 -28
- package/dist/services/organizations.js +26 -0
- package/dist/services/session-code.js +7 -22
- package/dist/services/sessions.js +13 -30
- package/dist/services/update.js +17 -55
- package/dist/services/users.js +11 -26
- package/dist/types/app-bundle-file.js +1 -2
- package/dist/types/app-bundle.js +1 -2
- package/dist/types/app-channel.js +1 -2
- package/dist/types/app-device.js +1 -2
- package/dist/types/app.js +1 -2
- package/dist/types/index.js +8 -23
- package/dist/types/npm-package.js +1 -2
- package/dist/types/organization.js +1 -0
- package/dist/types/session-code.js +1 -2
- package/dist/types/session.js +1 -2
- package/dist/types/user.js +1 -2
- package/dist/utils/buffer.js +12 -43
- package/dist/utils/error.js +24 -14
- package/dist/utils/file.js +22 -41
- package/dist/utils/hash.js +3 -39
- package/dist/utils/http-client.js +27 -53
- package/dist/utils/manifest.js +11 -24
- package/dist/utils/private-key.js +23 -0
- package/dist/utils/prompt.js +9 -26
- package/dist/utils/signature.js +3 -39
- package/dist/utils/user-config.js +12 -0
- package/dist/utils/zip.js +11 -27
- package/package.json +22 -9
- package/dist/utils/ci.js +0 -7
- package/dist/utils/userConfig.js +0 -16
|
@@ -1,52 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
17
3
|
class AppBundlesServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
create(dto) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return response.data;
|
|
8
|
+
async create(dto) {
|
|
9
|
+
const response = await this.httpClient.post(`/v1/apps/${dto.appId}/bundles`, dto, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
12
|
+
},
|
|
29
13
|
});
|
|
14
|
+
return response.data;
|
|
30
15
|
}
|
|
31
|
-
update(dto) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
return response.data;
|
|
16
|
+
async update(dto) {
|
|
17
|
+
const response = await this.httpClient.patch(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}`, dto, {
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
20
|
+
},
|
|
39
21
|
});
|
|
22
|
+
return response.data;
|
|
40
23
|
}
|
|
41
|
-
delete(dto) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
});
|
|
24
|
+
async delete(dto) {
|
|
25
|
+
await this.httpClient.delete(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}`, {
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
28
|
+
},
|
|
48
29
|
});
|
|
49
30
|
}
|
|
50
31
|
}
|
|
51
|
-
const appBundlesService = new AppBundlesServiceImpl(
|
|
52
|
-
|
|
32
|
+
const appBundlesService = new AppBundlesServiceImpl(httpClient);
|
|
33
|
+
export default appBundlesService;
|
|
@@ -1,94 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
17
3
|
class AppChannelsServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
create(dto) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return response.data;
|
|
8
|
+
async create(dto) {
|
|
9
|
+
const response = await this.httpClient.post(`/v1/apps/${dto.appId}/channels`, dto, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
12
|
+
},
|
|
29
13
|
});
|
|
14
|
+
return response.data;
|
|
30
15
|
}
|
|
31
|
-
delete(data) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
yield this.httpClient.delete(`/v1/apps/${data.appId}/channels/${data.id}`, {
|
|
35
|
-
headers: {
|
|
36
|
-
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else if (data.name) {
|
|
41
|
-
yield this.httpClient.delete(`/v1/apps/${data.appId}/channels`, {
|
|
42
|
-
headers: {
|
|
43
|
-
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
44
|
-
},
|
|
45
|
-
params: {
|
|
46
|
-
name: data.name,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
findAll(dto) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const queryParams = new URLSearchParams();
|
|
55
|
-
if (dto.limit) {
|
|
56
|
-
queryParams.append('limit', dto.limit.toString());
|
|
57
|
-
}
|
|
58
|
-
if (dto.name) {
|
|
59
|
-
queryParams.append('name', dto.name);
|
|
60
|
-
}
|
|
61
|
-
if (dto.offset) {
|
|
62
|
-
queryParams.append('offset', dto.offset.toString());
|
|
63
|
-
}
|
|
64
|
-
const response = yield this.httpClient.get(`/v1/apps/${dto.appId}/channels?${queryParams}`, {
|
|
16
|
+
async delete(data) {
|
|
17
|
+
if (data.id) {
|
|
18
|
+
await this.httpClient.delete(`/v1/apps/${data.appId}/channels/${data.id}`, {
|
|
65
19
|
headers: {
|
|
66
|
-
Authorization: `Bearer ${
|
|
20
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
67
21
|
},
|
|
68
22
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
findOneById(data) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const response = yield this.httpClient.get(`/v1/apps/${data.appId}/channels/${data.id}`, {
|
|
23
|
+
}
|
|
24
|
+
else if (data.name) {
|
|
25
|
+
await this.httpClient.delete(`/v1/apps/${data.appId}/channels`, {
|
|
75
26
|
headers: {
|
|
76
|
-
Authorization: `Bearer ${
|
|
27
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
28
|
+
},
|
|
29
|
+
params: {
|
|
30
|
+
name: data.name,
|
|
77
31
|
},
|
|
78
32
|
});
|
|
79
|
-
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async findAll(dto) {
|
|
36
|
+
const queryParams = new URLSearchParams();
|
|
37
|
+
if (dto.limit) {
|
|
38
|
+
queryParams.append('limit', dto.limit.toString());
|
|
39
|
+
}
|
|
40
|
+
if (dto.name) {
|
|
41
|
+
queryParams.append('name', dto.name);
|
|
42
|
+
}
|
|
43
|
+
if (dto.offset) {
|
|
44
|
+
queryParams.append('offset', dto.offset.toString());
|
|
45
|
+
}
|
|
46
|
+
const response = await this.httpClient.get(`/v1/apps/${dto.appId}/channels?${queryParams}`, {
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
49
|
+
},
|
|
80
50
|
});
|
|
51
|
+
return response.data;
|
|
81
52
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
async findOneById(data) {
|
|
54
|
+
const response = await this.httpClient.get(`/v1/apps/${data.appId}/channels/${data.id}`, {
|
|
55
|
+
headers: {
|
|
56
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
async update(dto) {
|
|
62
|
+
const response = await this.httpClient.patch(`/v1/apps/${dto.appId}/channels/${dto.appChannelId}`, dto, {
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
65
|
+
},
|
|
90
66
|
});
|
|
67
|
+
return response.data;
|
|
91
68
|
}
|
|
92
69
|
}
|
|
93
|
-
const appChannelsService = new AppChannelsServiceImpl(
|
|
94
|
-
|
|
70
|
+
const appChannelsService = new AppChannelsServiceImpl(httpClient);
|
|
71
|
+
export default appChannelsService;
|
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
17
3
|
class AppDevicesServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
delete(data) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
});
|
|
8
|
+
async delete(data) {
|
|
9
|
+
await this.httpClient.delete(`/v1/apps/${data.appId}/devices/${data.deviceId}`, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
12
|
+
},
|
|
28
13
|
});
|
|
29
14
|
}
|
|
30
15
|
}
|
|
31
|
-
const appDevicesService = new AppDevicesServiceImpl(
|
|
32
|
-
|
|
16
|
+
const appDevicesService = new AppDevicesServiceImpl(httpClient);
|
|
17
|
+
export default appDevicesService;
|
package/dist/services/apps.js
CHANGED
|
@@ -1,52 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import authorizationService from '../services/authorization-service.js';
|
|
2
|
+
import httpClient from '../utils/http-client.js';
|
|
17
3
|
class AppsServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
create(dto) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return response.data;
|
|
8
|
+
async create(dto) {
|
|
9
|
+
const params = new URLSearchParams({ organizationId: dto.organizationId });
|
|
10
|
+
const { organizationId, ...bodyData } = dto;
|
|
11
|
+
const response = await this.httpClient.post(`/v1/apps?${params.toString()}`, bodyData, {
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
14
|
+
},
|
|
29
15
|
});
|
|
16
|
+
return response.data;
|
|
30
17
|
}
|
|
31
|
-
delete(dto) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
});
|
|
18
|
+
async delete(dto) {
|
|
19
|
+
await this.httpClient.delete(`/v1/apps/${dto.id}`, {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
22
|
+
},
|
|
38
23
|
});
|
|
39
24
|
}
|
|
40
|
-
findAll() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
return response.data;
|
|
25
|
+
async findAll(dto) {
|
|
26
|
+
const params = new URLSearchParams({ organizationId: dto.organizationId });
|
|
27
|
+
const response = await this.httpClient.get(`/v1/apps?${params.toString()}`, {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
30
|
+
},
|
|
48
31
|
});
|
|
32
|
+
return response.data;
|
|
49
33
|
}
|
|
50
34
|
}
|
|
51
|
-
const appsService = new AppsServiceImpl(
|
|
52
|
-
|
|
35
|
+
const appsService = new AppsServiceImpl(httpClient);
|
|
36
|
+
export default appsService;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
1
|
+
import userConfig from '../utils/user-config.js';
|
|
7
2
|
class AuthorizationServiceImpl {
|
|
3
|
+
userConfig;
|
|
8
4
|
constructor(userConfig) {
|
|
9
5
|
this.userConfig = userConfig;
|
|
10
6
|
}
|
|
@@ -15,5 +11,5 @@ class AuthorizationServiceImpl {
|
|
|
15
11
|
return !!this.getCurrentAuthorizationToken();
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
|
-
const authorizationService = new AuthorizationServiceImpl(
|
|
19
|
-
|
|
14
|
+
const authorizationService = new AuthorizationServiceImpl(userConfig);
|
|
15
|
+
export default authorizationService;
|
package/dist/services/config.js
CHANGED
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const c12_1 = require("c12");
|
|
1
|
+
import { DEFAULT_API_BASE_URL, DEFAULT_CONSOLE_BASE_URL } from '../config/consts.js';
|
|
2
|
+
import { loadConfig } from 'c12';
|
|
13
3
|
class ConfigServiceImpl {
|
|
4
|
+
config;
|
|
14
5
|
constructor() {
|
|
15
6
|
this.config = this.loadConfig();
|
|
16
7
|
}
|
|
17
|
-
getValueForKey(key) {
|
|
18
|
-
return
|
|
19
|
-
return (yield this.config)[key];
|
|
20
|
-
});
|
|
8
|
+
async getValueForKey(key) {
|
|
9
|
+
return (await this.config)[key];
|
|
21
10
|
}
|
|
22
|
-
loadConfig() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
name: 'capawesome',
|
|
31
|
-
});
|
|
32
|
-
return config;
|
|
11
|
+
async loadConfig() {
|
|
12
|
+
const { config } = await loadConfig({
|
|
13
|
+
defaults: {
|
|
14
|
+
API_BASE_URL: DEFAULT_API_BASE_URL,
|
|
15
|
+
CONSOLE_BASE_URL: DEFAULT_CONSOLE_BASE_URL,
|
|
16
|
+
ENVIRONMENT: 'production',
|
|
17
|
+
},
|
|
18
|
+
name: 'capawesome',
|
|
33
19
|
});
|
|
20
|
+
return config;
|
|
34
21
|
}
|
|
35
22
|
}
|
|
36
23
|
const configService = new ConfigServiceImpl();
|
|
37
|
-
|
|
24
|
+
export default configService;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
3
|
+
class OrganizationsServiceImpl {
|
|
4
|
+
httpClient;
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
async create(dto) {
|
|
9
|
+
const response = await this.httpClient.post('/v1/organizations', dto, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
async findAll() {
|
|
17
|
+
const response = await this.httpClient.get(`/v1/organizations`, {
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const organizationsService = new OrganizationsServiceImpl(httpClient);
|
|
26
|
+
export default organizationsService;
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
|
|
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"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
16
2
|
class SessionCodesServiceImpl {
|
|
3
|
+
httpClient;
|
|
17
4
|
constructor(httpClient) {
|
|
18
5
|
this.httpClient = httpClient;
|
|
19
6
|
}
|
|
20
|
-
create() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return response.data;
|
|
24
|
-
});
|
|
7
|
+
async create() {
|
|
8
|
+
const response = await this.httpClient.post(`/v1/sessions/codes`, {});
|
|
9
|
+
return response.data;
|
|
25
10
|
}
|
|
26
11
|
}
|
|
27
|
-
const sessionCodesService = new SessionCodesServiceImpl(
|
|
28
|
-
|
|
12
|
+
const sessionCodesService = new SessionCodesServiceImpl(httpClient);
|
|
13
|
+
export default sessionCodesService;
|
|
@@ -1,38 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
17
3
|
class SessionsServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
create(dto) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return response.data;
|
|
25
|
-
});
|
|
8
|
+
async create(dto) {
|
|
9
|
+
const response = await this.httpClient.post(`/v1/sessions`, dto);
|
|
10
|
+
return response.data;
|
|
26
11
|
}
|
|
27
|
-
delete(dto) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
});
|
|
12
|
+
async delete(dto) {
|
|
13
|
+
await this.httpClient.delete(`/v1/sessions/${dto.id}`, {
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
16
|
+
},
|
|
34
17
|
});
|
|
35
18
|
}
|
|
36
19
|
}
|
|
37
|
-
const sessionsService = new SessionsServiceImpl(
|
|
38
|
-
|
|
20
|
+
const sessionsService = new SessionsServiceImpl(httpClient);
|
|
21
|
+
export default sessionsService;
|
package/dist/services/update.js
CHANGED
|
@@ -1,62 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const consola_1 = __importDefault(require("consola"));
|
|
39
|
-
const semver = __importStar(require("semver"));
|
|
40
|
-
const package_json_1 = __importDefault(require("../../package.json"));
|
|
41
|
-
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
1
|
+
import consola from 'consola';
|
|
2
|
+
import * as semver from 'semver';
|
|
3
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
4
|
+
import httpClient from '../utils/http-client.js';
|
|
42
5
|
class UpdateServiceImpl {
|
|
6
|
+
httpClient;
|
|
43
7
|
constructor(httpClient) {
|
|
44
8
|
this.httpClient = httpClient;
|
|
45
9
|
}
|
|
46
|
-
checkForUpdate() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
consola_1.default.warn(`New version of Capawesome CLI available: ${package_json_1.default.name}@${latestVersion}. Please update to receive the latest features and bug fixes.`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
consola_1.default.warn('Failed to check for updates.');
|
|
10
|
+
async checkForUpdate() {
|
|
11
|
+
try {
|
|
12
|
+
const response = await this.httpClient.get(`https://registry.npmjs.org/${pkg.name}/latest`);
|
|
13
|
+
const latestVersion = response.data.version;
|
|
14
|
+
if (semver.gt(latestVersion, pkg.version)) {
|
|
15
|
+
consola.warn(`New version of Capawesome CLI available: ${pkg.name}@${latestVersion}. Please update to receive the latest features and bug fixes.`);
|
|
57
16
|
}
|
|
58
|
-
}
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
consola.warn('Failed to check for updates.');
|
|
20
|
+
}
|
|
59
21
|
}
|
|
60
22
|
}
|
|
61
|
-
const updateService = new UpdateServiceImpl(
|
|
62
|
-
|
|
23
|
+
const updateService = new UpdateServiceImpl(httpClient);
|
|
24
|
+
export default updateService;
|