@webex/contact-center 3.9.0 → 3.10.0-next.10

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 (115) hide show
  1. package/dist/cc.js +207 -47
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +1 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger-proxy.js +24 -1
  8. package/dist/logger-proxy.js.map +1 -1
  9. package/dist/metrics/MetricsManager.js +1 -1
  10. package/dist/metrics/MetricsManager.js.map +1 -1
  11. package/dist/metrics/behavioral-events.js +89 -0
  12. package/dist/metrics/behavioral-events.js.map +1 -1
  13. package/dist/metrics/constants.js +32 -2
  14. package/dist/metrics/constants.js.map +1 -1
  15. package/dist/services/AddressBook.js +271 -0
  16. package/dist/services/AddressBook.js.map +1 -0
  17. package/dist/services/EntryPoint.js +227 -0
  18. package/dist/services/EntryPoint.js.map +1 -0
  19. package/dist/services/Queue.js +261 -0
  20. package/dist/services/Queue.js.map +1 -0
  21. package/dist/services/config/constants.js +36 -2
  22. package/dist/services/config/constants.js.map +1 -1
  23. package/dist/services/config/index.js +29 -21
  24. package/dist/services/config/index.js.map +1 -1
  25. package/dist/services/config/types.js +33 -1
  26. package/dist/services/config/types.js.map +1 -1
  27. package/dist/services/core/GlobalTypes.js.map +1 -1
  28. package/dist/services/core/Utils.js +181 -2
  29. package/dist/services/core/Utils.js.map +1 -1
  30. package/dist/services/core/aqm-reqs.js +0 -4
  31. package/dist/services/core/aqm-reqs.js.map +1 -1
  32. package/dist/services/core/constants.js +17 -1
  33. package/dist/services/core/constants.js.map +1 -1
  34. package/dist/services/core/websocket/WebSocketManager.js +0 -4
  35. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  36. package/dist/services/task/TaskManager.js +151 -7
  37. package/dist/services/task/TaskManager.js.map +1 -1
  38. package/dist/services/task/TaskUtils.js +104 -0
  39. package/dist/services/task/TaskUtils.js.map +1 -0
  40. package/dist/services/task/constants.js +26 -1
  41. package/dist/services/task/constants.js.map +1 -1
  42. package/dist/services/task/contact.js +86 -0
  43. package/dist/services/task/contact.js.map +1 -1
  44. package/dist/services/task/index.js +428 -91
  45. package/dist/services/task/index.js.map +1 -1
  46. package/dist/services/task/types.js +12 -0
  47. package/dist/services/task/types.js.map +1 -1
  48. package/dist/types/cc.d.ts +121 -35
  49. package/dist/types/constants.d.ts +1 -0
  50. package/dist/types/index.d.ts +4 -3
  51. package/dist/types/metrics/constants.d.ts +25 -1
  52. package/dist/types/services/AddressBook.d.ts +74 -0
  53. package/dist/types/services/EntryPoint.d.ts +67 -0
  54. package/dist/types/services/Queue.d.ts +76 -0
  55. package/dist/types/services/config/constants.d.ts +35 -1
  56. package/dist/types/services/config/index.d.ts +6 -9
  57. package/dist/types/services/config/types.d.ts +79 -58
  58. package/dist/types/services/core/GlobalTypes.d.ts +25 -0
  59. package/dist/types/services/core/Utils.d.ts +55 -1
  60. package/dist/types/services/core/constants.d.ts +14 -0
  61. package/dist/types/services/task/TaskUtils.d.ts +42 -0
  62. package/dist/types/services/task/constants.d.ts +23 -0
  63. package/dist/types/services/task/contact.d.ts +10 -0
  64. package/dist/types/services/task/index.d.ts +85 -4
  65. package/dist/types/services/task/types.d.ts +245 -21
  66. package/dist/types/types.d.ts +162 -0
  67. package/dist/types/utils/PageCache.d.ts +173 -0
  68. package/dist/types.js +17 -0
  69. package/dist/types.js.map +1 -1
  70. package/dist/utils/PageCache.js +192 -0
  71. package/dist/utils/PageCache.js.map +1 -0
  72. package/dist/webex.js +1 -1
  73. package/package.json +10 -9
  74. package/src/cc.ts +232 -52
  75. package/src/constants.ts +1 -0
  76. package/src/index.ts +17 -2
  77. package/src/logger-proxy.ts +24 -1
  78. package/src/metrics/MetricsManager.ts +1 -1
  79. package/src/metrics/behavioral-events.ts +94 -0
  80. package/src/metrics/constants.ts +37 -1
  81. package/src/services/AddressBook.ts +291 -0
  82. package/src/services/EntryPoint.ts +241 -0
  83. package/src/services/Queue.ts +277 -0
  84. package/src/services/config/constants.ts +42 -2
  85. package/src/services/config/index.ts +30 -30
  86. package/src/services/config/types.ts +59 -58
  87. package/src/services/core/GlobalTypes.ts +27 -0
  88. package/src/services/core/Utils.ts +215 -1
  89. package/src/services/core/aqm-reqs.ts +0 -5
  90. package/src/services/core/constants.ts +16 -0
  91. package/src/services/core/websocket/WebSocketManager.ts +0 -4
  92. package/src/services/task/TaskManager.ts +182 -9
  93. package/src/services/task/TaskUtils.ts +113 -0
  94. package/src/services/task/constants.ts +25 -0
  95. package/src/services/task/contact.ts +80 -0
  96. package/src/services/task/index.ts +497 -71
  97. package/src/services/task/types.ts +264 -20
  98. package/src/types.ts +180 -0
  99. package/src/utils/PageCache.ts +252 -0
  100. package/test/unit/spec/cc.ts +282 -85
  101. package/test/unit/spec/metrics/MetricsManager.ts +0 -1
  102. package/test/unit/spec/metrics/behavioral-events.ts +42 -0
  103. package/test/unit/spec/services/AddressBook.ts +332 -0
  104. package/test/unit/spec/services/EntryPoint.ts +259 -0
  105. package/test/unit/spec/services/Queue.ts +323 -0
  106. package/test/unit/spec/services/config/index.ts +279 -65
  107. package/test/unit/spec/services/core/Utils.ts +282 -1
  108. package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
  109. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
  110. package/test/unit/spec/services/task/TaskManager.ts +760 -2
  111. package/test/unit/spec/services/task/TaskUtils.ts +131 -0
  112. package/test/unit/spec/services/task/contact.ts +31 -1
  113. package/test/unit/spec/services/task/index.ts +873 -163
  114. package/umd/contact-center.min.js +2 -2
  115. package/umd/contact-center.min.js.map +1 -1
@@ -0,0 +1,131 @@
1
+ import { checkParticipantNotInInteraction,
2
+ getIsConferenceInProgress,
3
+ isParticipantInMainInteraction,
4
+ isPrimary,} from '../../../../../src/services/task/TaskUtils';
5
+ import {ITask} from '../../../../../src/services/task/types';
6
+
7
+ describe('TaskUtils', () => {
8
+ let mockTask: ITask;
9
+ const mockAgentId = 'agent-123';
10
+ const mockOtherAgentId = 'agent-456';
11
+
12
+ beforeEach(() => {
13
+ mockTask = {
14
+ data: {
15
+ interactionId: 'interaction-123',
16
+ agentId: mockAgentId,
17
+ interaction: {
18
+ owner: mockAgentId,
19
+ participants: {
20
+ [mockAgentId]: { hasLeft: false },
21
+ [mockOtherAgentId]: { hasLeft: false },
22
+ },
23
+ media: {
24
+ 'media-1': {
25
+ mType: 'mainCall',
26
+ participants: [mockAgentId, mockOtherAgentId],
27
+ },
28
+ },
29
+ },
30
+ },
31
+ emit: jest.fn(),
32
+ updateTaskData: jest.fn(),
33
+ } as any;
34
+ });
35
+
36
+ describe('isPrimary', () => {
37
+ it('should return true when agent is the owner', () => {
38
+ expect(isPrimary(mockTask, mockAgentId)).toBe(true);
39
+ });
40
+
41
+ it('should return false when agent is not the owner', () => {
42
+ expect(isPrimary(mockTask, mockOtherAgentId)).toBe(false);
43
+ });
44
+
45
+ it('should fallback to data.agentId when owner is not set', () => {
46
+ mockTask.data.interaction.owner = undefined;
47
+ expect(isPrimary(mockTask, mockAgentId)).toBe(true);
48
+ expect(isPrimary(mockTask, mockOtherAgentId)).toBe(false);
49
+ });
50
+ });
51
+
52
+ describe('isParticipantInMainInteraction', () => {
53
+ it('should return true when agent is in mainCall media', () => {
54
+ expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(true);
55
+ });
56
+
57
+ it('should return false when agent is not in mainCall media', () => {
58
+ mockTask.data.interaction.media['media-1'].participants = [mockOtherAgentId];
59
+ expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(false);
60
+ });
61
+
62
+ it('should return false when no mainCall media exists', () => {
63
+ mockTask.data.interaction.media['media-1'].mType = 'consult';
64
+ expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(false);
65
+ });
66
+ });
67
+
68
+ describe('checkParticipantNotInInteraction', () => {
69
+ it('should return false when agent is active participant', () => {
70
+ expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(false);
71
+ });
72
+
73
+ it('should return true when agent is not in participants', () => {
74
+ delete mockTask.data.interaction.participants[mockAgentId];
75
+ expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(true);
76
+ });
77
+
78
+ it('should return true when agent has left', () => {
79
+ mockTask.data.interaction.participants[mockAgentId].hasLeft = true;
80
+ expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(true);
81
+ });
82
+ });
83
+
84
+ describe('getIsConferenceInProgress', () => {
85
+ beforeEach(() => {
86
+ // Set up mock task with proper media structure for conference detection
87
+ mockTask.data.interaction.media = {
88
+ [mockTask.data.interactionId]: {
89
+ mType: 'mainCall',
90
+ participants: [mockAgentId, mockOtherAgentId, 'customer-123'],
91
+ },
92
+ };
93
+ mockTask.data.interaction.participants = {
94
+ [mockAgentId]: { pType: 'Agent', hasLeft: false },
95
+ [mockOtherAgentId]: { pType: 'Agent', hasLeft: false },
96
+ 'customer-123': { pType: 'Customer', hasLeft: false },
97
+ };
98
+ });
99
+
100
+ it('should return true when there are 2 or more active agents', () => {
101
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(true);
102
+ });
103
+
104
+ it('should return false when there is only 1 active agent', () => {
105
+ mockTask.data.interaction.participants[mockOtherAgentId].hasLeft = true;
106
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
107
+ });
108
+
109
+ it('should exclude customers from agent count', () => {
110
+ // Remove one agent, should still be false with only 1 agent + customer
111
+ delete mockTask.data.interaction.participants[mockOtherAgentId];
112
+ mockTask.data.interaction.media[mockTask.data.interactionId].participants = [mockAgentId, 'customer-123'];
113
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
114
+ });
115
+
116
+ it('should exclude supervisors from agent count', () => {
117
+ mockTask.data.interaction.participants[mockOtherAgentId].pType = 'Supervisor';
118
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
119
+ });
120
+
121
+ it('should exclude VVA from agent count', () => {
122
+ mockTask.data.interaction.participants[mockOtherAgentId].pType = 'VVA';
123
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
124
+ });
125
+
126
+ it('should return false when no main call media exists', () => {
127
+ mockTask.data.interaction.media = {};
128
+ expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
129
+ });
130
+ });
131
+ });
@@ -197,7 +197,37 @@ describe("Routing contacts", () => {
197
197
  const req = contact.wrapup({
198
198
  interactionId: "interactionId",
199
199
  data: { wrapUpReason: "testWrapUpReason", auxCodeId: "auxCodeID1234", isAutoWrapup: "on" }
200
- } as any);
200
+ } as any);
201
+ expect(req).toBeDefined();
202
+ });
203
+
204
+ it("consultConference", () => {
205
+ fakeAqm.pendingRequests = {};
206
+ const consultData = {
207
+ agentId: "current-agent-id",
208
+ to: "destination-agent-id",
209
+ destinationType: "agent"
210
+ };
211
+ const req = contact.consultConference({
212
+ interactionId: "test-interaction-123",
213
+ data: consultData
214
+ });
215
+ expect(req).toBeDefined();
216
+ });
217
+
218
+ it("exitConference", () => {
219
+ fakeAqm.pendingRequests = {};
220
+ const req = contact.exitConference({
221
+ interactionId: "test-interaction-456"
222
+ });
223
+ expect(req).toBeDefined();
224
+ });
225
+
226
+ it("conferenceTransfer", () => {
227
+ fakeAqm.pendingRequests = {};
228
+ const req = contact.conferenceTransfer({
229
+ interactionId: "test-interaction-transfer-123"
230
+ });
201
231
  expect(req).toBeDefined();
202
232
  });
203
233
  });