@webex/contact-center 3.11.0 → 3.12.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.
- package/dist/cc.js +91 -27
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +13 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +9 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/ApiAiAssistant.js +173 -0
- package/dist/services/ApiAiAssistant.js.map +1 -0
- package/dist/services/agent/types.js.map +1 -1
- package/dist/services/config/Util.js +6 -2
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +12 -0
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +41 -2
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +19 -1
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +19 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +28 -6
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +92 -17
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +13 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/TaskManager.js +96 -25
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +16 -3
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/constants.js +14 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/dialer.js +51 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/types.js +15 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +800 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/constants.d.ts +50 -0
- package/dist/types/index.d.ts +184 -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 +161 -0
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/ApiAiAssistant.d.ts +31 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -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 +20 -0
- package/dist/types/services/config/constants.d.ts +249 -0
- package/dist/types/services/config/index.d.ts +177 -0
- package/dist/types/services/config/types.d.ts +1207 -0
- package/dist/types/services/constants.d.ts +103 -0
- package/dist/types/services/core/Err.d.ts +121 -0
- package/dist/types/services/core/GlobalTypes.d.ts +58 -0
- package/dist/types/services/core/Utils.d.ts +101 -0
- package/dist/types/services/core/WebexRequest.d.ts +22 -0
- package/dist/types/services/core/aqm-reqs.d.ts +65 -0
- package/dist/types/services/core/constants.d.ts +99 -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/TaskUtils.d.ts +92 -0
- package/dist/types/services/task/constants.d.ts +83 -0
- package/dist/types/services/task/contact.d.ts +69 -0
- package/dist/types/services/task/dialer.d.ts +43 -0
- package/dist/types/services/task/index.d.ts +650 -0
- package/dist/types/services/task/types.d.ts +1319 -0
- package/dist/types/types.d.ts +643 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types/webex-config.d.ts +53 -0
- package/dist/types/webex.d.ts +7 -0
- package/dist/types.js +14 -1
- package/dist/types.js.map +1 -1
- package/dist/webex.js +1 -1
- package/package.json +9 -9
- package/src/cc.ts +120 -29
- package/src/constants.ts +4 -0
- package/src/index.ts +1 -0
- package/src/metrics/behavioral-events.ts +14 -0
- package/src/metrics/constants.ts +11 -0
- package/src/services/ApiAiAssistant.ts +217 -0
- package/src/services/agent/types.ts +1 -1
- package/src/services/config/Util.ts +8 -0
- package/src/services/config/constants.ts +12 -0
- package/src/services/config/index.ts +45 -1
- package/src/services/config/types.ts +67 -0
- package/src/services/constants.ts +21 -0
- package/src/services/core/Err.ts +1 -0
- package/src/services/core/Utils.ts +32 -5
- package/src/services/core/aqm-reqs.ts +100 -22
- package/src/services/core/websocket/WebSocketManager.ts +12 -0
- package/src/services/task/TaskManager.ts +149 -28
- package/src/services/task/TaskUtils.ts +12 -0
- package/src/services/task/constants.ts +15 -0
- package/src/services/task/dialer.ts +56 -1
- package/src/services/task/types.ts +24 -0
- package/src/types.ts +40 -1
- package/test/unit/spec/cc.ts +92 -22
- package/test/unit/spec/services/ApiAiAssistant.ts +115 -0
- package/test/unit/spec/services/config/index.ts +56 -0
- package/test/unit/spec/services/core/Utils.ts +63 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +71 -1
- package/test/unit/spec/services/task/TaskManager.ts +1015 -165
- package/test/unit/spec/services/task/dialer.ts +198 -112
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
};
|
|
98
|
+
export declare const AI_ASSISTANT_API_URLS: {
|
|
99
|
+
EVENT: string;
|
|
100
|
+
TRANSCRIPTS_LIST: string;
|
|
101
|
+
};
|
|
102
|
+
export declare const AI_ASSISTANT_BASE_URL_TEMPLATE = "https://api-ai-assistant.%s.ciscoccservice.com";
|
|
103
|
+
export declare const AI_ASSISTANT_ENV_MAP: Record<string, string>;
|
|
@@ -0,0 +1,121 @@
|
|
|
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.aqm.dialer.acceptPreviewContact': Failure;
|
|
70
|
+
} | {
|
|
71
|
+
'Service.reqs.generic.failure': {
|
|
72
|
+
trackingId: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type ReqError = 'Service.aqm.reqs.GenericRequestError' | {
|
|
76
|
+
'Service.aqm.reqs.Pending': {
|
|
77
|
+
key: string;
|
|
78
|
+
msg: string;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
'Service.aqm.reqs.PendingEvent': {
|
|
82
|
+
key: string;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
'Service.aqm.reqs.Timeout': {
|
|
86
|
+
key: string;
|
|
87
|
+
response: WebexRequestPayload;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
'Service.aqm.reqs.TimeoutEvent': {
|
|
91
|
+
key: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export interface Ids {
|
|
95
|
+
'Service.aqm.agent': AgentErrorIds;
|
|
96
|
+
'Service.aqm.reqs': ReqError;
|
|
97
|
+
'Service.aqm.task': TaskErrorIds;
|
|
98
|
+
}
|
|
99
|
+
export type IdsGlobal = 'system' | 'handle' | 'fallback';
|
|
100
|
+
export type IdsSub = Ids[keyof Ids];
|
|
101
|
+
export type IdsMessage = IdsGlobal | keyof Ids | Exclude<IdsSub, object>;
|
|
102
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
103
|
+
export type FlattenUnion<T> = {
|
|
104
|
+
[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];
|
|
105
|
+
};
|
|
106
|
+
export type IdsDetailsType = FlattenUnion<Exclude<IdsSub, string>>;
|
|
107
|
+
export type IdsDetails = keyof IdsDetailsType;
|
|
108
|
+
export type Id = IdsMessage | IdsDetails;
|
|
109
|
+
export declare class Message extends Error {
|
|
110
|
+
readonly id: Id;
|
|
111
|
+
constructor(id: IdsMessage);
|
|
112
|
+
constructor(id: IdsMessage, message: string);
|
|
113
|
+
constructor(id: IdsMessage, errror: Error);
|
|
114
|
+
private isErr;
|
|
115
|
+
}
|
|
116
|
+
export declare class Details<T extends IdsDetails> extends Error {
|
|
117
|
+
readonly id: Id;
|
|
118
|
+
readonly details: IdsDetailsType[T];
|
|
119
|
+
constructor(id: T, details: IdsDetailsType[T]);
|
|
120
|
+
private isErr;
|
|
121
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as Err from './Err';
|
|
2
|
+
import { LoginOption, WebexRequestPayload } from '../../types';
|
|
3
|
+
import { Failure, AugmentedError } from './GlobalTypes';
|
|
4
|
+
import { TaskData, ConsultTransferPayLoad, Interaction } from '../task/types';
|
|
5
|
+
import { DialPlan } from '../config/types';
|
|
6
|
+
export declare const FALLBACK_DIAL_NUMBER_REGEX: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* Validates a dial number against the provided dial plan regex patterns.
|
|
9
|
+
* A number is valid if it matches at least one regex pattern in the dial plans.
|
|
10
|
+
* Falls back to US/Canada regex validation if no dial plan entries are configured.
|
|
11
|
+
*
|
|
12
|
+
* @param input - The dial number to validate
|
|
13
|
+
* @param dialPlanEntries - Array of dial plan entries containing regex patterns
|
|
14
|
+
* @returns true if the input matches at least one dial plan regex pattern, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare const isValidDialNumber: (input: string, dialPlanEntries: DialPlan['dialPlanEntity']) => boolean;
|
|
17
|
+
export declare const getStationLoginErrorData: (failure: Failure, loginOption: LoginOption) => {
|
|
18
|
+
message: any;
|
|
19
|
+
fieldName: any;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.
|
|
23
|
+
*
|
|
24
|
+
* @param error - The error object, expected to have a `details` property of type Failure.
|
|
25
|
+
* @param methodName - The name of the method where the error occurred.
|
|
26
|
+
* @param moduleName - The name of the module where the error occurred.
|
|
27
|
+
* @returns An object containing the error instance and the reason string.
|
|
28
|
+
* @public
|
|
29
|
+
* @example
|
|
30
|
+
* const details = getErrorDetails(error, 'fetchData', 'DataModule');
|
|
31
|
+
* if (details.error) { handleError(details.error); }
|
|
32
|
+
* @ignore
|
|
33
|
+
*/
|
|
34
|
+
export declare const getErrorDetails: (error: any, methodName: string, moduleName: string) => {
|
|
35
|
+
error: Error;
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Extracts error details from task API errors and logs them. Also uploads logs for the error.
|
|
40
|
+
* This handles the specific error format returned by task API calls.
|
|
41
|
+
*
|
|
42
|
+
* @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}
|
|
43
|
+
* @param methodName - The name of the method where the error occurred.
|
|
44
|
+
* @param moduleName - The name of the module where the error occurred.
|
|
45
|
+
* @returns AugmentedError containing structured error details on err.data for metrics and logging
|
|
46
|
+
* @public
|
|
47
|
+
* @example
|
|
48
|
+
* const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');
|
|
49
|
+
* throw taskError.error;
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
export declare const generateTaskErrorObject: (error: any, methodName: string, moduleName: string) => AugmentedError;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an error details object suitable for use with the Err.Details class.
|
|
55
|
+
*
|
|
56
|
+
* @param errObj - The Webex request payload object.
|
|
57
|
+
* @returns An instance of Err.Details with the generic failure message and extracted details.
|
|
58
|
+
* @public
|
|
59
|
+
* @example
|
|
60
|
+
* const errDetails = createErrDetailsObject(webexRequestPayload);
|
|
61
|
+
* @ignore
|
|
62
|
+
*/
|
|
63
|
+
export declare const createErrDetailsObject: (errObj: WebexRequestPayload) => Err.Details<"Service.reqs.generic.failure">;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the consulted agent ID from the media object by finding the agent
|
|
66
|
+
* in the consult media participants (excluding the current agent).
|
|
67
|
+
*
|
|
68
|
+
* @param media - The media object from the interaction
|
|
69
|
+
* @param agentId - The current agent's ID to exclude from the search
|
|
70
|
+
* @returns The consulted agent ID, or empty string if none found
|
|
71
|
+
*/
|
|
72
|
+
export declare const getConsultedAgentId: (media: Interaction['media'], agentId: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the destination agent ID for CBT (Capacity Based Team) scenarios.
|
|
75
|
+
* CBT refers to teams created in Control Hub with capacity-based routing
|
|
76
|
+
* (as opposed to agent-based routing). This handles cases where the consulted
|
|
77
|
+
* participant is not directly in participants but can be found by matching
|
|
78
|
+
* the dial number (dn).
|
|
79
|
+
*
|
|
80
|
+
* @param interaction - The interaction object
|
|
81
|
+
* @param consultingAgent - The consulting agent identifier
|
|
82
|
+
* @returns The destination agent ID for CBT scenarios, or empty string if none found
|
|
83
|
+
*/
|
|
84
|
+
export declare const getDestAgentIdForCBT: (interaction: Interaction, consultingAgent: string) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Calculates the destination agent ID for consult operations.
|
|
87
|
+
*
|
|
88
|
+
* @param interaction - The interaction object
|
|
89
|
+
* @param agentId - The current agent's ID
|
|
90
|
+
* @returns The destination agent ID
|
|
91
|
+
*/
|
|
92
|
+
export declare const calculateDestAgentId: (interaction: Interaction, agentId: string) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Calculates the destination agent ID for fetching destination type.
|
|
95
|
+
*
|
|
96
|
+
* @param interaction - The interaction object
|
|
97
|
+
* @param agentId - The current agent's ID
|
|
98
|
+
* @returns The destination agent ID for determining destination type
|
|
99
|
+
*/
|
|
100
|
+
export declare const calculateDestType: (interaction: Interaction, agentId: string) => string;
|
|
101
|
+
export declare const deriveConsultTransferDestinationType: (taskData?: TaskData) => ConsultTransferPayLoad['destinationType'];
|
|
@@ -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,65 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Creates a request function for an API call with parameters
|
|
11
|
+
* @param c - The configuration for the request
|
|
12
|
+
* @returns A function that makes the API request
|
|
13
|
+
*/
|
|
14
|
+
req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a request function for an API call with no parameters
|
|
17
|
+
* @param c - The configuration for the request
|
|
18
|
+
* @returns A function that makes the API request
|
|
19
|
+
*/
|
|
20
|
+
reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes>;
|
|
21
|
+
/**
|
|
22
|
+
* Makes an API request
|
|
23
|
+
* @param c - The request configuration
|
|
24
|
+
* @param cbRes - The callback for the response
|
|
25
|
+
* @returns A promise that resolves with the response or rejects with an error
|
|
26
|
+
*/
|
|
27
|
+
private makeAPIRequest;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a promise for an API request
|
|
30
|
+
* @param c - The request configuration
|
|
31
|
+
* @param cbRes - The callback for the response
|
|
32
|
+
* @returns A promise that resolves with the response or rejects with an error
|
|
33
|
+
*/
|
|
34
|
+
private createPromise;
|
|
35
|
+
/**
|
|
36
|
+
* Converts a bind object to a string representation
|
|
37
|
+
* @param bind - The bind object to convert
|
|
38
|
+
* @returns A string representation of the bind object
|
|
39
|
+
*/
|
|
40
|
+
private bindPrint;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a message matches a bind object
|
|
43
|
+
* @param bind - The bind object to check against
|
|
44
|
+
* @param msg - The message to check
|
|
45
|
+
* @returns True if the message matches the bind object, false otherwise
|
|
46
|
+
*/
|
|
47
|
+
private bindCheck;
|
|
48
|
+
/**
|
|
49
|
+
* Checks type-dependent field conditions defined in __typeMap.
|
|
50
|
+
* @param typeMap - The type map to check against
|
|
51
|
+
* @param msg - The message to check
|
|
52
|
+
* @returns True if the message matches the type map, false otherwise
|
|
53
|
+
* The typeMap has the shape:
|
|
54
|
+
* { typeField: "type", conditions: { EventA: { field: value }, EventB: { field: value } } }
|
|
55
|
+
* It reads msg[typeField] to determine which condition set to apply,
|
|
56
|
+
* then verifies all fields in that condition match the message.
|
|
57
|
+
*/
|
|
58
|
+
private static typeMapCheck;
|
|
59
|
+
/**
|
|
60
|
+
* Handles incoming messages from the WebSocket (must be a lambda fn)
|
|
61
|
+
* @param msg - The message to handle
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
private readonly onMessage;
|
|
65
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
/**
|
|
57
|
+
* Constants for participant types, destination types, and interaction states
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
export declare const PARTICIPANT_TYPES: {
|
|
61
|
+
/** Participant type for Entry Point Dial Number */
|
|
62
|
+
EP_DN: string;
|
|
63
|
+
/** Participant type for dial number */
|
|
64
|
+
DN: string;
|
|
65
|
+
/** Participant type for Agent */
|
|
66
|
+
AGENT: string;
|
|
67
|
+
};
|
|
68
|
+
/** Interaction state for consultation */
|
|
69
|
+
export declare const STATE_CONSULT = "consult";
|
|
70
|
+
export declare const METHODS: {
|
|
71
|
+
REQUEST: string;
|
|
72
|
+
UPLOAD_LOGS: string;
|
|
73
|
+
GET_ERROR_DETAILS: string;
|
|
74
|
+
GET_COMMON_ERROR_DETAILS: string;
|
|
75
|
+
CREATE_ERR_DETAILS_OBJECT: string;
|
|
76
|
+
REQ: string;
|
|
77
|
+
REQ_EMPTY: string;
|
|
78
|
+
MAKE_API_REQUEST: string;
|
|
79
|
+
CREATE_PROMISE: string;
|
|
80
|
+
BIND_PRINT: string;
|
|
81
|
+
BIND_CHECK: string;
|
|
82
|
+
ON_MESSAGE: string;
|
|
83
|
+
INIT_WEB_SOCKET: string;
|
|
84
|
+
CLOSE: string;
|
|
85
|
+
HANDLE_CONNECTION_LOST: string;
|
|
86
|
+
REGISTER: string;
|
|
87
|
+
CONNECT: string;
|
|
88
|
+
WEB_SOCKET_ON_CLOSE_HANDLER: string;
|
|
89
|
+
SETUP_EVENT_LISTENERS: string;
|
|
90
|
+
DISPATCH_CONNECTION_EVENT: string;
|
|
91
|
+
CS_HANDLE_CONNECTION_LOST: string;
|
|
92
|
+
CLEAR_TIMER_ON_RESTORE_FAILED: string;
|
|
93
|
+
HANDLE_RESTORE_FAILED: string;
|
|
94
|
+
UPDATE_CONNECTION_DATA: string;
|
|
95
|
+
SET_CONNECTION_PROP: string;
|
|
96
|
+
ON_PING: string;
|
|
97
|
+
HANDLE_SOCKET_CLOSE: string;
|
|
98
|
+
ON_SOCKET_CLOSE: string;
|
|
99
|
+
};
|
|
@@ -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";
|