@webex/contact-center 3.10.0-next.17 → 3.10.0-next.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cc.js +2 -1
  2. package/dist/cc.js.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +17 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger-proxy.js.map +1 -1
  8. package/dist/metrics/MetricsManager.js +2 -1
  9. package/dist/metrics/MetricsManager.js.map +1 -1
  10. package/dist/metrics/behavioral-events.js +12 -0
  11. package/dist/metrics/behavioral-events.js.map +1 -1
  12. package/dist/metrics/constants.js +4 -0
  13. package/dist/metrics/constants.js.map +1 -1
  14. package/dist/services/AddressBook.js +2 -3
  15. package/dist/services/AddressBook.js.map +1 -1
  16. package/dist/services/EntryPoint.js +2 -3
  17. package/dist/services/EntryPoint.js.map +1 -1
  18. package/dist/services/Queue.js +2 -3
  19. package/dist/services/Queue.js.map +1 -1
  20. package/dist/services/WebCallingService.js +1 -1
  21. package/dist/services/WebCallingService.js.map +1 -1
  22. package/dist/services/agent/index.js +1 -2
  23. package/dist/services/agent/index.js.map +1 -1
  24. package/dist/services/agent/types.js +10 -0
  25. package/dist/services/agent/types.js.map +1 -1
  26. package/dist/services/config/Util.js.map +1 -1
  27. package/dist/services/config/constants.js.map +1 -1
  28. package/dist/services/config/index.js +1 -1
  29. package/dist/services/config/index.js.map +1 -1
  30. package/dist/services/config/types.js.map +1 -1
  31. package/dist/services/constants.js.map +1 -1
  32. package/dist/services/core/Err.js.map +1 -1
  33. package/dist/services/core/GlobalTypes.js.map +1 -1
  34. package/dist/services/core/Utils.js +2 -3
  35. package/dist/services/core/Utils.js.map +1 -1
  36. package/dist/services/core/WebexRequest.js +1 -2
  37. package/dist/services/core/WebexRequest.js.map +1 -1
  38. package/dist/services/core/aqm-reqs.js +2 -3
  39. package/dist/services/core/aqm-reqs.js.map +1 -1
  40. package/dist/services/core/constants.js.map +1 -1
  41. package/dist/services/core/types.js.map +1 -1
  42. package/dist/services/core/websocket/WebSocketManager.js +1 -2
  43. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  44. package/dist/services/core/websocket/connection-service.js +1 -1
  45. package/dist/services/core/websocket/connection-service.js.map +1 -1
  46. package/dist/services/core/websocket/keepalive.worker.js.map +1 -1
  47. package/dist/services/core/websocket/types.js.map +1 -1
  48. package/dist/services/index.js +1 -1
  49. package/dist/services/index.js.map +1 -1
  50. package/dist/services/task/AutoWrapup.js +1 -1
  51. package/dist/services/task/AutoWrapup.js.map +1 -1
  52. package/dist/services/task/TaskManager.js +113 -36
  53. package/dist/services/task/TaskManager.js.map +1 -1
  54. package/dist/services/task/TaskUtils.js +90 -1
  55. package/dist/services/task/TaskUtils.js.map +1 -1
  56. package/dist/services/task/constants.js +3 -1
  57. package/dist/services/task/constants.js.map +1 -1
  58. package/dist/services/task/contact.js +0 -2
  59. package/dist/services/task/contact.js.map +1 -1
  60. package/dist/services/task/dialer.js.map +1 -1
  61. package/dist/services/task/index.js +1 -1
  62. package/dist/services/task/index.js.map +1 -1
  63. package/dist/services/task/types.js +359 -0
  64. package/dist/services/task/types.js.map +1 -1
  65. package/dist/types/metrics/constants.d.ts +4 -0
  66. package/dist/types/services/task/TaskUtils.d.ts +42 -0
  67. package/dist/types/services/task/constants.d.ts +2 -0
  68. package/dist/types/services/task/types.d.ts +6 -0
  69. package/dist/types.js +5 -0
  70. package/dist/types.js.map +1 -1
  71. package/dist/utils/PageCache.js +1 -1
  72. package/dist/utils/PageCache.js.map +1 -1
  73. package/dist/webex-config.js.map +1 -1
  74. package/dist/webex.js +2 -2
  75. package/dist/webex.js.map +1 -1
  76. package/package.json +8 -8
  77. package/src/cc.ts +1 -0
  78. package/src/metrics/behavioral-events.ts +12 -0
  79. package/src/metrics/constants.ts +4 -0
  80. package/src/services/task/TaskManager.ts +127 -29
  81. package/src/services/task/TaskUtils.ts +109 -1
  82. package/src/services/task/constants.ts +2 -0
  83. package/src/services/task/types.ts +6 -0
  84. package/test/unit/spec/cc.ts +1 -0
  85. package/test/unit/spec/metrics/behavioral-events.ts +14 -0
  86. package/test/unit/spec/services/task/TaskManager.ts +143 -0
  87. package/test/unit/spec/services/task/TaskUtils.ts +305 -3
  88. package/umd/contact-center.min.js +2 -2
  89. package/umd/contact-center.min.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["POST_AUTH","exports","WCC_API_GATEWAY","WCC_CALLING_RTMS_DOMAIN","DEFAULT_RTMS_DOMAIN","WEBSOCKET_EVENT_TIMEOUT","AGENT","SUBSCRIBE_API","LOGIN_API","WEB_RTC_PREFIX","STATE_CHANGE_API","DEREGISTER_WEBCALLING_LINE_MSG","METHODS","SET_LOGIN_OPTION","HANDLE_MEDIA_EVENT","HANDLE_DISCONNECT_EVENT","REGISTER_CALL_LISTENERS","CLEAN_UP_CALL","GET_RTMS_DOMAIN","REGISTER_WEB_CALLING_LINE","DEREGISTER_WEB_CALLING_LINE","ANSWER_CALL","MUTE_UNMUTE_CALL","IS_CALL_MUTED","DECLINE_CALL","MAP_CALL_TO_TASK","GET_TASK_ID_FOR_CALL"],"sources":["constants.ts"],"sourcesContent":["/**\n * Post-authentication event name.\n * @type {string}\n * @public\n * @example\n * if (event === POST_AUTH) { ... }\n * @ignore\n */\nexport const POST_AUTH = 'postauth';\n\n/**\n * API gateway identifier for Webex Contact Center.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WCC_API_GATEWAY = 'wcc-api-gateway';\n\n/**\n * Domain identifier for WCC Calling RTMS.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WCC_CALLING_RTMS_DOMAIN = 'wcc-calling-rtms-domain';\n\n/**\n * Default RTMS domain for production use.\n * @type {string}\n * @public\n * @ignore\n */\nexport const DEFAULT_RTMS_DOMAIN = 'rtw.prod-us1.rtmsprod.net';\n\n/**\n * Timeout in milliseconds for WebSocket events.\n * @type {number}\n * @public\n * @example\n * setTimeout(() => { ... }, WEBSOCKET_EVENT_TIMEOUT);\n * @ignore\n */\nexport const WEBSOCKET_EVENT_TIMEOUT = 20000;\n\n/**\n * Agent role identifier.\n * @type {string}\n * @public\n * @ignore\n */\nexport const AGENT = 'agent';\n\n// CC GATEWAY API URL PATHS\n/**\n * API path for notification subscription.\n * @type {string}\n * @public\n * @ignore\n */\nexport const SUBSCRIBE_API = 'v1/notification/subscribe';\n\n/**\n * API path for agent login.\n * @type {string}\n * @public\n * @ignore\n */\nexport const LOGIN_API = 'v1/agents/login';\n\n/**\n * Prefix for WebRTC-related API endpoints.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WEB_RTC_PREFIX = 'webrtc-';\n\n/**\n * API path for agent session state changes.\n * @type {string}\n * @public\n * @ignore\n */\nexport const STATE_CHANGE_API = 'v1/agents/session/state';\n\n/**\n * Message for deregistering WebCalling line and cleaning up resources.\n * @type {string}\n * @public\n * @ignore\n */\nexport const DEREGISTER_WEBCALLING_LINE_MSG =\n 'Deregistering WebCalling line and cleaning up resources';\n\n// WebCallingService method names\nexport const METHODS = {\n SET_LOGIN_OPTION: 'setLoginOption',\n HANDLE_MEDIA_EVENT: 'handleMediaEvent',\n HANDLE_DISCONNECT_EVENT: 'handleDisconnectEvent',\n REGISTER_CALL_LISTENERS: 'registerCallListeners',\n CLEAN_UP_CALL: 'cleanUpCall',\n GET_RTMS_DOMAIN: 'getRTMSDomain',\n REGISTER_WEB_CALLING_LINE: 'registerWebCallingLine',\n DEREGISTER_WEB_CALLING_LINE: 'deregisterWebCallingLine',\n ANSWER_CALL: 'answerCall',\n MUTE_UNMUTE_CALL: 'muteUnmuteCall',\n IS_CALL_MUTED: 'isCallMuted',\n DECLINE_CALL: 'declineCall',\n MAP_CALL_TO_TASK: 'mapCallToTask',\n GET_TASK_ID_FOR_CALL: 'getTaskIdForCall',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SA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E,wBAAwB;EACnDC,2BAA2B,EAAE,0BAA0B;EACvDC,WAAW,EAAE,YAAY;EACzBC,gBAAgB,EAAE,gBAAgB;EAClCC,aAAa,EAAE,aAAa;EAC5BC,YAAY,EAAE,aAAa;EAC3BC,gBAAgB,EAAE,eAAe;EACjCC,oBAAoB,EAAE;AACxB,CAAC"}
1
+ {"version":3,"names":["POST_AUTH","exports","WCC_API_GATEWAY","WCC_CALLING_RTMS_DOMAIN","DEFAULT_RTMS_DOMAIN","WEBSOCKET_EVENT_TIMEOUT","AGENT","SUBSCRIBE_API","LOGIN_API","WEB_RTC_PREFIX","STATE_CHANGE_API","DEREGISTER_WEBCALLING_LINE_MSG","METHODS","SET_LOGIN_OPTION","HANDLE_MEDIA_EVENT","HANDLE_DISCONNECT_EVENT","REGISTER_CALL_LISTENERS","CLEAN_UP_CALL","GET_RTMS_DOMAIN","REGISTER_WEB_CALLING_LINE","DEREGISTER_WEB_CALLING_LINE","ANSWER_CALL","MUTE_UNMUTE_CALL","IS_CALL_MUTED","DECLINE_CALL","MAP_CALL_TO_TASK","GET_TASK_ID_FOR_CALL"],"sources":["constants.ts"],"sourcesContent":["/**\n * Post-authentication event name.\n * @type {string}\n * @public\n * @example\n * if (event === POST_AUTH) { ... }\n * @ignore\n */\nexport const POST_AUTH = 'postauth';\n\n/**\n * API gateway identifier for Webex Contact Center.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WCC_API_GATEWAY = 'wcc-api-gateway';\n\n/**\n * Domain identifier for WCC Calling RTMS.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WCC_CALLING_RTMS_DOMAIN = 'wcc-calling-rtms-domain';\n\n/**\n * Default RTMS domain for production use.\n * @type {string}\n * @public\n * @ignore\n */\nexport const DEFAULT_RTMS_DOMAIN = 'rtw.prod-us1.rtmsprod.net';\n\n/**\n * Timeout in milliseconds for WebSocket events.\n * @type {number}\n * @public\n * @example\n * setTimeout(() => { ... }, WEBSOCKET_EVENT_TIMEOUT);\n * @ignore\n */\nexport const WEBSOCKET_EVENT_TIMEOUT = 20000;\n\n/**\n * Agent role identifier.\n * @type {string}\n * @public\n * @ignore\n */\nexport const AGENT = 'agent';\n\n// CC GATEWAY API URL PATHS\n/**\n * API path for notification subscription.\n * @type {string}\n * @public\n * @ignore\n */\nexport const SUBSCRIBE_API = 'v1/notification/subscribe';\n\n/**\n * API path for agent login.\n * @type {string}\n * @public\n * @ignore\n */\nexport const LOGIN_API = 'v1/agents/login';\n\n/**\n * Prefix for WebRTC-related API endpoints.\n * @type {string}\n * @public\n * @ignore\n */\nexport const WEB_RTC_PREFIX = 'webrtc-';\n\n/**\n * API path for agent session state changes.\n * @type {string}\n * @public\n * @ignore\n */\nexport const STATE_CHANGE_API = 'v1/agents/session/state';\n\n/**\n * Message for deregistering WebCalling line and cleaning up resources.\n * @type {string}\n * @public\n * @ignore\n */\nexport const DEREGISTER_WEBCALLING_LINE_MSG =\n 'Deregistering WebCalling line and cleaning up resources';\n\n// WebCallingService method names\nexport const METHODS = {\n SET_LOGIN_OPTION: 'setLoginOption',\n HANDLE_MEDIA_EVENT: 'handleMediaEvent',\n HANDLE_DISCONNECT_EVENT: 'handleDisconnectEvent',\n REGISTER_CALL_LISTENERS: 'registerCallListeners',\n CLEAN_UP_CALL: 'cleanUpCall',\n GET_RTMS_DOMAIN: 'getRTMSDomain',\n REGISTER_WEB_CALLING_LINE: 'registerWebCallingLine',\n DEREGISTER_WEB_CALLING_LINE: 'deregisterWebCallingLine',\n ANSWER_CALL: 'answerCall',\n MUTE_UNMUTE_CALL: 'muteUnmuteCall',\n IS_CALL_MUTED: 'isCallMuted',\n DECLINE_CALL: 'declineCall',\n MAP_CALL_TO_TASK: 'mapCallToTask',\n GET_TASK_ID_FOR_CALL: 'getTaskIdForCall',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,UAAU;;AAEnC;AACA;AACA;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YAAY;EACzBC,gBAAgB,EAAE,gBAAgB;EAClCC,aAAa,EAAE,aAAa;EAC5BC,YAAY,EAAE,aAAa;EAC3BC,gBAAgB,EAAE,eAAe;EACjCC,oBAAoB,EAAE;AACxB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["Message","Error","constructor","id","value","stack","message","name","isErr","exports","Details","details"],"sources":["Err.ts"],"sourcesContent":["import {WebexRequestPayload} from '../../types';\nimport {Failure} from './GlobalTypes';\n\n/**\n * Err module provides a structured way to handle errors in the Contact Center plugin.\n * @ignore\n */\n\nexport type ErrDetails = {status: number; type: string; trackingId: string};\n\nexport type AgentErrorIds =\n | {'Service.aqm.agent.stationLogin': ErrDetails}\n | {'Service.aqm.agent.stationLoginFailed': Failure}\n | {'Service.aqm.agent.stateChange': Failure}\n | {'Service.aqm.agent.reload': Failure}\n | {'Service.aqm.agent.logout': Failure}\n | {'Service.reqs.generic.failure': {trackingId: string}}\n | {'Service.aqm.agent.BuddyAgentsRetrieveFailed': Failure};\n\nexport type vteamType = 'inboundqueue' | 'inboundentrypoint' | string;\n\nexport type TaskErrorIds =\n | {'Service.aqm.task.accept': Failure}\n | {'Service.aqm.task.end': Failure}\n | {'Service.aqm.task.wrapup': Failure}\n | {'Service.aqm.task.AgentVteamTransferFailed': Failure}\n | {'Service.aqm.task.AgentBlindTransferFailedEvent': Failure}\n | {'Service.aqm.task.AgentConsultTransferFailed': Failure}\n | {'Service.aqm.task.consult': Failure}\n | {'Service.aqm.err.trackingId': {trackingId: string}}\n | {'Service.aqm.task.consultAccept': Failure}\n | {'Service.aqm.task.consultConference': Failure}\n | {'Service.aqm.task.consultEnd': Failure}\n | {'Service.aqm.task.cancelCtq': Failure}\n | {'Service.aqm.task.hold': Failure}\n | {'Service.aqm.task.unHold': Failure}\n | {'Service.aqm.task.VteamListFailed': Failure}\n | {'Service.aqm.task.pauseRecording': Failure}\n | {'Service.aqm.task.resumeRecording': Failure}\n | {'Service.aqm.dialer.startOutdial': Failure}\n | {'Service.reqs.generic.failure': {trackingId: string}};\n\nexport type ReqError =\n | 'Service.aqm.reqs.GenericRequestError'\n | {'Service.aqm.reqs.Pending': {key: string; msg: string}}\n | {'Service.aqm.reqs.PendingEvent': {key: string}}\n | {'Service.aqm.reqs.Timeout': {key: string; response: WebexRequestPayload}}\n | {'Service.aqm.reqs.TimeoutEvent': {key: string}};\n\nexport interface Ids {\n 'Service.aqm.agent': AgentErrorIds;\n 'Service.aqm.reqs': ReqError;\n 'Service.aqm.task': TaskErrorIds;\n}\n\nexport type IdsGlobal =\n | 'system' // to handle errors that was not created by 'new Err.WithId()'\n | 'handle'\n | 'fallback';\n\nexport type IdsSub = Ids[keyof Ids];\n\nexport type IdsMessage = IdsGlobal | keyof Ids | Exclude<IdsSub, object>;\n\nexport type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nexport type FlattenUnion<T> = {\n [K in keyof UnionToIntersection<T>]: K extends keyof T\n ? T[K] extends any[]\n ? T[K]\n : T[K] extends object\n ? FlattenUnion<T[K]>\n : T[K]\n : UnionToIntersection<T>[K];\n};\nexport type IdsDetailsType = FlattenUnion<Exclude<IdsSub, string>>;\n\nexport type IdsDetails = keyof IdsDetailsType;\n\nexport type Id = IdsMessage | IdsDetails;\n\nexport class Message extends Error {\n readonly id: Id;\n\n constructor(id: IdsMessage);\n constructor(id: IdsMessage, message: string);\n constructor(id: IdsMessage, errror: Error);\n constructor(id: IdsMessage, value?: string | Error) {\n super();\n\n this.id = id;\n this.stack = new Error().stack!;\n\n if (typeof value === 'string') {\n this.message = value;\n } else if (value instanceof Error) {\n this.message = value.message;\n this.name = value.name;\n } else {\n this.message = '';\n }\n }\n\n // Marker to distinct Err class from other errors\n private isErr = 'yes';\n}\n\nexport class Details<T extends IdsDetails> extends Error {\n readonly id: Id;\n readonly details: IdsDetailsType[T];\n\n constructor(id: T, details: IdsDetailsType[T]) {\n super();\n\n this.id = id;\n this.stack = new Error().stack!;\n this.details = details;\n }\n\n // Marker to distinct Err class from other errors\n private isErr = 'yes';\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;;AA+EO,MAAMA,OAAO,SAASC,KAAK,CAAC;EAMjCC,WAAWA,CAACC,EAAc,EAAEC,KAAsB,EAAE;IAClD,KAAK,CAAC,CAAC;IAEP,IAAI,CAACD,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACE,KAAK,GAAG,IAAIJ,KAAK,CAAC,CAAC,CAACI,KAAM;IAE/B,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC7B,IAAI,CAACE,OAAO,GAAGF,KAAK;IACtB,CAAC,MAAM,IAAIA,KAAK,YAAYH,KAAK,EAAE;MACjC,IAAI,CAACK,OAAO,GAAGF,KAAK,CAACE,OAAO;MAC5B,IAAI,CAACC,IAAI,GAAGH,KAAK,CAACG,IAAI;IACxB,CAAC,MAAM;MACL,IAAI,CAACD,OAAO,GAAG,EAAE;IACnB;EACF;;EAEA;EACQE,KAAK,GAAG,KAAK;AACvB;AAACC,OAAA,CAAAT,OAAA,GAAAA,OAAA;AAEM,MAAMU,OAAO,SAA+BT,KAAK,CAAC;EAIvDC,WAAWA,CAACC,EAAK,EAAEQ,OAA0B,EAAE;IAC7C,KAAK,CAAC,CAAC;IAEP,IAAI,CAACR,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACE,KAAK,GAAG,IAAIJ,KAAK,CAAC,CAAC,CAACI,KAAM;IAC/B,IAAI,CAACM,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACQH,KAAK,GAAG,KAAK;AACvB;AAACC,OAAA,CAAAC,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"names":["Message","Error","constructor","id","value","stack","message","name","isErr","exports","Details","details"],"sources":["Err.ts"],"sourcesContent":["import {WebexRequestPayload} from '../../types';\nimport {Failure} from './GlobalTypes';\n\n/**\n * Err module provides a structured way to handle errors in the Contact Center plugin.\n * @ignore\n */\n\nexport type ErrDetails = {status: number; type: string; trackingId: string};\n\nexport type AgentErrorIds =\n | {'Service.aqm.agent.stationLogin': ErrDetails}\n | {'Service.aqm.agent.stationLoginFailed': Failure}\n | {'Service.aqm.agent.stateChange': Failure}\n | {'Service.aqm.agent.reload': Failure}\n | {'Service.aqm.agent.logout': Failure}\n | {'Service.reqs.generic.failure': {trackingId: string}}\n | {'Service.aqm.agent.BuddyAgentsRetrieveFailed': Failure};\n\nexport type vteamType = 'inboundqueue' | 'inboundentrypoint' | string;\n\nexport type TaskErrorIds =\n | {'Service.aqm.task.accept': Failure}\n | {'Service.aqm.task.end': Failure}\n | {'Service.aqm.task.wrapup': Failure}\n | {'Service.aqm.task.AgentVteamTransferFailed': Failure}\n | {'Service.aqm.task.AgentBlindTransferFailedEvent': Failure}\n | {'Service.aqm.task.AgentConsultTransferFailed': Failure}\n | {'Service.aqm.task.consult': Failure}\n | {'Service.aqm.err.trackingId': {trackingId: string}}\n | {'Service.aqm.task.consultAccept': Failure}\n | {'Service.aqm.task.consultConference': Failure}\n | {'Service.aqm.task.consultEnd': Failure}\n | {'Service.aqm.task.cancelCtq': Failure}\n | {'Service.aqm.task.hold': Failure}\n | {'Service.aqm.task.unHold': Failure}\n | {'Service.aqm.task.VteamListFailed': Failure}\n | {'Service.aqm.task.pauseRecording': Failure}\n | {'Service.aqm.task.resumeRecording': Failure}\n | {'Service.aqm.dialer.startOutdial': Failure}\n | {'Service.reqs.generic.failure': {trackingId: string}};\n\nexport type ReqError =\n | 'Service.aqm.reqs.GenericRequestError'\n | {'Service.aqm.reqs.Pending': {key: string; msg: string}}\n | {'Service.aqm.reqs.PendingEvent': {key: string}}\n | {'Service.aqm.reqs.Timeout': {key: string; response: WebexRequestPayload}}\n | {'Service.aqm.reqs.TimeoutEvent': {key: string}};\n\nexport interface Ids {\n 'Service.aqm.agent': AgentErrorIds;\n 'Service.aqm.reqs': ReqError;\n 'Service.aqm.task': TaskErrorIds;\n}\n\nexport type IdsGlobal =\n | 'system' // to handle errors that was not created by 'new Err.WithId()'\n | 'handle'\n | 'fallback';\n\nexport type IdsSub = Ids[keyof Ids];\n\nexport type IdsMessage = IdsGlobal | keyof Ids | Exclude<IdsSub, object>;\n\nexport type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never;\n\nexport type FlattenUnion<T> = {\n [K in keyof UnionToIntersection<T>]: K extends keyof T\n ? T[K] extends any[]\n ? T[K]\n : T[K] extends object\n ? FlattenUnion<T[K]>\n : T[K]\n : UnionToIntersection<T>[K];\n};\nexport type IdsDetailsType = FlattenUnion<Exclude<IdsSub, string>>;\n\nexport type IdsDetails = keyof IdsDetailsType;\n\nexport type Id = IdsMessage | IdsDetails;\n\nexport class Message extends Error {\n readonly id: Id;\n\n constructor(id: IdsMessage);\n constructor(id: IdsMessage, message: string);\n constructor(id: IdsMessage, errror: Error);\n constructor(id: IdsMessage, value?: string | Error) {\n super();\n\n this.id = id;\n this.stack = new Error().stack!;\n\n if (typeof value === 'string') {\n this.message = value;\n } else if (value instanceof Error) {\n this.message = value.message;\n this.name = value.name;\n } else {\n this.message = '';\n }\n }\n\n // Marker to distinct Err class from other errors\n private isErr = 'yes';\n}\n\nexport class Details<T extends IdsDetails> extends Error {\n readonly id: Id;\n readonly details: IdsDetailsType[T];\n\n constructor(id: T, details: IdsDetailsType[T]) {\n super();\n\n this.id = id;\n this.stack = new Error().stack!;\n this.details = details;\n }\n\n // Marker to distinct Err class from other errors\n private isErr = 'yes';\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;;AA+EO,MAAMA,OAAO,SAASC,KAAK,CAAC;EAMjCC,WAAWA,CAACC,EAAc,EAAEC,KAAsB,EAAE;IAClD,KAAK,CAAC,CAAC;IAEP,IAAI,CAACD,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACE,KAAK,GAAG,IAAIJ,KAAK,CAAC,CAAC,CAACI,KAAM;IAE/B,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC7B,IAAI,CAACE,OAAO,GAAGF,KAAK;IACtB,CAAC,MAAM,IAAIA,KAAK,YAAYH,KAAK,EAAE;MACjC,IAAI,CAACK,OAAO,GAAGF,KAAK,CAACE,OAAO;MAC5B,IAAI,CAACC,IAAI,GAAGH,KAAK,CAACG,IAAI;IACxB,CAAC,MAAM;MACL,IAAI,CAACD,OAAO,GAAG,EAAE;IACnB;EACF;;EAEA;EACQE,KAAK,GAAG,KAAK;AACvB;AAACC,OAAA,CAAAT,OAAA,GAAAA,OAAA;AAEM,MAAMU,OAAO,SAA+BT,KAAK,CAAC;EAIvDC,WAAWA,CAACC,EAAK,EAAEQ,OAA0B,EAAE;IAC7C,KAAK,CAAC,CAAC;IAEP,IAAI,CAACR,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACE,KAAK,GAAG,IAAIJ,KAAK,CAAC,CAAC,CAACI,KAAM;IAC/B,IAAI,CAACM,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACQH,KAAK,GAAG,KAAK;AACvB;AAACC,OAAA,CAAAC,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["GlobalTypes.ts"],"sourcesContent":["/**\n * Generic message interface used throughout the plugin\n * @template T - Type of the data payload (defaults to any)\n * @private\n * @ignore\n */\nexport type Msg<T = any> = {\n /** Message/Event type identifier */\n type: string;\n /** Organization identifier */\n orgId: string;\n /** Unique tracking identifier for the message/Event */\n trackingId: string;\n /** Message/Event payload data */\n data: T;\n};\n\n/**\n * Represents a failure message with specific error details\n * @private\n * @ignore\n */\nexport type Failure = Msg<{\n /** Agent identifier associated with the failure */\n agentId: string;\n /** Tracking identifier for the failure event */\n trackingId: string;\n /** Numeric code indicating the reason for failure */\n reasonCode: number;\n /** Organization identifier */\n orgId: string;\n /** Human-readable description of the failure reason */\n reason: string;\n}>;\n\n/**\n * Represents task API error details in a structured format\n * @public\n */\nexport interface TaskError {\n /** Original error object for throwing */\n error: Error;\n /** Unique tracking identifier for correlation */\n trackingId: string;\n /** Detailed error message from the API */\n errorMessage: string;\n /** Type/category of the error (e.g., \"Bad Request\") */\n errorType: string;\n /** Additional error context data */\n errorData: string;\n /** Numeric reason code */\n reasonCode: number;\n}\n\n/**\n * An Error object augmented with a flexible data field for additional context.\n * Use this to attach structured data to thrown errors without ts-ignore.\n */\nexport interface AugmentedError extends Error {\n data?: Record<string, any>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["GlobalTypes.ts"],"sourcesContent":["/**\n * Generic message interface used throughout the plugin\n * @template T - Type of the data payload (defaults to any)\n * @private\n * @ignore\n */\nexport type Msg<T = any> = {\n /** Message/Event type identifier */\n type: string;\n /** Organization identifier */\n orgId: string;\n /** Unique tracking identifier for the message/Event */\n trackingId: string;\n /** Message/Event payload data */\n data: T;\n};\n\n/**\n * Represents a failure message with specific error details\n * @private\n * @ignore\n */\nexport type Failure = Msg<{\n /** Agent identifier associated with the failure */\n agentId: string;\n /** Tracking identifier for the failure event */\n trackingId: string;\n /** Numeric code indicating the reason for failure */\n reasonCode: number;\n /** Organization identifier */\n orgId: string;\n /** Human-readable description of the failure reason */\n reason: string;\n}>;\n\n/**\n * Represents task API error details in a structured format\n * @public\n */\nexport interface TaskError {\n /** Original error object for throwing */\n error: Error;\n /** Unique tracking identifier for correlation */\n trackingId: string;\n /** Detailed error message from the API */\n errorMessage: string;\n /** Type/category of the error (e.g., \"Bad Request\") */\n errorType: string;\n /** Additional error context data */\n errorData: string;\n /** Numeric reason code */\n reasonCode: number;\n}\n\n/**\n * An Error object augmented with a flexible data field for additional context.\n * Use this to attach structured data to thrown errors without ts-ignore.\n */\nexport interface AugmentedError extends Error {\n data?: Record<string, any>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -10,9 +10,8 @@ var _loggerProxy = _interopRequireDefault(require("../../logger-proxy"));
10
10
  var _WebexRequest = _interopRequireDefault(require("./WebexRequest"));
11
11
  var _types2 = require("../task/types");
12
12
  var _constants = require("./constants");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
15
  /**
17
16
  * Extracts common error details from a Webex request payload.
18
17
  *
@@ -1 +1 @@
1
- {"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","_constants","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","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};\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;AAMA,IAAAM,UAAA,GAAAN,OAAA;AAA6D,SAAAG,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAA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{"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};\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;AAMA,IAAAM,UAAA,GAAAN,OAAA;AAA6D,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAA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ACC,UAAU;EAClD;EAEA,OAAOD,yCAAiC,CAACT,KAAK;AAChD,CAAC;AAACpE,OAAA,CAAAgF,oCAAA,GAAAA,oCAAA","ignoreList":[]}
@@ -9,7 +9,7 @@ var _loggerProxy = _interopRequireDefault(require("../../logger-proxy"));
9
9
  var _constants2 = require("./constants");
10
10
  var _constants3 = require("../../metrics/constants");
11
11
  var _MetricsManager = _interopRequireDefault(require("../../metrics/MetricsManager"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  class WebexRequest {
14
14
  static getInstance(options) {
15
15
  if (!WebexRequest.instance && options && options.webex) {
@@ -55,7 +55,6 @@ class WebexRequest {
55
55
  type: 'diff'
56
56
  } // this is to take the diff logs from previous upload
57
57
  );
58
-
59
58
  _loggerProxy.default.info(`Logs uploaded successfully with feedbackId: ${feedbackId}`, {
60
59
  module: _constants.WEBEX_REQUEST_FILE,
61
60
  method: _constants2.METHODS.UPLOAD_LOGS
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","_loggerProxy","_interopRequireDefault","_constants2","_constants3","_MetricsManager","obj","__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 },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a,EAAEtB,QAAQ,EAAEsB;MAC3B,CAAC,EACD,CAAC,YAAY,CACf,CAAC;MACD,MAAMG,KAAK;IACb;EACF;AACF;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAEcC,YAAY"}
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,KAA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AAU,EAAEjB,QAAQ,CAACiB,UAAU;QAC/B,IAAIjB,QAAQ,CAACmB,GAAG,GAAG;UAACA,GAAG,EAAEnB,QAAQ,CAACmB;QAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAInB,QAAQ,CAACoB,MAAM,GAAG;UAACA,MAAM,EAAEpB,QAAQ,CAACoB;QAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,IAAIpB,QAAQ,CAACkB,aAAa,GAAG;UAACA,aAAa,EAAElB,QAAQ,CAACkB;QAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1ErB;MACF,CAAC;IACH,CAAC,CAAC,OAAOwB,KAAK,EAAE;MACdf,oBAAW,CAACe,KAAK,CAAC,yBAAyBA,KAAK,EAAE,EAAE;QAClDb,MAAM,EAAEC,6BAAkB;QAC1BhB,MAAM,EAAEiB,mBAAO,CAACC;MAClB,CAAC,CAAC;MAEFC,uBAAc,CAAC3B,WAAW,CAAC,CAAC,CAAC4B,UAAU,CACrCC,8BAAkB,CAACQ,kBAAkB,EACrC;QACEC,KAAK,EAAEF,KAAK,EAAEE,KAAK;QACnB1B,UAAU;QACVqB,aAAa,EAAEtB,QAAQ,EAAEsB;MAC3B,CAAC,EACD,CAAC,YAAY,CACf,CAAC;MACD,MAAMG,KAAK;IACb;EACF;AACF;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAEcC,YAAY","ignoreList":[]}
@@ -10,9 +10,8 @@ var _loggerProxy = _interopRequireDefault(require("../../logger-proxy"));
10
10
  var _constants = require("./constants");
11
11
  var _constants2 = require("../../constants");
12
12
  var _WebexRequest = _interopRequireDefault(require("./WebexRequest"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
15
  class AqmReqs {
17
16
  pendingRequests = {};
18
17
  pendingNotifCancelrequest = {};
@@ -1 +1 @@
1
- {"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC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EA,IAAIL,KAAK,CAACE,IAAI,KAAK,oBAAoB,EAAE;MACvCzC,oBAAW,CAAC0C,IAAI,CAAC,0CAA0C,EAAE;QAC3DtC,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;IAEA,IAAIE,SAAS,GAAG,KAAK;IAErB,MAAMC,IAAI,GAAG/F,MAAM,CAACgG,IAAI,CAAC,IAAI,CAACtF,eAAe,CAAC;IAC9C,KAAK,MAAMuF,OAAO,IAAIF,IAAI,EAAE;MAC1B,MAAM3E,GAAG,GAAG,IAAI,CAACV,eAAe,CAACuF,OAAO,CAAC;MACzC,IAAI7E,GAAG,CAACwB,KAAK,CAAC4C,KAAK,CAAC,EAAE;QACpBpE,GAAG,CAAC0B,MAAM,CAAC0C,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;QAChB;MACF;IACF;IACA;IACA,MAAMI,OAAO,GAAGlG,MAAM,CAACgG,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,CAAE,uEAAsE,EAAE;QACxFtC,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAA9G,OAAA,GAAAoB,OAAA"}
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,CA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,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAA3G,OAAA,GAAAiB,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["KEEPALIVE_WORKER_INTERVAL","exports","NOTIFS_RESOLVE_DELAY","CLOSE_SOCKET_TIMEOUT_DURATION","PING_API_URL","WELCOME_TIMEOUT","RTD_PING_EVENT","TIMEOUT_REQ","LOST_CONNECTION_RECOVERY_TIMEOUT","WS_DISCONNECT_ALLOWED","CONNECTIVITY_CHECK_INTERVAL","CLOSE_SOCKET_TIMEOUT","PARTICIPANT_TYPES","EP_DN","DN","AGENT","STATE_CONSULT","METHODS","REQUEST","UPLOAD_LOGS","GET_ERROR_DETAILS","GET_COMMON_ERROR_DETAILS","CREATE_ERR_DETAILS_OBJECT","REQ","REQ_EMPTY","MAKE_API_REQUEST","CREATE_PROMISE","BIND_PRINT","BIND_CHECK","ON_MESSAGE","INIT_WEB_SOCKET","CLOSE","HANDLE_CONNECTION_LOST","REGISTER","CONNECT","WEB_SOCKET_ON_CLOSE_HANDLER","SETUP_EVENT_LISTENERS","DISPATCH_CONNECTION_EVENT","CS_HANDLE_CONNECTION_LOST","CLEAR_TIMER_ON_RESTORE_FAILED","HANDLE_RESTORE_FAILED","UPDATE_CONNECTION_DATA","SET_CONNECTION_PROP","ON_PING","HANDLE_SOCKET_CLOSE","ON_SOCKET_CLOSE"],"sources":["constants.ts"],"sourcesContent":["/**\n * Interval in milliseconds for sending keepalive pings to the worker.\n * @ignore\n */\nexport const KEEPALIVE_WORKER_INTERVAL = 4000;\n\n/**\n * Delay in milliseconds before resolving notification handlers.\n * @ignore\n */\nexport const NOTIFS_RESOLVE_DELAY = 1200;\n\n/**\n * Timeout duration in milliseconds before forcefully closing a WebSocket connection.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;\n\n/**\n * API endpoint used for connectivity or health checks.\n * @ignore\n */\nexport const PING_API_URL = '/health';\n\n/**\n * Timeout in milliseconds to wait for a welcome message after socket connection.\n * @ignore\n */\nexport const WELCOME_TIMEOUT = 30000;\n\n/**\n * Event name used for real-time device (RTD) ping status.\n * @ignore\n */\nexport const RTD_PING_EVENT = 'rtd-online-status';\n\n/**\n * Timeout in milliseconds for individual HTTP requests.\n * @ignore\n */\nexport const TIMEOUT_REQ = 20000;\n\n/**\n * Duration in milliseconds to wait before attempting lost connection recovery.\n * @ignore\n */\nexport const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;\n\n/**\n * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.\n * @ignore\n */\nexport const WS_DISCONNECT_ALLOWED = 8000;\n\n/**\n * Interval in milliseconds to check for connectivity status.\n * @ignore\n */\nexport const CONNECTIVITY_CHECK_INTERVAL = 5000;\n\n/**\n * Timeout in milliseconds for cleanly closing the WebSocket.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT = 16000;\n\n/**\n * Constants for participant types, destination types, and interaction states\n * @ignore\n */\nexport const PARTICIPANT_TYPES = {\n /** Participant type for Entry Point Dial Number */\n EP_DN: 'EpDn',\n /** Participant type for dial number */\n DN: 'dn',\n /** Participant type for Agent */\n AGENT: 'Agent',\n};\n\n/** Interaction state for consultation */\nexport const STATE_CONSULT = 'consult';\n\n// Method names for core services\nexport const METHODS = {\n // WebexRequest methods\n REQUEST: 'request',\n UPLOAD_LOGS: 'uploadLogs',\n\n // Utils methods\n GET_ERROR_DETAILS: 'getErrorDetails',\n GET_COMMON_ERROR_DETAILS: 'getCommonErrorDetails',\n CREATE_ERR_DETAILS_OBJECT: 'createErrDetailsObject',\n\n // AqmReqs methods\n REQ: 'req',\n REQ_EMPTY: 'reqEmpty',\n MAKE_API_REQUEST: 'makeAPIRequest',\n CREATE_PROMISE: 'createPromise',\n BIND_PRINT: 'bindPrint',\n BIND_CHECK: 'bindCheck',\n ON_MESSAGE: 'onMessage',\n\n // WebSocketManager methods\n INIT_WEB_SOCKET: 'initWebSocket',\n CLOSE: 'close',\n HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n REGISTER: 'register',\n CONNECT: 'connect',\n WEB_SOCKET_ON_CLOSE_HANDLER: 'webSocketOnCloseHandler',\n\n // ConnectionService methods\n SETUP_EVENT_LISTENERS: 'setupEventListeners',\n DISPATCH_CONNECTION_EVENT: 'dispatchConnectionEvent',\n CS_HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n CLEAR_TIMER_ON_RESTORE_FAILED: 'clearTimerOnRestoreFailed',\n HANDLE_RESTORE_FAILED: 'handleRestoreFailed',\n UPDATE_CONNECTION_DATA: 'updateConnectionData',\n SET_CONNECTION_PROP: 'setConnectionProp',\n ON_PING: 'onPing',\n HANDLE_SOCKET_CLOSE: 'handleSocketClose',\n ON_SOCKET_CLOSE: 'onSocketClose',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,IAAI;;AAE7C;AACA;AACA;AACA;AACO,MAAME,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,GAAG,IAAI;;AAExC;AACA;AACA;AACA;AACO,MAAMC,6BAA6B,GAAAF,OAAA,CAAAE,6BAAA,GAAG,KAAK;;AAElD;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,SAAS;;AAErC;AACA;AACA;AACA;AACO,MAAMC,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAG,KAAK;;AAEpC;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAAL,OAAA,CAAAK,cAAA,GAAG,mBAAmB;;AAEjD;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAN,OAAA,CAAAM,WAAA,GAAG,KAAK;;AAEhC;AACA;AACA;AACA;AACO,MAAMC,gCAAgC,GAAAP,OAAA,CAAAO,gCAAA,GAAG,KAAK;;AAErD;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,G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xCC,OAAO,EAAE,QAAQ;EACjBC,mBAAmB,EAAE,mBAAmB;EACxCC,eAAe,EAAE;AACnB,CAAC"}
1
+ {"version":3,"names":["KEEPALIVE_WORKER_INTERVAL","exports","NOTIFS_RESOLVE_DELAY","CLOSE_SOCKET_TIMEOUT_DURATION","PING_API_URL","WELCOME_TIMEOUT","RTD_PING_EVENT","TIMEOUT_REQ","LOST_CONNECTION_RECOVERY_TIMEOUT","WS_DISCONNECT_ALLOWED","CONNECTIVITY_CHECK_INTERVAL","CLOSE_SOCKET_TIMEOUT","PARTICIPANT_TYPES","EP_DN","DN","AGENT","STATE_CONSULT","METHODS","REQUEST","UPLOAD_LOGS","GET_ERROR_DETAILS","GET_COMMON_ERROR_DETAILS","CREATE_ERR_DETAILS_OBJECT","REQ","REQ_EMPTY","MAKE_API_REQUEST","CREATE_PROMISE","BIND_PRINT","BIND_CHECK","ON_MESSAGE","INIT_WEB_SOCKET","CLOSE","HANDLE_CONNECTION_LOST","REGISTER","CONNECT","WEB_SOCKET_ON_CLOSE_HANDLER","SETUP_EVENT_LISTENERS","DISPATCH_CONNECTION_EVENT","CS_HANDLE_CONNECTION_LOST","CLEAR_TIMER_ON_RESTORE_FAILED","HANDLE_RESTORE_FAILED","UPDATE_CONNECTION_DATA","SET_CONNECTION_PROP","ON_PING","HANDLE_SOCKET_CLOSE","ON_SOCKET_CLOSE"],"sources":["constants.ts"],"sourcesContent":["/**\n * Interval in milliseconds for sending keepalive pings to the worker.\n * @ignore\n */\nexport const KEEPALIVE_WORKER_INTERVAL = 4000;\n\n/**\n * Delay in milliseconds before resolving notification handlers.\n * @ignore\n */\nexport const NOTIFS_RESOLVE_DELAY = 1200;\n\n/**\n * Timeout duration in milliseconds before forcefully closing a WebSocket connection.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;\n\n/**\n * API endpoint used for connectivity or health checks.\n * @ignore\n */\nexport const PING_API_URL = '/health';\n\n/**\n * Timeout in milliseconds to wait for a welcome message after socket connection.\n * @ignore\n */\nexport const WELCOME_TIMEOUT = 30000;\n\n/**\n * Event name used for real-time device (RTD) ping status.\n * @ignore\n */\nexport const RTD_PING_EVENT = 'rtd-online-status';\n\n/**\n * Timeout in milliseconds for individual HTTP requests.\n * @ignore\n */\nexport const TIMEOUT_REQ = 20000;\n\n/**\n * Duration in milliseconds to wait before attempting lost connection recovery.\n * @ignore\n */\nexport const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;\n\n/**\n * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.\n * @ignore\n */\nexport const WS_DISCONNECT_ALLOWED = 8000;\n\n/**\n * Interval in milliseconds to check for connectivity status.\n * @ignore\n */\nexport const CONNECTIVITY_CHECK_INTERVAL = 5000;\n\n/**\n * Timeout in milliseconds for cleanly closing the WebSocket.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT = 16000;\n\n/**\n * Constants for participant types, destination types, and interaction states\n * @ignore\n */\nexport const PARTICIPANT_TYPES = {\n /** Participant type for Entry Point Dial Number */\n EP_DN: 'EpDn',\n /** Participant type for dial number */\n DN: 'dn',\n /** Participant type for Agent */\n AGENT: 'Agent',\n};\n\n/** Interaction state for consultation */\nexport const STATE_CONSULT = 'consult';\n\n// Method names for core services\nexport const METHODS = {\n // WebexRequest methods\n REQUEST: 'request',\n UPLOAD_LOGS: 'uploadLogs',\n\n // Utils methods\n GET_ERROR_DETAILS: 'getErrorDetails',\n GET_COMMON_ERROR_DETAILS: 'getCommonErrorDetails',\n CREATE_ERR_DETAILS_OBJECT: 'createErrDetailsObject',\n\n // AqmReqs methods\n REQ: 'req',\n REQ_EMPTY: 'reqEmpty',\n MAKE_API_REQUEST: 'makeAPIRequest',\n CREATE_PROMISE: 'createPromise',\n BIND_PRINT: 'bindPrint',\n BIND_CHECK: 'bindCheck',\n ON_MESSAGE: 'onMessage',\n\n // WebSocketManager methods\n INIT_WEB_SOCKET: 'initWebSocket',\n CLOSE: 'close',\n HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n REGISTER: 'register',\n CONNECT: 'connect',\n WEB_SOCKET_ON_CLOSE_HANDLER: 'webSocketOnCloseHandler',\n\n // ConnectionService methods\n SETUP_EVENT_LISTENERS: 'setupEventListeners',\n DISPATCH_CONNECTION_EVENT: 'dispatchConnectionEvent',\n CS_HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n CLEAR_TIMER_ON_RESTORE_FAILED: 'clearTimerOnRestoreFailed',\n HANDLE_RESTORE_FAILED: 'handleRestoreFailed',\n UPDATE_CONNECTION_DATA: 'updateConnectionData',\n SET_CONNECTION_PROP: 'setConnectionProp',\n ON_PING: 'onPing',\n HANDLE_SOCKET_CLOSE: 'handleSocketClose',\n ON_SOCKET_CLOSE: 'onSocketClose',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,IAAI;;AAE7C;AACA;AACA;AACA;AACO,MAAME,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,GAAG,IAAI;;AAExC;AACA;AACA;AACA;AACO,MAAMC,6BAA6B,GAAAF,OAAA,CAAAE,6BAAA,GAAG,KAAK;;AAElD;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,SAAS;;AAErC;AACA;AACA;AACA;AACO,MAAMC,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAG,KAAK;;AAEpC;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAAL,OAAA,CAAAK,cAAA,GAAG,mBAAmB;;AAEjD;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAN,OAAA,CAAAM,WAAA,GAAG,KAAK;;AAEhC;AACA;AACA;AACA;AACO,MAAMC,gCAAgC,GAAAP,OAAA,CAAAO,gCAAA,GAAG,KAAK;;AAErD;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAAR,OAAA,CAAAQ,qBAAA,GAAG,IAAI;;AAEzC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BAAmB;EACxCC,eAAe,EAAE;AACnB,CAAC","ignoreList":[]}
@@ -1 +1 @@
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 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":""}
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 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":[]}
@@ -12,7 +12,7 @@ var _loggerProxy = _interopRequireDefault(require("../../../logger-proxy"));
12
12
  var _keepalive = _interopRequireDefault(require("./keepalive.worker"));
13
13
  var _constants2 = require("../constants");
14
14
  var _constants3 = require("../../../constants");
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  /**
17
17
  * WebSocketManager handles the WebSocket connection for Contact Center operations.
18
18
  * It manages the connection lifecycle, including registration, reconnection, and message handling.
@@ -124,7 +124,6 @@ class WebSocketManager extends _events.default {
124
124
  closeSocketTimeout: _constants2.CLOSE_SOCKET_TIMEOUT // Close socket timeout
125
125
  });
126
126
  };
127
-
128
127
  this.websocket.onerror = event => {
129
128
  _loggerProxy.default.error(`[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`, {
130
129
  module: _constants3.WEB_SOCKET_MANAGER_FILE,
@@ -1 +1 @@
1
- {"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","obj","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","connectionConfig","body","register","Promise","resolve","reject","connect","catch","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","subscribeResponse","request","service","WCC_API_GATEWAY","resource","SUBSCRIBE_API","HTTP_METHODS","POST","webSocketUrl","e","REGISTER","undefined","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","WEB_SOCKET_ON_CLOSE_HANDLER","exports"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {SUBSCRIBE_API, WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {KEEPALIVE_WORKER_INTERVAL, CLOSE_SOCKET_TIMEOUT, METHODS} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {body: SubscribeRequest}): Promise<WelcomeResponse> {\n const connectionConfig = options.body;\n await this.register(connectionConfig);\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest) {\n try {\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource: SUBSCRIBE_API,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n });\n this.url = subscribeResponse.body.webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n issueReason = !onlineStatus\n ? 'network issue'\n : 'missing keepalive from either desktop or notif service';\n }\n LoggerProxy.error(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER}\n );\n this.forceCloseWebSocketOnTimeout = false;\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA2D,SAAAD,uBAAAS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,CAAC,CAAC;EACJ;;EAEA;EACA,MAAcgB,uBAAuBA,CAAC7B,KAAU,EAAE;IAChD,IAAI,CAAClC,cAAc,GAAG,IAAI;IAC1B,IAAI,CAACQ,eAAe,CAACsB,WAAW,CAAC;MAACvB,IAAI,EAAE;IAAW,CAAC,CAAC;IACrD,IAAI,IAAI,CAACT,eAAe,EAAE;MACxB,IAAI,CAACkE,IAAI,CAAC,aAAa,CAAC;MACxB,IAAIK,WAAW;MACf,IAAI,IAAI,CAACnE,4BAA4B,EAAE;QACrCmE,WAAW,GAAG,8DAA8D;MAC9E,CAAC,MAAM;QACL,MAAMC,YAAY,GAAGC,SAAS,CAACC,MAAM;QACrCH,WAAW,GAAG,CAACC,YAAY,GACvB,eAAe,GACf,wDAAwD;MAC9D;MACAhD,oBAAW,CAACD,KAAK,CACd,kFAAiFgD,WAAY,EAAC,EAC/F;QAAC9C,MAAM,EAAEC,mCAAuB;QAAEC,MAAM,EAAEC,mBAAO,CAAC+C;MAA2B,CAC/E,CAAC;MACD,IAAI,CAACvE,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAACwE,OAAA,CAAAnF,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","e","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","connectionConfig","body","register","Promise","resolve","reject","connect","catch","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","subscribeResponse","request","service","WCC_API_GATEWAY","resource","SUBSCRIBE_API","HTTP_METHODS","POST","webSocketUrl","REGISTER","undefined","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","WEB_SOCKET_ON_CLOSE_HANDLER","exports"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {SUBSCRIBE_API, WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {KEEPALIVE_WORKER_INTERVAL, CLOSE_SOCKET_TIMEOUT, METHODS} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {body: SubscribeRequest}): Promise<WelcomeResponse> {\n const connectionConfig = options.body;\n await this.register(connectionConfig);\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest) {\n try {\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource: SUBSCRIBE_API,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n });\n this.url = subscribeResponse.body.webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n issueReason = !onlineStatus\n ? 'network issue'\n : 'missing keepalive from either desktop or notif service';\n }\n LoggerProxy.error(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER}\n );\n this.forceCloseWebSocketOnTimeout = false;\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA2D,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,SAASC,eAAY,CAAC;EAKzCC,GAAG,GAAkB,IAAI;EAIzBC,qBAAqB,GAElB,IAAI;EAIfC,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC,CAAC;IACP,MAAM;MAACC;IAAK,CAAC,GAAGD,OAAO;IACvB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B,IAAI,CAACC,SAAS,GAAG,CAAC,CAAc;IAChC,IAAI,CAACC,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B,IAAI,CAACC,4BAA4B,GAAG,KAAK;IACzC,IAAI,CAACC,gBAAgB,GAAG,KAAK;IAE7B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AAEC,mBAAO,CAAC8C;MAA2B,CAC/E,CAAC;MACD,IAAI,CAACtE,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAACuE,OAAA,CAAAlF,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -8,7 +8,7 @@ var _events = require("events");
8
8
  var _loggerProxy = _interopRequireDefault(require("../../../logger-proxy"));
9
9
  var _constants = require("../constants");
10
10
  var _constants2 = require("../../../constants");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  class ConnectionService extends _events.EventEmitter {
13
13
  connectionProp = {
14
14
  lostConnectionRecoveryTimeout: _constants.LOST_CONNECTION_RECOVERY_TIMEOUT
@@ -1 +1 @@
1
- {"version":3,"names":["_events","require","_loggerProxy","_interopRequireDefault","_constants","_constants2","obj","__esModule","default","ConnectionService","EventEmitter","connectionProp","lostConnectionRecoveryTimeout","LOST_CONNECTION_RECOVERY_TIMEOUT","wsDisconnectAllowed","WS_DISCONNECT_ALLOWED","constructor","options","webSocketManager","subscribeRequest","isConnectionLost","isRestoreFailed","isSocketReconnected","isKeepAlive","setupEventListeners","on","onPing","bind","onSocketClose","dispatchConnectionEvent","socketReconnected","event","isSocketClosed","handleConnectionLost","LoggerProxy","info","module","CONNECTION_SERVICE_FILE","method","METHODS","DISPATCH_CONNECTION_EVENT","emit","clearTimerOnRestoreFailed","reconnectInterval","clearInterval","handleRestoreFailed","shouldReconnect","updateConnectionData","setConnectionProp","prop","parsedEvent","JSON","parse","reconnectingTimer","clearTimeout","restoreTimer","keepalive","setTimeout","handleSocketClose","HANDLE_SOCKET_CLOSE","onlineStatus","navigator","onLine","initWebSocket","body","Error","setInterval","CONNECTIVITY_CHECK_INTERVAL","exports"],"sources":["connection-service.ts"],"sourcesContent":["import {EventEmitter} from 'events';\nimport {WebSocketManager} from './WebSocketManager';\nimport LoggerProxy from '../../../logger-proxy';\nimport {ConnectionServiceOptions, ConnectionLostDetails, ConnectionProp} from './types';\nimport {\n LOST_CONNECTION_RECOVERY_TIMEOUT,\n WS_DISCONNECT_ALLOWED,\n CONNECTIVITY_CHECK_INTERVAL,\n METHODS,\n} from '../constants';\nimport {CONNECTION_SERVICE_FILE} from '../../../constants';\nimport {SubscribeRequest} from '../../../types';\n\nexport class ConnectionService extends EventEmitter {\n private connectionProp: ConnectionProp = {\n lostConnectionRecoveryTimeout: LOST_CONNECTION_RECOVERY_TIMEOUT,\n };\n\n private wsDisconnectAllowed = WS_DISCONNECT_ALLOWED;\n private reconnectingTimer: ReturnType<typeof setTimeout>;\n private restoreTimer: ReturnType<typeof setTimeout>;\n private isConnectionLost: boolean;\n private isRestoreFailed: boolean;\n private isSocketReconnected: boolean;\n private isKeepAlive: boolean;\n private reconnectInterval: ReturnType<typeof setInterval>;\n private webSocketManager: WebSocketManager;\n private subscribeRequest: SubscribeRequest;\n\n constructor(options: ConnectionServiceOptions) {\n super();\n this.webSocketManager = options.webSocketManager;\n this.subscribeRequest = options.subscribeRequest;\n\n this.isConnectionLost = false;\n this.isRestoreFailed = false;\n this.isSocketReconnected = false;\n this.isKeepAlive = false;\n\n this.setupEventListeners();\n }\n\n private setupEventListeners() {\n this.webSocketManager.on('message', this.onPing.bind(this));\n this.webSocketManager.on('socketClose', this.onSocketClose.bind(this));\n }\n\n private dispatchConnectionEvent(socketReconnected = false): void {\n const event: ConnectionLostDetails = {\n isConnectionLost: this.isConnectionLost,\n isRestoreFailed: this.isRestoreFailed,\n isSocketReconnected:\n !this.webSocketManager.isSocketClosed && (socketReconnected || this.isSocketReconnected),\n isKeepAlive: this.isKeepAlive,\n };\n this.webSocketManager.handleConnectionLost(event);\n LoggerProxy.info(`Dispatching connection event`, {\n module: CONNECTION_SERVICE_FILE,\n method: METHODS.DISPATCH_CONNECTION_EVENT,\n });\n this.emit('connectionLost', event);\n }\n\n private handleConnectionLost = (): void => {\n this.isConnectionLost = true;\n this.dispatchConnectionEvent();\n };\n\n private clearTimerOnRestoreFailed = async () => {\n if (this.reconnectInterval) {\n clearInterval(this.reconnectInterval);\n }\n };\n\n private handleRestoreFailed = async () => {\n this.isRestoreFailed = true;\n this.webSocketManager.shouldReconnect = false;\n this.dispatchConnectionEvent();\n await this.clearTimerOnRestoreFailed();\n };\n\n private updateConnectionData = (): void => {\n this.isRestoreFailed = false;\n this.isConnectionLost = false;\n this.isSocketReconnected = false;\n };\n\n public setConnectionProp(prop: ConnectionProp): void {\n this.connectionProp = prop;\n }\n\n private onPing = (event: any): void => {\n const parsedEvent = JSON.parse(event);\n if (this.reconnectingTimer) {\n clearTimeout(this.reconnectingTimer);\n }\n if (this.restoreTimer) {\n clearTimeout(this.restoreTimer);\n }\n this.isKeepAlive = parsedEvent.keepalive === 'true';\n\n if (\n ((this.isConnectionLost && !this.isRestoreFailed) || this.isKeepAlive) &&\n !this.isSocketReconnected\n ) {\n this.updateConnectionData();\n this.dispatchConnectionEvent();\n } else if (this.isSocketReconnected && this.isKeepAlive) {\n this.updateConnectionData();\n this.dispatchConnectionEvent(true);\n }\n\n this.reconnectingTimer = setTimeout(this.handleConnectionLost, this.wsDisconnectAllowed);\n this.restoreTimer = setTimeout(\n this.handleRestoreFailed,\n this.connectionProp && this.connectionProp.lostConnectionRecoveryTimeout\n );\n };\n\n private handleSocketClose = async (): Promise<void> => {\n LoggerProxy.info(`event=socketConnectionRetry | Trying to reconnect to websocket`, {\n module: CONNECTION_SERVICE_FILE,\n method: METHODS.HANDLE_SOCKET_CLOSE,\n });\n const onlineStatus = navigator.onLine;\n if (onlineStatus) {\n await this.webSocketManager.initWebSocket({body: this.subscribeRequest});\n await this.clearTimerOnRestoreFailed();\n this.isSocketReconnected = true;\n } else {\n throw new Error('event=socketConnectionRetry | browser network not available');\n }\n };\n\n private onSocketClose = (): void => {\n this.clearTimerOnRestoreFailed();\n\n this.reconnectInterval = setInterval(async () => {\n await this.handleSocketClose();\n }, CONNECTIVITY_CHECK_INTERVAL);\n };\n}\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AAC;MACtC,IAAI,CAACpB,mBAAmB,GAAG,IAAI;IACjC,CAAC,MAAM;MACL,MAAM,IAAI2C,KAAK,CAAC,6DAA6D,CAAC;IAChF;EACF,CAAC;EAEOrC,aAAa,GAAGA,CAAA,KAAY;IAClC,IAAI,CAACc,yBAAyB,CAAC,CAAC;IAEhC,IAAI,CAACC,iBAAiB,GAAGuB,WAAW,CAAC,YAAY;MAC/C,MAAM,IAAI,CAACR,iBAAiB,CAAC,CAAC;IAChC,CAAC,EAAES,sCAA2B,CAAC;EACjC,CAAC;AACH;AAACC,OAAA,CAAA3D,iBAAA,GAAAA,iBAAA"}
1
+ {"version":3,"names":["_events","require","_loggerProxy","_interopRequireDefault","_constants","_constants2","e","__esModule","default","ConnectionService","EventEmitter","connectionProp","lostConnectionRecoveryTimeout","LOST_CONNECTION_RECOVERY_TIMEOUT","wsDisconnectAllowed","WS_DISCONNECT_ALLOWED","constructor","options","webSocketManager","subscribeRequest","isConnectionLost","isRestoreFailed","isSocketReconnected","isKeepAlive","setupEventListeners","on","onPing","bind","onSocketClose","dispatchConnectionEvent","socketReconnected","event","isSocketClosed","handleConnectionLost","LoggerProxy","info","module","CONNECTION_SERVICE_FILE","method","METHODS","DISPATCH_CONNECTION_EVENT","emit","clearTimerOnRestoreFailed","reconnectInterval","clearInterval","handleRestoreFailed","shouldReconnect","updateConnectionData","setConnectionProp","prop","parsedEvent","JSON","parse","reconnectingTimer","clearTimeout","restoreTimer","keepalive","setTimeout","handleSocketClose","HANDLE_SOCKET_CLOSE","onlineStatus","navigator","onLine","initWebSocket","body","Error","setInterval","CONNECTIVITY_CHECK_INTERVAL","exports"],"sources":["connection-service.ts"],"sourcesContent":["import {EventEmitter} from 'events';\nimport {WebSocketManager} from './WebSocketManager';\nimport LoggerProxy from '../../../logger-proxy';\nimport {ConnectionServiceOptions, ConnectionLostDetails, ConnectionProp} from './types';\nimport {\n LOST_CONNECTION_RECOVERY_TIMEOUT,\n WS_DISCONNECT_ALLOWED,\n CONNECTIVITY_CHECK_INTERVAL,\n METHODS,\n} from '../constants';\nimport {CONNECTION_SERVICE_FILE} from '../../../constants';\nimport {SubscribeRequest} from '../../../types';\n\nexport class ConnectionService extends EventEmitter {\n private connectionProp: ConnectionProp = {\n lostConnectionRecoveryTimeout: LOST_CONNECTION_RECOVERY_TIMEOUT,\n };\n\n private wsDisconnectAllowed = WS_DISCONNECT_ALLOWED;\n private reconnectingTimer: ReturnType<typeof setTimeout>;\n private restoreTimer: ReturnType<typeof setTimeout>;\n private isConnectionLost: boolean;\n private isRestoreFailed: boolean;\n private isSocketReconnected: boolean;\n private isKeepAlive: boolean;\n private reconnectInterval: ReturnType<typeof setInterval>;\n private webSocketManager: WebSocketManager;\n private subscribeRequest: SubscribeRequest;\n\n constructor(options: ConnectionServiceOptions) {\n super();\n this.webSocketManager = options.webSocketManager;\n this.subscribeRequest = options.subscribeRequest;\n\n this.isConnectionLost = false;\n this.isRestoreFailed = false;\n this.isSocketReconnected = false;\n this.isKeepAlive = false;\n\n this.setupEventListeners();\n }\n\n private setupEventListeners() {\n this.webSocketManager.on('message', this.onPing.bind(this));\n this.webSocketManager.on('socketClose', this.onSocketClose.bind(this));\n }\n\n private dispatchConnectionEvent(socketReconnected = false): void {\n const event: ConnectionLostDetails = {\n isConnectionLost: this.isConnectionLost,\n isRestoreFailed: this.isRestoreFailed,\n isSocketReconnected:\n !this.webSocketManager.isSocketClosed && (socketReconnected || this.isSocketReconnected),\n isKeepAlive: this.isKeepAlive,\n };\n this.webSocketManager.handleConnectionLost(event);\n LoggerProxy.info(`Dispatching connection event`, {\n module: CONNECTION_SERVICE_FILE,\n method: METHODS.DISPATCH_CONNECTION_EVENT,\n });\n this.emit('connectionLost', event);\n }\n\n private handleConnectionLost = (): void => {\n this.isConnectionLost = true;\n this.dispatchConnectionEvent();\n };\n\n private clearTimerOnRestoreFailed = async () => {\n if (this.reconnectInterval) {\n clearInterval(this.reconnectInterval);\n }\n };\n\n private handleRestoreFailed = async () => {\n this.isRestoreFailed = true;\n this.webSocketManager.shouldReconnect = false;\n this.dispatchConnectionEvent();\n await this.clearTimerOnRestoreFailed();\n };\n\n private updateConnectionData = (): void => {\n this.isRestoreFailed = false;\n this.isConnectionLost = false;\n this.isSocketReconnected = false;\n };\n\n public setConnectionProp(prop: ConnectionProp): void {\n this.connectionProp = prop;\n }\n\n private onPing = (event: any): void => {\n const parsedEvent = JSON.parse(event);\n if (this.reconnectingTimer) {\n clearTimeout(this.reconnectingTimer);\n }\n if (this.restoreTimer) {\n clearTimeout(this.restoreTimer);\n }\n this.isKeepAlive = parsedEvent.keepalive === 'true';\n\n if (\n ((this.isConnectionLost && !this.isRestoreFailed) || this.isKeepAlive) &&\n !this.isSocketReconnected\n ) {\n this.updateConnectionData();\n this.dispatchConnectionEvent();\n } else if (this.isSocketReconnected && this.isKeepAlive) {\n this.updateConnectionData();\n this.dispatchConnectionEvent(true);\n }\n\n this.reconnectingTimer = setTimeout(this.handleConnectionLost, this.wsDisconnectAllowed);\n this.restoreTimer = setTimeout(\n this.handleRestoreFailed,\n this.connectionProp && this.connectionProp.lostConnectionRecoveryTimeout\n );\n };\n\n private handleSocketClose = async (): Promise<void> => {\n LoggerProxy.info(`event=socketConnectionRetry | Trying to reconnect to websocket`, {\n module: CONNECTION_SERVICE_FILE,\n method: METHODS.HANDLE_SOCKET_CLOSE,\n });\n const onlineStatus = navigator.onLine;\n if (onlineStatus) {\n await this.webSocketManager.initWebSocket({body: this.subscribeRequest});\n await this.clearTimerOnRestoreFailed();\n this.isSocketReconnected = true;\n } else {\n throw new Error('event=socketConnectionRetry | browser network not available');\n }\n };\n\n private onSocketClose = (): void => {\n this.clearTimerOnRestoreFailed();\n\n this.reconnectInterval = setInterval(async () => {\n await this.handleSocketClose();\n }, CONNECTIVITY_CHECK_INTERVAL);\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,I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