@webex/contact-center 3.10.0 → 3.11.0

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 (139) hide show
  1. package/dist/cc.js +42 -31
  2. package/dist/cc.js.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +17 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger-proxy.js.map +1 -1
  8. package/dist/metrics/MetricsManager.js +2 -1
  9. package/dist/metrics/MetricsManager.js.map +1 -1
  10. package/dist/metrics/behavioral-events.js +12 -0
  11. package/dist/metrics/behavioral-events.js.map +1 -1
  12. package/dist/metrics/constants.js +4 -0
  13. package/dist/metrics/constants.js.map +1 -1
  14. package/dist/services/AddressBook.js +2 -3
  15. package/dist/services/AddressBook.js.map +1 -1
  16. package/dist/services/EntryPoint.js +2 -3
  17. package/dist/services/EntryPoint.js.map +1 -1
  18. package/dist/services/Queue.js +2 -3
  19. package/dist/services/Queue.js.map +1 -1
  20. package/dist/services/WebCallingService.js +1 -1
  21. package/dist/services/WebCallingService.js.map +1 -1
  22. package/dist/services/agent/index.js +1 -2
  23. package/dist/services/agent/index.js.map +1 -1
  24. package/dist/services/agent/types.js +10 -0
  25. package/dist/services/agent/types.js.map +1 -1
  26. package/dist/services/config/Util.js.map +1 -1
  27. package/dist/services/config/constants.js.map +1 -1
  28. package/dist/services/config/index.js +1 -1
  29. package/dist/services/config/index.js.map +1 -1
  30. package/dist/services/config/types.js +2 -2
  31. package/dist/services/config/types.js.map +1 -1
  32. package/dist/services/constants.js.map +1 -1
  33. package/dist/services/core/Err.js.map +1 -1
  34. package/dist/services/core/GlobalTypes.js.map +1 -1
  35. package/dist/services/core/Utils.js +92 -74
  36. package/dist/services/core/Utils.js.map +1 -1
  37. package/dist/services/core/WebexRequest.js +1 -2
  38. package/dist/services/core/WebexRequest.js.map +1 -1
  39. package/dist/services/core/aqm-reqs.js +2 -3
  40. package/dist/services/core/aqm-reqs.js.map +1 -1
  41. package/dist/services/core/constants.js +17 -1
  42. package/dist/services/core/constants.js.map +1 -1
  43. package/dist/services/core/types.js.map +1 -1
  44. package/dist/services/core/websocket/WebSocketManager.js +11 -3
  45. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  46. package/dist/services/core/websocket/connection-service.js +1 -1
  47. package/dist/services/core/websocket/connection-service.js.map +1 -1
  48. package/dist/services/core/websocket/keepalive.worker.js.map +1 -1
  49. package/dist/services/core/websocket/types.js.map +1 -1
  50. package/dist/services/index.js +1 -1
  51. package/dist/services/index.js.map +1 -1
  52. package/dist/services/task/AutoWrapup.js +1 -1
  53. package/dist/services/task/AutoWrapup.js.map +1 -1
  54. package/dist/services/task/TaskManager.js +177 -56
  55. package/dist/services/task/TaskManager.js.map +1 -1
  56. package/dist/services/task/TaskUtils.js +122 -5
  57. package/dist/services/task/TaskUtils.js.map +1 -1
  58. package/dist/services/task/constants.js +3 -1
  59. package/dist/services/task/constants.js.map +1 -1
  60. package/dist/services/task/contact.js +0 -2
  61. package/dist/services/task/contact.js.map +1 -1
  62. package/dist/services/task/dialer.js.map +1 -1
  63. package/dist/services/task/index.js +78 -51
  64. package/dist/services/task/index.js.map +1 -1
  65. package/dist/services/task/types.js +377 -4
  66. package/dist/services/task/types.js.map +1 -1
  67. package/dist/types.js +5 -0
  68. package/dist/types.js.map +1 -1
  69. package/dist/utils/PageCache.js +1 -1
  70. package/dist/utils/PageCache.js.map +1 -1
  71. package/dist/webex-config.js.map +1 -1
  72. package/dist/webex.js +2 -2
  73. package/dist/webex.js.map +1 -1
  74. package/package.json +9 -9
  75. package/src/cc.ts +50 -41
  76. package/src/index.ts +1 -0
  77. package/src/metrics/behavioral-events.ts +12 -0
  78. package/src/metrics/constants.ts +4 -0
  79. package/src/services/config/types.ts +2 -2
  80. package/src/services/core/Utils.ts +101 -85
  81. package/src/services/core/constants.ts +16 -0
  82. package/src/services/core/websocket/WebSocketManager.ts +10 -1
  83. package/src/services/task/TaskManager.ts +204 -36
  84. package/src/services/task/TaskUtils.ts +145 -5
  85. package/src/services/task/constants.ts +2 -0
  86. package/src/services/task/index.ts +88 -74
  87. package/src/services/task/types.ts +72 -15
  88. package/test/unit/spec/cc.ts +1 -0
  89. package/test/unit/spec/metrics/behavioral-events.ts +14 -0
  90. package/test/unit/spec/services/core/Utils.ts +262 -31
  91. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +20 -0
  92. package/test/unit/spec/services/task/TaskManager.ts +748 -5
  93. package/test/unit/spec/services/task/TaskUtils.ts +311 -9
  94. package/test/unit/spec/services/task/index.ts +440 -68
  95. package/umd/contact-center.min.js +2 -2
  96. package/umd/contact-center.min.js.map +1 -1
  97. package/dist/types/cc.d.ts +0 -756
  98. package/dist/types/config.d.ts +0 -66
  99. package/dist/types/constants.d.ts +0 -46
  100. package/dist/types/index.d.ts +0 -183
  101. package/dist/types/logger-proxy.d.ts +0 -71
  102. package/dist/types/metrics/MetricsManager.d.ts +0 -223
  103. package/dist/types/metrics/behavioral-events.d.ts +0 -29
  104. package/dist/types/metrics/constants.d.ts +0 -151
  105. package/dist/types/services/AddressBook.d.ts +0 -74
  106. package/dist/types/services/EntryPoint.d.ts +0 -67
  107. package/dist/types/services/Queue.d.ts +0 -76
  108. package/dist/types/services/WebCallingService.d.ts +0 -1
  109. package/dist/types/services/agent/index.d.ts +0 -46
  110. package/dist/types/services/agent/types.d.ts +0 -413
  111. package/dist/types/services/config/Util.d.ts +0 -19
  112. package/dist/types/services/config/constants.d.ts +0 -237
  113. package/dist/types/services/config/index.d.ts +0 -168
  114. package/dist/types/services/config/types.d.ts +0 -1134
  115. package/dist/types/services/constants.d.ts +0 -97
  116. package/dist/types/services/core/Err.d.ts +0 -119
  117. package/dist/types/services/core/GlobalTypes.d.ts +0 -58
  118. package/dist/types/services/core/Utils.d.ts +0 -75
  119. package/dist/types/services/core/WebexRequest.d.ts +0 -22
  120. package/dist/types/services/core/aqm-reqs.d.ts +0 -16
  121. package/dist/types/services/core/constants.d.ts +0 -85
  122. package/dist/types/services/core/types.d.ts +0 -47
  123. package/dist/types/services/core/websocket/WebSocketManager.d.ts +0 -34
  124. package/dist/types/services/core/websocket/connection-service.d.ts +0 -27
  125. package/dist/types/services/core/websocket/keepalive.worker.d.ts +0 -2
  126. package/dist/types/services/core/websocket/types.d.ts +0 -37
  127. package/dist/types/services/index.d.ts +0 -52
  128. package/dist/types/services/task/AutoWrapup.d.ts +0 -40
  129. package/dist/types/services/task/TaskManager.d.ts +0 -1
  130. package/dist/types/services/task/TaskUtils.d.ts +0 -28
  131. package/dist/types/services/task/constants.d.ts +0 -69
  132. package/dist/types/services/task/contact.d.ts +0 -69
  133. package/dist/types/services/task/dialer.d.ts +0 -28
  134. package/dist/types/services/task/index.d.ts +0 -632
  135. package/dist/types/services/task/types.d.ts +0 -1243
  136. package/dist/types/types.d.ts +0 -614
  137. package/dist/types/utils/PageCache.d.ts +0 -173
  138. package/dist/types/webex-config.d.ts +0 -53
  139. package/dist/types/webex.d.ts +0 -7
@@ -1,97 +0,0 @@
1
- /**
2
- * Post-authentication event name.
3
- * @type {string}
4
- * @public
5
- * @example
6
- * if (event === POST_AUTH) { ... }
7
- * @ignore
8
- */
9
- export declare const POST_AUTH = "postauth";
10
- /**
11
- * API gateway identifier for Webex Contact Center.
12
- * @type {string}
13
- * @public
14
- * @ignore
15
- */
16
- export declare const WCC_API_GATEWAY = "wcc-api-gateway";
17
- /**
18
- * Domain identifier for WCC Calling RTMS.
19
- * @type {string}
20
- * @public
21
- * @ignore
22
- */
23
- export declare const WCC_CALLING_RTMS_DOMAIN = "wcc-calling-rtms-domain";
24
- /**
25
- * Default RTMS domain for production use.
26
- * @type {string}
27
- * @public
28
- * @ignore
29
- */
30
- export declare const DEFAULT_RTMS_DOMAIN = "rtw.prod-us1.rtmsprod.net";
31
- /**
32
- * Timeout in milliseconds for WebSocket events.
33
- * @type {number}
34
- * @public
35
- * @example
36
- * setTimeout(() => { ... }, WEBSOCKET_EVENT_TIMEOUT);
37
- * @ignore
38
- */
39
- export declare const WEBSOCKET_EVENT_TIMEOUT = 20000;
40
- /**
41
- * Agent role identifier.
42
- * @type {string}
43
- * @public
44
- * @ignore
45
- */
46
- export declare const AGENT = "agent";
47
- /**
48
- * API path for notification subscription.
49
- * @type {string}
50
- * @public
51
- * @ignore
52
- */
53
- export declare const SUBSCRIBE_API = "v1/notification/subscribe";
54
- /**
55
- * API path for agent login.
56
- * @type {string}
57
- * @public
58
- * @ignore
59
- */
60
- export declare const LOGIN_API = "v1/agents/login";
61
- /**
62
- * Prefix for WebRTC-related API endpoints.
63
- * @type {string}
64
- * @public
65
- * @ignore
66
- */
67
- export declare const WEB_RTC_PREFIX = "webrtc-";
68
- /**
69
- * API path for agent session state changes.
70
- * @type {string}
71
- * @public
72
- * @ignore
73
- */
74
- export declare const STATE_CHANGE_API = "v1/agents/session/state";
75
- /**
76
- * Message for deregistering WebCalling line and cleaning up resources.
77
- * @type {string}
78
- * @public
79
- * @ignore
80
- */
81
- export declare const DEREGISTER_WEBCALLING_LINE_MSG = "Deregistering WebCalling line and cleaning up resources";
82
- export declare const METHODS: {
83
- SET_LOGIN_OPTION: string;
84
- HANDLE_MEDIA_EVENT: string;
85
- HANDLE_DISCONNECT_EVENT: string;
86
- REGISTER_CALL_LISTENERS: string;
87
- CLEAN_UP_CALL: string;
88
- GET_RTMS_DOMAIN: string;
89
- REGISTER_WEB_CALLING_LINE: string;
90
- DEREGISTER_WEB_CALLING_LINE: string;
91
- ANSWER_CALL: string;
92
- MUTE_UNMUTE_CALL: string;
93
- IS_CALL_MUTED: string;
94
- DECLINE_CALL: string;
95
- MAP_CALL_TO_TASK: string;
96
- GET_TASK_ID_FOR_CALL: string;
97
- };
@@ -1,119 +0,0 @@
1
- import { WebexRequestPayload } from '../../types';
2
- import { Failure } from './GlobalTypes';
3
- /**
4
- * Err module provides a structured way to handle errors in the Contact Center plugin.
5
- * @ignore
6
- */
7
- export type ErrDetails = {
8
- status: number;
9
- type: string;
10
- trackingId: string;
11
- };
12
- export type AgentErrorIds = {
13
- 'Service.aqm.agent.stationLogin': ErrDetails;
14
- } | {
15
- 'Service.aqm.agent.stationLoginFailed': Failure;
16
- } | {
17
- 'Service.aqm.agent.stateChange': Failure;
18
- } | {
19
- 'Service.aqm.agent.reload': Failure;
20
- } | {
21
- 'Service.aqm.agent.logout': Failure;
22
- } | {
23
- 'Service.reqs.generic.failure': {
24
- trackingId: string;
25
- };
26
- } | {
27
- 'Service.aqm.agent.BuddyAgentsRetrieveFailed': Failure;
28
- };
29
- export type vteamType = 'inboundqueue' | 'inboundentrypoint' | string;
30
- export type TaskErrorIds = {
31
- 'Service.aqm.task.accept': Failure;
32
- } | {
33
- 'Service.aqm.task.end': Failure;
34
- } | {
35
- 'Service.aqm.task.wrapup': Failure;
36
- } | {
37
- 'Service.aqm.task.AgentVteamTransferFailed': Failure;
38
- } | {
39
- 'Service.aqm.task.AgentBlindTransferFailedEvent': Failure;
40
- } | {
41
- 'Service.aqm.task.AgentConsultTransferFailed': Failure;
42
- } | {
43
- 'Service.aqm.task.consult': Failure;
44
- } | {
45
- 'Service.aqm.err.trackingId': {
46
- trackingId: string;
47
- };
48
- } | {
49
- 'Service.aqm.task.consultAccept': Failure;
50
- } | {
51
- 'Service.aqm.task.consultConference': Failure;
52
- } | {
53
- 'Service.aqm.task.consultEnd': Failure;
54
- } | {
55
- 'Service.aqm.task.cancelCtq': Failure;
56
- } | {
57
- 'Service.aqm.task.hold': Failure;
58
- } | {
59
- 'Service.aqm.task.unHold': Failure;
60
- } | {
61
- 'Service.aqm.task.VteamListFailed': Failure;
62
- } | {
63
- 'Service.aqm.task.pauseRecording': Failure;
64
- } | {
65
- 'Service.aqm.task.resumeRecording': Failure;
66
- } | {
67
- 'Service.aqm.dialer.startOutdial': Failure;
68
- } | {
69
- 'Service.reqs.generic.failure': {
70
- trackingId: string;
71
- };
72
- };
73
- export type ReqError = 'Service.aqm.reqs.GenericRequestError' | {
74
- 'Service.aqm.reqs.Pending': {
75
- key: string;
76
- msg: string;
77
- };
78
- } | {
79
- 'Service.aqm.reqs.PendingEvent': {
80
- key: string;
81
- };
82
- } | {
83
- 'Service.aqm.reqs.Timeout': {
84
- key: string;
85
- response: WebexRequestPayload;
86
- };
87
- } | {
88
- 'Service.aqm.reqs.TimeoutEvent': {
89
- key: string;
90
- };
91
- };
92
- export interface Ids {
93
- 'Service.aqm.agent': AgentErrorIds;
94
- 'Service.aqm.reqs': ReqError;
95
- 'Service.aqm.task': TaskErrorIds;
96
- }
97
- export type IdsGlobal = 'system' | 'handle' | 'fallback';
98
- export type IdsSub = Ids[keyof Ids];
99
- export type IdsMessage = IdsGlobal | keyof Ids | Exclude<IdsSub, object>;
100
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
101
- export type FlattenUnion<T> = {
102
- [K in keyof UnionToIntersection<T>]: K extends keyof T ? T[K] extends any[] ? T[K] : T[K] extends object ? FlattenUnion<T[K]> : T[K] : UnionToIntersection<T>[K];
103
- };
104
- export type IdsDetailsType = FlattenUnion<Exclude<IdsSub, string>>;
105
- export type IdsDetails = keyof IdsDetailsType;
106
- export type Id = IdsMessage | IdsDetails;
107
- export declare class Message extends Error {
108
- readonly id: Id;
109
- constructor(id: IdsMessage);
110
- constructor(id: IdsMessage, message: string);
111
- constructor(id: IdsMessage, errror: Error);
112
- private isErr;
113
- }
114
- export declare class Details<T extends IdsDetails> extends Error {
115
- readonly id: Id;
116
- readonly details: IdsDetailsType[T];
117
- constructor(id: T, details: IdsDetailsType[T]);
118
- private isErr;
119
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * Generic message interface used throughout the plugin
3
- * @template T - Type of the data payload (defaults to any)
4
- * @private
5
- * @ignore
6
- */
7
- export type Msg<T = any> = {
8
- /** Message/Event type identifier */
9
- type: string;
10
- /** Organization identifier */
11
- orgId: string;
12
- /** Unique tracking identifier for the message/Event */
13
- trackingId: string;
14
- /** Message/Event payload data */
15
- data: T;
16
- };
17
- /**
18
- * Represents a failure message with specific error details
19
- * @private
20
- * @ignore
21
- */
22
- export type Failure = Msg<{
23
- /** Agent identifier associated with the failure */
24
- agentId: string;
25
- /** Tracking identifier for the failure event */
26
- trackingId: string;
27
- /** Numeric code indicating the reason for failure */
28
- reasonCode: number;
29
- /** Organization identifier */
30
- orgId: string;
31
- /** Human-readable description of the failure reason */
32
- reason: string;
33
- }>;
34
- /**
35
- * Represents task API error details in a structured format
36
- * @public
37
- */
38
- export interface TaskError {
39
- /** Original error object for throwing */
40
- error: Error;
41
- /** Unique tracking identifier for correlation */
42
- trackingId: string;
43
- /** Detailed error message from the API */
44
- errorMessage: string;
45
- /** Type/category of the error (e.g., "Bad Request") */
46
- errorType: string;
47
- /** Additional error context data */
48
- errorData: string;
49
- /** Numeric reason code */
50
- reasonCode: number;
51
- }
52
- /**
53
- * An Error object augmented with a flexible data field for additional context.
54
- * Use this to attach structured data to thrown errors without ts-ignore.
55
- */
56
- export interface AugmentedError extends Error {
57
- data?: Record<string, any>;
58
- }
@@ -1,75 +0,0 @@
1
- import * as Err from './Err';
2
- import { LoginOption, WebexRequestPayload } from '../../types';
3
- import { Failure, AugmentedError } from './GlobalTypes';
4
- import { TaskData, ConsultTransferPayLoad, ConsultConferenceData, consultConferencePayloadData, Interaction } from '../task/types';
5
- export declare const isValidDialNumber: (input: string) => boolean;
6
- export declare const getStationLoginErrorData: (failure: Failure, loginOption: LoginOption) => {
7
- message: any;
8
- fieldName: any;
9
- };
10
- /**
11
- * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.
12
- *
13
- * @param error - The error object, expected to have a `details` property of type Failure.
14
- * @param methodName - The name of the method where the error occurred.
15
- * @param moduleName - The name of the module where the error occurred.
16
- * @returns An object containing the error instance and the reason string.
17
- * @public
18
- * @example
19
- * const details = getErrorDetails(error, 'fetchData', 'DataModule');
20
- * if (details.error) { handleError(details.error); }
21
- * @ignore
22
- */
23
- export declare const getErrorDetails: (error: any, methodName: string, moduleName: string) => {
24
- error: Error;
25
- reason: string;
26
- };
27
- /**
28
- * Extracts error details from task API errors and logs them. Also uploads logs for the error.
29
- * This handles the specific error format returned by task API calls.
30
- *
31
- * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}
32
- * @param methodName - The name of the method where the error occurred.
33
- * @param moduleName - The name of the module where the error occurred.
34
- * @returns AugmentedError containing structured error details on err.data for metrics and logging
35
- * @public
36
- * @example
37
- * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');
38
- * throw taskError.error;
39
- * @ignore
40
- */
41
- export declare const generateTaskErrorObject: (error: any, methodName: string, moduleName: string) => AugmentedError;
42
- /**
43
- * Creates an error details object suitable for use with the Err.Details class.
44
- *
45
- * @param errObj - The Webex request payload object.
46
- * @returns An instance of Err.Details with the generic failure message and extracted details.
47
- * @public
48
- * @example
49
- * const errDetails = createErrDetailsObject(webexRequestPayload);
50
- * @ignore
51
- */
52
- export declare const createErrDetailsObject: (errObj: WebexRequestPayload) => Err.Details<"Service.reqs.generic.failure">;
53
- /**
54
- * Gets the destination agent ID from participants data by finding the first
55
- * non-customer participant that is not the current agent and is not in wrap-up state.
56
- *
57
- * @param participants - The participants data from the interaction
58
- * @param agentId - The current agent's ID to exclude from the search
59
- * @returns The destination agent ID, or empty string if none found
60
- */
61
- export declare const getDestinationAgentId: (participants: Interaction['participants'], agentId: string) => string;
62
- export declare const deriveConsultTransferDestinationType: (taskData?: TaskData) => ConsultTransferPayLoad['destinationType'];
63
- /**
64
- * Builds consult conference parameter data using EXACT Agent Desktop logic.
65
- * This matches the Agent Desktop's consultConference implementation exactly.
66
- *
67
- * @param dataPassed - Original consultation data from Agent Desktop format
68
- * @param interactionIdPassed - The interaction ID for the task
69
- * @returns Object with interactionId and ConsultConferenceData matching Agent Desktop format
70
- * @public
71
- */
72
- export declare const buildConsultConferenceParamData: (dataPassed: consultConferencePayloadData, interactionIdPassed: string) => {
73
- interactionId: string;
74
- data: ConsultConferenceData;
75
- };
@@ -1,22 +0,0 @@
1
- import { WebexSDK, HTTP_METHODS, IHttpResponse, RequestBody, UploadLogsResponse, LogsMetaData } from '../../types';
2
- declare class WebexRequest {
3
- private webex;
4
- private static instance;
5
- static getInstance(options?: {
6
- webex: WebexSDK;
7
- }): WebexRequest;
8
- private constructor();
9
- request(options: {
10
- service: string;
11
- resource: string;
12
- method: HTTP_METHODS;
13
- body?: RequestBody;
14
- }): Promise<IHttpResponse>;
15
- /**
16
- * This is used for uploading the logs to backend/mats.
17
- *
18
- * @param metaData - meta data to be uploaded.
19
- */
20
- uploadLogs(metaData?: LogsMetaData): Promise<UploadLogsResponse>;
21
- }
22
- export default WebexRequest;
@@ -1,16 +0,0 @@
1
- import { Conf, ConfEmpty, Res, ResEmpty } from './types';
2
- import { WebSocketManager } from './websocket/WebSocketManager';
3
- export default class AqmReqs {
4
- private pendingRequests;
5
- private pendingNotifCancelrequest;
6
- private webexRequest;
7
- private webSocketManager;
8
- constructor(webSocketManager: WebSocketManager);
9
- req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq>;
10
- reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes>;
11
- private makeAPIRequest;
12
- private createPromise;
13
- private bindPrint;
14
- private bindCheck;
15
- private readonly onMessage;
16
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * Interval in milliseconds for sending keepalive pings to the worker.
3
- * @ignore
4
- */
5
- export declare const KEEPALIVE_WORKER_INTERVAL = 4000;
6
- /**
7
- * Delay in milliseconds before resolving notification handlers.
8
- * @ignore
9
- */
10
- export declare const NOTIFS_RESOLVE_DELAY = 1200;
11
- /**
12
- * Timeout duration in milliseconds before forcefully closing a WebSocket connection.
13
- * @ignore
14
- */
15
- export declare const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;
16
- /**
17
- * API endpoint used for connectivity or health checks.
18
- * @ignore
19
- */
20
- export declare const PING_API_URL = "/health";
21
- /**
22
- * Timeout in milliseconds to wait for a welcome message after socket connection.
23
- * @ignore
24
- */
25
- export declare const WELCOME_TIMEOUT = 30000;
26
- /**
27
- * Event name used for real-time device (RTD) ping status.
28
- * @ignore
29
- */
30
- export declare const RTD_PING_EVENT = "rtd-online-status";
31
- /**
32
- * Timeout in milliseconds for individual HTTP requests.
33
- * @ignore
34
- */
35
- export declare const TIMEOUT_REQ = 20000;
36
- /**
37
- * Duration in milliseconds to wait before attempting lost connection recovery.
38
- * @ignore
39
- */
40
- export declare const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;
41
- /**
42
- * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.
43
- * @ignore
44
- */
45
- export declare const WS_DISCONNECT_ALLOWED = 8000;
46
- /**
47
- * Interval in milliseconds to check for connectivity status.
48
- * @ignore
49
- */
50
- export declare const CONNECTIVITY_CHECK_INTERVAL = 5000;
51
- /**
52
- * Timeout in milliseconds for cleanly closing the WebSocket.
53
- * @ignore
54
- */
55
- export declare const CLOSE_SOCKET_TIMEOUT = 16000;
56
- export declare const METHODS: {
57
- REQUEST: string;
58
- UPLOAD_LOGS: string;
59
- GET_ERROR_DETAILS: string;
60
- GET_COMMON_ERROR_DETAILS: string;
61
- CREATE_ERR_DETAILS_OBJECT: string;
62
- REQ: string;
63
- REQ_EMPTY: string;
64
- MAKE_API_REQUEST: string;
65
- CREATE_PROMISE: string;
66
- BIND_PRINT: string;
67
- BIND_CHECK: string;
68
- ON_MESSAGE: string;
69
- INIT_WEB_SOCKET: string;
70
- CLOSE: string;
71
- HANDLE_CONNECTION_LOST: string;
72
- REGISTER: string;
73
- CONNECT: string;
74
- WEB_SOCKET_ON_CLOSE_HANDLER: string;
75
- SETUP_EVENT_LISTENERS: string;
76
- DISPATCH_CONNECTION_EVENT: string;
77
- CS_HANDLE_CONNECTION_LOST: string;
78
- CLEAR_TIMER_ON_RESTORE_FAILED: string;
79
- HANDLE_RESTORE_FAILED: string;
80
- UPDATE_CONNECTION_DATA: string;
81
- SET_CONNECTION_PROP: string;
82
- ON_PING: string;
83
- HANDLE_SOCKET_CLOSE: string;
84
- ON_SOCKET_CLOSE: string;
85
- };
@@ -1,47 +0,0 @@
1
- import { HTTP_METHODS, RequestBody, WebexRequestPayload } from '../../types';
2
- import * as Err from './Err';
3
- import { Msg } from './GlobalTypes';
4
- export type Pending = {
5
- check: (msg: Msg) => boolean;
6
- handle: (msg: Msg) => void;
7
- alternateBind?: string;
8
- };
9
- export type BindType = string | string[] | {
10
- [key: string]: BindType;
11
- };
12
- interface Bind {
13
- type: BindType;
14
- data?: any;
15
- }
16
- export type Timeout = number | 'disabled';
17
- export type Req<TRes, TErr> = {
18
- url: string;
19
- host?: string;
20
- method?: HTTP_METHODS;
21
- err?: ((errObj: WebexRequestPayload) => Err.Details<'Service.reqs.generic.failure'>) | Err.IdsMessage | ((e: WebexRequestPayload) => Err.Message | Err.Details<Err.IdsDetails>);
22
- notifSuccess: {
23
- bind: Bind;
24
- msg: TRes;
25
- };
26
- notifFail?: {
27
- bind: Bind;
28
- errMsg: TErr;
29
- err: (e: TErr) => Err.Details<Err.IdsDetails>;
30
- } | {
31
- bind: Bind;
32
- errId: Err.IdsDetails;
33
- };
34
- data?: RequestBody;
35
- headers?: Record<string, string>;
36
- timeout?: Timeout;
37
- notifCancel?: {
38
- bind: Bind;
39
- msg: TRes;
40
- };
41
- };
42
- export type Conf<TRes, TErr, TReq> = (p: TReq) => Req<TRes, TErr>;
43
- export type ConfEmpty<TRes, TErr> = () => Req<TRes, TErr>;
44
- export type Res<TRes, TReq> = (p: TReq, cbRes?: CbRes<TRes>) => Promise<TRes>;
45
- export type ResEmpty<TRes> = (cbRes?: CbRes<TRes>) => Promise<TRes>;
46
- export type CbRes<TRes> = (res: any) => void | TRes;
47
- export {};
@@ -1,34 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from 'events';
3
- import { WebexSDK, SubscribeRequest } from '../../../types';
4
- import { ConnectionLostDetails } from './types';
5
- import { WelcomeResponse } from '../../config/types';
6
- /**
7
- * WebSocketManager handles the WebSocket connection for Contact Center operations.
8
- * It manages the connection lifecycle, including registration, reconnection, and message handling.
9
- * It also utilizes a Web Worker to manage keepalive messages and socket closure.
10
- * @ignore
11
- */
12
- export declare class WebSocketManager extends EventEmitter {
13
- private websocket;
14
- shouldReconnect: boolean;
15
- isSocketClosed: boolean;
16
- private isWelcomeReceived;
17
- private url;
18
- private forceCloseWebSocketOnTimeout;
19
- private isConnectionLost;
20
- private webex;
21
- private welcomePromiseResolve;
22
- private keepaliveWorker;
23
- constructor(options: {
24
- webex: WebexSDK;
25
- });
26
- initWebSocket(options: {
27
- body: SubscribeRequest;
28
- }): Promise<WelcomeResponse>;
29
- close(shouldReconnect: boolean, reason?: string): void;
30
- handleConnectionLost(event: ConnectionLostDetails): void;
31
- private register;
32
- private connect;
33
- private webSocketOnCloseHandler;
34
- }
@@ -1,27 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { ConnectionServiceOptions, ConnectionProp } from './types';
4
- export declare class ConnectionService extends EventEmitter {
5
- private connectionProp;
6
- private wsDisconnectAllowed;
7
- private reconnectingTimer;
8
- private restoreTimer;
9
- private isConnectionLost;
10
- private isRestoreFailed;
11
- private isSocketReconnected;
12
- private isKeepAlive;
13
- private reconnectInterval;
14
- private webSocketManager;
15
- private subscribeRequest;
16
- constructor(options: ConnectionServiceOptions);
17
- private setupEventListeners;
18
- private dispatchConnectionEvent;
19
- private handleConnectionLost;
20
- private clearTimerOnRestoreFailed;
21
- private handleRestoreFailed;
22
- private updateConnectionData;
23
- setConnectionProp(prop: ConnectionProp): void;
24
- private onPing;
25
- private handleSocketClose;
26
- private onSocketClose;
27
- }
@@ -1,2 +0,0 @@
1
- export default workerScript;
2
- declare const workerScript: "\nconsole.log(\"*** Keepalive Worker Thread ***\");\nlet intervalId, intervalDuration, timeOutId, isSocketClosed, closeSocketTimeout;\nlet initialised = false;\nlet initiateWebSocketClosure = false;\n\nconst resetOfflineHandler = function () {\n if (timeOutId) {\n initialised = false;\n clearTimeout(timeOutId);\n timeOutId = null;\n }\n};\n\nconst checkOnlineStatus = function () {\n const onlineStatus = navigator.onLine;\n console.log(\n `[WebSocketStatus] event=checkOnlineStatus | online status=`,\n onlineStatus\n );\n return onlineStatus;\n};\n\n// Checks network status and if it's offline then force closes WebSocket\nconst checkNetworkStatus = function () {\n const onlineStatus = checkOnlineStatus();\n postMessage({ type: \"keepalive\", onlineStatus });\n if (!onlineStatus && !initialised) {\n initialised = true;\n // Sets a timeout of 16s, checks if socket didn't close then it closes forcefully\n timeOutId = setTimeout(() => {\n if (!isSocketClosed) {\n initiateWebSocketClosure = true;\n postMessage({ type: \"closeSocket\" });\n }\n }, closeSocketTimeout);\n }\n\n if (onlineStatus && initialised) {\n initialised = false;\n }\n\n if (initiateWebSocketClosure) {\n initiateWebSocketClosure = false;\n clearTimeout(timeOutId);\n timeOutId = null;\n }\n};\n\naddEventListener(\"message\", (event) => {\n if (event.data?.type === \"start\") {\n intervalDuration = event.data?.intervalDuration || 4000;\n closeSocketTimeout = event.data?.closeSocketTimeout || 5000;\n console.log(\"event=Websocket startWorker | keepalive Worker started\");\n intervalId = setInterval(\n (checkIfSocketClosed) => {\n checkNetworkStatus();\n isSocketClosed = checkIfSocketClosed;\n },\n intervalDuration,\n event.data?.isSocketClosed\n );\n\n resetOfflineHandler();\n }\n\n if (event.data?.type === \"terminate\" && intervalId) {\n console.log(\"event=Websocket terminateWorker | keepalive Worker stopped\");\n clearInterval(intervalId);\n intervalId = null;\n resetOfflineHandler();\n }\n});\n\n// Listen for online and offline events\nself.addEventListener('online', () => {\n console.log('Network status: online');\n checkNetworkStatus();\n});\n\nself.addEventListener('offline', () => {\n console.log('Network status: offline');\n checkNetworkStatus();\n});\n";
@@ -1,37 +0,0 @@
1
- import { SubscribeRequest } from '../../../types';
2
- import { WebSocketManager } from './WebSocketManager';
3
- /**
4
- * Options for initializing a connection service.
5
- * @typedef ConnectionServiceOptions
6
- * @property {WebSocketManager} webSocketManager - The WebSocket manager instance.
7
- * @property {SubscribeRequest} subscribeRequest - The subscribe request payload.
8
- * @ignore
9
- */
10
- export type ConnectionServiceOptions = {
11
- webSocketManager: WebSocketManager;
12
- subscribeRequest: SubscribeRequest;
13
- };
14
- /**
15
- * Details about the state of a lost connection and recovery attempts.
16
- * @typedef ConnectionLostDetails
17
- * @property {boolean} isConnectionLost - Indicates if the connection is currently lost.
18
- * @property {boolean} isRestoreFailed - Indicates if restoring the connection has failed.
19
- * @property {boolean} isSocketReconnected - Indicates if the socket has been reconnected.
20
- * @property {boolean} isKeepAlive - Indicates if the keep-alive mechanism is active.
21
- * @ignore
22
- */
23
- export type ConnectionLostDetails = {
24
- isConnectionLost: boolean;
25
- isRestoreFailed: boolean;
26
- isSocketReconnected: boolean;
27
- isKeepAlive: boolean;
28
- };
29
- /**
30
- * Properties for connection configuration.
31
- * @typedef ConnectionProp
32
- * @property {number} lostConnectionRecoveryTimeout - Timeout in milliseconds for lost connection recovery.
33
- * @ignore
34
- */
35
- export type ConnectionProp = {
36
- lostConnectionRecoveryTimeout: number;
37
- };
@@ -1,52 +0,0 @@
1
- import routingAgent from './agent';
2
- import routingContact from './task/contact';
3
- import AgentConfigService from './config';
4
- import { WebSocketManager } from './core/websocket/WebSocketManager';
5
- import { ConnectionService } from './core/websocket/connection-service';
6
- import { WebexSDK, SubscribeRequest } from '../types';
7
- import aqmDialer from './task/dialer';
8
- /**
9
- * Services class provides centralized access to all contact center plugin services
10
- * using a singleton pattern to ensure a single instance throughout the application.
11
- * @private
12
- * @ignore
13
- * @class
14
- */
15
- export default class Services {
16
- /** Agent services for managing agent state and capabilities */
17
- readonly agent: ReturnType<typeof routingAgent>;
18
- /** Configuration services for agent settings */
19
- readonly config: AgentConfigService;
20
- /** Contact services for managing customer interactions */
21
- readonly contact: ReturnType<typeof routingContact>;
22
- /** Dialer services for outbound calling features */
23
- readonly dialer: ReturnType<typeof aqmDialer>;
24
- /** WebSocket manager for handling real-time communications */
25
- readonly webSocketManager: WebSocketManager;
26
- /** Connection service for managing websocket connections */
27
- readonly connectionService: ConnectionService;
28
- /** Singleton instance of the Services class */
29
- private static instance;
30
- /**
31
- * Creates a new Services instance
32
- * @param options - Configuration options
33
- * @param options.webex - WebexSDK instance
34
- * @param options.connectionConfig - Subscription configuration for websocket connection
35
- */
36
- constructor(options: {
37
- webex: WebexSDK;
38
- connectionConfig: SubscribeRequest;
39
- });
40
- /**
41
- * Gets singleton instance of Services class
42
- * Creates a new instance if one doesn't exist
43
- * @param options - Configuration options
44
- * @param options.webex - WebexSDK instance
45
- * @param options.connectionConfig - Subscription configuration for websocket connection
46
- * @returns The singleton Services instance
47
- */
48
- static getInstance(options: {
49
- webex: WebexSDK;
50
- connectionConfig: SubscribeRequest;
51
- }): Services;
52
- }