@webex/contact-center 3.12.0-llmrefactor.2 → 3.12.0-llmrefactor.3

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 (187) hide show
  1. package/.sdd/manifest.json +5 -4
  2. package/ai-docs/ARCHITECTURE.md +1 -1
  3. package/ai-docs/CONTRACTS.md +5 -1
  4. package/ai-docs/SECURITY.md +1 -1
  5. package/ai-docs/contact-center-spec.md +22 -4
  6. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  7. package/dist/cc.js +440 -10
  8. package/dist/cc.js.map +1 -1
  9. package/dist/config.js +7 -0
  10. package/dist/config.js.map +1 -1
  11. package/dist/constants.js +10 -2
  12. package/dist/constants.js.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/metrics/behavioral-events.js +13 -0
  15. package/dist/metrics/behavioral-events.js.map +1 -1
  16. package/dist/metrics/constants.js +2 -0
  17. package/dist/metrics/constants.js.map +1 -1
  18. package/dist/services/AddressBook.js +18 -15
  19. package/dist/services/AddressBook.js.map +1 -1
  20. package/dist/services/AnswerCallOnWebexService.js +174 -0
  21. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  22. package/dist/services/EntryPoint.js +46 -68
  23. package/dist/services/EntryPoint.js.map +1 -1
  24. package/dist/services/Queue.js +27 -22
  25. package/dist/services/Queue.js.map +1 -1
  26. package/dist/services/WebexCrossClientService.js +171 -0
  27. package/dist/services/WebexCrossClientService.js.map +1 -0
  28. package/dist/services/WxAppTelephonyMercurySync.js +93 -0
  29. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  30. package/dist/services/config/Util.js +3 -0
  31. package/dist/services/config/Util.js.map +1 -1
  32. package/dist/services/config/constants.js +10 -6
  33. package/dist/services/config/constants.js.map +1 -1
  34. package/dist/services/config/types.js +4 -0
  35. package/dist/services/config/types.js.map +1 -1
  36. package/dist/services/core/Err.js.map +1 -1
  37. package/dist/services/core/WebexRequest.js +6 -2
  38. package/dist/services/core/WebexRequest.js.map +1 -1
  39. package/dist/services/core/aqm-reqs.js +28 -14
  40. package/dist/services/core/aqm-reqs.js.map +1 -1
  41. package/dist/services/core/types.js.map +1 -1
  42. package/dist/services/task/Task.js +73 -7
  43. package/dist/services/task/Task.js.map +1 -1
  44. package/dist/services/task/TaskFactory.js +8 -4
  45. package/dist/services/task/TaskFactory.js.map +1 -1
  46. package/dist/services/task/TaskManager.js +176 -20
  47. package/dist/services/task/TaskManager.js.map +1 -1
  48. package/dist/services/task/WebexCallingUtils.js +70 -0
  49. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  50. package/dist/services/task/constants.js +4 -1
  51. package/dist/services/task/constants.js.map +1 -1
  52. package/dist/services/task/contact.js +29 -0
  53. package/dist/services/task/contact.js.map +1 -1
  54. package/dist/services/task/digital/Digital.js +3 -2
  55. package/dist/services/task/digital/Digital.js.map +1 -1
  56. package/dist/services/task/state-machine/TaskStateMachine.js +135 -37
  57. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
  58. package/dist/services/task/state-machine/actions.js +6 -1
  59. package/dist/services/task/state-machine/actions.js.map +1 -1
  60. package/dist/services/task/state-machine/guards.js +38 -11
  61. package/dist/services/task/state-machine/guards.js.map +1 -1
  62. package/dist/services/task/state-machine/types.js.map +1 -1
  63. package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
  64. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
  65. package/dist/services/task/types.js +16 -1
  66. package/dist/services/task/types.js.map +1 -1
  67. package/dist/services/task/voice/Voice.js +350 -14
  68. package/dist/services/task/voice/Voice.js.map +1 -1
  69. package/dist/services/task/voice/WebRTC.js +4 -1
  70. package/dist/services/task/voice/WebRTC.js.map +1 -1
  71. package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
  72. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  73. package/dist/services/wxAppTelephonyUtils.js +19 -0
  74. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  75. package/dist/types/cc.d.ts +77 -4
  76. package/dist/types/config.d.ts +7 -0
  77. package/dist/types/constants.d.ts +8 -0
  78. package/dist/types/index.d.ts +3 -1
  79. package/dist/types/metrics/constants.d.ts +2 -0
  80. package/dist/types/services/AddressBook.d.ts +2 -1
  81. package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
  82. package/dist/types/services/EntryPoint.d.ts +7 -5
  83. package/dist/types/services/Queue.d.ts +5 -3
  84. package/dist/types/services/WebexCrossClientService.d.ts +28 -0
  85. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  86. package/dist/types/services/config/constants.d.ts +8 -5
  87. package/dist/types/services/config/types.d.ts +17 -4
  88. package/dist/types/services/core/Err.d.ts +2 -0
  89. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  90. package/dist/types/services/core/types.d.ts +2 -0
  91. package/dist/types/services/task/Task.d.ts +20 -2
  92. package/dist/types/services/task/TaskFactory.d.ts +2 -1
  93. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  94. package/dist/types/services/task/constants.d.ts +3 -0
  95. package/dist/types/services/task/contact.d.ts +4 -0
  96. package/dist/types/services/task/digital/Digital.d.ts +2 -2
  97. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +260 -56
  98. package/dist/types/services/task/state-machine/guards.d.ts +6 -5
  99. package/dist/types/services/task/state-machine/types.d.ts +9 -1
  100. package/dist/types/services/task/types.d.ts +81 -4
  101. package/dist/types/services/task/voice/Voice.d.ts +48 -9
  102. package/dist/types/services/task/voice/WebRTC.d.ts +2 -2
  103. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
  104. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  105. package/dist/types/types.d.ts +14 -8
  106. package/dist/types/utils/PageCache.d.ts +20 -3
  107. package/dist/types.js +7 -2
  108. package/dist/types.js.map +1 -1
  109. package/dist/utils/PageCache.js +19 -5
  110. package/dist/utils/PageCache.js.map +1 -1
  111. package/dist/webex.js +1 -1
  112. package/package.json +1 -1
  113. package/src/cc.ts +506 -9
  114. package/src/config.ts +7 -0
  115. package/src/constants.ts +8 -0
  116. package/src/index.ts +2 -0
  117. package/src/metrics/ai-docs/metrics-spec.md +9 -3
  118. package/src/metrics/behavioral-events.ts +14 -0
  119. package/src/metrics/constants.ts +2 -0
  120. package/src/services/AddressBook.ts +17 -6
  121. package/src/services/AnswerCallOnWebexService.ts +206 -0
  122. package/src/services/EntryPoint.ts +59 -60
  123. package/src/services/Queue.ts +29 -12
  124. package/src/services/WebexCrossClientService.ts +212 -0
  125. package/src/services/WxAppTelephonyMercurySync.ts +115 -0
  126. package/src/services/ai-docs/AGENTS.md +10 -10
  127. package/src/services/ai-docs/services-spec.md +6 -1
  128. package/src/services/config/Util.ts +3 -0
  129. package/src/services/config/ai-docs/AGENTS.md +1 -1
  130. package/src/services/config/ai-docs/ARCHITECTURE.md +2 -2
  131. package/src/services/config/ai-docs/config-spec.md +6 -0
  132. package/src/services/config/constants.ts +10 -6
  133. package/src/services/config/types.ts +16 -4
  134. package/src/services/core/Err.ts +1 -0
  135. package/src/services/core/WebexRequest.ts +3 -1
  136. package/src/services/core/ai-docs/core-spec.md +5 -1
  137. package/src/services/core/aqm-reqs.ts +30 -15
  138. package/src/services/core/types.ts +2 -0
  139. package/src/services/task/Task.ts +79 -8
  140. package/src/services/task/TaskFactory.ts +8 -3
  141. package/src/services/task/TaskManager.ts +254 -15
  142. package/src/services/task/WebexCallingUtils.ts +136 -0
  143. package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
  144. package/src/services/task/ai-docs/task-spec.md +117 -2
  145. package/src/services/task/constants.ts +3 -0
  146. package/src/services/task/contact.ts +30 -0
  147. package/src/services/task/digital/Digital.ts +4 -2
  148. package/src/services/task/state-machine/TaskStateMachine.ts +210 -63
  149. package/src/services/task/state-machine/actions.ts +5 -2
  150. package/src/services/task/state-machine/ai-docs/AGENTS.md +8 -4
  151. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +17 -8
  152. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +46 -22
  153. package/src/services/task/state-machine/guards.ts +64 -11
  154. package/src/services/task/state-machine/types.ts +16 -1
  155. package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
  156. package/src/services/task/types.ts +114 -4
  157. package/src/services/task/voice/Voice.ts +462 -12
  158. package/src/services/task/voice/WebRTC.ts +5 -1
  159. package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
  160. package/src/services/wxAppTelephonyUtils.ts +14 -0
  161. package/src/types.ts +33 -9
  162. package/src/utils/AGENTS.md +21 -10
  163. package/src/utils/PageCache.ts +38 -5
  164. package/src/utils/ai-docs/utils-spec.md +21 -11
  165. package/test/unit/spec/cc.ts +1274 -0
  166. package/test/unit/spec/metrics/behavioral-events.ts +18 -0
  167. package/test/unit/spec/services/AddressBook.ts +37 -6
  168. package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
  169. package/test/unit/spec/services/EntryPoint.ts +87 -40
  170. package/test/unit/spec/services/Queue.ts +123 -12
  171. package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
  172. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
  173. package/test/unit/spec/services/config/Util.ts +85 -0
  174. package/test/unit/spec/services/core/WebexRequest.ts +3 -1
  175. package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
  176. package/test/unit/spec/services/task/Task.ts +200 -0
  177. package/test/unit/spec/services/task/TaskFactory.ts +39 -2
  178. package/test/unit/spec/services/task/TaskManager.ts +653 -1
  179. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  180. package/test/unit/spec/services/task/contact.ts +33 -0
  181. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +854 -72
  182. package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
  183. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
  184. package/test/unit/spec/services/task/voice/Voice.ts +874 -0
  185. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
  186. package/umd/contact-center.min.js +2 -2
  187. package/umd/contact-center.min.js.map +1 -1
@@ -51,6 +51,7 @@ describe('WebexRequest', () => {
51
51
  resource: 'resource',
52
52
  method: HTTP_METHODS.POST,
53
53
  body: { key: 'value' },
54
+ headers: {'x-test-header': 'test-value'},
54
55
  });
55
56
 
56
57
  expect(result).toEqual(mockResponse);
@@ -59,6 +60,7 @@ describe('WebexRequest', () => {
59
60
  resource: 'resource',
60
61
  method: HTTP_METHODS.POST,
61
62
  body: { key: 'value' },
63
+ headers: {'x-test-header': 'test-value'},
62
64
  });
63
65
  });
64
66
 
@@ -141,4 +143,4 @@ describe('WebexRequest', () => {
141
143
  );
142
144
  });
143
145
  });
144
- });
146
+ });
@@ -334,6 +334,28 @@ describe('AqmReqs', () => {
334
334
  });
335
335
 
336
336
  describe('Event tests', () => {
337
+ const participantDropConfig = (participantId: string, timeout?: number | 'disabled') => ({
338
+ host: 'fake-host',
339
+ url: `/v1/tasks/interaction/conference/participants/${participantId}/drop`,
340
+ data: {},
341
+ timeout,
342
+ redactSensitiveLogs: true,
343
+ err: (error: any) => error,
344
+ notifSuccess: {
345
+ bind: {
346
+ type: 'RoutingMessage',
347
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
348
+ },
349
+ },
350
+ notifFail: {
351
+ bind: {
352
+ type: 'RoutingMessage',
353
+ data: {type: 'ParticipantDropConferenceFailed'},
354
+ },
355
+ errId: 'Service.aqm.task.dropConferenceParticipant' as const,
356
+ },
357
+ });
358
+
337
359
  it('should handle onMessage events', async () => {
338
360
  webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
339
361
 
@@ -564,5 +586,95 @@ describe('AqmReqs', () => {
564
586
  const result = await promise;
565
587
  expect(result).toEqual(eventData);
566
588
  });
589
+
590
+ it('redacts sensitive routing failure payloads from logs', async () => {
591
+ const participantId = '+1/failure-secret';
592
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
593
+ const promise = aqm['createPromise'](participantDropConfig(participantId, 'disabled'));
594
+
595
+ webSocketManagerInstance.emit(
596
+ 'message',
597
+ JSON.stringify({
598
+ type: 'RoutingMessage',
599
+ data: {type: 'ParticipantDropConferenceFailed', participantId},
600
+ })
601
+ );
602
+
603
+ await expect(promise).rejects.toBeDefined();
604
+ expect(LoggerProxy.log).toHaveBeenCalledTimes(1);
605
+ expect(LoggerProxy.log).toHaveBeenCalledWith(
606
+ 'Routing request failed (sensitive details redacted)',
607
+ expect.objectContaining({module: AQM_REQS_FILE})
608
+ );
609
+ expect(JSON.stringify((LoggerProxy.log as jest.Mock).mock.calls)).not.toContain(participantId);
610
+ expect(aqm['pendingRequests']).toEqual({});
611
+ });
612
+
613
+ it('resolves a correlated participant-left event and clears its binds', async () => {
614
+ jest.useFakeTimers();
615
+ (global.window as any).setTimeout = global.setTimeout;
616
+
617
+ try {
618
+ const participantId = '+1/success-secret';
619
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
620
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
621
+ const eventData = {
622
+ type: 'RoutingMessage',
623
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
624
+ };
625
+
626
+ webSocketManagerInstance.emit('message', JSON.stringify(eventData));
627
+
628
+ await expect(promise).resolves.toEqual(eventData);
629
+ expect(aqm['pendingRequests']).toEqual({});
630
+ } finally {
631
+ jest.useRealTimers();
632
+ (global.window as any).setTimeout = global.setTimeout;
633
+ }
634
+ });
635
+
636
+ it('clears participant Drop binds after an HTTP failure without logging sensitive data', async () => {
637
+ jest.useFakeTimers();
638
+ (global.window as any).setTimeout = global.setTimeout;
639
+
640
+ try {
641
+ const participantId = '+1/http-secret';
642
+ const httpFailure = {headers: {Authorization: 'Bearer secret'}};
643
+ webexRequestInstance.request.mockRejectedValueOnce(httpFailure);
644
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
645
+
646
+ await expect(promise).rejects.toBe(httpFailure);
647
+ expect(aqm['pendingRequests']).toEqual({});
648
+ expect(JSON.stringify([
649
+ (LoggerProxy.log as jest.Mock).mock.calls,
650
+ (LoggerProxy.error as jest.Mock).mock.calls,
651
+ ])).not.toContain(participantId);
652
+ expect(httpFailure.headers.Authorization).toBe('*');
653
+ } finally {
654
+ jest.useRealTimers();
655
+ (global.window as any).setTimeout = global.setTimeout;
656
+ }
657
+ });
658
+
659
+ it('uses the default timeout without logging a sensitive request URL', async () => {
660
+ jest.useFakeTimers();
661
+ (global.window as any).setTimeout = global.setTimeout;
662
+
663
+ try {
664
+ const participantId = '+1/timeout-secret';
665
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
666
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
667
+ const rejection = expect(promise).rejects.toBeDefined();
668
+
669
+ jest.advanceTimersByTime(20000);
670
+
671
+ await rejection;
672
+ expect(JSON.stringify((LoggerProxy.error as jest.Mock).mock.calls)).not.toContain(participantId);
673
+ expect(aqm['pendingRequests']).toEqual({});
674
+ } finally {
675
+ jest.useRealTimers();
676
+ (global.window as any).setTimeout = global.setTimeout;
677
+ }
678
+ });
567
679
  });
568
- });
680
+ });
@@ -4,9 +4,11 @@ import {
4
4
  DESTINATION_TYPE,
5
5
  TASK_EVENTS,
6
6
  TASK_CHANNEL_TYPE,
7
+ TransferPayLoad,
7
8
  VOICE_VARIANT,
8
9
  } from '../../../../../src/services/task/types';
9
10
  import {TaskEvent} from '../../../../../src/services/task/state-machine';
11
+ import {ENTRY_POINT_TRANSFER_DESTINATION_TYPE} from '../../../../../src/services/task/constants';
10
12
  import LoggerProxy from '../../../../../src/logger-proxy';
11
13
  import {createTaskData} from './taskTestUtils';
12
14
 
@@ -24,6 +26,20 @@ class DummyTask extends Task {
24
26
  }
25
27
  }
26
28
 
29
+ class ConferenceTask extends DummyTask {
30
+ protected override getChannelSpecificActionOverrides() {
31
+ return {
32
+ ...super.getChannelSpecificActionOverrides(),
33
+ emitTaskParticipantLeft: this.createEmitSelfAction(TASK_EVENTS.TASK_PARTICIPANT_LEFT, {
34
+ updateTaskData: true,
35
+ }),
36
+ emitTaskConferenceEnded: this.createEmitSelfAction(TASK_EVENTS.TASK_CONFERENCE_ENDED, {
37
+ updateTaskData: true,
38
+ }),
39
+ };
40
+ }
41
+ }
42
+
27
43
  class SpyAcceptTask extends Task {
28
44
  public acceptMock: jest.Mock;
29
45
 
@@ -246,6 +262,7 @@ describe('Task (base class)', () => {
246
262
  () => voiceTask.endConsult({} as any),
247
263
  () => voiceTask.consultTransfer({} as any),
248
264
  () => voiceTask.consultConference(),
265
+ () => voiceTask.dropConferenceParticipant({participantId: 'participant-id'}),
249
266
  () => voiceTask.exitConference(),
250
267
  () => voiceTask.transferConference(),
251
268
  () => voiceTask.toggleMute(),
@@ -273,6 +290,171 @@ describe('Task (base class)', () => {
273
290
  expect((voiceTask.data as any).foo).toBe('new');
274
291
  });
275
292
 
293
+ it('syncs owner changes and emits task:hydrate without changing task state', () => {
294
+ const originalData = createTaskData({
295
+ interaction: {owner: 'agent-1'} as any,
296
+ });
297
+ const voiceTask = new DummyTask(dummyContact, originalData);
298
+ const hydrateHandler = jest.fn();
299
+
300
+ voiceTask.stateMachineService?.send({
301
+ type: TaskEvent.TASK_INCOMING,
302
+ taskData: originalData,
303
+ });
304
+ voiceTask.stateMachineService?.send({type: TaskEvent.ASSIGN, taskData: originalData});
305
+ const stateBeforeOwnerChange = voiceTask.stateMachineService?.getSnapshot().value;
306
+ voiceTask.on(TASK_EVENTS.TASK_HYDRATE, hydrateHandler);
307
+
308
+ const updatedData = createTaskData({
309
+ interaction: {owner: 'agent-2'} as any,
310
+ });
311
+ voiceTask.sendStateMachineEvent({
312
+ type: TaskEvent.CONTACT_OWNER_CHANGED,
313
+ taskData: updatedData,
314
+ });
315
+
316
+ expect(voiceTask.data.interaction.owner).toBe('agent-2');
317
+ expect(hydrateHandler).toHaveBeenCalledWith(voiceTask);
318
+ expect(voiceTask.stateMachineService?.getSnapshot().value).toBe(stateBeforeOwnerChange);
319
+ });
320
+
321
+ it('synchronizes the roster from PARTICIPANT_LEAVE without an unrelated state transition', () => {
322
+ const conferenceData = createTaskData({
323
+ agentId: 'agent-1',
324
+ interactionId: 'interaction-1',
325
+ interaction: {
326
+ state: 'conference',
327
+ owner: 'agent-1',
328
+ interactionId: 'interaction-1',
329
+ mainInteractionId: 'interaction-1',
330
+ participants: {
331
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false},
332
+ 'agent-2': {id: 'agent-2', pType: 'Agent', hasLeft: false},
333
+ 'agent-3': {id: 'agent-3', pType: 'Agent', hasLeft: false},
334
+ customer: {id: 'customer', pType: 'Customer', hasLeft: false},
335
+ },
336
+ media: {
337
+ 'interaction-1': {
338
+ mediaResourceId: 'interaction-1',
339
+ mType: 'mainCall',
340
+ participants: ['agent-1', 'agent-2', 'agent-3', 'customer'],
341
+ isHold: false,
342
+ },
343
+ },
344
+ } as any,
345
+ });
346
+ const voiceTask = new ConferenceTask(dummyContact, conferenceData);
347
+ const participantLeftHandler = jest.fn();
348
+
349
+ voiceTask.sendStateMachineEvent({type: TaskEvent.TASK_INCOMING, taskData: conferenceData});
350
+ voiceTask.sendStateMachineEvent({type: TaskEvent.ASSIGN, taskData: conferenceData});
351
+ voiceTask.sendStateMachineEvent({type: TaskEvent.CONFERENCE_START, taskData: conferenceData});
352
+ const conferenceState = voiceTask.stateMachineService?.getSnapshot().value;
353
+ voiceTask.on(TASK_EVENTS.TASK_PARTICIPANT_LEFT, participantLeftHandler);
354
+
355
+ const updatedData = createTaskData({
356
+ ...conferenceData,
357
+ participantId: 'agent-2',
358
+ interaction: {
359
+ ...conferenceData.interaction,
360
+ participants: {
361
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false},
362
+ 'agent-3': {id: 'agent-3', pType: 'Agent', hasLeft: false},
363
+ customer: {id: 'customer', pType: 'Customer', hasLeft: false},
364
+ },
365
+ media: {
366
+ 'interaction-1': {
367
+ ...conferenceData.interaction.media['interaction-1'],
368
+ participants: ['agent-1', 'agent-3', 'customer'],
369
+ },
370
+ },
371
+ } as any,
372
+ });
373
+
374
+ voiceTask.sendStateMachineEvent({
375
+ type: TaskEvent.PARTICIPANT_LEAVE,
376
+ taskData: updatedData,
377
+ participantId: 'agent-2',
378
+ });
379
+
380
+ expect(voiceTask.data.interaction.participants['agent-2']).toBeUndefined();
381
+ expect(participantLeftHandler).toHaveBeenCalledWith(voiceTask);
382
+ expect(voiceTask.stateMachineService?.getSnapshot().value).toBe(conferenceState);
383
+ });
384
+
385
+ it('keeps the conference participant controls after the customer leaves', () => {
386
+ const conferenceData = createTaskData({
387
+ agentId: 'agent-1',
388
+ interactionId: 'interaction-1',
389
+ isConferenceInProgress: true,
390
+ isConferencing: true,
391
+ interaction: {
392
+ state: 'conference',
393
+ mediaType: 'telephony',
394
+ owner: 'agent-1',
395
+ interactionId: 'interaction-1',
396
+ mainInteractionId: 'interaction-1',
397
+ callProcessingDetails: {isConferencing: true},
398
+ participants: {
399
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false},
400
+ 'agent-2': {id: 'agent-2', pType: 'Agent', hasLeft: false},
401
+ customer: {id: 'customer', pType: 'Customer', hasLeft: false},
402
+ },
403
+ media: {
404
+ 'interaction-1': {
405
+ mediaResourceId: 'interaction-1',
406
+ mType: 'mainCall',
407
+ participants: ['agent-1', 'agent-2', 'customer'],
408
+ isHold: false,
409
+ },
410
+ },
411
+ } as any,
412
+ });
413
+ const voiceTask = new ConferenceTask(dummyContact, conferenceData);
414
+ const participantLeftHandler = jest.fn();
415
+ const conferenceEndedHandler = jest.fn();
416
+
417
+ voiceTask.sendStateMachineEvent({type: TaskEvent.TASK_INCOMING, taskData: conferenceData});
418
+ voiceTask.sendStateMachineEvent({type: TaskEvent.ASSIGN, taskData: conferenceData});
419
+ voiceTask.sendStateMachineEvent({type: TaskEvent.CONFERENCE_START, taskData: conferenceData});
420
+ voiceTask.on(TASK_EVENTS.TASK_PARTICIPANT_LEFT, participantLeftHandler);
421
+ voiceTask.on(TASK_EVENTS.TASK_CONFERENCE_ENDED, conferenceEndedHandler);
422
+
423
+ const customerLeftData = createTaskData({
424
+ ...conferenceData,
425
+ participantId: 'customer',
426
+ interaction: {
427
+ ...conferenceData.interaction,
428
+ participants: {
429
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false},
430
+ 'agent-2': {id: 'agent-2', pType: 'Agent', hasLeft: false},
431
+ },
432
+ media: {
433
+ 'interaction-1': {
434
+ ...conferenceData.interaction.media['interaction-1'],
435
+ participants: ['agent-1', 'agent-2'],
436
+ },
437
+ },
438
+ } as any,
439
+ });
440
+
441
+ voiceTask.sendStateMachineEvent({
442
+ type: TaskEvent.PARTICIPANT_LEAVE,
443
+ taskData: customerLeftData,
444
+ participantId: 'customer',
445
+ });
446
+
447
+ expect(voiceTask.data.interaction.participants.customer).toBeUndefined();
448
+ expect(voiceTask.data.interaction.participants['agent-2']).toBeDefined();
449
+ expect(voiceTask.stateMachineService?.getSnapshot().value).toBe('CONFERENCING');
450
+ expect(voiceTask.uiControls.main.exitConference).toEqual({
451
+ isVisible: true,
452
+ isEnabled: true,
453
+ });
454
+ expect(participantLeftHandler).toHaveBeenCalledWith(voiceTask);
455
+ expect(conferenceEndedHandler).not.toHaveBeenCalled();
456
+ });
457
+
276
458
  it('stopStateMachine clears state snapshot access', () => {
277
459
  const fullData = createTaskData();
278
460
  const voiceTask = new DummyTask(dummyContact, fullData);
@@ -398,6 +580,24 @@ describe('Task common methods', () => {
398
580
  expect(result).toEqual({result: 'vt'});
399
581
  });
400
582
 
583
+ it('transfer uses vteamTransfer with the backend destination type for entry-point destinations', async () => {
584
+ const payload: TransferPayLoad = {
585
+ to: 'entry-point-1',
586
+ destinationType: DESTINATION_TYPE.ENTRYPOINT,
587
+ };
588
+ const result = await task.transfer(payload);
589
+
590
+ expect(contact.vteamTransfer).toHaveBeenCalledWith({
591
+ interactionId: taskData.interactionId,
592
+ data: {
593
+ to: payload.to,
594
+ destinationType: ENTRY_POINT_TRANSFER_DESTINATION_TYPE,
595
+ },
596
+ });
597
+ expect(contact.blindTransfer).not.toHaveBeenCalled();
598
+ expect(result).toEqual({result: 'vt'});
599
+ });
600
+
401
601
  it('end invokes contact.end and returns its response', async () => {
402
602
  const result = await task.end();
403
603
  expect(contact.end).toHaveBeenCalledWith({
@@ -1,6 +1,10 @@
1
1
  import 'jsdom-global/register';
2
2
  import TaskFactory from '../../../../../src/services/task/TaskFactory';
3
- import {MEDIA_CHANNEL, TaskData} from '../../../../../src/services/task/types';
3
+ import {
4
+ CONSULT_TRANSFER_DESTINATION_TYPE,
5
+ MEDIA_CHANNEL,
6
+ TaskData,
7
+ } from '../../../../../src/services/task/types';
4
8
  import {LoginOption} from '../../../../../src/types';
5
9
  import WebCallingService from '../../../../../src/services/WebCallingService';
6
10
  import {ConfigFlags} from '../../../../../src/types';
@@ -18,7 +22,7 @@ describe('TaskFactory', () => {
18
22
  loginOption,
19
23
  on: jest.fn(),
20
24
  off: jest.fn?.(),
21
- } as unknown) as WebCallingService;
25
+ } as unknown as WebCallingService);
22
26
 
23
27
  const configFlags: ConfigFlags = {
24
28
  isEndTaskEnabled: true,
@@ -59,4 +63,37 @@ describe('TaskFactory', () => {
59
63
  const t2 = TaskFactory.createTask(dummyContact, svcExt, data, configFlags);
60
64
  expect(t2.constructor.name).toBe('Voice');
61
65
  });
66
+
67
+ it('passes consult/transfer destination policy into created tasks', () => {
68
+ const svc = makeSvc(LoginOption.EXTENSION);
69
+ const data = {
70
+ ...baseData,
71
+ interaction: {
72
+ mediaType: MEDIA_CHANNEL.TELEPHONY,
73
+ contactDirection: {type: 'INBOUND'},
74
+ },
75
+ } as TaskData;
76
+ const task = TaskFactory.createTask(dummyContact, svc, data, {
77
+ ...configFlags,
78
+ consultTransfer: {
79
+ allowConsultToQueue: true,
80
+ accessQueue: 'ALL',
81
+ accessEntryPoint: 'NONE',
82
+ accessBuddyTeam: 'ALL',
83
+ },
84
+ });
85
+
86
+ expect(task.uiControls.consultTransferDestinations).toEqual({
87
+ consult: [
88
+ CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
89
+ CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE,
90
+ CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER,
91
+ ],
92
+ transfer: [
93
+ CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
94
+ CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE,
95
+ CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER,
96
+ ],
97
+ });
98
+ });
62
99
  });