@webex/contact-center 3.12.0 → 3.13.0

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 (337) hide show
  1. package/.sdd/manifest.json +887 -0
  2. package/AGENTS.md +94 -0
  3. package/ai-docs/ARCHITECTURE.md +168 -0
  4. package/ai-docs/CONTRACTS.md +62 -0
  5. package/ai-docs/GETTING_STARTED.md +168 -0
  6. package/ai-docs/GLOSSARY.md +43 -0
  7. package/ai-docs/README.md +138 -0
  8. package/ai-docs/REVIEW_CHECKLIST.md +41 -0
  9. package/ai-docs/RULES.md +444 -0
  10. package/ai-docs/SECURITY.md +52 -0
  11. package/ai-docs/SERVICE_STATE.md +52 -0
  12. package/ai-docs/SPEC_INDEX.md +65 -0
  13. package/ai-docs/adr/0001-spec-source-policy.md +55 -0
  14. package/ai-docs/adr/README.md +8 -0
  15. package/ai-docs/adr/_adr-template.md +31 -0
  16. package/ai-docs/contact-center-spec.md +385 -0
  17. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  18. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  19. package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
  20. package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
  21. package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
  22. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  23. package/ai-docs/patterns/testing-patterns.md +480 -0
  24. package/ai-docs/patterns/typescript-patterns.md +365 -0
  25. package/ai-docs/templates/README.md +102 -0
  26. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  27. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  28. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  29. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  30. package/ai-docs/templates/new-method/00-master.md +80 -0
  31. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  32. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  33. package/ai-docs/templates/new-method/03-tests.md +201 -0
  34. package/ai-docs/templates/new-method/04-validation.md +141 -0
  35. package/ai-docs/templates/new-service/00-master.md +109 -0
  36. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  37. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  38. package/ai-docs/templates/new-service/03-integration.md +178 -0
  39. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  40. package/ai-docs/templates/new-service/05-validation.md +145 -0
  41. package/dist/cc.js +1045 -45
  42. package/dist/cc.js.map +1 -1
  43. package/dist/config.js +13 -0
  44. package/dist/config.js.map +1 -1
  45. package/dist/constants.js +40 -3
  46. package/dist/constants.js.map +1 -1
  47. package/dist/index.js +54 -17
  48. package/dist/index.js.map +1 -1
  49. package/dist/metrics/MetricsManager.js +16 -0
  50. package/dist/metrics/MetricsManager.js.map +1 -1
  51. package/dist/metrics/behavioral-events.js +211 -0
  52. package/dist/metrics/behavioral-events.js.map +1 -1
  53. package/dist/metrics/constants.js +58 -4
  54. package/dist/metrics/constants.js.map +1 -1
  55. package/dist/services/AddressBook.js +18 -15
  56. package/dist/services/AddressBook.js.map +1 -1
  57. package/dist/services/AnswerCallOnWebexService.js +202 -0
  58. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  59. package/dist/services/ApiAiAssistant.js +369 -14
  60. package/dist/services/ApiAiAssistant.js.map +1 -1
  61. package/dist/services/EntryPoint.js +46 -68
  62. package/dist/services/EntryPoint.js.map +1 -1
  63. package/dist/services/Queue.js +27 -22
  64. package/dist/services/Queue.js.map +1 -1
  65. package/dist/services/UserPreference.js +427 -0
  66. package/dist/services/UserPreference.js.map +1 -0
  67. package/dist/services/WebCallingService.js +10 -2
  68. package/dist/services/WebCallingService.js.map +1 -1
  69. package/dist/services/WebexCrossClientService.js +225 -0
  70. package/dist/services/WebexCrossClientService.js.map +1 -0
  71. package/dist/services/WxAppTelephonyMercurySync.js +111 -0
  72. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  73. package/dist/services/config/Util.js +48 -48
  74. package/dist/services/config/Util.js.map +1 -1
  75. package/dist/services/config/constants.js +57 -79
  76. package/dist/services/config/constants.js.map +1 -1
  77. package/dist/services/config/index.js +100 -226
  78. package/dist/services/config/index.js.map +1 -1
  79. package/dist/services/config/types.js +97 -24
  80. package/dist/services/config/types.js.map +1 -1
  81. package/dist/services/constants.js +19 -1
  82. package/dist/services/constants.js.map +1 -1
  83. package/dist/services/core/Err.js.map +1 -1
  84. package/dist/services/core/Utils.js +131 -32
  85. package/dist/services/core/Utils.js.map +1 -1
  86. package/dist/services/core/WebexRequest.js +6 -2
  87. package/dist/services/core/WebexRequest.js.map +1 -1
  88. package/dist/services/core/aqm-reqs.js +17 -11
  89. package/dist/services/core/aqm-reqs.js.map +1 -1
  90. package/dist/services/core/constants.js +9 -1
  91. package/dist/services/core/constants.js.map +1 -1
  92. package/dist/services/core/types.js.map +1 -1
  93. package/dist/services/core/websocket/WebSocketManager.js +26 -6
  94. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  95. package/dist/services/core/websocket/connection-service.js +3 -1
  96. package/dist/services/core/websocket/connection-service.js.map +1 -1
  97. package/dist/services/core/websocket/types.js.map +1 -1
  98. package/dist/services/index.js +6 -0
  99. package/dist/services/index.js.map +1 -1
  100. package/dist/services/task/Task.js +955 -0
  101. package/dist/services/task/Task.js.map +1 -0
  102. package/dist/services/task/TaskFactory.js +50 -0
  103. package/dist/services/task/TaskFactory.js.map +1 -0
  104. package/dist/services/task/TaskManager.js +1275 -504
  105. package/dist/services/task/TaskManager.js.map +1 -1
  106. package/dist/services/task/TaskUtils.js +221 -27
  107. package/dist/services/task/TaskUtils.js.map +1 -1
  108. package/dist/services/task/WebexCallingUtils.js +70 -0
  109. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  110. package/dist/services/task/constants.js +22 -2
  111. package/dist/services/task/constants.js.map +1 -1
  112. package/dist/services/task/contact.js +29 -0
  113. package/dist/services/task/contact.js.map +1 -1
  114. package/dist/services/task/dialer.js +78 -0
  115. package/dist/services/task/dialer.js.map +1 -1
  116. package/dist/services/task/digital/Digital.js +78 -0
  117. package/dist/services/task/digital/Digital.js.map +1 -0
  118. package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
  119. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  120. package/dist/services/task/state-machine/actions.js +572 -0
  121. package/dist/services/task/state-machine/actions.js.map +1 -0
  122. package/dist/services/task/state-machine/constants.js +161 -0
  123. package/dist/services/task/state-machine/constants.js.map +1 -0
  124. package/dist/services/task/state-machine/guards.js +379 -0
  125. package/dist/services/task/state-machine/guards.js.map +1 -0
  126. package/dist/services/task/state-machine/index.js +53 -0
  127. package/dist/services/task/state-machine/index.js.map +1 -0
  128. package/dist/services/task/state-machine/types.js +54 -0
  129. package/dist/services/task/state-machine/types.js.map +1 -0
  130. package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
  131. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  132. package/dist/services/task/taskDataNormalizer.js +99 -0
  133. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  134. package/dist/services/task/types.js +259 -5
  135. package/dist/services/task/types.js.map +1 -1
  136. package/dist/services/task/voice/Voice.js +1504 -0
  137. package/dist/services/task/voice/Voice.js.map +1 -0
  138. package/dist/services/task/voice/WebRTC.js +152 -0
  139. package/dist/services/task/voice/WebRTC.js.map +1 -0
  140. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  141. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  142. package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
  143. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  144. package/dist/services/wxAppDiagnosticLogging.js +159 -0
  145. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  146. package/dist/services/wxAppTelephonyUtils.js +19 -0
  147. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  148. package/dist/types/cc.d.ts +197 -9
  149. package/dist/types/config.d.ts +13 -0
  150. package/dist/types/constants.d.ts +38 -1
  151. package/dist/types/index.d.ts +54 -20
  152. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  153. package/dist/types/metrics/constants.d.ts +52 -1
  154. package/dist/types/services/AddressBook.d.ts +2 -1
  155. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  156. package/dist/types/services/ApiAiAssistant.d.ts +67 -5
  157. package/dist/types/services/EntryPoint.d.ts +7 -5
  158. package/dist/types/services/Queue.d.ts +5 -3
  159. package/dist/types/services/UserPreference.d.ts +118 -0
  160. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  161. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  162. package/dist/types/services/config/Util.d.ts +4 -8
  163. package/dist/types/services/config/constants.d.ts +49 -76
  164. package/dist/types/services/config/index.d.ts +16 -64
  165. package/dist/types/services/config/types.d.ts +248 -114
  166. package/dist/types/services/constants.d.ts +16 -0
  167. package/dist/types/services/core/Err.d.ts +6 -0
  168. package/dist/types/services/core/Utils.d.ts +43 -13
  169. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  170. package/dist/types/services/core/constants.d.ts +7 -0
  171. package/dist/types/services/core/types.d.ts +2 -0
  172. package/dist/types/services/core/websocket/WebSocketManager.d.ts +2 -0
  173. package/dist/types/services/core/websocket/types.d.ts +1 -1
  174. package/dist/types/services/index.d.ts +2 -0
  175. package/dist/types/services/task/Task.d.ts +186 -0
  176. package/dist/types/services/task/TaskFactory.d.ts +14 -0
  177. package/dist/types/services/task/TaskUtils.d.ts +54 -2
  178. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  179. package/dist/types/services/task/constants.d.ts +20 -0
  180. package/dist/types/services/task/contact.d.ts +4 -0
  181. package/dist/types/services/task/dialer.d.ts +30 -0
  182. package/dist/types/services/task/digital/Digital.d.ts +23 -0
  183. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
  184. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  185. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  186. package/dist/types/services/task/state-machine/guards.d.ts +103 -0
  187. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  188. package/dist/types/services/task/state-machine/types.d.ts +277 -0
  189. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  190. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  191. package/dist/types/services/task/types.d.ts +790 -66
  192. package/dist/types/services/task/voice/Voice.d.ts +241 -0
  193. package/dist/types/services/task/voice/WebRTC.d.ts +54 -0
  194. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  195. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
  196. package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
  197. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  198. package/dist/types/types.d.ts +213 -11
  199. package/dist/types/utils/PageCache.d.ts +20 -3
  200. package/dist/types/webex.d.ts +1 -0
  201. package/dist/types.js +168 -6
  202. package/dist/types.js.map +1 -1
  203. package/dist/utils/PageCache.js +19 -5
  204. package/dist/utils/PageCache.js.map +1 -1
  205. package/dist/webex.js +22 -2
  206. package/dist/webex.js.map +1 -1
  207. package/package.json +16 -12
  208. package/src/cc.ts +1367 -101
  209. package/src/config.ts +13 -0
  210. package/src/constants.ts +41 -1
  211. package/src/index.ts +62 -15
  212. package/src/metrics/MetricsManager.ts +16 -0
  213. package/src/metrics/ai-docs/AGENTS.md +350 -0
  214. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  215. package/src/metrics/ai-docs/metrics-spec.md +971 -0
  216. package/src/metrics/behavioral-events.ts +218 -0
  217. package/src/metrics/constants.ts +63 -4
  218. package/src/services/AddressBook.ts +17 -6
  219. package/src/services/AnswerCallOnWebexService.ts +239 -0
  220. package/src/services/ApiAiAssistant.ts +494 -15
  221. package/src/services/EntryPoint.ts +59 -60
  222. package/src/services/Queue.ts +29 -12
  223. package/src/services/UserPreference.ts +509 -0
  224. package/src/services/WebCallingService.ts +16 -2
  225. package/src/services/WebexCrossClientService.ts +298 -0
  226. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  227. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  228. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  229. package/src/services/agent/ai-docs/agent-spec.md +505 -0
  230. package/src/services/ai-docs/AGENTS.md +386 -0
  231. package/src/services/ai-docs/services-spec.md +512 -0
  232. package/src/services/config/Util.ts +54 -84
  233. package/src/services/config/ai-docs/AGENTS.md +250 -0
  234. package/src/services/config/ai-docs/ARCHITECTURE.md +413 -0
  235. package/src/services/config/ai-docs/config-spec.md +669 -0
  236. package/src/services/config/constants.ts +64 -86
  237. package/src/services/config/index.ts +116 -277
  238. package/src/services/config/types.ts +233 -125
  239. package/src/services/constants.ts +18 -0
  240. package/src/services/core/Err.ts +3 -0
  241. package/src/services/core/Utils.ts +151 -37
  242. package/src/services/core/WebexRequest.ts +3 -1
  243. package/src/services/core/ai-docs/AGENTS.md +381 -0
  244. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  245. package/src/services/core/ai-docs/core-spec.md +797 -0
  246. package/src/services/core/aqm-reqs.ts +18 -12
  247. package/src/services/core/constants.ts +8 -0
  248. package/src/services/core/types.ts +33 -1
  249. package/src/services/core/websocket/WebSocketManager.ts +37 -8
  250. package/src/services/core/websocket/connection-service.ts +5 -1
  251. package/src/services/core/websocket/types.ts +1 -1
  252. package/src/services/index.ts +4 -0
  253. package/src/services/task/Task.ts +1211 -0
  254. package/src/services/task/TaskFactory.ts +82 -0
  255. package/src/services/task/TaskManager.ts +1551 -584
  256. package/src/services/task/TaskUtils.ts +316 -25
  257. package/src/services/task/WebexCallingUtils.ts +136 -0
  258. package/src/services/task/ai-docs/AGENTS.md +457 -0
  259. package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
  260. package/src/services/task/ai-docs/task-spec.md +1501 -0
  261. package/src/services/task/constants.ts +21 -0
  262. package/src/services/task/contact.ts +30 -0
  263. package/src/services/task/dialer.ts +80 -0
  264. package/src/services/task/digital/Digital.ts +102 -0
  265. package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
  266. package/src/services/task/state-machine/actions.ts +741 -0
  267. package/src/services/task/state-machine/ai-docs/AGENTS.md +460 -0
  268. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1156 -0
  269. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2247 -0
  270. package/src/services/task/state-machine/constants.ts +172 -0
  271. package/src/services/task/state-machine/guards.ts +442 -0
  272. package/src/services/task/state-machine/index.ts +28 -0
  273. package/src/services/task/state-machine/types.ts +258 -0
  274. package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
  275. package/src/services/task/taskDataNormalizer.ts +137 -0
  276. package/src/services/task/types.ts +974 -70
  277. package/src/services/task/voice/Voice.ts +1878 -0
  278. package/src/services/task/voice/WebRTC.ts +194 -0
  279. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  280. package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
  281. package/src/services/wxAppDiagnosticLogging.ts +286 -0
  282. package/src/services/wxAppTelephonyUtils.ts +14 -0
  283. package/src/types.ts +272 -13
  284. package/src/utils/AGENTS.md +289 -0
  285. package/src/utils/PageCache.ts +38 -5
  286. package/src/utils/ai-docs/utils-spec.md +391 -0
  287. package/src/webex.js +10 -0
  288. package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
  289. package/test/unit/spec/cc.ts +3764 -118
  290. package/test/unit/spec/index.ts +885 -0
  291. package/test/unit/spec/logger-proxy.ts +70 -0
  292. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  293. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  294. package/test/unit/spec/services/AddressBook.ts +37 -6
  295. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  296. package/test/unit/spec/services/ApiAiAssistant.ts +442 -23
  297. package/test/unit/spec/services/EntryPoint.ts +87 -40
  298. package/test/unit/spec/services/Queue.ts +123 -12
  299. package/test/unit/spec/services/UserPreference.ts +401 -0
  300. package/test/unit/spec/services/WebCallingService.ts +45 -1
  301. package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
  302. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  303. package/test/unit/spec/services/config/Util.ts +501 -0
  304. package/test/unit/spec/services/config/index.ts +318 -548
  305. package/test/unit/spec/services/core/Utils.ts +447 -8
  306. package/test/unit/spec/services/core/WebexRequest.ts +8 -7
  307. package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
  308. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +132 -56
  309. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  310. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  311. package/test/unit/spec/services/task/Task.ts +2723 -0
  312. package/test/unit/spec/services/task/TaskFactory.ts +116 -0
  313. package/test/unit/spec/services/task/TaskManager.ts +4800 -1586
  314. package/test/unit/spec/services/task/TaskUtils.ts +307 -0
  315. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  316. package/test/unit/spec/services/task/contact.ts +33 -0
  317. package/test/unit/spec/services/task/dialer.ts +190 -0
  318. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  319. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
  320. package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
  321. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  322. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
  323. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  324. package/test/unit/spec/services/task/voice/Voice.ts +2355 -0
  325. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  326. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  327. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
  328. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
  329. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  330. package/typedoc.md +1 -1
  331. package/umd/contact-center.min.js +2 -2
  332. package/umd/contact-center.min.js.map +1 -1
  333. package/dist/services/task/index.js +0 -1525
  334. package/dist/services/task/index.js.map +0 -1
  335. package/dist/types/services/task/index.d.ts +0 -650
  336. package/src/services/task/index.ts +0 -1801
  337. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -8,9 +8,20 @@ import {
8
8
  isDigitalOutbound,
9
9
  hasAgentInitiatedOutdial,
10
10
  shouldAutoAnswerTask,
11
+ getIsCustomerInCall,
12
+ getConferenceParticipantsCount,
13
+ isSecondaryAgent,
14
+ isSecondaryEpDnAgent,
15
+ getConsultMediaResourceId,
16
+ getIsConsultInProgressForConferenceControls,
17
+ getIsConsultedAgentForControls,
18
+ getServerHoldStateForControls,
19
+ isCampaignPreviewTask,
20
+ isCampaignPreviewReservation,
11
21
  } from '../../../../../src/services/task/TaskUtils';
12
22
  import {ITask, Interaction, TaskData} from '../../../../../src/services/task/types';
13
23
  import {LoginOption} from '../../../../../src/types';
24
+ import {CC_EVENTS} from '../../../../../src/services/config/types';
14
25
 
15
26
  describe('TaskUtils', () => {
16
27
  let mockTask: ITask;
@@ -41,6 +52,73 @@ describe('TaskUtils', () => {
41
52
  } as any;
42
53
  });
43
54
 
55
+ describe('state-control helper branches', () => {
56
+ it('should derive consulted-agent and hold states from task context', () => {
57
+ expect(
58
+ getIsConsultedAgentForControls({isConsulted: true} as TaskData, {} as any, false)
59
+ ).toBe(true);
60
+ expect(
61
+ getIsConsultedAgentForControls(
62
+ {} as TaskData,
63
+ {consultInitiator: false} as any,
64
+ true
65
+ )
66
+ ).toBe(true);
67
+ expect(
68
+ getIsConsultedAgentForControls(
69
+ {} as TaskData,
70
+ {consultInitiator: true} as any,
71
+ true
72
+ )
73
+ ).toBe(false);
74
+
75
+ const taskData = {
76
+ interaction: {
77
+ media: {
78
+ main: {isHold: true},
79
+ fallback: {isHold: false},
80
+ },
81
+ },
82
+ mediaResourceId: 'fallback',
83
+ } as TaskData;
84
+
85
+ expect(getServerHoldStateForControls({taskData} as any, 'main')).toBe(true);
86
+ expect(getServerHoldStateForControls({taskData} as any)).toBe(false);
87
+ expect(getServerHoldStateForControls({} as any)).toBeUndefined();
88
+ });
89
+
90
+ it('should detect campaign preview tasks and reservations', () => {
91
+ expect(
92
+ isCampaignPreviewTask({
93
+ interaction: {
94
+ outboundType: 'STANDARD_PREVIEW_CAMPAIGN',
95
+ callProcessingDetails: {},
96
+ },
97
+ } as TaskData)
98
+ ).toBe(true);
99
+ expect(
100
+ isCampaignPreviewTask({
101
+ interaction: {
102
+ outboundType: 'OUTDIAL',
103
+ callProcessingDetails: {campaignType: 'preview_standard'},
104
+ },
105
+ } as unknown as TaskData)
106
+ ).toBe(true);
107
+ expect(isCampaignPreviewTask({interaction: {callProcessingDetails: {}}} as TaskData)).toBe(
108
+ false
109
+ );
110
+
111
+ expect(
112
+ isCampaignPreviewReservation({
113
+ data: {type: CC_EVENTS.AGENT_OFFER_CAMPAIGN_RESERVATION},
114
+ } as ITask)
115
+ ).toBe(true);
116
+ expect(isCampaignPreviewReservation({data: {type: CC_EVENTS.AGENT_CONTACT}} as ITask)).toBe(
117
+ false
118
+ );
119
+ });
120
+ });
121
+
44
122
  describe('isPrimary', () => {
45
123
  it('should return true when agent is the owner', () => {
46
124
  expect(isPrimary(mockTask, mockAgentId)).toBe(true);
@@ -430,4 +508,233 @@ describe('TaskUtils', () => {
430
508
  });
431
509
  });
432
510
  });
511
+
512
+ // Additional coverage for conference/consult utility functions
513
+ describe('Conference Utility Functions', () => {
514
+ const interactionId = 'interaction-123';
515
+ const createInteraction = (media: any = {}, participants: any = {}) =>
516
+ ({interactionId, mainInteractionId: interactionId, media, participants}) as any;
517
+
518
+ it('getIsCustomerInCall returns true when customer active', () => {
519
+ const interaction = createInteraction(
520
+ {[interactionId]: {mType: 'mainCall', participants: ['c1']}},
521
+ {'c1': {pType: 'Customer', hasLeft: false}}
522
+ );
523
+ expect(getIsCustomerInCall(interaction, interactionId)).toBe(true);
524
+ });
525
+
526
+ it('getIsCustomerInCall returns false when participants map is missing', () => {
527
+ const interaction = createInteraction(
528
+ {[interactionId]: {mType: 'mainCall', participants: ['c1']}},
529
+ undefined
530
+ );
531
+ expect(getIsCustomerInCall(interaction, interactionId)).toBe(false);
532
+ });
533
+
534
+ it('getConferenceParticipantsCount counts active agents only', () => {
535
+ const interaction = createInteraction(
536
+ {[interactionId]: {mType: 'mainCall', participants: ['a1', 'a2', 'c1']}},
537
+ {'a1': {pType: 'Agent', hasLeft: false}, 'a2': {pType: 'Agent', hasLeft: false}, 'c1': {pType: 'Customer', hasLeft: false}}
538
+ );
539
+ expect(getConferenceParticipantsCount(interaction, interactionId)).toBe(2);
540
+ });
541
+
542
+ it('getConferenceParticipantsCount returns 0 when participants map is missing', () => {
543
+ const interaction = createInteraction(
544
+ {[interactionId]: {mType: 'mainCall', participants: ['a1', 'a2', 'c1']}},
545
+ undefined
546
+ );
547
+ expect(getConferenceParticipantsCount(interaction, interactionId)).toBe(0);
548
+ });
549
+
550
+ it('isSecondaryAgent returns true for consult with parentInteractionId', () => {
551
+ const interaction = createInteraction();
552
+ interaction.callProcessingDetails = {relationshipType: 'consult', parentInteractionId: 'parent-456'};
553
+ expect(isSecondaryAgent(interaction)).toBe(true);
554
+ });
555
+
556
+ it('isSecondaryEpDnAgent returns true for telephony secondary agent', () => {
557
+ const interaction = createInteraction();
558
+ interaction.mediaType = 'telephony';
559
+ interaction.callProcessingDetails = {relationshipType: 'consult', parentInteractionId: 'parent-456'};
560
+ expect(isSecondaryEpDnAgent(interaction)).toBe(true);
561
+ });
562
+ });
563
+
564
+ describe('getConsultMediaResourceId', () => {
565
+ it('returns consultMediaResourceId directly when provided', () => {
566
+ const result = getConsultMediaResourceId(undefined, 'consult-media-1', 'agent1');
567
+ expect(result).toBe('consult-media-1');
568
+ });
569
+
570
+ it('returns undefined when no interaction and no consultMediaResourceId', () => {
571
+ const result = getConsultMediaResourceId(undefined, undefined, 'agent1');
572
+ expect(result).toBeUndefined();
573
+ });
574
+
575
+ it('returns undefined when no agentId and no consultMediaResourceId', () => {
576
+ const interaction = {media: {}} as any;
577
+ const result = getConsultMediaResourceId(interaction, undefined, undefined);
578
+ expect(result).toBeUndefined();
579
+ });
580
+
581
+ it('finds consult media leg by mType and agent participation', () => {
582
+ const interaction = {
583
+ media: {
584
+ 'main-media': {
585
+ mediaResourceId: 'main-media',
586
+ mType: 'mainCall',
587
+ participants: ['agent1', 'customer1'],
588
+ },
589
+ 'consult-media': {
590
+ mediaResourceId: 'consult-media',
591
+ mType: 'consult',
592
+ participants: ['agent1', 'agent2'],
593
+ },
594
+ },
595
+ } as any;
596
+ const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
597
+ expect(result).toBe('consult-media');
598
+ });
599
+
600
+ it('returns undefined when no consult media leg matches the agent', () => {
601
+ const interaction = {
602
+ media: {
603
+ 'main-media': {
604
+ mediaResourceId: 'main-media',
605
+ mType: 'mainCall',
606
+ participants: ['agent1', 'customer1'],
607
+ },
608
+ 'consult-media': {
609
+ mediaResourceId: 'consult-media',
610
+ mType: 'consult',
611
+ participants: ['agent2', 'agent3'],
612
+ },
613
+ },
614
+ } as any;
615
+ const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
616
+ expect(result).toBeUndefined();
617
+ });
618
+
619
+ it('returns undefined when media has no consult type entries', () => {
620
+ const interaction = {
621
+ media: {
622
+ 'main-media': {
623
+ mediaResourceId: 'main-media',
624
+ mType: 'mainCall',
625
+ participants: ['agent1', 'customer1'],
626
+ },
627
+ },
628
+ } as any;
629
+ const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
630
+ expect(result).toBeUndefined();
631
+ });
632
+
633
+ it('prioritizes direct consultMediaResourceId over interaction search', () => {
634
+ const interaction = {
635
+ media: {
636
+ 'consult-media': {
637
+ mediaResourceId: 'consult-media',
638
+ mType: 'consult',
639
+ participants: ['agent1', 'agent2'],
640
+ },
641
+ },
642
+ } as any;
643
+ const result = getConsultMediaResourceId(interaction, 'direct-id', 'agent1');
644
+ expect(result).toBe('direct-id');
645
+ });
646
+ });
647
+
648
+ describe('getIsConsultInProgressForConferenceControls', () => {
649
+ it('returns false when consultee is reserved but has not joined (RONA)', () => {
650
+ const interaction = {
651
+ participants: {
652
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, isConsulted: false},
653
+ 'agent-2': {
654
+ id: 'agent-2',
655
+ pType: 'Agent',
656
+ hasLeft: false,
657
+ hasJoined: false,
658
+ isConsulted: true,
659
+ consultState: 'consultReserved',
660
+ },
661
+ 'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false},
662
+ },
663
+ media: {
664
+ 'interaction-1': {
665
+ mType: 'mainCall',
666
+ participants: ['customer-1', 'agent-1'],
667
+ },
668
+ 'consult-media': {
669
+ mType: 'consult',
670
+ participants: ['agent-2', 'agent-1'],
671
+ },
672
+ },
673
+ } as any;
674
+
675
+ expect(
676
+ getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
677
+ ).toBe(false);
678
+ });
679
+
680
+ it('returns true when consultee is actively consulting', () => {
681
+ const interaction = {
682
+ participants: {
683
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, isConsulted: false},
684
+ 'agent-2': {
685
+ id: 'agent-2',
686
+ pType: 'Agent',
687
+ hasLeft: false,
688
+ hasJoined: true,
689
+ isConsulted: true,
690
+ consultState: 'consulting',
691
+ },
692
+ 'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false},
693
+ },
694
+ media: {
695
+ 'interaction-1': {
696
+ mType: 'mainCall',
697
+ participants: ['customer-1', 'agent-1'],
698
+ },
699
+ 'consult-media': {
700
+ mType: 'consult',
701
+ participants: ['agent-2', 'agent-1'],
702
+ },
703
+ },
704
+ } as any;
705
+
706
+ expect(
707
+ getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
708
+ ).toBe(true);
709
+ });
710
+
711
+ it('returns true when EP-DN participant is on consult leg but not main call (CAI-8329)', () => {
712
+ const interaction = {
713
+ participants: {
714
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, consultState: 'conferencing'},
715
+ '+13159998087': {
716
+ id: '+13159998087',
717
+ pType: 'EP-DN',
718
+ type: 'EpDn',
719
+ hasLeft: false,
720
+ },
721
+ 'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false, hasJoined: true},
722
+ },
723
+ media: {
724
+ 'interaction-1': {
725
+ mType: 'mainCall',
726
+ participants: ['customer-1', 'agent-1'],
727
+ },
728
+ 'consult-media-1': {
729
+ mType: 'consult',
730
+ participants: ['+13159998087', 'agent-1'],
731
+ },
732
+ },
733
+ } as any;
734
+
735
+ expect(
736
+ getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
737
+ ).toBe(true);
738
+ });
739
+ });
433
740
  });
@@ -0,0 +1,153 @@
1
+ import {expect} from '@jest/globals';
2
+ import {
3
+ getWebexCallingDeviceDetailsForAgent,
4
+ isWebexCallingCallForAgent,
5
+ isWxAppEngagedForControls,
6
+ decodedLineOwnerId,
7
+ } from '../../../../../src/services/task/WebexCallingUtils';
8
+ import {TaskState} from '../../../../../src/services/task/state-machine/constants';
9
+
10
+ const WX_APP_PARTICIPANT = {
11
+ id: 'agent-1',
12
+ deviceType: 'wxApp',
13
+ deviceId: 'device-id-1',
14
+ deviceCallId: 'call-id-1',
15
+ };
16
+
17
+ const participantsById = {
18
+ 'agent-1': WX_APP_PARTICIPANT,
19
+ 'customer-1': {id: 'customer-1', pType: 'Customer'},
20
+ };
21
+
22
+ describe('getWebexCallingDeviceDetailsForAgent', () => {
23
+ it('returns device details when agent participant has wxApp deviceType', () => {
24
+ const result = getWebexCallingDeviceDetailsForAgent('agent-1', participantsById);
25
+
26
+ expect(result).toEqual({
27
+ deviceType: 'wxApp',
28
+ deviceId: 'device-id-1',
29
+ deviceCallId: 'call-id-1',
30
+ });
31
+ });
32
+
33
+ it('returns undefined when agentId is undefined', () => {
34
+ expect(getWebexCallingDeviceDetailsForAgent(undefined, participantsById)).toBeUndefined();
35
+ });
36
+
37
+ it('returns undefined when agentId is empty string', () => {
38
+ expect(getWebexCallingDeviceDetailsForAgent('', participantsById)).toBeUndefined();
39
+ });
40
+
41
+ it('returns undefined when participants is null', () => {
42
+ expect(getWebexCallingDeviceDetailsForAgent('agent-1', null)).toBeUndefined();
43
+ });
44
+
45
+ it('returns undefined when participants is an array (not object-by-id)', () => {
46
+ expect(getWebexCallingDeviceDetailsForAgent('agent-1', [WX_APP_PARTICIPANT])).toBeUndefined();
47
+ });
48
+
49
+ it('returns undefined when agent participant lacks deviceCallId', () => {
50
+ const participants = {
51
+ 'agent-1': {id: 'agent-1', deviceType: 'wxApp', deviceId: 'device-id-1'},
52
+ };
53
+
54
+ expect(getWebexCallingDeviceDetailsForAgent('agent-1', participants)).toBeUndefined();
55
+ });
56
+
57
+ it('returns undefined when agent participant lacks deviceId', () => {
58
+ const participants = {
59
+ 'agent-1': {id: 'agent-1', deviceType: 'wxApp', deviceCallId: 'call-id-1'},
60
+ };
61
+
62
+ expect(getWebexCallingDeviceDetailsForAgent('agent-1', participants)).toBeUndefined();
63
+ });
64
+
65
+ it('finds participant by id field when keyed differently', () => {
66
+ const participants = {
67
+ 'some-other-key': WX_APP_PARTICIPANT,
68
+ };
69
+ const result = getWebexCallingDeviceDetailsForAgent('agent-1', participants);
70
+
71
+ expect(result?.deviceCallId).toBe('call-id-1');
72
+ });
73
+
74
+ it('defaults deviceType to empty string when missing', () => {
75
+ const participants = {
76
+ 'agent-1': {id: 'agent-1', deviceId: 'device-id-1', deviceCallId: 'call-id-1'},
77
+ };
78
+ const result = getWebexCallingDeviceDetailsForAgent('agent-1', participants);
79
+
80
+ expect(result?.deviceType).toBe('');
81
+ });
82
+ });
83
+
84
+ describe('isWebexCallingCallForAgent', () => {
85
+ it('returns true when device details are found', () => {
86
+ expect(isWebexCallingCallForAgent('agent-1', participantsById)).toBe(true);
87
+ });
88
+
89
+ it('returns false when no device details are found', () => {
90
+ expect(isWebexCallingCallForAgent('unknown-agent', participantsById)).toBe(false);
91
+ });
92
+
93
+ it('returns false when agentId is undefined', () => {
94
+ expect(isWebexCallingCallForAgent(undefined, participantsById)).toBe(false);
95
+ });
96
+ });
97
+
98
+ describe('isWxAppEngagedForControls', () => {
99
+ it('returns true when flag is on, wxApp participant exists, and state is CONNECTED', () => {
100
+ expect(
101
+ isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.CONNECTED)
102
+ ).toBe(true);
103
+ });
104
+
105
+ it('returns false in OFFERED state', () => {
106
+ expect(isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.OFFERED)).toBe(
107
+ false
108
+ );
109
+ });
110
+
111
+ it('returns false when enableWxBetterTogether is false', () => {
112
+ expect(
113
+ isWxAppEngagedForControls(false, 'agent-1', participantsById, TaskState.CONNECTED)
114
+ ).toBe(false);
115
+ });
116
+
117
+ it('returns false in TERMINATED state', () => {
118
+ expect(
119
+ isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.TERMINATED)
120
+ ).toBe(false);
121
+ });
122
+
123
+ it('returns false in COMPLETED state', () => {
124
+ expect(
125
+ isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.COMPLETED)
126
+ ).toBe(false);
127
+ });
128
+
129
+ it('returns false in WRAPPING_UP state', () => {
130
+ expect(
131
+ isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.WRAPPING_UP)
132
+ ).toBe(false);
133
+ });
134
+ });
135
+
136
+ describe('decodedLineOwnerId', () => {
137
+ it('returns undefined when lineOwnerId is not provided', () => {
138
+ expect(decodedLineOwnerId(undefined)).toBeUndefined();
139
+ expect(decodedLineOwnerId('')).toBeUndefined();
140
+ });
141
+
142
+ it('decodes base64 encoded ID and returns last path segment', () => {
143
+ const orgId = 'ciscospark://us/ORGANIZATION/org-abc';
144
+ const encoded = btoa(orgId);
145
+ const result = decodedLineOwnerId(encoded);
146
+
147
+ expect(result).toBe('org-abc');
148
+ });
149
+
150
+ it('returns undefined when base64 decoding fails', () => {
151
+ expect(decodedLineOwnerId('not-valid-base64!!')).toBeUndefined();
152
+ });
153
+ });
@@ -215,6 +215,39 @@ describe("Routing contacts", () => {
215
215
  expect(req).toBeDefined();
216
216
  });
217
217
 
218
+ it('dropConferenceParticipant', () => {
219
+ fakeAqm.pendingRequests = {};
220
+ const req = contact.dropConferenceParticipant({
221
+ interactionId: 'test-interaction-drop-123',
222
+ participantId: '+1/participant 42',
223
+ }) as any;
224
+
225
+ expect(req).toEqual({
226
+ url: '/v1/tasks/test-interaction-drop-123/conference/participants/%2B1%2Fparticipant%2042/drop',
227
+ data: {},
228
+ host: 'wcc-api-gateway',
229
+ err: expect.any(Function),
230
+ redactSensitiveLogs: true,
231
+ notifSuccess: {
232
+ bind: {
233
+ type: 'RoutingMessage',
234
+ data: {
235
+ type: 'ParticipantLeftConference',
236
+ interactionId: 'test-interaction-drop-123',
237
+ },
238
+ },
239
+ msg: {},
240
+ },
241
+ notifFail: {
242
+ bind: {
243
+ type: 'RoutingMessage',
244
+ data: {type: 'ParticipantDropConferenceFailed'},
245
+ },
246
+ errId: 'Service.aqm.task.dropConferenceParticipant',
247
+ },
248
+ });
249
+ });
250
+
218
251
  it("exitConference", () => {
219
252
  fakeAqm.pendingRequests = {};
220
253
  const req = contact.exitConference({