@webex/contact-center 3.9.0 → 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 +207 -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/MetricsManager.js +1 -1
- package/dist/metrics/MetricsManager.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 +32 -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/GlobalTypes.js.map +1 -1
- package/dist/services/core/Utils.js +181 -2
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +0 -4
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/constants.js +17 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +0 -4
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/TaskManager.js +151 -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 +428 -91
- 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 +25 -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/GlobalTypes.d.ts +25 -0
- package/dist/types/services/core/Utils.d.ts +55 -1
- 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 +85 -4
- 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 +232 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +17 -2
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/MetricsManager.ts +1 -1
- package/src/metrics/behavioral-events.ts +94 -0
- package/src/metrics/constants.ts +37 -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/GlobalTypes.ts +27 -0
- package/src/services/core/Utils.ts +215 -1
- package/src/services/core/aqm-reqs.ts +0 -5
- package/src/services/core/constants.ts +16 -0
- package/src/services/core/websocket/WebSocketManager.ts +0 -4
- package/src/services/task/TaskManager.ts +182 -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 +497 -71
- 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/MetricsManager.ts +0 -1
- 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 +282 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
- package/test/unit/spec/services/task/TaskManager.ts +760 -2
- 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 +873 -163
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isValidDialNumber = exports.getStationLoginErrorData = exports.getErrorDetails = exports.createErrDetailsObject = void 0;
|
|
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
|
+
var _types2 = require("../task/types");
|
|
12
|
+
var _constants = require("./constants");
|
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
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); }
|
|
13
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; }
|
|
@@ -25,6 +27,28 @@ const getCommonErrorDetails = errObj => {
|
|
|
25
27
|
msg: errObj?.body
|
|
26
28
|
};
|
|
27
29
|
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the destination type represents an entry point variant (EPDN or ENTRYPOINT).
|
|
33
|
+
*/
|
|
34
|
+
const isEntryPointOrEpdn = destAgentType => {
|
|
35
|
+
return destAgentType === 'EPDN' || destAgentType === 'ENTRYPOINT';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Determines if the task involves dialing a number based on the destination type.
|
|
40
|
+
* Returns 'DIAL_NUMBER' for dial-related destinations, empty string otherwise.
|
|
41
|
+
*/
|
|
42
|
+
const getAgentActionTypeFromTask = taskData => {
|
|
43
|
+
const destAgentType = taskData?.destinationType;
|
|
44
|
+
|
|
45
|
+
// Check if destination requires dialing: direct dial number or entry point variants
|
|
46
|
+
const isDialNumber = destAgentType === 'DN';
|
|
47
|
+
const isEntryPointVariant = isEntryPointOrEpdn(destAgentType);
|
|
48
|
+
|
|
49
|
+
// If the destination type is a dial number or an entry point variant, return 'DIAL_NUMBER'
|
|
50
|
+
return isDialNumber || isEntryPointVariant ? 'DIAL_NUMBER' : '';
|
|
51
|
+
};
|
|
28
52
|
const isValidDialNumber = input => {
|
|
29
53
|
// This regex checks for a valid dial number format for only few countries such as US, Canada.
|
|
30
54
|
const regexForDn = /1[0-9]{3}[2-9][0-9]{6}([,]{1,10}[0-9]+){0,1}/;
|
|
@@ -107,6 +131,51 @@ const getErrorDetails = (error, methodName, moduleName) => {
|
|
|
107
131
|
};
|
|
108
132
|
};
|
|
109
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Extracts error details from task API errors and logs them. Also uploads logs for the error.
|
|
136
|
+
* This handles the specific error format returned by task API calls.
|
|
137
|
+
*
|
|
138
|
+
* @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}
|
|
139
|
+
* @param methodName - The name of the method where the error occurred.
|
|
140
|
+
* @param moduleName - The name of the module where the error occurred.
|
|
141
|
+
* @returns AugmentedError containing structured error details on err.data for metrics and logging
|
|
142
|
+
* @public
|
|
143
|
+
* @example
|
|
144
|
+
* const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');
|
|
145
|
+
* throw taskError.error;
|
|
146
|
+
* @ignore
|
|
147
|
+
*/
|
|
148
|
+
exports.getErrorDetails = getErrorDetails;
|
|
149
|
+
const generateTaskErrorObject = (error, methodName, moduleName) => {
|
|
150
|
+
const trackingId = error?.details?.trackingId || error?.trackingId || '';
|
|
151
|
+
const errorMsg = error?.details?.msg;
|
|
152
|
+
const fallbackMessage = error && typeof error.message === 'string' && error.message || `Error while performing ${methodName}`;
|
|
153
|
+
const errorMessage = errorMsg?.errorMessage || fallbackMessage;
|
|
154
|
+
const errorType = errorMsg?.errorType || error && typeof error.name === 'string' && error.name || 'Unknown Error';
|
|
155
|
+
const errorData = errorMsg?.errorData || '';
|
|
156
|
+
const reasonCode = errorMsg?.reasonCode || 0;
|
|
157
|
+
|
|
158
|
+
// Log and upload for Task API formatted errors
|
|
159
|
+
_loggerProxy.default.error(`${methodName} failed: ${errorMessage} (${errorType})`, {
|
|
160
|
+
module: moduleName,
|
|
161
|
+
method: methodName,
|
|
162
|
+
trackingId
|
|
163
|
+
});
|
|
164
|
+
_WebexRequest.default.getInstance().uploadLogs({
|
|
165
|
+
correlationId: trackingId
|
|
166
|
+
});
|
|
167
|
+
const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;
|
|
168
|
+
const err = new Error(reason);
|
|
169
|
+
err.data = {
|
|
170
|
+
message: errorMessage,
|
|
171
|
+
errorType,
|
|
172
|
+
errorData,
|
|
173
|
+
reasonCode,
|
|
174
|
+
trackingId
|
|
175
|
+
};
|
|
176
|
+
return err;
|
|
177
|
+
};
|
|
178
|
+
|
|
110
179
|
/**
|
|
111
180
|
* Creates an error details object suitable for use with the Err.Details class.
|
|
112
181
|
*
|
|
@@ -117,10 +186,120 @@ const getErrorDetails = (error, methodName, moduleName) => {
|
|
|
117
186
|
* const errDetails = createErrDetailsObject(webexRequestPayload);
|
|
118
187
|
* @ignore
|
|
119
188
|
*/
|
|
120
|
-
exports.
|
|
189
|
+
exports.generateTaskErrorObject = generateTaskErrorObject;
|
|
121
190
|
const createErrDetailsObject = errObj => {
|
|
122
191
|
const details = getCommonErrorDetails(errObj);
|
|
123
192
|
return new Err.Details('Service.reqs.generic.failure', details);
|
|
124
193
|
};
|
|
194
|
+
|
|
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).
|
|
198
|
+
*
|
|
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
|
+
*/
|
|
125
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).
|
|
225
|
+
*
|
|
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
|
|
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
|
+
|
|
247
|
+
/**
|
|
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
|
|
253
|
+
*/
|
|
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;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Calculates the destination agent ID for fetching destination type.
|
|
269
|
+
*
|
|
270
|
+
* @param interaction - The interaction object
|
|
271
|
+
* @param agentId - The current agent's ID
|
|
272
|
+
* @returns The destination agent ID for determining destination type
|
|
273
|
+
*/
|
|
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();
|
|
293
|
+
}
|
|
294
|
+
return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
|
|
295
|
+
};
|
|
296
|
+
exports.calculateDestType = calculateDestType;
|
|
297
|
+
const deriveConsultTransferDestinationType = taskData => {
|
|
298
|
+
const agentActionType = getAgentActionTypeFromTask(taskData);
|
|
299
|
+
if (agentActionType === 'DIAL_NUMBER') {
|
|
300
|
+
return isEntryPointOrEpdn(taskData?.destinationType) ? _types2.CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT : _types2.CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
|
|
301
|
+
}
|
|
302
|
+
return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
|
|
303
|
+
};
|
|
304
|
+
exports.deriveConsultTransferDestinationType = deriveConsultTransferDestinationType;
|
|
126
305
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","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","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","createErrDetailsObject","Details"],"sources":["Utils.ts"],"sourcesContent":["import * as Err from './Err';\nimport {LoginOption, WebexRequestPayload} from '../../types';\nimport {Failure} from './GlobalTypes';\nimport LoggerProxy from '../../logger-proxy';\nimport WebexRequest from './WebexRequest';\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\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 * 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"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC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IC,KAAK,CAAChB,MAAM,IAAK,0BAAyBI,UAAW,EAAC,CAAC;EACvE;EACAW,GAAG,CAACd,IAAI,GAAGK,OAAO;EAElB,OAAO;IACLH,KAAK,EAAEY,GAAG;IACVf;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATAf,OAAA,CAAAiB,eAAA,GAAAA,eAAA;AAUO,MAAMe,sBAAsB,GAAI3C,MAA2B,IAAK;EACrE,MAAMiC,OAAO,GAAGlC,qBAAqB,CAACC,MAAM,CAAC;EAE7C,OAAO,IAAI9B,GAAG,CAAC0E,OAAO,CAAC,8BAA8B,EAAEX,OAAO,CAAC;AACjE,CAAC;AAACtB,OAAA,CAAAgC,sBAAA,GAAAA,sBAAA"}
|
|
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(ta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qF,kBAAkB,GACpCjB,WAAW,CAACN,YAAY,CAACuB,kBAAkB,CAAC,EAAEZ,KAAK,GACnDa,SAAS;EACb,IAAItF,aAAa,EAAE;IACjB,IAAIA,aAAa,KAAK,IAAI,EAAE;MAC1B,OAAOuF,yCAAiC,CAACC,UAAU;IACrD;IACA,IAAIxF,aAAa,KAAK,OAAO,EAAE;MAC7B,OAAOuF,yCAAiC,CAACE,UAAU;IACrD;IACA;IACA;;IAEA,OAAOzF,aAAa,CAAC0E,WAAW,CAAC,CAAC;EACpC;EAEA,OAAOa,yCAAiC,CAACT,KAAK;AAChD,CAAC;AAACpE,OAAA,CAAA0E,iBAAA,GAAAA,iBAAA;AAEK,MAAMM,oCAAoC,GAC/CxF,QAAmB,IAC2B;EAC9C,MAAMyF,eAAe,GAAG1F,0BAA0B,CAACC,QAAQ,CAAC;EAE5D,IAAIyF,eAAe,KAAK,aAAa,EAAE;IACrC,OAAO5F,kBAAkB,CAACG,QAAQ,EAAEC,eAAe,CAAC,GAChDoF,yCAAiC,CAACE,UAAU,GAC5CF,yCAAiC,CAACC,UAAU;EAClD;EAEA,OAAOD,yCAAiC,CAACT,KAAK;AAChD,CAAC;AAACpE,OAAA,CAAAgF,oCAAA,GAAAA,oCAAA"}
|
|
@@ -200,10 +200,6 @@ class AqmReqs {
|
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
if (event.keepalive === 'true') {
|
|
203
|
-
_loggerProxy.default.info(`Keepalive from web socket`, {
|
|
204
|
-
module: _constants2.AQM_REQS_FILE,
|
|
205
|
-
method: _constants.METHODS.ON_MESSAGE
|
|
206
|
-
});
|
|
207
203
|
return;
|
|
208
204
|
}
|
|
209
205
|
if (event.type === 'AgentReloginFailed') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","LoggerProxy","log","JSON","stringify","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","eerr","errId","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","error","headers","Authorization","Message","window","setTimeout","TIMEOUT_REQ","result","Array","isArray","join","slice","includes","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","keys","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n const eerr = new Err.Details(notifFail.errId, msg as any);\n LoggerProxy.log(`Routing request failed: ${eerr}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(eerr);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n LoggerProxy.error(`Routing request timeout${keySuccess}${response!}${c.url}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n private bindPrint(bind: any) {\n let result = '';\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n result += `${k}=[${bind[k].join(',')}],`;\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n result += `${k}=(${this.bindPrint(bind[k])}),`;\n } else {\n result += `${k}=${bind[k]},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n private bindCheck(bind: any, msg: any) {\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n // Check if the message value matches any of the values in the array\n if (!bind[k].includes(msg[k])) {\n return false;\n }\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n if (typeof msg[k] === 'object' && msg[k] !== null) {\n if (!this.bindCheck(bind[k], msg[k])) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msg[k] || msg[k] !== bind[k]) {\n return false;\n }\n }\n\n return true;\n }\n\n // must be lambda\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n LoggerProxy.info(`Keepalive from web socket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\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AC7B,MAAM9E,GAAG,GAAG,IAAI,CAACT,yBAAyB,CAACsF,OAAO,CAAC;MACnD,IAAI7E,GAAG,CAACwB,KAAK,CAAC4C,KAAK,CAAC,EAAE;QACpBpE,GAAG,CAAC0B,MAAM,CAAC0C,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;MAClB;IACF;;IAEA;;IAEA,IAAI,CAACA,SAAS,EAAE;MACd7C,oBAAW,CAAC0C,IAAI,CAAE,uEAAsE,EAAE;QACxFtC,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAA9G,OAAA,GAAAoB,OAAA"}
|
|
1
|
+
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","LoggerProxy","log","JSON","stringify","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","eerr","errId","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","error","headers","Authorization","Message","window","setTimeout","TIMEOUT_REQ","result","Array","isArray","join","slice","includes","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","keys","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n const eerr = new Err.Details(notifFail.errId, msg as any);\n LoggerProxy.log(`Routing request failed: ${eerr}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(eerr);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n LoggerProxy.error(`Routing request timeout${keySuccess}${response!}${c.url}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n private bindPrint(bind: any) {\n let result = '';\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n result += `${k}=[${bind[k].join(',')}],`;\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n result += `${k}=(${this.bindPrint(bind[k])}),`;\n } else {\n result += `${k}=${bind[k]},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n private bindCheck(bind: any, msg: any) {\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n // Check if the message value matches any of the values in the array\n if (!bind[k].includes(msg[k])) {\n return false;\n }\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n if (typeof msg[k] === 'object' && msg[k] !== null) {\n if (!this.bindCheck(bind[k], msg[k])) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msg[k] || msg[k] !== bind[k]) {\n return false;\n }\n }\n\n return true;\n }\n\n // must be lambda\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,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,C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AAO,IAAIF,IAAI,EAAE;MAC1B,MAAM3E,GAAG,GAAG,IAAI,CAACV,eAAe,CAACuF,OAAO,CAAC;MACzC,IAAI7E,GAAG,CAACwB,KAAK,CAAC4C,KAAK,CAAC,EAAE;QACpBpE,GAAG,CAAC0B,MAAM,CAAC0C,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;QAChB;MACF;IACF;IACA;IACA,MAAMI,OAAO,GAAGlG,MAAM,CAACgG,IAAI,CAAC,IAAI,CAACrF,yBAAyB,CAAC;IAC3D,KAAK,MAAMsF,OAAO,IAAIC,OAAO,EAAE;MAC7B,MAAM9E,GAAG,GAAG,IAAI,CAACT,yBAAyB,CAACsF,OAAO,CAAC;MACnD,IAAI7E,GAAG,CAACwB,KAAK,CAAC4C,KAAK,CAAC,EAAE;QACpBpE,GAAG,CAAC0B,MAAM,CAAC0C,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;MAClB;IACF;;IAEA;;IAEA,IAAI,CAACA,SAAS,EAAE;MACd7C,oBAAW,CAAC0C,IAAI,CAAE,uEAAsE,EAAE;QACxFtC,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACoC;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACO,OAAA,CAAA9G,OAAA,GAAAoB,OAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
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,CAAAS,2BAAA,GAAG,IAAI;;AAE/C;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,GAAAV,OAAA,CAAAU,oBAAA,GAAG,KAAK;;AAEzC;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAAX,OAAA,CAAAW,iBAAA,GAAG;EAC/B;EACAC,KAAK,EAAE,MAAM;EACb;EACAC,EAAE,EAAE,IAAI;EACR;EACAC,KAAK,EAAE;AACT,CAAC;;AAED;AACO,MAAMC,aAAa,GAAAf,OAAA,CAAAe,aAAA,GAAG,SAAS;;AAEtC;AACO,MAAMC,OAAO,GAAAhB,OAAA,CAAAgB,OAAA,GAAG;EACrB;EACAC,OAAO,EAAE,SAAS;EAClBC,WAAW,EAAE,YAAY;EAEzB;EACAC,iBAAiB,EAAE,iBAAiB;EACpCC,wBAAwB,EAAE,uBAAuB;EACjDC,yBAAyB,EAAE,wBAAwB;EAEnD;EACAC,GAAG,EAAE,KAAK;EACVC,SAAS,EAAE,UAAU;EACrBC,gBAAgB,EAAE,gBAAgB;EAClCC,cAAc,EAAE,eAAe;EAC/BC,UAAU,EAAE,WAAW;EACvBC,UAAU,EAAE,WAAW;EACvBC,UAAU,EAAE,WAAW;EAEvB;EACAC,eAAe,EAAE,eAAe;EAChCC,KAAK,EAAE,OAAO;EACdC,sBAAsB,EAAE,sBAAsB;EAC9CC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE,SAAS;EAClBC,2BAA2B,EAAE,yBAAyB;EAEtD;EACAC,qBAAqB,EAAE,qBAAqB;EAC5CC,yBAAyB,EAAE,yBAAyB;EACpDC,yBAAyB,EAAE,sBAAsB;EACjDC,6BAA6B,EAAE,2BAA2B;EAC1DC,qBAAqB,EAAE,qBAAqB;EAC5CC,sBAAsB,EAAE,sBAAsB;EAC9CC,mBAAmB,EAAE,mBAAmB;EACxCC,OAAO,EAAE,QAAQ;EACjBC,mBAAmB,EAAE,mBAAmB;EACxCC,eAAe,EAAE;AACnB,CAAC"}
|
|
@@ -169,10 +169,6 @@ class WebSocketManager extends _events.default {
|
|
|
169
169
|
issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';
|
|
170
170
|
} else {
|
|
171
171
|
const onlineStatus = navigator.onLine;
|
|
172
|
-
_loggerProxy.default.info(`[WebSocketStatus] | desktop online status is ${onlineStatus}`, {
|
|
173
|
-
module: _constants3.WEB_SOCKET_MANAGER_FILE,
|
|
174
|
-
method: _constants2.METHODS.WEB_SOCKET_ON_CLOSE_HANDLER
|
|
175
|
-
});
|
|
176
172
|
issueReason = !onlineStatus ? 'network issue' : 'missing keepalive from either desktop or notif service';
|
|
177
173
|
}
|
|
178
174
|
_loggerProxy.default.error(`[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","obj","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","connectionConfig","body","register","Promise","resolve","reject","connect","catch","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","subscribeResponse","request","service","WCC_API_GATEWAY","resource","SUBSCRIBE_API","HTTP_METHODS","POST","webSocketUrl","e","REGISTER","undefined","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","info","WEB_SOCKET_ON_CLOSE_HANDLER","exports"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {SUBSCRIBE_API, WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {KEEPALIVE_WORKER_INTERVAL, CLOSE_SOCKET_TIMEOUT, METHODS} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {body: SubscribeRequest}): Promise<WelcomeResponse> {\n const connectionConfig = options.body;\n await this.register(connectionConfig);\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest) {\n try {\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource: SUBSCRIBE_API,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n });\n this.url = subscribeResponse.body.webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n LoggerProxy.info(`[WebSocketStatus] | desktop online status is ${onlineStatus}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER,\n });\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,U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KAAK,mBAAmB,EAAE;UAC1C,IAAI,CAACqB,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;UAC/BN,oBAAW,CAACD,KAAK,CACf,6FAA6F,EAC7F;YAACE,MAAM,EAAEC,mCAAuB;YAAEC,MAAM,EAAEC,mBAAO,CAACqB;UAAO,CAC3D,CAAC;QACH;MACF,CAAC;IACH,CAAC,CAAC;EACJ;;EAEA;EACA,MAAcgB,uBAAuBA,CAAC7B,KAAU,EAAE;IAChD,IAAI,CAAClC,cAAc,GAAG,IAAI;IAC1B,IAAI,CAACQ,eAAe,CAACsB,WAAW,CAAC;MAACvB,IAAI,EAAE;IAAW,CAAC,CAAC;IACrD,IAAI,IAAI,CAACT,eAAe,EAAE;MACxB,IAAI,CAACkE,IAAI,CAAC,aAAa,CAAC;MACxB,IAAIK,WAAW;MACf,IAAI,IAAI,CAACnE,4BAA4B,EAAE;QACrCmE,WAAW,GAAG,8DAA8D;MAC9E,CAAC,MAAM;QACL,MAAMC,YAAY,GAAGC,SAAS,CAACC,MAAM;QACrClD,oBAAW,CAACmD,IAAI,CAAE,gDAA+CH,YAAa,EAAC,EAAE;UAC/E/C,MAAM,EAAEC,mCAAuB;UAC/BC,MAAM,EAAEC,mBAAO,CAACgD;QAClB,CAAC,CAAC;QACFL,WAAW,GAAG,CAACC,YAAY,GACvB,eAAe,GACf,wDAAwD;MAC9D;MACAhD,oBAAW,CAACD,KAAK,CACd,kFAAiFgD,WAAY,EAAC,EAC/F;QAAC9C,MAAM,EAAEC,mCAAuB;QAAEC,MAAM,EAAEC,mBAAO,CAACgD;MAA2B,CAC/E,CAAC;MACD,IAAI,CAACxE,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAACyE,OAAA,CAAApF,gBAAA,GAAAA,gBAAA"}
|
|
1
|
+
{"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","obj","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","connectionConfig","body","register","Promise","resolve","reject","connect","catch","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","subscribeResponse","request","service","WCC_API_GATEWAY","resource","SUBSCRIBE_API","HTTP_METHODS","POST","webSocketUrl","e","REGISTER","undefined","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","WEB_SOCKET_ON_CLOSE_HANDLER","exports"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {SUBSCRIBE_API, WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {KEEPALIVE_WORKER_INTERVAL, CLOSE_SOCKET_TIMEOUT, METHODS} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {body: SubscribeRequest}): Promise<WelcomeResponse> {\n const connectionConfig = options.body;\n await this.register(connectionConfig);\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest) {\n try {\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource: SUBSCRIBE_API,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n });\n this.url = subscribeResponse.body.webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n issueReason = !onlineStatus\n ? 'network issue'\n : 'missing keepalive from either desktop or notif service';\n }\n LoggerProxy.error(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER}\n );\n this.forceCloseWebSocketOnTimeout = false;\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA2D,SAAAD,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,SAASC,eAAY,CAAC;EAKzCC,GAAG,GAAkB,IAAI;EAIzBC,qBAAqB,GAElB,IA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