@webex/contact-center 3.11.0-next.16 → 3.11.0-next.18

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.
@@ -79,11 +79,23 @@ class WebSocketManager extends _events.default {
79
79
  }
80
80
  async register(connectionConfig) {
81
81
  try {
82
+ // X-ORGANIZATION-ID header is only required for INT environments
83
+ const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;
84
+ const orgId = this.webex.credentials.getOrgId();
85
+ if (isIntEnv && orgId) {
86
+ _loggerProxy.default.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {
87
+ module: _constants3.WEB_SOCKET_MANAGER_FILE,
88
+ method: _constants2.METHODS.REGISTER
89
+ });
90
+ }
82
91
  const subscribeResponse = await this.webex.request({
83
92
  service: _constants.WCC_API_GATEWAY,
84
93
  resource: _constants.SUBSCRIBE_API,
85
94
  method: _types.HTTP_METHODS.POST,
86
- body: connectionConfig
95
+ body: connectionConfig,
96
+ headers: isIntEnv && orgId ? {
97
+ 'X-ORGANIZATION-ID': orgId
98
+ } : undefined
87
99
  });
88
100
  this.url = subscribeResponse.body.webSocketUrl;
89
101
  } catch (e) {
@@ -1 +1 @@
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","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","Promise","resolve","reject","connect","catch","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 try {\n await this.register(connectionConfig);\n } catch (error) {\n LoggerProxy.error(`[WebSocketStatus] | Error in registering Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n throw error;\n }\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 throw e;\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,CA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AAC,CAAC;IACrD,IAAI,IAAI,CAACT,eAAe,EAAE;MACxB,IAAI,CAACiE,IAAI,CAAC,aAAa,CAAC;MACxB,IAAIK,WAAW;MACf,IAAI,IAAI,CAAClE,4BAA4B,EAAE;QACrCkE,WAAW,GAAG,8DAA8D;MAC9E,CAAC,MAAM;QACL,MAAMC,YAAY,GAAGC,SAAS,CAACC,MAAM;QACrCH,WAAW,GAAG,CAACC,YAAY,GACvB,eAAe,GACf,wDAAwD;MAC9D;MACApD,oBAAW,CAACD,KAAK,CACf,kFAAkFoD,WAAW,EAAE,EAC/F;QAAClD,MAAM,EAAEC,mCAAuB;QAAEC,MAAM,EAAEC,mBAAO,CAACmD;MAA2B,CAC/E,CAAC;MACD,IAAI,CAACtE,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAACuE,OAAA,CAAAlF,gBAAA,GAAAA,gBAAA","ignoreList":[]}
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","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","Promise","resolve","reject","connect","catch","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","isIntEnv","internal","services","isIntegrationEnvironment","orgId","credentials","getOrgId","REGISTER","subscribeResponse","request","service","WCC_API_GATEWAY","resource","SUBSCRIBE_API","HTTP_METHODS","POST","headers","undefined","webSocketUrl","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 try {\n await this.register(connectionConfig);\n } catch (error) {\n LoggerProxy.error(`[WebSocketStatus] | Error in registering Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n throw error;\n }\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 // X-ORGANIZATION-ID header is only required for INT environments\n const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;\n const orgId = this.webex.credentials.getOrgId();\n\n if (isIntEnv && orgId) {\n LoggerProxy.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.REGISTER,\n });\n }\n\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 headers: isIntEnv && orgId ? {'X-ORGANIZATION-ID': orgId} : undefined,\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 throw e;\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;MAAC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P_METHODS","exports","GET","POST","PATCH","PUT","DELETE","LOGGING_LEVEL","LoginOption","AGENT_DN","EXTENSION","BROWSER"],"sources":["types.ts"],"sourcesContent":["import {CallingClientConfig} from '@webex/calling';\nimport {\n SubmitBehavioralEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n} from '@webex/internal-plugin-metrics/src/metrics.types';\nimport * as Agent from './services/agent/types';\nimport * as Contact from './services/task/types';\nimport {Profile} from './services/config/types';\nimport {PaginatedResponse, BaseSearchParams} from './utils/PageCache';\n\n/**\n * Generic type for converting a const enum object into a union type of its values.\n * @template T The enum object type\n * @internal\n * @ignore\n */\ntype Enum<T extends Record<string, unknown>> = T[keyof T];\n\n/**\n * HTTP methods supported by WebexRequest.\n * @enum {string}\n * @public\n * @example\n * const method: HTTP_METHODS = HTTP_METHODS.GET;\n * @ignore\n */\nexport const HTTP_METHODS = {\n /** HTTP GET method for retrieving data */\n GET: 'GET',\n /** HTTP POST method for creating resources */\n POST: 'POST',\n /** HTTP PATCH method for partial updates */\n PATCH: 'PATCH',\n /** HTTP PUT method for complete updates */\n PUT: 'PUT',\n /** HTTP DELETE method for removing resources */\n DELETE: 'DELETE',\n} as const;\n\n/**\n * Union type of HTTP methods.\n * @public\n * @example\n * function makeRequest(method: HTTP_METHODS) { ... }\n * @ignore\n */\nexport type HTTP_METHODS = Enum<typeof HTTP_METHODS>;\n\n/**\n * Payload for making requests to Webex APIs.\n * @public\n * @example\n * const payload: WebexRequestPayload = {\n * service: 'identity',\n * resource: '/users',\n * method: HTTP_METHODS.GET\n * };\n * @ignore\n */\nexport type WebexRequestPayload = {\n /** Service name to target */\n service?: string;\n /** Resource path within the service */\n resource?: string;\n /** HTTP method to use */\n method?: HTTP_METHODS;\n /** Full URI if not using service/resource pattern */\n uri?: string;\n /** Whether to add authorization header */\n addAuthHeader?: boolean;\n /** Custom headers to include in request */\n headers?: {\n [key: string]: string | null;\n };\n /** Request body data */\n body?: object;\n /** Expected response status code */\n statusCode?: number;\n /** Whether to parse response as JSON */\n json?: boolean;\n};\n\n/**\n * Event listener function type.\n * @internal\n * @ignore\n */\ntype Listener = (e: string, data?: unknown) => void;\n\n/**\n * Event listener removal function type.\n * @internal\n * @ignore\n */\ntype ListenerOff = (e: string) => void;\n\n/**\n * Service host configuration.\n * @internal\n * @ignore\n */\ntype ServiceHost = {\n /** Host URL/domain for the service */\n host: string;\n /** Time-to-live in seconds */\n ttl: number;\n /** Priority level for load balancing (lower is higher priority) */\n priority: number;\n /** Unique identifier for this host */\n id: string;\n /** Whether this is the home cluster for the user */\n homeCluster?: boolean;\n};\n\n/**\n * Configuration options for the Contact Center Plugin.\n * @interface CCPluginConfig\n * @public\n * @example\n * const config: CCPluginConfig = {\n * allowMultiLogin: true,\n * allowAutomatedRelogin: false,\n * clientType: 'browser',\n * isKeepAliveEnabled: true,\n * force: false,\n * metrics: { clientName: 'myClient', clientType: 'browser' },\n * logging: { enable: true, verboseEvents: false },\n * callingClientConfig: { ... }\n * };\n */\nexport interface CCPluginConfig {\n /** Whether to allow multiple logins from different devices */\n allowMultiLogin: boolean;\n /** Whether to automatically attempt relogin on connection loss */\n allowAutomatedRelogin: boolean;\n /** The type of client making the connection */\n clientType: string;\n /** Whether to enable keep-alive messages */\n isKeepAliveEnabled: boolean;\n /** Whether to force registration */\n force: boolean;\n /** Metrics configuration */\n metrics: {\n /** Name of the client for metrics */\n clientName: string;\n /** Type of client for metrics */\n clientType: string;\n };\n /** Logging configuration */\n logging: {\n /** Whether to enable logging */\n enable: boolean;\n /** Whether to log verbose events */\n verboseEvents: boolean;\n };\n /** Configuration for the calling client */\n callingClientConfig: CallingClientConfig;\n}\n\n/**\n * Logger interface for standardized logging throughout the plugin.\n * @public\n * @example\n * logger.log('This is a log message');\n * logger.error('This is an error message');\n * @ignore\n */\nexport type Logger = {\n /** Log general messages */\n log: (payload: string) => void;\n /** Log error messages */\n error: (payload: string) => void;\n /** Log warning messages */\n warn: (payload: string) => void;\n /** Log informational messages */\n info: (payload: string) => void;\n /** Log detailed trace messages */\n trace: (payload: string) => void;\n /** Log debug messages */\n debug: (payload: string) => void;\n};\n\n/**\n * Contextual information for log entries.\n * @public\n * @ignore\n */\nexport interface LogContext {\n /** Module name where the log originated */\n module?: string;\n /** Method name where the log originated */\n method?: string;\n interactionId?: string;\n trackingId?: string;\n /** Additional structured data to include in logs */\n data?: Record<string, any>;\n /** Error object to include in logs */\n error?: Error | unknown;\n}\n\n/**\n * Available logging severity levels.\n * @enum {string}\n * @public\n * @example\n * const level: LOGGING_LEVEL = LOGGING_LEVEL.error;\n * @ignore\n */\nexport enum LOGGING_LEVEL {\n /** Critical failures that require immediate attention */\n error = 'ERROR',\n /** Important issues that don't prevent the system from working */\n warn = 'WARN',\n /** General informational logs */\n log = 'LOG',\n /** Detailed information about system operation */\n info = 'INFO',\n /** Highly detailed diagnostic information */\n trace = 'TRACE',\n}\n\n/**\n * Metadata for log uploads.\n * @public\n * @example\n * const meta: LogsMetaData = { feedbackId: 'fb123', correlationId: 'corr456' };\n * @ignore\n */\nexport type LogsMetaData = {\n /** Optional feedback ID to associate with logs */\n feedbackId?: string;\n /** Optional correlation ID to track related operations */\n correlationId?: string;\n};\n\n/**\n * Response from uploading logs to the server.\n * @public\n * @example\n * const response: UploadLogsResponse = { trackingid: 'track123', url: 'https://...', userId: 'user1' };\n */\nexport type UploadLogsResponse = {\n /** Tracking ID for the upload request */\n trackingid?: string;\n /** URL where the logs can be accessed */\n url?: string;\n /** ID of the user who uploaded logs */\n userId?: string;\n /** Feedback ID associated with the logs */\n feedbackId?: string;\n /** Correlation ID for tracking related operations */\n correlationId?: string;\n};\n\n/**\n * Internal Webex SDK interfaces needed for plugin integration.\n * @internal\n * @ignore\n */\ninterface IWebexInternal {\n /** Mercury service for real-time messaging */\n mercury: {\n /** Register an event listener */\n on: Listener;\n /** Remove an event listener */\n off: ListenerOff;\n /** Establish a connection to the Mercury service */\n connect: () => Promise<void>;\n /** Disconnect from the Mercury service */\n disconnect: () => Promise<void>;\n /** Whether Mercury is currently connected */\n connected: boolean;\n /** Whether Mercury is in the process of connecting */\n connecting: boolean;\n };\n /** Device information */\n device: {\n /** Current WDM URL */\n url: string;\n /** Current user's ID */\n userId: string;\n /** Current organization ID */\n orgId: string;\n /** Device version */\n version: string;\n /** Calling behavior configuration */\n callingBehavior: string;\n };\n /** Presence service */\n presence: unknown;\n /** Services discovery and management */\n services: {\n /** Get a service URL by name */\n get: (service: string) => string;\n /** Wait for service catalog to be loaded */\n waitForCatalog: (service: string) => Promise<void>;\n /** Host catalog for service discovery */\n _hostCatalog: Record<string, ServiceHost[]>;\n /** Service URLs cache */\n _serviceUrls: {\n /** Mobius calling service */\n mobius: string;\n /** Identity service */\n identity: string;\n /** Janus media server */\n janus: string;\n /** WDM (WebEx Device Management) service */\n wdm: string;\n /** BroadWorks IDP proxy service */\n broadworksIdpProxy: string;\n /** Hydra API service */\n hydra: string;\n /** Mercury API service */\n mercuryApi: string;\n /** UC Management gateway service */\n 'ucmgmt-gateway': string;\n /** Contacts service */\n contactsService: string;\n };\n };\n /** Metrics collection services */\n newMetrics: {\n /** Submit behavioral events (user actions) */\n submitBehavioralEvent: SubmitBehavioralEvent;\n /** Submit operational events (system operations) */\n submitOperationalEvent: SubmitOperationalEvent;\n /** Submit business events (business outcomes) */\n submitBusinessEvent: SubmitBusinessEvent;\n };\n /** Support functionality */\n support: {\n /** Submit logs to server */\n submitLogs: (\n metaData: LogsMetaData,\n logs: string,\n options: {\n /** Whether to submit full logs or just differences */\n type: 'diff' | 'full';\n }\n ) => Promise<UploadLogsResponse>;\n };\n}\n\n/**\n * Interface representing the WebexSDK core functionality.\n * @interface WebexSDK\n * @public\n * @example\n * const sdk: WebexSDK = ...;\n * sdk.request({ service: 'identity', resource: '/users', method: HTTP_METHODS.GET });\n * @ignore\n */\nexport interface WebexSDK {\n /** Version of the WebexSDK */\n version: string;\n /** Whether the SDK can authorize requests */\n canAuthorize: boolean;\n /** Credentials management */\n credentials: {\n /** Get the user token for authentication */\n getUserToken: () => Promise<string>;\n /** Get the organization ID */\n getOrgId: () => string;\n };\n /** Whether the SDK is ready for use */\n ready: boolean;\n /** Make a request to the Webex APIs */\n request: <T>(payload: WebexRequestPayload) => Promise<T>;\n /** Register a one-time event handler */\n once: (event: string, callBack: () => void) => void;\n /** Internal plugins and services */\n internal: IWebexInternal;\n /** Logger instance */\n logger: Logger;\n}\n\n/**\n * An interface for the `ContactCenter` class.\n * The `ContactCenter` package is designed to provide a set of APIs to perform various operations for the Agent flow within Webex Contact Center.\n * @public\n * @example\n * const cc: IContactCenter = ...;\n * cc.register().then(profile => { ... });\n * @ignore\n */\nexport interface IContactCenter {\n /**\n * Initialize the CC SDK by setting up the contact center mercury connection.\n * This establishes WebSocket connectivity for real-time communication.\n *\n * @returns A Promise that resolves to the agent's profile upon successful registration\n * @public\n * @example\n * cc.register().then(profile => { ... });\n */\n register(): Promise<Profile>;\n}\n\n/**\n * Generic HTTP response structure.\n * @public\n * @example\n * const response: IHttpResponse = { body: {}, statusCode: 200, method: 'GET', headers: {}, url: '...' };\n * @ignore\n */\nexport interface IHttpResponse {\n /** Response body content */\n body: any;\n /** HTTP status code */\n statusCode: number;\n /** HTTP method used for the request */\n method: string;\n /** Response headers */\n headers: Headers;\n /** Request URL */\n url: string;\n}\n\n/**\n * Supported login options for agent authentication.\n * @public\n * @example\n * const option: LoginOption = LoginOption.AGENT_DN;\n * @ignore\n */\nexport const LoginOption = {\n /** Login using agent's direct number */\n AGENT_DN: 'AGENT_DN',\n /** Login using an extension number */\n EXTENSION: 'EXTENSION',\n /** Login using browser WebRTC capabilities */\n BROWSER: 'BROWSER',\n} as const;\n\n/**\n * Union type of login options.\n * @public\n * @example\n * function login(option: LoginOption) { ... }\n * @ignore\n */\nexport type LoginOption = Enum<typeof LoginOption>;\n\n/**\n * Request payload for subscribing to the contact center websocket.\n * @public\n * @example\n * const req: SubscribeRequest = { force: true, isKeepAliveEnabled: true, clientType: 'browser', allowMultiLogin: false };\n * @ignore\n */\nexport type SubscribeRequest = {\n /** Whether to force connection even if another exists */\n force: boolean;\n /** Whether to send keepalive messages */\n isKeepAliveEnabled: boolean;\n /** Type of client connecting */\n clientType: string;\n /** Whether to allow login from multiple devices */\n allowMultiLogin: boolean;\n};\n\n/**\n * Represents the response from getListOfTeams method.\n * Teams are groups of agents that can be managed together.\n * @public\n * @example\n * const team: Team = { id: 'team1', name: 'Support', desktopLayoutId: 'layout1' };\n * @ignore\n */\nexport type Team = {\n /**\n * Unique identifier of the team.\n */\n id: string;\n\n /**\n * Display name of the team.\n */\n name: string;\n\n /**\n * Associated desktop layout ID for the team.\n * Controls how the agent desktop is displayed for team members.\n */\n desktopLayoutId?: string;\n};\n\n/**\n * Represents the request to perform agent login.\n * @public\n * @example\n * const login: AgentLogin = { dialNumber: '1234', teamId: 'team1', loginOption: LoginOption.AGENT_DN };\n */\nexport type AgentLogin = {\n /**\n * A dialNumber field contains the number to dial such as a route point or extension.\n * Required for AGENT_DN and EXTENSION login options.\n */\n dialNumber?: string;\n\n /**\n * The unique ID representing a team of users.\n * The agent must belong to this team.\n */\n teamId: string;\n\n /**\n * The loginOption field specifies the type of login method.\n * Controls how calls are delivered to the agent.\n */\n loginOption: LoginOption;\n};\n\n/**\n * Represents the request to update agent profile settings.\n * @public\n * @example\n * const update: AgentProfileUpdate = { loginOption: LoginOption.BROWSER, dialNumber: '5678' };\n */\nexport type AgentProfileUpdate = Pick<AgentLogin, 'loginOption' | 'dialNumber' | 'teamId'>;\n\n/**\n * Union type for all possible request body types.\n * @internal\n * @ignore\n */\nexport type RequestBody =\n | SubscribeRequest\n | Agent.Logout\n | Agent.UserStationLogin\n | Agent.StateChange\n | Agent.BuddyAgents\n | Contact.HoldResumePayload\n | Contact.ResumeRecordingPayload\n | Contact.ConsultPayload\n | Contact.ConsultEndAPIPayload // API Payload accepts only QueueId wheres SDK API allows more params\n | Contact.TransferPayLoad\n | Contact.ConsultTransferPayLoad\n | Contact.cancelCtq\n | Contact.WrapupPayLoad\n | Contact.DialerPayload;\n\n/**\n * Represents the options to fetch buddy agents for the logged in agent.\n * Buddy agents are other agents who can be consulted or transfered to.\n * @public\n * @example\n * const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };\n * @ignore\n */\nexport type BuddyAgents = {\n /**\n * The media type channel to filter buddy agents.\n * Determines which channel capability the returned agents must have.\n */\n mediaType: 'telephony' | 'chat' | 'social' | 'email';\n\n /**\n * Optional filter for agent state.\n * If specified, returns only agents in that state.\n * If omitted, returns both available and idle agents.\n */\n state?: 'Available' | 'Idle';\n};\n\n/**\n * Generic error structure for Contact Center SDK errors.\n * Contains detailed information about the error context.\n * @public\n * @example\n * const err: GenericError = new Error('Failed');\n * err.details = { type: 'ERR', orgId: 'org1', trackingId: 'track1', data: {} };\n * @ignore\n */\nexport interface GenericError extends Error {\n /** Structured details about the error */\n details: {\n /** Error type identifier */\n type: string;\n /** Organization ID where the error occurred */\n orgId: string;\n /** Unique tracking ID for the error */\n trackingId: string;\n /** Additional error context data */\n data: Record<string, any>;\n };\n}\n\n/**\n * Response type for station login operations.\n * Either a success response with agent details or an error.\n * @public\n * @example\n * function handleLogin(resp: StationLoginResponse) { ... }\n */\nexport type StationLoginResponse = Agent.StationLoginSuccessResponse | Error;\n\n/**\n * Response type for station logout operations.\n * Either a success response with logout details or an error.\n * @public\n * @example\n * function handleLogout(resp: StationLogoutResponse) { ... }\n */\nexport type StationLogoutResponse = Agent.LogoutSuccess | Error;\n\n/**\n * Response type for station relogin operations.\n * Either a success response with relogin details or an error.\n * @public\n * @example\n * function handleReLogin(resp: StationReLoginResponse) { ... }\n * @ignore\n */\nexport type StationReLoginResponse = Agent.ReloginSuccess | Error;\n\n/**\n * Response type for agent state change operations.\n * Either a success response with state change details or an error.\n * @public\n * @example\n * function handleStateChange(resp: SetStateResponse) { ... }\n * @ignore\n */\nexport type SetStateResponse = Agent.StateChangeSuccess | Error;\n\n/**\n * AddressBook types\n */\nexport interface AddressBookEntry {\n id: string;\n organizationId?: string;\n version?: number;\n name: string;\n number: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport type AddressBookEntriesResponse = PaginatedResponse<AddressBookEntry>;\n\nexport interface AddressBookEntrySearchParams extends BaseSearchParams {\n addressBookId?: string;\n}\n\n/**\n * EntryPointRecord types\n */\nexport interface EntryPointRecord {\n id: string;\n name: string;\n description?: string;\n type: string;\n isActive: boolean;\n orgId: string;\n createdAt?: string;\n updatedAt?: string;\n settings?: Record<string, any>;\n}\n\nexport type EntryPointListResponse = PaginatedResponse<EntryPointRecord>;\nexport type EntryPointSearchParams = BaseSearchParams;\n\n/**\n * Queue types\n */\nexport interface QueueSkillRequirement {\n organizationId?: string;\n id?: string;\n version?: number;\n skillId: string;\n skillName?: string;\n skillType?: string;\n condition: string;\n skillValue: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport interface QueueAgent {\n id: string;\n ciUserId?: string;\n}\n\nexport interface AgentGroup {\n teamId: string;\n}\n\nexport interface CallDistributionGroup {\n agentGroups: AgentGroup[];\n order: number;\n duration?: number;\n}\n\nexport interface AssistantSkillMapping {\n assistantSkillId?: string;\n assistantSkillUpdatedTime?: number;\n}\n\n/**\n * Configuration for a contact service queue\n * @public\n */\nexport interface ContactServiceQueue {\n /** Organization ID */\n organizationId?: string;\n /** Unique identifier for the queue */\n id?: string;\n /** Version of the queue */\n version?: number;\n /** Name of the Contact Service Queue */\n name: string;\n /** Description of the queue */\n description?: string;\n /** Queue type (INBOUND, OUTBOUND) */\n queueType: 'INBOUND' | 'OUTBOUND';\n /** Whether to check agent availability */\n checkAgentAvailability: boolean;\n /** Channel type (TELEPHONY, EMAIL, SOCIAL_CHANNEL, CHAT, etc.) */\n channelType: 'TELEPHONY' | 'EMAIL' | 'FAX' | 'CHAT' | 'VIDEO' | 'OTHERS' | 'SOCIAL_CHANNEL';\n /** Social channel type for SOCIAL_CHANNEL channelType */\n socialChannelType?:\n | 'MESSAGEBIRD'\n | 'MESSENGER'\n | 'WHATSAPP'\n | 'APPLE_BUSINESS_CHAT'\n | 'GOOGLE_BUSINESS_MESSAGES';\n /** Service level threshold in seconds */\n serviceLevelThreshold: number;\n /** Maximum number of simultaneous contacts */\n maxActiveContacts: number;\n /** Maximum time in queue in seconds */\n maxTimeInQueue: number;\n /** Default music in queue media file ID */\n defaultMusicInQueueMediaFileId: string;\n /** Timezone for routing strategies */\n timezone?: string;\n /** Whether the queue is active */\n active: boolean;\n /** Whether outdial campaign is enabled */\n outdialCampaignEnabled?: boolean;\n /** Whether monitoring is permitted */\n monitoringPermitted: boolean;\n /** Whether parking is permitted */\n parkingPermitted: boolean;\n /** Whether recording is permitted */\n recordingPermitted: boolean;\n /** Whether recording all calls is permitted */\n recordingAllCallsPermitted: boolean;\n /** Whether pausing recording is permitted */\n pauseRecordingPermitted: boolean;\n /** Recording pause duration in seconds */\n recordingPauseDuration?: number;\n /** Control flow script URL */\n controlFlowScriptUrl: string;\n /** IVR requeue URL */\n ivrRequeueUrl: string;\n /** Overflow number for telephony */\n overflowNumber?: string;\n /** Vendor ID */\n vendorId?: string;\n /** Routing type */\n routingType: 'LONGEST_AVAILABLE_AGENT' | 'SKILLS_BASED' | 'CIRCULAR' | 'LINEAR';\n /** Skills-based routing type */\n skillBasedRoutingType?: 'LONGEST_AVAILABLE_AGENT' | 'BEST_AVAILABLE_AGENT';\n /** Queue routing type */\n queueRoutingType: 'TEAM_BASED' | 'SKILL_BASED' | 'AGENT_BASED';\n /** Queue skill requirements */\n queueSkillRequirements?: QueueSkillRequirement[];\n /** List of agents for agent-based queue */\n agents?: QueueAgent[];\n /** Call distribution groups */\n callDistributionGroups: CallDistributionGroup[];\n /** XSP version */\n xspVersion?: string;\n /** Subscription ID */\n subscriptionId?: string;\n /** Assistant skill mapping */\n assistantSkill?: AssistantSkillMapping;\n /** Whether this is a system default queue */\n systemDefault?: boolean;\n /** User who last updated agents list */\n agentsLastUpdatedByUserName?: string;\n /** Email of user who last updated agents list */\n agentsLastUpdatedByUserEmailPrefix?: string;\n /** When agents list was last updated */\n agentsLastUpdatedTime?: number;\n /** Creation timestamp in epoch millis */\n createdTime?: number;\n /** Last updated timestamp in epoch millis */\n lastUpdatedTime?: number;\n}\n\nexport type ContactServiceQueuesResponse = PaginatedResponse<ContactServiceQueue>;\n\nexport interface ContactServiceQueueSearchParams extends BaseSearchParams {\n desktopProfileFilter?: boolean;\n provisioningView?: boolean;\n singleObjectResponse?: boolean;\n}\n\n/**\n * Response type for buddy agents query operations.\n * Either a success response with list of buddy agents or an error.\n * @public\n * @example\n * function handleBuddyAgents(resp: BuddyAgentsResponse) { ... }\n */\nexport type BuddyAgentsResponse = Agent.BuddyAgentsSuccess | Error;\n\n/**\n * Response type for device type update operations.\n * Either a success response with update confirmation or an error.\n * @public\n * @example\n * function handleUpdateDeviceType(resp: UpdateDeviceTypeResponse) { ... }\n */\nexport type UpdateDeviceTypeResponse = Agent.DeviceTypeUpdateSuccess | Error;\n"],"mappings":";;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;EACAE,GAAG,EAAE,KAAK;EACV;EACAC,IAAI,EAAE,MAAM;EACZ;EACAC,KAAK,EAAE,OAAO;EACd;EACAC,GAAG,EAAE,KAAK;EACV;EACAC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAQYC,aAAa,GAAAN,OAAA,CAAAM,aAAA,0BAAbA,aAAa;EACvB;EADUA,aAAa;EAGvB;EAHUA,aAAa;EAKvB;EALUA,aAAa;EAOvB;EAPUA,aAAa;EASvB;EATUA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAazB;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAqFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAG;EACzB;EACAC,QAAQ,EAAE,UAAU;EACpB;EACAC,SAAS,EAAE,WAAW;EACtB;EACAC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAgBA;AACA;AACA;;AAkCA;AACA;AACA;AACA;;AAmGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["HTTP_METHODS","exports","GET","POST","PATCH","PUT","DELETE","LOGGING_LEVEL","LoginOption","AGENT_DN","EXTENSION","BROWSER"],"sources":["types.ts"],"sourcesContent":["import {CallingClientConfig} from '@webex/calling';\nimport {\n SubmitBehavioralEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n} from '@webex/internal-plugin-metrics/src/metrics.types';\nimport * as Agent from './services/agent/types';\nimport * as Contact from './services/task/types';\nimport {Profile} from './services/config/types';\nimport {PaginatedResponse, BaseSearchParams} from './utils/PageCache';\n\n/**\n * Generic type for converting a const enum object into a union type of its values.\n * @template T The enum object type\n * @internal\n * @ignore\n */\ntype Enum<T extends Record<string, unknown>> = T[keyof T];\n\n/**\n * HTTP methods supported by WebexRequest.\n * @enum {string}\n * @public\n * @example\n * const method: HTTP_METHODS = HTTP_METHODS.GET;\n * @ignore\n */\nexport const HTTP_METHODS = {\n /** HTTP GET method for retrieving data */\n GET: 'GET',\n /** HTTP POST method for creating resources */\n POST: 'POST',\n /** HTTP PATCH method for partial updates */\n PATCH: 'PATCH',\n /** HTTP PUT method for complete updates */\n PUT: 'PUT',\n /** HTTP DELETE method for removing resources */\n DELETE: 'DELETE',\n} as const;\n\n/**\n * Union type of HTTP methods.\n * @public\n * @example\n * function makeRequest(method: HTTP_METHODS) { ... }\n * @ignore\n */\nexport type HTTP_METHODS = Enum<typeof HTTP_METHODS>;\n\n/**\n * Payload for making requests to Webex APIs.\n * @public\n * @example\n * const payload: WebexRequestPayload = {\n * service: 'identity',\n * resource: '/users',\n * method: HTTP_METHODS.GET\n * };\n * @ignore\n */\nexport type WebexRequestPayload = {\n /** Service name to target */\n service?: string;\n /** Resource path within the service */\n resource?: string;\n /** HTTP method to use */\n method?: HTTP_METHODS;\n /** Full URI if not using service/resource pattern */\n uri?: string;\n /** Whether to add authorization header */\n addAuthHeader?: boolean;\n /** Custom headers to include in request */\n headers?: {\n [key: string]: string | null;\n };\n /** Request body data */\n body?: object;\n /** Expected response status code */\n statusCode?: number;\n /** Whether to parse response as JSON */\n json?: boolean;\n};\n\n/**\n * Event listener function type.\n * @internal\n * @ignore\n */\ntype Listener = (e: string, data?: unknown) => void;\n\n/**\n * Event listener removal function type.\n * @internal\n * @ignore\n */\ntype ListenerOff = (e: string) => void;\n\n/**\n * Service host configuration.\n * @internal\n * @ignore\n */\ntype ServiceHost = {\n /** Host URL/domain for the service */\n host: string;\n /** Time-to-live in seconds */\n ttl: number;\n /** Priority level for load balancing (lower is higher priority) */\n priority: number;\n /** Unique identifier for this host */\n id: string;\n /** Whether this is the home cluster for the user */\n homeCluster?: boolean;\n};\n\n/**\n * Configuration options for the Contact Center Plugin.\n * @interface CCPluginConfig\n * @public\n * @example\n * const config: CCPluginConfig = {\n * allowMultiLogin: true,\n * allowAutomatedRelogin: false,\n * clientType: 'browser',\n * isKeepAliveEnabled: true,\n * force: false,\n * metrics: { clientName: 'myClient', clientType: 'browser' },\n * logging: { enable: true, verboseEvents: false },\n * callingClientConfig: { ... }\n * };\n */\nexport interface CCPluginConfig {\n /** Whether to allow multiple logins from different devices */\n allowMultiLogin: boolean;\n /** Whether to automatically attempt relogin on connection loss */\n allowAutomatedRelogin: boolean;\n /** The type of client making the connection */\n clientType: string;\n /** Whether to enable keep-alive messages */\n isKeepAliveEnabled: boolean;\n /** Whether to force registration */\n force: boolean;\n /** Metrics configuration */\n metrics: {\n /** Name of the client for metrics */\n clientName: string;\n /** Type of client for metrics */\n clientType: string;\n };\n /** Logging configuration */\n logging: {\n /** Whether to enable logging */\n enable: boolean;\n /** Whether to log verbose events */\n verboseEvents: boolean;\n };\n /** Configuration for the calling client */\n callingClientConfig: CallingClientConfig;\n}\n\n/**\n * Logger interface for standardized logging throughout the plugin.\n * @public\n * @example\n * logger.log('This is a log message');\n * logger.error('This is an error message');\n * @ignore\n */\nexport type Logger = {\n /** Log general messages */\n log: (payload: string) => void;\n /** Log error messages */\n error: (payload: string) => void;\n /** Log warning messages */\n warn: (payload: string) => void;\n /** Log informational messages */\n info: (payload: string) => void;\n /** Log detailed trace messages */\n trace: (payload: string) => void;\n /** Log debug messages */\n debug: (payload: string) => void;\n};\n\n/**\n * Contextual information for log entries.\n * @public\n * @ignore\n */\nexport interface LogContext {\n /** Module name where the log originated */\n module?: string;\n /** Method name where the log originated */\n method?: string;\n interactionId?: string;\n trackingId?: string;\n /** Additional structured data to include in logs */\n data?: Record<string, any>;\n /** Error object to include in logs */\n error?: Error | unknown;\n}\n\n/**\n * Available logging severity levels.\n * @enum {string}\n * @public\n * @example\n * const level: LOGGING_LEVEL = LOGGING_LEVEL.error;\n * @ignore\n */\nexport enum LOGGING_LEVEL {\n /** Critical failures that require immediate attention */\n error = 'ERROR',\n /** Important issues that don't prevent the system from working */\n warn = 'WARN',\n /** General informational logs */\n log = 'LOG',\n /** Detailed information about system operation */\n info = 'INFO',\n /** Highly detailed diagnostic information */\n trace = 'TRACE',\n}\n\n/**\n * Metadata for log uploads.\n * @public\n * @example\n * const meta: LogsMetaData = { feedbackId: 'fb123', correlationId: 'corr456' };\n * @ignore\n */\nexport type LogsMetaData = {\n /** Optional feedback ID to associate with logs */\n feedbackId?: string;\n /** Optional correlation ID to track related operations */\n correlationId?: string;\n};\n\n/**\n * Response from uploading logs to the server.\n * @public\n * @example\n * const response: UploadLogsResponse = { trackingid: 'track123', url: 'https://...', userId: 'user1' };\n */\nexport type UploadLogsResponse = {\n /** Tracking ID for the upload request */\n trackingid?: string;\n /** URL where the logs can be accessed */\n url?: string;\n /** ID of the user who uploaded logs */\n userId?: string;\n /** Feedback ID associated with the logs */\n feedbackId?: string;\n /** Correlation ID for tracking related operations */\n correlationId?: string;\n};\n\n/**\n * Internal Webex SDK interfaces needed for plugin integration.\n * @internal\n * @ignore\n */\ninterface IWebexInternal {\n /** Mercury service for real-time messaging */\n mercury: {\n /** Register an event listener */\n on: Listener;\n /** Remove an event listener */\n off: ListenerOff;\n /** Establish a connection to the Mercury service */\n connect: () => Promise<void>;\n /** Disconnect from the Mercury service */\n disconnect: () => Promise<void>;\n /** Whether Mercury is currently connected */\n connected: boolean;\n /** Whether Mercury is in the process of connecting */\n connecting: boolean;\n };\n /** Device information */\n device: {\n /** Current WDM URL */\n url: string;\n /** Current user's ID */\n userId: string;\n /** Current organization ID */\n orgId: string;\n /** Device version */\n version: string;\n /** Calling behavior configuration */\n callingBehavior: string;\n };\n /** Presence service */\n presence: unknown;\n /** Services discovery and management */\n services: {\n /** Get a service URL by name */\n get: (service: string) => string;\n /** Wait for service catalog to be loaded */\n waitForCatalog: (service: string) => Promise<void>;\n /** Check if current environment is INT (integration) */\n isIntegrationEnvironment: () => boolean;\n /** Host catalog for service discovery */\n _hostCatalog: Record<string, ServiceHost[]>;\n /** Service URLs cache */\n _serviceUrls: {\n /** Mobius calling service */\n mobius: string;\n /** Identity service */\n identity: string;\n /** Janus media server */\n janus: string;\n /** WDM (WebEx Device Management) service */\n wdm: string;\n /** BroadWorks IDP proxy service */\n broadworksIdpProxy: string;\n /** Hydra API service */\n hydra: string;\n /** Mercury API service */\n mercuryApi: string;\n /** UC Management gateway service */\n 'ucmgmt-gateway': string;\n /** Contacts service */\n contactsService: string;\n };\n };\n /** Metrics collection services */\n newMetrics: {\n /** Submit behavioral events (user actions) */\n submitBehavioralEvent: SubmitBehavioralEvent;\n /** Submit operational events (system operations) */\n submitOperationalEvent: SubmitOperationalEvent;\n /** Submit business events (business outcomes) */\n submitBusinessEvent: SubmitBusinessEvent;\n };\n /** Support functionality */\n support: {\n /** Submit logs to server */\n submitLogs: (\n metaData: LogsMetaData,\n logs: string,\n options: {\n /** Whether to submit full logs or just differences */\n type: 'diff' | 'full';\n }\n ) => Promise<UploadLogsResponse>;\n };\n}\n\n/**\n * Interface representing the WebexSDK core functionality.\n * @interface WebexSDK\n * @public\n * @example\n * const sdk: WebexSDK = ...;\n * sdk.request({ service: 'identity', resource: '/users', method: HTTP_METHODS.GET });\n * @ignore\n */\nexport interface WebexSDK {\n /** Version of the WebexSDK */\n version: string;\n /** Whether the SDK can authorize requests */\n canAuthorize: boolean;\n /** Credentials management */\n credentials: {\n /** Get the user token for authentication */\n getUserToken: () => Promise<string>;\n /** Get the organization ID */\n getOrgId: () => string;\n };\n /** Whether the SDK is ready for use */\n ready: boolean;\n /** Make a request to the Webex APIs */\n request: <T>(payload: WebexRequestPayload) => Promise<T>;\n /** Register a one-time event handler */\n once: (event: string, callBack: () => void) => void;\n /** Internal plugins and services */\n internal: IWebexInternal;\n /** Logger instance */\n logger: Logger;\n}\n\n/**\n * An interface for the `ContactCenter` class.\n * The `ContactCenter` package is designed to provide a set of APIs to perform various operations for the Agent flow within Webex Contact Center.\n * @public\n * @example\n * const cc: IContactCenter = ...;\n * cc.register().then(profile => { ... });\n * @ignore\n */\nexport interface IContactCenter {\n /**\n * Initialize the CC SDK by setting up the contact center mercury connection.\n * This establishes WebSocket connectivity for real-time communication.\n *\n * @returns A Promise that resolves to the agent's profile upon successful registration\n * @public\n * @example\n * cc.register().then(profile => { ... });\n */\n register(): Promise<Profile>;\n}\n\n/**\n * Generic HTTP response structure.\n * @public\n * @example\n * const response: IHttpResponse = { body: {}, statusCode: 200, method: 'GET', headers: {}, url: '...' };\n * @ignore\n */\nexport interface IHttpResponse {\n /** Response body content */\n body: any;\n /** HTTP status code */\n statusCode: number;\n /** HTTP method used for the request */\n method: string;\n /** Response headers */\n headers: Headers;\n /** Request URL */\n url: string;\n}\n\n/**\n * Supported login options for agent authentication.\n * @public\n * @example\n * const option: LoginOption = LoginOption.AGENT_DN;\n * @ignore\n */\nexport const LoginOption = {\n /** Login using agent's direct number */\n AGENT_DN: 'AGENT_DN',\n /** Login using an extension number */\n EXTENSION: 'EXTENSION',\n /** Login using browser WebRTC capabilities */\n BROWSER: 'BROWSER',\n} as const;\n\n/**\n * Union type of login options.\n * @public\n * @example\n * function login(option: LoginOption) { ... }\n * @ignore\n */\nexport type LoginOption = Enum<typeof LoginOption>;\n\n/**\n * Request payload for subscribing to the contact center websocket.\n * @public\n * @example\n * const req: SubscribeRequest = { force: true, isKeepAliveEnabled: true, clientType: 'browser', allowMultiLogin: false };\n * @ignore\n */\nexport type SubscribeRequest = {\n /** Whether to force connection even if another exists */\n force: boolean;\n /** Whether to send keepalive messages */\n isKeepAliveEnabled: boolean;\n /** Type of client connecting */\n clientType: string;\n /** Whether to allow login from multiple devices */\n allowMultiLogin: boolean;\n};\n\n/**\n * Represents the response from getListOfTeams method.\n * Teams are groups of agents that can be managed together.\n * @public\n * @example\n * const team: Team = { id: 'team1', name: 'Support', desktopLayoutId: 'layout1' };\n * @ignore\n */\nexport type Team = {\n /**\n * Unique identifier of the team.\n */\n id: string;\n\n /**\n * Display name of the team.\n */\n name: string;\n\n /**\n * Associated desktop layout ID for the team.\n * Controls how the agent desktop is displayed for team members.\n */\n desktopLayoutId?: string;\n};\n\n/**\n * Represents the request to perform agent login.\n * @public\n * @example\n * const login: AgentLogin = { dialNumber: '1234', teamId: 'team1', loginOption: LoginOption.AGENT_DN };\n */\nexport type AgentLogin = {\n /**\n * A dialNumber field contains the number to dial such as a route point or extension.\n * Required for AGENT_DN and EXTENSION login options.\n */\n dialNumber?: string;\n\n /**\n * The unique ID representing a team of users.\n * The agent must belong to this team.\n */\n teamId: string;\n\n /**\n * The loginOption field specifies the type of login method.\n * Controls how calls are delivered to the agent.\n */\n loginOption: LoginOption;\n};\n\n/**\n * Represents the request to update agent profile settings.\n * @public\n * @example\n * const update: AgentProfileUpdate = { loginOption: LoginOption.BROWSER, dialNumber: '5678' };\n */\nexport type AgentProfileUpdate = Pick<AgentLogin, 'loginOption' | 'dialNumber' | 'teamId'>;\n\n/**\n * Union type for all possible request body types.\n * @internal\n * @ignore\n */\nexport type RequestBody =\n | SubscribeRequest\n | Agent.Logout\n | Agent.UserStationLogin\n | Agent.StateChange\n | Agent.BuddyAgents\n | Contact.HoldResumePayload\n | Contact.ResumeRecordingPayload\n | Contact.ConsultPayload\n | Contact.ConsultEndAPIPayload // API Payload accepts only QueueId wheres SDK API allows more params\n | Contact.TransferPayLoad\n | Contact.ConsultTransferPayLoad\n | Contact.cancelCtq\n | Contact.WrapupPayLoad\n | Contact.DialerPayload;\n\n/**\n * Represents the options to fetch buddy agents for the logged in agent.\n * Buddy agents are other agents who can be consulted or transfered to.\n * @public\n * @example\n * const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };\n * @ignore\n */\nexport type BuddyAgents = {\n /**\n * The media type channel to filter buddy agents.\n * Determines which channel capability the returned agents must have.\n */\n mediaType: 'telephony' | 'chat' | 'social' | 'email';\n\n /**\n * Optional filter for agent state.\n * If specified, returns only agents in that state.\n * If omitted, returns both available and idle agents.\n */\n state?: 'Available' | 'Idle';\n};\n\n/**\n * Generic error structure for Contact Center SDK errors.\n * Contains detailed information about the error context.\n * @public\n * @example\n * const err: GenericError = new Error('Failed');\n * err.details = { type: 'ERR', orgId: 'org1', trackingId: 'track1', data: {} };\n * @ignore\n */\nexport interface GenericError extends Error {\n /** Structured details about the error */\n details: {\n /** Error type identifier */\n type: string;\n /** Organization ID where the error occurred */\n orgId: string;\n /** Unique tracking ID for the error */\n trackingId: string;\n /** Additional error context data */\n data: Record<string, any>;\n };\n}\n\n/**\n * Response type for station login operations.\n * Either a success response with agent details or an error.\n * @public\n * @example\n * function handleLogin(resp: StationLoginResponse) { ... }\n */\nexport type StationLoginResponse = Agent.StationLoginSuccessResponse | Error;\n\n/**\n * Response type for station logout operations.\n * Either a success response with logout details or an error.\n * @public\n * @example\n * function handleLogout(resp: StationLogoutResponse) { ... }\n */\nexport type StationLogoutResponse = Agent.LogoutSuccess | Error;\n\n/**\n * Response type for station relogin operations.\n * Either a success response with relogin details or an error.\n * @public\n * @example\n * function handleReLogin(resp: StationReLoginResponse) { ... }\n * @ignore\n */\nexport type StationReLoginResponse = Agent.ReloginSuccess | Error;\n\n/**\n * Response type for agent state change operations.\n * Either a success response with state change details or an error.\n * @public\n * @example\n * function handleStateChange(resp: SetStateResponse) { ... }\n * @ignore\n */\nexport type SetStateResponse = Agent.StateChangeSuccess | Error;\n\n/**\n * AddressBook types\n */\nexport interface AddressBookEntry {\n id: string;\n organizationId?: string;\n version?: number;\n name: string;\n number: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport type AddressBookEntriesResponse = PaginatedResponse<AddressBookEntry>;\n\nexport interface AddressBookEntrySearchParams extends BaseSearchParams {\n addressBookId?: string;\n}\n\n/**\n * EntryPointRecord types\n */\nexport interface EntryPointRecord {\n id: string;\n name: string;\n description?: string;\n type: string;\n isActive: boolean;\n orgId: string;\n createdAt?: string;\n updatedAt?: string;\n settings?: Record<string, any>;\n}\n\nexport type EntryPointListResponse = PaginatedResponse<EntryPointRecord>;\nexport type EntryPointSearchParams = BaseSearchParams;\n\n/**\n * Queue types\n */\nexport interface QueueSkillRequirement {\n organizationId?: string;\n id?: string;\n version?: number;\n skillId: string;\n skillName?: string;\n skillType?: string;\n condition: string;\n skillValue: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport interface QueueAgent {\n id: string;\n ciUserId?: string;\n}\n\nexport interface AgentGroup {\n teamId: string;\n}\n\nexport interface CallDistributionGroup {\n agentGroups: AgentGroup[];\n order: number;\n duration?: number;\n}\n\nexport interface AssistantSkillMapping {\n assistantSkillId?: string;\n assistantSkillUpdatedTime?: number;\n}\n\n/**\n * Configuration for a contact service queue\n * @public\n */\nexport interface ContactServiceQueue {\n /** Organization ID */\n organizationId?: string;\n /** Unique identifier for the queue */\n id?: string;\n /** Version of the queue */\n version?: number;\n /** Name of the Contact Service Queue */\n name: string;\n /** Description of the queue */\n description?: string;\n /** Queue type (INBOUND, OUTBOUND) */\n queueType: 'INBOUND' | 'OUTBOUND';\n /** Whether to check agent availability */\n checkAgentAvailability: boolean;\n /** Channel type (TELEPHONY, EMAIL, SOCIAL_CHANNEL, CHAT, etc.) */\n channelType: 'TELEPHONY' | 'EMAIL' | 'FAX' | 'CHAT' | 'VIDEO' | 'OTHERS' | 'SOCIAL_CHANNEL';\n /** Social channel type for SOCIAL_CHANNEL channelType */\n socialChannelType?:\n | 'MESSAGEBIRD'\n | 'MESSENGER'\n | 'WHATSAPP'\n | 'APPLE_BUSINESS_CHAT'\n | 'GOOGLE_BUSINESS_MESSAGES';\n /** Service level threshold in seconds */\n serviceLevelThreshold: number;\n /** Maximum number of simultaneous contacts */\n maxActiveContacts: number;\n /** Maximum time in queue in seconds */\n maxTimeInQueue: number;\n /** Default music in queue media file ID */\n defaultMusicInQueueMediaFileId: string;\n /** Timezone for routing strategies */\n timezone?: string;\n /** Whether the queue is active */\n active: boolean;\n /** Whether outdial campaign is enabled */\n outdialCampaignEnabled?: boolean;\n /** Whether monitoring is permitted */\n monitoringPermitted: boolean;\n /** Whether parking is permitted */\n parkingPermitted: boolean;\n /** Whether recording is permitted */\n recordingPermitted: boolean;\n /** Whether recording all calls is permitted */\n recordingAllCallsPermitted: boolean;\n /** Whether pausing recording is permitted */\n pauseRecordingPermitted: boolean;\n /** Recording pause duration in seconds */\n recordingPauseDuration?: number;\n /** Control flow script URL */\n controlFlowScriptUrl: string;\n /** IVR requeue URL */\n ivrRequeueUrl: string;\n /** Overflow number for telephony */\n overflowNumber?: string;\n /** Vendor ID */\n vendorId?: string;\n /** Routing type */\n routingType: 'LONGEST_AVAILABLE_AGENT' | 'SKILLS_BASED' | 'CIRCULAR' | 'LINEAR';\n /** Skills-based routing type */\n skillBasedRoutingType?: 'LONGEST_AVAILABLE_AGENT' | 'BEST_AVAILABLE_AGENT';\n /** Queue routing type */\n queueRoutingType: 'TEAM_BASED' | 'SKILL_BASED' | 'AGENT_BASED';\n /** Queue skill requirements */\n queueSkillRequirements?: QueueSkillRequirement[];\n /** List of agents for agent-based queue */\n agents?: QueueAgent[];\n /** Call distribution groups */\n callDistributionGroups: CallDistributionGroup[];\n /** XSP version */\n xspVersion?: string;\n /** Subscription ID */\n subscriptionId?: string;\n /** Assistant skill mapping */\n assistantSkill?: AssistantSkillMapping;\n /** Whether this is a system default queue */\n systemDefault?: boolean;\n /** User who last updated agents list */\n agentsLastUpdatedByUserName?: string;\n /** Email of user who last updated agents list */\n agentsLastUpdatedByUserEmailPrefix?: string;\n /** When agents list was last updated */\n agentsLastUpdatedTime?: number;\n /** Creation timestamp in epoch millis */\n createdTime?: number;\n /** Last updated timestamp in epoch millis */\n lastUpdatedTime?: number;\n}\n\nexport type ContactServiceQueuesResponse = PaginatedResponse<ContactServiceQueue>;\n\nexport interface ContactServiceQueueSearchParams extends BaseSearchParams {\n desktopProfileFilter?: boolean;\n provisioningView?: boolean;\n singleObjectResponse?: boolean;\n}\n\n/**\n * Response type for buddy agents query operations.\n * Either a success response with list of buddy agents or an error.\n * @public\n * @example\n * function handleBuddyAgents(resp: BuddyAgentsResponse) { ... }\n */\nexport type BuddyAgentsResponse = Agent.BuddyAgentsSuccess | Error;\n\n/**\n * Response type for device type update operations.\n * Either a success response with update confirmation or an error.\n * @public\n * @example\n * function handleUpdateDeviceType(resp: UpdateDeviceTypeResponse) { ... }\n */\nexport type UpdateDeviceTypeResponse = Agent.DeviceTypeUpdateSuccess | Error;\n"],"mappings":";;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;EACAE,GAAG,EAAE,KAAK;EACV;EACAC,IAAI,EAAE,MAAM;EACZ;EACAC,KAAK,EAAE,OAAO;EACd;EACAC,GAAG,EAAE,KAAK;EACV;EACAC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAQYC,aAAa,GAAAN,OAAA,CAAAM,aAAA,0BAAbA,aAAa;EACvB;EADUA,aAAa;EAGvB;EAHUA,aAAa;EAKvB;EALUA,aAAa;EAOvB;EAPUA,aAAa;EASvB;EATUA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAazB;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAuFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAG;EACzB;EACAC,QAAQ,EAAE,UAAU;EACpB;EACAC,SAAS,EAAE,WAAW;EACtB;EACAC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAgBA;AACA;AACA;;AAkCA;AACA;AACA;AACA;;AAmGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/dist/webex.js CHANGED
@@ -29,7 +29,7 @@ if (!global.Buffer) {
29
29
  */
30
30
  const Webex = _webexCore.default.extend({
31
31
  webex: true,
32
- version: `3.11.0-next.16`
32
+ version: `3.11.0-next.18`
33
33
  });
34
34
 
35
35
  /**
package/package.json CHANGED
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@types/platform": "1.3.4",
48
- "@webex/calling": "3.11.0-next.10",
49
- "@webex/internal-plugin-mercury": "3.11.0-next.6",
50
- "@webex/internal-plugin-metrics": "3.11.0-next.5",
51
- "@webex/internal-plugin-support": "3.11.0-next.6",
52
- "@webex/plugin-authorization": "3.11.0-next.5",
53
- "@webex/plugin-logger": "3.11.0-next.5",
54
- "@webex/webex-core": "3.11.0-next.5",
48
+ "@webex/calling": "3.11.0-next.12",
49
+ "@webex/internal-plugin-mercury": "3.11.0-next.7",
50
+ "@webex/internal-plugin-metrics": "3.11.0-next.6",
51
+ "@webex/internal-plugin-support": "3.11.0-next.7",
52
+ "@webex/plugin-authorization": "3.11.0-next.6",
53
+ "@webex/plugin-logger": "3.11.0-next.6",
54
+ "@webex/webex-core": "3.11.0-next.6",
55
55
  "jest-html-reporters": "3.0.11",
56
56
  "lodash": "^4.17.21"
57
57
  },
@@ -80,5 +80,5 @@
80
80
  "typedoc": "^0.25.0",
81
81
  "typescript": "4.9.5"
82
82
  },
83
- "version": "3.11.0-next.16"
83
+ "version": "3.11.0-next.18"
84
84
  }
@@ -86,11 +86,23 @@ export class WebSocketManager extends EventEmitter {
86
86
 
87
87
  private async register(connectionConfig: SubscribeRequest) {
88
88
  try {
89
+ // X-ORGANIZATION-ID header is only required for INT environments
90
+ const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;
91
+ const orgId = this.webex.credentials.getOrgId();
92
+
93
+ if (isIntEnv && orgId) {
94
+ LoggerProxy.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {
95
+ module: WEB_SOCKET_MANAGER_FILE,
96
+ method: METHODS.REGISTER,
97
+ });
98
+ }
99
+
89
100
  const subscribeResponse: SubscribeResponse = await this.webex.request({
90
101
  service: WCC_API_GATEWAY,
91
102
  resource: SUBSCRIBE_API,
92
103
  method: HTTP_METHODS.POST,
93
104
  body: connectionConfig,
105
+ headers: isIntEnv && orgId ? {'X-ORGANIZATION-ID': orgId} : undefined,
94
106
  });
95
107
  this.url = subscribeResponse.body.webSocketUrl;
96
108
  } catch (e) {
package/src/types.ts CHANGED
@@ -295,6 +295,8 @@ interface IWebexInternal {
295
295
  get: (service: string) => string;
296
296
  /** Wait for service catalog to be loaded */
297
297
  waitForCatalog: (service: string) => Promise<void>;
298
+ /** Check if current environment is INT (integration) */
299
+ isIntegrationEnvironment: () => boolean;
298
300
  /** Host catalog for service discovery */
299
301
  _hostCatalog: Record<string, ServiceHost[]>;
300
302
  /** Service URLs cache */
@@ -74,6 +74,14 @@ describe('WebSocketManager', () => {
74
74
 
75
75
  mockWebex = {
76
76
  request: jest.fn(),
77
+ credentials: {
78
+ getOrgId: jest.fn().mockReturnValue('test-org-id'),
79
+ },
80
+ internal: {
81
+ services: {
82
+ isIntegrationEnvironment: jest.fn().mockReturnValue(true), // INT environment by default
83
+ },
84
+ },
77
85
  } as unknown as WebexSDK;
78
86
 
79
87
  mockWorker = {
@@ -107,15 +115,76 @@ describe('WebSocketManager', () => {
107
115
  expect(webSocketManager).toBeDefined();
108
116
  });
109
117
 
110
- it('should register and connect to WebSocket', async () => {
118
+ it('should register and connect to WebSocket with X-ORGANIZATION-ID header for INT environment', async () => {
119
+ const subscribeResponse = {
120
+ body: {
121
+ webSocketUrl: 'wss://fake-url',
122
+ },
123
+ };
124
+
125
+ // Mock INT environment (services.isIntegrationEnvironment returns true)
126
+ (mockWebex.internal.services.isIntegrationEnvironment as jest.Mock).mockReturnValue(true);
127
+ (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
128
+
129
+ await webSocketManager.initWebSocket({ body: fakeSubscribeRequest });
130
+
131
+ expect(mockWebex.request).toHaveBeenCalledWith({
132
+ service: WCC_API_GATEWAY,
133
+ resource: SUBSCRIBE_API,
134
+ method: 'POST',
135
+ body: fakeSubscribeRequest,
136
+ headers: {'X-ORGANIZATION-ID': 'test-org-id'},
137
+ });
138
+ });
139
+
140
+ it('should register and connect to WebSocket without X-ORGANIZATION-ID header for production environment', async () => {
141
+ const subscribeResponse = {
142
+ body: {
143
+ webSocketUrl: 'wss://fake-url',
144
+ },
145
+ };
146
+
147
+ // Mock production environment (services.isIntegrationEnvironment returns false)
148
+ (mockWebex.internal.services.isIntegrationEnvironment as jest.Mock).mockReturnValue(false);
149
+ (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
150
+
151
+ // Create new WebSocketManager instance with production mock
152
+ webSocketManager = new WebSocketManager({ webex: mockWebex });
153
+
154
+ setTimeout(() => {
155
+ MockWebSocket.inst.onopen();
156
+ MockWebSocket.inst.onmessage({ data: JSON.stringify({ type: "Welcome" }) });
157
+ }, 1);
158
+
159
+ await webSocketManager.initWebSocket({ body: fakeSubscribeRequest });
160
+
161
+ expect(mockWebex.request).toHaveBeenCalledWith({
162
+ service: WCC_API_GATEWAY,
163
+ resource: SUBSCRIBE_API,
164
+ method: 'POST',
165
+ body: fakeSubscribeRequest,
166
+ headers: undefined,
167
+ });
168
+ });
169
+
170
+ it('should not send X-ORGANIZATION-ID header when services.isIntegrationEnvironment is not available', async () => {
111
171
  const subscribeResponse = {
112
172
  body: {
113
173
  webSocketUrl: 'wss://fake-url',
114
174
  },
115
175
  };
116
176
 
177
+ // Mock services not available (defaults to production behavior)
178
+ (mockWebex as any).internal = undefined;
117
179
  (mockWebex.request as jest.Mock).mockResolvedValueOnce(subscribeResponse);
118
180
 
181
+ webSocketManager = new WebSocketManager({ webex: mockWebex });
182
+
183
+ setTimeout(() => {
184
+ MockWebSocket.inst.onopen();
185
+ MockWebSocket.inst.onmessage({ data: JSON.stringify({ type: "Welcome" }) });
186
+ }, 1);
187
+
119
188
  await webSocketManager.initWebSocket({ body: fakeSubscribeRequest });
120
189
 
121
190
  expect(mockWebex.request).toHaveBeenCalledWith({
@@ -123,6 +192,7 @@ describe('WebSocketManager', () => {
123
192
  resource: SUBSCRIBE_API,
124
193
  method: 'POST',
125
194
  body: fakeSubscribeRequest,
195
+ headers: undefined,
126
196
  });
127
197
  });
128
198