@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,429 @@
1
+ import {CC_EVENTS} from '../config/types';
2
+ import {createErrDetailsObject as err} from '../core/Utils';
3
+ import {WCC_API_GATEWAY} from '../constants';
4
+ import AqmReqs from '../core/aqm-reqs';
5
+ import {TIMEOUT_REQ} from '../core/constants';
6
+ import {
7
+ CONSULT,
8
+ CONSULT_ACCEPT,
9
+ CONSULT_END,
10
+ CONSULT_TRANSFER,
11
+ END,
12
+ HOLD,
13
+ PAUSE,
14
+ RESUME,
15
+ TASK_API,
16
+ TASK_MESSAGE_TYPE,
17
+ TRANSFER,
18
+ UNHOLD,
19
+ WRAPUP,
20
+ } from './constants';
21
+ import * as Contact from './types';
22
+ import {DESTINATION_TYPE} from './types';
23
+
24
+ export default function routingContact(aqm: AqmReqs) {
25
+ return {
26
+ /*
27
+ * Accept incoming task
28
+ */
29
+ accept: aqm.req((p: {interactionId: string}) => ({
30
+ url: `${TASK_API}${p.interactionId}/accept`,
31
+ host: WCC_API_GATEWAY,
32
+ data: {},
33
+ err,
34
+ notifSuccess: {
35
+ bind: {
36
+ type: TASK_MESSAGE_TYPE,
37
+ data: {type: CC_EVENTS.AGENT_CONTACT_ASSIGNED, interactionId: p.interactionId},
38
+ },
39
+ msg: {} as Contact.AgentContact,
40
+ },
41
+ notifFail: {
42
+ bind: {
43
+ type: TASK_MESSAGE_TYPE,
44
+ data: {type: CC_EVENTS.AGENT_CONTACT_ASSIGN_FAILED, interactionId: p.interactionId},
45
+ },
46
+ errId: 'Service.aqm.task.accept',
47
+ },
48
+ })),
49
+
50
+ /*
51
+ * Hold task
52
+ */
53
+ hold: aqm.req((p: {interactionId: string; data: Contact.HoldResumePayload}) => ({
54
+ url: `${TASK_API}${p.interactionId}${HOLD}`,
55
+ data: p.data,
56
+ host: WCC_API_GATEWAY,
57
+ err,
58
+ notifSuccess: {
59
+ bind: {
60
+ type: TASK_MESSAGE_TYPE,
61
+ data: {type: CC_EVENTS.AGENT_CONTACT_HELD, interactionId: p.interactionId},
62
+ },
63
+ msg: {} as Contact.AgentContact,
64
+ },
65
+ notifFail: {
66
+ bind: {
67
+ type: TASK_MESSAGE_TYPE,
68
+ data: {type: CC_EVENTS.AGENT_CONTACT_HOLD_FAILED},
69
+ },
70
+ errId: 'Service.aqm.task.hold',
71
+ },
72
+ })),
73
+
74
+ /*
75
+ * Unhold task
76
+ */
77
+ unHold: aqm.req((p: {interactionId: string; data: Contact.HoldResumePayload}) => ({
78
+ url: `${TASK_API}${p.interactionId}${UNHOLD}`,
79
+ data: p.data,
80
+ host: WCC_API_GATEWAY,
81
+ err,
82
+ notifSuccess: {
83
+ bind: {
84
+ type: TASK_MESSAGE_TYPE,
85
+ data: {type: CC_EVENTS.AGENT_CONTACT_UNHELD, interactionId: p.interactionId},
86
+ },
87
+ msg: {} as Contact.AgentContact,
88
+ },
89
+ notifFail: {
90
+ bind: {
91
+ type: TASK_MESSAGE_TYPE,
92
+ data: {type: CC_EVENTS.AGENT_CONTACT_UNHOLD_FAILED},
93
+ },
94
+ errId: 'Service.aqm.task.unHold',
95
+ },
96
+ })),
97
+
98
+ /*
99
+ * Pause Recording
100
+ */
101
+ pauseRecording: aqm.req((p: {interactionId: string}) => ({
102
+ url: `${TASK_API}${p.interactionId}${PAUSE}`,
103
+ data: {},
104
+ host: WCC_API_GATEWAY,
105
+ err,
106
+ notifSuccess: {
107
+ bind: {
108
+ type: TASK_MESSAGE_TYPE,
109
+ data: {type: CC_EVENTS.CONTACT_RECORDING_PAUSED, interactionId: p.interactionId},
110
+ },
111
+ msg: {} as Contact.AgentContact,
112
+ },
113
+ notifFail: {
114
+ bind: {
115
+ type: TASK_MESSAGE_TYPE,
116
+ data: {type: CC_EVENTS.CONTACT_RECORDING_PAUSE_FAILED},
117
+ },
118
+ errId: 'Service.aqm.task.pauseRecording',
119
+ },
120
+ })),
121
+
122
+ /*
123
+ * Resume Recording
124
+ */
125
+ resumeRecording: aqm.req(
126
+ (p: {interactionId: string; data: Contact.ResumeRecordingPayload}) => ({
127
+ url: `${TASK_API}${p.interactionId}${RESUME}`,
128
+ data: p.data,
129
+ host: WCC_API_GATEWAY,
130
+ err,
131
+ notifSuccess: {
132
+ bind: {
133
+ type: TASK_MESSAGE_TYPE,
134
+ data: {type: CC_EVENTS.CONTACT_RECORDING_RESUMED, interactionId: p.interactionId},
135
+ },
136
+ msg: {} as Contact.AgentContact,
137
+ },
138
+ notifFail: {
139
+ bind: {
140
+ type: TASK_MESSAGE_TYPE,
141
+ data: {type: CC_EVENTS.CONTACT_RECORDING_RESUME_FAILED},
142
+ },
143
+ errId: 'Service.aqm.task.resumeRecording',
144
+ },
145
+ })
146
+ ),
147
+
148
+ /*
149
+ * Consult contact
150
+ */
151
+ consult: aqm.req((p: {interactionId: string; data: Contact.ConsultPayload}) => ({
152
+ url: `${TASK_API}${p.interactionId}${CONSULT}`,
153
+ data: p.data,
154
+ timeout:
155
+ p.data && p.data.destinationType === DESTINATION_TYPE.QUEUE ? 'disabled' : TIMEOUT_REQ,
156
+ host: WCC_API_GATEWAY,
157
+ err,
158
+ notifSuccess: {
159
+ bind: {
160
+ type: TASK_MESSAGE_TYPE,
161
+ data: {type: CC_EVENTS.AGENT_CONSULT_CREATED, interactionId: p.interactionId},
162
+ },
163
+ msg: {} as Contact.AgentContact,
164
+ },
165
+ notifFail: {
166
+ bind: {
167
+ type: TASK_MESSAGE_TYPE,
168
+ data: {
169
+ type:
170
+ p.data && p.data.destinationType === DESTINATION_TYPE.QUEUE
171
+ ? CC_EVENTS.AGENT_CTQ_FAILED
172
+ : CC_EVENTS.AGENT_CONSULT_FAILED,
173
+ },
174
+ },
175
+ errId: 'Service.aqm.task.consult',
176
+ },
177
+ notifCancel: {
178
+ bind: {
179
+ type: TASK_MESSAGE_TYPE,
180
+ data: {type: 'AgentCtqCancelled', interactionId: p.interactionId},
181
+ },
182
+ msg: {} as Contact.AgentContact,
183
+ },
184
+ })),
185
+
186
+ /*
187
+ * Consult End
188
+ */
189
+ consultEnd: aqm.req((p: {interactionId: string; data: Contact.ConsultEndPayload}) => {
190
+ // Setting false value for optional attribute
191
+ const {isConsult, isSecondaryEpDnAgent = false, queueId} = p.data;
192
+
193
+ return {
194
+ url: `${TASK_API}${p.interactionId}${CONSULT_END}`,
195
+ host: WCC_API_GATEWAY,
196
+ data: queueId
197
+ ? {
198
+ queueId,
199
+ }
200
+ : {},
201
+ err,
202
+ notifSuccess: {
203
+ bind: {
204
+ type: 'RoutingMessage',
205
+ data: {
206
+ type: (() => {
207
+ if (queueId) return CC_EVENTS.AGENT_CTQ_CANCELLED;
208
+ if (isSecondaryEpDnAgent) return CC_EVENTS.CONTACT_ENDED;
209
+ if (isConsult) return CC_EVENTS.AGENT_CONSULT_ENDED;
210
+
211
+ return CC_EVENTS.AGENT_CONSULT_CONFERENCE_ENDED;
212
+ })(),
213
+ interactionId: p.interactionId,
214
+ },
215
+ },
216
+ msg: {} as Contact.AgentContact,
217
+ },
218
+ notifFail: {
219
+ bind: {
220
+ type: 'RoutingMessage',
221
+ data: {
222
+ type: p.data.queueId
223
+ ? CC_EVENTS.AGENT_CTQ_CANCEL_FAILED
224
+ : CC_EVENTS.AGENT_CONSULT_END_FAILED,
225
+ },
226
+ },
227
+ errId: p.data.queueId ? 'Service.aqm.task.cancelCtq' : 'Service.aqm.task.consultEnd',
228
+ },
229
+ };
230
+ }),
231
+
232
+ /*
233
+ * Consult Accept contact
234
+ */
235
+ consultAccept: aqm.req((p: {interactionId: string}) => ({
236
+ url: `${TASK_API}${p.interactionId}${CONSULT_ACCEPT}`,
237
+ data: {},
238
+ host: WCC_API_GATEWAY,
239
+ err,
240
+ notifSuccess: {
241
+ bind: {
242
+ type: TASK_MESSAGE_TYPE,
243
+ data: {type: CC_EVENTS.AGENT_CONSULTING, interactionId: p.interactionId},
244
+ },
245
+ msg: {} as Contact.AgentContact,
246
+ },
247
+ notifFail: {
248
+ bind: {
249
+ type: TASK_MESSAGE_TYPE,
250
+ data: {type: CC_EVENTS.AGENT_CONTACT_ASSIGN_FAILED},
251
+ },
252
+ errId: 'Service.aqm.task.consultAccept',
253
+ },
254
+ })),
255
+
256
+ /*
257
+ * BlindTransfer contact
258
+ */
259
+ blindTransfer: aqm.req((p: {interactionId: string; data: Contact.TransferPayLoad}) => ({
260
+ url: `${TASK_API}${p.interactionId}${TRANSFER}`,
261
+ data: p.data,
262
+ host: WCC_API_GATEWAY,
263
+ err,
264
+ notifSuccess: {
265
+ bind: {
266
+ type: TASK_MESSAGE_TYPE,
267
+ data: {type: CC_EVENTS.AGENT_BLIND_TRANSFERRED, interactionId: p.interactionId},
268
+ },
269
+ msg: {} as Contact.AgentContact,
270
+ },
271
+ notifFail: {
272
+ bind: {
273
+ type: TASK_MESSAGE_TYPE,
274
+ data: {type: CC_EVENTS.AGENT_BLIND_TRANSFER_FAILED},
275
+ },
276
+ errId: 'Service.aqm.task.AgentBlindTransferFailedEvent',
277
+ },
278
+ })),
279
+
280
+ /*
281
+ * VteamTransfer contact
282
+ */
283
+ vteamTransfer: aqm.req((p: {interactionId: string; data: Contact.TransferPayLoad}) => ({
284
+ url: `${TASK_API}${p.interactionId}${TRANSFER}`,
285
+ data: p.data,
286
+ host: WCC_API_GATEWAY,
287
+ err,
288
+ notifSuccess: {
289
+ bind: {
290
+ type: TASK_MESSAGE_TYPE,
291
+ data: {type: CC_EVENTS.AGENT_VTEAM_TRANSFERRED, interactionId: p.interactionId},
292
+ },
293
+ msg: {} as Contact.AgentContact,
294
+ },
295
+ notifFail: {
296
+ bind: {
297
+ type: TASK_MESSAGE_TYPE,
298
+ data: {type: CC_EVENTS.AGENT_VTEAM_TRANSFER_FAILED},
299
+ },
300
+ errId: 'Service.aqm.task.AgentVteamTransferFailed',
301
+ },
302
+ })),
303
+
304
+ /*
305
+ * Consult Transfer contact
306
+ */
307
+ consultTransfer: aqm.req(
308
+ (p: {interactionId: string; data: Contact.ConsultTransferPayLoad}) => ({
309
+ url: `${TASK_API}${p.interactionId}${CONSULT_TRANSFER}`,
310
+ data: p.data,
311
+ host: WCC_API_GATEWAY,
312
+ err,
313
+ notifSuccess: {
314
+ bind: {
315
+ type: TASK_MESSAGE_TYPE,
316
+ data: {
317
+ type: [CC_EVENTS.AGENT_CONSULT_TRANSFERRED, CC_EVENTS.AGENT_CONSULT_TRANSFERRING],
318
+ interactionId: p.interactionId,
319
+ },
320
+ },
321
+ msg: {} as Contact.AgentContact,
322
+ },
323
+ notifFail: {
324
+ bind: {
325
+ type: TASK_MESSAGE_TYPE,
326
+ data: {type: CC_EVENTS.AGENT_CONSULT_TRANSFER_FAILED},
327
+ },
328
+ errId: 'Service.aqm.task.AgentConsultTransferFailed',
329
+ },
330
+ })
331
+ ),
332
+
333
+ /*
334
+ * End contact
335
+ */
336
+ end: aqm.req((p: {interactionId: string}) => ({
337
+ url: `${TASK_API}${p.interactionId}${END}`,
338
+ data: {},
339
+ host: WCC_API_GATEWAY,
340
+ err,
341
+ notifSuccess: {
342
+ bind: {
343
+ type: TASK_MESSAGE_TYPE,
344
+ data: {type: CC_EVENTS.AGENT_WRAPUP, interactionId: p.interactionId},
345
+ },
346
+ msg: {} as Contact.AgentContact,
347
+ },
348
+ notifFail: {
349
+ bind: {
350
+ type: TASK_MESSAGE_TYPE,
351
+ data: {type: CC_EVENTS.AGENT_CONTACT_END_FAILED},
352
+ },
353
+ errId: 'Service.aqm.task.end',
354
+ },
355
+ })),
356
+
357
+ /*
358
+ * Wrapup contact
359
+ */
360
+ wrapup: aqm.req((p: {interactionId: string; data: Contact.WrapupPayLoad}) => ({
361
+ url: `${TASK_API}${p.interactionId}${WRAPUP}`,
362
+ data: p.data,
363
+ host: WCC_API_GATEWAY,
364
+ err,
365
+ notifSuccess: {
366
+ bind: {
367
+ type: TASK_MESSAGE_TYPE,
368
+ data: {type: CC_EVENTS.AGENT_WRAPPEDUP, interactionId: p.interactionId},
369
+ },
370
+ msg: {} as Contact.AgentContact,
371
+ },
372
+ notifFail: {
373
+ bind: {
374
+ type: TASK_MESSAGE_TYPE,
375
+ data: {type: CC_EVENTS.AGENT_WRAPUP_FAILED},
376
+ },
377
+ errId: 'Service.aqm.task.wrapup',
378
+ },
379
+ })),
380
+
381
+ /*
382
+ * Cancel popover
383
+ */
384
+ cancelTask: aqm.req((p: {interactionId: string}) => ({
385
+ url: `${TASK_API}${p.interactionId}${END}`,
386
+ data: {},
387
+ host: WCC_API_GATEWAY,
388
+ err,
389
+ notifSuccess: {
390
+ bind: {
391
+ type: TASK_MESSAGE_TYPE,
392
+ data: {type: CC_EVENTS.CONTACT_ENDED, interactionId: p.interactionId},
393
+ },
394
+ msg: {} as Contact.AgentContact,
395
+ },
396
+ notifFail: {
397
+ bind: {
398
+ type: TASK_MESSAGE_TYPE,
399
+ data: {type: CC_EVENTS.AGENT_CONTACT_END_FAILED},
400
+ },
401
+ errId: 'Service.aqm.task.end',
402
+ },
403
+ })),
404
+
405
+ /*
406
+ * Cancel Ctq request
407
+ */
408
+ cancelCtq: aqm.req((p: {interactionId: string; data: Contact.cancelCtq}) => ({
409
+ url: `${TASK_API}${p.interactionId}/cancelCtq`,
410
+ data: p.data,
411
+ host: WCC_API_GATEWAY,
412
+ err,
413
+ notifSuccess: {
414
+ bind: {
415
+ type: TASK_MESSAGE_TYPE,
416
+ data: {type: 'AgentCtqCancelled', interactionId: p.interactionId},
417
+ },
418
+ msg: {} as Contact.AgentContact,
419
+ },
420
+ notifFail: {
421
+ bind: {
422
+ type: TASK_MESSAGE_TYPE,
423
+ data: {type: 'AgentCtqCancelFailed'},
424
+ },
425
+ errId: 'Service.aqm.task.cancelCtq',
426
+ },
427
+ })),
428
+ };
429
+ }
@@ -0,0 +1,52 @@
1
+ import {CC_EVENTS} from '../config/types';
2
+ import {WCC_API_GATEWAY} from '../constants';
3
+ import {createErrDetailsObject as err} from '../core/Utils';
4
+ import {TASK_MESSAGE_TYPE, TASK_API} from './constants';
5
+ import * as Contact from './types';
6
+ import AqmReqs from '../core/aqm-reqs';
7
+
8
+ /**
9
+ * Returns an object with AQM dialer functions used for outbound contact handling.
10
+ *
11
+ * @param {AqmReqs} aqm - An instance of AQM request handler.
12
+ * @returns {{
13
+ * startOutdial: (params: {data: Contact.DialerPayload}) => Promise<any>
14
+ * }} Object containing methods for outbound dialing.
15
+ * @ignore
16
+ */
17
+ export default function aqmDialer(aqm: AqmReqs) {
18
+ return {
19
+ /**
20
+ * Initiates an outbound contact (outdial) request.
21
+ *
22
+ * @param {Object} p - Parameters object.
23
+ * @param {Contact.DialerPayload} p.data - Payload for the outbound call.
24
+ * @returns {Promise<any>} A promise that resolves or rejects based on the outbound call response.
25
+ *
26
+ * Emits:
27
+ * - `CC_EVENTS.AGENT_OFFER_CONTACT` on success
28
+ * - `CC_EVENTS.AGENT_OUTBOUND_FAILED` on failure
29
+ * @ignore
30
+ */
31
+ startOutdial: aqm.req((p: {data: Contact.DialerPayload}) => ({
32
+ url: `${TASK_API}`,
33
+ host: WCC_API_GATEWAY,
34
+ data: p.data,
35
+ err,
36
+ notifSuccess: {
37
+ bind: {
38
+ type: TASK_MESSAGE_TYPE,
39
+ data: {type: CC_EVENTS.AGENT_OFFER_CONTACT},
40
+ },
41
+ msg: {} as Contact.AgentContact,
42
+ },
43
+ notifFail: {
44
+ bind: {
45
+ type: TASK_MESSAGE_TYPE,
46
+ data: {type: CC_EVENTS.AGENT_OUTBOUND_FAILED},
47
+ },
48
+ errId: 'Service.aqm.dialer.startOutdial',
49
+ },
50
+ })),
51
+ };
52
+ }