@webex/contact-center 0.0.0-next.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 (177) hide show
  1. package/README.md +81 -0
  2. package/__mocks__/workerMock.js +15 -0
  3. package/babel.config.js +15 -0
  4. package/dist/cc.js +1416 -0
  5. package/dist/cc.js.map +1 -0
  6. package/dist/config.js +72 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/constants.js +58 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/index.js +142 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/logger-proxy.js +115 -0
  13. package/dist/logger-proxy.js.map +1 -0
  14. package/dist/metrics/MetricsManager.js +474 -0
  15. package/dist/metrics/MetricsManager.js.map +1 -0
  16. package/dist/metrics/behavioral-events.js +322 -0
  17. package/dist/metrics/behavioral-events.js.map +1 -0
  18. package/dist/metrics/constants.js +134 -0
  19. package/dist/metrics/constants.js.map +1 -0
  20. package/dist/services/WebCallingService.js +323 -0
  21. package/dist/services/WebCallingService.js.map +1 -0
  22. package/dist/services/agent/index.js +177 -0
  23. package/dist/services/agent/index.js.map +1 -0
  24. package/dist/services/agent/types.js +137 -0
  25. package/dist/services/agent/types.js.map +1 -0
  26. package/dist/services/config/Util.js +203 -0
  27. package/dist/services/config/Util.js.map +1 -0
  28. package/dist/services/config/constants.js +221 -0
  29. package/dist/services/config/constants.js.map +1 -0
  30. package/dist/services/config/index.js +607 -0
  31. package/dist/services/config/index.js.map +1 -0
  32. package/dist/services/config/types.js +334 -0
  33. package/dist/services/config/types.js.map +1 -0
  34. package/dist/services/constants.js +117 -0
  35. package/dist/services/constants.js.map +1 -0
  36. package/dist/services/core/Err.js +43 -0
  37. package/dist/services/core/Err.js.map +1 -0
  38. package/dist/services/core/GlobalTypes.js +6 -0
  39. package/dist/services/core/GlobalTypes.js.map +1 -0
  40. package/dist/services/core/Utils.js +126 -0
  41. package/dist/services/core/Utils.js.map +1 -0
  42. package/dist/services/core/WebexRequest.js +96 -0
  43. package/dist/services/core/WebexRequest.js.map +1 -0
  44. package/dist/services/core/aqm-reqs.js +246 -0
  45. package/dist/services/core/aqm-reqs.js.map +1 -0
  46. package/dist/services/core/constants.js +109 -0
  47. package/dist/services/core/constants.js.map +1 -0
  48. package/dist/services/core/types.js +6 -0
  49. package/dist/services/core/types.js.map +1 -0
  50. package/dist/services/core/websocket/WebSocketManager.js +187 -0
  51. package/dist/services/core/websocket/WebSocketManager.js.map +1 -0
  52. package/dist/services/core/websocket/connection-service.js +111 -0
  53. package/dist/services/core/websocket/connection-service.js.map +1 -0
  54. package/dist/services/core/websocket/keepalive.worker.js +94 -0
  55. package/dist/services/core/websocket/keepalive.worker.js.map +1 -0
  56. package/dist/services/core/websocket/types.js +6 -0
  57. package/dist/services/core/websocket/types.js.map +1 -0
  58. package/dist/services/index.js +78 -0
  59. package/dist/services/index.js.map +1 -0
  60. package/dist/services/task/AutoWrapup.js +88 -0
  61. package/dist/services/task/AutoWrapup.js.map +1 -0
  62. package/dist/services/task/TaskManager.js +369 -0
  63. package/dist/services/task/TaskManager.js.map +1 -0
  64. package/dist/services/task/constants.js +58 -0
  65. package/dist/services/task/constants.js.map +1 -0
  66. package/dist/services/task/contact.js +464 -0
  67. package/dist/services/task/contact.js.map +1 -0
  68. package/dist/services/task/dialer.js +60 -0
  69. package/dist/services/task/dialer.js.map +1 -0
  70. package/dist/services/task/index.js +1188 -0
  71. package/dist/services/task/index.js.map +1 -0
  72. package/dist/services/task/types.js +214 -0
  73. package/dist/services/task/types.js.map +1 -0
  74. package/dist/types/cc.d.ts +676 -0
  75. package/dist/types/config.d.ts +66 -0
  76. package/dist/types/constants.d.ts +45 -0
  77. package/dist/types/index.d.ts +178 -0
  78. package/dist/types/logger-proxy.d.ts +71 -0
  79. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  80. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  81. package/dist/types/metrics/constants.d.ts +127 -0
  82. package/dist/types/services/WebCallingService.d.ts +1 -0
  83. package/dist/types/services/agent/index.d.ts +46 -0
  84. package/dist/types/services/agent/types.d.ts +413 -0
  85. package/dist/types/services/config/Util.d.ts +19 -0
  86. package/dist/types/services/config/constants.d.ts +203 -0
  87. package/dist/types/services/config/index.d.ts +171 -0
  88. package/dist/types/services/config/types.d.ts +1113 -0
  89. package/dist/types/services/constants.d.ts +97 -0
  90. package/dist/types/services/core/Err.d.ts +119 -0
  91. package/dist/types/services/core/GlobalTypes.d.ts +33 -0
  92. package/dist/types/services/core/Utils.d.ts +36 -0
  93. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  94. package/dist/types/services/core/aqm-reqs.d.ts +16 -0
  95. package/dist/types/services/core/constants.d.ts +85 -0
  96. package/dist/types/services/core/types.d.ts +47 -0
  97. package/dist/types/services/core/websocket/WebSocketManager.d.ts +34 -0
  98. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  99. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  100. package/dist/types/services/core/websocket/types.d.ts +37 -0
  101. package/dist/types/services/index.d.ts +52 -0
  102. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  103. package/dist/types/services/task/TaskManager.d.ts +1 -0
  104. package/dist/types/services/task/constants.d.ts +46 -0
  105. package/dist/types/services/task/contact.d.ts +59 -0
  106. package/dist/types/services/task/dialer.d.ts +28 -0
  107. package/dist/types/services/task/index.d.ts +569 -0
  108. package/dist/types/services/task/types.d.ts +1041 -0
  109. package/dist/types/types.d.ts +452 -0
  110. package/dist/types/webex-config.d.ts +53 -0
  111. package/dist/types/webex.d.ts +7 -0
  112. package/dist/types.js +292 -0
  113. package/dist/types.js.map +1 -0
  114. package/dist/webex-config.js +60 -0
  115. package/dist/webex-config.js.map +1 -0
  116. package/dist/webex.js +99 -0
  117. package/dist/webex.js.map +1 -0
  118. package/jest.config.js +45 -0
  119. package/package.json +83 -0
  120. package/src/cc.ts +1618 -0
  121. package/src/config.ts +65 -0
  122. package/src/constants.ts +51 -0
  123. package/src/index.ts +220 -0
  124. package/src/logger-proxy.ts +110 -0
  125. package/src/metrics/MetricsManager.ts +512 -0
  126. package/src/metrics/behavioral-events.ts +332 -0
  127. package/src/metrics/constants.ts +135 -0
  128. package/src/services/WebCallingService.ts +351 -0
  129. package/src/services/agent/index.ts +149 -0
  130. package/src/services/agent/types.ts +440 -0
  131. package/src/services/config/Util.ts +261 -0
  132. package/src/services/config/constants.ts +249 -0
  133. package/src/services/config/index.ts +743 -0
  134. package/src/services/config/types.ts +1117 -0
  135. package/src/services/constants.ts +111 -0
  136. package/src/services/core/Err.ts +126 -0
  137. package/src/services/core/GlobalTypes.ts +34 -0
  138. package/src/services/core/Utils.ts +132 -0
  139. package/src/services/core/WebexRequest.ts +103 -0
  140. package/src/services/core/aqm-reqs.ts +272 -0
  141. package/src/services/core/constants.ts +106 -0
  142. package/src/services/core/types.ts +48 -0
  143. package/src/services/core/websocket/WebSocketManager.ts +196 -0
  144. package/src/services/core/websocket/connection-service.ts +142 -0
  145. package/src/services/core/websocket/keepalive.worker.js +88 -0
  146. package/src/services/core/websocket/types.ts +40 -0
  147. package/src/services/index.ts +71 -0
  148. package/src/services/task/AutoWrapup.ts +86 -0
  149. package/src/services/task/TaskManager.ts +420 -0
  150. package/src/services/task/constants.ts +52 -0
  151. package/src/services/task/contact.ts +429 -0
  152. package/src/services/task/dialer.ts +52 -0
  153. package/src/services/task/index.ts +1375 -0
  154. package/src/services/task/types.ts +1113 -0
  155. package/src/types.ts +639 -0
  156. package/src/webex-config.ts +54 -0
  157. package/src/webex.js +96 -0
  158. package/test/unit/spec/cc.ts +1985 -0
  159. package/test/unit/spec/metrics/MetricsManager.ts +491 -0
  160. package/test/unit/spec/metrics/behavioral-events.ts +102 -0
  161. package/test/unit/spec/services/WebCallingService.ts +416 -0
  162. package/test/unit/spec/services/agent/index.ts +65 -0
  163. package/test/unit/spec/services/config/index.ts +1035 -0
  164. package/test/unit/spec/services/core/Utils.ts +279 -0
  165. package/test/unit/spec/services/core/WebexRequest.ts +144 -0
  166. package/test/unit/spec/services/core/aqm-reqs.ts +570 -0
  167. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +378 -0
  168. package/test/unit/spec/services/core/websocket/connection-service.ts +178 -0
  169. package/test/unit/spec/services/task/TaskManager.ts +1351 -0
  170. package/test/unit/spec/services/task/contact.ts +204 -0
  171. package/test/unit/spec/services/task/dialer.ts +157 -0
  172. package/test/unit/spec/services/task/index.ts +1474 -0
  173. package/tsconfig.json +6 -0
  174. package/typedoc.json +37 -0
  175. package/typedoc.md +240 -0
  176. package/umd/contact-center.min.js +3 -0
  177. package/umd/contact-center.min.js.map +1 -0
@@ -0,0 +1,440 @@
1
+ import {Msg} from '../core/GlobalTypes';
2
+
3
+ /**
4
+ * Response type received when an agent successfully logs out from the system
5
+ * @public
6
+ * @remarks
7
+ * This type represents the response message sent by the server when an agent
8
+ * successfully logs out. It includes essential details about the logout action
9
+ * and the agent's final state.
10
+ */
11
+ export type LogoutSuccess = Msg<{
12
+ /** Message type identifier for agent desktop events */
13
+ eventType: 'AgentDesktopMessage';
14
+ /** Unique identifier of the agent */
15
+ agentId: string;
16
+ /** Tracking ID for the logout request */
17
+ trackingId: string;
18
+ /** Current session ID of the agent */
19
+ agentSessionId: string;
20
+ /** Organization ID the agent belongs to */
21
+ orgId: string;
22
+ /** Current status of the agent (e.g., 'LoggedOut') */
23
+ status: string;
24
+ /** Detailed status information */
25
+ subStatus: string;
26
+ /** Identity of who initiated the logout if not the agent themselves */
27
+ loggedOutBy?: string;
28
+ /** List of roles assigned to the agent */
29
+ roles?: string[];
30
+ /** Type identifier for logout success event */
31
+ type: 'AgentLogoutSuccess';
32
+ }>;
33
+
34
+ /**
35
+ * Response type received when an agent successfully relogins to the system
36
+ * @public
37
+ * @remarks
38
+ * Represents the response message when an agent successfully re-authenticates.
39
+ * Contains comprehensive information about the agent's new session, including
40
+ * their state, assigned channels, and device information.
41
+ */
42
+ export type ReloginSuccess = Msg<{
43
+ /** Message type identifier for agent desktop events */
44
+ eventType: 'AgentDesktopMessage';
45
+ /** Unique identifier of the agent */
46
+ agentId: string;
47
+ /** Tracking ID for the relogin request */
48
+ trackingId: string;
49
+ /** Auxiliary code ID for the agent's initial state */
50
+ auxCodeId: string;
51
+ /** ID of the team the agent belongs to */
52
+ teamId: string;
53
+ /** New session ID assigned to the agent */
54
+ agentSessionId: string;
55
+ /** Directory number assigned to the agent */
56
+ dn: string;
57
+ /** Organization ID the agent belongs to */
58
+ orgId: string;
59
+ /** List of active interaction IDs */
60
+ interactionIds: string[];
61
+ /** Indicates if login is via extension */
62
+ isExtension: boolean;
63
+ /** Current login status */
64
+ status: 'LoggedIn';
65
+ /** Current sub-status */
66
+ subStatus: 'Idle';
67
+ /** ID of the site where the agent is located */
68
+ siteId: string;
69
+ /** Timestamp of last idle code change */
70
+ lastIdleCodeChangeTimestamp: number;
71
+ /** Timestamp of last state change */
72
+ lastStateChangeTimestamp: number;
73
+ /** Reason for the last state change */
74
+ lastStateChangeReason?: string;
75
+ /** Type of agent profile */
76
+ profileType: string;
77
+ /** Map of channel types to channel IDs */
78
+ channelsMap: Record<string, string[]>;
79
+ /** Phone number for dialing */
80
+ dialNumber?: string;
81
+ /** List of roles assigned to the agent */
82
+ roles?: string[];
83
+ /** Type of device being used */
84
+ deviceType?: DeviceType;
85
+ /** Unique identifier of the device */
86
+ deviceId?: string | null;
87
+ /** Flag indicating if emergency modal was shown */
88
+ isEmergencyModalAlreadyDisplayed?: boolean;
89
+ /** Type identifier for relogin success event */
90
+ type: 'AgentReloginSuccess';
91
+ }>;
92
+
93
+ /**
94
+ * Response type received when an agent's state is successfully changed
95
+ * @public
96
+ * @remarks
97
+ * Contains information about the agent's new state, including who initiated
98
+ * the change and timestamps for tracking state transitions.
99
+ */
100
+ export type StateChangeSuccess = Msg<{
101
+ /** Message type identifier for agent desktop events */
102
+ eventType: 'AgentDesktopMessage';
103
+ /** Unique identifier of the agent */
104
+ agentId: string;
105
+ /** Tracking ID for the state change request */
106
+ trackingId: string;
107
+ /** Auxiliary code ID associated with the new state */
108
+ auxCodeId: string;
109
+ /** Current session ID of the agent */
110
+ agentSessionId: string;
111
+ /** Organization ID the agent belongs to */
112
+ orgId: string;
113
+ /** Current status of the agent */
114
+ status: string;
115
+ /** Detailed status indicating availability */
116
+ subStatus: 'Available' | 'Idle';
117
+ /** Timestamp of last idle code change */
118
+ lastIdleCodeChangeTimestamp: number;
119
+ /** Timestamp of current state change */
120
+ lastStateChangeTimestamp: number;
121
+ /** Type identifier for state change success event */
122
+ type: 'AgentStateChangeSuccess';
123
+ /** Identity of who initiated the state change */
124
+ changedBy: string | null;
125
+ /** ID of the user who initiated the change */
126
+ changedById: string | null;
127
+ /** Name of the user who initiated the change */
128
+ changedByName: string | null;
129
+ /** Reason for the state change */
130
+ lastStateChangeReason: string;
131
+ }>;
132
+
133
+ /**
134
+ * Response type received when an agent successfully logs into their station
135
+ * @public
136
+ * @remarks
137
+ * Represents the success response when an agent logs into their workstation.
138
+ * Includes details about the agent's initial state, assigned teams, and channels.
139
+ */
140
+ export type StationLoginSuccess = Msg<{
141
+ /** Message type identifier for agent desktop events */
142
+ eventType: 'AgentDesktopMessage';
143
+ /** Unique identifier of the agent */
144
+ agentId: string;
145
+ /** Tracking ID for the station login request */
146
+ trackingId: string;
147
+ /** Auxiliary code ID for initial state */
148
+ auxCodeId: string;
149
+ /** ID of the team the agent belongs to */
150
+ teamId: string;
151
+ /** New session ID assigned to the agent */
152
+ agentSessionId: string;
153
+ /** Organization ID the agent belongs to */
154
+ orgId: string;
155
+ /** List of active interaction IDs */
156
+ interactionIds: string[];
157
+ /** Current login status */
158
+ status: string;
159
+ /** Current availability status */
160
+ subStatus: 'Available' | 'Idle';
161
+ /** ID of the site where the agent is located */
162
+ siteId: string;
163
+ /** Timestamp of last idle code change */
164
+ lastIdleCodeChangeTimestamp: number;
165
+ /** Timestamp of last state change */
166
+ lastStateChangeTimestamp: number;
167
+ /** Type of agent profile */
168
+ profileType: string;
169
+ /** Map of channel types to channel IDs */
170
+ channelsMap: Record<string, string[]>;
171
+ /** Phone number for dialing */
172
+ dialNumber?: string;
173
+ /** List of roles assigned to the agent */
174
+ roles?: string[];
175
+ /** Session ID of the supervising agent if applicable */
176
+ supervisorSessionId?: string;
177
+ /** Type identifier for station login success event */
178
+ type: 'AgentStationLoginSuccess';
179
+ }>;
180
+
181
+ /**
182
+ * Extended response type for station login success that includes notification tracking
183
+ * @public
184
+ * @remarks
185
+ * Similar to StationLoginSuccess but includes additional fields for notification
186
+ * tracking and multimedia profile settings.
187
+ */
188
+ export type StationLoginSuccessResponse = {
189
+ /** Message type identifier for agent desktop events */
190
+ eventType: 'AgentDesktopMessage';
191
+ /** Unique identifier of the agent */
192
+ agentId: string;
193
+ /** Tracking ID for the station login request */
194
+ trackingId: string;
195
+ /** Auxiliary code ID for initial state */
196
+ auxCodeId: string;
197
+ /** ID of the team the agent belongs to */
198
+ teamId: string;
199
+ /** New session ID assigned to the agent */
200
+ agentSessionId: string;
201
+ /** Organization ID the agent belongs to */
202
+ orgId: string;
203
+ /** List of active interaction IDs */
204
+ interactionIds: string[];
205
+ /** Current login status */
206
+ status: string;
207
+ /** Current availability status */
208
+ subStatus: 'Available' | 'Idle';
209
+ /** ID of the site where the agent is located */
210
+ siteId: string;
211
+ /** Timestamp of last idle code change */
212
+ lastIdleCodeChangeTimestamp: number;
213
+ /** Timestamp of last state change */
214
+ lastStateChangeTimestamp: number;
215
+ /** Type of agent profile */
216
+ profileType: string;
217
+ /** Multimedia profile capacity settings */
218
+ mmProfile: {
219
+ /** Maximum concurrent chat capacity */
220
+ chat: number;
221
+ /** Maximum concurrent email capacity */
222
+ email: number;
223
+ /** Maximum concurrent social media capacity */
224
+ social: number;
225
+ /** Maximum concurrent voice call capacity */
226
+ telephony: number;
227
+ };
228
+ /** Phone number for dialing */
229
+ dialNumber?: string;
230
+ /** List of roles assigned to the agent */
231
+ roles?: string[];
232
+ /** Session ID of the supervising agent if applicable */
233
+ supervisorSessionId?: string;
234
+ /** Type identifier for station login success event */
235
+ type: 'AgentStationLoginSuccess';
236
+ /** Tracking ID for notifications */
237
+ notifsTrackingId: string;
238
+ };
239
+
240
+ /**
241
+ * Extended response type for agent device type update success
242
+ * @public
243
+ * @remarks
244
+ * Represents the response when an agent's device type is successfully updated.
245
+ * Contains all the details of the agent's session and device configuration.
246
+ */
247
+ export type DeviceTypeUpdateSuccess = Omit<StationLoginSuccessResponse, 'type'> & {
248
+ type: 'AgentDeviceTypeUpdateSuccess';
249
+ };
250
+ /**
251
+ * Parameters required for initiating an agent logout
252
+ * @public
253
+ * @remarks
254
+ * Defines the parameters that can be provided when logging out an agent,
255
+ * including the reason for logout which helps with reporting and auditing.
256
+ */
257
+ export type Logout = {
258
+ /** Reason for the logout action */
259
+ logoutReason?:
260
+ | 'User requested logout'
261
+ | 'Inactivity Logout'
262
+ | 'User requested agent device change';
263
+ };
264
+
265
+ /**
266
+ * Represents the possible states an agent can be in
267
+ * @public
268
+ * @remarks
269
+ * Defines the various states an agent can transition between during their session.
270
+ * Common states include 'Available' (ready to handle interactions), 'Idle' (on break
271
+ * or not ready), and 'RONA' (Response on No Answer).
272
+ */
273
+ export type AgentState = 'Available' | 'Idle' | 'RONA' | string;
274
+
275
+ /**
276
+ * Parameters required for changing an agent's state
277
+ * @public
278
+ * @remarks
279
+ * Defines the necessary information for transitioning an agent from one state to another.
280
+ */
281
+ export type StateChange = {
282
+ /** New state to transition the agent to */
283
+ state: AgentState;
284
+ /** Auxiliary code ID associated with the state change */
285
+ auxCodeId: string;
286
+ /** Reason for the state change */
287
+ lastStateChangeReason?: string;
288
+ /** ID of the agent whose state is being changed */
289
+ agentId?: string;
290
+ };
291
+
292
+ /**
293
+ * Parameters required for agent station login
294
+ * @public
295
+ * @remarks
296
+ * Contains all the necessary information for logging an agent into their workstation,
297
+ * including team assignments, roles, and device configurations.
298
+ */
299
+ export type UserStationLogin = {
300
+ /** Phone number for dialing */
301
+ dialNumber?: string | null;
302
+ /** Directory number */
303
+ dn?: string | null;
304
+ /** ID of the team the agent belongs to */
305
+ teamId: string | null;
306
+ /** Name of the team */
307
+ teamName: string | null;
308
+ /** List of roles assigned to the agent */
309
+ roles?: Array<string>;
310
+ /** ID of the site where the agent is located */
311
+ siteId: string;
312
+ /** Indicates if agent uses a different DN than their assigned one */
313
+ usesOtherDN: boolean;
314
+ /** ID of the agent's skill profile */
315
+ skillProfileId?: string;
316
+ /** ID of the initial auxiliary state code */
317
+ auxCodeId: string;
318
+ /** Indicates if login is via extension */
319
+ isExtension?: boolean;
320
+ /** Type of device being used */
321
+ deviceType?: DeviceType;
322
+ /** Unique identifier of the device */
323
+ deviceId?: string | null;
324
+ /** Flag indicating if emergency modal was shown */
325
+ isEmergencyModalAlreadyDisplayed?: boolean;
326
+ };
327
+
328
+ /**
329
+ * Available options for agent login methods
330
+ * @public
331
+ * @remarks
332
+ * Defines the supported methods for agent login:
333
+ * - AGENT_DN: Login using agent's direct number
334
+ * - EXTENSION: Login using extension number
335
+ * - BROWSER: Browser-based login
336
+ */
337
+ export type LoginOption = 'AGENT_DN' | 'EXTENSION' | 'BROWSER';
338
+
339
+ /**
340
+ * Type of device used for agent login
341
+ * @public
342
+ * @remarks
343
+ * Represents the type of device being used for login. Can be one of the standard
344
+ * LoginOptions or a custom device type string.
345
+ */
346
+ export type DeviceType = LoginOption | string;
347
+
348
+ /**
349
+ * Parameters for retrieving buddy agent information
350
+ * @public
351
+ * @remarks
352
+ * Defines the criteria for fetching information about other agents (buddies)
353
+ * in the system, allowing filtering by profile, media type, and state.
354
+ */
355
+ export type BuddyAgents = {
356
+ agentProfileId: string;
357
+ mediaType: string;
358
+ /** Filter for agent state eg : Available | Idle */
359
+ state?: string;
360
+ };
361
+
362
+ /**
363
+ * Detailed information about a buddy agent
364
+ * @public
365
+ * @remarks
366
+ * Contains comprehensive information about a buddy agent including their
367
+ * current state, assignments, and contact information.
368
+ */
369
+ export type BuddyDetails = {
370
+ agentId: string;
371
+ state: string;
372
+ teamId: string;
373
+ dn: string;
374
+ agentName: string;
375
+ siteId: string;
376
+ };
377
+
378
+ /**
379
+ * Response type received when successfully retrieving buddy agent information
380
+ * @public
381
+ * @remarks
382
+ * Contains the list of buddy agents and their details returned from a buddy
383
+ * agent lookup request. Used for monitoring team member statuses and availability.
384
+ */
385
+ export type BuddyAgentsSuccess = Msg<{
386
+ /** Message type identifier for agent desktop events */
387
+ eventType: 'AgentDesktopMessage';
388
+ /** Unique identifier of the requesting agent */
389
+ agentId: string;
390
+ /** Tracking ID for the buddy list request */
391
+ trackingId: string;
392
+ /** Current session ID of the requesting agent */
393
+ agentSessionId: string;
394
+ /** Organization ID the agent belongs to */
395
+ orgId: string;
396
+ /** Type identifier for buddy agents response */
397
+ type: 'BuddyAgents';
398
+ /** List of buddy agents and their details */
399
+ agentList: Array<BuddyDetails>;
400
+ }>;
401
+
402
+ /**
403
+ * Events emitted by the agent service for various state changes and actions
404
+ * @public
405
+ * @remarks
406
+ * Enumeration of all possible events that can be emitted by the agent service.
407
+ * These events can be used to track and respond to changes in agent state,
408
+ * login status, and other important agent-related activities.
409
+ */
410
+ export enum AGENT_EVENTS {
411
+ /** Emitted when an agent's state changes (e.g., Available to Idle) */
412
+ AGENT_STATE_CHANGE = 'agent:stateChange',
413
+
414
+ /** Emitted when multiple logins are detected for the same agent */
415
+ AGENT_MULTI_LOGIN = 'agent:multiLogin',
416
+
417
+ /** Emitted when an agent successfully logs into their station */
418
+ AGENT_STATION_LOGIN_SUCCESS = 'agent:stationLoginSuccess',
419
+
420
+ /** Emitted when station login attempt fails */
421
+ AGENT_STATION_LOGIN_FAILED = 'agent:stationLoginFailed',
422
+
423
+ /** Emitted when an agent successfully logs out */
424
+ AGENT_LOGOUT_SUCCESS = 'agent:logoutSuccess',
425
+
426
+ /** Emitted when logout attempt fails */
427
+ AGENT_LOGOUT_FAILED = 'agent:logoutFailed',
428
+
429
+ /** Emitted when an agent's directory number is successfully registered */
430
+ AGENT_DN_REGISTERED = 'agent:dnRegistered',
431
+
432
+ /** Emitted when an agent successfully re-authenticates */
433
+ AGENT_RELOGIN_SUCCESS = 'agent:reloginSuccess',
434
+
435
+ /** Emitted when agent state change is successful */
436
+ AGENT_STATE_CHANGE_SUCCESS = 'agent:stateChangeSuccess',
437
+
438
+ /** Emitted when agent state change attempt fails */
439
+ AGENT_STATE_CHANGE_FAILED = 'agent:stateChangeFailed',
440
+ }
@@ -0,0 +1,261 @@
1
+ import {LOST_CONNECTION_RECOVERY_TIMEOUT} from '../core/constants';
2
+ import {
3
+ AgentResponse,
4
+ AuxCode,
5
+ AuxCodeType,
6
+ DesktopProfileResponse,
7
+ DialPlanEntity,
8
+ Entity,
9
+ IDLE_CODE,
10
+ OrgInfo,
11
+ OrgSettings,
12
+ Profile,
13
+ Team,
14
+ TenantData,
15
+ URLMapping,
16
+ WRAP_UP_CODE,
17
+ } from './types';
18
+
19
+ /**
20
+ * Get the URL mapping for the given name
21
+ * @param {Array<URLMapping>} urlMappings
22
+ * @param {string} name
23
+ * @returns {string}
24
+ */
25
+ const getUrlMapping = (urlMappings: Array<URLMapping>, name: string) => {
26
+ const mappedUrl = urlMappings.find((mapping) => mapping.name === name)?.url;
27
+
28
+ return mappedUrl || '';
29
+ };
30
+
31
+ /**
32
+ * Get the MSFT and Webex configuration
33
+ * @param {DesktopProfileResponse} agentProfileData
34
+ * @returns {Object}
35
+ */
36
+ const getMsftConfig = (agentProfileData: DesktopProfileResponse) => {
37
+ return {
38
+ showUserDetailsMS: agentProfileData.showUserDetailsMS ?? false,
39
+ stateSynchronizationMS: agentProfileData.stateSynchronizationMS ?? false,
40
+ };
41
+ };
42
+
43
+ /**
44
+ * Get the Webex configuration
45
+ * @param {DesktopProfileResponse} agentProfileData
46
+ * @returns {Object}
47
+ */
48
+ const getWebexConfig = (agentProfileData: DesktopProfileResponse) => {
49
+ return {
50
+ showUserDetailsWebex: agentProfileData.showUserDetailsWebex ?? false,
51
+ stateSynchronizationWebex: agentProfileData.stateSynchronizationWebex ?? false,
52
+ };
53
+ };
54
+
55
+ /**
56
+ * Get the default agent DN
57
+ * @param {string} agentDNValidation
58
+ * @returns {boolean}
59
+ */
60
+ const getDefaultAgentDN = (agentDNValidation: string) => {
61
+ return agentDNValidation === 'PROVISIONED_VALUE';
62
+ };
63
+
64
+ /**
65
+ * Get the filtered dialplan entries
66
+ * @param {Array<DialPlanEntity>} dialPlanData
67
+ * @param {Array<string>} profileDialPlans
68
+ * @returns {Array<Entity>}
69
+ */
70
+ const getFilteredDialplanEntries = (dialPlanData: DialPlanEntity[], profileDialPlans: string[]) => {
71
+ const dialPlanEntries = [];
72
+ dialPlanData.forEach((dailPlan: DialPlanEntity) => {
73
+ if (profileDialPlans.includes(dailPlan.id)) {
74
+ const filteredPlan = {
75
+ regex: dailPlan.regularExpression,
76
+ prefix: dailPlan.prefix,
77
+ strippedChars: dailPlan.strippedChars,
78
+ name: dailPlan.name,
79
+ };
80
+ dialPlanEntries.push(filteredPlan);
81
+ }
82
+ });
83
+
84
+ return dialPlanEntries;
85
+ };
86
+
87
+ /**
88
+ * Get the filtered aux codes
89
+ * @param {Array<AuxCode>} auxCodes
90
+ * @param {AuxCodeType} type
91
+ * @param {Array<string>} specificCodes
92
+ * @returns {Array<Entity>}
93
+ */
94
+ const getFilterAuxCodes = (
95
+ auxCodes: Array<AuxCode>,
96
+ type: AuxCodeType,
97
+ specificCodes: string[]
98
+ ) => {
99
+ const filteredAuxCodes: Array<Entity> = [];
100
+ auxCodes.forEach((auxCode: AuxCode) => {
101
+ if (
102
+ auxCode.workTypeCode === type &&
103
+ auxCode.active &&
104
+ (specificCodes.length === 0 || specificCodes.includes(auxCode.id))
105
+ ) {
106
+ filteredAuxCodes.push({
107
+ id: auxCode.id,
108
+ name: auxCode.name,
109
+ isSystem: auxCode.isSystemCode,
110
+ isDefault: auxCode.defaultCode,
111
+ });
112
+ }
113
+ });
114
+
115
+ return filteredAuxCodes;
116
+ };
117
+
118
+ /**
119
+ * Get the default wrapup code
120
+ * @param {Array<Entity>} wrapUpReasonList
121
+ * @returns {Entity}
122
+ */
123
+ function getDefaultWrapUpCode(wrapUpReasonList: Entity[]) {
124
+ return wrapUpReasonList?.find((c: Entity) => c.isDefault);
125
+ }
126
+
127
+ /**
128
+ * Parse the agent configurations
129
+ * @param {Object} profileData
130
+ * @returns {Profile}
131
+ */
132
+ function parseAgentConfigs(profileData: {
133
+ userData: AgentResponse;
134
+ teamData: Team[];
135
+ tenantData: TenantData;
136
+ orgInfoData: OrgInfo;
137
+ auxCodes: AuxCode[];
138
+ orgSettingsData: OrgSettings;
139
+ agentProfileData: DesktopProfileResponse;
140
+ dialPlanData: DialPlanEntity[];
141
+ urlMapping: URLMapping[];
142
+ multimediaProfileId: string;
143
+ }): Profile {
144
+ const {
145
+ userData,
146
+ teamData,
147
+ tenantData,
148
+ orgInfoData,
149
+ auxCodes,
150
+ orgSettingsData,
151
+ agentProfileData,
152
+ dialPlanData,
153
+ urlMapping,
154
+ } = profileData;
155
+
156
+ const tenantDataTimeout = tenantData.timeoutDesktopInactivityEnabled
157
+ ? tenantData.timeoutDesktopInactivityMins
158
+ : null;
159
+ const inactivityTimeoutTimer = agentProfileData.timeoutDesktopInactivityCustomEnabled
160
+ ? agentProfileData.timeoutDesktopInactivityMins
161
+ : tenantDataTimeout;
162
+
163
+ const wrapupCodes = getFilterAuxCodes(
164
+ auxCodes,
165
+ WRAP_UP_CODE,
166
+ agentProfileData.accessWrapUpCode === 'ALL' ? [] : agentProfileData.wrapUpCodes
167
+ );
168
+
169
+ const idleCodes = getFilterAuxCodes(
170
+ auxCodes,
171
+ IDLE_CODE,
172
+ agentProfileData.accessIdleCode === 'ALL' ? [] : agentProfileData.idleCodes
173
+ );
174
+
175
+ idleCodes.push({
176
+ id: '0',
177
+ name: 'Available',
178
+ isSystem: false,
179
+ isDefault: false,
180
+ }); // pushing available state to idle codes
181
+
182
+ const defaultWrapUpData = getDefaultWrapUpCode(wrapupCodes);
183
+
184
+ const finalData = {
185
+ teams: teamData,
186
+ defaultDn: userData.defaultDialledNumber,
187
+ forceDefaultDn: tenantData.forceDefaultDn,
188
+ forceDefaultDnForAgent: getDefaultAgentDN(agentProfileData.agentDNValidation),
189
+ regexUS: tenantData.dnDefaultRegex,
190
+ regexOther: tenantData.dnOtherRegex,
191
+ agentId: userData.ciUserId,
192
+ agentName: `${userData.firstName} ${userData.lastName}`,
193
+ agentMailId: userData.email,
194
+ agentProfileID: userData.agentProfileId,
195
+ autoAnswer: agentProfileData.autoAnswer,
196
+ dialPlan: agentProfileData.dialPlanEnabled
197
+ ? {
198
+ type: 'adhocDial',
199
+ dialPlanEntity: getFilteredDialplanEntries(dialPlanData, agentProfileData.dialPlans),
200
+ }
201
+ : undefined,
202
+ multimediaProfileId: profileData.multimediaProfileId,
203
+ skillProfileId: userData.skillProfileId ? userData.skillProfileId : null,
204
+ siteId: userData.siteId,
205
+ enterpriseId: orgInfoData.tenantId,
206
+ tenantTimezone: orgInfoData.timezone,
207
+ privacyShieldVisible: tenantData.privacyShieldVisible,
208
+ organizationIdleCodes: [], // TODO: for supervisor, getOrgFilteredIdleCodes(auxCodes, false),
209
+ idleCodesAccess: agentProfileData.accessIdleCode as 'ALL' | 'SPECIFIC',
210
+ idleCodes,
211
+ wrapupCodes,
212
+ wrapUpData: {
213
+ wrapUpProps: {
214
+ autoWrapup: agentProfileData.autoWrapUp,
215
+ autoWrapupInterval: agentProfileData.autoWrapAfterSeconds,
216
+ lastAgentRoute: agentProfileData.lastAgentRouting,
217
+ wrapUpCodeAccess: agentProfileData.accessWrapUpCode,
218
+ wrapUpReasonList: wrapupCodes,
219
+ allowCancelAutoWrapup: agentProfileData.allowAutoWrapUpExtension,
220
+ },
221
+ },
222
+ defaultWrapupCode: defaultWrapUpData?.id ?? '',
223
+ isOutboundEnabledForTenant: tenantData.outdialEnabled,
224
+ isOutboundEnabledForAgent: agentProfileData.outdialEnabled,
225
+ isAdhocDialingEnabled: agentProfileData.dialPlanEnabled,
226
+ isAgentAvailableAfterOutdial: agentProfileData.agentAvailableAfterOutdial,
227
+ outDialEp: agentProfileData.outdialEntryPointId,
228
+ isCampaignManagementEnabled: orgSettingsData.campaignManagerEnabled,
229
+ isEndCallEnabled: tenantData.endCallEnabled,
230
+ isEndConsultEnabled: tenantData.endConsultEnabled,
231
+ callVariablesSuppressed: tenantData.callVariablesSuppressed,
232
+ agentDbId: userData.dbId,
233
+ allowConsultToQueue: agentProfileData.consultToQueue,
234
+ agentPersonalStatsEnabled: agentProfileData.viewableStatistics
235
+ ? agentProfileData.viewableStatistics.agentStats
236
+ : false,
237
+ addressBookId: agentProfileData.addressBookId,
238
+ outdialANIId: agentProfileData.outdialANIId,
239
+ analyserUserId: userData.id,
240
+
241
+ urlMappings: {
242
+ acqueonApiUrl: getUrlMapping(urlMapping, 'ACQUEON_API_URL'),
243
+ acqueonConsoleUrl: getUrlMapping(urlMapping, 'ACQUEON_CONSOLE_URL'),
244
+ },
245
+ isTimeoutDesktopInactivityEnabled: tenantData.timeoutDesktopInactivityEnabled,
246
+ timeoutDesktopInactivityMins: inactivityTimeoutTimer,
247
+ loginVoiceOptions: agentProfileData.loginVoiceOptions ?? [],
248
+ webRtcEnabled: orgSettingsData.webRtcEnabled,
249
+ maskSensitiveData: orgSettingsData.maskSensitiveData
250
+ ? orgSettingsData.maskSensitiveData
251
+ : false,
252
+ microsoftConfig: getMsftConfig(agentProfileData),
253
+ webexConfig: getWebexConfig(agentProfileData),
254
+ lostConnectionRecoveryTimeout:
255
+ tenantData.lostConnectionRecoveryTimeout || LOST_CONNECTION_RECOVERY_TIMEOUT,
256
+ };
257
+
258
+ return finalData;
259
+ }
260
+
261
+ export {parseAgentConfigs};