@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,676 @@
1
+ /**
2
+ * @module CCPlugin
3
+ * @packageDocumentation
4
+ * Contact Center Plugin module that provides functionality for managing contact center agents,
5
+ * handling tasks, and interacting with contact center services. This module enables integration
6
+ * with Webex Contact Center features through the WebexSDK.
7
+ */
8
+ import { WebexPlugin } from '@webex/webex-core';
9
+ import { SetStateResponse, IContactCenter, AgentLogin, AgentProfileUpdate, StationLoginResponse, StationLogoutResponse, BuddyAgentsResponse, BuddyAgents, UploadLogsResponse, UpdateDeviceTypeResponse } from './types';
10
+ import LoggerProxy from './logger-proxy';
11
+ import { StateChange, Logout } from './services/agent/types';
12
+ import { Profile, ContactServiceQueue } from './services/config/types';
13
+ import { TaskResponse } from './services/task/types';
14
+ /**
15
+ * The main Contact Center plugin class that enables integration with Webex Contact Center.
16
+ *
17
+ * @class ContactCenter
18
+ * @extends WebexPlugin
19
+ * @implements IContactCenter
20
+ * @description
21
+ * Features:
22
+ *
23
+ * 1. Session Management:
24
+ * - {@link register} - Initialize and register SDK with contact center
25
+ * - {@link deregister} - Cleanup and disconnect SDK resources
26
+ *
27
+ * 2. Agent Login/Logout:
28
+ * - {@link stationLogin} - Login with browser or desk phone
29
+ * - {@link stationLogout} - Logout from current station
30
+ * - {@link updateAgentProfile} - Update device type and settings
31
+ *
32
+ * 3. Agent State Control:
33
+ * - {@link setAgentState} - Change agent state (Available/Idle)
34
+ *
35
+ * 4. Task Management:
36
+ * - Inbound task handling via events
37
+ * - {@link startOutdial} - Make outbound calls
38
+ *
39
+ * 5. Routing & Distribution:
40
+ * - {@link getQueues} - Get available queues for routing
41
+ * - {@link getBuddyAgents} - Get available buddy agents
42
+ *
43
+ * 6. Diagnostics:
44
+ * - {@link uploadLogs} - Upload logs for troubleshooting
45
+ *
46
+ * * Key Events:
47
+ * - Agent State Events:
48
+ * - `agent:stateChange` - Agent's state has changed (Available, Idle, etc.)
49
+ * - `agent:stateChangeSuccess` - Agent state change was successful
50
+ * - `agent:stateChangeFailed` - Agent state change failed
51
+ *
52
+ * - Session Events:
53
+ * - `agent:stationLoginSuccess` - Agent login was successful
54
+ * - `agent:stationLoginFailed` - Agent login failed
55
+ * - `agent:logoutSuccess` - Agent logout was successful
56
+ * - `agent:logoutFailed` - Agent logout failed
57
+ *
58
+ * - Task Events:
59
+ * - `task:incoming` - New task is being offered
60
+ * - `task:hydrate` - Task data has been updated
61
+ * - `task:established` - Task/call has been connected
62
+ * - `task:ended` - Task/call has ended
63
+ * - `task:error` - An error occurred during task handling
64
+ *
65
+ * @public
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import Webex from 'webex';
70
+ *
71
+ * // Initialize SDK with access token
72
+ * const webex = new Webex({
73
+ * credentials: 'YOUR_ACCESS_TOKEN'
74
+ * });
75
+ *
76
+ * // Get Contact Center plugin instance
77
+ * const cc = webex.cc;
78
+ *
79
+ * // Setup event handlers
80
+ * cc.on('agent:stateChange', (event) => {
81
+ * console.log('Agent state changed:', event.state);
82
+ * });
83
+ *
84
+ * cc.on('task:incoming', (task) => {
85
+ * console.log('New task received:', task.interactionId);
86
+ * });
87
+ *
88
+ * // Initialize agent session
89
+ * async function initializeAgent() {
90
+ * try {
91
+ * // Register with contact center
92
+ * const profile = await cc.register();
93
+ *
94
+ * // Login with browser-based calling
95
+ * await cc.stationLogin({
96
+ * teamId: profile.teams[0].teamId,
97
+ * loginOption: 'BROWSER'
98
+ * });
99
+ *
100
+ * // Set agent to Available state
101
+ * await cc.setAgentState({
102
+ * state: 'Available',
103
+ * auxCodeId: '0'
104
+ * });
105
+ *
106
+ * console.log('Agent initialized and ready');
107
+ * } catch (error) {
108
+ * console.error('Initialization failed:', error);
109
+ * await cc.uploadLogs(); // Upload logs for troubleshooting
110
+ * }
111
+ * }
112
+ *
113
+ * initializeAgent();
114
+ * ```
115
+ *
116
+ * @public
117
+ */
118
+ export default class ContactCenter extends WebexPlugin implements IContactCenter {
119
+ /**
120
+ * The plugin's unique namespace identifier in the Webex SDK.
121
+ * Used to access the plugin via webex.cc
122
+ * @type {string}
123
+ * @public
124
+ */
125
+ namespace: string;
126
+ /**
127
+ * Plugin configuration settings including connection and authentication options
128
+ * @type {CCPluginConfig}
129
+ * @private
130
+ */
131
+ private $config;
132
+ /**
133
+ * Reference to the parent Webex SDK instance
134
+ * Used to access core Webex functionality and credentials
135
+ * @type {WebexSDK}
136
+ * @private
137
+ */
138
+ private $webex;
139
+ /**
140
+ * Event emitter for handling internal plugin events
141
+ * Manages event subscriptions and notifications
142
+ * @type {EventEmitter}
143
+ * @private
144
+ */
145
+ private eventEmitter;
146
+ /**
147
+ * Agent's profile and configuration data
148
+ * Includes capabilities, teams, settings, and current state
149
+ * @type {Profile}
150
+ * @private
151
+ */
152
+ private agentConfig;
153
+ /**
154
+ * Service for managing browser-based calling (WebRTC)
155
+ * Handles audio/video streaming and device management
156
+ * @type {WebCallingService}
157
+ * @private
158
+ */
159
+ private webCallingService;
160
+ /**
161
+ * Core service managers for Contact Center operations
162
+ * Includes agent, connection, and configuration services
163
+ * @type {Services}
164
+ * @private
165
+ */
166
+ private services;
167
+ /**
168
+ * Service for making authenticated HTTP requests to Webex APIs
169
+ * Handles request/response lifecycle and error handling
170
+ * @type {WebexRequest}
171
+ * @private
172
+ */
173
+ private webexRequest;
174
+ /**
175
+ * Manager for handling contact center tasks (calls, chats, etc.)
176
+ * Coordinates task lifecycle events and state
177
+ * @type {TaskManager}
178
+ * @private
179
+ */
180
+ private taskManager;
181
+ /**
182
+ * Manager for tracking and reporting SDK metrics and analytics
183
+ * Monitors performance, errors, and usage patterns
184
+ * @type {MetricsManager}
185
+ * @private
186
+ */
187
+ private metricsManager;
188
+ /**
189
+ * Logger utility for Contact Center plugin
190
+ * Provides consistent logging across the plugin
191
+ * @type {LoggerProxy}
192
+ * @public
193
+ */
194
+ LoggerProxy: typeof LoggerProxy;
195
+ /**
196
+ * @ignore
197
+ * Creates an instance of ContactCenter plugin
198
+ * @param {any[]} args Arguments passed to plugin constructor
199
+ */
200
+ constructor(...args: any[]);
201
+ /**
202
+ * Handles incoming task events and triggers appropriate notifications
203
+ * @private
204
+ * @param {ITask} task The incoming task object containing task details
205
+ */
206
+ private handleIncomingTask;
207
+ /**
208
+ * Handles task hydration events for updating task data
209
+ * @private
210
+ * @param {ITask} task The task object to be hydrated with additional data
211
+ */
212
+ private handleTaskHydrate;
213
+ /**
214
+ * Sets up event listeners for incoming tasks and task hydration
215
+ * Subscribes to task events from the task manager
216
+ * @private
217
+ */
218
+ private incomingTaskListener;
219
+ /**
220
+ * Initializes the Contact Center SDK by setting up the web socket connections.
221
+ * This method must be called before performing any agent operations such as login, state change, or handling tasks.
222
+ *
223
+ * @returns {Promise<Profile>} Agent profile information after successful registration.
224
+ * The returned `Profile` object contains details such as:
225
+ * - `agentId`: The unique identifier for the agent.
226
+ * - `defaultDn`: The default dial number associated with the agent.
227
+ * - `teams`: Array of teams the agent belongs to.
228
+ * - `webRtcEnabled`: Indicates if WebRTC (browser calling) is enabled.
229
+ * - `loginVoiceOptions`: Supported login options for the agent (e.g., BROWSER, EXTENSION).
230
+ * - ...and other agent configuration details.
231
+ *
232
+ * @throws {Error} If registration fails.
233
+ *
234
+ * @public
235
+ * @example
236
+ * ```typescript
237
+ * import Webex from 'webex';
238
+ *
239
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
240
+ * const cc = webex.cc;
241
+ *
242
+ * // Register the SDK and fetch agent profile
243
+ * const profile = await cc.register();
244
+ *
245
+ * console.log('Agent ID:', profile.agentId);
246
+ * console.log('Default DN:', profile.defaultDn);
247
+ * console.log('Teams:', profile.teams.map(t => t.teamId));
248
+ * console.log('WebRTC Enabled:', profile.webRtcEnabled);
249
+ * console.log('Supported Login Options:', profile.loginVoiceOptions);
250
+ *
251
+ * // Now you can proceed with station login, state changes, etc.
252
+ * await cc.stationLogin({ teamId: profile.teams[0].teamId, loginOption: 'BROWSER' });
253
+ * ```
254
+ */
255
+ register(): Promise<Profile>;
256
+ /**
257
+ * Unregisters the Contact Center SDK by closing all web socket connections, removing event listeners,
258
+ * and cleaning up internal state.
259
+ *
260
+ * @remarks
261
+ * This method only disconnects the SDK from the backend and cleans up resources. It does NOT perform a station logout
262
+ * (i.e., the agent remains logged in to the contact center unless you explicitly call {@link stationLogout}).
263
+ * Use this when you want to fully tear down the SDK instance, such as during application shutdown or user sign-out.
264
+ *
265
+ * @returns {Promise<void>} Resolves when deregistration and cleanup are complete.
266
+ * @throws {Error} If deregistration fails.
267
+ *
268
+ * @public
269
+ * @example
270
+ * // Typical usage: clean up SDK before application exit or user logout
271
+ * import Webex from 'webex';
272
+ *
273
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
274
+ * const cc = webex.cc;
275
+ *
276
+ * await cc.register();
277
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
278
+ * // ... perform agent operations ...
279
+ *
280
+ * // If you want to log out the agent as well, call:
281
+ * // await cc.stationLogout({ logoutReason: 'User signed out' });
282
+ * // On application shutdown or user sign-out:
283
+ * await cc.deregister();
284
+ *
285
+
286
+ */
287
+ deregister(): Promise<void>;
288
+ /**
289
+ * Returns the list of buddy agents who are in the given user state and media type based on their agent profile settings
290
+ * @param {BuddyAgents} data The data required to fetch buddy agents
291
+ * @returns {Promise<BuddyAgentsResponse>} A promise resolving to the buddy agents information
292
+ * @throws {Error} If fetching buddy agents fails
293
+ * @example
294
+ * ```typescript
295
+ * // Get list of available agents for consultation or transfer
296
+ * const cc = webex.cc;
297
+ *
298
+ * // First ensure you're registered and logged in
299
+ * await cc.register();
300
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
301
+ *
302
+ * // Get buddy agents filtered by state and media type
303
+ * const response = await cc.getBuddyAgents({
304
+ * state: 'Available', // Filter by agent state ('Available', 'Idle', etc.)
305
+ * mediaType: 'telephony' // Filter by media type ('telephony', 'chat', 'email', 'social')
306
+ * });
307
+ *
308
+ * // Process the buddy agents list
309
+ * if (response.data.agentList.length > 0) {
310
+ * const buddyAgents = response.data.agentList;
311
+ * console.log(`Found ${buddyAgents.length} available agents`);
312
+ *
313
+ * // Access agent details
314
+ * buddyAgents.forEach(agent => {
315
+ * console.log(`Agent ID: ${agent.agentId}`);
316
+ * console.log(`Name: ${agent.firstName} ${agent.lastName}`);
317
+ * console.log(`State: ${agent.state}`);
318
+ * console.log(`Team: ${agent.teamName}`);
319
+ * });
320
+ * }
321
+ * ```
322
+ */
323
+ getBuddyAgents(data: BuddyAgents): Promise<BuddyAgentsResponse>;
324
+ /**
325
+ * Connects to the websocket and fetches the agent profile
326
+ * @returns {Promise<Profile>} Agent profile information
327
+ * @throws {Error} If connection fails or profile cannot be fetched
328
+ * @private
329
+ */
330
+ private connectWebsocket;
331
+ /**
332
+ * Performs agent login with specified credentials and device type
333
+ * @param {AgentLogin} data Login parameters including teamId, loginOption and dialNumber
334
+ * @returns {Promise<StationLoginResponse>} Response containing login status and profile
335
+ * @throws {Error} If login fails
336
+ * @public
337
+ * @example
338
+ * ```typescript
339
+ * const cc = webex.cc;
340
+ * await cc.register();
341
+ *
342
+ * // Primary usage: using Promise response
343
+ * try {
344
+ * const response = await cc.stationLogin({
345
+ * teamId: 'team123',
346
+ * loginOption: 'EXTENSION',
347
+ * dialNumber: '1002'
348
+ * });
349
+ * console.log('Login successful:', response);
350
+ * } catch (error) {
351
+ * console.error('Login failed:', error);
352
+ * }
353
+ *
354
+ * // Optional: Also listen for events elsewhere in your application
355
+ * // cc.on('agent:stationLoginSuccess', (data) => { ... });
356
+ * // cc.on('agent:stationLoginFailed', (error) => { ... });
357
+ * ```
358
+ */
359
+ stationLogin(data: AgentLogin): Promise<StationLoginResponse>;
360
+ /**
361
+ * Performs a station logout operation for the agent
362
+ * @remarks
363
+ * A logout operation cannot happen if the agent is in an interaction or haven't logged in yet.
364
+ * @param {Logout} data Logout parameters with logoutReason - a string explaining why the agent is logging out
365
+ * @returns {Promise<StationLogoutResponse>} Response indicating logout status
366
+ * @throws {Error} If logout fails
367
+ * @public
368
+ * @example
369
+ * ```typescript
370
+ * // Basic logout
371
+ * try {
372
+ * await cc.stationLogout({
373
+ * logoutReason: 'End of shift'
374
+ * });
375
+ * console.log('Logged out successfully');
376
+ * } catch (error) {
377
+ * console.error('Logout failed:', error);
378
+ * }
379
+ * ```
380
+ */
381
+ stationLogout(data: Logout): Promise<StationLogoutResponse>;
382
+ /**
383
+ * Gets the device ID based on login option and dial number
384
+ * @param {string} loginOption The login option (BROWSER, EXTENSION, etc)
385
+ * @param {string} dialNumber The dial number if applicable
386
+ * @returns {string} The device ID
387
+ * @private
388
+ */
389
+ private getDeviceId;
390
+ /**
391
+ * Sets the state of the agent to Available or any of the Idle states.
392
+ * After a state change attempt, one of the following events will be emitted:
393
+ * - agent:stateChange: Emitted when agent's state changes (triggered for both local and remote changes)
394
+ * - agent:stateChangeSuccess: Emitted when agent state change is successful
395
+ * - agent:stateChangeFailed: Emitted when agent state change attempt fails
396
+ *
397
+ * @param {StateChange} data State change parameters including the new state
398
+ * @returns {Promise<SetStateResponse>} Response with updated state information
399
+ * @throws {Error} If state change fails
400
+ * @public
401
+ * @example
402
+ * ```typescript
403
+ * const cc = webex.cc;
404
+ * await cc.register();
405
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
406
+ *
407
+ * // Using promise-based approach
408
+ * try {
409
+ * await cc.setAgentState({
410
+ * state: 'Available',
411
+ * auxCodeId: '12345',
412
+ * lastStateChangeReason: 'Manual state change',
413
+ * agentId: 'agent123',
414
+ * });
415
+ * } catch (error) {
416
+ * console.error('State change failed:', error);
417
+ * }
418
+ *
419
+ * // Optionally, listen for events
420
+ * cc.on('agent:stateChange', (eventData) => {
421
+ * // Triggered for both local and remote state changes
422
+ * console.log('State changed:', eventData);
423
+ * });
424
+ *
425
+ * cc.on('agent:stateChangeSuccess', (eventData) => {
426
+ * console.log('State change succeeded:', eventData);
427
+ * });
428
+ *
429
+ * cc.on('agent:stateChangeFailed', (error) => {
430
+ * console.error('State change failed:', error);
431
+ * });
432
+ * ```
433
+ */
434
+ setAgentState(data: StateChange): Promise<SetStateResponse>;
435
+ /**
436
+ * Processes incoming websocket messages and emits corresponding events
437
+ * Handles various event types including agent state changes, login events,
438
+ * and other agent-related notifications
439
+ * @private
440
+ * @param {string} event The raw websocket event message
441
+ */
442
+ private handleWebsocketMessage;
443
+ /**
444
+ * Initializes event listeners for the Contact Center service
445
+ * Sets up handlers for connection state changes and other core events
446
+ * @private
447
+ */
448
+ private setupEventListeners;
449
+ /**
450
+ * Returns the connection configuration
451
+ * @returns {SubscribeRequest} Connection configuration
452
+ * @private
453
+ */
454
+ private getConnectionConfig;
455
+ /**
456
+ * Handles connection lost events and reconnection attempts
457
+ * @param {ConnectionLostDetails} msg Connection lost details
458
+ * @private
459
+ */
460
+ private handleConnectionLost;
461
+ /**
462
+ * Handles silent relogin after registration completion
463
+ * @private
464
+ */
465
+ private silentRelogin;
466
+ /**
467
+ * Handles device type specific configuration and setup
468
+ * Configures services and settings based on the login device type
469
+ * @param {LoginOption} deviceType The type of device being used for login
470
+ * @param {string} dn The dial number associated with the device
471
+ * @returns {Promise<void>}
472
+ * @private
473
+ */
474
+ private handleDeviceType;
475
+ /**
476
+ * Makes an outbound call to a specified phone number.
477
+ *
478
+ * @param {string} destination - The phone number to dial (e.g., '+1234567890').
479
+ * Should include country code and be in E.164 format.
480
+ * @returns {Promise<TaskResponse>} Resolves with the task response containing:
481
+ * - interactionId: Unique identifier for the outbound call
482
+ * - taskId: Identifier for the task instance
483
+ * - data: Task details including state, queue info, and media properties
484
+ * @throws {Error} If the outdial operation fails:
485
+ * - "Agent not configured for outbound calls" if isOutboundEnabledForAgent is false
486
+ * - "Invalid phone number format" if destination is not in E.164 format
487
+ * - "Agent not in Available state" if agent's state is not Available
488
+ * @public
489
+ * @example
490
+ * ```typescript
491
+ * // Initialize and prepare agent
492
+ * const cc = webex.cc;
493
+ * await cc.register();
494
+ * await cc.stationLogin({
495
+ * teamId: 'team123',
496
+ * loginOption: 'BROWSER'
497
+ * });
498
+ *
499
+ * // Set Available state before outbound call
500
+ * await cc.setAgentState({
501
+ * state: 'Available',
502
+ * auxCodeId: '0'
503
+ * });
504
+ *
505
+ * // Make outbound call with full error handling
506
+ * try {
507
+ * // Verify agent is properly configured for outdial
508
+ * if (!cc.agentConfig.isOutboundEnabledForAgent) {
509
+ * throw new Error('Agent not configured for outbound calls');
510
+ * }
511
+ *
512
+ * // Start the outbound call
513
+ * const destination = '+1234567890';
514
+ * const task = await cc.startOutdial(destination);
515
+ *
516
+ * // Listen for all relevant task events
517
+ * task.on('task:ringing', () => {
518
+ * console.log('Call is ringing');
519
+ * updateCallStatus('Ringing...');
520
+ * });
521
+ *
522
+ * task.on('task:established', () => {
523
+ * console.log('Call connected');
524
+ * updateCallStatus('Connected');
525
+ * enableCallControls(); // Show mute, hold, transfer buttons
526
+ * });
527
+ *
528
+ * task.on('task:hold', () => {
529
+ * console.log('Call placed on hold');
530
+ * updateCallStatus('On Hold');
531
+ * });
532
+ *
533
+ * task.on('task:error', (error) => {
534
+ * console.error('Call error:', error);
535
+ * updateCallStatus('Error');
536
+ * showErrorDialog(error.message);
537
+ * });
538
+ *
539
+ * task.on('task:ended', () => {
540
+ * console.log('Call ended');
541
+ * updateCallStatus('Call Ended');
542
+ * resetCallControls();
543
+ *
544
+ * // Handle wrap-up if required
545
+ * if (task.data.wrapUpRequired) {
546
+ * showWrapupForm();
547
+ * }
548
+ * });
549
+ *
550
+ * // Example call control usage
551
+ * function handleMuteToggle() {
552
+ * await task.toggleMute();
553
+ * }
554
+ *
555
+ * function handleHoldToggle() {
556
+ * if (task.data.isOnHold) {
557
+ * await task.resume();
558
+ * } else {
559
+ * await task.hold();
560
+ * }
561
+ * }
562
+ *
563
+ * async function handleTransfer() {
564
+ * // Get available queues for transfer
565
+ * const queues = await cc.getQueues();
566
+ *
567
+ * // Transfer to first available queue
568
+ * if (queues.length > 0) {
569
+ * await task.transfer({
570
+ * to: queues[0].queueId,
571
+ * destinationType: 'QUEUE'
572
+ * });
573
+ * }
574
+ * }
575
+ *
576
+ * } catch (error) {
577
+ * console.error('Outdial failed:', error);
578
+ * showErrorNotification('Failed to place call: ' + error.message);
579
+ * }
580
+ * ```
581
+ */
582
+ startOutdial(destination: string): Promise<TaskResponse>;
583
+ /**
584
+ * This is used for getting the list of queues to which a task can be consulted or transferred.
585
+ * @param {string} [search] - Optional search string to filter queues by name
586
+ * @param {string} [filter] - Optional OData filter expression (e.g., 'teamId eq "team123"')
587
+ * @param {number} [page=0] - Page number for paginated results, starting at 0
588
+ * @param {number} [pageSize=100] - Number of queues to return per page
589
+ * @returns Promise<ContactServiceQueue[]> Resolves with the list of queues
590
+ * @throws Error If the operation fails
591
+ * @public
592
+ * @example
593
+ * ```typescript
594
+ * const cc = webex.cc;
595
+ * await cc.register();
596
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
597
+ *
598
+ * // Basic usage - get all queues
599
+ * const allQueues = await cc.getQueues();
600
+ *
601
+ * // Search for specific queues
602
+ * const salesQueues = await cc.getQueues('sales'); // Search for 'sales' in queue names
603
+ *
604
+ * // Use filtering and pagination
605
+ * const filteredQueues = await cc.getQueues(
606
+ * '', // No search term
607
+ * 'teamId eq "team123"', // Filter by team
608
+ * 0, // First page
609
+ * 50 // 50 items per page
610
+ * );
611
+ *
612
+ * // Process queue results
613
+ * queues.forEach(queue => {
614
+ * console.log('Queue:', {
615
+ * id: queue.queueId,
616
+ * name: queue.queueName,
617
+ * channelType: queue.channelType,
618
+ * isActive: queue.isActive,
619
+ * description: queue.description
620
+ * });
621
+ * });
622
+ * ```
623
+ */
624
+ getQueues(search?: string, filter?: string, page?: number, pageSize?: number): Promise<ContactServiceQueue[]>;
625
+ /**
626
+ * Uploads logs to help troubleshoot SDK issues.
627
+ *
628
+ * This method collects the current SDK logs including network requests, WebSocket
629
+ * messages, and client-side events, then securely submits them to Webex's diagnostics
630
+ * service. The returned tracking ID, feedbackID can be provided to Webex support for faster
631
+ * issue resolution.
632
+ * @returns Promise<UploadLogsResponse> Resolves with the upload logs response
633
+ * @throws Error If the upload fails
634
+ * @public
635
+ * @example
636
+ * ```typescript
637
+ * const cc = webex.cc;
638
+ * try {
639
+ * await cc.register();
640
+ * } catch (error) {
641
+ * console.error('Error:', error);
642
+ * const result = await cc.uploadLogs();
643
+ * console.log('Logs uploaded. Tracking ID:', result.trackingId);
644
+ * }
645
+ * ```
646
+ */
647
+ uploadLogs(): Promise<UploadLogsResponse>;
648
+ /**
649
+ * Updates the agent device type and login configuration.
650
+ * Use this method to change how an agent connects to the contact center system (e.g., switching from browser-based calling to a desk phone extension).
651
+ *
652
+ * @param {AgentDeviceUpdate} data Configuration containing:
653
+ * - loginOption: New device type ('BROWSER', 'EXTENSION', 'AGENT_DN')
654
+ * - dialNumber: Required phone number when using EXTENSION or AGENT_DN
655
+ * - teamId: Optional team ID (defaults to current team if not specified)
656
+ * @returns Promise<UpdateDeviceTypeResponse> Resolves with the device type update response
657
+ * @throws Error If the update fails
658
+ * @example
659
+ * ```typescript
660
+ * const cc = webex.cc;
661
+ *
662
+ * // Switch from browser to extension
663
+ * try {
664
+ * await cc.updateAgentProfile({
665
+ * loginOption: 'EXTENSION',
666
+ * dialNumber: '1234', // Required for EXTENSION
667
+ * teamId: 'currentTeam' // Optional: uses current team if not specified
668
+ * });
669
+ * } catch (error) {
670
+ * console.error('Failed to update device:', error.message);
671
+ * }
672
+ * ```
673
+ * @public
674
+ */
675
+ updateAgentProfile(data: AgentProfileUpdate): Promise<UpdateDeviceTypeResponse>;
676
+ }