@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +7 -3
  3. package/dist/commands/apps/bundles/create.js +218 -234
  4. package/dist/commands/apps/bundles/create.test.js +276 -0
  5. package/dist/commands/apps/bundles/delete.js +47 -55
  6. package/dist/commands/apps/bundles/delete.test.js +139 -0
  7. package/dist/commands/apps/bundles/update.js +73 -84
  8. package/dist/commands/apps/bundles/update.test.js +141 -0
  9. package/dist/commands/apps/channels/create.js +57 -70
  10. package/dist/commands/apps/channels/create.test.js +119 -0
  11. package/dist/commands/apps/channels/delete.js +58 -64
  12. package/dist/commands/apps/channels/delete.test.js +141 -0
  13. package/dist/commands/apps/channels/get.js +52 -94
  14. package/dist/commands/apps/channels/get.test.js +135 -0
  15. package/dist/commands/apps/channels/list.js +37 -82
  16. package/dist/commands/apps/channels/list.test.js +121 -0
  17. package/dist/commands/apps/channels/update.js +50 -77
  18. package/dist/commands/apps/channels/update.test.js +138 -0
  19. package/dist/commands/apps/create.js +39 -42
  20. package/dist/commands/apps/create.test.js +117 -0
  21. package/dist/commands/apps/delete.js +41 -45
  22. package/dist/commands/apps/delete.test.js +120 -0
  23. package/dist/commands/apps/devices/delete.js +47 -55
  24. package/dist/commands/apps/devices/delete.test.js +139 -0
  25. package/dist/commands/doctor.js +12 -29
  26. package/dist/commands/doctor.test.js +52 -0
  27. package/dist/commands/login.js +50 -71
  28. package/dist/commands/login.test.js +116 -0
  29. package/dist/commands/logout.js +13 -31
  30. package/dist/commands/logout.test.js +47 -0
  31. package/dist/commands/manifests/generate.js +20 -38
  32. package/dist/commands/manifests/generate.test.js +60 -0
  33. package/dist/commands/organizations/create.js +25 -0
  34. package/dist/commands/organizations/create.test.js +80 -0
  35. package/dist/commands/whoami.js +20 -31
  36. package/dist/commands/whoami.test.js +30 -0
  37. package/dist/config/consts.js +4 -5
  38. package/dist/config/index.js +1 -17
  39. package/dist/index.js +54 -80
  40. package/dist/services/app-bundle-files.js +117 -136
  41. package/dist/services/app-bundles.js +22 -41
  42. package/dist/services/app-channels.js +54 -77
  43. package/dist/services/app-devices.js +10 -25
  44. package/dist/services/apps.js +25 -41
  45. package/dist/services/authorization-service.js +4 -8
  46. package/dist/services/config.js +15 -28
  47. package/dist/services/organizations.js +26 -0
  48. package/dist/services/session-code.js +7 -22
  49. package/dist/services/sessions.js +13 -30
  50. package/dist/services/update.js +17 -55
  51. package/dist/services/users.js +11 -26
  52. package/dist/types/app-bundle-file.js +1 -2
  53. package/dist/types/app-bundle.js +1 -2
  54. package/dist/types/app-channel.js +1 -2
  55. package/dist/types/app-device.js +1 -2
  56. package/dist/types/app.js +1 -2
  57. package/dist/types/index.js +8 -23
  58. package/dist/types/npm-package.js +1 -2
  59. package/dist/types/organization.js +1 -0
  60. package/dist/types/session-code.js +1 -2
  61. package/dist/types/session.js +1 -2
  62. package/dist/types/user.js +1 -2
  63. package/dist/utils/buffer.js +12 -43
  64. package/dist/utils/error.js +24 -14
  65. package/dist/utils/file.js +22 -41
  66. package/dist/utils/hash.js +3 -39
  67. package/dist/utils/http-client.js +27 -53
  68. package/dist/utils/manifest.js +11 -24
  69. package/dist/utils/private-key.js +23 -0
  70. package/dist/utils/prompt.js +9 -26
  71. package/dist/utils/signature.js +3 -39
  72. package/dist/utils/user-config.js +12 -0
  73. package/dist/utils/zip.js +11 -27
  74. package/package.json +22 -9
  75. package/dist/utils/ci.js +0 -7
  76. package/dist/utils/userConfig.js +0 -16
@@ -1,52 +1,33 @@
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"));
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
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield this.httpClient.post(`/v1/apps/${dto.appId}/bundles`, dto, {
24
- headers: {
25
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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
- return __awaiter(this, void 0, void 0, function* () {
33
- const response = yield this.httpClient.patch(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}`, dto, {
34
- headers: {
35
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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
- return __awaiter(this, void 0, void 0, function* () {
43
- yield this.httpClient.delete(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}`, {
44
- headers: {
45
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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(http_client_1.default);
52
- exports.default = appBundlesService;
32
+ const appBundlesService = new AppBundlesServiceImpl(httpClient);
33
+ export default appBundlesService;
@@ -1,94 +1,71 @@
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"));
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
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield this.httpClient.post(`/v1/apps/${dto.appId}/channels`, dto, {
24
- headers: {
25
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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
- return __awaiter(this, void 0, void 0, function* () {
33
- if (data.id) {
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 ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
20
+ Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
67
21
  },
68
22
  });
69
- return response.data;
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 ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
27
+ Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
28
+ },
29
+ params: {
30
+ name: data.name,
77
31
  },
78
32
  });
79
- return response.data;
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
- update(dto) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const response = yield this.httpClient.patch(`/v1/apps/${dto.appId}/channels/${dto.appChannelId}`, dto, {
85
- headers: {
86
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
87
- },
88
- });
89
- return response.data;
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(http_client_1.default);
94
- exports.default = appChannelsService;
70
+ const appChannelsService = new AppChannelsServiceImpl(httpClient);
71
+ export default appChannelsService;
@@ -1,32 +1,17 @@
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"));
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
- return __awaiter(this, void 0, void 0, function* () {
23
- yield this.httpClient.delete(`/v1/apps/${data.appId}/devices/${data.deviceId}`, {
24
- headers: {
25
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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(http_client_1.default);
32
- exports.default = appDevicesService;
16
+ const appDevicesService = new AppDevicesServiceImpl(httpClient);
17
+ export default appDevicesService;
@@ -1,52 +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"));
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
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield this.httpClient.post(`/v1/apps`, dto, {
24
- headers: {
25
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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
- return __awaiter(this, void 0, void 0, function* () {
33
- yield this.httpClient.delete(`/v1/apps/${dto.id}`, {
34
- headers: {
35
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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
- return __awaiter(this, void 0, void 0, function* () {
42
- const response = yield this.httpClient.get('/v1/apps', {
43
- headers: {
44
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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(http_client_1.default);
52
- exports.default = appsService;
35
+ const appsService = new AppsServiceImpl(httpClient);
36
+ export default appsService;
@@ -1,10 +1,6 @@
1
- "use strict";
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(userConfig_1.default);
19
- exports.default = authorizationService;
14
+ const authorizationService = new AuthorizationServiceImpl(userConfig);
15
+ export default authorizationService;
@@ -1,37 +1,24 @@
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
- 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 __awaiter(this, void 0, void 0, function* () {
19
- return (yield this.config)[key];
20
- });
8
+ async getValueForKey(key) {
9
+ return (await this.config)[key];
21
10
  }
22
- loadConfig() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const { config } = yield (0, c12_1.loadConfig)({
25
- defaults: {
26
- API_BASE_URL: 'https://api.cloud.capawesome.io',
27
- CONSOLE_BASE_URL: 'https://console.cloud.capawesome.io',
28
- ENVIRONMENT: 'production',
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
- exports.default = configService;
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
- "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"));
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
- return __awaiter(this, void 0, void 0, function* () {
22
- const response = yield this.httpClient.post(`/v1/sessions/codes`, {});
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(http_client_1.default);
28
- exports.default = sessionCodesService;
12
+ const sessionCodesService = new SessionCodesServiceImpl(httpClient);
13
+ export default sessionCodesService;
@@ -1,38 +1,21 @@
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"));
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
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield this.httpClient.post(`/v1/sessions`, dto);
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
- return __awaiter(this, void 0, void 0, function* () {
29
- yield this.httpClient.delete(`/v1/sessions/${dto.id}`, {
30
- headers: {
31
- Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
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(http_client_1.default);
38
- exports.default = sessionsService;
20
+ const sessionsService = new SessionsServiceImpl(httpClient);
21
+ export default sessionsService;
@@ -1,62 +1,24 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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
- return __awaiter(this, void 0, void 0, function* () {
48
- try {
49
- const response = yield this.httpClient.get(`https://registry.npmjs.org/${package_json_1.default.name}/latest`);
50
- const latestVersion = response.data.version;
51
- if (semver.gt(latestVersion, package_json_1.default.version)) {
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(http_client_1.default);
62
- exports.default = updateService;
23
+ const updateService = new UpdateServiceImpl(httpClient);
24
+ export default updateService;