@capawesome/cli 1.14.0 → 2.0.0
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 +27 -0
- package/README.md +7 -3
- package/dist/commands/apps/bundles/create.js +206 -239
- package/dist/commands/apps/bundles/create.test.js +276 -0
- package/dist/commands/apps/bundles/delete.js +35 -60
- package/dist/commands/apps/bundles/delete.test.js +139 -0
- package/dist/commands/apps/bundles/update.js +61 -89
- package/dist/commands/apps/bundles/update.test.js +141 -0
- package/dist/commands/apps/channels/create.js +45 -75
- package/dist/commands/apps/channels/create.test.js +119 -0
- package/dist/commands/apps/channels/delete.js +46 -69
- 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 +39 -83
- package/dist/commands/apps/channels/update.test.js +138 -0
- package/dist/commands/apps/create.js +28 -53
- package/dist/commands/apps/create.test.js +117 -0
- package/dist/commands/apps/delete.js +29 -50
- package/dist/commands/apps/delete.test.js +120 -0
- package/dist/commands/apps/devices/delete.js +35 -60
- 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 -43
- package/dist/services/authorization-service.js +4 -8
- package/dist/services/config.js +15 -28
- package/dist/services/organizations.js +19 -26
- 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 -24
- package/dist/types/npm-package.js +1 -2
- package/dist/types/organization.js +1 -2
- 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,155 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 form_data_1 = __importDefault(require("form-data"));
|
|
16
|
-
const config_1 = require("../config");
|
|
17
|
-
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
18
|
-
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
1
|
+
import FormData from 'form-data';
|
|
2
|
+
import { MAX_CONCURRENT_UPLOADS } from '../config/index.js';
|
|
3
|
+
import httpClient from '../utils/http-client.js';
|
|
4
|
+
import authorizationService from '../services/authorization-service.js';
|
|
19
5
|
class AppBundleFilesServiceImpl {
|
|
6
|
+
httpClient;
|
|
20
7
|
constructor(httpClient) {
|
|
21
8
|
this.httpClient = httpClient;
|
|
22
9
|
}
|
|
23
|
-
create(dto) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
yield this.upload({
|
|
46
|
-
appBundleFileId: response.data.id,
|
|
47
|
-
appBundleId: dto.appBundleId,
|
|
48
|
-
appId: dto.appId,
|
|
49
|
-
buffer: dto.buffer,
|
|
50
|
-
name: dto.name,
|
|
51
|
-
checksum: dto.checksum,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return response.data;
|
|
10
|
+
async create(dto) {
|
|
11
|
+
const sizeInBytes = dto.buffer.byteLength;
|
|
12
|
+
const useMultipartUpload = sizeInBytes >= 100 * 1024 * 1024; // 100 MB
|
|
13
|
+
const formData = new FormData();
|
|
14
|
+
formData.append('checksum', dto.checksum);
|
|
15
|
+
if (!useMultipartUpload) {
|
|
16
|
+
formData.append('file', dto.buffer, { filename: dto.name });
|
|
17
|
+
}
|
|
18
|
+
if (dto.href) {
|
|
19
|
+
formData.append('href', dto.href);
|
|
20
|
+
}
|
|
21
|
+
formData.append('mimeType', dto.mimeType);
|
|
22
|
+
formData.append('name', dto.name);
|
|
23
|
+
if (dto.signature) {
|
|
24
|
+
formData.append('signature', dto.signature);
|
|
25
|
+
}
|
|
26
|
+
formData.append('sizeInBytes', sizeInBytes.toString());
|
|
27
|
+
const response = await this.httpClient.post(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}/files`, formData, {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
30
|
+
...formData.getHeaders(),
|
|
31
|
+
},
|
|
55
32
|
});
|
|
33
|
+
if (useMultipartUpload) {
|
|
34
|
+
await this.upload({
|
|
35
|
+
appBundleFileId: response.data.id,
|
|
36
|
+
appBundleId: dto.appBundleId,
|
|
37
|
+
appId: dto.appId,
|
|
38
|
+
buffer: dto.buffer,
|
|
39
|
+
name: dto.name,
|
|
40
|
+
checksum: dto.checksum,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return response.data;
|
|
56
44
|
}
|
|
57
|
-
completeUpload(dto) {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.then((response) => response.data);
|
|
68
|
-
});
|
|
45
|
+
async completeUpload(dto) {
|
|
46
|
+
return this.httpClient
|
|
47
|
+
.post(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}/files/${dto.appBundleFileId}/upload?action=mpu-complete&uploadId=${dto.uploadId}`, {
|
|
48
|
+
parts: dto.parts,
|
|
49
|
+
}, {
|
|
50
|
+
headers: {
|
|
51
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
.then((response) => response.data);
|
|
69
55
|
}
|
|
70
|
-
createUpload(dto) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
return response.data;
|
|
56
|
+
async createUpload(dto) {
|
|
57
|
+
const response = await this.httpClient.post(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}/files/${dto.appBundleFileId}/upload?action=mpu-create`, {}, {
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
60
|
+
},
|
|
78
61
|
});
|
|
62
|
+
return response.data;
|
|
79
63
|
}
|
|
80
|
-
createUploadPart(dto) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
64
|
+
async createUploadPart(dto) {
|
|
65
|
+
const formData = new FormData();
|
|
66
|
+
formData.append('blob', dto.buffer, { filename: dto.name });
|
|
67
|
+
formData.append('partNumber', dto.partNumber.toString());
|
|
68
|
+
return this.httpClient
|
|
69
|
+
.put(`/v1/apps/${dto.appId}/bundles/${dto.appBundleId}/files/${dto.appBundleFileId}/upload?action=mpu-uploadpart&uploadId=${dto.uploadId}`, formData, {
|
|
70
|
+
headers: {
|
|
71
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
72
|
+
...formData.getHeaders(),
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
.then((response) => response.data);
|
|
91
76
|
}
|
|
92
|
-
createUploadParts(dto) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
partNumber++;
|
|
103
|
-
const start = (partNumber - 1) * partSize;
|
|
104
|
-
const end = Math.min(start + partSize, dto.buffer.byteLength);
|
|
105
|
-
const partBuffer = dto.buffer.subarray(start, end);
|
|
106
|
-
const uploadedPart = yield this.createUploadPart({
|
|
107
|
-
appBundleFileId: dto.appBundleFileId,
|
|
108
|
-
appBundleId: dto.appBundleId,
|
|
109
|
-
appId: dto.appId,
|
|
110
|
-
buffer: partBuffer,
|
|
111
|
-
name: dto.name,
|
|
112
|
-
partNumber,
|
|
113
|
-
uploadId: dto.uploadId,
|
|
114
|
-
});
|
|
115
|
-
uploadedParts.push(uploadedPart);
|
|
116
|
-
yield uploadNextPart();
|
|
117
|
-
});
|
|
118
|
-
const uploadPartPromises = Array.from({ length: config_1.MAX_CONCURRENT_UPLOADS });
|
|
119
|
-
for (let i = 0; i < config_1.MAX_CONCURRENT_UPLOADS; i++) {
|
|
120
|
-
uploadPartPromises[i] = uploadNextPart();
|
|
77
|
+
async createUploadParts(dto) {
|
|
78
|
+
const uploadedParts = [];
|
|
79
|
+
const partSize = 10 * 1024 * 1024; // 10 MB. 5 MB is the minimum part size except for the last part.
|
|
80
|
+
const totalParts = Math.ceil(dto.buffer.byteLength / partSize);
|
|
81
|
+
let partNumber = 0;
|
|
82
|
+
const uploadNextPart = async () => {
|
|
83
|
+
if (partNumber >= totalParts) {
|
|
84
|
+
return;
|
|
121
85
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
// 1. Create a multipart upload
|
|
129
|
-
const { uploadId } = yield this.createUpload({
|
|
86
|
+
partNumber++;
|
|
87
|
+
const start = (partNumber - 1) * partSize;
|
|
88
|
+
const end = Math.min(start + partSize, dto.buffer.byteLength);
|
|
89
|
+
const partBuffer = dto.buffer.subarray(start, end);
|
|
90
|
+
const uploadedPart = await this.createUploadPart({
|
|
130
91
|
appBundleFileId: dto.appBundleFileId,
|
|
131
92
|
appBundleId: dto.appBundleId,
|
|
132
93
|
appId: dto.appId,
|
|
133
|
-
|
|
134
|
-
// 2. Upload the file in parts
|
|
135
|
-
const parts = yield this.createUploadParts({
|
|
136
|
-
appBundleFileId: dto.appBundleFileId,
|
|
137
|
-
appBundleId: dto.appBundleId,
|
|
138
|
-
appId: dto.appId,
|
|
139
|
-
buffer: dto.buffer,
|
|
94
|
+
buffer: partBuffer,
|
|
140
95
|
name: dto.name,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// 3. Complete the upload
|
|
144
|
-
yield this.completeUpload({
|
|
145
|
-
appBundleFileId: dto.appBundleFileId,
|
|
146
|
-
appBundleId: dto.appBundleId,
|
|
147
|
-
appId: dto.appId,
|
|
148
|
-
parts,
|
|
149
|
-
uploadId,
|
|
96
|
+
partNumber,
|
|
97
|
+
uploadId: dto.uploadId,
|
|
150
98
|
});
|
|
99
|
+
uploadedParts.push(uploadedPart);
|
|
100
|
+
await uploadNextPart();
|
|
101
|
+
};
|
|
102
|
+
const uploadPartPromises = Array.from({ length: MAX_CONCURRENT_UPLOADS });
|
|
103
|
+
for (let i = 0; i < MAX_CONCURRENT_UPLOADS; i++) {
|
|
104
|
+
uploadPartPromises[i] = uploadNextPart();
|
|
105
|
+
}
|
|
106
|
+
await Promise.all(uploadPartPromises);
|
|
107
|
+
return uploadedParts;
|
|
108
|
+
}
|
|
109
|
+
async upload(dto) {
|
|
110
|
+
// 1. Create a multipart upload
|
|
111
|
+
const { uploadId } = await this.createUpload({
|
|
112
|
+
appBundleFileId: dto.appBundleFileId,
|
|
113
|
+
appBundleId: dto.appBundleId,
|
|
114
|
+
appId: dto.appId,
|
|
115
|
+
});
|
|
116
|
+
// 2. Upload the file in parts
|
|
117
|
+
const parts = await this.createUploadParts({
|
|
118
|
+
appBundleFileId: dto.appBundleFileId,
|
|
119
|
+
appBundleId: dto.appBundleId,
|
|
120
|
+
appId: dto.appId,
|
|
121
|
+
buffer: dto.buffer,
|
|
122
|
+
name: dto.name,
|
|
123
|
+
uploadId,
|
|
124
|
+
});
|
|
125
|
+
// 3. Complete the upload
|
|
126
|
+
await this.completeUpload({
|
|
127
|
+
appBundleFileId: dto.appBundleFileId,
|
|
128
|
+
appBundleId: dto.appBundleId,
|
|
129
|
+
appId: dto.appId,
|
|
130
|
+
parts,
|
|
131
|
+
uploadId,
|
|
151
132
|
});
|
|
152
133
|
}
|
|
153
134
|
}
|
|
154
|
-
const appBundleFilesService = new AppBundleFilesServiceImpl(
|
|
155
|
-
|
|
135
|
+
const appBundleFilesService = new AppBundleFilesServiceImpl(httpClient);
|
|
136
|
+
export default appBundleFilesService;
|
|
@@ -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,54 +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
|
-
});
|
|
29
|
-
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
|
+
},
|
|
30
15
|
});
|
|
16
|
+
return response.data;
|
|
31
17
|
}
|
|
32
|
-
delete(dto) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
});
|
|
18
|
+
async delete(dto) {
|
|
19
|
+
await this.httpClient.delete(`/v1/apps/${dto.id}`, {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
22
|
+
},
|
|
39
23
|
});
|
|
40
24
|
}
|
|
41
|
-
findAll(dto) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
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
|
+
},
|
|
50
31
|
});
|
|
32
|
+
return response.data;
|
|
51
33
|
}
|
|
52
34
|
}
|
|
53
|
-
const appsService = new AppsServiceImpl(
|
|
54
|
-
|
|
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;
|