@webex/contact-center 0.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/__mocks__/workerMock.js +15 -0
- package/babel.config.js +15 -0
- package/dist/cc.js +1416 -0
- package/dist/cc.js.map +1 -0
- package/dist/config.js +72 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.js +58 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -0
- package/dist/logger-proxy.js +115 -0
- package/dist/logger-proxy.js.map +1 -0
- package/dist/metrics/MetricsManager.js +474 -0
- package/dist/metrics/MetricsManager.js.map +1 -0
- package/dist/metrics/behavioral-events.js +322 -0
- package/dist/metrics/behavioral-events.js.map +1 -0
- package/dist/metrics/constants.js +134 -0
- package/dist/metrics/constants.js.map +1 -0
- package/dist/services/WebCallingService.js +323 -0
- package/dist/services/WebCallingService.js.map +1 -0
- package/dist/services/agent/index.js +177 -0
- package/dist/services/agent/index.js.map +1 -0
- package/dist/services/agent/types.js +137 -0
- package/dist/services/agent/types.js.map +1 -0
- package/dist/services/config/Util.js +203 -0
- package/dist/services/config/Util.js.map +1 -0
- package/dist/services/config/constants.js +221 -0
- package/dist/services/config/constants.js.map +1 -0
- package/dist/services/config/index.js +607 -0
- package/dist/services/config/index.js.map +1 -0
- package/dist/services/config/types.js +334 -0
- package/dist/services/config/types.js.map +1 -0
- package/dist/services/constants.js +117 -0
- package/dist/services/constants.js.map +1 -0
- package/dist/services/core/Err.js +43 -0
- package/dist/services/core/Err.js.map +1 -0
- package/dist/services/core/GlobalTypes.js +6 -0
- package/dist/services/core/GlobalTypes.js.map +1 -0
- package/dist/services/core/Utils.js +126 -0
- package/dist/services/core/Utils.js.map +1 -0
- package/dist/services/core/WebexRequest.js +96 -0
- package/dist/services/core/WebexRequest.js.map +1 -0
- package/dist/services/core/aqm-reqs.js +246 -0
- package/dist/services/core/aqm-reqs.js.map +1 -0
- package/dist/services/core/constants.js +109 -0
- package/dist/services/core/constants.js.map +1 -0
- package/dist/services/core/types.js +6 -0
- package/dist/services/core/types.js.map +1 -0
- package/dist/services/core/websocket/WebSocketManager.js +187 -0
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -0
- package/dist/services/core/websocket/connection-service.js +111 -0
- package/dist/services/core/websocket/connection-service.js.map +1 -0
- package/dist/services/core/websocket/keepalive.worker.js +94 -0
- package/dist/services/core/websocket/keepalive.worker.js.map +1 -0
- package/dist/services/core/websocket/types.js +6 -0
- package/dist/services/core/websocket/types.js.map +1 -0
- package/dist/services/index.js +78 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/task/AutoWrapup.js +88 -0
- package/dist/services/task/AutoWrapup.js.map +1 -0
- package/dist/services/task/TaskManager.js +369 -0
- package/dist/services/task/TaskManager.js.map +1 -0
- package/dist/services/task/constants.js +58 -0
- package/dist/services/task/constants.js.map +1 -0
- package/dist/services/task/contact.js +464 -0
- package/dist/services/task/contact.js.map +1 -0
- package/dist/services/task/dialer.js +60 -0
- package/dist/services/task/dialer.js.map +1 -0
- package/dist/services/task/index.js +1188 -0
- package/dist/services/task/index.js.map +1 -0
- package/dist/services/task/types.js +214 -0
- package/dist/services/task/types.js.map +1 -0
- package/dist/types/cc.d.ts +676 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/constants.d.ts +45 -0
- package/dist/types/index.d.ts +178 -0
- package/dist/types/logger-proxy.d.ts +71 -0
- package/dist/types/metrics/MetricsManager.d.ts +223 -0
- package/dist/types/metrics/behavioral-events.d.ts +29 -0
- package/dist/types/metrics/constants.d.ts +127 -0
- package/dist/types/services/WebCallingService.d.ts +1 -0
- package/dist/types/services/agent/index.d.ts +46 -0
- package/dist/types/services/agent/types.d.ts +413 -0
- package/dist/types/services/config/Util.d.ts +19 -0
- package/dist/types/services/config/constants.d.ts +203 -0
- package/dist/types/services/config/index.d.ts +171 -0
- package/dist/types/services/config/types.d.ts +1113 -0
- package/dist/types/services/constants.d.ts +97 -0
- package/dist/types/services/core/Err.d.ts +119 -0
- package/dist/types/services/core/GlobalTypes.d.ts +33 -0
- package/dist/types/services/core/Utils.d.ts +36 -0
- package/dist/types/services/core/WebexRequest.d.ts +22 -0
- package/dist/types/services/core/aqm-reqs.d.ts +16 -0
- package/dist/types/services/core/constants.d.ts +85 -0
- package/dist/types/services/core/types.d.ts +47 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +34 -0
- package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
- package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +37 -0
- package/dist/types/services/index.d.ts +52 -0
- package/dist/types/services/task/AutoWrapup.d.ts +40 -0
- package/dist/types/services/task/TaskManager.d.ts +1 -0
- package/dist/types/services/task/constants.d.ts +46 -0
- package/dist/types/services/task/contact.d.ts +59 -0
- package/dist/types/services/task/dialer.d.ts +28 -0
- package/dist/types/services/task/index.d.ts +569 -0
- package/dist/types/services/task/types.d.ts +1041 -0
- package/dist/types/types.d.ts +452 -0
- package/dist/types/webex-config.d.ts +53 -0
- package/dist/types/webex.d.ts +7 -0
- package/dist/types.js +292 -0
- package/dist/types.js.map +1 -0
- package/dist/webex-config.js +60 -0
- package/dist/webex-config.js.map +1 -0
- package/dist/webex.js +99 -0
- package/dist/webex.js.map +1 -0
- package/jest.config.js +45 -0
- package/package.json +83 -0
- package/src/cc.ts +1618 -0
- package/src/config.ts +65 -0
- package/src/constants.ts +51 -0
- package/src/index.ts +220 -0
- package/src/logger-proxy.ts +110 -0
- package/src/metrics/MetricsManager.ts +512 -0
- package/src/metrics/behavioral-events.ts +332 -0
- package/src/metrics/constants.ts +135 -0
- package/src/services/WebCallingService.ts +351 -0
- package/src/services/agent/index.ts +149 -0
- package/src/services/agent/types.ts +440 -0
- package/src/services/config/Util.ts +261 -0
- package/src/services/config/constants.ts +249 -0
- package/src/services/config/index.ts +743 -0
- package/src/services/config/types.ts +1117 -0
- package/src/services/constants.ts +111 -0
- package/src/services/core/Err.ts +126 -0
- package/src/services/core/GlobalTypes.ts +34 -0
- package/src/services/core/Utils.ts +132 -0
- package/src/services/core/WebexRequest.ts +103 -0
- package/src/services/core/aqm-reqs.ts +272 -0
- package/src/services/core/constants.ts +106 -0
- package/src/services/core/types.ts +48 -0
- package/src/services/core/websocket/WebSocketManager.ts +196 -0
- package/src/services/core/websocket/connection-service.ts +142 -0
- package/src/services/core/websocket/keepalive.worker.js +88 -0
- package/src/services/core/websocket/types.ts +40 -0
- package/src/services/index.ts +71 -0
- package/src/services/task/AutoWrapup.ts +86 -0
- package/src/services/task/TaskManager.ts +420 -0
- package/src/services/task/constants.ts +52 -0
- package/src/services/task/contact.ts +429 -0
- package/src/services/task/dialer.ts +52 -0
- package/src/services/task/index.ts +1375 -0
- package/src/services/task/types.ts +1113 -0
- package/src/types.ts +639 -0
- package/src/webex-config.ts +54 -0
- package/src/webex.js +96 -0
- package/test/unit/spec/cc.ts +1985 -0
- package/test/unit/spec/metrics/MetricsManager.ts +491 -0
- package/test/unit/spec/metrics/behavioral-events.ts +102 -0
- package/test/unit/spec/services/WebCallingService.ts +416 -0
- package/test/unit/spec/services/agent/index.ts +65 -0
- package/test/unit/spec/services/config/index.ts +1035 -0
- package/test/unit/spec/services/core/Utils.ts +279 -0
- package/test/unit/spec/services/core/WebexRequest.ts +144 -0
- package/test/unit/spec/services/core/aqm-reqs.ts +570 -0
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +378 -0
- package/test/unit/spec/services/core/websocket/connection-service.ts +178 -0
- package/test/unit/spec/services/task/TaskManager.ts +1351 -0
- package/test/unit/spec/services/task/contact.ts +204 -0
- package/test/unit/spec/services/task/dialer.ts +157 -0
- package/test/unit/spec/services/task/index.ts +1474 -0
- package/tsconfig.json +6 -0
- package/typedoc.json +37 -0
- package/typedoc.md +240 -0
- package/umd/contact-center.min.js +3 -0
- package/umd/contact-center.min.js.map +1 -0
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Err from './Err';
|
|
2
|
+
import { LoginOption, WebexRequestPayload } from '../../types';
|
|
3
|
+
import { Failure } from './GlobalTypes';
|
|
4
|
+
export declare const isValidDialNumber: (input: string) => boolean;
|
|
5
|
+
export declare const getStationLoginErrorData: (failure: Failure, loginOption: LoginOption) => {
|
|
6
|
+
message: any;
|
|
7
|
+
fieldName: any;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.
|
|
11
|
+
*
|
|
12
|
+
* @param error - The error object, expected to have a `details` property of type Failure.
|
|
13
|
+
* @param methodName - The name of the method where the error occurred.
|
|
14
|
+
* @param moduleName - The name of the module where the error occurred.
|
|
15
|
+
* @returns An object containing the error instance and the reason string.
|
|
16
|
+
* @public
|
|
17
|
+
* @example
|
|
18
|
+
* const details = getErrorDetails(error, 'fetchData', 'DataModule');
|
|
19
|
+
* if (details.error) { handleError(details.error); }
|
|
20
|
+
* @ignore
|
|
21
|
+
*/
|
|
22
|
+
export declare const getErrorDetails: (error: any, methodName: string, moduleName: string) => {
|
|
23
|
+
error: Error;
|
|
24
|
+
reason: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Creates an error details object suitable for use with the Err.Details class.
|
|
28
|
+
*
|
|
29
|
+
* @param errObj - The Webex request payload object.
|
|
30
|
+
* @returns An instance of Err.Details with the generic failure message and extracted details.
|
|
31
|
+
* @public
|
|
32
|
+
* @example
|
|
33
|
+
* const errDetails = createErrDetailsObject(webexRequestPayload);
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
export declare const createErrDetailsObject: (errObj: WebexRequestPayload) => Err.Details<"Service.reqs.generic.failure">;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
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";
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoWrapup class implements a timer for automatic wrap-up functionality.
|
|
3
|
+
* It handles timing the wrap-up period and executing a callback when the timer completes.
|
|
4
|
+
*/
|
|
5
|
+
export default class AutoWrapup {
|
|
6
|
+
private timer;
|
|
7
|
+
private startTime;
|
|
8
|
+
private readonly interval;
|
|
9
|
+
allowCancelAutoWrapup: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new AutoWrapup timer
|
|
12
|
+
* @param interval - Time in milliseconds before auto wrap-up executes
|
|
13
|
+
* @param allowCancelAutoWrapup - Whether to allow canceling the auto wrap-up
|
|
14
|
+
*/
|
|
15
|
+
constructor(interval: number, allowCancelAutoWrapup?: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* Starts the auto wrap-up timer
|
|
18
|
+
* @param onComplete - Callback function to execute when timer completes
|
|
19
|
+
*/
|
|
20
|
+
start(onComplete: () => void): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clears the auto wrap-up timer if it's running
|
|
23
|
+
*/
|
|
24
|
+
clear(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the remaining time in milliseconds
|
|
27
|
+
* @returns Time left in milliseconds
|
|
28
|
+
*/
|
|
29
|
+
getTimeLeft(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the timer is currently running
|
|
32
|
+
* @returns True if the timer is running, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
isRunning(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the remaining time in seconds (rounded)
|
|
37
|
+
* @returns Time left in seconds
|
|
38
|
+
*/
|
|
39
|
+
getTimeLeftSeconds(): number;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|