@webex/contact-center 3.9.0 → 3.10.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/cc.js +196 -47
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +1 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger-proxy.js +24 -1
  8. package/dist/logger-proxy.js.map +1 -1
  9. package/dist/metrics/MetricsManager.js +1 -1
  10. package/dist/metrics/MetricsManager.js.map +1 -1
  11. package/dist/metrics/behavioral-events.js +89 -0
  12. package/dist/metrics/behavioral-events.js.map +1 -1
  13. package/dist/metrics/constants.js +32 -2
  14. package/dist/metrics/constants.js.map +1 -1
  15. package/dist/services/AddressBook.js +271 -0
  16. package/dist/services/AddressBook.js.map +1 -0
  17. package/dist/services/EntryPoint.js +227 -0
  18. package/dist/services/EntryPoint.js.map +1 -0
  19. package/dist/services/Queue.js +261 -0
  20. package/dist/services/Queue.js.map +1 -0
  21. package/dist/services/config/constants.js +36 -2
  22. package/dist/services/config/constants.js.map +1 -1
  23. package/dist/services/config/index.js +29 -21
  24. package/dist/services/config/index.js.map +1 -1
  25. package/dist/services/config/types.js +33 -1
  26. package/dist/services/config/types.js.map +1 -1
  27. package/dist/services/core/GlobalTypes.js.map +1 -1
  28. package/dist/services/core/Utils.js +162 -2
  29. package/dist/services/core/Utils.js.map +1 -1
  30. package/dist/services/core/aqm-reqs.js +0 -4
  31. package/dist/services/core/aqm-reqs.js.map +1 -1
  32. package/dist/services/core/websocket/WebSocketManager.js +0 -4
  33. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  34. package/dist/services/task/TaskManager.js +114 -3
  35. package/dist/services/task/TaskManager.js.map +1 -1
  36. package/dist/services/task/TaskUtils.js +76 -0
  37. package/dist/services/task/TaskUtils.js.map +1 -0
  38. package/dist/services/task/constants.js +26 -1
  39. package/dist/services/task/constants.js.map +1 -1
  40. package/dist/services/task/contact.js +86 -0
  41. package/dist/services/task/contact.js.map +1 -1
  42. package/dist/services/task/index.js +418 -87
  43. package/dist/services/task/index.js.map +1 -1
  44. package/dist/services/task/types.js +14 -0
  45. package/dist/services/task/types.js.map +1 -1
  46. package/dist/types/cc.d.ts +115 -35
  47. package/dist/types/constants.d.ts +1 -0
  48. package/dist/types/index.d.ts +3 -2
  49. package/dist/types/metrics/constants.d.ts +25 -1
  50. package/dist/types/services/AddressBook.d.ts +74 -0
  51. package/dist/types/services/EntryPoint.d.ts +67 -0
  52. package/dist/types/services/Queue.d.ts +76 -0
  53. package/dist/types/services/config/constants.d.ts +35 -1
  54. package/dist/types/services/config/index.d.ts +6 -9
  55. package/dist/types/services/config/types.d.ts +79 -58
  56. package/dist/types/services/core/GlobalTypes.d.ts +25 -0
  57. package/dist/types/services/core/Utils.d.ts +40 -1
  58. package/dist/types/services/task/TaskUtils.d.ts +28 -0
  59. package/dist/types/services/task/constants.d.ts +23 -0
  60. package/dist/types/services/task/contact.d.ts +10 -0
  61. package/dist/types/services/task/index.d.ts +85 -4
  62. package/dist/types/services/task/types.d.ts +233 -21
  63. package/dist/types/types.d.ts +162 -0
  64. package/dist/types/utils/PageCache.d.ts +173 -0
  65. package/dist/types.js +17 -0
  66. package/dist/types.js.map +1 -1
  67. package/dist/utils/PageCache.js +192 -0
  68. package/dist/utils/PageCache.js.map +1 -0
  69. package/dist/webex.js +1 -1
  70. package/package.json +10 -9
  71. package/src/cc.ts +221 -52
  72. package/src/constants.ts +1 -0
  73. package/src/index.ts +16 -2
  74. package/src/logger-proxy.ts +24 -1
  75. package/src/metrics/MetricsManager.ts +1 -1
  76. package/src/metrics/behavioral-events.ts +94 -0
  77. package/src/metrics/constants.ts +37 -1
  78. package/src/services/AddressBook.ts +291 -0
  79. package/src/services/EntryPoint.ts +241 -0
  80. package/src/services/Queue.ts +277 -0
  81. package/src/services/config/constants.ts +42 -2
  82. package/src/services/config/index.ts +30 -30
  83. package/src/services/config/types.ts +59 -58
  84. package/src/services/core/GlobalTypes.ts +27 -0
  85. package/src/services/core/Utils.ts +199 -1
  86. package/src/services/core/aqm-reqs.ts +0 -5
  87. package/src/services/core/websocket/WebSocketManager.ts +0 -4
  88. package/src/services/task/TaskManager.ts +123 -5
  89. package/src/services/task/TaskUtils.ts +81 -0
  90. package/src/services/task/constants.ts +25 -0
  91. package/src/services/task/contact.ts +80 -0
  92. package/src/services/task/index.ts +510 -71
  93. package/src/services/task/types.ts +251 -20
  94. package/src/types.ts +180 -0
  95. package/src/utils/PageCache.ts +252 -0
  96. package/test/unit/spec/cc.ts +282 -85
  97. package/test/unit/spec/metrics/MetricsManager.ts +0 -1
  98. package/test/unit/spec/metrics/behavioral-events.ts +42 -0
  99. package/test/unit/spec/services/AddressBook.ts +332 -0
  100. package/test/unit/spec/services/EntryPoint.ts +259 -0
  101. package/test/unit/spec/services/Queue.ts +323 -0
  102. package/test/unit/spec/services/config/index.ts +279 -65
  103. package/test/unit/spec/services/core/Utils.ts +50 -0
  104. package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
  105. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
  106. package/test/unit/spec/services/task/TaskManager.ts +390 -1
  107. package/test/unit/spec/services/task/TaskUtils.ts +131 -0
  108. package/test/unit/spec/services/task/contact.ts +31 -1
  109. package/test/unit/spec/services/task/index.ts +585 -130
  110. package/umd/contact-center.min.js +2 -2
  111. package/umd/contact-center.min.js.map +1 -1
@@ -3,11 +3,12 @@
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.getDestinationAgentId = exports.generateTaskErrorObject = exports.deriveConsultTransferDestinationType = exports.createErrDetailsObject = exports.buildConsultConferenceParamData = 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");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  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
14
  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 +26,28 @@ const getCommonErrorDetails = errObj => {
25
26
  msg: errObj?.body
26
27
  };
27
28
  };
29
+
30
+ /**
31
+ * Checks if the destination type represents an entry point variant (EPDN or ENTRYPOINT).
32
+ */
33
+ const isEntryPointOrEpdn = destAgentType => {
34
+ return destAgentType === 'EPDN' || destAgentType === 'ENTRYPOINT';
35
+ };
36
+
37
+ /**
38
+ * Determines if the task involves dialing a number based on the destination type.
39
+ * Returns 'DIAL_NUMBER' for dial-related destinations, empty string otherwise.
40
+ */
41
+ const getAgentActionTypeFromTask = taskData => {
42
+ const destAgentType = taskData?.destinationType;
43
+
44
+ // Check if destination requires dialing: direct dial number or entry point variants
45
+ const isDialNumber = destAgentType === 'DN';
46
+ const isEntryPointVariant = isEntryPointOrEpdn(destAgentType);
47
+
48
+ // If the destination type is a dial number or an entry point variant, return 'DIAL_NUMBER'
49
+ return isDialNumber || isEntryPointVariant ? 'DIAL_NUMBER' : '';
50
+ };
28
51
  const isValidDialNumber = input => {
29
52
  // This regex checks for a valid dial number format for only few countries such as US, Canada.
30
53
  const regexForDn = /1[0-9]{3}[2-9][0-9]{6}([,]{1,10}[0-9]+){0,1}/;
@@ -107,6 +130,51 @@ const getErrorDetails = (error, methodName, moduleName) => {
107
130
  };
108
131
  };
109
132
 
133
+ /**
134
+ * Extracts error details from task API errors and logs them. Also uploads logs for the error.
135
+ * This handles the specific error format returned by task API calls.
136
+ *
137
+ * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}
138
+ * @param methodName - The name of the method where the error occurred.
139
+ * @param moduleName - The name of the module where the error occurred.
140
+ * @returns AugmentedError containing structured error details on err.data for metrics and logging
141
+ * @public
142
+ * @example
143
+ * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');
144
+ * throw taskError.error;
145
+ * @ignore
146
+ */
147
+ exports.getErrorDetails = getErrorDetails;
148
+ const generateTaskErrorObject = (error, methodName, moduleName) => {
149
+ const trackingId = error?.details?.trackingId || error?.trackingId || '';
150
+ const errorMsg = error?.details?.msg;
151
+ const fallbackMessage = error && typeof error.message === 'string' && error.message || `Error while performing ${methodName}`;
152
+ const errorMessage = errorMsg?.errorMessage || fallbackMessage;
153
+ const errorType = errorMsg?.errorType || error && typeof error.name === 'string' && error.name || 'Unknown Error';
154
+ const errorData = errorMsg?.errorData || '';
155
+ const reasonCode = errorMsg?.reasonCode || 0;
156
+
157
+ // Log and upload for Task API formatted errors
158
+ _loggerProxy.default.error(`${methodName} failed: ${errorMessage} (${errorType})`, {
159
+ module: moduleName,
160
+ method: methodName,
161
+ trackingId
162
+ });
163
+ _WebexRequest.default.getInstance().uploadLogs({
164
+ correlationId: trackingId
165
+ });
166
+ const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;
167
+ const err = new Error(reason);
168
+ err.data = {
169
+ message: errorMessage,
170
+ errorType,
171
+ errorData,
172
+ reasonCode,
173
+ trackingId
174
+ };
175
+ return err;
176
+ };
177
+
110
178
  /**
111
179
  * Creates an error details object suitable for use with the Err.Details class.
112
180
  *
@@ -117,10 +185,102 @@ const getErrorDetails = (error, methodName, moduleName) => {
117
185
  * const errDetails = createErrDetailsObject(webexRequestPayload);
118
186
  * @ignore
119
187
  */
120
- exports.getErrorDetails = getErrorDetails;
188
+ exports.generateTaskErrorObject = generateTaskErrorObject;
121
189
  const createErrDetailsObject = errObj => {
122
190
  const details = getCommonErrorDetails(errObj);
123
191
  return new Err.Details('Service.reqs.generic.failure', details);
124
192
  };
193
+
194
+ /**
195
+ * Derives the consult transfer destination type based on the provided task data.
196
+ *
197
+ * Logic parity with desktop behavior:
198
+ * - If agent action is dialing a number (DN/EPDN/ENTRYPOINT):
199
+ * - ENTRYPOINT/EPDN map to ENTRYPOINT
200
+ * - DN maps to DIALNUMBER
201
+ * - Otherwise defaults to AGENT
202
+ *
203
+ * @param taskData - The task data used to infer the agent action and destination type
204
+ * @returns The normalized destination type to be used for consult transfer
205
+ */
206
+ /**
207
+ * Checks if a participant type represents a non-customer participant.
208
+ * Non-customer participants include agents, dial numbers, entry point dial numbers,
209
+ * and entry points.
210
+ */
125
211
  exports.createErrDetailsObject = createErrDetailsObject;
212
+ const isNonCustomerParticipant = participantType => {
213
+ return participantType === 'Agent' || participantType === 'DN' || participantType === 'EpDn' || participantType === 'entryPoint';
214
+ };
215
+
216
+ /**
217
+ * Gets the destination agent ID from participants data by finding the first
218
+ * non-customer participant that is not the current agent and is not in wrap-up state.
219
+ *
220
+ * @param participants - The participants data from the interaction
221
+ * @param agentId - The current agent's ID to exclude from the search
222
+ * @returns The destination agent ID, or empty string if none found
223
+ */
224
+ const getDestinationAgentId = (participants, agentId) => {
225
+ let id = '';
226
+ if (participants) {
227
+ Object.keys(participants).forEach(participant => {
228
+ const participantData = participants[participant];
229
+ if (isNonCustomerParticipant(participantData.type) && participantData.id !== agentId && !participantData.isWrapUp) {
230
+ id = participantData.id;
231
+ }
232
+ });
233
+ }
234
+ return id;
235
+ };
236
+ exports.getDestinationAgentId = getDestinationAgentId;
237
+ const deriveConsultTransferDestinationType = taskData => {
238
+ const agentActionType = getAgentActionTypeFromTask(taskData);
239
+ if (agentActionType === 'DIAL_NUMBER') {
240
+ return isEntryPointOrEpdn(taskData?.destinationType) ? _types2.CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT : _types2.CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
241
+ }
242
+ return _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
243
+ };
244
+
245
+ /**
246
+ * Builds consult conference parameter data using EXACT Agent Desktop logic.
247
+ * This matches the Agent Desktop's consultConference implementation exactly.
248
+ *
249
+ * @param dataPassed - Original consultation data from Agent Desktop format
250
+ * @param interactionIdPassed - The interaction ID for the task
251
+ * @returns Object with interactionId and ConsultConferenceData matching Agent Desktop format
252
+ * @public
253
+ */
254
+ exports.deriveConsultTransferDestinationType = deriveConsultTransferDestinationType;
255
+ const buildConsultConferenceParamData = (dataPassed, interactionIdPassed) => {
256
+ const data = {
257
+ // Include agentId if present in input data
258
+ ...('agentId' in dataPassed && {
259
+ agentId: dataPassed.agentId
260
+ }),
261
+ // Handle destAgentId from consultation data
262
+ to: dataPassed.destAgentId,
263
+ destinationType: ''
264
+ };
265
+
266
+ // Agent Desktop destination type logic
267
+ if ('destinationType' in dataPassed) {
268
+ if (dataPassed.destinationType === 'DN') {
269
+ data.destinationType = _types2.CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;
270
+ } else if (dataPassed.destinationType === 'EP_DN') {
271
+ data.destinationType = _types2.CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;
272
+ } else {
273
+ // Keep the existing destinationType if it's something else (like "agent" or "Agent")
274
+ // Convert "Agent" to lowercase for consistency
275
+ data.destinationType = dataPassed.destinationType.toLowerCase();
276
+ }
277
+ } else {
278
+ data.destinationType = _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;
279
+ }
280
+ return {
281
+ interactionId: interactionIdPassed,
282
+ data
283
+ };
284
+ };
285
+ exports.buildConsultConferenceParamData = buildConsultConferenceParamData;
126
286
  //# 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,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAE,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,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,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E3B,OAAO,EAAEZ;IAC1B,CAAC,CAAC;EACJ;EAEA,IAAI6B,UAAU,KAAK,cAAc,EAAE;IACjCE,OAAO,GAAGpB,wBAAwB,CAACC,OAAO,EAAEgB,KAAK,CAACf,WAAW,CAAC;IAE9DoB,oBAAW,CAACL,KAAK,CACd,GAAEC,UAAW,wBAAuBJ,MAAO,cAAaM,OAAO,CAACX,OAAQ,gBAAeW,OAAO,CAACV,SAAU,EAAC,EAC3G;MACEa,MAAM,EAAEJ,UAAU;MAClBK,MAAM,EAAEN,UAAU;MAClB7B,UAAU,EAAEY,OAAO,EAAEZ;IACvB,CACF,CAAC;EACH;EAEA,MAAMwC,GAAG,GAAG,IAAIC,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","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","buildConsultConferenceParamData","dataPassed","interactionIdPassed","to","destAgentId","toLowerCase","interactionId"],"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 ConsultConferenceData,\n consultConferencePayloadData,\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\n/**\n * Builds consult conference parameter data using EXACT Agent Desktop logic.\n * This matches the Agent Desktop's consultConference implementation exactly.\n *\n * @param dataPassed - Original consultation data from Agent Desktop format\n * @param interactionIdPassed - The interaction ID for the task\n * @returns Object with interactionId and ConsultConferenceData matching Agent Desktop format\n * @public\n */\nexport const buildConsultConferenceParamData = (\n dataPassed: consultConferencePayloadData,\n interactionIdPassed: string\n): {interactionId: string; data: ConsultConferenceData} => {\n const data: ConsultConferenceData = {\n // Include agentId if present in input data\n ...('agentId' in dataPassed && {agentId: dataPassed.agentId}),\n // Handle destAgentId from consultation data\n to: dataPassed.destAgentId,\n destinationType: '',\n };\n\n // Agent Desktop destination type logic\n if ('destinationType' in dataPassed) {\n if (dataPassed.destinationType === 'DN') {\n data.destinationType = CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n } else if (dataPassed.destinationType === 'EP_DN') {\n data.destinationType = CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n } else {\n // Keep the existing destinationType if it's something else (like \"agent\" or \"Agent\")\n // Convert \"Agent\" to lowercase for consistency\n data.destinationType = dataPassed.destinationType.toLowerCase();\n }\n } else {\n data.destinationType = CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n }\n\n return {\n interactionId: interactionIdPassed,\n data,\n };\n};\n"],"mappings":";;;;;;AAAA,IA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AAI,SAAS,IAAI6C,UAAU,IAAI;MAACf,OAAO,EAAEe,UAAU,CAACf;IAAO,CAAC,CAAC;IAC7D;IACAiB,EAAE,EAAEF,UAAU,CAACG,WAAW;IAC1BvE,eAAe,EAAE;EACnB,CAAC;;EAED;EACA,IAAI,iBAAiB,IAAIoE,UAAU,EAAE;IACnC,IAAIA,UAAU,CAACpE,eAAe,KAAK,IAAI,EAAE;MACvCuB,IAAI,CAACvB,eAAe,GAAG+D,yCAAiC,CAACE,UAAU;IACrE,CAAC,MAAM,IAAIG,UAAU,CAACpE,eAAe,KAAK,OAAO,EAAE;MACjDuB,IAAI,CAACvB,eAAe,GAAG+D,yCAAiC,CAACC,UAAU;IACrE,CAAC,MAAM;MACL;MACA;MACAzC,IAAI,CAACvB,eAAe,GAAGoE,UAAU,CAACpE,eAAe,CAACwE,WAAW,CAAC,CAAC;IACjE;EACF,CAAC,MAAM;IACLjD,IAAI,CAACvB,eAAe,GAAG+D,yCAAiC,CAACG,KAAK;EAChE;EAEA,OAAO;IACLO,aAAa,EAAEJ,mBAAmB;IAClC9C;EACF,CAAC;AACH,CAAC;AAAChB,OAAA,CAAA4D,+BAAA,GAAAA,+BAAA"}
@@ -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 });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,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BpE,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,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CA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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"}
@@ -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,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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c,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,IAAI;EAIfC,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC,CAAC;IACP,MAAM;MAACC;IAAK,CAAC,GAAGD,OAAO;IACvB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B,IAAI,CAACC,SAAS,GAAG,CAAC,CAAc;IAChC,IAAI,CAACC,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B,IAAI,CAACC,4BAA4B,GA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,EAC/F;QAAC9C,MAAM,EAAEC,mCAAuB;QAAEC,MAAM,EAAEC,mBAAO,CAAC+C;MAA2B,CAC/E,CAAC;MACD,IAAI,CAACvE,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAACwE,OAAA,CAAAnF,gBAAA,GAAAA,gBAAA"}
@@ -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,8 @@ 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?.[payload.data.agentId]?.isWrapUp || false
98
- }, this.wrapupData);
110
+ wrapUpRequired: payload.data.interaction?.participants?.[this.agentId]?.isWrapUp || false
111
+ }, this.wrapupData, this.agentId);
99
112
  this.taskCollection[payload.data.interactionId] = task;
100
113
  // Condition 1: The state is=new i.e it is a incoming task
101
114
  if (payload.data.interaction.state === 'new') {
@@ -120,7 +133,7 @@ class TaskManager extends _events.default {
120
133
  task = new _.default(this.contact, this.webCallingService, {
121
134
  ...payload.data,
122
135
  isConsulted: false
123
- }, this.wrapupData); // Ensure isConsulted prop exists
136
+ }, this.wrapupData, this.agentId);
124
137
  this.taskCollection[payload.data.interactionId] = task;
125
138
  if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels
126
139
  ) {
@@ -229,6 +242,7 @@ class TaskManager extends _events.default {
229
242
  break;
230
243
  case _types2.CC_EVENTS.AGENT_CONSULTING:
231
244
  // Received when agent is in an active consult state
245
+ // TODO: Check if we can use backend consult state instead of isConsulted
232
246
  task = this.updateTaskData(task, payload.data);
233
247
  if (task.data.isConsulted) {
234
248
  // Fire only if you are the agent who received the consult request
@@ -285,6 +299,103 @@ class TaskManager extends _events.default {
285
299
  task = this.updateTaskData(task, payload.data);
286
300
  task.emit(_types.TASK_EVENTS.TASK_RECORDING_RESUME_FAILED, task);
287
301
  break;
302
+ case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCING:
303
+ // Conference is being established - update task state and emit establishing event
304
+ task = this.updateTaskData(task, payload.data);
305
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_ESTABLISHING, task);
306
+ break;
307
+ case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCED:
308
+ // Conference started successfully - update task state and emit event
309
+ task = this.updateTaskData(task, payload.data);
310
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_STARTED, task);
311
+ break;
312
+ case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_FAILED:
313
+ // Conference failed - update task state and emit failure event
314
+ task = this.updateTaskData(task, payload.data);
315
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_FAILED, task);
316
+ break;
317
+ case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_ENDED:
318
+ // Conference ended - update task state and emit event
319
+ task = this.updateTaskData(task, payload.data);
320
+ if (!task || (0, _TaskUtils.isPrimary)(task, this.agentId) || (0, _TaskUtils.isParticipantInMainInteraction)(task, this.agentId)) {
321
+ _loggerProxy.default.log('Primary or main interaction participant leaving conference');
322
+ } else {
323
+ this.removeTaskFromCollection(task);
324
+ }
325
+ task?.emit(_types.TASK_EVENTS.TASK_CONFERENCE_ENDED, task);
326
+ break;
327
+ case _types2.CC_EVENTS.PARTICIPANT_JOINED_CONFERENCE:
328
+ {
329
+ // Participant joined conference - update task state with participant information and emit event
330
+ // Pre-calculate isConferenceInProgress with updated data to avoid double update
331
+ const simulatedTaskForJoin = {
332
+ ...task,
333
+ data: {
334
+ ...task.data,
335
+ ...payload.data
336
+ }
337
+ };
338
+ task = this.updateTaskData(task, {
339
+ ...payload.data,
340
+ isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(simulatedTaskForJoin)
341
+ });
342
+ task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_JOINED, task);
343
+ break;
344
+ }
345
+ case _types2.CC_EVENTS.PARTICIPANT_LEFT_CONFERENCE:
346
+ {
347
+ // Conference ended - update task state and emit event
348
+ // Pre-calculate isConferenceInProgress with updated data to avoid double update
349
+ const simulatedTaskForLeft = {
350
+ ...task,
351
+ data: {
352
+ ...task.data,
353
+ ...payload.data
354
+ }
355
+ };
356
+ task = this.updateTaskData(task, {
357
+ ...payload.data,
358
+ isConferenceInProgress: (0, _TaskUtils.getIsConferenceInProgress)(simulatedTaskForLeft)
359
+ });
360
+ if ((0, _TaskUtils.checkParticipantNotInInteraction)(task, this.agentId)) {
361
+ if ((0, _TaskUtils.isParticipantInMainInteraction)(task, this.agentId) || (0, _TaskUtils.isPrimary)(task, this.agentId)) {
362
+ _loggerProxy.default.log('Primary or main interaction participant leaving conference');
363
+ } else {
364
+ this.removeTaskFromCollection(task);
365
+ }
366
+ }
367
+ task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_LEFT, task);
368
+ break;
369
+ }
370
+ case _types2.CC_EVENTS.PARTICIPANT_LEFT_CONFERENCE_FAILED:
371
+ // Conference exit failed - update task state and emit failure event
372
+ task = this.updateTaskData(task, payload.data);
373
+ task.emit(_types.TASK_EVENTS.TASK_PARTICIPANT_LEFT_FAILED, task);
374
+ break;
375
+ case _types2.CC_EVENTS.AGENT_CONSULT_CONFERENCE_END_FAILED:
376
+ // Conference end failed - update task state with error details and emit failure event
377
+ task = this.updateTaskData(task, payload.data);
378
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_END_FAILED, task);
379
+ break;
380
+ case _types2.CC_EVENTS.AGENT_CONFERENCE_TRANSFERRED:
381
+ // Conference was transferred - update task state and emit transfer success event
382
+ // Note: Backend should provide hasLeft and wrapUpRequired status
383
+ task = this.updateTaskData(task, payload.data);
384
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_TRANSFERRED, task);
385
+ break;
386
+ case _types2.CC_EVENTS.AGENT_CONFERENCE_TRANSFER_FAILED:
387
+ // Conference transfer failed - update task state with error details and emit failure event
388
+ task = this.updateTaskData(task, payload.data);
389
+ task.emit(_types.TASK_EVENTS.TASK_CONFERENCE_TRANSFER_FAILED, task);
390
+ break;
391
+ case _types2.CC_EVENTS.CONSULTED_PARTICIPANT_MOVING:
392
+ // Participant is being moved/transferred - update task state with movement info
393
+ task = this.updateTaskData(task, payload.data);
394
+ break;
395
+ case _types2.CC_EVENTS.PARTICIPANT_POST_CALL_ACTIVITY:
396
+ // Post-call activity for participant - update task state with activity details
397
+ task = this.updateTaskData(task, payload.data);
398
+ break;
288
399
  default:
289
400
  break;
290
401
  }