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.
Files changed (40) hide show
  1. package/README.md +3 -0
  2. package/dist/css/ysyt-agent-sdk.css +1 -0
  3. package/dist/fonts/iconfont.ttf +0 -0
  4. package/dist/fonts/iconfont.woff +0 -0
  5. package/dist/fonts/iconfont.woff2 +0 -0
  6. package/dist/src/core/api-client.d.ts +20 -0
  7. package/dist/src/core/components/my-input.d.ts +15 -0
  8. package/dist/src/core/components/my-message.d.ts +16 -0
  9. package/dist/src/core/components/my-modal-wrapper.d.ts +12 -0
  10. package/dist/src/core/components/my-phone-dialer.d.ts +15 -0
  11. package/dist/src/core/components/my-popover.d.ts +19 -0
  12. package/dist/src/core/components/my-select.d.ts +28 -0
  13. package/dist/src/core/components/my-tooltip.d.ts +15 -0
  14. package/dist/src/core/components/select-option.d.ts +6 -0
  15. package/dist/src/core/components/timer-component.d.ts +14 -0
  16. package/dist/src/core/phone-view.d.ts +57 -0
  17. package/dist/src/core/sip-client.d.ts +96 -0
  18. package/dist/src/core/ws-client.d.ts +10 -0
  19. package/dist/src/index.d.ts +63 -0
  20. package/dist/src/internal/_internalStore.d.ts +15 -0
  21. package/dist/src/store/call-info-store.d.ts +19 -0
  22. package/dist/src/store/event-bus.d.ts +9 -0
  23. package/dist/src/store/event-center.d.ts +47 -0
  24. package/dist/src/store/network-info-store.d.ts +10 -0
  25. package/dist/src/store/reactive-store.d.ts +24 -0
  26. package/dist/src/types/Enum.d.ts +92 -0
  27. package/dist/src/types/event.d.ts +35 -0
  28. package/dist/src/types/index.d.ts +114 -0
  29. package/dist/src/utils/ReconnectingWebSocket.d.ts +28 -0
  30. package/dist/src/utils/global.d.ts +16 -0
  31. package/dist/src/utils/http.d.ts +18 -0
  32. package/dist/src/utils/notification-util.d.ts +22 -0
  33. package/dist/src/utils/phone-style-config.d.ts +11 -0
  34. package/dist/src/utils/request.d.ts +16 -0
  35. package/dist/tsconfig.json +19 -0
  36. package/dist/vite.config.d.ts +2 -0
  37. package/dist/ysyt-agent-sdk.cjs.js +777 -0
  38. package/dist/ysyt-agent-sdk.esm.js +777 -0
  39. package/dist/ysyt-agent-sdk.umd.js +777 -0
  40. package/package.json +58 -0
@@ -0,0 +1,35 @@
1
+ import { CallSipCallEvent, WebRtcCallSipEventEnum } from '@/types/Enum';
2
+ import { StateType } from '@/types/index';
3
+ export type CallBackType = WebRtcCallSipEventEnum.WEB_RTC_CONNECTED | WebRtcCallSipEventEnum.WEB_RTC_DISCONNECTED | WebRtcCallSipEventEnum.WEB_RTC_CONNECTING | WebRtcCallSipEventEnum.WEB_RTC_DISCONNECTING | WebRtcCallSipEventEnum.WEB_RTC_REGISTERED | WebRtcCallSipEventEnum.WEB_RTC_UNREGISTERED | WebRtcCallSipEventEnum.WEB_RTC_REGISTER_FAILED | WebRtcCallSipEventEnum.WEB_RTC_TERMINATED | WebRtcCallSipEventEnum.WEB_RTC_ANSWER_FAILED | WebRtcCallSipEventEnum.WEB_RTC_SEND_DTMF | CallSipCallEvent.CONSULT_INCOMING | 'initial' | 'unknown' | 'error';
4
+ export type IncomingCallDataType = {
5
+ from: string;
6
+ };
7
+ export type OutgoingCallDataType = {
8
+ to: string;
9
+ };
10
+ export type RtcLoadingDataType = {
11
+ target: string;
12
+ };
13
+ export type RtcErrorDataType = {
14
+ message?: string;
15
+ detail?: any;
16
+ };
17
+ export type DTMFDataType = {
18
+ tone: string;
19
+ };
20
+ export type ConsultInComingType = {
21
+ agent_mane: string;
22
+ };
23
+ export type InComingType = {
24
+ customer_phone: string;
25
+ };
26
+ export type AgentStateType = {
27
+ state: StateType;
28
+ state_name: string;
29
+ };
30
+ export type NotificationClickType = ConsultInComingType | InComingType;
31
+ export type RtcEventDataTypes = IncomingCallDataType | OutgoingCallDataType | RtcLoadingDataType | RtcErrorDataType | DTMFDataType;
32
+ export interface RtcEventDataType<T> {
33
+ type: CallBackType;
34
+ data?: T;
35
+ }
@@ -0,0 +1,114 @@
1
+ import { AgentStatus, DirectionEnum } from '@/types/Enum';
2
+ export interface ResponseCodeType<T> {
3
+ code: number;
4
+ msg: string;
5
+ data?: T;
6
+ }
7
+ export interface RequestBodyType<B = any, R = any> {
8
+ success?: (params: ResponseCodeType<R>) => void;
9
+ data?: B;
10
+ }
11
+ export type RttObjectType = {
12
+ rtt?: number;
13
+ jitter?: number;
14
+ packetsLost?: number;
15
+ packetsReceived?: number;
16
+ packetsSent?: number;
17
+ sendBitrate?: number;
18
+ recvBitrate?: number;
19
+ codec?: string;
20
+ };
21
+ export interface CallInfoType {
22
+ isCalling: boolean;
23
+ direction: DirectionEnum.OUTGOING | DirectionEnum.INCOMING | DirectionEnum.CONSULT | null;
24
+ outCallIsAnswer: boolean;
25
+ consultIsAnswer: boolean;
26
+ incomingIsAnswer: boolean;
27
+ isHold: boolean;
28
+ displayText: string;
29
+ isMuted: boolean;
30
+ actionConfigs: ActionConfigsType;
31
+ answerDevice: DeviceType;
32
+ }
33
+ export interface InitInfoType {
34
+ url?: string;
35
+ appKey: string;
36
+ appSecret: string;
37
+ agentNo: string;
38
+ enableBrowserAlert?: boolean;
39
+ actionNodeParams?: {
40
+ viewHtmlElement?: HTMLElement;
41
+ rttHTML?: HTMLElement;
42
+ };
43
+ }
44
+ export interface StyleType {
45
+ statusColor: {
46
+ [AgentStatus.IDLE]: string;
47
+ [AgentStatus.BUSY]: string;
48
+ [AgentStatus.OFFLINE]: string;
49
+ [AgentStatus.RINGING]: string;
50
+ };
51
+ }
52
+ export interface StatusType {
53
+ state: AgentStatus.IDLE | AgentStatus.BUSY | AgentStatus.OFFLINE | AgentStatus.RINGING;
54
+ statusName: string;
55
+ }
56
+ export type DeviceType = 1 | 2 | 3;
57
+ export type StateType = AgentStatus.OFFLINE | AgentStatus.IDLE | AgentStatus.BUSY | AgentStatus.RINGING;
58
+ export type ActionType = 'call_number' | 'answer' | 'reject' | 'hangup' | 'dtmf' | 'unhold' | 'hold' | 'mute' | 'unmute' | 'satisfaction' | 'consult' | 'consult_transfer' | 'transfer';
59
+ export type ActionConfigsType = Array<ActionType>;
60
+ export interface AgentObjectType {
61
+ app_id: string;
62
+ agent_no: string;
63
+ state: 0 | 1;
64
+ agent_name: string;
65
+ data_role_id: string;
66
+ answer_devices: string;
67
+ phone: string;
68
+ email: string;
69
+ show_satisfaction: 0 | 1;
70
+ default_device: DeviceType;
71
+ is_inquire: number;
72
+ soft_device_auto_answer: 0 | 1;
73
+ auto_answer_time: number;
74
+ init_state: 1 | 2;
75
+ state_is_inquire: 0 | 1;
76
+ post_call_process_time: number;
77
+ auto_jump: number;
78
+ ring_card: 0 | 1;
79
+ browser_alert: 0 | 1;
80
+ browser_alert_time: number;
81
+ call_noise_reduction: 0 | 1;
82
+ current_state: StateType;
83
+ current_state_name: string;
84
+ current_answer_device: DeviceType;
85
+ sip_account_list: {
86
+ sip_account: string;
87
+ sip_password: string;
88
+ device_type: DeviceType;
89
+ sip_register_addr: string;
90
+ }[];
91
+ skill_agent_list: {
92
+ group_id: number;
93
+ group_name: string;
94
+ }[];
95
+ }
96
+ export interface AgentItemType {
97
+ agent_no: string;
98
+ agent_name: string;
99
+ }
100
+ export interface SeatStatusItemType {
101
+ /**
102
+ * 是否启用,0:是 1:否 缺省:0
103
+ */
104
+ enable: 0 | 1;
105
+ /**
106
+ * 状态,0:离线 1:空闲 2:通话中 3:振铃中
107
+ */
108
+ state: StateType;
109
+ /**
110
+ * 状态名称
111
+ */
112
+ state_name: string;
113
+ }
114
+ export type AgentStateDataType = Pick<SeatStatusItemType, 'state_name' | 'state'>[];
@@ -0,0 +1,28 @@
1
+ type WsResType = {
2
+ type: number;
3
+ data: any;
4
+ };
5
+ export declare const handleMessage: (raw: WsResType) => any;
6
+ export declare class ReconnectingWebSocket {
7
+ private url;
8
+ private ws;
9
+ private heartbeatWorker;
10
+ private reconnectDelay;
11
+ private manualClose;
12
+ private apiClient;
13
+ private constructor();
14
+ static getInstance(url?: string): ReconnectingWebSocket;
15
+ private stateIdleChange;
16
+ private putAgentState;
17
+ private initWebSocket;
18
+ private startHeartbeat;
19
+ private stopHeartbeat;
20
+ private sendMessage;
21
+ /** ✅ 私有 close,只允许内部调用 */
22
+ private close;
23
+ /** ✅ SDK 内部可调用的关闭方法 */
24
+ static __internalClose(): void;
25
+ /** ✅ SDK 内部发送消息 */
26
+ static __internalSend(data: any): void;
27
+ }
28
+ export {};
@@ -0,0 +1,16 @@
1
+ type LatencyMonitorOptions<T> = {
2
+ requestFn: () => Promise<T>;
3
+ intervalMs?: number;
4
+ onSuccess?: (delay: number, res: T) => void;
5
+ onError?: (err: any) => void;
6
+ };
7
+ export declare function startLatencyMonitor<T>({ requestFn, intervalMs, onSuccess, onError }: LatencyMonitorOptions<T>): {
8
+ stop: () => void;
9
+ };
10
+ export declare const handleToken: (YS_APP_KEY: string, YS_APP_SECRET: string) => string;
11
+ export declare const DeviceMap: {
12
+ 1: string;
13
+ 2: string;
14
+ 3: string;
15
+ };
16
+ export {};
@@ -0,0 +1,18 @@
1
+ import { DeviceType, StateType } from '@/types';
2
+ export declare const queryPing: () => Promise<any>;
3
+ export declare const agentLogin: (params: {
4
+ agent_no: string;
5
+ }) => Promise<any>;
6
+ export declare const changeState: (params: {
7
+ agent_no: string;
8
+ state: StateType;
9
+ state_name: string;
10
+ }) => Promise<any>;
11
+ export declare const changeDevice: (params: {
12
+ agent_no: string;
13
+ answer_device: DeviceType;
14
+ }) => Promise<any>;
15
+ export declare const getIdleAgents: (params: {
16
+ agent_no: string;
17
+ }) => Promise<any>;
18
+ export declare const querySeatStatusAll: () => Promise<any>;
@@ -0,0 +1,22 @@
1
+ export declare class NotificationUtil {
2
+ /**
3
+ * 请求浏览器通知权限
4
+ */
5
+ static requestPermission(): void;
6
+ /**
7
+ * 请求麦克风和扬声器权限
8
+ * 通常只需请求 audio(video 可选)
9
+ */
10
+ static requestMediaPermissions(): Promise<MediaStream | null>;
11
+ /**
12
+ * 显示浏览器系统通知
13
+ * @param title 通知标题
14
+ * @param body 通知内容
15
+ * @param onClick 点击回调
16
+ */
17
+ static show(title: string, body: string, onClick?: () => void): void;
18
+ /**
19
+ * 检查是否已授予音频权限(返回 true/false)
20
+ */
21
+ static checkMediaPermissions(): Promise<boolean>;
22
+ }
@@ -0,0 +1,11 @@
1
+ import { ActionConfigsType, StatusType, StyleType } from '@/types';
2
+ export declare const phoneStyleConfig: StyleType;
3
+ export declare const IdleNode: ({ state, statusName }: StatusType) => import("lit").TemplateResult<1>;
4
+ export declare const initIdleConfig: ActionConfigsType;
5
+ export declare const initBusyConfig: ActionConfigsType;
6
+ export declare const incomingConfig: ActionConfigsType;
7
+ export declare const outgoingConfig: ActionConfigsType;
8
+ export declare const consultConfig: ActionConfigsType;
9
+ export declare const transferConfig: ActionConfigsType;
10
+ export declare const incomingCallConfig: ActionConfigsType;
11
+ export declare const incomingCallAnswerConfig: ActionConfigsType;
@@ -0,0 +1,16 @@
1
+ export interface ResponseData<T = unknown> {
2
+ code: number;
3
+ data?: T;
4
+ msg?: string;
5
+ }
6
+ export declare const AGENT_SERVER = "/v1/aicc/bmserver";
7
+ export declare const AGENT_CCS_SERVER = "/v1/aicc/ccs";
8
+ export declare function SET_URL(newUrl: string): void;
9
+ export declare function SET_APP_KEY(newAppId: string): void;
10
+ export declare function SET_APP_SECRET(newAppSecret: string): void;
11
+ /**
12
+ * POST 请求封装
13
+ * @param url 相对接口路径,如 /user/login
14
+ * @param params 请求体参数对象
15
+ */
16
+ export declare function $POST<T extends object = any, R = any>(url: string, params: T): Promise<R>;
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".", // 让非相对路径起作用
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "target": "ES2020",
7
+ "lib": ["ES2020", "DOM"],
8
+ "types": ["sip.js"],
9
+ "declaration": true,
10
+ "emitDeclarationOnly": true,
11
+ "jsx": "preserve", // 不使用 React 时也可保留默认
12
+ "outDir": "dist",
13
+ "experimentalDecorators": true,
14
+ "useDefineForClassFields": false,
15
+ "paths": {
16
+ "@/*": ["src/*"]
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;