@webex/contact-center 3.12.0-next.13 → 3.12.0-next.130
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.
- package/.sdd/manifest.json +884 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +53 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +138 -0
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +444 -0
- package/ai-docs/SECURITY.md +52 -0
- package/ai-docs/SERVICE_STATE.md +52 -0
- package/ai-docs/SPEC_INDEX.md +65 -0
- package/ai-docs/adr/0001-spec-source-policy.md +55 -0
- package/ai-docs/adr/README.md +8 -0
- package/ai-docs/adr/_adr-template.md +31 -0
- package/ai-docs/contact-center-spec.md +382 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/contact-owner-change-refactor.md +78 -0
- package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
- package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
- package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +971 -42
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +31 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +45 -15
- package/dist/index.js.map +1 -1
- package/dist/metrics/MetricsManager.js +16 -0
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +205 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +48 -4
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +202 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +269 -9
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/UserPreference.js +427 -0
- package/dist/services/UserPreference.js.map +1 -0
- package/dist/services/WebexCrossClientService.js +222 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +108 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +11 -4
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +41 -7
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +51 -0
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +57 -12
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +111 -32
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +28 -14
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +2 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +754 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +49 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1172 -521
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +211 -27
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +12 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/dialer.js +78 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +78 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +572 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +379 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +228 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1485 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +152 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +354 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppDiagnosticLogging.js +122 -0
- package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +193 -6
- package/dist/types/config.d.ts +13 -0
- package/dist/types/constants.d.ts +29 -1
- package/dist/types/index.d.ts +35 -8
- package/dist/types/metrics/MetricsManager.d.ts +6 -0
- package/dist/types/metrics/constants.d.ts +43 -1
- package/dist/types/services/AddressBook.d.ts +2 -1
- package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
- package/dist/types/services/ApiAiAssistant.d.ts +56 -5
- package/dist/types/services/EntryPoint.d.ts +7 -5
- package/dist/types/services/Queue.d.ts +5 -3
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebexCrossClientService.d.ts +32 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/config/constants.d.ts +34 -5
- package/dist/types/services/config/types.d.ts +197 -12
- package/dist/types/services/core/Err.d.ts +6 -0
- package/dist/types/services/core/Utils.d.ts +35 -13
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +1 -1
- package/dist/types/services/task/Task.d.ts +175 -0
- package/dist/types/services/task/TaskFactory.d.ts +13 -0
- package/dist/types/services/task/TaskUtils.d.ts +48 -2
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +10 -0
- package/dist/types/services/task/contact.d.ts +4 -0
- package/dist/types/services/task/dialer.d.ts +30 -0
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +103 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +277 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +680 -66
- package/dist/types/services/task/voice/Voice.d.ts +227 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +55 -0
- package/dist/types/services/wxAppDiagnosticLogging.d.ts +51 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +205 -9
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +162 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +22 -2
- package/dist/webex.js.map +1 -1
- package/package.json +16 -12
- package/src/cc.ts +1289 -112
- package/src/config.ts +13 -0
- package/src/constants.ts +29 -1
- package/src/index.ts +36 -5
- package/src/metrics/MetricsManager.ts +16 -0
- package/src/metrics/ai-docs/AGENTS.md +350 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
- package/src/metrics/ai-docs/metrics-spec.md +921 -0
- package/src/metrics/behavioral-events.ts +212 -0
- package/src/metrics/constants.ts +52 -4
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +239 -0
- package/src/services/ApiAiAssistant.ts +356 -9
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebexCrossClientService.ts +293 -0
- package/src/services/WxAppTelephonyMercurySync.ts +142 -0
- package/src/services/agent/ai-docs/AGENTS.md +240 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
- package/src/services/agent/ai-docs/agent-spec.md +505 -0
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +505 -0
- package/src/services/config/Util.ts +12 -3
- package/src/services/config/ai-docs/AGENTS.md +255 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
- package/src/services/config/ai-docs/config-spec.md +686 -0
- package/src/services/config/constants.ts +46 -6
- package/src/services/config/index.ts +65 -0
- package/src/services/config/types.ts +197 -13
- package/src/services/core/Err.ts +3 -0
- package/src/services/core/Utils.ts +127 -37
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/AGENTS.md +381 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
- package/src/services/core/ai-docs/core-spec.md +787 -0
- package/src/services/core/aqm-reqs.ts +30 -15
- package/src/services/core/types.ts +2 -0
- package/src/services/core/websocket/WebSocketManager.ts +2 -0
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +1 -1
- package/src/services/task/Task.ts +908 -0
- package/src/services/task/TaskFactory.ts +60 -0
- package/src/services/task/TaskManager.ts +1419 -608
- package/src/services/task/TaskUtils.ts +303 -25
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/AGENTS.md +457 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
- package/src/services/task/ai-docs/task-spec.md +1474 -0
- package/src/services/task/constants.ts +10 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +80 -0
- package/src/services/task/digital/Digital.ts +97 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +460 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1156 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2247 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +442 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +258 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +819 -70
- package/src/services/task/voice/Voice.ts +1851 -0
- package/src/services/task/voice/WebRTC.ts +191 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +516 -0
- package/src/services/wxAppDiagnosticLogging.ts +174 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +262 -11
- package/src/utils/AGENTS.md +289 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +391 -0
- package/src/webex.js +10 -0
- package/test/unit/spec/cc.ts +2210 -119
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/MetricsManager.ts +25 -0
- package/test/unit/spec/metrics/behavioral-events.ts +60 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +311 -21
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/UserPreference.ts +401 -0
- package/test/unit/spec/services/WebCallingService.ts +7 -1
- package/test/unit/spec/services/WebexCrossClientService.ts +467 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
- package/test/unit/spec/services/config/Util.ts +129 -0
- package/test/unit/spec/services/config/index.ts +97 -29
- package/test/unit/spec/services/core/Utils.ts +425 -8
- package/test/unit/spec/services/core/WebexRequest.ts +3 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +745 -0
- package/test/unit/spec/services/task/TaskFactory.ts +99 -0
- package/test/unit/spec/services/task/TaskManager.ts +2518 -1494
- package/test/unit/spec/services/task/TaskUtils.ts +235 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/dialer.ts +190 -0
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +2061 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +603 -0
- package/test/unit/spec/services/wxAppDiagnosticLogging.ts +143 -0
- package/test/unit/spec/wellnessSampleUtils.ts +288 -0
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1525
- package/dist/services/task/index.js.map +0 -1
- package/dist/types/services/task/index.d.ts +0 -650
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -1,8 +1,160 @@
|
|
|
1
1
|
/* eslint-disable import/prefer-default-export */
|
|
2
2
|
import {Interaction, ITask, TaskData, MEDIA_CHANNEL} from './types';
|
|
3
|
-
import {CC_EVENTS} from '../config/types';
|
|
4
|
-
import {OUTDIAL_DIRECTION, OUTDIAL_MEDIA_TYPE, OUTBOUND_TYPE} from '../../constants';
|
|
5
3
|
import {LoginOption} from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
PARTICIPANT_TYPE,
|
|
6
|
+
MEDIA_TYPE_MAIN_CALL,
|
|
7
|
+
CONSULT_STATE,
|
|
8
|
+
INTERACTION_STATE,
|
|
9
|
+
MEDIA_TYPE_CONSULT,
|
|
10
|
+
} from './state-machine/constants';
|
|
11
|
+
import {TaskContext} from './state-machine/types';
|
|
12
|
+
import {CC_EVENTS} from '../config/types';
|
|
13
|
+
import {OUTBOUND_TYPE, OUTDIAL_DIRECTION, OUTDIAL_MEDIA_TYPE} from '../../constants';
|
|
14
|
+
|
|
15
|
+
const CAMPAIGN_PREVIEW_OUTBOUND_TYPES = ['STANDARD_PREVIEW_CAMPAIGN', 'DIRECT_PREVIEW_CAMPAIGN'];
|
|
16
|
+
const CAMPAIGN_PREVIEW_CAMPAIGN_TYPES = ['preview_standard', 'preview_direct'];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the customer is still in the call (not left)
|
|
20
|
+
*
|
|
21
|
+
* @param interaction - The interaction object
|
|
22
|
+
* @param interactionId - The main interaction ID
|
|
23
|
+
* @returns true if customer is in the call
|
|
24
|
+
*/
|
|
25
|
+
export const getIsCustomerInCall = (interaction: Interaction, interactionId: string): boolean => {
|
|
26
|
+
const mainCallMedia = interaction.media?.[interactionId];
|
|
27
|
+
const participants = interaction.participants;
|
|
28
|
+
if (!mainCallMedia?.participants || !participants) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return mainCallMedia.participants.some((participantId: string) => {
|
|
33
|
+
const participant = participants[participantId];
|
|
34
|
+
|
|
35
|
+
return participant?.pType === PARTICIPANT_TYPE.CUSTOMER && !participant.hasLeft;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gets the count of active agent participants in the conference
|
|
41
|
+
* Excludes Customer, Supervisor, and VVA participant types
|
|
42
|
+
*
|
|
43
|
+
* @param interaction - The interaction object
|
|
44
|
+
* @param interactionId - The main interaction ID
|
|
45
|
+
* @returns Number of active agent participants
|
|
46
|
+
*/
|
|
47
|
+
export const getConferenceParticipantsCount = (
|
|
48
|
+
interaction: Interaction,
|
|
49
|
+
interactionId: string
|
|
50
|
+
): number => {
|
|
51
|
+
const mainCallMedia = interaction.media?.[interactionId];
|
|
52
|
+
const participants = interaction.participants;
|
|
53
|
+
if (!mainCallMedia?.participants || !participants) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let count = 0;
|
|
58
|
+
for (const participantId of mainCallMedia.participants) {
|
|
59
|
+
const participant = participants[participantId];
|
|
60
|
+
if (
|
|
61
|
+
participant &&
|
|
62
|
+
participant.pType !== PARTICIPANT_TYPE.CUSTOMER &&
|
|
63
|
+
participant.pType !== PARTICIPANT_TYPE.SUPERVISOR &&
|
|
64
|
+
participant.pType !== PARTICIPANT_TYPE.VVA &&
|
|
65
|
+
!participant.hasLeft
|
|
66
|
+
) {
|
|
67
|
+
count += 1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return count;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Determines if a consult is actively in-progress for conference control gating.
|
|
76
|
+
* This is used to disable conference controls (End/Consult) only when a consult leg
|
|
77
|
+
* still exists outside the main call participants.
|
|
78
|
+
*/
|
|
79
|
+
export const getIsConsultInProgressForConferenceControls = (
|
|
80
|
+
interaction: Interaction | undefined,
|
|
81
|
+
mainCallId: string | undefined,
|
|
82
|
+
selfAgentId: string | undefined
|
|
83
|
+
): boolean => {
|
|
84
|
+
if (!interaction || !mainCallId) return false;
|
|
85
|
+
|
|
86
|
+
const mainParticipants = interaction.media?.[mainCallId]?.participants;
|
|
87
|
+
if (!Array.isArray(mainParticipants) || mainParticipants.length === 0) return false;
|
|
88
|
+
|
|
89
|
+
const mainSet = new Set(mainParticipants);
|
|
90
|
+
const media = interaction.media;
|
|
91
|
+
if (!media) return false;
|
|
92
|
+
|
|
93
|
+
return Object.values(media).some((m: any) => {
|
|
94
|
+
if (!m || m.mType !== 'consult') return false;
|
|
95
|
+
if (!Array.isArray(m.participants) || m.participants.length === 0) return false;
|
|
96
|
+
|
|
97
|
+
return m.participants.some((participantId: string) => {
|
|
98
|
+
const p: any = interaction.participants?.[participantId];
|
|
99
|
+
if (!p || p.hasLeft) return false;
|
|
100
|
+
if (selfAgentId && participantId === selfAgentId) return false;
|
|
101
|
+
if (mainSet.has(participantId)) return false;
|
|
102
|
+
|
|
103
|
+
const participantType = String(p.pType ?? '').toUpperCase();
|
|
104
|
+
const isEpDnParticipant =
|
|
105
|
+
participantType === 'EP-DN' || participantType === 'EP_DN' || participantType === 'DN';
|
|
106
|
+
if (isEpDnParticipant) {
|
|
107
|
+
if (!selfAgentId) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const selfConsultState = interaction.participants?.[selfAgentId]?.consultState as
|
|
111
|
+
| string
|
|
112
|
+
| undefined;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
selfConsultState === 'consulting' ||
|
|
116
|
+
selfConsultState === 'conferencing' ||
|
|
117
|
+
selfConsultState === 'consultInitiated'
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const consultState = p.consultState as string | undefined;
|
|
122
|
+
const isRonaPendingConsultee = consultState === 'consultReserved' && p.hasJoined === false;
|
|
123
|
+
const consultLegActive =
|
|
124
|
+
consultState === 'consulting' ||
|
|
125
|
+
p.currentState === 'consulting' ||
|
|
126
|
+
(p.isConsulted === true && consultState !== 'consultCompleted' && !isRonaPendingConsultee);
|
|
127
|
+
|
|
128
|
+
return consultLegActive;
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const getIsConsultedAgentForControls = (
|
|
134
|
+
taskData: TaskData | null,
|
|
135
|
+
context: TaskContext,
|
|
136
|
+
isConsultingState: boolean
|
|
137
|
+
): boolean => {
|
|
138
|
+
return Boolean(taskData?.isConsulted) || (isConsultingState && !context.consultInitiator);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const getServerHoldStateForControls = (
|
|
142
|
+
context: TaskContext,
|
|
143
|
+
mainCallId?: string,
|
|
144
|
+
fallbackTaskData?: TaskData | null
|
|
145
|
+
): boolean | undefined => {
|
|
146
|
+
const media = context.taskData?.interaction?.media ?? fallbackTaskData?.interaction?.media;
|
|
147
|
+
if (!media) return undefined;
|
|
148
|
+
|
|
149
|
+
if (mainCallId && media[mainCallId]) {
|
|
150
|
+
return media[mainCallId].isHold ?? false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const mediaId = context.taskData?.mediaResourceId ?? fallbackTaskData?.mediaResourceId;
|
|
154
|
+
if (!mediaId) return undefined;
|
|
155
|
+
|
|
156
|
+
return media[mediaId]?.isHold;
|
|
157
|
+
};
|
|
6
158
|
|
|
7
159
|
/**
|
|
8
160
|
* Determines if the given agent is the primary agent (owner) of the task
|
|
@@ -32,7 +184,9 @@ export const isParticipantInMainInteraction = (task: ITask, agentId: string): bo
|
|
|
32
184
|
|
|
33
185
|
return Object.values(task.data.interaction.media).some(
|
|
34
186
|
(mediaObj) =>
|
|
35
|
-
mediaObj &&
|
|
187
|
+
mediaObj &&
|
|
188
|
+
mediaObj.mType === MEDIA_TYPE_MAIN_CALL &&
|
|
189
|
+
mediaObj.participants?.includes(agentId)
|
|
36
190
|
);
|
|
37
191
|
};
|
|
38
192
|
|
|
@@ -56,33 +210,110 @@ export const checkParticipantNotInInteraction = (task: ITask, agentId: string):
|
|
|
56
210
|
|
|
57
211
|
/**
|
|
58
212
|
* Determines if a conference is currently in progress based on the number of active agent participants
|
|
59
|
-
* @param
|
|
213
|
+
* @param data - The task data to check for conference status
|
|
60
214
|
* @returns true if there are 2 or more active agent participants in the main call, false otherwise
|
|
215
|
+
*
|
|
216
|
+
* For Agent B (consulted agent), their task's interactionId may be different from the main call.
|
|
217
|
+
* We use mainInteractionId from the interaction if available, otherwise fallback to interactionId.
|
|
61
218
|
*/
|
|
62
219
|
export const getIsConferenceInProgress = (data: TaskData): boolean => {
|
|
63
|
-
|
|
220
|
+
if (!data.interaction) return false;
|
|
221
|
+
|
|
222
|
+
const mainCallId = data.interaction.mainInteractionId || data.interactionId;
|
|
223
|
+
const mediaMainCall = data.interaction.media?.[mainCallId];
|
|
64
224
|
const participantsInMainCall = new Set(mediaMainCall?.participants);
|
|
65
|
-
const participants = data.interaction
|
|
225
|
+
const {participants} = data.interaction;
|
|
66
226
|
|
|
67
227
|
const agentParticipants = new Set();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
}
|
|
228
|
+
participantsInMainCall.forEach((participantId: string) => {
|
|
229
|
+
const participant = participants[participantId];
|
|
230
|
+
if (
|
|
231
|
+
participant &&
|
|
232
|
+
participant.pType !== PARTICIPANT_TYPE.CUSTOMER &&
|
|
233
|
+
participant.pType !== PARTICIPANT_TYPE.SUPERVISOR &&
|
|
234
|
+
participant.pType !== PARTICIPANT_TYPE.VVA &&
|
|
235
|
+
!participant.hasLeft
|
|
236
|
+
) {
|
|
237
|
+
agentParticipants.add(participantId);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
82
240
|
|
|
83
241
|
return agentParticipants.size >= 2;
|
|
84
242
|
};
|
|
85
243
|
|
|
244
|
+
const EP_DN_MERGE_TERMINAL_CONSULT_EVENTS = new Set<string>([
|
|
245
|
+
CC_EVENTS.AGENT_CONSULT_ENDED,
|
|
246
|
+
CC_EVENTS.AGENT_CONSULT_CONFERENCE_ENDED,
|
|
247
|
+
]);
|
|
248
|
+
|
|
249
|
+
const isEpDnParticipantType = (pType: string | undefined): boolean => {
|
|
250
|
+
const normalized = String(pType ?? '').toUpperCase();
|
|
251
|
+
|
|
252
|
+
return normalized === 'EP-DN' || normalized === 'EP_DN' || normalized === 'DN';
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/** EP-DN consult merged to conference before a second agent joins the main leg (CAI-8329). */
|
|
256
|
+
export const isEpDnConsultPendingConferenceMerge = (
|
|
257
|
+
taskData: TaskData | undefined,
|
|
258
|
+
selfAgentId: string | undefined
|
|
259
|
+
): boolean => {
|
|
260
|
+
if (!taskData?.interaction || !selfAgentId) return false;
|
|
261
|
+
|
|
262
|
+
if (taskData.type && EP_DN_MERGE_TERMINAL_CONSULT_EVENTS.has(taskData.type)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const interaction = taskData.interaction;
|
|
267
|
+
const mainCallId = interaction.mainInteractionId || taskData.interactionId;
|
|
268
|
+
if (!mainCallId) return false;
|
|
269
|
+
|
|
270
|
+
if (getConferenceParticipantsCount(interaction, mainCallId) > 1) return false;
|
|
271
|
+
|
|
272
|
+
const selfParticipant = interaction.participants?.[selfAgentId] as
|
|
273
|
+
| {consultState?: string}
|
|
274
|
+
| undefined;
|
|
275
|
+
if (taskData.isConsulted === true || selfParticipant?.consultState === 'consultCompleted') {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const mainParticipantIds = new Set(interaction.media?.[mainCallId]?.participants ?? []);
|
|
280
|
+
const hasEpDnOnConsultLegNotMain = Object.values(interaction.media ?? {}).some((media: any) => {
|
|
281
|
+
if (media?.mType !== MEDIA_TYPE_CONSULT) return false;
|
|
282
|
+
|
|
283
|
+
return (media.participants ?? []).some((participantId: string) => {
|
|
284
|
+
if (participantId === selfAgentId || mainParticipantIds.has(participantId)) return false;
|
|
285
|
+
const participant = interaction.participants?.[participantId] as
|
|
286
|
+
| {hasLeft?: boolean; pType?: string}
|
|
287
|
+
| undefined;
|
|
288
|
+
if (!participant || participant.hasLeft) return false;
|
|
289
|
+
|
|
290
|
+
return isEpDnParticipantType(participant.pType);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
if (!hasEpDnOnConsultLegNotMain) return false;
|
|
294
|
+
|
|
295
|
+
const callProcessingDetails = interaction.callProcessingDetails as
|
|
296
|
+
| {hasCustomerLeft?: string}
|
|
297
|
+
| undefined;
|
|
298
|
+
const customerLeft =
|
|
299
|
+
callProcessingDetails?.hasCustomerLeft === 'true' ||
|
|
300
|
+
!getIsCustomerInCall(interaction, mainCallId);
|
|
301
|
+
|
|
302
|
+
const conferenceFromPayload =
|
|
303
|
+
interaction.state === INTERACTION_STATE.CONFERENCE ||
|
|
304
|
+
getIsConferenceInProgress(taskData) ||
|
|
305
|
+
(interaction.state === INTERACTION_STATE.POST_CALL && customerLeft);
|
|
306
|
+
if (!conferenceFromPayload) return false;
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
taskData.consultingAgentId === selfAgentId ||
|
|
310
|
+
interaction.owner === selfAgentId ||
|
|
311
|
+
selfParticipant?.consultState === CONSULT_STATE.CONSULTING ||
|
|
312
|
+
selfParticipant?.consultState === CONSULT_STATE.CONFERENCING ||
|
|
313
|
+
selfParticipant?.consultState === 'consultInitiated'
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
86
317
|
/**
|
|
87
318
|
* Checks if the current agent is a secondary agent in a consultation scenario.
|
|
88
319
|
* Secondary agents are those who were consulted (not the original call owner).
|
|
@@ -104,17 +335,30 @@ export const isSecondaryAgent = (interaction: Interaction): boolean => {
|
|
|
104
335
|
/**
|
|
105
336
|
* Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
|
|
106
337
|
* This is specifically for telephony consultations to external numbers/entry points.
|
|
107
|
-
* @param
|
|
338
|
+
* @param interaction - The interaction object
|
|
108
339
|
* @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
|
|
109
340
|
*/
|
|
110
341
|
export const isSecondaryEpDnAgent = (interaction: Interaction): boolean => {
|
|
111
|
-
if (!interaction) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
342
|
return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction);
|
|
116
343
|
};
|
|
117
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Checks if the task belongs to a campaign preview interaction.
|
|
347
|
+
* Campaign preview ContactEnded events are terminal cleanup events and should not trigger wrapup.
|
|
348
|
+
*/
|
|
349
|
+
export const isCampaignPreviewTask = (taskData?: TaskData | null): boolean => {
|
|
350
|
+
const outboundType = taskData?.interaction?.outboundType ?? '';
|
|
351
|
+
const cpd = taskData?.interaction?.callProcessingDetails as unknown as
|
|
352
|
+
| Record<string, string | undefined>
|
|
353
|
+
| undefined;
|
|
354
|
+
const campaignType = cpd?.campaignType ?? '';
|
|
355
|
+
|
|
356
|
+
return (
|
|
357
|
+
CAMPAIGN_PREVIEW_OUTBOUND_TYPES.includes(outboundType) ||
|
|
358
|
+
CAMPAIGN_PREVIEW_CAMPAIGN_TYPES.includes(campaignType)
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
118
362
|
/**
|
|
119
363
|
* Checks if auto-answer is enabled for the agent participant
|
|
120
364
|
* @param interaction - The interaction object
|
|
@@ -221,6 +465,40 @@ export const shouldAutoAnswerTask = (
|
|
|
221
465
|
return false;
|
|
222
466
|
};
|
|
223
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Gets the consult media resource ID for switch-call operations.
|
|
470
|
+
* Searches for the consult media leg in the interaction.
|
|
471
|
+
*
|
|
472
|
+
* @param interaction - The interaction object
|
|
473
|
+
* @param consultMediaResourceId - The consult media resource ID from task data
|
|
474
|
+
* @param agentId - Current agent ID
|
|
475
|
+
* @returns The consult media resource ID or undefined
|
|
476
|
+
*/
|
|
477
|
+
export const getConsultMediaResourceId = (
|
|
478
|
+
interaction: Interaction | undefined,
|
|
479
|
+
consultMediaResourceId: string | undefined,
|
|
480
|
+
agentId: string | undefined
|
|
481
|
+
): string | undefined => {
|
|
482
|
+
// First priority: use consultMediaResourceId from task data if available
|
|
483
|
+
if (consultMediaResourceId) {
|
|
484
|
+
return consultMediaResourceId;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Second priority: search for consult media leg in interaction.media
|
|
488
|
+
if (!interaction?.media || !agentId) {
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Find the consult media leg where this agent is a participant
|
|
493
|
+
for (const [mediaId, media] of Object.entries(interaction.media)) {
|
|
494
|
+
if (media.mType === 'consult' && media.participants?.includes(agentId)) {
|
|
495
|
+
return mediaId;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return undefined;
|
|
500
|
+
};
|
|
501
|
+
|
|
224
502
|
/**
|
|
225
503
|
* Checks if a task is a campaign preview reservation that has not yet been accepted.
|
|
226
504
|
* Campaign preview tasks should not trigger incoming call handling until the agent
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {TaskState} from './state-machine/constants';
|
|
2
|
+
|
|
3
|
+
export type WebexCallingDeviceDetails = {
|
|
4
|
+
deviceType: string;
|
|
5
|
+
deviceId: string;
|
|
6
|
+
deviceCallId: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type WebexCallingParticipant = {
|
|
10
|
+
id?: unknown;
|
|
11
|
+
deviceType?: unknown;
|
|
12
|
+
deviceCallId?: unknown;
|
|
13
|
+
deviceId?: unknown;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const normalizeId = (id: unknown): string | undefined => {
|
|
17
|
+
if (typeof id !== 'string') {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const normalizedId = id.trim();
|
|
22
|
+
|
|
23
|
+
return normalizedId === '' ? undefined : normalizedId;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const isParticipantsById = (participants: unknown): participants is Record<string, unknown> =>
|
|
27
|
+
Boolean(participants) &&
|
|
28
|
+
typeof participants === 'object' &&
|
|
29
|
+
!Array.isArray(participants) &&
|
|
30
|
+
!(participants instanceof Map);
|
|
31
|
+
|
|
32
|
+
const hasWebexCallingDeviceDetails = (
|
|
33
|
+
participant: unknown
|
|
34
|
+
): participant is WebexCallingParticipant &
|
|
35
|
+
Pick<WebexCallingDeviceDetails, 'deviceCallId' | 'deviceId'> => {
|
|
36
|
+
const participantDetails = participant as WebexCallingParticipant | undefined;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
typeof participantDetails?.deviceCallId === 'string' &&
|
|
40
|
+
participantDetails.deviceCallId.trim() !== '' &&
|
|
41
|
+
typeof participantDetails?.deviceId === 'string' &&
|
|
42
|
+
participantDetails.deviceId.trim() !== ''
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const isWebexCallingParticipantForAgent = (
|
|
47
|
+
participant: unknown,
|
|
48
|
+
agentId: string
|
|
49
|
+
): participant is WebexCallingParticipant &
|
|
50
|
+
Pick<WebexCallingDeviceDetails, 'deviceCallId' | 'deviceId'> => {
|
|
51
|
+
const participantDetails = participant as WebexCallingParticipant | undefined;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
normalizeId(participantDetails?.id) === agentId && hasWebexCallingDeviceDetails(participant)
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getWebexCallingDeviceDetails = (
|
|
59
|
+
participant: WebexCallingParticipant &
|
|
60
|
+
Pick<WebexCallingDeviceDetails, 'deviceCallId' | 'deviceId'>
|
|
61
|
+
): WebexCallingDeviceDetails => ({
|
|
62
|
+
deviceType: typeof participant.deviceType === 'string' ? participant.deviceType : '',
|
|
63
|
+
deviceId: participant.deviceId,
|
|
64
|
+
deviceCallId: participant.deviceCallId,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export function getWebexCallingDeviceDetailsForAgent(
|
|
68
|
+
agentId: string | undefined,
|
|
69
|
+
participants: unknown
|
|
70
|
+
): WebexCallingDeviceDetails | undefined {
|
|
71
|
+
const normalizedAgentId = normalizeId(agentId);
|
|
72
|
+
if (!normalizedAgentId || !isParticipantsById(participants)) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const agentParticipant = participants[normalizedAgentId];
|
|
77
|
+
const matchingAgentParticipant = hasWebexCallingDeviceDetails(agentParticipant)
|
|
78
|
+
? agentParticipant
|
|
79
|
+
: Object.values(participants).find((participant) =>
|
|
80
|
+
isWebexCallingParticipantForAgent(participant, normalizedAgentId)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (!matchingAgentParticipant || !hasWebexCallingDeviceDetails(matchingAgentParticipant)) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return getWebexCallingDeviceDetails(matchingAgentParticipant);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function isWebexCallingCallForAgent(
|
|
91
|
+
agentId: string | undefined,
|
|
92
|
+
participants: unknown
|
|
93
|
+
): boolean {
|
|
94
|
+
return Boolean(getWebexCallingDeviceDetailsForAgent(agentId, participants));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Matches wxAppVoiceMethods.getWebexCallingCallId engaged semantics for uiControls. */
|
|
98
|
+
export function isWxAppEngagedForControls(
|
|
99
|
+
enableWxBetterTogether: boolean,
|
|
100
|
+
agentId: string | undefined,
|
|
101
|
+
participants: unknown,
|
|
102
|
+
state: TaskState
|
|
103
|
+
): boolean {
|
|
104
|
+
if (!enableWxBetterTogether) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (
|
|
109
|
+
!state ||
|
|
110
|
+
state === TaskState.OFFERED ||
|
|
111
|
+
state === TaskState.IDLE ||
|
|
112
|
+
state === TaskState.WRAPPING_UP ||
|
|
113
|
+
state === TaskState.TERMINATED ||
|
|
114
|
+
state === TaskState.COMPLETED
|
|
115
|
+
) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const details = getWebexCallingDeviceDetailsForAgent(agentId, participants);
|
|
120
|
+
|
|
121
|
+
return details?.deviceType === 'wxApp';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function decodedLineOwnerId(lineOwnerId?: string): string | undefined {
|
|
125
|
+
if (!lineOwnerId) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
const decoded = atob(lineOwnerId);
|
|
131
|
+
|
|
132
|
+
return decoded.split('/').pop();
|
|
133
|
+
} catch {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|