@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.
- package/.sdd/manifest.json +883 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +50 -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 +48 -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 +359 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -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 +818 -59
- 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 +27 -5
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +127 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +34 -3
- 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 +174 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +318 -0
- package/dist/services/ApiAiAssistant.js.map +1 -0
- 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 +171 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +93 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/agent/types.js.map +1 -1
- package/dist/services/config/Util.js +11 -4
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +45 -8
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +41 -2
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +70 -8
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +27 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +122 -25
- 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 +119 -30
- 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 +22 -6
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/connection-service.js +3 -1
- package/dist/services/core/websocket/connection-service.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +6 -0
- 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 +1073 -447
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +220 -23
- 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 +26 -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 +129 -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 +971 -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 +409 -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 +243 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1380 -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 +201 -0
- package/dist/services/task/voice/wxAppVoiceMethods.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 +967 -0
- package/dist/types/config.d.ts +79 -0
- package/dist/types/constants.d.ts +74 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/types/logger-proxy.d.ts +71 -0
- package/dist/types/metrics/MetricsManager.d.ts +223 -0
- package/dist/types/metrics/behavioral-events.d.ts +29 -0
- package/dist/types/metrics/constants.d.ts +183 -0
- package/dist/types/services/AddressBook.d.ts +75 -0
- package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
- package/dist/types/services/ApiAiAssistant.d.ts +49 -0
- package/dist/types/services/EntryPoint.d.ts +69 -0
- package/dist/types/services/Queue.d.ts +78 -0
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebCallingService.d.ts +1 -0
- package/dist/types/services/WebexCrossClientService.d.ts +28 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/agent/index.d.ts +46 -0
- package/dist/types/services/agent/types.d.ts +413 -0
- package/dist/types/services/config/Util.d.ts +20 -0
- package/dist/types/services/config/constants.d.ts +273 -0
- package/dist/types/services/config/index.d.ts +177 -0
- package/dist/types/services/config/types.d.ts +1381 -0
- package/dist/types/services/constants.d.ts +110 -0
- package/dist/types/services/core/Err.d.ts +127 -0
- package/dist/types/services/core/GlobalTypes.d.ts +58 -0
- package/dist/types/services/core/Utils.d.ts +121 -0
- package/dist/types/services/core/WebexRequest.d.ts +23 -0
- package/dist/types/services/core/aqm-reqs.d.ts +65 -0
- package/dist/types/services/core/constants.d.ts +99 -0
- package/dist/types/services/core/types.d.ts +49 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
- package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
- package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +37 -0
- package/dist/types/services/index.d.ts +54 -0
- package/dist/types/services/task/AutoWrapup.d.ts +40 -0
- 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/TaskManager.d.ts +1 -0
- package/dist/types/services/task/TaskUtils.d.ts +138 -0
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +94 -0
- package/dist/types/services/task/contact.d.ts +73 -0
- package/dist/types/services/task/dialer.d.ts +73 -0
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1398 -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 +1933 -0
- package/dist/types/services/task/voice/Voice.d.ts +223 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +784 -0
- package/dist/types/utils/PageCache.d.ts +190 -0
- package/dist/types/webex-config.d.ts +53 -0
- package/dist/types/webex.d.ts +8 -0
- package/dist/types.js +137 -3
- 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 +14 -2
- package/dist/webex.js.map +1 -1
- package/package.json +16 -12
- package/src/cc.ts +983 -60
- package/src/config.ts +13 -0
- package/src/constants.ts +29 -1
- package/src/index.ts +26 -5
- 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 +860 -0
- package/src/metrics/behavioral-events.ts +134 -0
- package/src/metrics/constants.ts +39 -3
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +206 -0
- package/src/services/ApiAiAssistant.ts +412 -0
- 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 +212 -0
- package/src/services/WxAppTelephonyMercurySync.ts +115 -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 +504 -0
- package/src/services/agent/types.ts +1 -1
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +497 -0
- package/src/services/config/Util.ts +13 -2
- 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 +675 -0
- package/src/services/config/constants.ts +47 -7
- package/src/services/config/index.ts +45 -1
- package/src/services/config/types.ts +253 -11
- package/src/services/constants.ts +29 -0
- package/src/services/core/Err.ts +4 -0
- package/src/services/core/Utils.ts +143 -30
- 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 +125 -32
- package/src/services/core/types.ts +2 -0
- package/src/services/core/websocket/WebSocketManager.ts +23 -6
- package/src/services/core/websocket/connection-service.ts +5 -1
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +4 -0
- package/src/services/task/Task.ts +908 -0
- package/src/services/task/TaskFactory.ts +60 -0
- package/src/services/task/TaskManager.ts +1291 -513
- package/src/services/task/TaskUtils.ts +314 -24
- 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 +1469 -0
- package/src/services/task/constants.ts +26 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +136 -1
- package/src/services/task/digital/Digital.ts +97 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1313 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +462 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1146 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2209 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +498 -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 +843 -70
- package/src/services/task/voice/Voice.ts +1720 -0
- package/src/services/task/voice/WebRTC.ts +191 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +238 -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 +2 -0
- package/test/unit/spec/cc.ts +1856 -122
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/behavioral-events.ts +18 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
- 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 +261 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
- package/test/unit/spec/services/config/Util.ts +85 -0
- package/test/unit/spec/services/config/index.ts +85 -29
- package/test/unit/spec/services/core/Utils.ts +481 -2
- 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 +137 -41
- package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +677 -0
- package/test/unit/spec/services/task/TaskFactory.ts +99 -0
- package/test/unit/spec/services/task/TaskManager.ts +2209 -918
- 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 +372 -96
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +3433 -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 +1523 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -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/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","_constants","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getCommonErrorDetails","errObj","trackingId","headers","trackingid","TrackingID","msg","body","isEntryPointOrEpdn","destAgentType","getAgentActionTypeFromTask","taskData","destinationType","isDialNumber","isEntryPointVariant","isValidDialNumber","input","regexForDn","test","exports","getStationLoginErrorData","failure","loginOption","duplicateLocationMessage","LoginOption","EXTENSION","AGENT_DN","errorCodeMessageMap","DUPLICATE_LOCATION","message","fieldName","INVALID_DIAL_NUMBER","defaultMessage","defaultFieldName","reason","data","getErrorDetails","error","methodName","moduleName","errData","details","LoggerProxy","module","method","WebexRequest","getInstance","uploadLogs","correlationId","err","Error","generateTaskErrorObject","errorMsg","fallbackMessage","errorMessage","errorType","name","errorData","reasonCode","createErrDetailsObject","Details","getConsultedAgentId","media","agentId","consultParticipants","consultedParticipantId","keys","forEach","key","mType","STATE_CONSULT","participants","includes","id","find","participant","getDestAgentIdForCBT","interaction","consultingAgent","destAgentIdForCBT","foundEntry","entries","pType","toLowerCase","PARTICIPANT_TYPES","DN","type","AGENT","dn","calculateDestAgentId","destAgentIdCBT","EP_DN","epId","calculateDestType","destinationaegntId","undefined","CONSULT_TRANSFER_DESTINATION_TYPE","DIALNUMBER","ENTRYPOINT","deriveConsultTransferDestinationType","agentActionType"],"sources":["Utils.ts"],"sourcesContent":["import * as Err from './Err';\nimport {LoginOption, WebexRequestPayload} from '../../types';\nimport {Failure, AugmentedError} from './GlobalTypes';\nimport LoggerProxy from '../../logger-proxy';\nimport WebexRequest from './WebexRequest';\nimport {\n TaskData,\n ConsultTransferPayLoad,\n CONSULT_TRANSFER_DESTINATION_TYPE,\n Interaction,\n} from '../task/types';\nimport {PARTICIPANT_TYPES, STATE_CONSULT} from './constants';\n\n/**\n * Extracts common error details from a Webex request payload.\n *\n * @param errObj - The Webex request payload object.\n * @returns An object containing the tracking ID and message body.\n * @private\n * @ignore\n */\nconst getCommonErrorDetails = (errObj: WebexRequestPayload) => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body,\n };\n};\n\n/**\n * Checks if the destination type represents an entry point variant (EPDN or ENTRYPOINT).\n */\nconst isEntryPointOrEpdn = (destAgentType?: string): boolean => {\n return destAgentType === 'EPDN' || destAgentType === 'ENTRYPOINT';\n};\n\n/**\n * Determines if the task involves dialing a number based on the destination type.\n * Returns 'DIAL_NUMBER' for dial-related destinations, empty string otherwise.\n */\nconst getAgentActionTypeFromTask = (taskData?: TaskData): 'DIAL_NUMBER' | '' => {\n const destAgentType = taskData?.destinationType;\n\n // Check if destination requires dialing: direct dial number or entry point variants\n const isDialNumber = destAgentType === 'DN';\n const isEntryPointVariant = isEntryPointOrEpdn(destAgentType);\n\n // If the destination type is a dial number or an entry point variant, return 'DIAL_NUMBER'\n return isDialNumber || isEntryPointVariant ? 'DIAL_NUMBER' : '';\n};\n\nexport const isValidDialNumber = (input: string): boolean => {\n // This regex checks for a valid dial number format for only few countries such as US, Canada.\n const regexForDn = /1[0-9]{3}[2-9][0-9]{6}([,]{1,10}[0-9]+){0,1}/;\n\n return regexForDn.test(input);\n};\n\nexport const getStationLoginErrorData = (failure: Failure, loginOption: LoginOption) => {\n let duplicateLocationMessage = 'This value is already in use';\n\n if (loginOption === LoginOption.EXTENSION) {\n duplicateLocationMessage = 'This extension is already in use';\n }\n\n if (loginOption === LoginOption.AGENT_DN) {\n duplicateLocationMessage =\n 'Dial number is in use. Try a different one. For help, reach out to your administrator or support team.';\n }\n\n const errorCodeMessageMap = {\n DUPLICATE_LOCATION: {\n message: duplicateLocationMessage,\n fieldName: loginOption,\n },\n INVALID_DIAL_NUMBER: {\n message:\n 'Enter a valid US dial number. For help, reach out to your administrator or support team.',\n fieldName: loginOption,\n },\n };\n\n const defaultMessage = 'An error occurred while logging in to the station';\n const defaultFieldName = 'generic';\n\n const reason = failure?.data?.reason || '';\n\n return {\n message: errorCodeMessageMap[reason]?.message || defaultMessage,\n fieldName: errorCodeMessageMap[reason]?.fieldName || defaultFieldName,\n };\n};\n\n/**\n * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.\n *\n * @param error - The error object, expected to have a `details` property of type Failure.\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns An object containing the error instance and the reason string.\n * @public\n * @example\n * const details = getErrorDetails(error, 'fetchData', 'DataModule');\n * if (details.error) { handleError(details.error); }\n * @ignore\n */\nexport const getErrorDetails = (error: any, methodName: string, moduleName: string) => {\n let errData = {message: '', fieldName: ''};\n\n const failure = error.details as Failure;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentRelogin')) {\n LoggerProxy.error(`${methodName} failed with reason: ${reason}`, {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n });\n // we can add more conditions here if not needed for specific cases eg: silentReLogin\n WebexRequest.getInstance().uploadLogs({\n correlationId: failure?.trackingId,\n });\n }\n\n if (methodName === 'stationLogin') {\n errData = getStationLoginErrorData(failure, error.loginOption);\n\n LoggerProxy.error(\n `${methodName} failed with reason: ${reason}, message: ${errData.message}, fieldName: ${errData.fieldName}`,\n {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n }\n );\n }\n\n const err = new Error(reason ?? `Error while performing ${methodName}`);\n // @ts-ignore - add custom property to the error object for backward compatibility\n err.data = errData;\n\n return {\n error: err,\n reason,\n };\n};\n\n/**\n * Extracts error details from task API errors and logs them. Also uploads logs for the error.\n * This handles the specific error format returned by task API calls.\n *\n * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns AugmentedError containing structured error details on err.data for metrics and logging\n * @public\n * @example\n * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');\n * throw taskError.error;\n * @ignore\n */\nexport const generateTaskErrorObject = (\n error: any,\n methodName: string,\n moduleName: string\n): AugmentedError => {\n const trackingId = error?.details?.trackingId || error?.trackingId || '';\n const errorMsg = error?.details?.msg;\n\n const fallbackMessage =\n (error && typeof error.message === 'string' && error.message) ||\n `Error while performing ${methodName}`;\n const errorMessage = errorMsg?.errorMessage || fallbackMessage;\n const errorType =\n errorMsg?.errorType ||\n (error && typeof error.name === 'string' && error.name) ||\n 'Unknown Error';\n const errorData = errorMsg?.errorData || '';\n const reasonCode = errorMsg?.reasonCode || 0;\n\n // Log and upload for Task API formatted errors\n LoggerProxy.error(`${methodName} failed: ${errorMessage} (${errorType})`, {\n module: moduleName,\n method: methodName,\n trackingId,\n });\n WebexRequest.getInstance().uploadLogs({\n correlationId: trackingId,\n });\n\n const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;\n const err: AugmentedError = new Error(reason);\n err.data = {\n message: errorMessage,\n errorType,\n errorData,\n reasonCode,\n trackingId,\n };\n\n return err;\n};\n\n/**\n * Creates an error details object suitable for use with the Err.Details class.\n *\n * @param errObj - The Webex request payload object.\n * @returns An instance of Err.Details with the generic failure message and extracted details.\n * @public\n * @example\n * const errDetails = createErrDetailsObject(webexRequestPayload);\n * @ignore\n */\nexport const createErrDetailsObject = (errObj: WebexRequestPayload) => {\n const details = getCommonErrorDetails(errObj);\n\n return new Err.Details('Service.reqs.generic.failure', details);\n};\n\n/**\n * Gets the consulted agent ID from the media object by finding the agent\n * in the consult media participants (excluding the current agent).\n *\n * @param media - The media object from the interaction\n * @param agentId - The current agent's ID to exclude from the search\n * @returns The consulted agent ID, or empty string if none found\n */\nexport const getConsultedAgentId = (media: Interaction['media'], agentId: string): string => {\n let consultParticipants: string[] = [];\n let consultedParticipantId = '';\n\n Object.keys(media).forEach((key) => {\n if (media[key].mType === STATE_CONSULT) {\n consultParticipants = media[key].participants;\n }\n });\n\n if (consultParticipants.includes(agentId)) {\n const id = consultParticipants.find((participant) => participant !== agentId);\n consultedParticipantId = id || consultedParticipantId;\n }\n\n return consultedParticipantId;\n};\n\n/**\n * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.\n * CBT refers to teams created in Control Hub with capacity-based routing\n * (as opposed to agent-based routing). This handles cases where the consulted\n * participant is not directly in participants but can be found by matching\n * the dial number (dn).\n *\n * @param interaction - The interaction object\n * @param consultingAgent - The consulting agent identifier\n * @returns The destination agent ID for CBT scenarios, or empty string if none found\n */\nexport const getDestAgentIdForCBT = (interaction: Interaction, consultingAgent: string): string => {\n const participants = interaction.participants;\n let destAgentIdForCBT = '';\n\n // Check if this is a CBT scenario (consultingAgent exists but not directly in participants)\n if (consultingAgent && !participants[consultingAgent]) {\n const foundEntry = Object.entries(participants).find(\n ([, participant]: [string, Interaction['participants'][string]]) => {\n return (\n participant.pType.toLowerCase() === PARTICIPANT_TYPES.DN &&\n participant.type === PARTICIPANT_TYPES.AGENT &&\n participant.dn === consultingAgent\n );\n }\n );\n\n if (foundEntry) {\n destAgentIdForCBT = foundEntry[0];\n }\n }\n\n return destAgentIdForCBT;\n};\n\n/**\n * Calculates the destination agent ID for consult operations.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID\n */\nexport const calculateDestAgentId = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario\n // If not CBT, the function will return empty string and we'll use the normal flow\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n if (destAgentIdCBT) {\n return destAgentIdCBT;\n }\n\n return interaction.participants[consultingAgent]?.type === PARTICIPANT_TYPES.EP_DN\n ? interaction.participants[consultingAgent]?.epId\n : interaction.participants[consultingAgent]?.id;\n};\n\n/**\n * Calculates the destination agent ID for fetching destination type.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID for determining destination type\n */\nexport const calculateDestType = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario, otherwise use consultingAgent\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n const destinationaegntId = destAgentIdCBT || consultingAgent;\n const destAgentType = destinationaegntId\n ? interaction.participants[destinationaegntId]?.pType\n : undefined;\n if (destAgentType) {\n if (destAgentType === 'DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (destAgentType === 'EP-DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n // Keep the existing destinationType if it's something else (like \"agent\" or \"Agent\")\n // Convert \"Agent\" to lowercase for consistency\n\n return destAgentType.toLowerCase();\n }\n\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n\nexport const deriveConsultTransferDestinationType = (\n taskData?: TaskData\n): ConsultTransferPayLoad['destinationType'] => {\n const agentActionType = getAgentActionTypeFromTask(taskData);\n\n if (agentActionType === 'DIAL_NUMBER') {\n return isEntryPointOrEpdn(taskData?.destinationType)\n ? CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT\n : CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\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,CAAC0E,WAAW,CAAC,CAAC;EACpC;EAEA,OAAOa,yCAAiC,CAACT,KAAK;AAChD,CAAC;AAACpE,OAAA,CAAA0E,iBAAA,GAAAA,iBAAA;AAEK,MAAMM,oCAAoC,GAC/CxF,QAAmB,IAC2B;EAC9C,MAAMyF,eAAe,GAAG1F,0BAA0B,CAACC,QAAQ,CAAC;EAE5D,IAAIyF,eAAe,KAAK,aAAa,EAAE;IACrC,OAAO5F,kBAAkB,CAACG,QAAQ,EAAEC,eAAe,CAAC,GAChDoF,yCAAiC,CAACE,UAAU,GAC5CF,yCAAiC,CAACC,UAAU;EAClD;EAEA,OAAOD,yCAAiC,CAACT,KAAK;AAChD,CAAC;AAACpE,OAAA,CAAAgF,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","_constants","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getCommonErrorDetails","errObj","trackingId","headers","trackingid","TrackingID","msg","body","stripDialPlanChars","input","strippedChars","charsToStrip","Set","split","filter","c","join","exports","isValidDialNumber","dialPlanEntries","LoggerProxy","warn","module","method","length","log","some","entry","sanitizedInput","regex","RegExp","test","name","getStationLoginErrorData","failure","loginOption","duplicateLocationMessage","LoginOption","EXTENSION","AGENT_DN","errorCodeMessageMap","DUPLICATE_LOCATION","message","fieldName","INVALID_DIAL_NUMBER","defaultMessage","defaultFieldName","reason","data","getErrorDetails","error","methodName","moduleName","errData","details","WebexRequest","getInstance","uploadLogs","correlationId","err","Error","generateTaskErrorObject","errorMsg","fallbackMessage","errorMessage","errorType","errorData","reasonCode","createErrDetailsObject","Details","getConsultedAgentId","media","agentId","consultParticipants","consultedParticipantId","keys","forEach","key","mType","STATE_CONSULT","participants","includes","id","find","participant","getDestAgentIdForCBT","interaction","consultingAgent","destAgentIdForCBT","foundEntry","entries","pType","toLowerCase","PARTICIPANT_TYPES","DN","type","AGENT","dn","calculateDestAgentId","destAgentIdCBT","EP_DN","epId","calculateDestType","destinationaegntId","destAgentType","undefined","CONSULT_TRANSFER_DESTINATION_TYPE","DIALNUMBER","ENTRYPOINT","buildConsultConferenceParamData","dataPassed","interactionIdPassed","to","destAgentId","destinationType","String","trim","normalizedDestinationType","toUpperCase","replace","DESTINATION_TYPE","QUEUE","interactionId","deriveConsultTransferDestinationType","taskData","destType","normalizedDestType"],"sources":["Utils.ts"],"sourcesContent":["import * as Err from './Err';\nimport {LoginOption, WebexRequestPayload} from '../../types';\nimport {Failure, AugmentedError} from './GlobalTypes';\nimport LoggerProxy from '../../logger-proxy';\nimport WebexRequest from './WebexRequest';\nimport {\n ConsultConferenceData,\n consultConferencePayloadData,\n ConsultTransferDestinationType,\n TaskData,\n CONSULT_TRANSFER_DESTINATION_TYPE,\n DESTINATION_TYPE,\n Interaction,\n InteractionParticipant,\n} from '../task/types';\nimport {PARTICIPANT_TYPES, STATE_CONSULT} from './constants';\nimport {DialPlan} from '../config/types';\n\n/**\n * Extracts common error details from a Webex request payload.\n *\n * @param errObj - The Webex request payload object.\n * @returns An object containing the tracking ID and message body.\n * @private\n * @ignore\n */\nconst getCommonErrorDetails = (errObj: WebexRequestPayload) => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body,\n };\n};\n\n/**\n * Strips characters defined in the dial plan entry from the input string.\n *\n * @param input - The dial number to sanitize\n * @param strippedChars - String of characters to remove from the input\n * @returns The sanitized input with specified characters removed\n */\nexport const stripDialPlanChars = (input: string, strippedChars: string): string => {\n if (!strippedChars) {\n return input;\n }\n\n const charsToStrip = new Set(strippedChars.split(''));\n\n return input\n .split('')\n .filter((c) => !charsToStrip.has(c))\n .join('');\n};\n\n/**\n * Validates a dial number against the provided dial plan regex patterns.\n * A number is valid if it matches at least one regex pattern in the dial plans.\n * Skips validation when no dial plan entries are configured, deferring to the server.\n *\n * @param input - The dial number to validate\n * @param dialPlanEntries - Array of dial plan entries containing regex patterns\n * @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise\n */\nexport const isValidDialNumber = (\n input: string,\n dialPlanEntries: DialPlan['dialPlanEntity']\n): boolean => {\n if (!input) {\n LoggerProxy.warn('Dial number is empty or undefined.', {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n\n if (!dialPlanEntries || dialPlanEntries.length === 0) {\n LoggerProxy.log(\n 'No dial plan entries found. Skipping client-side validation, deferring to server.',\n {module: 'Utils', method: 'isValidDialNumber'}\n );\n\n return true;\n }\n\n return dialPlanEntries.some((entry) => {\n try {\n const sanitizedInput = stripDialPlanChars(input, entry.strippedChars);\n const regex = new RegExp(entry.regex);\n\n return regex.test(sanitizedInput);\n } catch (e) {\n LoggerProxy.warn(`Failed to validate dial number against entry \"${entry.name}\": ${e}`, {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n });\n};\n\nexport const getStationLoginErrorData = (failure: Failure, loginOption: LoginOption) => {\n let duplicateLocationMessage = 'This value is already in use';\n\n if (loginOption === LoginOption.EXTENSION) {\n duplicateLocationMessage = 'This extension is already in use';\n }\n\n if (loginOption === LoginOption.AGENT_DN) {\n duplicateLocationMessage =\n 'Dial number is in use. Try a different one. For help, reach out to your administrator or support team.';\n }\n\n const errorCodeMessageMap = {\n DUPLICATE_LOCATION: {\n message: duplicateLocationMessage,\n fieldName: loginOption,\n },\n INVALID_DIAL_NUMBER: {\n message:\n 'Enter a valid dial number. For help, reach out to your administrator or support team.',\n fieldName: loginOption,\n },\n };\n\n const defaultMessage = 'An error occurred while logging in to the station';\n const defaultFieldName = 'generic';\n\n const reason = failure?.data?.reason || '';\n\n return {\n message: errorCodeMessageMap[reason]?.message || defaultMessage,\n fieldName: errorCodeMessageMap[reason]?.fieldName || defaultFieldName,\n };\n};\n\n/**\n * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.\n *\n * @param error - The error object, expected to have a `details` property of type Failure.\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns An object containing the error instance and the reason string.\n * @public\n * @example\n * const details = getErrorDetails(error, 'fetchData', 'DataModule');\n * if (details.error) { handleError(details.error); }\n * @ignore\n */\nexport const getErrorDetails = (error: any, methodName: string, moduleName: string) => {\n let errData = {message: '', fieldName: ''};\n\n const failure = error.details as Failure;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentRelogin')) {\n LoggerProxy.error(`${methodName} failed with reason: ${reason}`, {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n });\n // we can add more conditions here if not needed for specific cases eg: silentReLogin\n WebexRequest.getInstance().uploadLogs({\n correlationId: failure?.trackingId,\n });\n }\n\n if (methodName === 'stationLogin') {\n errData = getStationLoginErrorData(failure, error.loginOption);\n\n LoggerProxy.error(\n `${methodName} failed with reason: ${reason}, message: ${errData.message}, fieldName: ${errData.fieldName}`,\n {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n }\n );\n }\n\n const err = new Error(reason ?? `Error while performing ${methodName}`);\n // @ts-ignore - add custom property to the error object for backward compatibility\n err.data = errData;\n\n return {\n error: err,\n reason,\n };\n};\n\n/**\n * Extracts error details from task API errors and logs them. Also uploads logs for the error.\n * This handles the specific error format returned by task API calls.\n *\n * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns AugmentedError containing structured error details on err.data for metrics and logging\n * @public\n * @example\n * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');\n * throw taskError.error;\n * @ignore\n */\nexport const generateTaskErrorObject = (\n error: any,\n methodName: string,\n moduleName: string\n): AugmentedError => {\n const trackingId = error?.details?.trackingId || error?.trackingId || '';\n const errorMsg = error?.details?.msg;\n\n const fallbackMessage =\n (error && typeof error.message === 'string' && error.message) ||\n `Error while performing ${methodName}`;\n const errorMessage = errorMsg?.errorMessage || fallbackMessage;\n const errorType =\n errorMsg?.errorType ||\n (error && typeof error.name === 'string' && error.name) ||\n 'Unknown Error';\n const errorData = errorMsg?.errorData || '';\n const reasonCode = errorMsg?.reasonCode || 0;\n\n // Log and upload for Task API formatted errors\n LoggerProxy.error(`${methodName} failed: ${errorMessage} (${errorType})`, {\n module: moduleName,\n method: methodName,\n trackingId,\n });\n WebexRequest.getInstance().uploadLogs({\n correlationId: trackingId,\n });\n\n const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;\n const err: AugmentedError = new Error(reason);\n err.data = {\n message: errorMessage,\n errorType,\n errorData,\n reasonCode,\n trackingId,\n };\n\n return err;\n};\n\n/**\n * Creates an error details object suitable for use with the Err.Details class.\n *\n * @param errObj - The Webex request payload object.\n * @returns An instance of Err.Details with the generic failure message and extracted details.\n * @public\n * @example\n * const errDetails = createErrDetailsObject(webexRequestPayload);\n * @ignore\n */\nexport const createErrDetailsObject = (errObj: WebexRequestPayload) => {\n const details = getCommonErrorDetails(errObj);\n\n return new Err.Details('Service.reqs.generic.failure', details);\n};\n\n/*\n/**\n * Gets the consulted agent ID from the media object by finding the agent\n * in the consult media participants (excluding the current agent).\n *\n * @param media - The media object from the interaction\n * @param agentId - The current agent's ID to exclude from the search\n * @returns The consulted agent ID, or empty string if none found\n */\nexport const getConsultedAgentId = (media: Interaction['media'], agentId: string): string => {\n let consultParticipants: string[] = [];\n let consultedParticipantId = '';\n\n Object.keys(media).forEach((key) => {\n if (media[key].mType === STATE_CONSULT) {\n consultParticipants = media[key].participants;\n }\n });\n\n if (consultParticipants.includes(agentId)) {\n const id = consultParticipants.find((participant) => participant !== agentId);\n consultedParticipantId = id || consultedParticipantId;\n }\n\n return consultedParticipantId;\n};\n\n/**\n * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.\n * CBT refers to teams created in Control Hub with capacity-based routing\n * (as opposed to agent-based routing). This handles cases where the consulted\n * participant is not directly in participants but can be found by matching\n * the dial number (dn).\n *\n * @param interaction - The interaction object\n * @param consultingAgent - The consulting agent identifier\n * @returns The destination agent ID for CBT scenarios, or empty string if none found\n */\nexport const getDestAgentIdForCBT = (interaction: Interaction, consultingAgent: string): string => {\n const participants = interaction.participants;\n let destAgentIdForCBT = '';\n\n // Check if this is a CBT scenario (consultingAgent exists but not directly in participants)\n if (consultingAgent && !participants[consultingAgent]) {\n const foundEntry = Object.entries(participants).find(\n ([, participant]: [string, Interaction['participants'][string]]) => {\n return (\n participant.pType.toLowerCase() === PARTICIPANT_TYPES.DN &&\n participant.type === PARTICIPANT_TYPES.AGENT &&\n participant.dn === consultingAgent\n );\n }\n );\n\n if (foundEntry) {\n destAgentIdForCBT = foundEntry[0];\n }\n }\n\n return destAgentIdForCBT;\n};\n\n/**\n * Calculates the destination agent ID for consult operations.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID\n */\nexport const calculateDestAgentId = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario\n // If not CBT, the function will return empty string and we'll use the normal flow\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n if (destAgentIdCBT) {\n return destAgentIdCBT;\n }\n\n const participant = interaction.participants[consultingAgent];\n if (!participant) {\n return '';\n }\n\n if (participant.type === PARTICIPANT_TYPES.EP_DN) {\n return (participant as InteractionParticipant & {epId?: string}).epId ?? '';\n }\n\n return participant.id ?? '';\n};\n\n/**\n * Calculates the destination agent ID for fetching destination type.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID for determining destination type\n */\nexport const calculateDestType = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario, otherwise use consultingAgent\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n const destinationaegntId = destAgentIdCBT || consultingAgent;\n const destAgentType = destinationaegntId\n ? interaction.participants[destinationaegntId]?.pType\n : undefined;\n if (destAgentType) {\n if (destAgentType === 'DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (destAgentType === 'EP-DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n // Keep the existing destinationType if it's something else (like \"agent\" or \"Agent\")\n // Convert \"Agent\" to lowercase for consistency\n\n return destAgentType.toLowerCase();\n }\n\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n\n/**\n * Gets the destination agent ID from participants.\n * Finds a participant who is not the current agent and is an agent type.\n *\n * @param participants - The participants object from interaction\n * @param agentId - The current agent's ID\n * @returns The destination agent ID, or undefined if none found\n */\nexport const buildConsultConferenceParamData = (\n dataPassed: consultConferencePayloadData,\n interactionIdPassed: string\n): {interactionId: string; data: ConsultConferenceData} => {\n const data: ConsultConferenceData = {\n ...('agentId' in dataPassed && {agentId: dataPassed.agentId}),\n to: dataPassed.destAgentId,\n destinationType: '',\n };\n\n if ('destinationType' in dataPassed) {\n const destinationType = String(dataPassed.destinationType || '').trim();\n const normalizedDestinationType = destinationType.toUpperCase().replace(/[-_\\s]/g, '');\n\n if (normalizedDestinationType === 'DN' || normalizedDestinationType === 'DIALNUMBER') {\n data.destinationType = DESTINATION_TYPE.DIALNUMBER;\n } else if (normalizedDestinationType === 'EPDN' || normalizedDestinationType === 'ENTRYPOINT') {\n data.destinationType = DESTINATION_TYPE.ENTRYPOINT;\n } else if (normalizedDestinationType === 'QUEUE') {\n data.destinationType = DESTINATION_TYPE.QUEUE;\n } else if (normalizedDestinationType === 'AGENT') {\n data.destinationType = DESTINATION_TYPE.AGENT;\n } else {\n data.destinationType = destinationType as ConsultConferenceData['destinationType'];\n }\n } else {\n data.destinationType = DESTINATION_TYPE.AGENT;\n }\n\n return {\n interactionId: interactionIdPassed,\n data,\n };\n};\n\n/**\n * Derives the consult transfer destination type based on task data.\n * This function determines the appropriate destination type for a consult transfer\n * by examining the destination type stored in the task data.\n *\n * @param taskData - The task data containing destination information\n * @returns The derived consult transfer destination type\n * @public\n */\nexport const deriveConsultTransferDestinationType = (\n taskData: TaskData\n): ConsultTransferDestinationType => {\n const destType = taskData?.destinationType;\n const normalizedDestType = String(destType || '')\n .toUpperCase()\n .replace(/[-_\\s]/g, '');\n\n // Map destination types to consult transfer destination types\n if (normalizedDestType === 'DN' || normalizedDestType === 'DIALNUMBER') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (normalizedDestType === 'EPDN' || normalizedDestType === 'ENTRYPOINT') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n if (normalizedDestType === 'QUEUE') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE;\n }\n\n // Default to agent if no specific type matches\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAUA,IAAAM,UAAA,GAAAN,OAAA;AAA6D,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,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
|
|
28
28
|
service,
|
|
29
29
|
resource,
|
|
30
30
|
method,
|
|
31
|
-
body
|
|
31
|
+
body,
|
|
32
|
+
headers
|
|
32
33
|
} = options;
|
|
33
34
|
return this.webex.request({
|
|
34
35
|
service,
|
|
35
36
|
resource,
|
|
36
37
|
method,
|
|
37
|
-
body
|
|
38
|
+
body,
|
|
39
|
+
...(headers ? {
|
|
40
|
+
headers
|
|
41
|
+
} : {})
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_constants","require","_loggerProxy","_interopRequireDefault","_constants2","_constants3","_MetricsManager","e","__esModule","default","WebexRequest","getInstance","options","instance","webex","constructor","request","service","resource","method","body","uploadLogs","metaData","feedbackId","crypto","randomUUID","response","internal","support","submitLogs","undefined","type","LoggerProxy","info","module","WEBEX_REQUEST_FILE","METHODS","UPLOAD_LOGS","MetricsManager","trackEvent","METRIC_EVENT_NAMES","UPLOAD_LOGS_SUCCESS","trackingId","trackingid","correlationId","url","userId","error","UPLOAD_LOGS_FAILED","stack","_default","exports"],"sources":["WebexRequest.ts"],"sourcesContent":["import {WEBEX_REQUEST_FILE} from '../../constants';\nimport LoggerProxy from '../../logger-proxy';\nimport {METHODS} from './constants';\nimport {METRIC_EVENT_NAMES} from '../../metrics/constants';\nimport MetricsManager from '../../metrics/MetricsManager';\nimport {\n WebexSDK,\n HTTP_METHODS,\n IHttpResponse,\n RequestBody,\n UploadLogsResponse,\n LogsMetaData,\n} from '../../types';\n\nclass WebexRequest {\n private webex: WebexSDK;\n private static instance: WebexRequest;\n\n public static getInstance(options?: {webex: WebexSDK}): WebexRequest {\n if (!WebexRequest.instance && options && options.webex) {\n WebexRequest.instance = new WebexRequest(options);\n }\n\n return WebexRequest.instance;\n }\n\n private constructor(options: {webex: WebexSDK}) {\n const {webex} = options;\n this.webex = webex;\n }\n\n public async request(options: {\n service: string;\n resource: string;\n method: HTTP_METHODS;\n body?: RequestBody;\n }): Promise<IHttpResponse> {\n const {service, resource, method, body} = options;\n\n return this.webex.request({\n service,\n resource,\n method,\n body,\n });\n }\n\n /**\n * This is used for uploading the logs to backend/mats.\n *\n * @param metaData - meta data to be uploaded.\n */\n public async uploadLogs(metaData: LogsMetaData = {}): Promise<UploadLogsResponse> {\n const feedbackId = crypto.randomUUID();\n try {\n const response = await this.webex.internal.support.submitLogs(\n {...metaData, feedbackId},\n undefined, // we dont send logs but take from webex logger\n {type: 'diff'} // this is to take the diff logs from previous upload\n );\n LoggerProxy.info(`Logs uploaded successfully with feedbackId: ${feedbackId}`, {\n module: WEBEX_REQUEST_FILE,\n method: METHODS.UPLOAD_LOGS,\n });\n\n MetricsManager.getInstance().trackEvent(\n METRIC_EVENT_NAMES.UPLOAD_LOGS_SUCCESS,\n {\n trackingId: response?.trackingid,\n feedbackId,\n correlationId: metaData?.correlationId,\n },\n ['behavioral']\n );\n\n return {\n trackingid: response.trackingid,\n ...(response.url ? {url: response.url} : {}),\n ...(response.userId ? {userId: response.userId} : {}),\n ...(response.correlationId ? {correlationId: response.correlationId} : {}),\n feedbackId,\n };\n } catch (error) {\n LoggerProxy.error(`Error uploading logs: ${error}`, {\n module: WEBEX_REQUEST_FILE,\n method: METHODS.UPLOAD_LOGS,\n });\n\n MetricsManager.getInstance().trackEvent(\n METRIC_EVENT_NAMES.UPLOAD_LOGS_FAILED,\n {\n stack: error?.stack,\n feedbackId,\n correlationId: metaData?.correlationId,\n },\n ['behavioral']\n );\n throw error;\n }\n }\n}\n\nexport default WebexRequest;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAH,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAU1D,MAAMG,YAAY,CAAC;EAIjB,OAAcC,WAAWA,CAACC,OAA2B,EAAgB;IACnE,IAAI,CAACF,YAAY,CAACG,QAAQ,IAAID,OAAO,IAAIA,OAAO,CAACE,KAAK,EAAE;MACtDJ,YAAY,CAACG,QAAQ,GAAG,IAAIH,YAAY,CAACE,OAAO,CAAC;IACnD;IAEA,OAAOF,YAAY,CAACG,QAAQ;EAC9B;EAEQE,WAAWA,CAACH,OAA0B,EAAE;IAC9C,MAAM;MAACE;IAAK,CAAC,GAAGF,OAAO;IACvB,IAAI,CAACE,KAAK,GAAGA,KAAK;EACpB;EAEA,MAAaE,OAAOA,CAACJ,
|
|
1
|
+
{"version":3,"names":["_constants","require","_loggerProxy","_interopRequireDefault","_constants2","_constants3","_MetricsManager","e","__esModule","default","WebexRequest","getInstance","options","instance","webex","constructor","request","service","resource","method","body","headers","uploadLogs","metaData","feedbackId","crypto","randomUUID","response","internal","support","submitLogs","undefined","type","LoggerProxy","info","module","WEBEX_REQUEST_FILE","METHODS","UPLOAD_LOGS","MetricsManager","trackEvent","METRIC_EVENT_NAMES","UPLOAD_LOGS_SUCCESS","trackingId","trackingid","correlationId","url","userId","error","UPLOAD_LOGS_FAILED","stack","_default","exports"],"sources":["WebexRequest.ts"],"sourcesContent":["import {WEBEX_REQUEST_FILE} from '../../constants';\nimport LoggerProxy from '../../logger-proxy';\nimport {METHODS} from './constants';\nimport {METRIC_EVENT_NAMES} from '../../metrics/constants';\nimport MetricsManager from '../../metrics/MetricsManager';\nimport {\n WebexSDK,\n HTTP_METHODS,\n IHttpResponse,\n RequestBody,\n UploadLogsResponse,\n LogsMetaData,\n} from '../../types';\n\nclass WebexRequest {\n private webex: WebexSDK;\n private static instance: WebexRequest;\n\n public static getInstance(options?: {webex: WebexSDK}): WebexRequest {\n if (!WebexRequest.instance && options && options.webex) {\n WebexRequest.instance = new WebexRequest(options);\n }\n\n return WebexRequest.instance;\n }\n\n private constructor(options: {webex: WebexSDK}) {\n const {webex} = options;\n this.webex = webex;\n }\n\n public async request(options: {\n service: string;\n resource: string;\n method: HTTP_METHODS;\n body?: RequestBody;\n headers?: Record<string, string | null>;\n }): Promise<IHttpResponse> {\n const {service, resource, method, body, headers} = options;\n\n return this.webex.request({\n service,\n resource,\n method,\n body,\n ...(headers ? {headers} : {}),\n });\n }\n\n /**\n * This is used for uploading the logs to backend/mats.\n *\n * @param metaData - meta data to be uploaded.\n */\n public async uploadLogs(metaData: LogsMetaData = {}): Promise<UploadLogsResponse> {\n const feedbackId = crypto.randomUUID();\n try {\n const response = await this.webex.internal.support.submitLogs(\n {...metaData, feedbackId},\n undefined, // we dont send logs but take from webex logger\n {type: 'diff'} // this is to take the diff logs from previous upload\n );\n LoggerProxy.info(`Logs uploaded successfully with feedbackId: ${feedbackId}`, {\n module: WEBEX_REQUEST_FILE,\n method: METHODS.UPLOAD_LOGS,\n });\n\n MetricsManager.getInstance().trackEvent(\n METRIC_EVENT_NAMES.UPLOAD_LOGS_SUCCESS,\n {\n trackingId: response?.trackingid,\n feedbackId,\n correlationId: metaData?.correlationId,\n },\n ['behavioral']\n );\n\n return {\n trackingid: response.trackingid,\n ...(response.url ? {url: response.url} : {}),\n ...(response.userId ? {userId: response.userId} : {}),\n ...(response.correlationId ? {correlationId: response.correlationId} : {}),\n feedbackId,\n };\n } catch (error) {\n LoggerProxy.error(`Error uploading logs: ${error}`, {\n module: WEBEX_REQUEST_FILE,\n method: METHODS.UPLOAD_LOGS,\n });\n\n MetricsManager.getInstance().trackEvent(\n METRIC_EVENT_NAMES.UPLOAD_LOGS_FAILED,\n {\n stack: error?.stack,\n feedbackId,\n correlationId: metaData?.correlationId,\n },\n ['behavioral']\n );\n throw error;\n }\n }\n}\n\nexport default WebexRequest;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GA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IACb;EACF;AACF;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA3C,OAAA,GAEcC,YAAY","ignoreList":[]}
|
|
@@ -20,15 +20,41 @@ class AqmReqs {
|
|
|
20
20
|
this.webSocketManager = webSocketManager;
|
|
21
21
|
this.webSocketManager.on('message', this.onMessage.bind(this));
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a request function for an API call with parameters
|
|
26
|
+
* @param c - The configuration for the request
|
|
27
|
+
* @returns A function that makes the API request
|
|
28
|
+
*/
|
|
23
29
|
req(c) {
|
|
24
30
|
return (p, cbRes) => this.makeAPIRequest(c(p), cbRes);
|
|
25
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a request function for an API call with no parameters
|
|
35
|
+
* @param c - The configuration for the request
|
|
36
|
+
* @returns A function that makes the API request
|
|
37
|
+
*/
|
|
26
38
|
reqEmpty(c) {
|
|
27
39
|
return cbRes => this.makeAPIRequest(c(), cbRes);
|
|
28
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Makes an API request
|
|
44
|
+
* @param c - The request configuration
|
|
45
|
+
* @param cbRes - The callback for the response
|
|
46
|
+
* @returns A promise that resolves with the response or rejects with an error
|
|
47
|
+
*/
|
|
29
48
|
async makeAPIRequest(c, cbRes) {
|
|
30
49
|
return this.createPromise(c, cbRes);
|
|
31
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates a promise for an API request
|
|
54
|
+
* @param c - The request configuration
|
|
55
|
+
* @param cbRes - The callback for the response
|
|
56
|
+
* @returns A promise that resolves with the response or rejects with an error
|
|
57
|
+
*/
|
|
32
58
|
createPromise(c, cbRes) {
|
|
33
59
|
return new Promise((resolve, reject) => {
|
|
34
60
|
const keySuccess = this.bindPrint(c.notifSuccess.bind);
|
|
@@ -86,16 +112,23 @@ class AqmReqs {
|
|
|
86
112
|
clear();
|
|
87
113
|
const notifFail = c.notifFail;
|
|
88
114
|
if ('errId' in notifFail) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
115
|
+
const error = new Err.Details(notifFail.errId, msg);
|
|
116
|
+
if (c.redactSensitiveLogs) {
|
|
117
|
+
_loggerProxy.default.log('Routing request failed (sensitive details redacted)', {
|
|
118
|
+
module: _constants2.AQM_REQS_FILE,
|
|
119
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
_loggerProxy.default.log(`Routing request failed: ${JSON.stringify(msg)}`, {
|
|
123
|
+
module: _constants2.AQM_REQS_FILE,
|
|
124
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
125
|
+
});
|
|
126
|
+
_loggerProxy.default.log(`Routing request failed: ${error}`, {
|
|
127
|
+
module: _constants2.AQM_REQS_FILE,
|
|
128
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
reject(error);
|
|
99
132
|
} else {
|
|
100
133
|
reject(notifFail.err(msg));
|
|
101
134
|
}
|
|
@@ -139,10 +172,17 @@ class AqmReqs {
|
|
|
139
172
|
if (response?.headers) {
|
|
140
173
|
response.headers.Authorization = '*';
|
|
141
174
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
175
|
+
if (c.redactSensitiveLogs) {
|
|
176
|
+
_loggerProxy.default.error('Routing request timeout (sensitive details redacted)', {
|
|
177
|
+
module: _constants2.AQM_REQS_FILE,
|
|
178
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
_loggerProxy.default.error(`Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`, {
|
|
182
|
+
module: _constants2.AQM_REQS_FILE,
|
|
183
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
184
|
+
});
|
|
185
|
+
}
|
|
146
186
|
reject(new Err.Details('Service.aqm.reqs.Timeout', {
|
|
147
187
|
key: keySuccess,
|
|
148
188
|
response: response
|
|
@@ -151,44 +191,93 @@ class AqmReqs {
|
|
|
151
191
|
}
|
|
152
192
|
});
|
|
153
193
|
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Converts a bind object to a string representation
|
|
197
|
+
* @param bind - The bind object to convert
|
|
198
|
+
* @returns A string representation of the bind object
|
|
199
|
+
*/
|
|
154
200
|
bindPrint(bind) {
|
|
155
201
|
let result = '';
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (Array.isArray(
|
|
159
|
-
result += `${
|
|
160
|
-
} else if (typeof
|
|
161
|
-
result += `${
|
|
202
|
+
for (const key of Object.keys(bind).filter(prop => prop !== '__typeMap')) {
|
|
203
|
+
const value = bind[key];
|
|
204
|
+
if (Array.isArray(value)) {
|
|
205
|
+
result += `${key}=[${value.join(',')}],`;
|
|
206
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
207
|
+
result += `${key}=(${this.bindPrint(value)}),`;
|
|
162
208
|
} else {
|
|
163
|
-
result += `${
|
|
209
|
+
result += `${key}=${value},`;
|
|
164
210
|
}
|
|
165
211
|
}
|
|
166
212
|
return result ? result.slice(0, -1) : result;
|
|
167
213
|
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Checks if a message matches a bind object
|
|
217
|
+
* @param bind - The bind object to check against
|
|
218
|
+
* @param msg - The message to check
|
|
219
|
+
* @returns True if the message matches the bind object, false otherwise
|
|
220
|
+
*/
|
|
168
221
|
bindCheck(bind, msg) {
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
if (
|
|
222
|
+
// Handle type-dependent field matching if __typeMap is present
|
|
223
|
+
if (bind.__typeMap && typeof bind.__typeMap === 'object') {
|
|
224
|
+
if (!AqmReqs.typeMapCheck(bind.__typeMap, msg)) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const key of Object.keys(bind).filter(prop => prop !== '__typeMap')) {
|
|
229
|
+
const bindValue = bind[key];
|
|
230
|
+
const msgValue = msg[key];
|
|
231
|
+
if (Array.isArray(bindValue)) {
|
|
172
232
|
// Check if the message value matches any of the values in the array
|
|
173
|
-
if (!
|
|
233
|
+
if (!bindValue.includes(msgValue)) {
|
|
174
234
|
return false;
|
|
175
235
|
}
|
|
176
|
-
} else if (typeof
|
|
177
|
-
if (typeof
|
|
178
|
-
if (!this.bindCheck(
|
|
236
|
+
} else if (typeof bindValue === 'object' && bindValue !== null) {
|
|
237
|
+
if (typeof msgValue === 'object' && msgValue !== null) {
|
|
238
|
+
if (!this.bindCheck(bindValue, msgValue)) {
|
|
179
239
|
return false;
|
|
180
240
|
}
|
|
181
241
|
} else {
|
|
182
242
|
return false;
|
|
183
243
|
}
|
|
184
|
-
} else if (!
|
|
244
|
+
} else if (!msgValue || msgValue !== bindValue) {
|
|
185
245
|
return false;
|
|
186
246
|
}
|
|
187
247
|
}
|
|
188
248
|
return true;
|
|
189
249
|
}
|
|
190
250
|
|
|
191
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Checks type-dependent field conditions defined in __typeMap.
|
|
253
|
+
* @param typeMap - The type map to check against
|
|
254
|
+
* @param msg - The message to check
|
|
255
|
+
* @returns True if the message matches the type map, false otherwise
|
|
256
|
+
* The typeMap has the shape:
|
|
257
|
+
* { typeField: "type", conditions: { EventA: { field: value }, EventB: { field: value } } }
|
|
258
|
+
* It reads msg[typeField] to determine which condition set to apply,
|
|
259
|
+
* then verifies all fields in that condition match the message.
|
|
260
|
+
*/
|
|
261
|
+
static typeMapCheck(typeMap, msg) {
|
|
262
|
+
const typeField = typeMap.typeField || 'type';
|
|
263
|
+
const msgType = msg[typeField];
|
|
264
|
+
if (typeMap.conditions && typeMap.conditions[msgType]) {
|
|
265
|
+
const condition = typeMap.conditions[msgType];
|
|
266
|
+
for (const field of Object.keys(condition)) {
|
|
267
|
+
if (!msg[field] || msg[field] !== condition[field]) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Handles incoming messages from the WebSocket (must be a lambda fn)
|
|
278
|
+
* @param msg - The message to handle
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
192
281
|
onMessage = msg => {
|
|
193
282
|
const event = JSON.parse(msg);
|
|
194
283
|
if (event.type === 'Welcome') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","LoggerProxy","log","JSON","stringify","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","eerr","errId","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","error","headers","Authorization","Message","window","setTimeout","TIMEOUT_REQ","result","Array","isArray","join","slice","includes","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","keys","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n const eerr = new Err.Details(notifFail.errId, msg as any);\n LoggerProxy.log(`Routing request failed: ${eerr}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(eerr);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n LoggerProxy.error(`Routing request timeout${keySuccess}${response!}${c.url}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n private bindPrint(bind: any) {\n let result = '';\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n result += `${k}=[${bind[k].join(',')}],`;\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n result += `${k}=(${this.bindPrint(bind[k])}),`;\n } else {\n result += `${k}=${bind[k]},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n private bindCheck(bind: any, msg: any) {\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n // Check if the message value matches any of the values in the array\n if (!bind[k].includes(msg[k])) {\n return false;\n }\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n if (typeof msg[k] === 'object' && msg[k] !== null) {\n if (!this.bindCheck(bind[k], msg[k])) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msg[k] || msg[k] !== bind[k]) {\n return false;\n }\n }\n\n return true;\n }\n\n // must be lambda\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAA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,IAAI;QAChB;MACF;IACF;IACA;IACA,MAAMI,OAAO,GAAG5F,MAAM,CAAC0F,IAAI,CAAC,IAAI,CAACrF,yBAAyB,CAAC;IAC3D,KAAK,MAAMsF,OAAO,IAAIC,OAAO,EAAE;MAC7B,MAAM9E,GAAG,GAAG,IAAI,CAACT,yBAAyB,CAACsF,OAAO,CAAC;MACnD,IAAI7E,GAAG,CAACwB,KAAK,CAAC4C,KAAK,CAAC,EAAE;QACpBpE,GAAG,CAAC0B,MAAM,CAAC0C,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;MAClB;IACF;;IAEA;;IAEA,IAAI,CAACA,SAAS,EAAE;MACd7C,oBAAW,CAAC0C,IAAI,CAAC,uEAAuE,EAAE;QACxFtC,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAA3G,OAAA,GAAAiB,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","error","errId","redactSensitiveLogs","LoggerProxy","log","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","JSON","stringify","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","headers","Authorization","Message","window","setTimeout","TIMEOUT_REQ","result","keys","filter","prop","value","Array","isArray","join","slice","__typeMap","typeMapCheck","bindValue","msgValue","includes","typeMap","typeField","msgType","conditions","condition","field","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n /**\n * Creates a request function for an API call with parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n /**\n * Creates a request function for an API call with no parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n /**\n * Makes an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n /**\n * Creates a promise for an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n const error = new Err.Details(notifFail.errId, msg as any);\n\n if (c.redactSensitiveLogs) {\n LoggerProxy.log('Routing request failed (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n } else {\n LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n LoggerProxy.log(`Routing request failed: ${error}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n }\n reject(error);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n if (c.redactSensitiveLogs) {\n LoggerProxy.error('Routing request timeout (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n } else {\n LoggerProxy.error(\n `Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`,\n {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n }\n );\n }\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n /**\n * Converts a bind object to a string representation\n * @param bind - The bind object to convert\n * @returns A string representation of the bind object\n */\n private bindPrint(bind: any): string {\n let result = '';\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const value = bind[key];\n\n if (Array.isArray(value)) {\n result += `${key}=[${value.join(',')}],`;\n } else if (typeof value === 'object' && value !== null) {\n result += `${key}=(${this.bindPrint(value)}),`;\n } else {\n result += `${key}=${value},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n /**\n * Checks if a message matches a bind object\n * @param bind - The bind object to check against\n * @param msg - The message to check\n * @returns True if the message matches the bind object, false otherwise\n */\n private bindCheck(bind: any, msg: any): boolean {\n // Handle type-dependent field matching if __typeMap is present\n if (bind.__typeMap && typeof bind.__typeMap === 'object') {\n if (!AqmReqs.typeMapCheck(bind.__typeMap, msg)) {\n return false;\n }\n }\n\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const bindValue = bind[key];\n const msgValue = msg[key];\n\n if (Array.isArray(bindValue)) {\n // Check if the message value matches any of the values in the array\n if (!bindValue.includes(msgValue)) {\n return false;\n }\n } else if (typeof bindValue === 'object' && bindValue !== null) {\n if (typeof msgValue === 'object' && msgValue !== null) {\n if (!this.bindCheck(bindValue, msgValue)) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msgValue || msgValue !== bindValue) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks type-dependent field conditions defined in __typeMap.\n * @param typeMap - The type map to check against\n * @param msg - The message to check\n * @returns True if the message matches the type map, false otherwise\n * The typeMap has the shape:\n * { typeField: \"type\", conditions: { EventA: { field: value }, EventB: { field: value } } }\n * It reads msg[typeField] to determine which condition set to apply,\n * then verifies all fields in that condition match the message.\n */\n private static typeMapCheck(typeMap: any, msg: any): boolean {\n const typeField = typeMap.typeField || 'type';\n const msgType = msg[typeField];\n\n if (typeMap.conditions && typeMap.conditions[msgType]) {\n const condition = typeMap.conditions[msgType];\n for (const field of Object.keys(condition)) {\n if (!msg[field] || msg[field] !== condition[field]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Handles incoming messages from the WebSocket (must be a lambda fn)\n * @param msg - The message to handle\n * @returns\n */\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OA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,"names":[],"sources":["types.ts"],"sourcesContent":["import {HTTP_METHODS, RequestBody, WebexRequestPayload} from '../../types';\nimport * as Err from './Err';\nimport {Msg} from './GlobalTypes';\n\nexport type Pending = {\n check: (msg: Msg) => boolean;\n handle: (msg: Msg) => void;\n alternateBind?: string;\n};\n\nexport type BindType = string | string[] | {[key: string]: BindType};\ninterface Bind {\n type: BindType;\n data?: any;\n}\n\nexport type Timeout = number | 'disabled';\n\nexport type Req<TRes, TErr> = {\n url: string;\n host?: string;\n method?: HTTP_METHODS;\n err?:\n | ((errObj: WebexRequestPayload) => Err.Details<'Service.reqs.generic.failure'>)\n | Err.IdsMessage\n | ((e: WebexRequestPayload) => Err.Message | Err.Details<Err.IdsDetails>);\n notifSuccess: {bind: Bind; msg: TRes};\n notifFail?:\n | {\n bind: Bind;\n errMsg: TErr;\n err: (e: TErr) => Err.Details<Err.IdsDetails>;\n }\n | {\n bind: Bind;\n errId: Err.IdsDetails;\n };\n data?: RequestBody;\n headers?: Record<string, string>;\n timeout?: Timeout;\n notifCancel?: {bind: Bind; msg: TRes};\n};\n\nexport type Conf<TRes, TErr, TReq> = (p: TReq) => Req<TRes, TErr>;\nexport type ConfEmpty<TRes, TErr> = () => Req<TRes, TErr>;\nexport type Res<TRes, TReq> = (p: TReq, cbRes?: CbRes<TRes>) => Promise<TRes>;\nexport type ResEmpty<TRes> = (cbRes?: CbRes<TRes>) => Promise<TRes>;\nexport type CbRes<TRes> = (res: any) => void | TRes;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {HTTP_METHODS, RequestBody, WebexRequestPayload} from '../../types';\nimport * as Err from './Err';\nimport {Msg} from './GlobalTypes';\n\nexport type Pending = {\n check: (msg: Msg) => boolean;\n handle: (msg: Msg) => void;\n alternateBind?: string;\n};\n\nexport type BindType = string | string[] | {[key: string]: BindType};\ninterface Bind {\n type: BindType;\n data?: any;\n}\n\nexport type Timeout = number | 'disabled';\n\nexport type Req<TRes, TErr> = {\n url: string;\n host?: string;\n method?: HTTP_METHODS;\n /** Suppress request URLs and routing payloads from AQM logs for sensitive operations. */\n redactSensitiveLogs?: boolean;\n err?:\n | ((errObj: WebexRequestPayload) => Err.Details<'Service.reqs.generic.failure'>)\n | Err.IdsMessage\n | ((e: WebexRequestPayload) => Err.Message | Err.Details<Err.IdsDetails>);\n notifSuccess: {bind: Bind; msg: TRes};\n notifFail?:\n | {\n bind: Bind;\n errMsg: TErr;\n err: (e: TErr) => Err.Details<Err.IdsDetails>;\n }\n | {\n bind: Bind;\n errId: Err.IdsDetails;\n };\n data?: RequestBody;\n headers?: Record<string, string>;\n timeout?: Timeout;\n notifCancel?: {bind: Bind; msg: TRes};\n};\n\nexport type Conf<TRes, TErr, TReq> = (p: TReq) => Req<TRes, TErr>;\nexport type ConfEmpty<TRes, TErr> = () => Req<TRes, TErr>;\nexport type Res<TRes, TReq> = (p: TReq, cbRes?: CbRes<TRes>) => Promise<TRes>;\nexport type ResEmpty<TRes> = (cbRes?: CbRes<TRes>) => Promise<TRes>;\nexport type CbRes<TRes> = (res: any) => void | TRes;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WebSocketManager = void 0;
|
|
6
|
+
exports.default = exports.WebSocketManager = void 0;
|
|
7
7
|
var _events = _interopRequireDefault(require("events"));
|
|
8
8
|
var _types = require("../../../types");
|
|
9
9
|
var _constants = require("../../constants");
|
|
@@ -40,9 +40,12 @@ class WebSocketManager extends _events.default {
|
|
|
40
40
|
this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));
|
|
41
41
|
}
|
|
42
42
|
async initWebSocket(options) {
|
|
43
|
-
const
|
|
43
|
+
const {
|
|
44
|
+
body: connectionConfig,
|
|
45
|
+
resource
|
|
46
|
+
} = options;
|
|
44
47
|
try {
|
|
45
|
-
await this.register(connectionConfig);
|
|
48
|
+
await this.register(connectionConfig, resource);
|
|
46
49
|
} catch (error) {
|
|
47
50
|
_loggerProxy.default.error(`[WebSocketStatus] | Error in registering Websocket ${error}`, {
|
|
48
51
|
module: _constants3.WEB_SOCKET_MANAGER_FILE,
|
|
@@ -77,13 +80,25 @@ class WebSocketManager extends _events.default {
|
|
|
77
80
|
handleConnectionLost(event) {
|
|
78
81
|
this.isConnectionLost = event.isConnectionLost;
|
|
79
82
|
}
|
|
80
|
-
async register(connectionConfig) {
|
|
83
|
+
async register(connectionConfig, resource) {
|
|
81
84
|
try {
|
|
85
|
+
// X-ORGANIZATION-ID header is only required for INT environments
|
|
86
|
+
const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;
|
|
87
|
+
const orgId = this.webex.credentials.getOrgId();
|
|
88
|
+
if (isIntEnv && orgId) {
|
|
89
|
+
_loggerProxy.default.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {
|
|
90
|
+
module: _constants3.WEB_SOCKET_MANAGER_FILE,
|
|
91
|
+
method: _constants2.METHODS.REGISTER
|
|
92
|
+
});
|
|
93
|
+
}
|
|
82
94
|
const subscribeResponse = await this.webex.request({
|
|
83
95
|
service: _constants.WCC_API_GATEWAY,
|
|
84
|
-
resource
|
|
96
|
+
resource,
|
|
85
97
|
method: _types.HTTP_METHODS.POST,
|
|
86
|
-
body: connectionConfig
|
|
98
|
+
body: connectionConfig,
|
|
99
|
+
headers: isIntEnv && orgId ? {
|
|
100
|
+
'X-ORGANIZATION-ID': orgId
|
|
101
|
+
} : undefined
|
|
87
102
|
});
|
|
88
103
|
this.url = subscribeResponse.body.webSocketUrl;
|
|
89
104
|
} catch (e) {
|
|
@@ -188,4 +203,5 @@ class WebSocketManager extends _events.default {
|
|
|
188
203
|
}
|
|
189
204
|
}
|
|
190
205
|
exports.WebSocketManager = WebSocketManager;
|
|
206
|
+
var _default = exports.default = WebSocketManager;
|
|
191
207
|
//# sourceMappingURL=WebSocketManager.js.map
|