@webex/calling 3.8.0-next.32 → 3.8.0-next.34
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/CallHistory/CallHistory.js +100 -63
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +115 -19
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallHistory/constants.js +9 -1
- package/dist/CallHistory/constants.js.map +1 -1
- package/dist/CallSettings/CallSettings.js +46 -13
- package/dist/CallSettings/CallSettings.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.js +62 -18
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.js +153 -103
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/constants.js +15 -1
- package/dist/CallSettings/constants.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +148 -107
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +53 -24
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +251 -189
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +96 -41
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +73 -48
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +96 -37
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/constants.js +101 -1
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +47 -18
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/registration/register.js +151 -115
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +43 -21
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/Contacts/ContactsClient.js +156 -102
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +197 -49
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Contacts/constants.js +11 -1
- package/dist/Contacts/constants.js.map +1 -1
- package/dist/Events/impl/index.js +1 -1
- package/dist/Events/impl/index.js.map +1 -1
- package/dist/Metrics/index.js +93 -39
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/types.js +4 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.js +105 -54
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +198 -79
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +188 -23
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.js +123 -76
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +69 -6
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/constants.js +25 -1
- package/dist/Voicemail/constants.js.map +1 -1
- package/dist/common/Utils.js +113 -64
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +154 -21
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/constants.js +2 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +32 -13
- package/dist/module/CallHistory/constants.js +6 -0
- package/dist/module/CallSettings/CallSettings.js +36 -3
- package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
- package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
- package/dist/module/CallSettings/constants.js +12 -0
- package/dist/module/CallingClient/CallingClient.js +52 -14
- package/dist/module/CallingClient/calling/call.js +172 -121
- package/dist/module/CallingClient/calling/callManager.js +51 -26
- package/dist/module/CallingClient/constants.js +98 -0
- package/dist/module/CallingClient/line/index.js +37 -8
- package/dist/module/CallingClient/registration/register.js +37 -11
- package/dist/module/Contacts/ContactsClient.js +65 -21
- package/dist/module/Contacts/constants.js +10 -0
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Metrics/index.js +49 -1
- package/dist/module/Metrics/types.js +3 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
- package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
- package/dist/module/Voicemail/Voicemail.js +109 -9
- package/dist/module/Voicemail/WxCallBackendConnector.js +50 -17
- package/dist/module/Voicemail/constants.js +21 -0
- package/dist/module/common/Utils.js +26 -4
- package/dist/module/common/constants.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallHistory/constants.d.ts +6 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -1
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -3
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +98 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Contacts/constants.d.ts +10 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +5 -1
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +8 -2
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/constants.d.ts +21 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +2 -2
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +12 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FAILURE_MESSAGE, SCIM_ENTERPRISE_USER, SCIM_WEBEXIDENTITY_USER, STATUS_CODE, SUCCESS_MESSAGE, } from '../common/constants';
|
|
1
|
+
import { FAILURE_MESSAGE, METHOD_START_MESSAGE, SCIM_ENTERPRISE_USER, SCIM_WEBEXIDENTITY_USER, STATUS_CODE, SUCCESS_MESSAGE, } from '../common/constants';
|
|
2
2
|
import { HTTP_METHODS } from '../common/types';
|
|
3
3
|
import SDKConnector from '../SDKConnector';
|
|
4
4
|
import log from '../Logger';
|
|
5
|
-
import { CONTACTS_FILE, CONTACTS_SCHEMA, CONTACT_FILTER, DEFAULT_GROUP_NAME, ENCRYPT_FILTER, GROUP_FILTER, OR, SCIM_ID_FILTER, USERS, encryptedFields, } from './constants';
|
|
5
|
+
import { CONTACTS_FILE, CONTACTS_SCHEMA, CONTACT_FILTER, DEFAULT_GROUP_NAME, ENCRYPT_FILTER, GROUP_FILTER, METHODS, OR, SCIM_ID_FILTER, USERS, encryptedFields, } from './constants';
|
|
6
6
|
import { ContactType, GroupType, } from './types';
|
|
7
|
-
import { scimQuery, serviceErrorCodeHandler } from '../common/Utils';
|
|
7
|
+
import { scimQuery, serviceErrorCodeHandler, uploadLogs } from '../common/Utils';
|
|
8
8
|
export class ContactsClient {
|
|
9
9
|
sdkConnector;
|
|
10
10
|
encryptionKeyUrl;
|
|
@@ -188,8 +188,9 @@ export class ContactsClient {
|
|
|
188
188
|
async getContacts() {
|
|
189
189
|
const loggerContext = {
|
|
190
190
|
file: CONTACTS_FILE,
|
|
191
|
-
method:
|
|
191
|
+
method: METHODS.GET_CONTACTS,
|
|
192
192
|
};
|
|
193
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
193
194
|
const contactList = [];
|
|
194
195
|
const cloudContactsMap = {};
|
|
195
196
|
try {
|
|
@@ -244,19 +245,24 @@ export class ContactsClient {
|
|
|
244
245
|
},
|
|
245
246
|
message: SUCCESS_MESSAGE,
|
|
246
247
|
};
|
|
248
|
+
log.log('Successfully fetched contacts and groups', loggerContext);
|
|
247
249
|
return contactResponse;
|
|
248
250
|
}
|
|
249
251
|
catch (err) {
|
|
250
252
|
const errorInfo = err;
|
|
253
|
+
const extendedError = new Error(`Error fetching contacts: ${err}`);
|
|
254
|
+
log.error(extendedError, loggerContext);
|
|
251
255
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
256
|
+
await uploadLogs();
|
|
252
257
|
return errorStatus;
|
|
253
258
|
}
|
|
254
259
|
}
|
|
255
260
|
async createNewEncryptionKeyUrl() {
|
|
256
261
|
const loggerContext = {
|
|
257
262
|
file: CONTACTS_FILE,
|
|
258
|
-
method:
|
|
263
|
+
method: METHODS.CREATE_NEW_ENCRYPTION_KEY_URL,
|
|
259
264
|
};
|
|
265
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
260
266
|
let unboundedKeyUri = '';
|
|
261
267
|
log.info('Requesting kms for a new KRO and key', loggerContext);
|
|
262
268
|
const unboundedKeys = await this.webex.internal.encryption.kms.createUnboundKeys({ count: 1 });
|
|
@@ -265,6 +271,11 @@ export class ContactsClient {
|
|
|
265
271
|
return unboundedKeyUri;
|
|
266
272
|
}
|
|
267
273
|
async fetchEncryptionKeyUrl() {
|
|
274
|
+
const loggerContext = {
|
|
275
|
+
file: CONTACTS_FILE,
|
|
276
|
+
method: METHODS.FETCH_ENCRYPTION_KEY_URL,
|
|
277
|
+
};
|
|
278
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
268
279
|
if (this.encryptionKeyUrl) {
|
|
269
280
|
return this.encryptionKeyUrl;
|
|
270
281
|
}
|
|
@@ -275,45 +286,67 @@ export class ContactsClient {
|
|
|
275
286
|
return this.groups[0].encryptionKeyUrl;
|
|
276
287
|
}
|
|
277
288
|
this.encryptionKeyUrl = await this.createNewEncryptionKeyUrl();
|
|
278
|
-
log.
|
|
289
|
+
log.log(`Creating a default group: ${DEFAULT_GROUP_NAME}`, {
|
|
279
290
|
file: CONTACTS_FILE,
|
|
280
291
|
method: this.fetchEncryptionKeyUrl.name,
|
|
281
292
|
});
|
|
282
293
|
const response = await this.createContactGroup(DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
|
|
283
294
|
if (response.data.group?.groupId) {
|
|
284
295
|
this.defaultGroupId = response.data.group?.groupId;
|
|
296
|
+
log.log(`Successfully created default group with ID: ${this.defaultGroupId}`, {
|
|
297
|
+
file: CONTACTS_FILE,
|
|
298
|
+
method: this.fetchEncryptionKeyUrl.name,
|
|
299
|
+
});
|
|
285
300
|
}
|
|
286
301
|
return this.encryptionKeyUrl;
|
|
287
302
|
}
|
|
288
303
|
async fetchDefaultGroup() {
|
|
304
|
+
const loggerContext = {
|
|
305
|
+
file: CONTACTS_FILE,
|
|
306
|
+
method: METHODS.FETCH_DEFAULT_GROUP,
|
|
307
|
+
};
|
|
308
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
289
309
|
if (this.defaultGroupId) {
|
|
310
|
+
log.log(`Using existing default group with ID: ${this.defaultGroupId}`, {
|
|
311
|
+
file: CONTACTS_FILE,
|
|
312
|
+
method: this.fetchDefaultGroup.name,
|
|
313
|
+
});
|
|
290
314
|
return this.defaultGroupId;
|
|
291
315
|
}
|
|
292
316
|
if (this.groups && this.groups.length) {
|
|
293
317
|
for (let i = 0; i < this.groups.length; i += 1) {
|
|
294
318
|
if (this.groups[i].displayName === DEFAULT_GROUP_NAME) {
|
|
295
319
|
this.defaultGroupId = this.groups[i].groupId;
|
|
320
|
+
log.log(`Found default group with ID: ${this.defaultGroupId}`, {
|
|
321
|
+
file: CONTACTS_FILE,
|
|
322
|
+
method: this.fetchDefaultGroup.name,
|
|
323
|
+
});
|
|
296
324
|
return this.defaultGroupId;
|
|
297
325
|
}
|
|
298
326
|
}
|
|
299
327
|
}
|
|
300
|
-
log.
|
|
328
|
+
log.log('No default group found.', {
|
|
301
329
|
file: CONTACTS_FILE,
|
|
302
330
|
method: this.fetchDefaultGroup.name,
|
|
303
331
|
});
|
|
304
332
|
const response = await this.createContactGroup(DEFAULT_GROUP_NAME);
|
|
305
333
|
const { group } = response.data;
|
|
306
334
|
if (group) {
|
|
307
|
-
|
|
335
|
+
const groupId = group.groupId;
|
|
336
|
+
log.log(`Successfully created new default group with ID: ${groupId}`, {
|
|
337
|
+
file: CONTACTS_FILE,
|
|
338
|
+
method: this.fetchDefaultGroup.name,
|
|
339
|
+
});
|
|
340
|
+
return groupId;
|
|
308
341
|
}
|
|
309
342
|
return '';
|
|
310
343
|
}
|
|
311
344
|
async createContactGroup(displayName, encryptionKeyUrl, groupType) {
|
|
312
345
|
const loggerContext = {
|
|
313
346
|
file: CONTACTS_FILE,
|
|
314
|
-
method:
|
|
347
|
+
method: METHODS.CREATE_CONTACT_GROUP,
|
|
315
348
|
};
|
|
316
|
-
log.info(
|
|
349
|
+
log.info(`${METHOD_START_MESSAGE} with displayName: ${displayName}`, loggerContext);
|
|
317
350
|
const encryptionKeyUrlFinal = encryptionKeyUrl || (await this.fetchEncryptionKeyUrl());
|
|
318
351
|
if (this.groups === undefined) {
|
|
319
352
|
await this.getContacts();
|
|
@@ -354,20 +387,24 @@ export class ContactsClient {
|
|
|
354
387
|
message: SUCCESS_MESSAGE,
|
|
355
388
|
};
|
|
356
389
|
this.groups?.push(group);
|
|
390
|
+
log.log(`Contact group ${displayName} successfully created`, loggerContext);
|
|
357
391
|
return contactResponse;
|
|
358
392
|
}
|
|
359
393
|
catch (err) {
|
|
360
|
-
log.warn('Unable to create contact group.', loggerContext);
|
|
361
394
|
const errorInfo = err;
|
|
395
|
+
const extendedError = new Error(`Unable to create contact group: ${err}`);
|
|
396
|
+
log.error(extendedError, loggerContext);
|
|
362
397
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
398
|
+
await uploadLogs();
|
|
363
399
|
return errorStatus;
|
|
364
400
|
}
|
|
365
401
|
}
|
|
366
402
|
async deleteContactGroup(groupId) {
|
|
367
403
|
const loggerContext = {
|
|
368
404
|
file: CONTACTS_FILE,
|
|
369
|
-
method:
|
|
405
|
+
method: METHODS.DELETE_CONTACT_GROUP,
|
|
370
406
|
};
|
|
407
|
+
log.info(`${METHOD_START_MESSAGE} with groupId: ${groupId}`, loggerContext);
|
|
371
408
|
try {
|
|
372
409
|
log.info(`Deleting contact group: ${groupId}`, loggerContext);
|
|
373
410
|
const response = await this.webex.request({
|
|
@@ -386,21 +423,24 @@ export class ContactsClient {
|
|
|
386
423
|
if (!this.groups?.length) {
|
|
387
424
|
this.defaultGroupId = '';
|
|
388
425
|
}
|
|
426
|
+
log.log(`Contact group ${groupId} successfully deleted`, loggerContext);
|
|
389
427
|
return contactResponse;
|
|
390
428
|
}
|
|
391
429
|
catch (err) {
|
|
392
|
-
log.warn(`Unable to delete contact group ${groupId}`, loggerContext);
|
|
393
430
|
const errorInfo = err;
|
|
431
|
+
const extendedError = new Error(`Unable to delete contact group ${groupId}: ${err}`);
|
|
432
|
+
log.error(extendedError, loggerContext);
|
|
394
433
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
434
|
+
await uploadLogs();
|
|
395
435
|
return errorStatus;
|
|
396
436
|
}
|
|
397
437
|
}
|
|
398
438
|
async createContact(contactInfo) {
|
|
399
439
|
const loggerContext = {
|
|
400
440
|
file: CONTACTS_FILE,
|
|
401
|
-
method:
|
|
441
|
+
method: METHODS.CREATE_CONTACT,
|
|
402
442
|
};
|
|
403
|
-
log.info(
|
|
443
|
+
log.info(`${METHOD_START_MESSAGE} with contactType: ${contactInfo.contactType}`, loggerContext);
|
|
404
444
|
try {
|
|
405
445
|
const contact = { ...contactInfo };
|
|
406
446
|
if (!contact.encryptionKeyUrl) {
|
|
@@ -467,23 +507,24 @@ export class ContactsClient {
|
|
|
467
507
|
else {
|
|
468
508
|
this.contacts?.push(contact);
|
|
469
509
|
}
|
|
510
|
+
log.log(`Contact successfully created`, loggerContext);
|
|
470
511
|
return contactResponse;
|
|
471
512
|
}
|
|
472
513
|
catch (err) {
|
|
473
|
-
log.warn('Failed to create contact.', {
|
|
474
|
-
file: CONTACTS_FILE,
|
|
475
|
-
method: this.createContact.name,
|
|
476
|
-
});
|
|
477
514
|
const errorInfo = err;
|
|
515
|
+
const extendedError = new Error(`Failed to create contact: ${err}`);
|
|
516
|
+
log.error(extendedError, loggerContext);
|
|
478
517
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
518
|
+
await uploadLogs();
|
|
479
519
|
return errorStatus;
|
|
480
520
|
}
|
|
481
521
|
}
|
|
482
522
|
async deleteContact(contactId) {
|
|
483
523
|
const loggerContext = {
|
|
484
524
|
file: CONTACTS_FILE,
|
|
485
|
-
method:
|
|
525
|
+
method: METHODS.DELETE_CONTACT,
|
|
486
526
|
};
|
|
527
|
+
log.info(`${METHOD_START_MESSAGE} with contactId: ${contactId}`, loggerContext);
|
|
487
528
|
try {
|
|
488
529
|
log.info(`Deleting contact : ${contactId}`, loggerContext);
|
|
489
530
|
const response = await this.webex.request({
|
|
@@ -499,12 +540,15 @@ export class ContactsClient {
|
|
|
499
540
|
if (contactToDelete !== undefined && contactToDelete !== -1) {
|
|
500
541
|
this.contacts?.splice(contactToDelete, 1);
|
|
501
542
|
}
|
|
543
|
+
log.log(`Contact ${contactId} successfully deleted`, loggerContext);
|
|
502
544
|
return contactResponse;
|
|
503
545
|
}
|
|
504
546
|
catch (err) {
|
|
505
|
-
log.warn(`Unable to delete contact ${contactId}`, loggerContext);
|
|
506
547
|
const errorInfo = err;
|
|
548
|
+
const extendedError = new Error(`Unable to delete contact ${contactId}: ${err}`);
|
|
549
|
+
log.error(extendedError, loggerContext);
|
|
507
550
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
551
|
+
await uploadLogs();
|
|
508
552
|
return errorStatus;
|
|
509
553
|
}
|
|
510
554
|
}
|
|
@@ -20,3 +20,13 @@ export var encryptedFields;
|
|
|
20
20
|
encryptedFields["SIP_ADDRESSES"] = "sipAddresses";
|
|
21
21
|
encryptedFields["TITLE"] = "title";
|
|
22
22
|
})(encryptedFields || (encryptedFields = {}));
|
|
23
|
+
export const METHODS = {
|
|
24
|
+
GET_CONTACTS: 'getContacts',
|
|
25
|
+
CREATE_NEW_ENCRYPTION_KEY_URL: 'createNewEncryptionKeyUrl',
|
|
26
|
+
FETCH_ENCRYPTION_KEY_URL: 'fetchEncryptionKeyUrl',
|
|
27
|
+
FETCH_DEFAULT_GROUP: 'fetchDefaultGroup',
|
|
28
|
+
CREATE_CONTACT_GROUP: 'createContactGroup',
|
|
29
|
+
DELETE_CONTACT_GROUP: 'deleteContactGroup',
|
|
30
|
+
CREATE_CONTACT: 'createContact',
|
|
31
|
+
DELETE_CONTACT: 'deleteContact',
|
|
32
|
+
};
|
|
@@ -4,7 +4,7 @@ import { LOG_PREFIX } from '../../Logger/types';
|
|
|
4
4
|
export class Eventing extends EventEmitter {
|
|
5
5
|
emit(event, ...args) {
|
|
6
6
|
const timestamp = new Date().toUTCString();
|
|
7
|
-
Logger.
|
|
7
|
+
Logger.info(`${timestamp} ${LOG_PREFIX.EVENT}: ${event.toString()} - event emitted with parameters -> ${args} = `, {
|
|
8
8
|
file: 'Events/impl/index.ts',
|
|
9
9
|
method: 'emit',
|
|
10
10
|
});
|
|
@@ -11,6 +11,54 @@ class MetricManager {
|
|
|
11
11
|
this.webex = webex;
|
|
12
12
|
this.serviceIndicator = indicator;
|
|
13
13
|
}
|
|
14
|
+
submitUploadLogsMetric(name, action, type, trackingId, feedbackId, correlationId, stack, callId) {
|
|
15
|
+
let data;
|
|
16
|
+
switch (name) {
|
|
17
|
+
case METRIC_EVENT.UPLOAD_LOGS_SUCCESS: {
|
|
18
|
+
data = {
|
|
19
|
+
tags: {
|
|
20
|
+
action,
|
|
21
|
+
device_id: this.deviceInfo?.device?.deviceId,
|
|
22
|
+
service_indicator: this.serviceIndicator,
|
|
23
|
+
},
|
|
24
|
+
fields: {
|
|
25
|
+
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
26
|
+
mobius_url: this.deviceInfo?.device?.uri,
|
|
27
|
+
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
28
|
+
correlation_id: correlationId,
|
|
29
|
+
tracking_id: trackingId,
|
|
30
|
+
feedback_id: feedbackId,
|
|
31
|
+
call_id: callId,
|
|
32
|
+
},
|
|
33
|
+
type,
|
|
34
|
+
};
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case METRIC_EVENT.UPLOAD_LOGS_FAILED: {
|
|
38
|
+
data = {
|
|
39
|
+
tags: {
|
|
40
|
+
action,
|
|
41
|
+
device_id: this.deviceInfo?.device?.deviceId,
|
|
42
|
+
service_indicator: this.serviceIndicator,
|
|
43
|
+
},
|
|
44
|
+
fields: {
|
|
45
|
+
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
46
|
+
mobius_url: this.deviceInfo?.device?.uri,
|
|
47
|
+
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
48
|
+
correlation_id: correlationId,
|
|
49
|
+
tracking_id: trackingId,
|
|
50
|
+
feedback_id: feedbackId,
|
|
51
|
+
error: stack,
|
|
52
|
+
call_id: callId,
|
|
53
|
+
},
|
|
54
|
+
type,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (data) {
|
|
59
|
+
this.webex.internal.metrics.submitClientMetrics(name, data);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
14
62
|
setDeviceInfo(deviceInfo) {
|
|
15
63
|
this.deviceInfo = deviceInfo;
|
|
16
64
|
}
|
|
@@ -256,7 +304,7 @@ class MetricManager {
|
|
|
256
304
|
}
|
|
257
305
|
}
|
|
258
306
|
export const getMetricManager = (webex, indicator) => {
|
|
259
|
-
if (!metricManager) {
|
|
307
|
+
if (!metricManager && webex) {
|
|
260
308
|
metricManager = new MetricManager(webex, indicator);
|
|
261
309
|
}
|
|
262
310
|
return metricManager;
|
|
@@ -15,6 +15,8 @@ export var METRIC_EVENT;
|
|
|
15
15
|
METRIC_EVENT["REGISTRATION_ERROR"] = "web-calling-sdk-registration-error";
|
|
16
16
|
METRIC_EVENT["VOICEMAIL"] = "web-calling-sdk-voicemail";
|
|
17
17
|
METRIC_EVENT["VOICEMAIL_ERROR"] = "web-calling-sdk-voicemail-error";
|
|
18
|
+
METRIC_EVENT["UPLOAD_LOGS_SUCCESS"] = "web-calling-sdk-upload-logs-success";
|
|
19
|
+
METRIC_EVENT["UPLOAD_LOGS_FAILED"] = "web-calling-sdk-upload-logs-failed";
|
|
18
20
|
})(METRIC_EVENT || (METRIC_EVENT = {}));
|
|
19
21
|
export var REG_ACTION;
|
|
20
22
|
(function (REG_ACTION) {
|
|
@@ -37,3 +39,4 @@ export var VOICEMAIL_ACTION;
|
|
|
37
39
|
VOICEMAIL_ACTION["DELETE"] = "delete";
|
|
38
40
|
VOICEMAIL_ACTION["TRANSCRIPT"] = "transcript";
|
|
39
41
|
})(VOICEMAIL_ACTION || (VOICEMAIL_ACTION = {}));
|
|
42
|
+
export const UPLOAD_LOGS_ACTION = 'upload_logs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ERROR_CODE } from '../Errors/types';
|
|
2
2
|
import SDKConnector from '../SDKConnector';
|
|
3
|
-
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, } from '../common/constants';
|
|
4
|
-
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
3
|
+
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, METHOD_START_MESSAGE, } from '../common/constants';
|
|
4
|
+
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, uploadLogs, } from '../common/Utils';
|
|
5
5
|
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
6
6
|
import log from '../Logger';
|
|
7
|
-
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, } from './constants';
|
|
7
|
+
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, METHODS, } from './constants';
|
|
8
8
|
export class BroadworksBackendConnector {
|
|
9
9
|
bwtoken;
|
|
10
10
|
userId;
|
|
@@ -26,10 +26,11 @@ export class BroadworksBackendConnector {
|
|
|
26
26
|
init() {
|
|
27
27
|
const loggerContext = {
|
|
28
28
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
29
|
-
method:
|
|
29
|
+
method: METHODS.INIT,
|
|
30
30
|
};
|
|
31
|
-
log.info(
|
|
31
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
32
32
|
const response = this.setXsiVoiceMessageURI();
|
|
33
|
+
log.log('Successfully initialized Broadworks voicemail connector', loggerContext);
|
|
33
34
|
return response;
|
|
34
35
|
}
|
|
35
36
|
getSDKConnector() {
|
|
@@ -38,8 +39,9 @@ export class BroadworksBackendConnector {
|
|
|
38
39
|
async getUserId() {
|
|
39
40
|
const loggerContext = {
|
|
40
41
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
41
|
-
method:
|
|
42
|
+
method: METHODS.GET_USER_ID,
|
|
42
43
|
};
|
|
44
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
43
45
|
try {
|
|
44
46
|
await this.getBwToken();
|
|
45
47
|
if (this.bwtoken && this.bwtoken.split('.').length > 1) {
|
|
@@ -54,10 +56,18 @@ export class BroadworksBackendConnector {
|
|
|
54
56
|
const errorInfo = {
|
|
55
57
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
56
58
|
};
|
|
59
|
+
const extendedError = new Error(`Failed to get userId: ${err}`);
|
|
60
|
+
log.error(extendedError, loggerContext);
|
|
61
|
+
await uploadLogs();
|
|
57
62
|
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
async getBwToken() {
|
|
66
|
+
const loggerContext = {
|
|
67
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
68
|
+
method: METHODS.GET_BW_TOKEN,
|
|
69
|
+
};
|
|
70
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
61
71
|
try {
|
|
62
72
|
const bwTokenResponse = await this.webex.request({
|
|
63
73
|
uri: `${this.webex.internal.services._serviceUrls.broadworksIdpProxy}${BW_TOKEN_FETCH_ENDPOINT}`,
|
|
@@ -65,16 +75,23 @@ export class BroadworksBackendConnector {
|
|
|
65
75
|
});
|
|
66
76
|
const response = bwTokenResponse.body;
|
|
67
77
|
this.bwtoken = response[TOKEN][BEARER];
|
|
78
|
+
log.log('Successfully fetched Broadworks token', loggerContext);
|
|
68
79
|
}
|
|
69
80
|
catch (err) {
|
|
70
|
-
|
|
81
|
+
const extendedError = new Error(`Broadworks token exception: ${err}`);
|
|
82
|
+
log.error(extendedError, {
|
|
83
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
84
|
+
method: METHODS.GET_BW_TOKEN,
|
|
85
|
+
});
|
|
86
|
+
await uploadLogs();
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
async setXsiVoiceMessageURI() {
|
|
74
90
|
const loggerContext = {
|
|
75
91
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
76
|
-
method:
|
|
92
|
+
method: METHODS.SET_XSI_VOICE_MESSAGE_URI,
|
|
77
93
|
};
|
|
94
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
78
95
|
let userIdResponse = await this.getUserId();
|
|
79
96
|
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.BWRKS);
|
|
80
97
|
this.xsiAccessToken = `${BEARER} ${this.bwtoken}`;
|
|
@@ -87,14 +104,15 @@ export class BroadworksBackendConnector {
|
|
|
87
104
|
message: SUCCESS_MESSAGE,
|
|
88
105
|
};
|
|
89
106
|
}
|
|
107
|
+
log.log('Successfully set XSI voice message URI', loggerContext);
|
|
90
108
|
return userIdResponse;
|
|
91
109
|
}
|
|
92
110
|
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
93
111
|
const loggerContext = {
|
|
94
112
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
95
|
-
method:
|
|
113
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
96
114
|
};
|
|
97
|
-
log.info(
|
|
115
|
+
log.info(`${METHOD_START_MESSAGE} with offset: ${offset}, offsetLimit: ${offsetLimit}, sort type: ${sort}`, loggerContext);
|
|
98
116
|
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
99
117
|
let messageinfo;
|
|
100
118
|
const sortParam = Object.values(SORT).includes(sort) ? sort : SORT.DEFAULT;
|
|
@@ -127,11 +145,15 @@ export class BroadworksBackendConnector {
|
|
|
127
145
|
const errorInfo = {
|
|
128
146
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
129
147
|
};
|
|
148
|
+
const extendedError = new Error(`Failed to get voicemail list: ${err}`);
|
|
149
|
+
log.error(extendedError, loggerContext);
|
|
150
|
+
await uploadLogs();
|
|
130
151
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
152
|
return errorStatus;
|
|
132
153
|
}
|
|
133
154
|
}
|
|
134
155
|
const { messages, moreVMAvailable } = fetchVoicemailList(this.context, offset, offsetLimit, loggerContext);
|
|
156
|
+
log.log(`Successfully fetched voicemail list with ${messages.length} messages`, loggerContext);
|
|
135
157
|
const responseDetails = {
|
|
136
158
|
statusCode: moreVMAvailable ? SUCCESS_STATUS_CODE : NO_VOICEMAIL_STATUS_CODE,
|
|
137
159
|
data: {
|
|
@@ -144,8 +166,9 @@ export class BroadworksBackendConnector {
|
|
|
144
166
|
async getVoicemailContent(messageId) {
|
|
145
167
|
const loggerContext = {
|
|
146
168
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
147
|
-
method:
|
|
169
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
148
170
|
};
|
|
171
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
149
172
|
try {
|
|
150
173
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
151
174
|
const response = await fetch(`${voicemailContentUrl}`, {
|
|
@@ -163,7 +186,8 @@ export class BroadworksBackendConnector {
|
|
|
163
186
|
const mediaDetails = xmlDOM.getElementsByTagName(MESSAGE_MEDIA_CONTENT)[0];
|
|
164
187
|
const mediaType = mediaDetails.childNodes[1]?.textContent;
|
|
165
188
|
const mediaContent = mediaDetails.childNodes[2]?.textContent;
|
|
166
|
-
log.info(`Media type is
|
|
189
|
+
log.info(`Media type is ${mediaType}`, loggerContext);
|
|
190
|
+
log.log(`Successfully fetched voicemail content for message ID: ${messageId}`, loggerContext);
|
|
167
191
|
const responseDetails = {
|
|
168
192
|
statusCode: response?.status,
|
|
169
193
|
data: {
|
|
@@ -180,6 +204,9 @@ export class BroadworksBackendConnector {
|
|
|
180
204
|
const errorInfo = {
|
|
181
205
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
182
206
|
};
|
|
207
|
+
const extendedError = new Error(`Failed to get voicemail content: ${err}`);
|
|
208
|
+
log.error(extendedError, loggerContext);
|
|
209
|
+
await uploadLogs();
|
|
183
210
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
184
211
|
return errorStatus;
|
|
185
212
|
}
|
|
@@ -190,8 +217,9 @@ export class BroadworksBackendConnector {
|
|
|
190
217
|
async voicemailMarkAsRead(messageId) {
|
|
191
218
|
const loggerContext = {
|
|
192
219
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
193
|
-
method:
|
|
220
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
194
221
|
};
|
|
222
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
195
223
|
try {
|
|
196
224
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
197
225
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -203,6 +231,7 @@ export class BroadworksBackendConnector {
|
|
|
203
231
|
if (!response.ok) {
|
|
204
232
|
throw new Error(`${response.status}`);
|
|
205
233
|
}
|
|
234
|
+
log.log(`Successfully marked voicemail with ID ${messageId} as read`, loggerContext);
|
|
206
235
|
const responseDetails = {
|
|
207
236
|
statusCode: response.status,
|
|
208
237
|
data: {},
|
|
@@ -214,6 +243,9 @@ export class BroadworksBackendConnector {
|
|
|
214
243
|
const errorInfo = {
|
|
215
244
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
216
245
|
};
|
|
246
|
+
const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
|
|
247
|
+
log.error(extendedError, loggerContext);
|
|
248
|
+
await uploadLogs();
|
|
217
249
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
218
250
|
return errorStatus;
|
|
219
251
|
}
|
|
@@ -221,8 +253,9 @@ export class BroadworksBackendConnector {
|
|
|
221
253
|
async voicemailMarkAsUnread(messageId) {
|
|
222
254
|
const loggerContext = {
|
|
223
255
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
224
|
-
method:
|
|
256
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
225
257
|
};
|
|
258
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
226
259
|
try {
|
|
227
260
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
228
261
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -234,6 +267,7 @@ export class BroadworksBackendConnector {
|
|
|
234
267
|
if (!response.ok) {
|
|
235
268
|
throw new Error(`${response.status}`);
|
|
236
269
|
}
|
|
270
|
+
log.log(`Successfully marked voicemail with ID ${messageId} as unread`, loggerContext);
|
|
237
271
|
const responseDetails = {
|
|
238
272
|
statusCode: response.status,
|
|
239
273
|
data: {},
|
|
@@ -245,6 +279,9 @@ export class BroadworksBackendConnector {
|
|
|
245
279
|
const errorInfo = {
|
|
246
280
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
247
281
|
};
|
|
282
|
+
const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
|
|
283
|
+
log.error(extendedError, loggerContext);
|
|
284
|
+
await uploadLogs();
|
|
248
285
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
249
286
|
return errorStatus;
|
|
250
287
|
}
|
|
@@ -252,8 +289,9 @@ export class BroadworksBackendConnector {
|
|
|
252
289
|
async deleteVoicemail(messageId) {
|
|
253
290
|
const loggerContext = {
|
|
254
291
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
255
|
-
method:
|
|
292
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
256
293
|
};
|
|
294
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
257
295
|
try {
|
|
258
296
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
259
297
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -265,6 +303,7 @@ export class BroadworksBackendConnector {
|
|
|
265
303
|
if (!response.ok) {
|
|
266
304
|
throw new Error(`${response.status}`);
|
|
267
305
|
}
|
|
306
|
+
log.log(`Successfully deleted voicemail with ID ${messageId}`, loggerContext);
|
|
268
307
|
const responseDetails = {
|
|
269
308
|
statusCode: response.status,
|
|
270
309
|
data: {},
|
|
@@ -276,16 +315,26 @@ export class BroadworksBackendConnector {
|
|
|
276
315
|
const errorInfo = {
|
|
277
316
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
278
317
|
};
|
|
318
|
+
const extendedError = new Error(`Failed to delete voicemail: ${err}`);
|
|
319
|
+
log.error(extendedError, loggerContext);
|
|
320
|
+
await uploadLogs();
|
|
279
321
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
280
322
|
return errorStatus;
|
|
281
323
|
}
|
|
282
324
|
}
|
|
283
325
|
async getVMTranscript(messageId) {
|
|
284
|
-
|
|
326
|
+
const loggerContext = {
|
|
327
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
328
|
+
method: METHODS.GET_VM_TRANSCRIPT,
|
|
329
|
+
};
|
|
330
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
285
331
|
return Promise.resolve(null);
|
|
286
332
|
}
|
|
287
333
|
resolveContact(callingPartyInfo) {
|
|
288
|
-
log.info(
|
|
334
|
+
log.info(`${METHOD_START_MESSAGE} with Calling Party Info: ${callingPartyInfo}`, {
|
|
335
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
336
|
+
method: METHODS.RESOLVE_CONTACT,
|
|
337
|
+
});
|
|
289
338
|
return Promise.resolve(null);
|
|
290
339
|
}
|
|
291
340
|
}
|