@webex/contact-center 3.9.0-next.9 → 3.10.0-multi-llms.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cc.js +193 -47
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/logger-proxy.js +24 -1
- package/dist/logger-proxy.js.map +1 -1
- package/dist/metrics/behavioral-events.js +89 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +30 -2
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +271 -0
- package/dist/services/AddressBook.js.map +1 -0
- package/dist/services/EntryPoint.js +227 -0
- package/dist/services/EntryPoint.js.map +1 -0
- package/dist/services/Queue.js +261 -0
- package/dist/services/Queue.js.map +1 -0
- package/dist/services/config/constants.js +36 -2
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +29 -21
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +33 -1
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +91 -31
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/constants.js +17 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/task/TaskManager.js +150 -7
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +104 -0
- package/dist/services/task/TaskUtils.js.map +1 -0
- package/dist/services/task/constants.js +26 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +86 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/index.js +302 -39
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +12 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +121 -35
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/metrics/constants.d.ts +24 -1
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -0
- package/dist/types/services/config/constants.d.ts +35 -1
- package/dist/types/services/config/index.d.ts +6 -9
- package/dist/types/services/config/types.d.ts +79 -58
- package/dist/types/services/core/Utils.d.ts +33 -5
- package/dist/types/services/core/constants.d.ts +14 -0
- package/dist/types/services/task/TaskUtils.d.ts +42 -0
- package/dist/types/services/task/constants.d.ts +23 -0
- package/dist/types/services/task/contact.d.ts +10 -0
- package/dist/types/services/task/index.d.ts +84 -3
- package/dist/types/services/task/types.d.ts +245 -21
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +192 -0
- package/dist/utils/PageCache.js.map +1 -0
- package/dist/webex.js +1 -1
- package/package.json +10 -9
- package/src/cc.ts +217 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +17 -2
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/behavioral-events.ts +94 -0
- package/src/metrics/constants.ts +34 -1
- package/src/services/AddressBook.ts +291 -0
- package/src/services/EntryPoint.ts +241 -0
- package/src/services/Queue.ts +277 -0
- package/src/services/config/constants.ts +42 -2
- package/src/services/config/index.ts +30 -30
- package/src/services/config/types.ts +59 -58
- package/src/services/core/Utils.ts +101 -41
- package/src/services/core/constants.ts +16 -0
- package/src/services/task/TaskManager.ts +181 -9
- package/src/services/task/TaskUtils.ts +113 -0
- package/src/services/task/constants.ts +25 -0
- package/src/services/task/contact.ts +80 -0
- package/src/services/task/index.ts +364 -54
- package/src/services/task/types.ts +264 -20
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +282 -85
- package/test/unit/spec/metrics/behavioral-events.ts +42 -0
- package/test/unit/spec/services/AddressBook.ts +332 -0
- package/test/unit/spec/services/EntryPoint.ts +259 -0
- package/test/unit/spec/services/Queue.ts +323 -0
- package/test/unit/spec/services/config/index.ts +279 -65
- package/test/unit/spec/services/core/Utils.ts +262 -31
- package/test/unit/spec/services/task/TaskManager.ts +752 -1
- package/test/unit/spec/services/task/TaskUtils.ts +131 -0
- package/test/unit/spec/services/task/contact.ts +31 -1
- package/test/unit/spec/services/task/index.ts +675 -69
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isValidDialNumber = exports.getStationLoginErrorData = exports.getErrorDetails = exports.
|
|
6
|
+
exports.isValidDialNumber = exports.getStationLoginErrorData = exports.getErrorDetails = exports.getDestAgentIdForCBT = exports.getConsultedAgentId = exports.generateTaskErrorObject = exports.deriveConsultTransferDestinationType = exports.createErrDetailsObject = exports.calculateDestType = exports.calculateDestAgentId = void 0;
|
|
7
7
|
var Err = _interopRequireWildcard(require("./Err"));
|
|
8
8
|
var _types = require("../../types");
|
|
9
9
|
var _loggerProxy = _interopRequireDefault(require("../../logger-proxy"));
|
|
10
10
|
var _WebexRequest = _interopRequireDefault(require("./WebexRequest"));
|
|
11
11
|
var _types2 = require("../task/types");
|
|
12
|
+
var _constants = require("./constants");
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
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); }
|
|
14
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; }
|
|
@@ -192,48 +193,107 @@ const createErrDetailsObject = errObj => {
|
|
|
192
193
|
};
|
|
193
194
|
|
|
194
195
|
/**
|
|
195
|
-
*
|
|
196
|
+
* Gets the consulted agent ID from the media object by finding the agent
|
|
197
|
+
* in the consult media participants (excluding the current agent).
|
|
196
198
|
*
|
|
197
|
-
*
|
|
198
|
-
* -
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
* @param media - The media object from the interaction
|
|
200
|
+
* @param agentId - The current agent's ID to exclude from the search
|
|
201
|
+
* @returns The consulted agent ID, or empty string if none found
|
|
202
|
+
*/
|
|
203
|
+
exports.createErrDetailsObject = createErrDetailsObject;
|
|
204
|
+
const getConsultedAgentId = (media, agentId) => {
|
|
205
|
+
let consultParticipants = [];
|
|
206
|
+
let consultedParticipantId = '';
|
|
207
|
+
Object.keys(media).forEach(key => {
|
|
208
|
+
if (media[key].mType === _constants.STATE_CONSULT) {
|
|
209
|
+
consultParticipants = media[key].participants;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
if (consultParticipants.includes(agentId)) {
|
|
213
|
+
const id = consultParticipants.find(participant => participant !== agentId);
|
|
214
|
+
consultedParticipantId = id || consultedParticipantId;
|
|
215
|
+
}
|
|
216
|
+
return consultedParticipantId;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Gets the destination agent ID for CBT (Capacity Based Team) scenarios.
|
|
221
|
+
* CBT refers to teams created in Control Hub with capacity-based routing
|
|
222
|
+
* (as opposed to agent-based routing). This handles cases where the consulted
|
|
223
|
+
* participant is not directly in participants but can be found by matching
|
|
224
|
+
* the dial number (dn).
|
|
202
225
|
*
|
|
203
|
-
* @param
|
|
204
|
-
* @
|
|
226
|
+
* @param interaction - The interaction object
|
|
227
|
+
* @param consultingAgent - The consulting agent identifier
|
|
228
|
+
* @returns The destination agent ID for CBT scenarios, or empty string if none found
|
|
205
229
|
*/
|
|
230
|
+
exports.getConsultedAgentId = getConsultedAgentId;
|
|
231
|
+
const getDestAgentIdForCBT = (interaction, consultingAgent) => {
|
|
232
|
+
const participants = interaction.participants;
|
|
233
|
+
let destAgentIdForCBT = '';
|
|
234
|
+
|
|
235
|
+
// Check if this is a CBT scenario (consultingAgent exists but not directly in participants)
|
|
236
|
+
if (consultingAgent && !participants[consultingAgent]) {
|
|
237
|
+
const foundEntry = Object.entries(participants).find(([, participant]) => {
|
|
238
|
+
return participant.pType.toLowerCase() === _constants.PARTICIPANT_TYPES.DN && participant.type === _constants.PARTICIPANT_TYPES.AGENT && participant.dn === consultingAgent;
|
|
239
|
+
});
|
|
240
|
+
if (foundEntry) {
|
|
241
|
+
destAgentIdForCBT = foundEntry[0];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return destAgentIdForCBT;
|
|
245
|
+
};
|
|
246
|
+
|
|
206
247
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
248
|
+
* Calculates the destination agent ID for consult operations.
|
|
249
|
+
*
|
|
250
|
+
* @param interaction - The interaction object
|
|
251
|
+
* @param agentId - The current agent's ID
|
|
252
|
+
* @returns The destination agent ID
|
|
210
253
|
*/
|
|
211
|
-
exports.
|
|
212
|
-
const
|
|
213
|
-
|
|
254
|
+
exports.getDestAgentIdForCBT = getDestAgentIdForCBT;
|
|
255
|
+
const calculateDestAgentId = (interaction, agentId) => {
|
|
256
|
+
const consultingAgent = getConsultedAgentId(interaction.media, agentId);
|
|
257
|
+
|
|
258
|
+
// Check if this is a CBT (Capacity Based Team) scenario
|
|
259
|
+
// If not CBT, the function will return empty string and we'll use the normal flow
|
|
260
|
+
const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);
|
|
261
|
+
if (destAgentIdCBT) {
|
|
262
|
+
return destAgentIdCBT;
|
|
263
|
+
}
|
|
264
|
+
return interaction.participants[consultingAgent]?.type === _constants.PARTICIPANT_TYPES.EP_DN ? interaction.participants[consultingAgent]?.epId : interaction.participants[consultingAgent]?.id;
|
|
214
265
|
};
|
|
215
266
|
|
|
216
267
|
/**
|
|
217
|
-
*
|
|
218
|
-
* non-customer participant that is not the current agent and is not in wrap-up state.
|
|
268
|
+
* Calculates the destination agent ID for fetching destination type.
|
|
219
269
|
*
|
|
220
|
-
* @param
|
|
221
|
-
* @param agentId - The current agent's ID
|
|
222
|
-
* @returns The destination agent ID
|
|
270
|
+
* @param interaction - The interaction object
|
|
271
|
+
* @param agentId - The current agent's ID
|
|
272
|
+
* @returns The destination agent ID for determining destination type
|
|
223
273
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
274
|
+
exports.calculateDestAgentId = calculateDestAgentId;
|
|
275
|
+
const calculateDestType = (interaction, agentId) => {
|
|
276
|
+
const consultingAgent = getConsultedAgentId(interaction.media, agentId);
|
|
277
|
+
|
|
278
|
+
// Check if this is a CBT (Capacity Based Team) scenario, otherwise use consultingAgent
|
|
279
|
+
const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);
|
|
280
|
+
const destinationaegntId = destAgentIdCBT || consultingAgent;
|
|
281
|
+
const destAgentType = destinationaegntId ? interaction.participants[destinationaegntId]?.pType : undefined;
|
|
282
|
+
if (destAgentType) {
|
|
283
|
+
if (destAgentType === 'DN') {
|
|
284
|
+
return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
|
|
285
|
+
}
|
|
286
|
+
if (destAgentType === 'EP-DN') {
|
|
287
|
+
return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;
|
|
288
|
+
}
|
|
289
|
+
// Keep the existing destinationType if it's something else (like "agent" or "Agent")
|
|
290
|
+
// Convert "Agent" to lowercase for consistency
|
|
291
|
+
|
|
292
|
+
return destAgentType.toLowerCase();
|
|
233
293
|
}
|
|
234
|
-
return
|
|
294
|
+
return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
|
|
235
295
|
};
|
|
236
|
-
exports.
|
|
296
|
+
exports.calculateDestType = calculateDestType;
|
|
237
297
|
const deriveConsultTransferDestinationType = taskData => {
|
|
238
298
|
const agentActionType = getAgentActionTypeFromTask(taskData);
|
|
239
299
|
if (agentActionType === 'DIAL_NUMBER') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","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","isNonCustomerParticipant","participantType","getDestinationAgentId","participants","agentId","id","keys","forEach","participant","participantData","type","isWrapUp","deriveConsultTransferDestinationType","agentActionType","CONSULT_TRANSFER_DESTINATION_TYPE","ENTRYPOINT","DIALNUMBER","AGENT"],"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';\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 * Derives the consult transfer destination type based on the provided task data.\n *\n * Logic parity with desktop behavior:\n * - If agent action is dialing a number (DN/EPDN/ENTRYPOINT):\n * - ENTRYPOINT/EPDN map to ENTRYPOINT\n * - DN maps to DIALNUMBER\n * - Otherwise defaults to AGENT\n *\n * @param taskData - The task data used to infer the agent action and destination type\n * @returns The normalized destination type to be used for consult transfer\n */\n/**\n * Checks if a participant type represents a non-customer participant.\n * Non-customer participants include agents, dial numbers, entry point dial numbers,\n * and entry points.\n */\nconst isNonCustomerParticipant = (participantType: string): boolean => {\n return (\n participantType === 'Agent' ||\n participantType === 'DN' ||\n participantType === 'EpDn' ||\n participantType === 'entryPoint'\n );\n};\n\n/**\n * Gets the destination agent ID from participants data by finding the first\n * non-customer participant that is not the current agent and is not in wrap-up state.\n *\n * @param participants - The participants data from the interaction\n * @param agentId - The current agent's ID to exclude from the search\n * @returns The destination agent ID, or empty string if none found\n */\nexport const getDestinationAgentId = (\n participants: Interaction['participants'],\n agentId: string\n): string => {\n let id = '';\n\n if (participants) {\n Object.keys(participants).forEach((participant) => {\n const participantData = participants[participant];\n if (\n isNonCustomerParticipant(participantData.type) &&\n participantData.id !== agentId &&\n !participantData.isWrapUp\n ) {\n id = participantData.id;\n }\n });\n }\n\n return id;\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;AAKuB,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,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ACnCC,YAAyC,EACzCC,OAAe,KACJ;EACX,IAAIC,EAAE,GAAG,EAAE;EAEX,IAAIF,YAAY,EAAE;IAChBzE,MAAM,CAAC4E,IAAI,CAACH,YAAY,CAAC,CAACI,OAAO,CAAEC,WAAW,IAAK;MACjD,MAAMC,eAAe,GAAGN,YAAY,CAACK,WAAW,CAAC;MACjD,IACER,wBAAwB,CAACS,eAAe,CAACC,IAAI,CAAC,IAC9CD,eAAe,CAACJ,EAAE,KAAKD,OAAO,IAC9B,CAACK,eAAe,CAACE,QAAQ,EACzB;QACAN,EAAE,GAAGI,eAAe,CAACJ,EAAE;MACzB;IACF,CAAC,CAAC;EACJ;EAEA,OAAOA,EAAE;AACX,CAAC;AAAC/C,OAAA,CAAA4C,qBAAA,GAAAA,qBAAA;AAEK,MAAMU,oCAAoC,GAC/C9D,QAAmB,IAC2B;EAC9C,MAAM+D,eAAe,GAAGhE,0BAA0B,CAACC,QAAQ,CAAC;EAE5D,IAAI+D,eAAe,KAAK,aAAa,EAAE;IACrC,OAAOlE,kBAAkB,CAACG,QAAQ,EAAEC,eAAe,CAAC,GAChD+D,yCAAiC,CAACC,UAAU,GAC5CD,yCAAiC,CAACE,UAAU;EAClD;EAEA,OAAOF,yCAAiC,CAACG,KAAK;AAChD,CAAC;AAAC3D,OAAA,CAAAsD,oCAAA,GAAAA,oCAAA"}
|
|
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,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAA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6
|
-
exports.WS_DISCONNECT_ALLOWED = exports.WELCOME_TIMEOUT = exports.TIMEOUT_REQ = exports.RTD_PING_EVENT = exports.PING_API_URL = exports.NOTIFS_RESOLVE_DELAY = exports.METHODS = exports.LOST_CONNECTION_RECOVERY_TIMEOUT = exports.KEEPALIVE_WORKER_INTERVAL = exports.CONNECTIVITY_CHECK_INTERVAL = exports.CLOSE_SOCKET_TIMEOUT_DURATION = exports.CLOSE_SOCKET_TIMEOUT = void 0;
|
|
6
|
+
exports.WS_DISCONNECT_ALLOWED = exports.WELCOME_TIMEOUT = exports.TIMEOUT_REQ = exports.STATE_CONSULT = exports.RTD_PING_EVENT = exports.PING_API_URL = exports.PARTICIPANT_TYPES = exports.NOTIFS_RESOLVE_DELAY = exports.METHODS = exports.LOST_CONNECTION_RECOVERY_TIMEOUT = exports.KEEPALIVE_WORKER_INTERVAL = exports.CONNECTIVITY_CHECK_INTERVAL = exports.CLOSE_SOCKET_TIMEOUT_DURATION = exports.CLOSE_SOCKET_TIMEOUT = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Interval in milliseconds for sending keepalive pings to the worker.
|
|
9
9
|
* @ignore
|
|
@@ -70,6 +70,22 @@ const CONNECTIVITY_CHECK_INTERVAL = exports.CONNECTIVITY_CHECK_INTERVAL = 5000;
|
|
|
70
70
|
*/
|
|
71
71
|
const CLOSE_SOCKET_TIMEOUT = exports.CLOSE_SOCKET_TIMEOUT = 16000;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Constants for participant types, destination types, and interaction states
|
|
75
|
+
* @ignore
|
|
76
|
+
*/
|
|
77
|
+
const PARTICIPANT_TYPES = exports.PARTICIPANT_TYPES = {
|
|
78
|
+
/** Participant type for Entry Point Dial Number */
|
|
79
|
+
EP_DN: 'EpDn',
|
|
80
|
+
/** Participant type for dial number */
|
|
81
|
+
DN: 'dn',
|
|
82
|
+
/** Participant type for Agent */
|
|
83
|
+
AGENT: 'Agent'
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Interaction state for consultation */
|
|
87
|
+
const STATE_CONSULT = exports.STATE_CONSULT = 'consult';
|
|
88
|
+
|
|
73
89
|
// Method names for core services
|
|
74
90
|
const METHODS = exports.METHODS = {
|
|
75
91
|
// WebexRequest methods
|
|
@@ -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","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// 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;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,GAAAT,OAAA,CAAAS,2BAAA,GAAG,IAAI;;AAE/C;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,GAAAV,OAAA,CAAAU,oBAAA,GAAG,KAAK;;AAEzC;AACO,MAAMC,
|
|
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;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,GAAAT,OAAA,C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15,6 +15,7 @@ var _loggerProxy = _interopRequireDefault(require("../../logger-proxy"));
|
|
|
15
15
|
var _ = _interopRequireDefault(require("."));
|
|
16
16
|
var _MetricsManager = _interopRequireDefault(require("../../metrics/MetricsManager"));
|
|
17
17
|
var _constants3 = require("../../metrics/constants");
|
|
18
|
+
var _TaskUtils = require("./TaskUtils");
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
20
|
/** @internal */
|
|
20
21
|
class TaskManager extends _events.default {
|
|
@@ -42,6 +43,18 @@ class TaskManager extends _events.default {
|
|
|
42
43
|
setWrapupData(wrapupData) {
|
|
43
44
|
this.wrapupData = wrapupData;
|
|
44
45
|
}
|
|
46
|
+
setAgentId(agentId) {
|
|
47
|
+
this.agentId = agentId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current agent ID
|
|
52
|
+
* @returns {string} The agent ID set for this task manager instance
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
getAgentId() {
|
|
56
|
+
return this.agentId;
|
|
57
|
+
}
|
|
45
58
|
handleIncomingWebCall = call => {
|
|
46
59
|
const currentTask = Object.values(this.taskCollection).find(task => task.data.interaction.mediaType === 'telephony');
|
|
47
60
|
if (currentTask) {
|
|
@@ -94,8 +107,9 @@ class TaskManager extends _events.default {
|
|
|
94
107
|
});
|
|
95
108
|
task = new _.default(this.contact, this.webCallingService, {
|
|
96
109
|
...payload.data,
|
|
97
|
-
wrapUpRequired: payload.data.interaction?.participants?.[
|
|
98
|
-
|
|
110
|
+
wrapUpRequired: payload.data.interaction?.participants?.[this.agentId]?.isWrapUp || false,
|
|
111
|
+
isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(payload.data)
|
|
112
|
+
}, this.wrapupData, this.agentId);
|
|
99
113
|
this.taskCollection[payload.data.interactionId] = task;
|
|
100
114
|
// Condition 1: The state is=new i.e it is a incoming task
|
|
101
115
|
if (payload.data.interaction.state === 'new') {
|
|
@@ -120,7 +134,7 @@ class TaskManager extends _events.default {
|
|
|
120
134
|
task = new _.default(this.contact, this.webCallingService, {
|
|
121
135
|
...payload.data,
|
|
122
136
|
isConsulted: false
|
|
123
|
-
}, this.wrapupData);
|
|
137
|
+
}, this.wrapupData, this.agentId);
|
|
124
138
|
this.taskCollection[payload.data.interactionId] = task;
|
|
125
139
|
if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels
|
|
126
140
|
) {
|
|
@@ -181,12 +195,18 @@ class TaskManager extends _events.default {
|
|
|
181
195
|
break;
|
|
182
196
|
}
|
|
183
197
|
case _types2.CC_EVENTS.CONTACT_ENDED:
|
|
198
|
+
// Update task data
|
|
184
199
|
task = this.updateTaskData(task, {
|
|
185
200
|
...payload.data,
|
|
186
|
-
wrapUpRequired: payload.data.interaction.state !== 'new'
|
|
201
|
+
wrapUpRequired: payload.data.interaction.state !== 'new' && !(0, _TaskUtils.isSecondaryEpDnAgent)(payload.data.interaction)
|
|
187
202
|
});
|
|
203
|
+
|
|
204
|
+
// Handle cleanup based on whether task should be deleted
|
|
188
205
|
this.handleTaskCleanup(task);
|
|
189
|
-
task
|
|
206
|
+
task?.emit(_types.TASK_EVENTS.TASK_END, task);
|
|
207
|
+
break;
|
|
208
|
+
case _types2.CC_EVENTS.CONTACT_MERGED:
|
|
209
|
+
task = this.handleContactMerged(task, payload.data);
|
|
190
210
|
break;
|
|
191
211
|
case _types2.CC_EVENTS.AGENT_CONTACT_HELD:
|
|
192
212
|
// As soon as the main interaction is held, we need to emit TASK_HOLD
|
|
@@ -286,6 +306,84 @@ class TaskManager extends _events.default {
|
|
|
286
306
|
task = this.updateTaskData(task, payload.data);
|
|
287
307
|
task.emit(_types.TASK_EVENTS.TASK_RECORDING_RESUME_FAILED, task);
|
|
288
308
|
break;
|
|
309
|
+
case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCING:
|
|
310
|
+
// Conference is being established - update task state and emit establishing event
|
|
311
|
+
task = this.updateTaskData(task, payload.data);
|
|
312
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_ESTABLISHING, task);
|
|
313
|
+
break;
|
|
314
|
+
case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCED:
|
|
315
|
+
// Conference started successfully - update task state and emit event
|
|
316
|
+
task = this.updateTaskData(task, payload.data);
|
|
317
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_STARTED, task);
|
|
318
|
+
break;
|
|
319
|
+
case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_FAILED:
|
|
320
|
+
// Conference failed - update task state and emit failure event
|
|
321
|
+
task = this.updateTaskData(task, payload.data);
|
|
322
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_FAILED, task);
|
|
323
|
+
break;
|
|
324
|
+
case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_ENDED:
|
|
325
|
+
// Conference ended - update task state and emit event
|
|
326
|
+
task = this.updateTaskData(task, payload.data);
|
|
327
|
+
if (!task || (0, _TaskUtils.isPrimary)(task, this.agentId) || (0, _TaskUtils.isParticipantInMainInteraction)(task, this.agentId)) {
|
|
328
|
+
_loggerProxy.default.log('Primary or main interaction participant leaving conference');
|
|
329
|
+
} else {
|
|
330
|
+
this.removeTaskFromCollection(task);
|
|
331
|
+
}
|
|
332
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_ENDED, task);
|
|
333
|
+
break;
|
|
334
|
+
case _types2.CC_EVENTS.PARTICIPANT_JOINED_CONFERENCE:
|
|
335
|
+
{
|
|
336
|
+
task = this.updateTaskData(task, {
|
|
337
|
+
...payload.data,
|
|
338
|
+
isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(payload.data)
|
|
339
|
+
});
|
|
340
|
+
task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_JOINED, task);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case _types2.CC_EVENTS.PARTICIPANT_LEFT_CONFERENCE:
|
|
344
|
+
{
|
|
345
|
+
// Conference ended - update task state and emit event
|
|
346
|
+
|
|
347
|
+
task = this.updateTaskData(task, {
|
|
348
|
+
...payload.data,
|
|
349
|
+
isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(payload.data)
|
|
350
|
+
});
|
|
351
|
+
if ((0, _TaskUtils.checkParticipantNotInInteraction)(task, this.agentId)) {
|
|
352
|
+
if ((0, _TaskUtils.isParticipantInMainInteraction)(task, this.agentId) || (0, _TaskUtils.isPrimary)(task, this.agentId)) {
|
|
353
|
+
_loggerProxy.default.log('Primary or main interaction participant leaving conference');
|
|
354
|
+
} else {
|
|
355
|
+
this.removeTaskFromCollection(task);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_LEFT, task);
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
case _types2.CC_EVENTS.PARTICIPANT_LEFT_CONFERENCE_FAILED:
|
|
362
|
+
// Conference exit failed - update task state and emit failure event
|
|
363
|
+
task = this.updateTaskData(task, payload.data);
|
|
364
|
+
task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_LEFT_FAILED, task);
|
|
365
|
+
break;
|
|
366
|
+
case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_END_FAILED:
|
|
367
|
+
// Conference end failed - update task state with error details and emit failure event
|
|
368
|
+
task = this.updateTaskData(task, payload.data);
|
|
369
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_END_FAILED, task);
|
|
370
|
+
break;
|
|
371
|
+
case _types2.CC_EVENTS.AGENT_CONFERENCE_TRANSFERRED:
|
|
372
|
+
// Conference was transferred - update task state and emit transfer success event
|
|
373
|
+
// Note: Backend should provide hasLeft and wrapUpRequired status
|
|
374
|
+
task = this.updateTaskData(task, payload.data);
|
|
375
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_TRANSFERRED, task);
|
|
376
|
+
break;
|
|
377
|
+
case _types2.CC_EVENTS.AGENT_CONFERENCE_TRANSFER_FAILED:
|
|
378
|
+
// Conference transfer failed - update task state with error details and emit failure event
|
|
379
|
+
task = this.updateTaskData(task, payload.data);
|
|
380
|
+
task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_TRANSFER_FAILED, task);
|
|
381
|
+
break;
|
|
382
|
+
case _types2.CC_EVENTS.PARTICIPANT_POST_CALL_ACTIVITY:
|
|
383
|
+
// Post-call activity for participant - update task state with activity details
|
|
384
|
+
task = this.updateTaskData(task, payload.data);
|
|
385
|
+
task.emit(_types.TASK_EVENTS.TASK_POST_CALL_ACTIVITY, task);
|
|
386
|
+
break;
|
|
289
387
|
default:
|
|
290
388
|
break;
|
|
291
389
|
}
|
|
@@ -318,6 +416,44 @@ class TaskManager extends _events.default {
|
|
|
318
416
|
return task;
|
|
319
417
|
}
|
|
320
418
|
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Handles CONTACT_MERGED event logic
|
|
422
|
+
* @param task - The task to process
|
|
423
|
+
* @param taskData - The task data from the event payload
|
|
424
|
+
* @returns Updated or newly created task
|
|
425
|
+
* @private
|
|
426
|
+
*/
|
|
427
|
+
handleContactMerged(task, taskData) {
|
|
428
|
+
if (taskData.childInteractionId) {
|
|
429
|
+
// remove the child task from collection
|
|
430
|
+
this.removeTaskFromCollection(this.taskCollection[taskData.childInteractionId]);
|
|
431
|
+
}
|
|
432
|
+
if (this.taskCollection[taskData.interactionId]) {
|
|
433
|
+
_loggerProxy.default.log(`Got CONTACT_MERGED: Task already exists in collection`, {
|
|
434
|
+
module: _constants.TASK_MANAGER_FILE,
|
|
435
|
+
method: _constants2.METHODS.REGISTER_TASK_LISTENERS,
|
|
436
|
+
interactionId: taskData.interactionId
|
|
437
|
+
});
|
|
438
|
+
// update the task data
|
|
439
|
+
task = this.updateTaskData(task, taskData);
|
|
440
|
+
} else {
|
|
441
|
+
// Case2 : Task is not present in taskCollection
|
|
442
|
+
_loggerProxy.default.log(`Got CONTACT_MERGED : Creating new task in taskManager`, {
|
|
443
|
+
module: _constants.TASK_MANAGER_FILE,
|
|
444
|
+
method: _constants2.METHODS.REGISTER_TASK_LISTENERS,
|
|
445
|
+
interactionId: taskData.interactionId
|
|
446
|
+
});
|
|
447
|
+
task = new _.default(this.contact, this.webCallingService, {
|
|
448
|
+
...taskData,
|
|
449
|
+
wrapUpRequired: taskData.interaction?.participants?.[this.agentId]?.isWrapUp || false,
|
|
450
|
+
isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(taskData)
|
|
451
|
+
}, this.wrapupData, this.agentId);
|
|
452
|
+
this.taskCollection[taskData.interactionId] = task;
|
|
453
|
+
}
|
|
454
|
+
this.emit(_types.TASK_EVENTS.TASK_MERGED, task);
|
|
455
|
+
return task;
|
|
456
|
+
}
|
|
321
457
|
removeTaskFromCollection(task) {
|
|
322
458
|
if (task?.data?.interactionId) {
|
|
323
459
|
delete this.taskCollection[task.data.interactionId];
|
|
@@ -328,13 +464,20 @@ class TaskManager extends _events.default {
|
|
|
328
464
|
});
|
|
329
465
|
}
|
|
330
466
|
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Handles cleanup of task resources including Desktop/WebRTC call cleanup and task removal
|
|
470
|
+
* @param task - The task to clean up
|
|
471
|
+
* @private
|
|
472
|
+
*/
|
|
331
473
|
handleTaskCleanup(task) {
|
|
474
|
+
// Clean up Desktop/WebRTC calling resources for browser-based telephony tasks
|
|
332
475
|
if (this.webCallingService.loginOption === _types3.LoginOption.BROWSER && task.data.interaction.mediaType === 'telephony') {
|
|
333
476
|
task.unregisterWebCallListeners();
|
|
334
477
|
this.webCallingService.cleanUpCall();
|
|
335
478
|
}
|
|
336
|
-
if (task.data.interaction.state === 'new') {
|
|
337
|
-
// Only remove tasks in 'new' state immediately. For other states,
|
|
479
|
+
if (task.data.interaction.state === 'new' || (0, _TaskUtils.isSecondaryEpDnAgent)(task.data.interaction)) {
|
|
480
|
+
// Only remove tasks in 'new' state or isSecondaryEpDnAgent immediately. For other states,
|
|
338
481
|
// retain tasks until they complete wrap-up, unless the task disconnected before being answered.
|
|
339
482
|
this.removeTaskFromCollection(task);
|
|
340
483
|
}
|