ysyt-agent-sdk 1.0.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/README.md +3 -0
- package/dist/css/ysyt-agent-sdk.css +1 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/src/core/api-client.d.ts +20 -0
- package/dist/src/core/components/my-input.d.ts +15 -0
- package/dist/src/core/components/my-message.d.ts +16 -0
- package/dist/src/core/components/my-modal-wrapper.d.ts +12 -0
- package/dist/src/core/components/my-phone-dialer.d.ts +15 -0
- package/dist/src/core/components/my-popover.d.ts +19 -0
- package/dist/src/core/components/my-select.d.ts +28 -0
- package/dist/src/core/components/my-tooltip.d.ts +15 -0
- package/dist/src/core/components/select-option.d.ts +6 -0
- package/dist/src/core/components/timer-component.d.ts +14 -0
- package/dist/src/core/phone-view.d.ts +57 -0
- package/dist/src/core/sip-client.d.ts +96 -0
- package/dist/src/core/ws-client.d.ts +10 -0
- package/dist/src/index.d.ts +63 -0
- package/dist/src/internal/_internalStore.d.ts +15 -0
- package/dist/src/store/call-info-store.d.ts +19 -0
- package/dist/src/store/event-bus.d.ts +9 -0
- package/dist/src/store/event-center.d.ts +47 -0
- package/dist/src/store/network-info-store.d.ts +10 -0
- package/dist/src/store/reactive-store.d.ts +24 -0
- package/dist/src/types/Enum.d.ts +92 -0
- package/dist/src/types/event.d.ts +35 -0
- package/dist/src/types/index.d.ts +114 -0
- package/dist/src/utils/ReconnectingWebSocket.d.ts +28 -0
- package/dist/src/utils/global.d.ts +16 -0
- package/dist/src/utils/http.d.ts +18 -0
- package/dist/src/utils/notification-util.d.ts +22 -0
- package/dist/src/utils/phone-style-config.d.ts +11 -0
- package/dist/src/utils/request.d.ts +16 -0
- package/dist/tsconfig.json +19 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/ysyt-agent-sdk.cjs.js +777 -0
- package/dist/ysyt-agent-sdk.esm.js +777 -0
- package/dist/ysyt-agent-sdk.umd.js +777 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@font-face{font-family:ysyt;src:url(../fonts/iconfont.woff2?t=1750839875481) format("woff2"),url(../fonts/iconfont.woff?t=1750839875481) format("woff"),url(../fonts/iconfont.ttf?t=1750839875481) format("truetype")}.ysyt{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:ysyt,serif!important;font-size:18px;font-style:normal}.icon-shouji:before{content:"\e692"}.icon-20gl-phoneSip:before{content:"\e924"}.icon-dianhua:before{content:"\e842"}.icon-quxiao:before{content:"\e676"}.icon-jieting:before{content:"\e60a"}.icon-boda:before{content:"\e679"}.icon-kaishi:before{content:"\e800"}.icon-guaji:before{content:"\e732"}.icon-manyidu:before{content:"\e600"}.icon-zixun:before{content:"\e71f"}.icon-zanting:before{content:"\ea81"}.icon-zhuanjie1:before{content:"\e601"}.icon-microphone:before{content:"\e661"}.icon-guanbimaikefeng:before{content:"\e603"}.icon-manglu:before{content:"\e65d"}.icon-shang:before{content:"\e60f"}.icon-xia:before{content:"\e64c"}.icon-kongxian:before{content:"\ed94"}#ysyt-body{display:flex;min-width:580px}.ysyt-phone-body{align-items:center;border-radius:30px 10px 0 30px;display:flex;height:30px;padding:5px 15px;user-select:none}.ysyt-phone-body .ysyt-title{color:#fff;cursor:pointer;font-size:14px;padding-right:10px;position:relative;width:100px}.ysyt-phone-body .select-icon{color:#fff;display:none;font-size:10px;left:calc(50% - 4px);position:absolute;top:100%;z-index:101}.ysyt-select{background:#fff;border-radius:4px;box-shadow:0 4px 8px rgba(0,0,0,.1);height:0;overflow:hidden;position:absolute;top:calc(100% + 8px);transition:height .1s ease-in;width:100%;z-index:100}.ysyt-select-body{position:relative}.ysyt-select-body>div{color:rgba(0,0,0,.6);padding:5px 4px;text-align:center}.ysyt-select-body>div:hover{background:#ecf5ff;color:#2b96ea}.ysyt-action-body{align-items:center;background:#fff;color:#3356ec;display:flex;font-size:25px;gap:0 10px;padding:0 10px}.ysyt-action-body>*{cursor:pointer}.content-call-key{color:rgba(0,0,0,.6);font-size:16px;padding:10px;width:250px}.content-call-key>my-input::part(wrapper){--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06);border:none;border-radius:30px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:25px;width:220px}.content-call-key>my-input::part(wrapper-input){text-align:center}#wifi-body>img{width:18px}.network-body{color:rgba(0,0,0,.7);font-size:12px;padding:5px 10px}.network-body>div{align-items:center;display:flex;margin-bottom:5px}.network-body>div>div{color:#000;width:50px}#ysyt-devices-body{align-items:center;display:flex;margin-right:15px;width:130px}.my-icon{font-size:22px}.agent-list-item{align-items:center;display:flex;justify-content:space-between;padding:10px}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AgentItemType, AgentStateDataType, DeviceType, RequestBodyType, StateType } from '@/types';
|
|
2
|
+
export declare class ApiClient {
|
|
3
|
+
private roleData;
|
|
4
|
+
/**
|
|
5
|
+
* 对外内
|
|
6
|
+
*/
|
|
7
|
+
_agentLogin(agentNo: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* 对外
|
|
10
|
+
*/
|
|
11
|
+
changeDevice(params: RequestBodyType<{
|
|
12
|
+
device: DeviceType;
|
|
13
|
+
}>): Promise<void>;
|
|
14
|
+
changeState(params: RequestBodyType<{
|
|
15
|
+
state: StateType;
|
|
16
|
+
state_name: string;
|
|
17
|
+
}>): Promise<void>;
|
|
18
|
+
getIdleAgentList(params: RequestBodyType<any, AgentItemType[]>): Promise<void>;
|
|
19
|
+
getAgentState(params: RequestBodyType<any, AgentStateDataType>): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyInput extends LitElement {
|
|
3
|
+
placeholder: string;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
allowClear: boolean;
|
|
6
|
+
value: string;
|
|
7
|
+
onPressEnter?: (value: string) => void;
|
|
8
|
+
private focused;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
private onInput;
|
|
11
|
+
clear(): void;
|
|
12
|
+
private clearInput;
|
|
13
|
+
private onKeyDown;
|
|
14
|
+
render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyMessage extends LitElement {
|
|
3
|
+
type: 'success' | 'error' | 'info' | 'warning' | 'loading';
|
|
4
|
+
content: string;
|
|
5
|
+
duration: number;
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
render(): import("lit").TemplateResult<1>;
|
|
9
|
+
}
|
|
10
|
+
export declare const message: {
|
|
11
|
+
success: (content: string, duration?: number) => void;
|
|
12
|
+
error: (content: string, duration?: number) => void;
|
|
13
|
+
info: (content: string, duration?: number) => void;
|
|
14
|
+
warning: (content: string, duration?: number) => void;
|
|
15
|
+
loading: (content: string, duration?: number) => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyModalWrapper extends LitElement {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
showFooter: boolean;
|
|
5
|
+
width: string;
|
|
6
|
+
title: string;
|
|
7
|
+
static styles: import("lit").CSSResult;
|
|
8
|
+
render(): import("lit").TemplateResult<1>;
|
|
9
|
+
private _onCancel;
|
|
10
|
+
private _onOk;
|
|
11
|
+
private _onMaskClick;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyPhoneDialer extends LitElement {
|
|
3
|
+
private isDialerVisible;
|
|
4
|
+
private inputValue;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
private keys;
|
|
7
|
+
protected updated(changedProps: Map<string | number | symbol, unknown>): void;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
private handleDocumentClick;
|
|
11
|
+
private handleKeyClick;
|
|
12
|
+
private handleBackspace;
|
|
13
|
+
private handleValueSize;
|
|
14
|
+
render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyPopover extends LitElement {
|
|
3
|
+
placement: 'top' | 'bottom' | 'left' | 'right';
|
|
4
|
+
triggerType: 'click' | 'hover';
|
|
5
|
+
visible: boolean;
|
|
6
|
+
private triggerEl;
|
|
7
|
+
private popoverEl;
|
|
8
|
+
private hideTimer;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
firstUpdated(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
private togglePopover;
|
|
13
|
+
private showPopover;
|
|
14
|
+
private hidePopoverDelayed;
|
|
15
|
+
private clearHideTimer;
|
|
16
|
+
private onOutsideClick;
|
|
17
|
+
private updatePosition;
|
|
18
|
+
render(): import("lit").TemplateResult<1>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export declare class MySelect extends LitElement {
|
|
3
|
+
placeholder: string;
|
|
4
|
+
value: string | null;
|
|
5
|
+
width: string | null;
|
|
6
|
+
/** 是否展开菜单 */
|
|
7
|
+
private open;
|
|
8
|
+
/** 控制菜单动画显示 */
|
|
9
|
+
private animating;
|
|
10
|
+
/** 选中内容的克隆节点 */
|
|
11
|
+
private selectedContent;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
disconnectedCallback(): void;
|
|
15
|
+
handleOutsideClick: (e: MouseEvent) => void;
|
|
16
|
+
toggleDropdown(): void;
|
|
17
|
+
openDropdown(): void;
|
|
18
|
+
closeDropdown(): void;
|
|
19
|
+
handleOptionClick(e: MouseEvent, optionEl: HTMLElement): void;
|
|
20
|
+
/** 组件属性变化时,更新选中内容 */
|
|
21
|
+
updated(changedProps: Map<string, unknown>): void;
|
|
22
|
+
/** 根据当前 value 找对应选项内容 clone */
|
|
23
|
+
private updateSelectedContent;
|
|
24
|
+
/** 渲染选中内容,如果没有则渲染 placeholder */
|
|
25
|
+
private renderSelectedLabel;
|
|
26
|
+
renderSelectOptions(): TemplateResult<1>[];
|
|
27
|
+
render(): TemplateResult<1>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class MyTooltip extends LitElement {
|
|
3
|
+
content: string;
|
|
4
|
+
placement: 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
delay: number;
|
|
6
|
+
color: string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
slotElement: HTMLSlotElement;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
timeoutId?: number;
|
|
11
|
+
firstUpdated(): void;
|
|
12
|
+
showTooltip: () => void;
|
|
13
|
+
hideTooltip: () => void;
|
|
14
|
+
render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class TimerComponent extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
private intervalId;
|
|
5
|
+
private elapsedSeconds;
|
|
6
|
+
private displayTime;
|
|
7
|
+
constructor();
|
|
8
|
+
private formatTime;
|
|
9
|
+
private updateTime;
|
|
10
|
+
start(): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
render(): import("lit").TemplateResult<1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { StatusType } from '@/types';
|
|
2
|
+
import YSYTAgentSdk from '@/index';
|
|
3
|
+
import '@/assets/css/iconfont.css';
|
|
4
|
+
import '@/assets/css/index.css';
|
|
5
|
+
import './components/timer-component.ts';
|
|
6
|
+
import './components/my-tooltip.ts';
|
|
7
|
+
import './components/my-popover.ts';
|
|
8
|
+
import './components/my-input.ts';
|
|
9
|
+
import './components/my-select';
|
|
10
|
+
import './components/my-phone-dialer';
|
|
11
|
+
import './components/my-modal-wrapper';
|
|
12
|
+
interface Props {
|
|
13
|
+
container: HTMLElement;
|
|
14
|
+
rttHTML?: HTMLElement;
|
|
15
|
+
statusParams: StatusType;
|
|
16
|
+
}
|
|
17
|
+
export declare class PhoneView {
|
|
18
|
+
private VoiceSDKInstance;
|
|
19
|
+
private readonly container;
|
|
20
|
+
private readonly rttHTML?;
|
|
21
|
+
private apiClient;
|
|
22
|
+
private isOpenSelect;
|
|
23
|
+
private statusParams;
|
|
24
|
+
private consultShow;
|
|
25
|
+
private modalRoot;
|
|
26
|
+
private agentStateData;
|
|
27
|
+
constructor({ container, rttHTML, statusParams }: Props, VoiceSDKInstance: YSYTAgentSdk);
|
|
28
|
+
private eventHandle;
|
|
29
|
+
private handleNetworkInfoChange;
|
|
30
|
+
private handleCallInfoChange;
|
|
31
|
+
private getAgentStateList;
|
|
32
|
+
private hiddenSelect;
|
|
33
|
+
private toggle;
|
|
34
|
+
private changeStatus;
|
|
35
|
+
private onChangeDevices;
|
|
36
|
+
private ruleCall;
|
|
37
|
+
private onCall;
|
|
38
|
+
private onKeyPress;
|
|
39
|
+
private renderCallPopover;
|
|
40
|
+
private renderHangup;
|
|
41
|
+
private renderDialer;
|
|
42
|
+
private renderHold;
|
|
43
|
+
private renderUnhold;
|
|
44
|
+
private renderMute;
|
|
45
|
+
private renderUnmute;
|
|
46
|
+
private renderSatisfaction;
|
|
47
|
+
private renderConsult;
|
|
48
|
+
private renderTransfer;
|
|
49
|
+
private renderConsultTransfer;
|
|
50
|
+
private renderAnswer;
|
|
51
|
+
private renderReject;
|
|
52
|
+
private renderConsultModalToBody;
|
|
53
|
+
private getActionConfigs;
|
|
54
|
+
private render;
|
|
55
|
+
private renderRtt;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { RtcEventDataType, RtcEventDataTypes } from '@/types/event';
|
|
2
|
+
/**
|
|
3
|
+
* SIP客户端核心类
|
|
4
|
+
*/
|
|
5
|
+
export declare class SIPClient {
|
|
6
|
+
private config;
|
|
7
|
+
private eventCallback;
|
|
8
|
+
private userAgent;
|
|
9
|
+
private registerer;
|
|
10
|
+
private activeSession;
|
|
11
|
+
private callTimeoutTimer;
|
|
12
|
+
private incomingInvitation;
|
|
13
|
+
private reconnectAttempts;
|
|
14
|
+
private maxReconnectAttempts;
|
|
15
|
+
private reconnectTimer;
|
|
16
|
+
private isOffline;
|
|
17
|
+
private autoAnswerTimer;
|
|
18
|
+
constructor(config: {
|
|
19
|
+
webSocket: string;
|
|
20
|
+
server: string;
|
|
21
|
+
user: string;
|
|
22
|
+
password: string;
|
|
23
|
+
callTimeout?: number;
|
|
24
|
+
}, eventCallback: (event: RtcEventDataType<RtcEventDataTypes>) => void);
|
|
25
|
+
private handleMessage;
|
|
26
|
+
private handleNetworkInfoChange;
|
|
27
|
+
private handleOffline;
|
|
28
|
+
private handleOnline;
|
|
29
|
+
/**
|
|
30
|
+
* 启动 SIP 客户端(创建 userAgent 实例、注册)
|
|
31
|
+
*/
|
|
32
|
+
start(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* 设置 SIP 事件监听(连接状态、来电等)
|
|
35
|
+
* - TransportState: 连接/断开
|
|
36
|
+
* - RegistererState: 注册/注销/过期...
|
|
37
|
+
* - 来电 Invite
|
|
38
|
+
*/
|
|
39
|
+
private setupEventListeners;
|
|
40
|
+
/**
|
|
41
|
+
* 注册当前用户
|
|
42
|
+
*/
|
|
43
|
+
private register;
|
|
44
|
+
private attachRemoteAudio;
|
|
45
|
+
/**
|
|
46
|
+
* 监听并处理通话状态变化(通话建立/结束)
|
|
47
|
+
* - Establishing: 进展(180/183)
|
|
48
|
+
* - Established: 接通(200 OK)
|
|
49
|
+
* - Terminated: 结束(BYE/拒绝/超时)
|
|
50
|
+
*/
|
|
51
|
+
private handleSessionState;
|
|
52
|
+
/**
|
|
53
|
+
* 来电处理逻辑(监听状态即可,不需要主动作出回应)
|
|
54
|
+
*/
|
|
55
|
+
private handleIncomingCall;
|
|
56
|
+
/**
|
|
57
|
+
* 发起呼叫
|
|
58
|
+
*/
|
|
59
|
+
makeCall(target: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* 接听来电
|
|
62
|
+
*/
|
|
63
|
+
answerCall(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* 拒绝来电
|
|
66
|
+
*/
|
|
67
|
+
rejectInCall(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* 发送 DTMF 按键音
|
|
70
|
+
*/
|
|
71
|
+
sendDTMF(tone: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* 挂断当前通话
|
|
74
|
+
*/
|
|
75
|
+
hangup(): Promise<void>;
|
|
76
|
+
rejectOutCall(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* 销毁 SIP 客户端(释放资源、注销、挂断)
|
|
79
|
+
*/
|
|
80
|
+
destroy(): Promise<void>;
|
|
81
|
+
private reconnect;
|
|
82
|
+
/**
|
|
83
|
+
* 获取当前通话的网络统计信息
|
|
84
|
+
* 返回如:RTT、抖动、丢包、码率、编码器等
|
|
85
|
+
*/
|
|
86
|
+
getNetworkStats(): Promise<{
|
|
87
|
+
rtt?: number;
|
|
88
|
+
jitter?: number;
|
|
89
|
+
packetsLost?: number;
|
|
90
|
+
packetsReceived?: number;
|
|
91
|
+
packetsSent?: number;
|
|
92
|
+
sendBitrate?: number;
|
|
93
|
+
recvBitrate?: number;
|
|
94
|
+
codec?: string;
|
|
95
|
+
} | null>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AgentItemType, AgentStateDataType, InitInfoType, RequestBodyType } from '@/types';
|
|
2
|
+
import { Events } from '@/store/event-center';
|
|
3
|
+
/**
|
|
4
|
+
* 语音SDK主类
|
|
5
|
+
* 提供统一的接口封装底层SIP和WebSocket实现
|
|
6
|
+
*/
|
|
7
|
+
declare class YSYTAgentSdk {
|
|
8
|
+
#private;
|
|
9
|
+
constructor();
|
|
10
|
+
initWebRtc(): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* 初始化SDK
|
|
13
|
+
* @param actionNodeParams
|
|
14
|
+
* @param url
|
|
15
|
+
* @param appKey
|
|
16
|
+
* @param appSecret
|
|
17
|
+
* @param agentNo 坐席工号
|
|
18
|
+
* @param enableBrowserAlert 是否开启浏览器通知
|
|
19
|
+
*/
|
|
20
|
+
init({ actionNodeParams, url, appKey, appSecret, agentNo, enableBrowserAlert }: InitInfoType): Promise<void>;
|
|
21
|
+
on<K extends keyof Events>(event: K, listener: (msg: Events[K]) => void): this;
|
|
22
|
+
off<K extends keyof Events>(event: K, listener: (msg: Events[K]) => void): void;
|
|
23
|
+
offAll(): void;
|
|
24
|
+
destroyRtc(): Promise<void>;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
get call_api(): {
|
|
27
|
+
answerCall?: undefined;
|
|
28
|
+
makeCall?: undefined;
|
|
29
|
+
cancelCall?: undefined;
|
|
30
|
+
hangup?: undefined;
|
|
31
|
+
sendDTMF?: undefined;
|
|
32
|
+
holdCall?: undefined;
|
|
33
|
+
unholdCall?: undefined;
|
|
34
|
+
consultCall?: undefined;
|
|
35
|
+
consultTransfer?: undefined;
|
|
36
|
+
mute?: undefined;
|
|
37
|
+
unmute?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
answerCall: any;
|
|
40
|
+
makeCall: any;
|
|
41
|
+
cancelCall: any;
|
|
42
|
+
hangup: any;
|
|
43
|
+
sendDTMF: any;
|
|
44
|
+
holdCall: any;
|
|
45
|
+
unholdCall: any;
|
|
46
|
+
consultCall: (agent_no: string) => Promise<void>;
|
|
47
|
+
consultTransfer: any;
|
|
48
|
+
mute: any;
|
|
49
|
+
unmute: any;
|
|
50
|
+
};
|
|
51
|
+
get agent_api(): {
|
|
52
|
+
changeDevice?: undefined;
|
|
53
|
+
changeState?: undefined;
|
|
54
|
+
getIdleAgentList?: undefined;
|
|
55
|
+
getAgentState?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
changeDevice: any;
|
|
58
|
+
changeState: any;
|
|
59
|
+
getIdleAgentList: (params: RequestBodyType<unknown, AgentItemType[]>) => Promise<void>;
|
|
60
|
+
getAgentState: (params: RequestBodyType<unknown, AgentStateDataType>) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export default YSYTAgentSdk;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AgentObjectType } from '@/types';
|
|
2
|
+
import { AgentStatus } from '@/types/Enum';
|
|
3
|
+
type InternalState = {
|
|
4
|
+
agentInfo: AgentObjectType;
|
|
5
|
+
isRtcReconnecting: boolean;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
enableBrowserAlert: boolean;
|
|
8
|
+
autoStateTimer: any;
|
|
9
|
+
stateObject?: {
|
|
10
|
+
state: AgentStatus;
|
|
11
|
+
state_name: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare const _internalStore: InternalState;
|
|
15
|
+
export default _internalStore;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CallInfoType } from '@/types';
|
|
2
|
+
import { ReactiveStore } from './reactive-store';
|
|
3
|
+
declare class CallInfoStore extends ReactiveStore<CallInfoType> {
|
|
4
|
+
updateIsCalling(isCalling: boolean): void;
|
|
5
|
+
updateDirection(direction: CallInfoType['direction']): void;
|
|
6
|
+
updateOutCallIsAnswer(outCallIsAnswer: boolean): void;
|
|
7
|
+
updateIsHold(isHold: boolean): void;
|
|
8
|
+
updateDisplayText(displayText: string): void;
|
|
9
|
+
updateActionConfigs(actionConfigs: CallInfoType['actionConfigs']): void;
|
|
10
|
+
updateConsultIsAnswer(consultIsAnswer: boolean): void;
|
|
11
|
+
updateIsMuted(isMuted: boolean): void;
|
|
12
|
+
updateIncomingIsAnswer(incomingIsAnswer: boolean): void;
|
|
13
|
+
updateAnswerDevice(answerDevice: CallInfoType['answerDevice']): void;
|
|
14
|
+
reset(): void;
|
|
15
|
+
getCallInfo(): CallInfoType;
|
|
16
|
+
get<K extends keyof CallInfoType>(key: K): CallInfoType[K];
|
|
17
|
+
}
|
|
18
|
+
export declare const callInfoStore: CallInfoStore;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type EventHandler = (...args: any[]) => void;
|
|
2
|
+
export declare class EventBus {
|
|
3
|
+
private events;
|
|
4
|
+
on(event: string, handler: EventHandler): void;
|
|
5
|
+
off(event: string, handler: EventHandler): void;
|
|
6
|
+
emit(event: string, ...args: any[]): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const eventBus: EventBus;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CallSipCallEvent, WebRtcCallSipEventEnum, EventName } from '@/types/Enum';
|
|
2
|
+
import { AgentStateType, ConsultInComingType, DTMFDataType, NotificationClickType, RtcErrorDataType, RtcEventDataType, RtcEventDataTypes } from '@/types/event';
|
|
3
|
+
import { ActionType, DeviceType } from '@/types';
|
|
4
|
+
type EventObject<T> = {
|
|
5
|
+
event: keyof Events;
|
|
6
|
+
data: T;
|
|
7
|
+
};
|
|
8
|
+
export interface Events {
|
|
9
|
+
[WebRtcCallSipEventEnum.WEB_RTC_CONNECTING]: unknown;
|
|
10
|
+
[WebRtcCallSipEventEnum.WEB_RTC_CONNECTED]: unknown;
|
|
11
|
+
[WebRtcCallSipEventEnum.WEB_RTC_DISCONNECTING]: unknown;
|
|
12
|
+
[WebRtcCallSipEventEnum.WEB_RTC_DISCONNECTED]: unknown;
|
|
13
|
+
[WebRtcCallSipEventEnum.WEB_RTC_REGISTERED]: unknown;
|
|
14
|
+
[WebRtcCallSipEventEnum.WEB_RTC_UNREGISTERED]: unknown;
|
|
15
|
+
[WebRtcCallSipEventEnum.WEB_RTC_TERMINATED]: unknown;
|
|
16
|
+
[WebRtcCallSipEventEnum.WEB_RTC_REGISTER_FAILED]: EventObject<RtcEventDataType<any>['data']>;
|
|
17
|
+
[WebRtcCallSipEventEnum.WEB_RTC_ANSWER_FAILED]: EventObject<RtcEventDataType<RtcErrorDataType>['data']>;
|
|
18
|
+
[WebRtcCallSipEventEnum.WEB_RTC_SEND_DTMF]: EventObject<RtcEventDataType<DTMFDataType>['data']>;
|
|
19
|
+
[EventName.EVENT_ALL]: EventObject<RtcEventDataType<RtcEventDataTypes>['data']>;
|
|
20
|
+
[CallSipCallEvent.OUT_INCOMING_CALL]: unknown;
|
|
21
|
+
[CallSipCallEvent.MUTE_SUCCESS]: unknown;
|
|
22
|
+
[CallSipCallEvent.MUTE_FAILED]: string;
|
|
23
|
+
[CallSipCallEvent.UNMUTE_SUCCESS]: unknown;
|
|
24
|
+
[CallSipCallEvent.UNMUTE_FAILED]: string;
|
|
25
|
+
[CallSipCallEvent.CONSULT_TRANSFER_SUCCESS]: unknown;
|
|
26
|
+
[CallSipCallEvent.CONSULT_TRANSFER_FAILED]: string;
|
|
27
|
+
[CallSipCallEvent.CONSULT_TRANSFER_OFF_HOOK]: unknown;
|
|
28
|
+
[EventName.NOTIFICATION_CLICK]: NotificationClickType;
|
|
29
|
+
[CallSipCallEvent.CONSULT_INCOMING]: RtcEventDataType<ConsultInComingType>['data'];
|
|
30
|
+
[CallSipCallEvent.AGENT_STATE]: AgentStateType;
|
|
31
|
+
[EventName.UPDATE_ANSWER_DEVICE]: DeviceType;
|
|
32
|
+
[EventName.PHONE_BAR_OPERATION]: Array<ActionType>;
|
|
33
|
+
[CallSipCallEvent.INCOMING_CALL]: {
|
|
34
|
+
customer_phone: string;
|
|
35
|
+
};
|
|
36
|
+
[CallSipCallEvent.INCOMING_CALL_OFF_HOOK]: unknown;
|
|
37
|
+
[CallSipCallEvent.INCOMING_CALL_END]: unknown;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
[key: symbol]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export declare const EventCenter: {
|
|
42
|
+
on<K extends keyof Events>(event: K, handler: (data: Events[K]) => void): void;
|
|
43
|
+
off<K_1 extends keyof Events>(event: K_1, handler: (data: Events[K_1]) => void): void;
|
|
44
|
+
emit<K_2 extends keyof Events>(event: K_2, data?: Events[K_2]): void;
|
|
45
|
+
clearAllListeners(): void;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactiveStore } from './reactive-store';
|
|
2
|
+
import { RttObjectType } from '@/types';
|
|
3
|
+
export type NetworkInfoStoreType = {
|
|
4
|
+
rttObject: RttObjectType;
|
|
5
|
+
};
|
|
6
|
+
declare class NetworkInfoStore extends ReactiveStore<NetworkInfoStoreType> {
|
|
7
|
+
updateRttObject(rttObject: RttObjectType): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const networkInfoStore: NetworkInfoStore;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Listener<T> = (state: T) => void;
|
|
2
|
+
export declare class ReactiveStore<T extends Record<string, any>> {
|
|
3
|
+
private listeners;
|
|
4
|
+
private keyListeners;
|
|
5
|
+
protected data: T;
|
|
6
|
+
private proxy;
|
|
7
|
+
constructor(initialState: T);
|
|
8
|
+
getState(): T;
|
|
9
|
+
/**
|
|
10
|
+
* 推荐使用的统一更新方法,支持批量更新、保证只触发一次 notify
|
|
11
|
+
*/
|
|
12
|
+
setState(partial: Partial<T>): void;
|
|
13
|
+
/**
|
|
14
|
+
* 订阅整个 state 的变化
|
|
15
|
+
*/
|
|
16
|
+
subscribe(listener: Listener<T>): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* 订阅单个字段的变化
|
|
19
|
+
*/
|
|
20
|
+
subscribeKey<K extends keyof T>(key: K, callback: (value: T[K]) => void): () => void;
|
|
21
|
+
private notify;
|
|
22
|
+
private notifyKey;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare enum AgentStatus {
|
|
2
|
+
IDLE = 1,
|
|
3
|
+
BUSY = 2,
|
|
4
|
+
RINGING = 3,
|
|
5
|
+
OFFLINE = 0
|
|
6
|
+
}
|
|
7
|
+
export declare enum DirectionEnum {
|
|
8
|
+
OUTGOING = "outgoing",
|
|
9
|
+
INCOMING = "incoming",
|
|
10
|
+
CONSULT = "consult"
|
|
11
|
+
}
|
|
12
|
+
export declare enum WebRtcCallSipEventEnum {
|
|
13
|
+
WEB_RTC_CONNECTING = "connecting",
|
|
14
|
+
WEB_RTC_CONNECTED = "connected",
|
|
15
|
+
WEB_RTC_DISCONNECTING = "disconnecting",
|
|
16
|
+
WEB_RTC_DISCONNECTED = "disconnected",
|
|
17
|
+
WEB_RTC_REGISTERED = "registered",
|
|
18
|
+
WEB_RTC_UNREGISTERED = "unregistered",
|
|
19
|
+
WEB_RTC_TERMINATED = "terminated",
|
|
20
|
+
WEB_RTC_REGISTER_FAILED = "register_failed",
|
|
21
|
+
WEB_RTC_INCOMING_CALL = "incoming_call",
|
|
22
|
+
WEB_RTC_ANSWER_SUCCESS = "answer_success",
|
|
23
|
+
WEB_RTC_ANSWER_FAILED = "answer_failed",
|
|
24
|
+
WEB_RTC_CALL_ENDED = "call_ended",
|
|
25
|
+
OUTGOING_LADING = "outgoing_login",
|
|
26
|
+
INCOMING_LADING = "incoming_login",
|
|
27
|
+
WEB_RTC_SEND_DTMF = "send_dtmf"
|
|
28
|
+
}
|
|
29
|
+
export declare enum CallSipCallEvent {
|
|
30
|
+
OUT_INCOMING_CALL = "out_call_incoming_call",
|
|
31
|
+
OUT_FAILED = "out_call_failed",
|
|
32
|
+
OUT_RINGING = "out_call_ringing",
|
|
33
|
+
OUT_OFF_ANSWER = "out_call_answer",
|
|
34
|
+
OUT_HANGUP = "out_call_hangup",
|
|
35
|
+
CONSULT_RINGING = "consult_ringing",
|
|
36
|
+
CONSULT_OFF_HOOK = "consult_off_hook",
|
|
37
|
+
CONSULT_FAILED = "consult_failed",
|
|
38
|
+
CONSULT_INCOMING = "consult_incoming",
|
|
39
|
+
CONSULT_CALL_IN_SUCCESS = "consult_call_in_success",
|
|
40
|
+
OTHER_SIDE_CONSULT_HANGUP = "other_side_consult_hangup",
|
|
41
|
+
OUR_SIDE_CONSULT_HANGUP = "Our_side_consult_hangup",
|
|
42
|
+
AGENT_STATE = "agent_state",
|
|
43
|
+
MUTE_SUCCESS = "mute_success",
|
|
44
|
+
MUTE_FAILED = "mute_failed",
|
|
45
|
+
UNMUTE_SUCCESS = "unmute_success",
|
|
46
|
+
UNMUTE_FAILED = "unmute_failed",
|
|
47
|
+
CONSULT_TRANSFER_SUCCESS = "consult_transfer_success",
|
|
48
|
+
CONSULT_TRANSFER_FAILED = "consult_transfer_failed",
|
|
49
|
+
CONSULT_TRANSFER_OFF_HOOK = "consult_transfer_off_hook",
|
|
50
|
+
INCOMING_CALL = "incoming_call",
|
|
51
|
+
INCOMING_CALL_OFF_HOOK = "incoming_call_off_hook",
|
|
52
|
+
INCOMING_CALL_END = "incoming_call_end"
|
|
53
|
+
}
|
|
54
|
+
export declare enum WebsocketTypeEnum {
|
|
55
|
+
OUT_CALL = 100,
|
|
56
|
+
AGENT_STATE = 101,
|
|
57
|
+
OUT_CALL_INCOMING_CALL = 102,
|
|
58
|
+
OUT_CALL_RINGING = 103,
|
|
59
|
+
OUT_CALL_ANSWER = 104,
|
|
60
|
+
CALL_HOLD = 105,
|
|
61
|
+
CALL_UNHOLD = 106,
|
|
62
|
+
OUT_CALL_END = 107,
|
|
63
|
+
CONSULT_REQUEST = 108,
|
|
64
|
+
CONSULT_RINGING = 109,
|
|
65
|
+
CONSULT_ANSWER = 110,
|
|
66
|
+
CONSULT_FAIL = 111,
|
|
67
|
+
MUTE = 112,
|
|
68
|
+
UNMUTE = 113,
|
|
69
|
+
CONSULT_CALL_IN = 114,
|
|
70
|
+
CONSULT_CALL_IN_SUCCESS = 115,
|
|
71
|
+
CONSULT_TRANSFER = 116,
|
|
72
|
+
CONSULT_TRANSFER_FAILED = 118,
|
|
73
|
+
CONSULT_TRANSFER_OFF_HOOK = 117,
|
|
74
|
+
INCOMING_CALL = 119,
|
|
75
|
+
INCOMING_CALL_OFF_HOOK = 120,
|
|
76
|
+
INCOMING_CALL_END = 121
|
|
77
|
+
}
|
|
78
|
+
export declare enum EventName {
|
|
79
|
+
EVENT_ALL = "event_all",
|
|
80
|
+
NOTIFICATION_CLICK = "notification_click",
|
|
81
|
+
UPDATE_ANSWER_DEVICE = "update_answer_device",
|
|
82
|
+
PHONE_BAR_OPERATION = "phone_bar_operation"
|
|
83
|
+
}
|
|
84
|
+
export declare enum DisplayTextEnum {
|
|
85
|
+
RINGING = "\u5BA2\u6237\u632F\u94C3",
|
|
86
|
+
HOLD = "\u901A\u8BDD\u4FDD\u6301",
|
|
87
|
+
AGENT_RINGING = "\u632F\u94C3\u4E2D",
|
|
88
|
+
CALLING = "\u901A\u8BDD\u4E2D",
|
|
89
|
+
CONSULTING = "\u6B63\u5728\u54A8\u8BE2",
|
|
90
|
+
CONSULT_CALL_IN = "\u54A8\u8BE2\u6765\u7535",
|
|
91
|
+
INCOMING_CALL = "\u5BA2\u6237\u6765\u7535"
|
|
92
|
+
}
|