@webex/contact-center 3.11.0 → 3.12.0-auth-prejoin-fetch.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 (325) hide show
  1. package/.sdd/manifest.json +883 -0
  2. package/AGENTS.md +94 -0
  3. package/ai-docs/ARCHITECTURE.md +168 -0
  4. package/ai-docs/CONTRACTS.md +50 -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 +48 -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 +359 -0
  17. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  18. package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
  19. package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
  20. package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
  21. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  22. package/ai-docs/patterns/testing-patterns.md +480 -0
  23. package/ai-docs/patterns/typescript-patterns.md +365 -0
  24. package/ai-docs/templates/README.md +102 -0
  25. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  26. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  27. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  28. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  29. package/ai-docs/templates/new-method/00-master.md +80 -0
  30. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  31. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  32. package/ai-docs/templates/new-method/03-tests.md +201 -0
  33. package/ai-docs/templates/new-method/04-validation.md +141 -0
  34. package/ai-docs/templates/new-service/00-master.md +109 -0
  35. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  36. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  37. package/ai-docs/templates/new-service/03-integration.md +178 -0
  38. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  39. package/ai-docs/templates/new-service/05-validation.md +145 -0
  40. package/dist/cc.js +818 -59
  41. package/dist/cc.js.map +1 -1
  42. package/dist/config.js +13 -0
  43. package/dist/config.js.map +1 -1
  44. package/dist/constants.js +31 -3
  45. package/dist/constants.js.map +1 -1
  46. package/dist/index.js +27 -5
  47. package/dist/index.js.map +1 -1
  48. package/dist/metrics/behavioral-events.js +127 -0
  49. package/dist/metrics/behavioral-events.js.map +1 -1
  50. package/dist/metrics/constants.js +34 -3
  51. package/dist/metrics/constants.js.map +1 -1
  52. package/dist/services/AddressBook.js +18 -15
  53. package/dist/services/AddressBook.js.map +1 -1
  54. package/dist/services/AnswerCallOnWebexService.js +174 -0
  55. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  56. package/dist/services/ApiAiAssistant.js +318 -0
  57. package/dist/services/ApiAiAssistant.js.map +1 -0
  58. package/dist/services/EntryPoint.js +46 -68
  59. package/dist/services/EntryPoint.js.map +1 -1
  60. package/dist/services/Queue.js +27 -22
  61. package/dist/services/Queue.js.map +1 -1
  62. package/dist/services/UserPreference.js +427 -0
  63. package/dist/services/UserPreference.js.map +1 -0
  64. package/dist/services/WebexCrossClientService.js +171 -0
  65. package/dist/services/WebexCrossClientService.js.map +1 -0
  66. package/dist/services/WxAppTelephonyMercurySync.js +93 -0
  67. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  68. package/dist/services/agent/types.js.map +1 -1
  69. package/dist/services/config/Util.js +11 -4
  70. package/dist/services/config/Util.js.map +1 -1
  71. package/dist/services/config/constants.js +45 -8
  72. package/dist/services/config/constants.js.map +1 -1
  73. package/dist/services/config/index.js +41 -2
  74. package/dist/services/config/index.js.map +1 -1
  75. package/dist/services/config/types.js +70 -8
  76. package/dist/services/config/types.js.map +1 -1
  77. package/dist/services/constants.js +27 -1
  78. package/dist/services/constants.js.map +1 -1
  79. package/dist/services/core/Err.js.map +1 -1
  80. package/dist/services/core/Utils.js +122 -25
  81. package/dist/services/core/Utils.js.map +1 -1
  82. package/dist/services/core/WebexRequest.js +6 -2
  83. package/dist/services/core/WebexRequest.js.map +1 -1
  84. package/dist/services/core/aqm-reqs.js +119 -30
  85. package/dist/services/core/aqm-reqs.js.map +1 -1
  86. package/dist/services/core/types.js.map +1 -1
  87. package/dist/services/core/websocket/WebSocketManager.js +22 -6
  88. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  89. package/dist/services/core/websocket/connection-service.js +3 -1
  90. package/dist/services/core/websocket/connection-service.js.map +1 -1
  91. package/dist/services/core/websocket/types.js.map +1 -1
  92. package/dist/services/index.js +6 -0
  93. package/dist/services/index.js.map +1 -1
  94. package/dist/services/task/Task.js +754 -0
  95. package/dist/services/task/Task.js.map +1 -0
  96. package/dist/services/task/TaskFactory.js +49 -0
  97. package/dist/services/task/TaskFactory.js.map +1 -0
  98. package/dist/services/task/TaskManager.js +1073 -447
  99. package/dist/services/task/TaskManager.js.map +1 -1
  100. package/dist/services/task/TaskUtils.js +220 -23
  101. package/dist/services/task/TaskUtils.js.map +1 -1
  102. package/dist/services/task/WebexCallingUtils.js +70 -0
  103. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  104. package/dist/services/task/constants.js +26 -2
  105. package/dist/services/task/constants.js.map +1 -1
  106. package/dist/services/task/contact.js +29 -0
  107. package/dist/services/task/contact.js.map +1 -1
  108. package/dist/services/task/dialer.js +129 -0
  109. package/dist/services/task/dialer.js.map +1 -1
  110. package/dist/services/task/digital/Digital.js +78 -0
  111. package/dist/services/task/digital/Digital.js.map +1 -0
  112. package/dist/services/task/state-machine/TaskStateMachine.js +971 -0
  113. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  114. package/dist/services/task/state-machine/actions.js +572 -0
  115. package/dist/services/task/state-machine/actions.js.map +1 -0
  116. package/dist/services/task/state-machine/constants.js +161 -0
  117. package/dist/services/task/state-machine/constants.js.map +1 -0
  118. package/dist/services/task/state-machine/guards.js +409 -0
  119. package/dist/services/task/state-machine/guards.js.map +1 -0
  120. package/dist/services/task/state-machine/index.js +53 -0
  121. package/dist/services/task/state-machine/index.js.map +1 -0
  122. package/dist/services/task/state-machine/types.js +54 -0
  123. package/dist/services/task/state-machine/types.js.map +1 -0
  124. package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
  125. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  126. package/dist/services/task/taskDataNormalizer.js +99 -0
  127. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  128. package/dist/services/task/types.js +243 -5
  129. package/dist/services/task/types.js.map +1 -1
  130. package/dist/services/task/voice/Voice.js +1380 -0
  131. package/dist/services/task/voice/Voice.js.map +1 -0
  132. package/dist/services/task/voice/WebRTC.js +152 -0
  133. package/dist/services/task/voice/WebRTC.js.map +1 -0
  134. package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
  135. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  136. package/dist/services/wxAppTelephonyUtils.js +19 -0
  137. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  138. package/dist/types/cc.d.ts +967 -0
  139. package/dist/types/config.d.ts +79 -0
  140. package/dist/types/constants.d.ts +74 -0
  141. package/dist/types/index.d.ts +201 -0
  142. package/dist/types/logger-proxy.d.ts +71 -0
  143. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  144. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  145. package/dist/types/metrics/constants.d.ts +183 -0
  146. package/dist/types/services/AddressBook.d.ts +75 -0
  147. package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
  148. package/dist/types/services/ApiAiAssistant.d.ts +49 -0
  149. package/dist/types/services/EntryPoint.d.ts +69 -0
  150. package/dist/types/services/Queue.d.ts +78 -0
  151. package/dist/types/services/UserPreference.d.ts +118 -0
  152. package/dist/types/services/WebCallingService.d.ts +1 -0
  153. package/dist/types/services/WebexCrossClientService.d.ts +28 -0
  154. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  155. package/dist/types/services/agent/index.d.ts +46 -0
  156. package/dist/types/services/agent/types.d.ts +413 -0
  157. package/dist/types/services/config/Util.d.ts +20 -0
  158. package/dist/types/services/config/constants.d.ts +273 -0
  159. package/dist/types/services/config/index.d.ts +177 -0
  160. package/dist/types/services/config/types.d.ts +1381 -0
  161. package/dist/types/services/constants.d.ts +110 -0
  162. package/dist/types/services/core/Err.d.ts +127 -0
  163. package/dist/types/services/core/GlobalTypes.d.ts +58 -0
  164. package/dist/types/services/core/Utils.d.ts +121 -0
  165. package/dist/types/services/core/WebexRequest.d.ts +23 -0
  166. package/dist/types/services/core/aqm-reqs.d.ts +65 -0
  167. package/dist/types/services/core/constants.d.ts +99 -0
  168. package/dist/types/services/core/types.d.ts +49 -0
  169. package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
  170. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  171. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  172. package/dist/types/services/core/websocket/types.d.ts +37 -0
  173. package/dist/types/services/index.d.ts +54 -0
  174. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  175. package/dist/types/services/task/Task.d.ts +175 -0
  176. package/dist/types/services/task/TaskFactory.d.ts +13 -0
  177. package/dist/types/services/task/TaskManager.d.ts +1 -0
  178. package/dist/types/services/task/TaskUtils.d.ts +138 -0
  179. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  180. package/dist/types/services/task/constants.d.ts +94 -0
  181. package/dist/types/services/task/contact.d.ts +73 -0
  182. package/dist/types/services/task/dialer.d.ts +73 -0
  183. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  184. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1398 -0
  185. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  186. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  187. package/dist/types/services/task/state-machine/guards.d.ts +103 -0
  188. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  189. package/dist/types/services/task/state-machine/types.d.ts +277 -0
  190. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  191. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  192. package/dist/types/services/task/types.d.ts +1933 -0
  193. package/dist/types/services/task/voice/Voice.d.ts +223 -0
  194. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  195. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
  196. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  197. package/dist/types/types.d.ts +784 -0
  198. package/dist/types/utils/PageCache.d.ts +190 -0
  199. package/dist/types/webex-config.d.ts +53 -0
  200. package/dist/types/webex.d.ts +8 -0
  201. package/dist/types.js +137 -3
  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 +14 -2
  206. package/dist/webex.js.map +1 -1
  207. package/package.json +16 -12
  208. package/src/cc.ts +983 -60
  209. package/src/config.ts +13 -0
  210. package/src/constants.ts +29 -1
  211. package/src/index.ts +26 -5
  212. package/src/metrics/ai-docs/AGENTS.md +350 -0
  213. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  214. package/src/metrics/ai-docs/metrics-spec.md +860 -0
  215. package/src/metrics/behavioral-events.ts +134 -0
  216. package/src/metrics/constants.ts +39 -3
  217. package/src/services/AddressBook.ts +17 -6
  218. package/src/services/AnswerCallOnWebexService.ts +206 -0
  219. package/src/services/ApiAiAssistant.ts +412 -0
  220. package/src/services/EntryPoint.ts +59 -60
  221. package/src/services/Queue.ts +29 -12
  222. package/src/services/UserPreference.ts +509 -0
  223. package/src/services/WebexCrossClientService.ts +212 -0
  224. package/src/services/WxAppTelephonyMercurySync.ts +115 -0
  225. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  226. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  227. package/src/services/agent/ai-docs/agent-spec.md +504 -0
  228. package/src/services/agent/types.ts +1 -1
  229. package/src/services/ai-docs/AGENTS.md +386 -0
  230. package/src/services/ai-docs/services-spec.md +497 -0
  231. package/src/services/config/Util.ts +13 -2
  232. package/src/services/config/ai-docs/AGENTS.md +255 -0
  233. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  234. package/src/services/config/ai-docs/config-spec.md +675 -0
  235. package/src/services/config/constants.ts +47 -7
  236. package/src/services/config/index.ts +45 -1
  237. package/src/services/config/types.ts +253 -11
  238. package/src/services/constants.ts +29 -0
  239. package/src/services/core/Err.ts +4 -0
  240. package/src/services/core/Utils.ts +143 -30
  241. package/src/services/core/WebexRequest.ts +3 -1
  242. package/src/services/core/ai-docs/AGENTS.md +381 -0
  243. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  244. package/src/services/core/ai-docs/core-spec.md +787 -0
  245. package/src/services/core/aqm-reqs.ts +125 -32
  246. package/src/services/core/types.ts +2 -0
  247. package/src/services/core/websocket/WebSocketManager.ts +23 -6
  248. package/src/services/core/websocket/connection-service.ts +5 -1
  249. package/src/services/core/websocket/types.ts +1 -1
  250. package/src/services/index.ts +4 -0
  251. package/src/services/task/Task.ts +908 -0
  252. package/src/services/task/TaskFactory.ts +60 -0
  253. package/src/services/task/TaskManager.ts +1291 -513
  254. package/src/services/task/TaskUtils.ts +314 -24
  255. package/src/services/task/WebexCallingUtils.ts +136 -0
  256. package/src/services/task/ai-docs/AGENTS.md +457 -0
  257. package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
  258. package/src/services/task/ai-docs/task-spec.md +1469 -0
  259. package/src/services/task/constants.ts +26 -0
  260. package/src/services/task/contact.ts +30 -0
  261. package/src/services/task/dialer.ts +136 -1
  262. package/src/services/task/digital/Digital.ts +97 -0
  263. package/src/services/task/state-machine/TaskStateMachine.ts +1313 -0
  264. package/src/services/task/state-machine/actions.ts +741 -0
  265. package/src/services/task/state-machine/ai-docs/AGENTS.md +462 -0
  266. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1146 -0
  267. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2209 -0
  268. package/src/services/task/state-machine/constants.ts +172 -0
  269. package/src/services/task/state-machine/guards.ts +498 -0
  270. package/src/services/task/state-machine/index.ts +28 -0
  271. package/src/services/task/state-machine/types.ts +258 -0
  272. package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
  273. package/src/services/task/taskDataNormalizer.ts +137 -0
  274. package/src/services/task/types.ts +843 -70
  275. package/src/services/task/voice/Voice.ts +1720 -0
  276. package/src/services/task/voice/WebRTC.ts +191 -0
  277. package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
  278. package/src/services/wxAppTelephonyUtils.ts +14 -0
  279. package/src/types.ts +238 -11
  280. package/src/utils/AGENTS.md +289 -0
  281. package/src/utils/PageCache.ts +38 -5
  282. package/src/utils/ai-docs/utils-spec.md +391 -0
  283. package/src/webex.js +2 -0
  284. package/test/unit/spec/cc.ts +1856 -122
  285. package/test/unit/spec/logger-proxy.ts +70 -0
  286. package/test/unit/spec/metrics/behavioral-events.ts +18 -0
  287. package/test/unit/spec/services/AddressBook.ts +37 -6
  288. package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
  289. package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
  290. package/test/unit/spec/services/EntryPoint.ts +87 -40
  291. package/test/unit/spec/services/Queue.ts +123 -12
  292. package/test/unit/spec/services/UserPreference.ts +401 -0
  293. package/test/unit/spec/services/WebCallingService.ts +7 -1
  294. package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
  295. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
  296. package/test/unit/spec/services/config/Util.ts +85 -0
  297. package/test/unit/spec/services/config/index.ts +85 -29
  298. package/test/unit/spec/services/core/Utils.ts +481 -2
  299. package/test/unit/spec/services/core/WebexRequest.ts +3 -1
  300. package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
  301. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +137 -41
  302. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  303. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  304. package/test/unit/spec/services/task/Task.ts +677 -0
  305. package/test/unit/spec/services/task/TaskFactory.ts +99 -0
  306. package/test/unit/spec/services/task/TaskManager.ts +2209 -918
  307. package/test/unit/spec/services/task/TaskUtils.ts +235 -0
  308. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  309. package/test/unit/spec/services/task/contact.ts +33 -0
  310. package/test/unit/spec/services/task/dialer.ts +372 -96
  311. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  312. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +3433 -0
  313. package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
  314. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  315. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
  316. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  317. package/test/unit/spec/services/task/voice/Voice.ts +1523 -0
  318. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  319. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
  320. package/umd/contact-center.min.js +2 -2
  321. package/umd/contact-center.min.js.map +1 -1
  322. package/dist/services/task/index.js +0 -1525
  323. package/dist/services/task/index.js.map +0 -1
  324. package/src/services/task/index.ts +0 -1801
  325. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -11,6 +11,7 @@ jest.mock('../../../../../src/logger-proxy', () => ({
11
11
  log: jest.fn(),
12
12
  error: jest.fn(),
13
13
  info: jest.fn(),
14
+ warn: jest.fn(),
14
15
  initialize: jest.fn(),
15
16
  },
16
17
  }));
@@ -244,7 +245,7 @@ describe('Utils', () => {
244
245
  const result = Utils.getStationLoginErrorData(failure, LoginOption.AGENT_DN);
245
246
  expect(result).toEqual({
246
247
  message:
247
- 'Enter a valid US dial number. For help, reach out to your administrator or support team.',
248
+ 'Enter a valid dial number. For help, reach out to your administrator or support team.',
248
249
  fieldName: LoginOption.AGENT_DN,
249
250
  });
250
251
  });
@@ -530,7 +531,7 @@ describe('Utils', () => {
530
531
  };
531
532
 
532
533
  const result = Utils.calculateDestAgentId(interaction, currentAgentId);
533
- expect(result).toBeUndefined();
534
+ expect(result).toBe('');
534
535
  });
535
536
 
536
537
  it('should handle CBT scenario when phone number is not a direct participant key', () => {
@@ -557,4 +558,482 @@ describe('Utils', () => {
557
558
  });
558
559
  });
559
560
 
561
+ describe('calculateDestType', () => {
562
+ const currentAgentId = 'current-agent-123';
563
+
564
+ it('should return DIALNUMBER when pType is DN', () => {
565
+ const interaction: any = {
566
+ media: {
567
+ consult: {
568
+ mType: 'consult',
569
+ participants: [currentAgentId, 'dest-agent-456'],
570
+ },
571
+ },
572
+ participants: {
573
+ [currentAgentId]: {type: 'Agent', pType: 'Agent'},
574
+ 'dest-agent-456': {type: 'Agent', pType: 'DN', id: 'dest-agent-456'},
575
+ },
576
+ };
577
+
578
+ const result = Utils.calculateDestType(interaction, currentAgentId);
579
+ expect(result).toBe('dialNumber');
580
+ });
581
+
582
+ it('should return ENTRYPOINT when pType is EP-DN', () => {
583
+ const interaction: any = {
584
+ media: {
585
+ consult: {
586
+ mType: 'consult',
587
+ participants: [currentAgentId, 'dest-agent-456'],
588
+ },
589
+ },
590
+ participants: {
591
+ [currentAgentId]: {type: 'Agent', pType: 'Agent'},
592
+ 'dest-agent-456': {type: 'Agent', pType: 'EP-DN', id: 'dest-agent-456'},
593
+ },
594
+ };
595
+
596
+ const result = Utils.calculateDestType(interaction, currentAgentId);
597
+ expect(result).toBe('entryPoint');
598
+ });
599
+
600
+ it('should return lowercase pType for other types', () => {
601
+ const interaction: any = {
602
+ media: {
603
+ consult: {
604
+ mType: 'consult',
605
+ participants: [currentAgentId, 'dest-agent-456'],
606
+ },
607
+ },
608
+ participants: {
609
+ [currentAgentId]: {type: 'Agent', pType: 'Agent'},
610
+ 'dest-agent-456': {type: 'Agent', pType: 'Agent', id: 'dest-agent-456'},
611
+ },
612
+ };
613
+
614
+ const result = Utils.calculateDestType(interaction, currentAgentId);
615
+ expect(result).toBe('agent');
616
+ });
617
+
618
+ it('should return agent when no destination agent found', () => {
619
+ const interaction: any = {
620
+ media: {},
621
+ participants: {
622
+ [currentAgentId]: {type: 'Agent', pType: 'Agent'},
623
+ },
624
+ };
625
+
626
+ const result = Utils.calculateDestType(interaction, currentAgentId);
627
+ expect(result).toBe('agent');
628
+ });
629
+ });
630
+
631
+ describe('buildConsultConferenceParamData', () => {
632
+ it('maps entryPoint destinationType correctly', () => {
633
+ const result = Utils.buildConsultConferenceParamData(
634
+ {
635
+ agentId: 'agent1',
636
+ destinationType: 'entryPoint',
637
+ destAgentId: 'ep123',
638
+ },
639
+ 'interaction123'
640
+ );
641
+
642
+ expect(result).toEqual({
643
+ interactionId: 'interaction123',
644
+ data: {
645
+ agentId: 'agent1',
646
+ to: 'ep123',
647
+ destinationType: 'entryPoint',
648
+ },
649
+ });
650
+ });
651
+
652
+ it('maps EP-DN/EP_DN destinationType variants to entryPoint', () => {
653
+ const hyphenResult = Utils.buildConsultConferenceParamData(
654
+ {
655
+ agentId: 'agent1',
656
+ destinationType: 'EP-DN',
657
+ destAgentId: 'ep123',
658
+ },
659
+ 'interaction123'
660
+ );
661
+ const underscoreResult = Utils.buildConsultConferenceParamData(
662
+ {
663
+ agentId: 'agent1',
664
+ destinationType: 'EP_DN',
665
+ destAgentId: 'ep123',
666
+ },
667
+ 'interaction123'
668
+ );
669
+
670
+ expect(hyphenResult.data.destinationType).toBe('entryPoint');
671
+ expect(underscoreResult.data.destinationType).toBe('entryPoint');
672
+ });
673
+ });
674
+
675
+ describe('getDestAgentIdForCBT', () => {
676
+ it('should return destination agent ID for CBT scenario', () => {
677
+ const interaction: any = {
678
+ participants: {
679
+ 'agent-uuid-123': {
680
+ type: 'Agent',
681
+ pType: 'dn',
682
+ dn: '5551234567',
683
+ id: 'agent-uuid-123',
684
+ },
685
+ 'customer-1': {
686
+ type: 'Customer',
687
+ pType: 'Customer',
688
+ id: 'customer-1',
689
+ },
690
+ },
691
+ };
692
+ const consultingAgent = '5551234567'; // Phone number, not in participants as key
693
+
694
+ const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
695
+ expect(result).toBe('agent-uuid-123');
696
+ });
697
+
698
+ it('should return empty string when consultingAgent is in participants (non-CBT)', () => {
699
+ const interaction: any = {
700
+ participants: {
701
+ 'agent-123': {
702
+ type: 'Agent',
703
+ pType: 'Agent',
704
+ id: 'agent-123',
705
+ },
706
+ },
707
+ };
708
+ const consultingAgent = 'agent-123'; // Exists as key in participants
709
+
710
+ const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
711
+ expect(result).toBe('');
712
+ });
713
+
714
+ it('should return empty string when no matching dial number found', () => {
715
+ const interaction: any = {
716
+ participants: {
717
+ 'agent-uuid-123': {
718
+ type: 'Agent',
719
+ pType: 'dn',
720
+ dn: '5559999999',
721
+ id: 'agent-uuid-123',
722
+ },
723
+ },
724
+ };
725
+ const consultingAgent = '5551234567'; // Different number
726
+
727
+ const result = Utils.getDestAgentIdForCBT(interaction, consultingAgent);
728
+ expect(result).toBe('');
729
+ });
730
+
731
+ it('should return empty string when consultingAgent is empty', () => {
732
+ const interaction: any = {
733
+ participants: {
734
+ 'agent-uuid-123': {
735
+ type: 'Agent',
736
+ pType: 'dn',
737
+ dn: '5551234567',
738
+ },
739
+ },
740
+ };
741
+
742
+ const result = Utils.getDestAgentIdForCBT(interaction, '');
743
+ expect(result).toBe('');
744
+ });
745
+
746
+ it('should match only when participant type is dial number and type is Agent', () => {
747
+ const interaction: any = {
748
+ participants: {
749
+ 'participant-1': {
750
+ type: 'Customer',
751
+ pType: 'dn',
752
+ dn: '5551234567',
753
+ },
754
+ 'participant-2': {
755
+ type: 'Agent',
756
+ pType: 'Agent',
757
+ dn: '5551234567',
758
+ },
759
+ 'participant-3': {
760
+ type: 'Agent',
761
+ pType: 'dn',
762
+ dn: '5551234567',
763
+ id: 'correct-agent',
764
+ },
765
+ },
766
+ };
767
+
768
+ const result = Utils.getDestAgentIdForCBT(interaction, '5551234567');
769
+ expect(result).toBe('participant-3');
770
+ });
771
+
772
+ it('should handle case-insensitive participant type comparison', () => {
773
+ const interaction: any = {
774
+ participants: {
775
+ 'agent-uuid': {
776
+ type: 'Agent',
777
+ pType: 'DN', // Uppercase (dial number)
778
+ dn: '5551234567',
779
+ },
780
+ },
781
+ };
782
+
783
+ const result = Utils.getDestAgentIdForCBT(interaction, '5551234567');
784
+ expect(result).toBe('agent-uuid');
785
+ });
786
+ });
787
+
788
+ describe('calculateDestAgentId', () => {
789
+ const currentAgentId = 'agent-123';
790
+
791
+ it('should return destAgentIdCBT when found', () => {
792
+ const interaction: any = {
793
+ media: {
794
+ consult: {
795
+ mType: 'consult',
796
+ participants: [currentAgentId, '5551234567'],
797
+ },
798
+ },
799
+ participants: {
800
+ 'agent-uuid-456': {
801
+ type: 'Agent',
802
+ pType: 'dn',
803
+ dn: '5551234567',
804
+ id: 'agent-uuid-456',
805
+ },
806
+ },
807
+ };
808
+
809
+ const result = Utils.calculateDestAgentId(interaction, currentAgentId);
810
+ expect(result).toBe('agent-uuid-456');
811
+ });
812
+
813
+ it('should return participant id for regular agent when not CBT', () => {
814
+ const consultedAgentId = 'agent-456';
815
+ const interaction: any = {
816
+ media: {
817
+ consult: {
818
+ mType: 'consult',
819
+ participants: [currentAgentId, consultedAgentId],
820
+ },
821
+ },
822
+ participants: {
823
+ [consultedAgentId]: {
824
+ type: 'Agent',
825
+ id: consultedAgentId,
826
+ },
827
+ },
828
+ };
829
+
830
+ const result = Utils.calculateDestAgentId(interaction, currentAgentId);
831
+ expect(result).toBe(consultedAgentId);
832
+ });
833
+
834
+ it('should return epId for EpDn type participants', () => {
835
+ const consultedAgentId = 'epdn-456';
836
+ const interaction: any = {
837
+ media: {
838
+ consult: {
839
+ mType: 'consult',
840
+ participants: [currentAgentId, consultedAgentId],
841
+ },
842
+ },
843
+ participants: {
844
+ [consultedAgentId]: {
845
+ type: 'EpDn',
846
+ id: consultedAgentId,
847
+ epId: 'entry-point-id-789',
848
+ },
849
+ },
850
+ };
851
+
852
+ const result = Utils.calculateDestAgentId(interaction, currentAgentId);
853
+ expect(result).toBe('entry-point-id-789');
854
+ });
855
+
856
+ it('should return undefined when no consulting agent found', () => {
857
+ const interaction: any = {
858
+ media: {
859
+ mainCall: {
860
+ mType: 'mainCall',
861
+ participants: [currentAgentId],
862
+ },
863
+ },
864
+ participants: {},
865
+ };
866
+
867
+ const result = Utils.calculateDestAgentId(interaction, currentAgentId);
868
+ expect(result).toBe('');
869
+ });
870
+
871
+ it('should handle CBT scenario when phone number is not a direct participant key', () => {
872
+ const interaction: any = {
873
+ media: {
874
+ consult: {
875
+ mType: 'consult',
876
+ participants: [currentAgentId, '5551234567'], // Phone number in media
877
+ },
878
+ },
879
+ participants: {
880
+ // Note: '5551234567' is NOT a key - this is CBT
881
+ 'agent-uuid-cbt': {
882
+ type: 'Agent',
883
+ pType: 'dn',
884
+ dn: '5551234567', // Found by matching DN
885
+ id: 'agent-uuid-cbt',
886
+ },
887
+ },
888
+ };
889
+
890
+ const result = Utils.calculateDestAgentId(interaction, currentAgentId);
891
+ expect(result).toBe('agent-uuid-cbt'); // Returns the CBT agent
892
+ });
893
+ });
894
+
895
+ describe('isValidDialNumber', () => {
896
+ const anyFormatEntry = {
897
+ name: 'Any Format',
898
+ prefix: '',
899
+ regex: '([0-9a-zA-Z]+[-._])*[0-9a-zA-Z]+',
900
+ strippedChars: '( )-',
901
+ };
902
+
903
+ const usOnlyEntry = {
904
+ name: 'US',
905
+ prefix: '1',
906
+ regex: '1[0-9]{3}[2-9][0-9]{6}([,]{1,10}[0-9]+){0,1}',
907
+ strippedChars: '( )-',
908
+ };
909
+
910
+ describe('with multiple dial plan entries (Any Format + US)', () => {
911
+ const dialPlanEntries = [anyFormatEntry, usOnlyEntry];
912
+
913
+ it('should return true for a valid US phone number', () => {
914
+ const result = Utils.isValidDialNumber('12223334567', dialPlanEntries);
915
+ expect(result).toBe(true);
916
+ });
917
+
918
+ it('should return true for a UK phone number', () => {
919
+ const result = Utils.isValidDialNumber('+442030484377', dialPlanEntries);
920
+ expect(result).toBe(true);
921
+ });
922
+
923
+ it('should return true for a European number', () => {
924
+ const result = Utils.isValidDialNumber('6955577166', dialPlanEntries);
925
+ expect(result).toBe(true);
926
+ });
927
+ });
928
+
929
+ describe('with US-only dial plan entry', () => {
930
+ const dialPlanEntries = [usOnlyEntry];
931
+
932
+ it('should return true for a valid US phone number', () => {
933
+ const result = Utils.isValidDialNumber('12223334567', dialPlanEntries);
934
+ expect(result).toBe(true);
935
+ });
936
+
937
+ it('should return false for a UK phone number', () => {
938
+ const result = Utils.isValidDialNumber('+442030484377', dialPlanEntries);
939
+ expect(result).toBe(false);
940
+ });
941
+
942
+ it('should return false for an invalid US number format', () => {
943
+ const result = Utils.isValidDialNumber('1234567890', dialPlanEntries);
944
+ expect(result).toBe(false);
945
+ });
946
+ });
947
+
948
+ describe('with empty dial plan entries (defers to server)', () => {
949
+ it('should return true for any dial number', () => {
950
+ expect(Utils.isValidDialNumber('12223334567', [])).toBe(true);
951
+ });
952
+
953
+ it('should return true for a UK phone number', () => {
954
+ expect(Utils.isValidDialNumber('+442030484377', [])).toBe(true);
955
+ });
956
+
957
+ it('should return true for a European number', () => {
958
+ expect(Utils.isValidDialNumber('6955577166', [])).toBe(true);
959
+ });
960
+ });
961
+
962
+ describe('strippedChars handling', () => {
963
+ it('should strip characters before regex matching', () => {
964
+ const strictEntry = {
965
+ name: 'Digits Only',
966
+ prefix: '',
967
+ regex: '^[0-9]{10,15}$',
968
+ strippedChars: '( )-+',
969
+ };
970
+ const result = Utils.isValidDialNumber('+44 (203) 048-4377', [strictEntry]);
971
+ expect(result).toBe(true);
972
+ });
973
+
974
+ it('should handle entries with no strippedChars', () => {
975
+ const noStripEntry = {
976
+ name: 'No Strip',
977
+ prefix: '',
978
+ regex: '^[0-9]+$',
979
+ strippedChars: '',
980
+ };
981
+ expect(Utils.isValidDialNumber('12345', [noStripEntry])).toBe(true);
982
+ expect(Utils.isValidDialNumber('+12345', [noStripEntry])).toBe(false);
983
+ });
984
+ });
985
+
986
+ describe('empty or undefined dial number', () => {
987
+ it('should return false and log warning for undefined dial number', () => {
988
+ const result = Utils.isValidDialNumber(undefined as any, [anyFormatEntry]);
989
+ expect(result).toBe(false);
990
+ expect(LoggerProxy.warn).toHaveBeenCalledWith(
991
+ 'Dial number is empty or undefined.',
992
+ expect.objectContaining({module: 'Utils', method: 'isValidDialNumber'})
993
+ );
994
+ });
995
+
996
+ it('should return false and log warning for empty string dial number', () => {
997
+ const result = Utils.isValidDialNumber('', [anyFormatEntry]);
998
+ expect(result).toBe(false);
999
+ expect(LoggerProxy.warn).toHaveBeenCalledWith(
1000
+ 'Dial number is empty or undefined.',
1001
+ expect.objectContaining({module: 'Utils', method: 'isValidDialNumber'})
1002
+ );
1003
+ });
1004
+ });
1005
+
1006
+ describe('invalid regex handling', () => {
1007
+ it('should return false and log warning for invalid regex pattern', () => {
1008
+ const badEntry = {
1009
+ name: 'Bad Regex',
1010
+ prefix: '',
1011
+ regex: '[invalid(',
1012
+ strippedChars: '',
1013
+ };
1014
+ const result = Utils.isValidDialNumber('12345', [badEntry]);
1015
+ expect(result).toBe(false);
1016
+ expect(LoggerProxy.warn).toHaveBeenCalledWith(
1017
+ expect.stringContaining('Failed to validate dial number against entry "Bad Regex"'),
1018
+ expect.objectContaining({module: 'Utils', method: 'isValidDialNumber'})
1019
+ );
1020
+ });
1021
+ });
1022
+ });
1023
+
1024
+ describe('stripDialPlanChars', () => {
1025
+ it('should remove specified characters from input', () => {
1026
+ expect(Utils.stripDialPlanChars('+44 (203) 048-4377', '( )-+')).toBe('442030484377');
1027
+ });
1028
+
1029
+ it('should return input unchanged when strippedChars is empty', () => {
1030
+ expect(Utils.stripDialPlanChars('+442030484377', '')).toBe('+442030484377');
1031
+ });
1032
+
1033
+ it('should return input unchanged when strippedChars is null/undefined', () => {
1034
+ expect(Utils.stripDialPlanChars('12345', null as any)).toBe('12345');
1035
+ expect(Utils.stripDialPlanChars('12345', undefined as any)).toBe('12345');
1036
+ });
1037
+ });
1038
+
560
1039
  });
@@ -51,6 +51,7 @@ describe('WebexRequest', () => {
51
51
  resource: 'resource',
52
52
  method: HTTP_METHODS.POST,
53
53
  body: { key: 'value' },
54
+ headers: {'x-test-header': 'test-value'},
54
55
  });
55
56
 
56
57
  expect(result).toEqual(mockResponse);
@@ -59,6 +60,7 @@ describe('WebexRequest', () => {
59
60
  resource: 'resource',
60
61
  method: HTTP_METHODS.POST,
61
62
  body: { key: 'value' },
63
+ headers: {'x-test-header': 'test-value'},
62
64
  });
63
65
  });
64
66
 
@@ -141,4 +143,4 @@ describe('WebexRequest', () => {
141
143
  );
142
144
  });
143
145
  });
144
- });
146
+ });
@@ -334,6 +334,28 @@ describe('AqmReqs', () => {
334
334
  });
335
335
 
336
336
  describe('Event tests', () => {
337
+ const participantDropConfig = (participantId: string, timeout?: number | 'disabled') => ({
338
+ host: 'fake-host',
339
+ url: `/v1/tasks/interaction/conference/participants/${participantId}/drop`,
340
+ data: {},
341
+ timeout,
342
+ redactSensitiveLogs: true,
343
+ err: (error: any) => error,
344
+ notifSuccess: {
345
+ bind: {
346
+ type: 'RoutingMessage',
347
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
348
+ },
349
+ },
350
+ notifFail: {
351
+ bind: {
352
+ type: 'RoutingMessage',
353
+ data: {type: 'ParticipantDropConferenceFailed'},
354
+ },
355
+ errId: 'Service.aqm.task.dropConferenceParticipant' as const,
356
+ },
357
+ });
358
+
337
359
  it('should handle onMessage events', async () => {
338
360
  webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
339
361
 
@@ -564,5 +586,95 @@ describe('AqmReqs', () => {
564
586
  const result = await promise;
565
587
  expect(result).toEqual(eventData);
566
588
  });
589
+
590
+ it('redacts sensitive routing failure payloads from logs', async () => {
591
+ const participantId = '+1/failure-secret';
592
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
593
+ const promise = aqm['createPromise'](participantDropConfig(participantId, 'disabled'));
594
+
595
+ webSocketManagerInstance.emit(
596
+ 'message',
597
+ JSON.stringify({
598
+ type: 'RoutingMessage',
599
+ data: {type: 'ParticipantDropConferenceFailed', participantId},
600
+ })
601
+ );
602
+
603
+ await expect(promise).rejects.toBeDefined();
604
+ expect(LoggerProxy.log).toHaveBeenCalledTimes(1);
605
+ expect(LoggerProxy.log).toHaveBeenCalledWith(
606
+ 'Routing request failed (sensitive details redacted)',
607
+ expect.objectContaining({module: AQM_REQS_FILE})
608
+ );
609
+ expect(JSON.stringify((LoggerProxy.log as jest.Mock).mock.calls)).not.toContain(participantId);
610
+ expect(aqm['pendingRequests']).toEqual({});
611
+ });
612
+
613
+ it('resolves a correlated participant-left event and clears its binds', async () => {
614
+ jest.useFakeTimers();
615
+ (global.window as any).setTimeout = global.setTimeout;
616
+
617
+ try {
618
+ const participantId = '+1/success-secret';
619
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
620
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
621
+ const eventData = {
622
+ type: 'RoutingMessage',
623
+ data: {type: 'ParticipantLeftConference', interactionId: 'interaction'},
624
+ };
625
+
626
+ webSocketManagerInstance.emit('message', JSON.stringify(eventData));
627
+
628
+ await expect(promise).resolves.toEqual(eventData);
629
+ expect(aqm['pendingRequests']).toEqual({});
630
+ } finally {
631
+ jest.useRealTimers();
632
+ (global.window as any).setTimeout = global.setTimeout;
633
+ }
634
+ });
635
+
636
+ it('clears participant Drop binds after an HTTP failure without logging sensitive data', async () => {
637
+ jest.useFakeTimers();
638
+ (global.window as any).setTimeout = global.setTimeout;
639
+
640
+ try {
641
+ const participantId = '+1/http-secret';
642
+ const httpFailure = {headers: {Authorization: 'Bearer secret'}};
643
+ webexRequestInstance.request.mockRejectedValueOnce(httpFailure);
644
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
645
+
646
+ await expect(promise).rejects.toBe(httpFailure);
647
+ expect(aqm['pendingRequests']).toEqual({});
648
+ expect(JSON.stringify([
649
+ (LoggerProxy.log as jest.Mock).mock.calls,
650
+ (LoggerProxy.error as jest.Mock).mock.calls,
651
+ ])).not.toContain(participantId);
652
+ expect(httpFailure.headers.Authorization).toBe('*');
653
+ } finally {
654
+ jest.useRealTimers();
655
+ (global.window as any).setTimeout = global.setTimeout;
656
+ }
657
+ });
658
+
659
+ it('uses the default timeout without logging a sensitive request URL', async () => {
660
+ jest.useFakeTimers();
661
+ (global.window as any).setTimeout = global.setTimeout;
662
+
663
+ try {
664
+ const participantId = '+1/timeout-secret';
665
+ webexRequestInstance.request.mockResolvedValueOnce(mockWebexRequestResolvedValue);
666
+ const promise = aqm['createPromise'](participantDropConfig(participantId));
667
+ const rejection = expect(promise).rejects.toBeDefined();
668
+
669
+ jest.advanceTimersByTime(20000);
670
+
671
+ await rejection;
672
+ expect(JSON.stringify((LoggerProxy.error as jest.Mock).mock.calls)).not.toContain(participantId);
673
+ expect(aqm['pendingRequests']).toEqual({});
674
+ } finally {
675
+ jest.useRealTimers();
676
+ (global.window as any).setTimeout = global.setTimeout;
677
+ }
678
+ });
567
679
  });
568
- });
680
+ });