@webex/contact-center 3.10.0-next.8 → 3.10.0-wxc-disconnect.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/cc.js +1 -12
  2. package/dist/cc.js.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/services/config/types.js +2 -2
  5. package/dist/services/config/types.js.map +1 -1
  6. package/dist/services/core/Utils.js +71 -90
  7. package/dist/services/core/Utils.js.map +1 -1
  8. package/dist/services/core/constants.js +1 -17
  9. package/dist/services/core/constants.js.map +1 -1
  10. package/dist/services/task/TaskManager.js +17 -89
  11. package/dist/services/task/TaskManager.js.map +1 -1
  12. package/dist/services/task/constants.js +1 -20
  13. package/dist/services/task/constants.js.map +1 -1
  14. package/dist/services/task/index.js +98 -123
  15. package/dist/services/task/index.js.map +1 -1
  16. package/dist/services/task/types.js +4 -2
  17. package/dist/services/task/types.js.map +1 -1
  18. package/dist/types/cc.d.ts +0 -6
  19. package/dist/types/index.d.ts +1 -1
  20. package/dist/types/services/config/types.d.ts +4 -4
  21. package/dist/types/services/core/Utils.d.ts +17 -32
  22. package/dist/types/services/core/constants.d.ts +0 -14
  23. package/dist/types/services/task/constants.d.ts +0 -17
  24. package/dist/types/services/task/index.d.ts +2 -41
  25. package/dist/types/services/task/types.d.ts +33 -133
  26. package/dist/webex.js +1 -1
  27. package/package.json +9 -9
  28. package/src/cc.ts +1 -12
  29. package/src/index.ts +0 -1
  30. package/src/services/config/types.ts +2 -2
  31. package/src/services/core/Utils.ts +85 -101
  32. package/src/services/core/constants.ts +0 -16
  33. package/src/services/task/TaskManager.ts +15 -112
  34. package/src/services/task/constants.ts +0 -19
  35. package/src/services/task/index.ts +82 -108
  36. package/src/services/task/types.ts +33 -142
  37. package/test/unit/spec/services/core/Utils.ts +31 -262
  38. package/test/unit/spec/services/task/TaskManager.ts +6 -620
  39. package/test/unit/spec/services/task/index.ts +79 -502
  40. package/umd/contact-center.min.js +2 -2
  41. package/umd/contact-center.min.js.map +1 -1
  42. package/dist/services/task/TaskUtils.js +0 -104
  43. package/dist/services/task/TaskUtils.js.map +0 -1
  44. package/dist/types/services/task/TaskUtils.d.ts +0 -42
  45. package/src/services/task/TaskUtils.ts +0 -113
  46. package/test/unit/spec/services/task/TaskUtils.ts +0 -131
@@ -245,17 +245,11 @@ class Task extends _events.default {
245
245
  * @private
246
246
  */
247
247
  reconcileData(oldData, newData) {
248
- // Remove keys from oldData that are not in newData
249
- Object.keys(oldData).forEach(key => {
250
- if (!(key in newData) && !_constants2.KEYS_TO_NOT_DELETE.includes(key)) {
251
- delete oldData[key];
252
- }
253
- });
254
-
255
- // Merge or update keys from newData
256
248
  Object.keys(newData).forEach(key => {
257
- if (newData[key] && typeof newData[key] === 'object' && !Array.isArray(newData[key]) && oldData[key] && typeof oldData[key] === 'object' && !Array.isArray(oldData[key])) {
258
- this.reconcileData(oldData[key], newData[key]);
249
+ if (newData[key] && typeof newData[key] === 'object' && !Array.isArray(newData[key])) {
250
+ oldData[key] = this.reconcileData({
251
+ ...oldData[key]
252
+ }, newData[key]);
259
253
  } else {
260
254
  oldData[key] = newData[key];
261
255
  }
@@ -446,7 +440,6 @@ class Task extends _events.default {
446
440
  * Puts the current task/interaction on hold.
447
441
  * Emits task:hold event when successful. For voice tasks, this mutes the audio.
448
442
  *
449
- * @param mediaResourceId - Optional media resource ID to use for the hold operation. If not provided, uses the task's current mediaResourceId
450
443
  * @returns Promise<TaskResponse>
451
444
  * @throws Error if hold operation fails
452
445
  * @example
@@ -467,17 +460,9 @@ class Task extends _events.default {
467
460
  * console.error('Failed to place task on hold:', error);
468
461
  * // Handle error (e.g., show error message, reset UI state)
469
462
  * }
470
- *
471
- * // Place task on hold with custom mediaResourceId
472
- * try {
473
- * await task.hold('custom-media-resource-id');
474
- * console.log('Successfully placed task on hold with custom mediaResourceId');
475
- * } catch (error) {
476
- * console.error('Failed to place task on hold:', error);
477
- * }
478
463
  * ```
479
464
  */
480
- async hold(mediaResourceId) {
465
+ async hold() {
481
466
  try {
482
467
  _loggerProxy.default.info(`Holding task`, {
483
468
  module: _constants.TASK_FILE,
@@ -485,17 +470,16 @@ class Task extends _events.default {
485
470
  interactionId: this.data.interactionId
486
471
  });
487
472
  this.metricsManager.timeEvent([_constants3.METRIC_EVENT_NAMES.TASK_HOLD_SUCCESS, _constants3.METRIC_EVENT_NAMES.TASK_HOLD_FAILED]);
488
- const effectiveMediaResourceId = mediaResourceId ?? this.data.mediaResourceId;
489
473
  const response = await this.contact.hold({
490
474
  interactionId: this.data.interactionId,
491
475
  data: {
492
- mediaResourceId: effectiveMediaResourceId
476
+ mediaResourceId: this.data.mediaResourceId
493
477
  }
494
478
  });
495
479
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_HOLD_SUCCESS, {
496
480
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response),
497
481
  taskId: this.data.interactionId,
498
- mediaResourceId: effectiveMediaResourceId
482
+ mediaResourceId: this.data.mediaResourceId
499
483
  }, ['operational', 'behavioral']);
500
484
  _loggerProxy.default.log(`Task placed on hold successfully`, {
501
485
  module: _constants.TASK_FILE,
@@ -513,10 +497,9 @@ class Task extends _events.default {
513
497
  errorData: err.data?.errorData,
514
498
  reasonCode: err.data?.reasonCode
515
499
  };
516
- const effectiveMediaResourceId = mediaResourceId ?? this.data.mediaResourceId;
517
500
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_HOLD_FAILED, {
518
501
  taskId: this.data.interactionId,
519
- mediaResourceId: effectiveMediaResourceId,
502
+ mediaResourceId: this.data.mediaResourceId,
520
503
  error: error.toString(),
521
504
  ...taskErrorProps,
522
505
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
@@ -529,7 +512,6 @@ class Task extends _events.default {
529
512
  * Resumes the task/interaction that was previously put on hold.
530
513
  * Emits task:resume event when successful. For voice tasks, this restores the audio.
531
514
  *
532
- * @param mediaResourceId - Optional media resource ID to use for the resume operation. If not provided, uses the task's current mediaResourceId from interaction media
533
515
  * @returns Promise<TaskResponse>
534
516
  * @throws Error if resume operation fails
535
517
  * @example
@@ -550,17 +532,9 @@ class Task extends _events.default {
550
532
  * console.error('Failed to resume task:', error);
551
533
  * // Handle error (e.g., show error message)
552
534
  * }
553
- *
554
- * // Resume task from hold with custom mediaResourceId
555
- * try {
556
- * await task.resume('custom-media-resource-id');
557
- * console.log('Successfully resumed task from hold with custom mediaResourceId');
558
- * } catch (error) {
559
- * console.error('Failed to resume task:', error);
560
- * }
561
535
  * ```
562
536
  */
563
- async resume(mediaResourceId) {
537
+ async resume() {
564
538
  try {
565
539
  _loggerProxy.default.info(`Resuming task`, {
566
540
  module: _constants.TASK_FILE,
@@ -570,19 +544,20 @@ class Task extends _events.default {
570
544
  const {
571
545
  mainInteractionId
572
546
  } = this.data.interaction;
573
- const defaultMediaResourceId = this.data.interaction.media[mainInteractionId]?.mediaResourceId;
574
- const effectiveMediaResourceId = mediaResourceId ?? defaultMediaResourceId;
547
+ const {
548
+ mediaResourceId
549
+ } = this.data.interaction.media[mainInteractionId];
575
550
  this.metricsManager.timeEvent([_constants3.METRIC_EVENT_NAMES.TASK_RESUME_SUCCESS, _constants3.METRIC_EVENT_NAMES.TASK_RESUME_FAILED]);
576
551
  const response = await this.contact.unHold({
577
552
  interactionId: this.data.interactionId,
578
553
  data: {
579
- mediaResourceId: effectiveMediaResourceId
554
+ mediaResourceId
580
555
  }
581
556
  });
582
557
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_SUCCESS, {
583
558
  taskId: this.data.interactionId,
584
559
  mainInteractionId,
585
- mediaResourceId: effectiveMediaResourceId,
560
+ mediaResourceId,
586
561
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
587
562
  }, ['operational', 'behavioral']);
588
563
  _loggerProxy.default.log(`Task resumed successfully`, {
@@ -595,8 +570,6 @@ class Task extends _events.default {
595
570
  } catch (error) {
596
571
  const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.RESUME, _constants.TASK_FILE);
597
572
  const mainInteractionId = this.data.interaction?.mainInteractionId;
598
- const defaultMediaResourceId = mainInteractionId ? this.data.interaction.media[mainInteractionId]?.mediaResourceId : '';
599
- const effectiveMediaResourceId = mediaResourceId ?? defaultMediaResourceId;
600
573
  const taskErrorProps = {
601
574
  trackingId: err.data?.trackingId,
602
575
  errorMessage: err.data?.message,
@@ -607,7 +580,7 @@ class Task extends _events.default {
607
580
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_FAILED, {
608
581
  taskId: this.data.interactionId,
609
582
  mainInteractionId,
610
- mediaResourceId: effectiveMediaResourceId,
583
+ mediaResourceId: mainInteractionId ? this.data.interaction.media[mainInteractionId].mediaResourceId : '',
611
584
  ...taskErrorProps,
612
585
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
613
586
  }, ['operational', 'behavioral']);
@@ -1223,27 +1196,27 @@ class Task extends _events.default {
1223
1196
  * ```
1224
1197
  */
1225
1198
  async consultTransfer(consultTransferPayload) {
1226
- // Get the destination agent ID using custom logic from participants data
1227
- const destAgentId = (0, _Utils.calculateDestAgentId)(this.data.interaction, this.agentId);
1199
+ try {
1200
+ // Get the destination agent ID using custom logic from participants data
1201
+ const destAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
1228
1202
 
1229
- // Resolve the target id (queue consult transfers go to the accepted agent)
1230
- if (!destAgentId) {
1231
- throw new Error('No agent has accepted this queue consult yet');
1232
- }
1233
- _loggerProxy.default.info(`Initiating consult transfer to ${consultTransferPayload?.to || destAgentId}`, {
1234
- module: _constants.TASK_FILE,
1235
- method: _constants2.METHODS.CONSULT_TRANSFER,
1236
- interactionId: this.data.interactionId
1237
- });
1203
+ // Resolve the target id (queue consult transfers go to the accepted agent)
1204
+ if (!destAgentId) {
1205
+ throw new Error('No agent has accepted this queue consult yet');
1206
+ }
1207
+ _loggerProxy.default.info(`Initiating consult transfer to ${consultTransferPayload?.to || destAgentId}`, {
1208
+ module: _constants.TASK_FILE,
1209
+ method: _constants2.METHODS.CONSULT_TRANSFER,
1210
+ interactionId: this.data.interactionId
1211
+ });
1212
+ // Obtain payload based on desktop logic using TaskData
1213
+ const finalDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
1238
1214
 
1239
- // Derive destination type from the participant's type property
1240
- const destType = (0, _Utils.calculateDestType)(this.data.interaction, this.agentId);
1241
- // By default we always use the computed destAgentId as the target id
1242
- const consultTransferRequest = {
1243
- to: destAgentId,
1244
- destinationType: destType
1245
- };
1246
- try {
1215
+ // By default we always use the computed destAgentId as the target id
1216
+ const consultTransferRequest = {
1217
+ to: destAgentId,
1218
+ destinationType: finalDestinationType
1219
+ };
1247
1220
  const result = await this.contact.consultTransfer({
1248
1221
  interactionId: this.data.interactionId,
1249
1222
  data: consultTransferRequest
@@ -1271,10 +1244,12 @@ class Task extends _events.default {
1271
1244
  errorData: err.data?.errorData,
1272
1245
  reasonCode: err.data?.reasonCode
1273
1246
  };
1247
+ const failedDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
1248
+ const failedDestAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
1274
1249
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED, {
1275
1250
  taskId: this.data.interactionId,
1276
- destination: destAgentId || '',
1277
- destinationType: destType,
1251
+ destination: failedDestAgentId || '',
1252
+ destinationType: failedDestinationType,
1278
1253
  isConsultTransfer: true,
1279
1254
  error: error.toString(),
1280
1255
  ...taskErrorProps,
@@ -1305,42 +1280,30 @@ class Task extends _events.default {
1305
1280
  * ```
1306
1281
  */
1307
1282
  async consultConference() {
1308
- // Get the destination agent ID dynamically from participants
1309
- // This handles multi-party conference scenarios, CBT (Capacity Based Team), and EP-DN cases
1310
- const destAgentId = (0, _Utils.calculateDestAgentId)(this.data.interaction, this.agentId);
1311
-
1312
- // Validate that we have a destination agent (for queue consult scenarios)
1313
- if (!destAgentId) {
1314
- throw new Error('No agent has accepted this queue consult yet');
1315
- }
1316
-
1317
- // Get the destination agent ID for fetching destination type
1318
- // This helps determine the correct participant type for CBT (Capacity Based Team) and EP-DN scenarios
1319
- const destAgentType = (0, _Utils.calculateDestType)(this.data.interaction, this.agentId);
1320
-
1321
1283
  // Extract consultation conference data from task data (used in both try and catch)
1322
1284
  const consultationData = {
1323
1285
  agentId: this.agentId,
1324
- to: destAgentId,
1325
- destinationType: destAgentType || this.data.destinationType || 'agent'
1286
+ destAgentId: this.data.destAgentId,
1287
+ destinationType: this.data.destinationType || 'agent'
1326
1288
  };
1327
1289
  try {
1328
- _loggerProxy.default.info(`Initiating consult conference to ${destAgentId}`, {
1290
+ _loggerProxy.default.info(`Initiating consult conference to ${consultationData.destAgentId}`, {
1329
1291
  module: _constants.TASK_FILE,
1330
1292
  method: _constants2.METHODS.CONSULT_CONFERENCE,
1331
1293
  interactionId: this.data.interactionId
1332
1294
  });
1295
+ const paramsDataForConferenceV2 = (0, _Utils.buildConsultConferenceParamData)(consultationData, this.data.interactionId);
1333
1296
  const response = await this.contact.consultConference({
1334
- interactionId: this.data.interactionId,
1335
- data: consultationData
1297
+ interactionId: paramsDataForConferenceV2.interactionId,
1298
+ data: paramsDataForConferenceV2.data
1336
1299
  });
1337
1300
 
1338
1301
  // Track success metrics (following consultTransfer pattern)
1339
1302
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_SUCCESS, {
1340
1303
  taskId: this.data.interactionId,
1341
- destination: consultationData.to,
1342
- destinationType: consultationData.destinationType,
1343
- agentId: consultationData.agentId,
1304
+ destination: paramsDataForConferenceV2.data.to,
1305
+ destinationType: paramsDataForConferenceV2.data.destinationType,
1306
+ agentId: paramsDataForConferenceV2.data.agentId,
1344
1307
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
1345
1308
  }, ['operational', 'behavioral', 'business']);
1346
1309
  _loggerProxy.default.log(`Consult conference started successfully`, {
@@ -1358,11 +1321,15 @@ class Task extends _events.default {
1358
1321
  errorData: err.data?.errorData,
1359
1322
  reasonCode: err.data?.reasonCode
1360
1323
  };
1324
+
1325
+ // Track failure metrics (following consultTransfer pattern)
1326
+ // Build conference data for error tracking using extracted data
1327
+ const failedParamsData = (0, _Utils.buildConsultConferenceParamData)(consultationData, this.data.interactionId);
1361
1328
  this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_FAILED, {
1362
1329
  taskId: this.data.interactionId,
1363
- destination: consultationData.to,
1364
- destinationType: consultationData.destinationType,
1365
- agentId: consultationData.agentId,
1330
+ destination: failedParamsData.data.to,
1331
+ destinationType: failedParamsData.data.destinationType,
1332
+ agentId: failedParamsData.data.agentId,
1366
1333
  error: error.toString(),
1367
1334
  ...taskErrorProps,
1368
1335
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
@@ -1448,6 +1415,9 @@ class Task extends _events.default {
1448
1415
  }
1449
1416
  }
1450
1417
 
1418
+ // TODO: Uncomment this method in future PR for Multi-Party Conference support (>3 participants)
1419
+ // Conference transfer will be supported when implementing enhanced multi-party conference functionality
1420
+ /*
1451
1421
  /**
1452
1422
  * Transfers the current conference to another agent
1453
1423
  *
@@ -1468,58 +1438,63 @@ class Task extends _events.default {
1468
1438
  * }
1469
1439
  * ```
1470
1440
  */
1471
- async transferConference() {
1441
+ /* public async transferConference(): Promise<TaskResponse> {
1472
1442
  try {
1473
- _loggerProxy.default.info(`Transferring conference`, {
1474
- module: _constants.TASK_FILE,
1475
- method: _constants2.METHODS.TRANSFER_CONFERENCE,
1476
- interactionId: this.data.interactionId
1443
+ LoggerProxy.info(`Transferring conference`, {
1444
+ module: TASK_FILE,
1445
+ method: METHODS.TRANSFER_CONFERENCE,
1446
+ interactionId: this.data.interactionId,
1477
1447
  });
1478
-
1479
- // Validate that interaction ID exists
1448
+ // Validate that interaction ID exists
1480
1449
  if (!this.data.interactionId) {
1481
1450
  throw new Error('Invalid interaction ID');
1482
1451
  }
1483
- const response = await this.contact.conferenceTransfer({
1484
- interactionId: this.data.interactionId
1452
+ const response = await this.contact.conferenceTransfer({
1453
+ interactionId: this.data.interactionId,
1485
1454
  });
1486
-
1487
- // Track success metrics (following consultTransfer pattern)
1488
- this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS, {
1489
- taskId: this.data.interactionId,
1490
- ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
1491
- }, ['operational', 'behavioral', 'business']);
1492
- _loggerProxy.default.log(`Conference transferred successfully`, {
1493
- module: _constants.TASK_FILE,
1494
- method: _constants2.METHODS.TRANSFER_CONFERENCE,
1495
- interactionId: this.data.interactionId
1455
+ // Track success metrics (following consultTransfer pattern)
1456
+ this.metricsManager.trackEvent(
1457
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS,
1458
+ {
1459
+ taskId: this.data.interactionId,
1460
+ ...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
1461
+ },
1462
+ ['operational', 'behavioral', 'business']
1463
+ );
1464
+ LoggerProxy.log(`Conference transferred successfully`, {
1465
+ module: TASK_FILE,
1466
+ method: METHODS.TRANSFER_CONFERENCE,
1467
+ interactionId: this.data.interactionId,
1496
1468
  });
1497
- return response;
1469
+ return response;
1498
1470
  } catch (error) {
1499
- const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.TRANSFER_CONFERENCE, _constants.TASK_FILE);
1471
+ const err = generateTaskErrorObject(error, METHODS.TRANSFER_CONFERENCE, TASK_FILE);
1500
1472
  const taskErrorProps = {
1501
1473
  trackingId: err.data?.trackingId,
1502
1474
  errorMessage: err.data?.message,
1503
1475
  errorType: err.data?.errorType,
1504
1476
  errorData: err.data?.errorData,
1505
- reasonCode: err.data?.reasonCode
1477
+ reasonCode: err.data?.reasonCode,
1506
1478
  };
1507
-
1508
- // Track failure metrics (following consultTransfer pattern)
1509
- this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED, {
1510
- taskId: this.data.interactionId,
1511
- error: error.toString(),
1512
- ...taskErrorProps,
1513
- ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
1514
- }, ['operational', 'behavioral', 'business']);
1515
- _loggerProxy.default.error(`Failed to transfer conference`, {
1516
- module: _constants.TASK_FILE,
1517
- method: _constants2.METHODS.TRANSFER_CONFERENCE,
1518
- interactionId: this.data.interactionId
1479
+ // Track failure metrics (following consultTransfer pattern)
1480
+ this.metricsManager.trackEvent(
1481
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED,
1482
+ {
1483
+ taskId: this.data.interactionId,
1484
+ error: error.toString(),
1485
+ ...taskErrorProps,
1486
+ ...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details || {}),
1487
+ },
1488
+ ['operational', 'behavioral', 'business']
1489
+ );
1490
+ LoggerProxy.error(`Failed to transfer conference`, {
1491
+ module: TASK_FILE,
1492
+ method: METHODS.TRANSFER_CONFERENCE,
1493
+ interactionId: this.data.interactionId,
1519
1494
  });
1520
- throw err;
1495
+ throw err;
1521
1496
  }
1522
- }
1497
+ } */
1523
1498
  }
1524
1499
  exports.default = Task;
1525
1500
  //# sourceMappingURL=index.js.map