@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,569 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ import { CallId } from '@webex/calling/dist/types/common/types';
4
+ import routingContact from './contact';
5
+ import { ITask, TaskResponse, TaskData, TaskId, WrapupPayLoad, ResumeRecordingPayload, ConsultPayload, ConsultEndPayload, TransferPayLoad, ConsultTransferPayLoad } from './types';
6
+ import WebCallingService from '../WebCallingService';
7
+ import AutoWrapup from './AutoWrapup';
8
+ import { WrapupData } from '../config/types';
9
+ /**
10
+ * Task class represents a contact center task/interaction that can be managed by an agent.
11
+ * This class provides all the necessary methods to manage tasks in a contact center environment,
12
+ * handling various call control operations and task lifecycle management.
13
+ *
14
+ * - Task Lifecycle Management:
15
+ * - {@link accept} - Accept incoming task
16
+ * - {@link decline} - Decline incoming task
17
+ * - {@link end} - End active task
18
+ * - Media Controls:
19
+ * - {@link toggleMute} - Mute/unmute microphone for voice tasks
20
+ * - {@link hold} - Place task on hold
21
+ * - {@link resume} - Resume held task
22
+ * - Recording Controls:
23
+ * - {@link pauseRecording} - Pause task recording
24
+ * - {@link resumeRecording} - Resume paused recording
25
+ * - Task Transfer & Consultation:
26
+ * - {@link consult} - Initiate consultation with another agent/queue
27
+ * - {@link endConsult} - End ongoing consultation
28
+ * - {@link transfer} - Transfer task to another agent/queue
29
+ * - {@link consultTransfer} - Transfer after consultation
30
+ * - Task Completion:
31
+ * - {@link wrapup} - Complete task wrap-up
32
+ *
33
+ * Key events emitted by Task instances (see {@link TASK_EVENTS} for details):
34
+ *
35
+ * - Task Lifecycle:
36
+ * - task:incoming — New task is being offered
37
+ * - task:assigned — Task assigned to agent
38
+ * - task:unassigned — Task unassigned from agent
39
+ * - task:end — Task has ended
40
+ * - task:wrapup — Task entered wrap-up state
41
+ * - task:wrappedup — Task wrap-up completed
42
+ * - task:rejected — Task was rejected/unanswered
43
+ * - task:hydrate — Task data populated
44
+ *
45
+ * - Media & Controls:
46
+ * - task:media — Voice call media track received
47
+ * - task:hold — Task placed on hold
48
+ * - task:unhold — Task resumed from hold
49
+ *
50
+ * - Consultation & Transfer:
51
+ * - task:consultCreated — Consultation initiated
52
+ * - task:consulting — Consultation in progress
53
+ * - task:consultAccepted — Consultation accepted
54
+ * - task:consultEnd — Consultation ended
55
+ * - task:consultQueueCancelled — Queue consultation cancelled
56
+ * - task:consultQueueFailed — Queue consultation failed
57
+ * - task:offerConsult — Consultation offered
58
+ * - task:offerContact — New contact offered
59
+ *
60
+ * - Recording:
61
+ * - task:recordingPaused — Recording paused
62
+ * - task:recordingPauseFailed — Recording pause failed
63
+ * - task:recordingResumed — Recording resumed
64
+ * - task:recordingResumeFailed — Recording resume failed
65
+ *
66
+ * @implements {ITask}
67
+ * @example
68
+ * ```typescript
69
+ * // 1. Initialize task
70
+ * const task = new Task(contact, webCallingService, taskData);
71
+ *
72
+ * // 2. Set up event listeners
73
+ * task.on('task:media', (track) => {
74
+ * // Handle voice call media
75
+ * const audioElement = document.getElementById('remote-audio');
76
+ * audioElement.srcObject = new MediaStream([track]);
77
+ * });
78
+ *
79
+ * task.on('task:hold', () => {
80
+ * console.log('Task is on hold');
81
+ * // Update UI to show hold state
82
+ * });
83
+ *
84
+ * task.on('task:end', () => {
85
+ * console.log('Task ended');
86
+ * if (task.data.wrapUpRequired) {
87
+ * // Show wrap-up form
88
+ * }
89
+ * });
90
+ *
91
+ * // 3. Example task operations
92
+ * await task.accept(); // Accept incoming task
93
+ * await task.hold(); // Place on hold
94
+ * await task.resume(); // Resume from hold
95
+ * await task.end(); // End task
96
+ *
97
+ * // 4. Handle wrap-up if required
98
+ * await task.wrapup({
99
+ * auxCodeId: 'RESOLVED',
100
+ * wrapUpReason: 'Customer issue resolved'
101
+ * });
102
+ * ```
103
+ */
104
+ export default class Task extends EventEmitter implements ITask {
105
+ private contact;
106
+ private localAudioStream;
107
+ private webCallingService;
108
+ data: TaskData;
109
+ private metricsManager;
110
+ webCallMap: Record<TaskId, CallId>;
111
+ private wrapupData;
112
+ autoWrapup?: AutoWrapup;
113
+ /**
114
+ * Creates a new Task instance which provides the following features:
115
+ * @param contact - The routing contact service instance
116
+ * @param webCallingService - The web calling service instance
117
+ * @param data - Initial task data
118
+ * @param wrapupData - Wrap-up configuration data
119
+ */
120
+ constructor(contact: ReturnType<typeof routingContact>, webCallingService: WebCallingService, data: TaskData, wrapupData: WrapupData);
121
+ /**
122
+ * Sets up the automatic wrap-up timer if wrap-up is required
123
+ * @private
124
+ */
125
+ private setupAutoWrapupTimer;
126
+ /**
127
+ * Cancels the automatic wrap-up timer if it's running
128
+ * @public - Public so it can be called externally when needed
129
+ * Note: This is supported only in single session mode. Not supported in multi-session mode.
130
+ */
131
+ cancelAutoWrapupTimer(): void;
132
+ /**
133
+ * @ignore
134
+ * @private
135
+ */
136
+ private handleRemoteMedia;
137
+ /**
138
+ * @ignore
139
+ * @private
140
+ */
141
+ private registerWebCallListeners;
142
+ /**
143
+ * @ignore
144
+ */
145
+ unregisterWebCallListeners(): void;
146
+ /**
147
+ * Updates the task data with new information
148
+ * @param updatedData - New task data to merge with existing data
149
+ * @param shouldOverwrite - If true, completely replace data instead of merging
150
+ * @returns The updated task instance
151
+ * @example
152
+ * ```typescript
153
+ * task.updateTaskData(newData);
154
+ * task.updateTaskData(newData, true); // completely replace data
155
+ * ```
156
+ */
157
+ updateTaskData: (updatedData: TaskData, shouldOverwrite?: boolean) => this;
158
+ /**
159
+ * Recursively merges old data with new data
160
+ * @private
161
+ */
162
+ private reconcileData;
163
+ /**
164
+ * Agent accepts the incoming task.
165
+ * After accepting, the task will emit task:assigned event and for voice calls,
166
+ * a task:media event with the audio stream.
167
+ *
168
+ * @returns Promise<TaskResponse>
169
+ * @throws Error if accepting task fails or media requirements not met
170
+ * @example
171
+ * ```typescript
172
+ * // Set up event handlers before accepting
173
+ * task.on(TASK_EVENTS.TASK_ASSIGNED, () => {
174
+ * console.log('Task assigned, ID:', task.data.interactionId);
175
+ * // Update UI to show active task
176
+ * });
177
+ *
178
+ * // For voice calls, handle media
179
+ * task.on(TASK_EVENTS.TASK_MEDIA, (track) => {
180
+ * const audioElement = document.getElementById('remote-audio');
181
+ * audioElement.srcObject = new MediaStream([track]);
182
+ * });
183
+ *
184
+ * // Accept the task
185
+ * try {
186
+ * await task.accept();
187
+ * console.log('Successfully accepted task');
188
+ * } catch (error) {
189
+ * console.error('Failed to accept task:', error);
190
+ * // Handle error (e.g., show error message to agent)
191
+ * }
192
+ * ```
193
+ */
194
+ accept(): Promise<TaskResponse>;
195
+ /**
196
+ * Agent can mute/unmute their microphone during a WebRTC task.
197
+ * This method toggles between muted and unmuted states for the local audio stream.
198
+ *
199
+ * @returns Promise<void> - Resolves when mute/unmute operation completes
200
+ * @throws Error if toggling mute state fails or audio stream is not available
201
+ * @example
202
+ * ```typescript
203
+ * // Toggle mute state
204
+ * task.toggleMute()
205
+ * .then(() => console.log('Mute state toggled successfully'))
206
+ * .catch(error => console.error('Failed to toggle mute:', error));
207
+ * ```
208
+ */
209
+ toggleMute(): Promise<void>;
210
+ /**
211
+ * Declines the incoming task. This will reject the task and notify the routing system.
212
+ * For voice calls, this is equivalent to declining the incoming call.
213
+ *
214
+ * @returns Promise<TaskResponse>
215
+ * @throws Error if the decline operation fails
216
+ * @example
217
+ * ```typescript
218
+ * // Decline an incoming task
219
+ * task.decline()
220
+ * .then(() => console.log('Task declined successfully'))
221
+ * .catch(error => console.error('Failed to decline task:', error));
222
+ * ```
223
+ */
224
+ decline(): Promise<TaskResponse>;
225
+ /**
226
+ * Puts the current task/interaction on hold.
227
+ * Emits task:hold event when successful. For voice tasks, this mutes the audio.
228
+ *
229
+ * @returns Promise<TaskResponse>
230
+ * @throws Error if hold operation fails
231
+ * @example
232
+ * ```typescript
233
+ * // Set up hold event handler
234
+ * task.on(TASK_EVENTS.TASK_HOLD, () => {
235
+ * console.log('Task is now on hold');
236
+ * // Update UI to show hold state (e.g., enable resume button, show hold indicator)
237
+ * document.getElementById('resume-btn').disabled = false;
238
+ * document.getElementById('hold-indicator').style.display = 'block';
239
+ * });
240
+ *
241
+ * // Place task on hold
242
+ * try {
243
+ * await task.hold();
244
+ * console.log('Successfully placed task on hold');
245
+ * } catch (error) {
246
+ * console.error('Failed to place task on hold:', error);
247
+ * // Handle error (e.g., show error message, reset UI state)
248
+ * }
249
+ * ```
250
+ */
251
+ hold(): Promise<TaskResponse>;
252
+ /**
253
+ * Resumes the task/interaction that was previously put on hold.
254
+ * Emits task:resume event when successful. For voice tasks, this restores the audio.
255
+ *
256
+ * @returns Promise<TaskResponse>
257
+ * @throws Error if resume operation fails
258
+ * @example
259
+ * ```typescript
260
+ * // Set up resume event handler
261
+ * task.on(TASK_EVENTS.TASK_RESUME, () => {
262
+ * console.log('Task resumed from hold');
263
+ * // Update UI to show active state
264
+ * document.getElementById('hold-btn').disabled = false;
265
+ * document.getElementById('hold-indicator').style.display = 'none';
266
+ * });
267
+ *
268
+ * // Resume task from hold
269
+ * try {
270
+ * await task.resume();
271
+ * console.log('Successfully resumed task from hold');
272
+ * } catch (error) {
273
+ * console.error('Failed to resume task:', error);
274
+ * // Handle error (e.g., show error message)
275
+ * }
276
+ * ```
277
+ */
278
+ resume(): Promise<TaskResponse>;
279
+ /**
280
+ * Ends the task/interaction with the customer.
281
+ * Emits task:end event when successful. If task requires wrap-up,
282
+ * this will be indicated in the task:end event data.
283
+ *
284
+ * @returns Promise<TaskResponse>
285
+ * @throws Error if ending task fails
286
+ * @example
287
+ * ```typescript
288
+ * // Set up task end event handler
289
+ * task.on(TASK_EVENTS.TASK_END, (data) => {
290
+ * console.log('Task ended:', task.data.interactionId);
291
+ *
292
+ * if (data.wrapUpRequired) {
293
+ * // Show wrap-up form
294
+ * showWrapupForm();
295
+ * } else {
296
+ * // Clean up and prepare for next task
297
+ * cleanupTask();
298
+ * }
299
+ * });
300
+ *
301
+ * // End the task
302
+ * try {
303
+ * await task.end();
304
+ * console.log('Task end request successful');
305
+ * } catch (error) {
306
+ * console.error('Failed to end task:', error);
307
+ * // Handle error (e.g., show error message, retry option)
308
+ * }
309
+ *
310
+ * function showWrapupForm() {
311
+ * // Show wrap-up UI with required codes
312
+ * document.getElementById('wrapup-form').style.display = 'block';
313
+ * }
314
+ *
315
+ * function cleanupTask() {
316
+ * // Reset UI state
317
+ * document.getElementById('active-task').style.display = 'none';
318
+ * document.getElementById('controls').style.display = 'none';
319
+ * }
320
+ * ```
321
+ */
322
+ end(): Promise<TaskResponse>;
323
+ /**
324
+ * Wraps up the task/interaction with the customer.
325
+ * This is called after task:end event if wrapUpRequired is true.
326
+ * Emits task:wrappedup event when successful.
327
+ *
328
+ * @param wrapupPayload - WrapupPayLoad containing:
329
+ * - auxCodeId: Required ID for the wrap-up code
330
+ * - wrapUpReason: Required description of wrap-up reason
331
+ * @returns Promise<TaskResponse>
332
+ * @throws Error if task data is unavailable, auxCodeId is missing, or wrapUpReason is missing
333
+ * @example
334
+ * ```typescript
335
+ * // Set up wrap-up events
336
+ * task.on(TASK_EVENTS.TASK_WRAPUP, () => {
337
+ * console.log('Task ready for wrap-up');
338
+ * // Show wrap-up form
339
+ * document.getElementById('wrapup-form').style.display = 'block';
340
+ * });
341
+ *
342
+ * task.on(TASK_EVENTS.TASK_WRAPPEDUP, () => {
343
+ * console.log('Task wrap-up completed');
344
+ * // Clean up UI
345
+ * document.getElementById('wrapup-form').style.display = 'none';
346
+ * });
347
+ *
348
+ * // Submit wrap-up
349
+ * try {
350
+ * const wrapupPayload = {
351
+ * auxCodeId: selectedCode, // e.g., 'ISSUE_RESOLVED'
352
+ * wrapUpReason: 'Customer issue resolved successfully'
353
+ * };
354
+ * await task.wrapup(wrapupPayload);
355
+ * console.log('Successfully submitted wrap-up');
356
+ * } catch (error) {
357
+ * console.error('Failed to submit wrap-up:', error);
358
+ * // Handle validation errors
359
+ * if (error.message.includes('required')) {
360
+ * // Show validation error to agent
361
+ * }
362
+ * }
363
+ * ```
364
+ */
365
+ wrapup(wrapupPayload: WrapupPayLoad): Promise<TaskResponse>;
366
+ /**
367
+ * Pauses the recording for the current voice task.
368
+ * Emits task:recordingPaused event when successful.
369
+ *
370
+ * @returns Promise<TaskResponse>
371
+ * @throws Error if pause recording fails
372
+ * @example
373
+ * ```typescript
374
+ * // Set up recording events
375
+ * task.on(TASK_EVENTS.TASK_RECORDING_PAUSED, () => {
376
+ * console.log('Recording paused');
377
+ * // Update UI to show recording paused state
378
+ * document.getElementById('recording-status').textContent = 'Recording Paused';
379
+ * document.getElementById('pause-recording-btn').style.display = 'none';
380
+ * document.getElementById('resume-recording-btn').style.display = 'block';
381
+ * });
382
+ *
383
+ * task.on(TASK_EVENTS.TASK_RECORDING_PAUSE_FAILED, (error) => {
384
+ * console.error('Failed to pause recording:', error);
385
+ * // Show error to agent
386
+ * });
387
+ *
388
+ * // Pause recording
389
+ * try {
390
+ * await task.pauseRecording();
391
+ * console.log('Pause recording request sent');
392
+ * } catch (error) {
393
+ * console.error('Error sending pause recording request:', error);
394
+ * // Handle error
395
+ * }
396
+ * ```
397
+ */
398
+ pauseRecording(): Promise<TaskResponse>;
399
+ /**
400
+ * Resumes the recording for the voice task that was previously paused.
401
+ * Emits task:recordingResumed event when successful.
402
+ *
403
+ * @param resumeRecordingPayload - Configuration for resuming recording:
404
+ * - autoResumed: Indicates if resume was automatic (defaults to false)
405
+ * @returns Promise<TaskResponse>
406
+ * @throws Error if resume recording fails
407
+ * @example
408
+ * ```typescript
409
+ * // Set up recording resume events
410
+ * task.on(TASK_EVENTS.TASK_RECORDING_RESUMED, () => {
411
+ * console.log('Recording resumed');
412
+ * // Update UI to show active recording state
413
+ * document.getElementById('recording-status').textContent = 'Recording Active';
414
+ * document.getElementById('pause-recording-btn').style.display = 'block';
415
+ * document.getElementById('resume-recording-btn').style.display = 'none';
416
+ * });
417
+ *
418
+ * task.on(TASK_EVENTS.TASK_RECORDING_RESUME_FAILED, (error) => {
419
+ * console.error('Failed to resume recording:', error);
420
+ * // Show error to agent
421
+ * });
422
+ *
423
+ * // Resume recording
424
+ * try {
425
+ * const resumePayload = {
426
+ * autoResumed: false // Set to true if triggered by system
427
+ * };
428
+ * await task.resumeRecording(resumePayload);
429
+ * console.log('Resume recording request sent');
430
+ * } catch (error) {
431
+ * console.error('Error sending resume recording request:', error);
432
+ * // Handle error
433
+ * }
434
+ * ```
435
+ */
436
+ resumeRecording(resumeRecordingPayload: ResumeRecordingPayload): Promise<TaskResponse>;
437
+ /**
438
+ * Consults another agent or queue on an ongoing task for further assistance.
439
+ * During consultation, the original customer is typically placed on hold while
440
+ * the agent seeks guidance from another agent or queue.
441
+ *
442
+ * @param consultPayload - Configuration for the consultation containing:
443
+ * - to: ID of the agent or queue to consult with
444
+ * - destinationType: Type of destination (AGENT, QUEUE, etc.)
445
+ * - holdParticipants: Whether to hold other participants (defaults to true)
446
+ * @returns Promise<TaskResponse> - Resolves with consultation result
447
+ * @throws Error if consultation fails or invalid parameters provided
448
+ * @example
449
+ * ```typescript
450
+ * // Consult with another agent
451
+ * const consultPayload = {
452
+ * to: 'agentId123',
453
+ * destinationType: DESTINATION_TYPE.AGENT,
454
+ * holdParticipants: true
455
+ * };
456
+ * task.consult(consultPayload)
457
+ * .then(response => console.log('Consultation started successfully'))
458
+ * .catch(error => console.error('Failed to start consultation:', error));
459
+ *
460
+ * // Consult with a queue
461
+ * const queueConsultPayload = {
462
+ * to: 'salesQueue123',
463
+ * destinationType: DESTINATION_TYPE.QUEUE
464
+ * };
465
+ * task.consult(queueConsultPayload)
466
+ * .then(response => console.log('Queue consultation started'))
467
+ * .catch(error => console.error('Failed to start queue consultation:', error));
468
+ * ```
469
+ */
470
+ consult(consultPayload: ConsultPayload): Promise<TaskResponse>;
471
+ /**
472
+ * Ends an ongoing consultation session for the task.
473
+ * This terminates the consultation while maintaining the original customer connection.
474
+ *
475
+ * @param consultEndPayload - Configuration for ending the consultation containing:
476
+ * - isConsult: Must be true to indicate this is a consultation end
477
+ * - taskId: ID of the task being consulted on
478
+ * - queueId: (Optional) Queue ID if this was a queue consultation
479
+ * - isSecondaryEpDnAgent: (Optional) Indicates if this involves a secondary entry point
480
+ * @returns Promise<TaskResponse> - Resolves when consultation is ended
481
+ * @throws Error if ending consultation fails or invalid parameters provided
482
+ * @example
483
+ * ```typescript
484
+ * // End a direct agent consultation
485
+ * const consultEndPayload = {
486
+ * isConsult: true,
487
+ * taskId: 'task123'
488
+ * };
489
+ * task.endConsult(consultEndPayload)
490
+ * .then(response => console.log('Consultation ended successfully'))
491
+ * .catch(error => console.error('Failed to end consultation:', error));
492
+ *
493
+ * // End a queue consultation
494
+ * const queueConsultEndPayload = {
495
+ * isConsult: true,
496
+ * taskId: 'task123',
497
+ * queueId: 'queue123'
498
+ * };
499
+ * task.endConsult(queueConsultEndPayload)
500
+ * .then(response => console.log('Queue consultation ended'))
501
+ * .catch(error => console.error('Failed to end queue consultation:', error));
502
+ * ```
503
+ */
504
+ endConsult(consultEndPayload: ConsultEndPayload): Promise<TaskResponse>;
505
+ /**
506
+ * Transfer the task to an agent directly or to a queue.
507
+ * This is a blind transfer that immediately redirects the task to the specified destination.
508
+ *
509
+ * @param transferPayload - Transfer configuration containing:
510
+ * - to: ID of the agent or queue to transfer to
511
+ * - destinationType: Type of destination (AGENT, QUEUE, etc.)
512
+ * @returns Promise<TaskResponse> - Resolves when transfer is completed
513
+ * @throws Error if transfer fails or invalid parameters provided
514
+ * @example
515
+ * ```typescript
516
+ * // Transfer to a queue
517
+ * const queueTransferPayload = {
518
+ * to: 'salesQueue123',
519
+ * destinationType: DESTINATION_TYPE.QUEUE
520
+ * };
521
+ * task.transfer(queueTransferPayload)
522
+ * .then(response => console.log('Task transferred to queue successfully'))
523
+ * .catch(error => console.error('Failed to transfer to queue:', error));
524
+ *
525
+ * // Transfer to an agent
526
+ * const agentTransferPayload = {
527
+ * to: 'agentId123',
528
+ * destinationType: DESTINATION_TYPE.AGENT
529
+ * };
530
+ * task.transfer(agentTransferPayload)
531
+ * .then(response => console.log('Task transferred to agent successfully'))
532
+ * .catch(error => console.error('Failed to transfer to agent:', error));
533
+ * ```
534
+ */
535
+ transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
536
+ /**
537
+ * Transfer the task to the party that was consulted.
538
+ * This completes a consultative transfer where the agent first consulted with the target
539
+ * before transferring the task. For queue consultations, the transfer is automatically
540
+ * directed to the agent who accepted the consultation.
541
+ *
542
+ * @param consultTransferPayload - Configuration for the consultation transfer containing:
543
+ * - to: ID of the agent or queue to transfer to
544
+ * - destinationType: Type of destination (AGENT, QUEUE, etc. from CONSULT_TRANSFER_DESTINATION_TYPE)
545
+ * @returns Promise<TaskResponse> - Resolves when consultation transfer is completed
546
+ * @throws Error if transfer fails, no agent has accepted a queue consultation, or other validation errors
547
+ * @example
548
+ * ```typescript
549
+ * // Complete consultation transfer to an agent
550
+ * const agentConsultTransfer = {
551
+ * to: 'agentId123',
552
+ * destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT
553
+ * };
554
+ * task.consultTransfer(agentConsultTransfer)
555
+ * .then(response => console.log('Consultation transfer to agent completed'))
556
+ * .catch(error => console.error('Failed to complete agent consultation transfer:', error));
557
+ *
558
+ * // Complete consultation transfer to a queue agent
559
+ * const queueConsultTransfer = {
560
+ * to: 'queue123',
561
+ * destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE
562
+ * };
563
+ * task.consultTransfer(queueConsultTransfer)
564
+ * .then(response => console.log('Consultation transfer to queue agent completed'))
565
+ * .catch(error => console.error('Failed to complete queue consultation transfer:', error));
566
+ * ```
567
+ */
568
+ consultTransfer(consultTransferPayload: ConsultTransferPayLoad): Promise<TaskResponse>;
569
+ }