whio-api-sdk 1.0.193-bet-staging → 1.0.194-beta-staging
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/dist/src/sdk/modules/agent.module.d.ts +17 -0
- package/dist/src/sdk/modules/agent.module.js +93 -0
- package/dist/src/sdk/modules/audio.module.d.ts +31 -0
- package/dist/src/sdk/modules/audio.module.js +147 -0
- package/dist/src/sdk/modules/auth.module.d.ts +9 -0
- package/dist/src/sdk/modules/auth.module.js +59 -0
- package/dist/src/sdk/modules/base-client.d.ts +25 -0
- package/dist/src/sdk/modules/base-client.js +183 -0
- package/dist/src/sdk/modules/debug.module.d.ts +20 -0
- package/dist/src/sdk/modules/debug.module.js +54 -0
- package/dist/src/sdk/modules/external-integration.module.d.ts +9 -0
- package/dist/src/sdk/modules/external-integration.module.js +38 -0
- package/dist/src/sdk/modules/log.module.d.ts +63 -0
- package/dist/src/sdk/modules/log.module.js +222 -0
- package/dist/src/sdk/modules/organization.module.d.ts +11 -0
- package/dist/src/sdk/modules/organization.module.js +50 -0
- package/dist/src/sdk/modules/session.module.d.ts +16 -0
- package/dist/src/sdk/modules/session.module.js +58 -0
- package/dist/src/sdk/modules/team.module.d.ts +13 -0
- package/dist/src/sdk/modules/team.module.js +72 -0
- package/dist/src/sdk/modules/template.module.d.ts +33 -0
- package/dist/src/sdk/modules/template.module.js +240 -0
- package/dist/src/sdk/modules/user.module.d.ts +17 -0
- package/dist/src/sdk/modules/user.module.js +104 -0
- package/dist/src/sdk/modules/workflow.module.d.ts +10 -0
- package/dist/src/sdk/modules/workflow.module.js +53 -0
- package/dist/src/sdk/sdk.d.ts +167 -211
- package/dist/src/sdk/sdk.js +375 -869
- package/dist/src/sdk/sdk.old.d.ts +222 -0
- package/dist/src/sdk/sdk.old.js +1238 -0
- package/dist/src/sdk/types/agent.types.d.ts +51 -0
- package/dist/src/sdk/types/agent.types.js +1 -0
- package/dist/src/sdk/types/audio.types.d.ts +72 -0
- package/dist/src/sdk/types/audio.types.js +8 -0
- package/dist/src/sdk/types/auth.types.d.ts +21 -0
- package/dist/src/sdk/types/auth.types.js +1 -0
- package/dist/src/sdk/types/common.types.d.ts +20 -0
- package/dist/src/sdk/types/common.types.js +9 -0
- package/dist/src/sdk/types/external-integration.types.d.ts +31 -0
- package/dist/src/sdk/types/external-integration.types.js +1 -0
- package/dist/src/sdk/types/index.d.ts +12 -0
- package/dist/src/sdk/types/index.js +13 -0
- package/dist/src/sdk/types/log.types.d.ts +61 -0
- package/dist/src/sdk/types/log.types.js +1 -0
- package/dist/src/sdk/types/organization.types.d.ts +42 -0
- package/dist/src/sdk/types/organization.types.js +6 -0
- package/dist/src/sdk/types/session.types.d.ts +54 -0
- package/dist/src/sdk/types/session.types.js +1 -0
- package/dist/src/sdk/types/team.types.d.ts +39 -0
- package/dist/src/sdk/types/team.types.js +1 -0
- package/dist/src/sdk/types/template.types.d.ts +118 -0
- package/dist/src/sdk/types/template.types.js +1 -0
- package/dist/src/sdk/types/user.types.d.ts +41 -0
- package/dist/src/sdk/types/user.types.js +1 -0
- package/dist/src/sdk/types/workflow.types.d.ts +19 -0
- package/dist/src/sdk/types/workflow.types.js +1 -0
- package/dist/src/sdk/types.d.ts +1 -517
- package/dist/src/sdk/types.js +2 -23
- package/dist/src/sdk/types.old.d.ts +517 -0
- package/dist/src/sdk/types.old.js +23 -0
- package/dist/src/sdk/urls.d.ts +1 -0
- package/dist/src/sdk/urls.js +2 -0
- package/package.json +1 -1
- package/src/sdk/modules/agent.module.ts +74 -0
- package/src/sdk/modules/audio.module.ts +131 -0
- package/src/sdk/modules/auth.module.ts +53 -0
- package/src/sdk/modules/base-client.ts +214 -0
- package/src/sdk/modules/debug.module.ts +44 -0
- package/src/sdk/modules/external-integration.module.ts +50 -0
- package/src/sdk/modules/log.module.ts +213 -0
- package/src/sdk/modules/organization.module.ts +35 -0
- package/src/sdk/modules/session.module.ts +41 -0
- package/src/sdk/modules/team.module.ts +55 -0
- package/src/sdk/modules/template.module.ts +242 -0
- package/src/sdk/modules/user.module.ts +89 -0
- package/src/sdk/modules/workflow.module.ts +39 -0
- package/src/sdk/sdk.old.ts +1312 -0
- package/src/sdk/sdk.ts +393 -1089
- package/src/sdk/types/agent.types.ts +65 -0
- package/src/sdk/types/audio.types.ts +89 -0
- package/src/sdk/types/auth.types.ts +29 -0
- package/src/sdk/types/common.types.ts +26 -0
- package/src/sdk/types/external-integration.types.ts +37 -0
- package/src/sdk/types/index.ts +13 -0
- package/src/sdk/types/log.types.ts +68 -0
- package/src/sdk/types/organization.types.ts +55 -0
- package/src/sdk/types/session.types.ts +63 -0
- package/src/sdk/types/team.types.ts +48 -0
- package/src/sdk/types/template.types.ts +142 -0
- package/src/sdk/types/user.types.ts +50 -0
- package/src/sdk/types/workflow.types.ts +26 -0
- package/src/sdk/types.old.ts +649 -0
- package/src/sdk/types.ts +2 -649
- package/src/sdk/urls.ts +3 -0
|
@@ -0,0 +1,1238 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
// sdk.ts
|
|
11
|
+
import { OrganizationRoleType, AudioFileStatus, } from './types';
|
|
12
|
+
import urls from './urls';
|
|
13
|
+
import { jwtDecode } from 'jwt-decode';
|
|
14
|
+
export class ApiSDK {
|
|
15
|
+
constructor(config = {}) {
|
|
16
|
+
this.accessToken = null;
|
|
17
|
+
this.refreshToken = null;
|
|
18
|
+
this.user = null;
|
|
19
|
+
this.baseUrl = config.baseUrl || '/api';
|
|
20
|
+
this.storage = config.storage;
|
|
21
|
+
this.initialize();
|
|
22
|
+
}
|
|
23
|
+
fetchConfig(url) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const response = yield fetch(url);
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`Failed to fetch config from ${url}`);
|
|
28
|
+
}
|
|
29
|
+
const conf = yield response.json();
|
|
30
|
+
this.baseUrl = conf.baseUrl || this.baseUrl;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getToken() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const accessToken = yield this.storage.getItem('access_token');
|
|
36
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
37
|
+
if (!this.accessToken) {
|
|
38
|
+
throw new Error('Access token not found');
|
|
39
|
+
}
|
|
40
|
+
// Check if token is expired or expiring soon
|
|
41
|
+
if (this.isTokenExpired(this.accessToken)) {
|
|
42
|
+
// Try to refresh the token
|
|
43
|
+
if (this.refreshToken) {
|
|
44
|
+
yield this.refreshAccessToken();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Error('Access token expired and no refresh token available');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
initialize() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const accessToken = yield this.storage.getItem('access_token');
|
|
55
|
+
const refreshToken = yield this.storage.getItem('refresh_token');
|
|
56
|
+
const userString = yield this.storage.getItem('user');
|
|
57
|
+
this.user = userString ? JSON.parse(userString) : null;
|
|
58
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
59
|
+
this.refreshToken = refreshToken ? JSON.parse(refreshToken) : null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
request(endpoint, method = 'GET', body, headers = {}, noToken = false) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
65
|
+
const defaultHeaders = {
|
|
66
|
+
'Content-Type': 'application/json',
|
|
67
|
+
'ngrok-skip-browser-warning': 'true'
|
|
68
|
+
};
|
|
69
|
+
if (noToken) {
|
|
70
|
+
defaultHeaders['Authorization'] = '';
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// If no token is available, try to get it
|
|
74
|
+
yield this.getToken();
|
|
75
|
+
}
|
|
76
|
+
if (this.accessToken) {
|
|
77
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
78
|
+
}
|
|
79
|
+
const response = yield fetch(url, {
|
|
80
|
+
method,
|
|
81
|
+
headers: Object.assign(Object.assign({}, defaultHeaders), headers),
|
|
82
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
86
|
+
throw new Error(errorData.message || `Request failed with status ${response.status}`);
|
|
87
|
+
}
|
|
88
|
+
return response.json();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
fileUploadRequest(endpoint, body, headers = {}) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
94
|
+
const defaultHeaders = {
|
|
95
|
+
'ngrok-skip-browser-warning': 'true'
|
|
96
|
+
};
|
|
97
|
+
if (this.accessToken) {
|
|
98
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
99
|
+
}
|
|
100
|
+
// Don't set Content-Type for FormData - let browser set it with boundary
|
|
101
|
+
const response = yield fetch(url, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: Object.assign(Object.assign({}, defaultHeaders), headers),
|
|
104
|
+
body,
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
108
|
+
throw new Error(errorData.message || `Request failed with status ${response.status}`);
|
|
109
|
+
}
|
|
110
|
+
return response.json();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
login(credentials) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
try {
|
|
116
|
+
const response = yield this.request('/auth/login', 'POST', credentials, {}, true);
|
|
117
|
+
this.accessToken = response.access_token;
|
|
118
|
+
this.refreshToken = response.refresh_token;
|
|
119
|
+
this.user = response.user;
|
|
120
|
+
yield this.storage.setItem('access_token', JSON.stringify(response.access_token));
|
|
121
|
+
yield this.storage.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
122
|
+
yield this.storage.setItem('user', JSON.stringify(response.user));
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
yield this.clearAuth();
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
logout() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
yield this.clearAuth();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
clearAuth() {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
this.accessToken = null;
|
|
139
|
+
this.refreshToken = null;
|
|
140
|
+
this.user = null;
|
|
141
|
+
yield this.storage.removeItem('access_token');
|
|
142
|
+
yield this.storage.removeItem('refresh_token');
|
|
143
|
+
yield this.storage.removeItem('user');
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
isTokenExpired(token, bufferMinutes = 5) {
|
|
147
|
+
try {
|
|
148
|
+
const decoded = jwtDecode(token);
|
|
149
|
+
const currentTime = Date.now() / 1000;
|
|
150
|
+
const bufferTime = bufferMinutes * 60;
|
|
151
|
+
return decoded.exp <= (currentTime + bufferTime);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
// If we can't decode the token, consider it expired
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
refreshAccessToken() {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
if (!this.refreshToken) {
|
|
161
|
+
throw new Error('No refresh token available');
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const response = yield this.request('/auth/refresh', 'POST', { refresh_token: this.refreshToken }, {}, true // Skip token validation for this request
|
|
165
|
+
);
|
|
166
|
+
this.accessToken = response.access_token;
|
|
167
|
+
this.refreshToken = response.refresh_token;
|
|
168
|
+
this.user = response.user;
|
|
169
|
+
yield this.storage.setItem('access_token', JSON.stringify(response.access_token));
|
|
170
|
+
yield this.storage.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
171
|
+
yield this.storage.setItem('user', JSON.stringify(response.user));
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
yield this.clearAuth();
|
|
175
|
+
throw new Error('Failed to refresh access token');
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
isAuthenticated() {
|
|
180
|
+
return !!this.accessToken;
|
|
181
|
+
}
|
|
182
|
+
getCurrentUser() {
|
|
183
|
+
return this.user;
|
|
184
|
+
}
|
|
185
|
+
getAccessToken() {
|
|
186
|
+
return this.accessToken;
|
|
187
|
+
}
|
|
188
|
+
getRefreshToken() {
|
|
189
|
+
return this.refreshToken;
|
|
190
|
+
}
|
|
191
|
+
createUser(firstName, lastName, email, password) {
|
|
192
|
+
var _a;
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const createUserDto = {
|
|
195
|
+
firstName,
|
|
196
|
+
lastName,
|
|
197
|
+
email,
|
|
198
|
+
password,
|
|
199
|
+
organizationId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.organizationId,
|
|
200
|
+
};
|
|
201
|
+
const user = yield this.request(urls.users, 'POST', createUserDto);
|
|
202
|
+
return user;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
assignRoleToUser(userId, roleName, organizationId) {
|
|
206
|
+
var _a;
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const orgId = organizationId || ((_a = this.user) === null || _a === void 0 ? void 0 : _a.organizationId);
|
|
209
|
+
const organization = yield this.request(`${urls.organizations}/${orgId}`, 'GET');
|
|
210
|
+
const orgRoleEditor = organization.roles.find(r => r.name === roleName);
|
|
211
|
+
const assignRoleDto = {
|
|
212
|
+
userId: userId,
|
|
213
|
+
organizationRoleId: orgRoleEditor.id,
|
|
214
|
+
};
|
|
215
|
+
this.request(urls.userOrganizationRoles, 'POST', assignRoleDto);
|
|
216
|
+
const userWithOrgRole = yield this.request(`${urls.user}/${userId}`, 'GET');
|
|
217
|
+
return userWithOrgRole;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
assignEditorToRoleToUser(userId, organizationId) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR, organizationId);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
assignAdminToRoleToUser(userId, organizationId) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN, organizationId);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
assignDisabledToRoleToUser(userId, organizationId) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
createEditorUser(firstName, lastName, email, password) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const user = yield this.createUser(firstName, lastName, email, password);
|
|
238
|
+
const userWithOrgRole = yield this.assignEditorToRoleToUser(user.id);
|
|
239
|
+
return userWithOrgRole;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
createAdminUser(firstName, lastName, email, password) {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
const user = yield this.createUser(firstName, lastName, email, password);
|
|
245
|
+
const userWithOrgRole = yield this.assignAdminToRoleToUser(user.id);
|
|
246
|
+
return userWithOrgRole;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
createDisabledUser(firstName, lastName, email, password) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
const user = yield this.createUser(firstName, lastName, email, password);
|
|
252
|
+
const userWithOrgRole = yield this.assignDisabledToRoleToUser(user.id);
|
|
253
|
+
return userWithOrgRole;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
createTeam(name, description) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
const teamDto = {
|
|
259
|
+
name,
|
|
260
|
+
description,
|
|
261
|
+
organizationId: this.user.organizationId,
|
|
262
|
+
};
|
|
263
|
+
return this.request(urls.teams, 'POST', teamDto);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
updateTeam(id, name, description) {
|
|
267
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
const teamDto = {
|
|
269
|
+
name,
|
|
270
|
+
description,
|
|
271
|
+
};
|
|
272
|
+
return this.request(`${urls.teams}/${id}`, 'PATCH', teamDto);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
addUserToTeam(teamId, userId, roleName) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
const assignRoleDto = {
|
|
278
|
+
teamId,
|
|
279
|
+
userId,
|
|
280
|
+
name: roleName,
|
|
281
|
+
};
|
|
282
|
+
return this.request(urls.teamRoles, 'POST', assignRoleDto);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
removeUserFromTeam(teamId, userId) {
|
|
286
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
yield this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
createTemplate(title, content, categoryId, workflowId, agentId) {
|
|
291
|
+
var _a;
|
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
let finalCategoryId = categoryId;
|
|
294
|
+
if (!finalCategoryId) {
|
|
295
|
+
const templateCategories = yield this.request(urls.templateCategories, 'GET');
|
|
296
|
+
finalCategoryId = (_a = templateCategories[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
297
|
+
if (!finalCategoryId) {
|
|
298
|
+
throw new Error('No template categories available. Please create one first.');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const createTemplateDto = {
|
|
302
|
+
title,
|
|
303
|
+
content,
|
|
304
|
+
isGlobal: false,
|
|
305
|
+
categoryId: finalCategoryId,
|
|
306
|
+
createdById: this.user.id,
|
|
307
|
+
organizationId: this.user.organizationId,
|
|
308
|
+
workflowId,
|
|
309
|
+
agentId,
|
|
310
|
+
};
|
|
311
|
+
return this.request(urls.templates, 'POST', createTemplateDto);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
createUserTemplate(title, content, originalTemplateId) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
const createUserTemplateDto = {
|
|
317
|
+
title,
|
|
318
|
+
content,
|
|
319
|
+
originalTemplateId,
|
|
320
|
+
userId: this.user.id,
|
|
321
|
+
};
|
|
322
|
+
return this.request(urls.userTemplates, 'POST', createUserTemplateDto);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
updateTemplate(title, content, id, workflowId, agentId) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
const templateDto = {
|
|
328
|
+
title,
|
|
329
|
+
content,
|
|
330
|
+
isGlobal: false,
|
|
331
|
+
organizationId: this.user.organizationId,
|
|
332
|
+
workflowId,
|
|
333
|
+
agentId,
|
|
334
|
+
};
|
|
335
|
+
return this.request(`${urls.templates}/${id}`, 'PATCH', templateDto);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
updateUserTemplate(title, content, id) {
|
|
339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
340
|
+
const userTemplateDto = {
|
|
341
|
+
title,
|
|
342
|
+
content,
|
|
343
|
+
};
|
|
344
|
+
return this.request(`${urls.userTemplates}/${id}`, 'PATCH', userTemplateDto);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
getTemplates() {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
return this.request(urls.templates, 'GET');
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
getTemplatesByOrganization() {
|
|
353
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
354
|
+
return this.request(`${urls.templates}/organization`, 'GET');
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
getUserTemplates() {
|
|
358
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
const url = `${urls.userTemplates}/user/${this.user.id}`;
|
|
360
|
+
return this.request(url, 'GET');
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
// ======================
|
|
364
|
+
// trANSCRIPTION SUMMARY METHODS
|
|
365
|
+
// ======================
|
|
366
|
+
generateTranscriptionSummary(templateId, sessionId) {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
const generateSummaryDto = {
|
|
369
|
+
templateId,
|
|
370
|
+
userId: this.user.id,
|
|
371
|
+
fromUserTemplate: false,
|
|
372
|
+
sessionId: sessionId,
|
|
373
|
+
};
|
|
374
|
+
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
375
|
+
return transcriptionSummary;
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
getByOrganizationTranscriptionSummaries(organizationId) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
+
return this.request(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
generateTranscriptionSummaryFromUserTemplate(userTemplateId, sessionId) {
|
|
384
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
+
const generateSummaryDto = {
|
|
386
|
+
templateId: userTemplateId,
|
|
387
|
+
userId: this.user.id,
|
|
388
|
+
fromUserTemplate: true,
|
|
389
|
+
sessionId: sessionId,
|
|
390
|
+
};
|
|
391
|
+
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
392
|
+
return transcriptionSummary;
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
updateTranscriptionSummary(id, content) {
|
|
396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
const updateSummaryDto = {
|
|
398
|
+
content,
|
|
399
|
+
};
|
|
400
|
+
return this.request(`${urls.transcriptionSummary}/${id}`, 'PATCH', updateSummaryDto);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
uploadLargeAudioFile(formData) {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
+
const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData);
|
|
406
|
+
const uploadIds = (yield this.storage.getItem('uploadIds')) || '[]';
|
|
407
|
+
const uploadIdsArray = JSON.parse(uploadIds);
|
|
408
|
+
yield this.storage.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
409
|
+
return uploadId;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
uploadAudioFile(formData) {
|
|
413
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
414
|
+
const data = yield this.fileUploadRequest(urls.uploadAudio, formData);
|
|
415
|
+
return data;
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
transcribeBase64Audio(base64String) {
|
|
419
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
420
|
+
const transcript = yield this.request(urls.transcribeBase64Audio, 'POST', { base64Audio: base64String });
|
|
421
|
+
return transcript.transcript;
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
// ======================
|
|
425
|
+
// AUTH METHODS
|
|
426
|
+
// ======================
|
|
427
|
+
getProfile() {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
return this.request(urls.profile, 'GET');
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
changePassword(currentPassword, newPassword) {
|
|
433
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
434
|
+
const dto = {
|
|
435
|
+
currentPassword,
|
|
436
|
+
newPassword,
|
|
437
|
+
};
|
|
438
|
+
return this.request(urls.changePassword, 'PATCH', dto);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
adminChangePassword(userId, newPassword) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
443
|
+
const dto = {
|
|
444
|
+
userId,
|
|
445
|
+
newPassword,
|
|
446
|
+
};
|
|
447
|
+
return this.request(urls.adminChangePassword, 'PATCH', dto);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
// ======================
|
|
451
|
+
// ORGANIZATION METHODS
|
|
452
|
+
// ======================
|
|
453
|
+
createOrganization(name, description) {
|
|
454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
455
|
+
const dto = { name, description };
|
|
456
|
+
return this.request(urls.organizations, 'POST', dto);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
getOrganizations() {
|
|
460
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
+
return this.request(urls.organizations, 'GET');
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
getOrganization(id) {
|
|
465
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
466
|
+
return this.request(`${urls.organizations}/${id}`, 'GET');
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
updateOrganization(id, name, description) {
|
|
470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
471
|
+
const dto = { name, description };
|
|
472
|
+
return this.request(`${urls.organizations}/${id}`, 'PATCH', dto);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
deleteOrganization(id) {
|
|
476
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
+
yield this.request(`${urls.organizations}/${id}`, 'DELETE');
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
addUserToOrganization(organizationId, userId) {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
+
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
removeUserFromOrganization(organizationId, userId) {
|
|
486
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
487
|
+
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'DELETE');
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// ======================
|
|
491
|
+
// USER METHODS
|
|
492
|
+
// ======================
|
|
493
|
+
getUsers() {
|
|
494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
+
return this.request(urls.users, 'GET');
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
getUser(id) {
|
|
499
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
+
return this.request(`${urls.users}/${id}`, 'GET');
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
getUsersByOrganization(organizationId) {
|
|
504
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
+
return this.request(`${urls.users}/organization/${organizationId}`, 'GET');
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
updateUser(id, data) {
|
|
509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
510
|
+
return this.request(`${urls.users}/${id}`, 'PATCH', data);
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
deleteUser(id) {
|
|
514
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
515
|
+
yield this.request(`${urls.users}/${id}`, 'DELETE');
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
// ======================
|
|
519
|
+
// TEAM METHODS
|
|
520
|
+
// ======================
|
|
521
|
+
getTeams() {
|
|
522
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
523
|
+
return this.request(urls.teams, 'GET');
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
getTeam(id) {
|
|
527
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
528
|
+
return this.request(`${urls.teams}/${id}`, 'GET');
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
getTeamsByOrganization(organizationId) {
|
|
532
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
533
|
+
return this.request(`${urls.teams}/organization/${organizationId}`, 'GET');
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
deleteTeam(id) {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
538
|
+
yield this.request(`${urls.teams}/${id}`, 'DELETE');
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
// ======================
|
|
542
|
+
// TEMPLATE CATEGORY METHODS
|
|
543
|
+
// ======================
|
|
544
|
+
getTemplateCategories() {
|
|
545
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
546
|
+
return this.request(urls.templateCategories, 'GET');
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
getTemplateCategory(id) {
|
|
550
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
551
|
+
return this.request(`${urls.templateCategories}/${id}`, 'GET');
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
createTemplateCategory(name) {
|
|
555
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
556
|
+
const dto = { name };
|
|
557
|
+
return this.request(urls.templateCategories, 'POST', dto);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
updateTemplateCategory(id, name) {
|
|
561
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
562
|
+
const dto = { name };
|
|
563
|
+
return this.request(`${urls.templateCategories}/${id}`, 'PATCH', dto);
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
deleteTemplateCategory(id) {
|
|
567
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
568
|
+
yield this.request(`${urls.templateCategories}/${id}`, 'DELETE');
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
// ======================
|
|
572
|
+
// ENHANCED TEMPLATE METHODS
|
|
573
|
+
// ======================
|
|
574
|
+
getTemplate(id) {
|
|
575
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
576
|
+
return this.request(`${urls.templates}/${id}`, 'GET');
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
deleteTemplate(id) {
|
|
580
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
581
|
+
yield this.request(`${urls.templates}/${id}`, 'DELETE');
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
getUserTemplate(id) {
|
|
585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
return this.request(`${urls.userTemplates}/${id}`, 'GET');
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
deleteUserTemplate(id) {
|
|
590
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
591
|
+
yield this.request(`${urls.userTemplates}/${id}`, 'DELETE');
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
// ======================
|
|
595
|
+
// TEAM TEMPLATE METHODS
|
|
596
|
+
// ======================
|
|
597
|
+
assignTemplateToTeam(teamId, templateId) {
|
|
598
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
599
|
+
const dto = { teamId, templateId };
|
|
600
|
+
yield this.request(urls.teamTemplates, 'POST', dto);
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
removeTemplateFromTeam(teamId, templateId) {
|
|
604
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
yield this.request(`${urls.teamTemplates}/team/${teamId}/template/${templateId}`, 'DELETE');
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
// ======================
|
|
609
|
+
// TRANSCRIPTION SUMMARY METHODS
|
|
610
|
+
// ======================
|
|
611
|
+
getTranscriptionSummaries() {
|
|
612
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
613
|
+
return this.request(urls.transcriptionSummaries, 'GET');
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
getTranscriptionSummary(id) {
|
|
617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
618
|
+
return this.request(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
getTranscriptionSummariesByUser(userId) {
|
|
622
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
623
|
+
return this.request(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
deleteTranscriptionSummary(id) {
|
|
627
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
628
|
+
yield this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
// ======================
|
|
632
|
+
// ENHANCED TEAM ROLE METHODS
|
|
633
|
+
// ======================
|
|
634
|
+
removeUserFromTeamFixed(teamId, userId) {
|
|
635
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
636
|
+
yield this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
// ======================
|
|
640
|
+
// SESSION METHODS
|
|
641
|
+
// ======================
|
|
642
|
+
createSession(sessionData) {
|
|
643
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
644
|
+
return this.request(urls.sessions, 'POST', sessionData);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
getSessions() {
|
|
648
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
649
|
+
return this.request(`${urls.sessions}/my-sessions`, 'GET');
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
getSession(id) {
|
|
653
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
654
|
+
return this.request(`${urls.sessions}/${id}`, 'GET');
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
getSessionsByUser(userId) {
|
|
658
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
659
|
+
return this.request(`${urls.sessions}/user/${userId}`, 'GET');
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
getSessionsByOrganization() {
|
|
663
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
664
|
+
return this.request(`${urls.sessions}/organization`, 'GET');
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
updateSession(id, sessionData) {
|
|
668
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
return this.request(`${urls.sessions}/${id}`, 'PATCH', sessionData);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
deleteSession(id) {
|
|
673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
674
|
+
yield this.request(`${urls.sessions}/${id}`, 'DELETE');
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
setPrimaryTranscriptionSummary(sessionId, summaryId) {
|
|
678
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
679
|
+
return this.request(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
rerunTranscription(sessionId) {
|
|
683
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
return this.request(`${urls.sessions}/${sessionId}/rerun-transcription`, 'POST');
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
// ======================
|
|
688
|
+
// AGENT METHODS
|
|
689
|
+
// ======================
|
|
690
|
+
createAgent(name, templateTextReplacement) {
|
|
691
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
692
|
+
const dto = { name, templateTextReplacement };
|
|
693
|
+
return this.request(urls.agents, 'POST', dto);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
getAgents() {
|
|
697
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
698
|
+
return this.request(urls.agents, 'GET');
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
getAgent(id) {
|
|
702
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
703
|
+
return this.request(`${urls.agents}/${id}`, 'GET');
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
updateAgent(id, name, templateTextReplacement) {
|
|
707
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
708
|
+
const dto = { name, templateTextReplacement };
|
|
709
|
+
return this.request(`${urls.agents}/${id}`, 'PATCH', dto);
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
deleteAgent(id) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
714
|
+
yield this.request(`${urls.agents}/${id}`, 'DELETE');
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
addAgentToOrganization(agentId, organizationId) {
|
|
718
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
719
|
+
yield this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'POST');
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
removeAgentFromOrganization(agentId, organizationId) {
|
|
723
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
724
|
+
yield this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
// ======================
|
|
728
|
+
// AGENT SETTINGS METHODS
|
|
729
|
+
// ======================
|
|
730
|
+
createAgentSettings(settingsData) {
|
|
731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
return this.request(urls.agentSettings, 'POST', settingsData);
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
getAgentSettings(organizationId, agentId) {
|
|
736
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
737
|
+
const params = new URLSearchParams();
|
|
738
|
+
if (organizationId)
|
|
739
|
+
params.append('organizationId', organizationId);
|
|
740
|
+
if (agentId)
|
|
741
|
+
params.append('agentId', agentId);
|
|
742
|
+
const queryString = params.toString();
|
|
743
|
+
const endpoint = queryString ? `${urls.agentSettings}?${queryString}` : urls.agentSettings;
|
|
744
|
+
return this.request(endpoint, 'GET');
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
getAgentSettingsById(id) {
|
|
748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
749
|
+
return this.request(`${urls.agentSettings}/${id}`, 'GET');
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
getAgentSettingsByAgentAndOrganization(agentId, organizationId) {
|
|
753
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
754
|
+
return this.request(`${urls.agentSettings}/agent/${agentId}/organization/${organizationId}`, 'GET');
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
updateAgentSettings(id, settingsData) {
|
|
758
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
759
|
+
return this.request(`${urls.agentSettings}/${id}`, 'PATCH', settingsData);
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
deleteAgentSettings(id) {
|
|
763
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
764
|
+
yield this.request(`${urls.agentSettings}/${id}`, 'DELETE');
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
// ======================
|
|
768
|
+
// AUDIO FILE METHODS
|
|
769
|
+
// ======================
|
|
770
|
+
uploadAudioFileToSession(sessionId, file, fileName, culturalTranscription) {
|
|
771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
772
|
+
const formData = new FormData();
|
|
773
|
+
formData.append('file', file, fileName);
|
|
774
|
+
if (culturalTranscription) {
|
|
775
|
+
formData.append('cultural_transcription', culturalTranscription);
|
|
776
|
+
}
|
|
777
|
+
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
uploadAudioFileWithTranscriptionQueue(sessionId, file, options) {
|
|
781
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
782
|
+
const formData = new FormData();
|
|
783
|
+
formData.append('file', file, options === null || options === void 0 ? void 0 : options.fileName);
|
|
784
|
+
if (options === null || options === void 0 ? void 0 : options.culturalTranscription) {
|
|
785
|
+
formData.append('cultural_transcription', options.culturalTranscription);
|
|
786
|
+
}
|
|
787
|
+
// This will automatically trigger the transcription queue
|
|
788
|
+
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
getMyAudioFiles() {
|
|
792
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
793
|
+
return this.request(`${urls.audioFiles}/my-files`, 'GET');
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
getAllAudioFiles() {
|
|
797
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
798
|
+
return this.request(`${urls.audioFiles}/all`, 'GET');
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
getOrganizationAudioFiles() {
|
|
802
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
803
|
+
return this.request(`${urls.audioFiles}/organization`, 'GET');
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
getAudioFilesBySession(sessionId) {
|
|
807
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
808
|
+
return this.request(`${urls.audioFiles}/session/${sessionId}`, 'GET');
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
getAudioFile(id) {
|
|
812
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
813
|
+
return this.request(`${urls.audioFiles}/${id}`, 'GET');
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
updateAudioFile(id, updates) {
|
|
817
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
818
|
+
return this.request(`${urls.audioFiles}/${id}`, 'PATCH', updates);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
deleteAudioFile(id) {
|
|
822
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
823
|
+
yield this.request(`${urls.audioFiles}/${id}`, 'DELETE');
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
downloadAudioFile(id) {
|
|
827
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
828
|
+
// For file downloads, we need a different approach than JSON requests
|
|
829
|
+
const url = `${this.baseUrl}${urls.audioFiles}/${id}/download`;
|
|
830
|
+
// Get token first
|
|
831
|
+
yield this.getToken();
|
|
832
|
+
const defaultHeaders = {
|
|
833
|
+
'ngrok-skip-browser-warning': 'true'
|
|
834
|
+
};
|
|
835
|
+
if (this.accessToken) {
|
|
836
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
837
|
+
}
|
|
838
|
+
const response = yield fetch(url, {
|
|
839
|
+
method: 'GET',
|
|
840
|
+
headers: defaultHeaders,
|
|
841
|
+
});
|
|
842
|
+
if (!response.ok) {
|
|
843
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
844
|
+
throw new Error(errorData.message || `Download failed with status ${response.status}`);
|
|
845
|
+
}
|
|
846
|
+
return response.blob();
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
downloadAudioFileAsUrl(id) {
|
|
850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
851
|
+
const blob = yield this.downloadAudioFile(id);
|
|
852
|
+
return URL.createObjectURL(blob);
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
// ======================
|
|
856
|
+
// TRANSCRIPTION QUEUE HELPER METHODS
|
|
857
|
+
// ======================
|
|
858
|
+
getTranscribedAudioFiles() {
|
|
859
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
860
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
861
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.TRANSCRIBED && file.transcription);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
getProcessingAudioFiles() {
|
|
865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
866
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
867
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.PROCESSING);
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
getFailedAudioFiles() {
|
|
871
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
872
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
873
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.FAILED);
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
// ======================
|
|
877
|
+
// BASE64 AUDIO FILE METHODS
|
|
878
|
+
// ======================
|
|
879
|
+
createBase64AudioFile(dto) {
|
|
880
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
881
|
+
return this.request(`${urls.audioFiles}/base64`, 'POST', dto);
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
getAllBase64AudioFiles() {
|
|
885
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
886
|
+
return this.request(`${urls.audioFiles}/base64/all`, 'GET');
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
getBase64AudioFilesBySession(sessionId) {
|
|
890
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
891
|
+
return this.request(`${urls.audioFiles}/base64/session/${sessionId}`, 'GET');
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
getBase64AudioFile(id) {
|
|
895
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
896
|
+
return this.request(`${urls.audioFiles}/base64/${id}`, 'GET');
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
updateBase64AudioFile(id, updates) {
|
|
900
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
901
|
+
return this.request(`${urls.audioFiles}/base64/${id}`, 'PATCH', updates);
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
deleteBase64AudioFile(id) {
|
|
905
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
906
|
+
yield this.request(`${urls.audioFiles}/base64/${id}`, 'DELETE');
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
addBase64Chunk(sessionId, base64Chunks) {
|
|
910
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
911
|
+
return this.request(`${urls.audioFiles}/base64/add-chunk/${sessionId}`, 'POST', { base64Chunks });
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
queueSessionBase64AudioForTranscription(sessionId) {
|
|
915
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
916
|
+
return this.request(`${urls.audioFiles}/session/${sessionId}/transcribe`, 'POST');
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
// ======================
|
|
920
|
+
// WORKFLOW METHODS
|
|
921
|
+
// ======================
|
|
922
|
+
createWorkflow(name, organizationId) {
|
|
923
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
924
|
+
const dto = {
|
|
925
|
+
name,
|
|
926
|
+
organizationId: organizationId || this.user.organizationId,
|
|
927
|
+
};
|
|
928
|
+
return this.request(urls.workflows, 'POST', dto);
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
getWorkflows(organizationId) {
|
|
932
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
933
|
+
const params = organizationId ? `?organizationId=${organizationId}` : '';
|
|
934
|
+
return this.request(`${urls.workflows}${params}`, 'GET');
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
getWorkflow(id) {
|
|
938
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
939
|
+
return this.request(`${urls.workflows}/${id}`, 'GET');
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
getWorkflowsByOrganization(organizationId) {
|
|
943
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
944
|
+
const orgId = organizationId || this.user.organizationId;
|
|
945
|
+
return this.request(`${urls.workflows}?organizationId=${orgId}`, 'GET');
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
updateWorkflow(id, name, organizationId) {
|
|
949
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
950
|
+
const dto = {
|
|
951
|
+
name,
|
|
952
|
+
organizationId: organizationId || this.user.organizationId,
|
|
953
|
+
};
|
|
954
|
+
return this.request(`${urls.workflows}/${id}`, 'PATCH', dto);
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
deleteWorkflow(id) {
|
|
958
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
959
|
+
yield this.request(`${urls.workflows}/${id}`, 'DELETE');
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
// ===== LOGS METHODS =====
|
|
963
|
+
/**
|
|
964
|
+
* Get logs with advanced filtering options
|
|
965
|
+
*/
|
|
966
|
+
getLogs(filters) {
|
|
967
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
968
|
+
const params = new URLSearchParams();
|
|
969
|
+
if (filters) {
|
|
970
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
971
|
+
if (value !== undefined && value !== null) {
|
|
972
|
+
params.append(key, value.toString());
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
const queryString = params.toString();
|
|
977
|
+
const url = queryString ? `${urls.logs}?${queryString}` : urls.logs;
|
|
978
|
+
return this.request(url, 'GET');
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Get logs for a specific user
|
|
983
|
+
*/
|
|
984
|
+
getLogsByUser(userId, limit, offset) {
|
|
985
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
986
|
+
const params = new URLSearchParams();
|
|
987
|
+
if (limit !== undefined)
|
|
988
|
+
params.append('limit', limit.toString());
|
|
989
|
+
if (offset !== undefined)
|
|
990
|
+
params.append('offset', offset.toString());
|
|
991
|
+
const queryString = params.toString();
|
|
992
|
+
const url = queryString ? `${urls.logs}/user/${userId}?${queryString}` : `${urls.logs}/user/${userId}`;
|
|
993
|
+
return this.request(url, 'GET');
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Get logs for a specific controller
|
|
998
|
+
*/
|
|
999
|
+
getLogsByController(controller, limit, offset) {
|
|
1000
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1001
|
+
const params = new URLSearchParams();
|
|
1002
|
+
if (limit !== undefined)
|
|
1003
|
+
params.append('limit', limit.toString());
|
|
1004
|
+
if (offset !== undefined)
|
|
1005
|
+
params.append('offset', offset.toString());
|
|
1006
|
+
const queryString = params.toString();
|
|
1007
|
+
const url = queryString ? `${urls.logs}/controller/${controller}?${queryString}` : `${urls.logs}/controller/${controller}`;
|
|
1008
|
+
return this.request(url, 'GET');
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Get logs for the current authenticated user
|
|
1013
|
+
*/
|
|
1014
|
+
getMyLogs(limit, offset) {
|
|
1015
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1016
|
+
const params = new URLSearchParams();
|
|
1017
|
+
if (limit !== undefined)
|
|
1018
|
+
params.append('limit', limit.toString());
|
|
1019
|
+
if (offset !== undefined)
|
|
1020
|
+
params.append('offset', offset.toString());
|
|
1021
|
+
const queryString = params.toString();
|
|
1022
|
+
const url = queryString ? `${urls.logs}/my-logs?${queryString}` : `${urls.logs}/my-logs`;
|
|
1023
|
+
return this.request(url, 'GET');
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Get logs within a date range
|
|
1028
|
+
*/
|
|
1029
|
+
getLogsByDateRange(startDate, endDate, limit, offset) {
|
|
1030
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1031
|
+
const params = new URLSearchParams();
|
|
1032
|
+
params.append('startDate', startDate);
|
|
1033
|
+
params.append('endDate', endDate);
|
|
1034
|
+
if (limit !== undefined)
|
|
1035
|
+
params.append('limit', limit.toString());
|
|
1036
|
+
if (offset !== undefined)
|
|
1037
|
+
params.append('offset', offset.toString());
|
|
1038
|
+
return this.request(`${urls.logs}/date-range?${params.toString()}`, 'GET');
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Get logging statistics
|
|
1043
|
+
*/
|
|
1044
|
+
getLogStats() {
|
|
1045
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1046
|
+
return this.request(`${urls.logs}/stats`, 'GET');
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Create a manual log entry (app logs)
|
|
1051
|
+
*/
|
|
1052
|
+
createLog(logData) {
|
|
1053
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1054
|
+
return this.request(urls.logs, 'POST', logData);
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Convenience methods for different log levels
|
|
1059
|
+
*/
|
|
1060
|
+
logInfo(message, context, action, data) {
|
|
1061
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1062
|
+
return this.createLog({
|
|
1063
|
+
level: 'info',
|
|
1064
|
+
message,
|
|
1065
|
+
context,
|
|
1066
|
+
action,
|
|
1067
|
+
data,
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
logError(message, context, action, data) {
|
|
1072
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1073
|
+
return this.createLog({
|
|
1074
|
+
level: 'error',
|
|
1075
|
+
message,
|
|
1076
|
+
context,
|
|
1077
|
+
action,
|
|
1078
|
+
data,
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
logWarn(message, context, action, data) {
|
|
1083
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1084
|
+
return this.createLog({
|
|
1085
|
+
level: 'warn',
|
|
1086
|
+
message,
|
|
1087
|
+
context,
|
|
1088
|
+
action,
|
|
1089
|
+
data,
|
|
1090
|
+
});
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
logDebug(message, context, action, data) {
|
|
1094
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1095
|
+
return this.createLog({
|
|
1096
|
+
level: 'debug',
|
|
1097
|
+
message,
|
|
1098
|
+
context,
|
|
1099
|
+
action,
|
|
1100
|
+
data,
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Get logs by role
|
|
1106
|
+
*/
|
|
1107
|
+
getLogsByRole(role, limit, offset) {
|
|
1108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1109
|
+
const params = new URLSearchParams();
|
|
1110
|
+
if (limit !== undefined)
|
|
1111
|
+
params.append('limit', limit.toString());
|
|
1112
|
+
if (offset !== undefined)
|
|
1113
|
+
params.append('offset', offset.toString());
|
|
1114
|
+
const queryString = params.toString();
|
|
1115
|
+
const url = queryString ? `${urls.logs}/role/${role}?${queryString}` : `${urls.logs}/role/${role}`;
|
|
1116
|
+
return this.request(url, 'GET');
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Get logs by organization role
|
|
1121
|
+
*/
|
|
1122
|
+
getLogsByOrganizationRole(organizationRole, limit, offset) {
|
|
1123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1124
|
+
const params = new URLSearchParams();
|
|
1125
|
+
if (limit !== undefined)
|
|
1126
|
+
params.append('limit', limit.toString());
|
|
1127
|
+
if (offset !== undefined)
|
|
1128
|
+
params.append('offset', offset.toString());
|
|
1129
|
+
const queryString = params.toString();
|
|
1130
|
+
const url = queryString ? `${urls.logs}/organization-role/${organizationRole}?${queryString}` : `${urls.logs}/organization-role/${organizationRole}`;
|
|
1131
|
+
return this.request(url, 'GET');
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Get logs by team role
|
|
1136
|
+
*/
|
|
1137
|
+
getLogsByTeamRole(teamRole, limit, offset) {
|
|
1138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1139
|
+
const params = new URLSearchParams();
|
|
1140
|
+
if (limit !== undefined)
|
|
1141
|
+
params.append('limit', limit.toString());
|
|
1142
|
+
if (offset !== undefined)
|
|
1143
|
+
params.append('offset', offset.toString());
|
|
1144
|
+
const queryString = params.toString();
|
|
1145
|
+
const url = queryString ? `${urls.logs}/team-role/${teamRole}?${queryString}` : `${urls.logs}/team-role/${teamRole}`;
|
|
1146
|
+
return this.request(url, 'GET');
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Get available roles for filtering
|
|
1151
|
+
*/
|
|
1152
|
+
getAvailableRoles() {
|
|
1153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1154
|
+
return this.request(`${urls.logs}/available-roles`, 'GET');
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Get logs for a specific session ID
|
|
1159
|
+
* Searches both log messages and meta data for the session ID
|
|
1160
|
+
*/
|
|
1161
|
+
getSessionLogs(sessionId, limit, offset) {
|
|
1162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1163
|
+
const params = new URLSearchParams();
|
|
1164
|
+
if (limit !== undefined)
|
|
1165
|
+
params.append('limit', limit.toString());
|
|
1166
|
+
if (offset !== undefined)
|
|
1167
|
+
params.append('offset', offset.toString());
|
|
1168
|
+
const queryString = params.toString();
|
|
1169
|
+
const url = queryString ? `${urls.logs}/session/${sessionId}?${queryString}` : `${urls.logs}/session/${sessionId}`;
|
|
1170
|
+
return this.request(url, 'GET');
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
// ===== DEBUG METHODS =====
|
|
1174
|
+
/**
|
|
1175
|
+
* Get sessions that do not have medical transcriptions and primary transcription summaries
|
|
1176
|
+
* for the current user's organization
|
|
1177
|
+
*/
|
|
1178
|
+
getSessionsWithoutMedicalTranscriptions() {
|
|
1179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1180
|
+
return this.request(`${urls.debug}/sessions/missing-medical-transcriptions`, 'GET');
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Download a session as a ZIP file containing all related data (decrypted)
|
|
1185
|
+
* Returns a Blob that can be used to create a download link
|
|
1186
|
+
*/
|
|
1187
|
+
downloadSessionAsZip(sessionId) {
|
|
1188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1189
|
+
const url = `${this.baseUrl}${urls.debug}/sessions/${sessionId}/download`;
|
|
1190
|
+
// Get token first
|
|
1191
|
+
yield this.getToken();
|
|
1192
|
+
const defaultHeaders = {
|
|
1193
|
+
'ngrok-skip-browser-warning': 'true'
|
|
1194
|
+
};
|
|
1195
|
+
if (this.accessToken) {
|
|
1196
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
1197
|
+
}
|
|
1198
|
+
const response = yield fetch(url, {
|
|
1199
|
+
method: 'GET',
|
|
1200
|
+
headers: defaultHeaders,
|
|
1201
|
+
});
|
|
1202
|
+
if (!response.ok) {
|
|
1203
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
1204
|
+
throw new Error(errorData.message || `Download failed with status ${response.status}`);
|
|
1205
|
+
}
|
|
1206
|
+
return response.blob();
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Download a session as a ZIP file and create a download URL
|
|
1211
|
+
* Returns a URL that can be used for direct download
|
|
1212
|
+
*/
|
|
1213
|
+
downloadSessionAsZipUrl(sessionId) {
|
|
1214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1215
|
+
const blob = yield this.downloadSessionAsZip(sessionId);
|
|
1216
|
+
return URL.createObjectURL(blob);
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Download a session as a ZIP file and trigger browser download
|
|
1221
|
+
* Optionally provide a custom filename
|
|
1222
|
+
*/
|
|
1223
|
+
downloadSessionAndTriggerDownload(sessionId, filename) {
|
|
1224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1225
|
+
const blob = yield this.downloadSessionAsZip(sessionId);
|
|
1226
|
+
const url = URL.createObjectURL(blob);
|
|
1227
|
+
// Create temporary download link and click it
|
|
1228
|
+
const link = document.createElement('a');
|
|
1229
|
+
link.href = url;
|
|
1230
|
+
link.download = filename || `session_${sessionId}_${new Date().toISOString().split('T')[0]}.zip`;
|
|
1231
|
+
document.body.appendChild(link);
|
|
1232
|
+
link.click();
|
|
1233
|
+
document.body.removeChild(link);
|
|
1234
|
+
// Clean up the URL object
|
|
1235
|
+
URL.revokeObjectURL(url);
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
}
|