@koi-design/callkit 1.0.26 → 2.0.0-beta.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/dist/index.d.ts +52 -105
- package/dist/index.global.js +1133 -1116
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1135 -1118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1135 -1118
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,19 +10,13 @@ declare class Api {
|
|
|
10
10
|
loginOut(params: {
|
|
11
11
|
sessionId: string;
|
|
12
12
|
}): Promise<any>;
|
|
13
|
-
|
|
14
|
-
* @description sdkLog
|
|
15
|
-
* @param params
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
sdkLog(data: any): Promise<any>;
|
|
13
|
+
trackLogs(log: string): Promise<any>;
|
|
19
14
|
/**
|
|
20
15
|
*
|
|
21
|
-
* @param params agentId
|
|
22
|
-
* @description userStatus: Logout(1, "unregistered"), Free(2, "free"), Break(3, "nap"), Busy(4, "busy")
|
|
16
|
+
* @param params agentId status
|
|
23
17
|
* @returns
|
|
24
18
|
*/
|
|
25
|
-
|
|
19
|
+
updateUserStatus(params: any): Promise<any>;
|
|
26
20
|
private post;
|
|
27
21
|
}
|
|
28
22
|
|
|
@@ -52,10 +46,6 @@ declare const CallStatus: {
|
|
|
52
46
|
* Initial state/Hang up
|
|
53
47
|
*/
|
|
54
48
|
init: number;
|
|
55
|
-
/**
|
|
56
|
-
* Registered
|
|
57
|
-
*/
|
|
58
|
-
registered: number;
|
|
59
49
|
/**
|
|
60
50
|
* Connecting
|
|
61
51
|
*/
|
|
@@ -74,6 +64,10 @@ declare const CallStatus: {
|
|
|
74
64
|
calling: number;
|
|
75
65
|
};
|
|
76
66
|
declare const KitEvent: {
|
|
67
|
+
/**
|
|
68
|
+
* Log
|
|
69
|
+
*/
|
|
70
|
+
KIT_LOG: string;
|
|
77
71
|
/**
|
|
78
72
|
* User status change
|
|
79
73
|
*/
|
|
@@ -153,7 +147,6 @@ declare const KitEvent: {
|
|
|
153
147
|
CONNECT_EVENT: string;
|
|
154
148
|
SIP_REGISTERER_EVENT: string;
|
|
155
149
|
SIP_SESSION_EVENT: string;
|
|
156
|
-
USER_STATUS_CHANGE_STEP: string;
|
|
157
150
|
};
|
|
158
151
|
declare const SocketSendEvent: {
|
|
159
152
|
/**
|
|
@@ -197,48 +190,43 @@ declare const SocketSendEvent: {
|
|
|
197
190
|
*/
|
|
198
191
|
HANG_UP_REASON: string;
|
|
199
192
|
ACK: string;
|
|
200
|
-
SDK_LOG: string;
|
|
201
193
|
};
|
|
202
194
|
declare const EncryptionMethod: {
|
|
203
195
|
NONE: string;
|
|
204
196
|
INTERNAL: string;
|
|
205
197
|
};
|
|
206
198
|
type EncryptionMethodType = (typeof EncryptionMethod)[keyof typeof EncryptionMethod];
|
|
207
|
-
declare const LogGatherEnum: {
|
|
208
|
-
ENABLE: number;
|
|
209
|
-
DISABLE: number;
|
|
210
|
-
};
|
|
211
|
-
type LogGatherEnumType = (typeof LogGatherEnum)[keyof typeof LogGatherEnum];
|
|
212
199
|
declare const CallSourceType: {
|
|
213
200
|
phoneNum: number;
|
|
214
201
|
workOrderId: number;
|
|
215
|
-
};
|
|
216
|
-
declare const LogDataEnum: {
|
|
217
|
-
readonly SIP: "sip";
|
|
218
|
-
readonly INCALL: "incall";
|
|
219
|
-
readonly AJAX: "ajax";
|
|
220
|
-
readonly ERROR: "error";
|
|
221
|
-
readonly RECONNECT: "reconnect";
|
|
222
|
-
readonly ALL: "all";
|
|
223
|
-
};
|
|
224
|
-
type LogDataType = (typeof LogDataEnum)[keyof typeof LogDataEnum];
|
|
202
|
+
};
|
|
225
203
|
|
|
226
|
-
type LoggerLevel = '
|
|
204
|
+
type LoggerLevel = 'info' | 'success' | 'warn' | 'error' | 'silent';
|
|
205
|
+
interface Log {
|
|
206
|
+
timestamp: string;
|
|
207
|
+
level: LoggerLevel;
|
|
208
|
+
type?: 'INCALL' | 'SIP' | 'API' | 'OTHER';
|
|
209
|
+
message: string;
|
|
210
|
+
caller: string;
|
|
211
|
+
content: Record<string, any>;
|
|
212
|
+
}
|
|
213
|
+
type LogEntity = Omit<Log, 'timestamp' | 'level' | 'message'>;
|
|
227
214
|
declare class Logger {
|
|
228
215
|
prefix: string;
|
|
229
216
|
level: LoggerLevel;
|
|
230
|
-
|
|
231
|
-
|
|
217
|
+
private pendingTrackLogs;
|
|
218
|
+
private trackLogsTimer;
|
|
232
219
|
private callKit;
|
|
233
220
|
constructor(callKit: CallKit, level?: LoggerLevel);
|
|
234
|
-
|
|
221
|
+
private startTrackLogsTimer;
|
|
222
|
+
private flushTrackLogs;
|
|
223
|
+
destroy(): void;
|
|
235
224
|
setLevel(level: LoggerLevel): void;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
warn(msg:
|
|
239
|
-
error(msg:
|
|
240
|
-
|
|
241
|
-
output(color: string): (msg: any, extra?: Object) => void;
|
|
225
|
+
info(msg: string, extra: LogEntity): void;
|
|
226
|
+
success(msg: string, extra: LogEntity): void;
|
|
227
|
+
warn(msg: string, extra: LogEntity): void;
|
|
228
|
+
error(msg: string | Error, extra: LogEntity): void;
|
|
229
|
+
private catchLog;
|
|
242
230
|
}
|
|
243
231
|
|
|
244
232
|
type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
|
|
@@ -257,32 +245,26 @@ declare class Socket {
|
|
|
257
245
|
lastPingTime: any;
|
|
258
246
|
isConnected: boolean;
|
|
259
247
|
pingTimer?: number;
|
|
260
|
-
recivedClose: boolean;
|
|
261
248
|
satrtConfirm: boolean;
|
|
262
249
|
private reconnectTimer?;
|
|
263
250
|
private isReconnecting;
|
|
264
251
|
private reconnectAttempts;
|
|
265
252
|
constructor(callKit: CallKit);
|
|
266
253
|
init(): void;
|
|
267
|
-
|
|
268
|
-
private reconnect;
|
|
254
|
+
private handleDisconnect;
|
|
269
255
|
private connect;
|
|
270
256
|
private onOpen;
|
|
257
|
+
private resetReconnectState;
|
|
271
258
|
private onClose;
|
|
272
259
|
private onError;
|
|
273
260
|
private confirmAck;
|
|
274
261
|
private onMessage;
|
|
275
262
|
send(event: SocketSendEventType, message?: any): void;
|
|
276
263
|
sendMessage(event: SocketSendEventType, message?: any): Promise<void>;
|
|
277
|
-
/**
|
|
278
|
-
* Attempt to close socket, need to wait for server confirmation
|
|
279
|
-
* @returns
|
|
280
|
-
*/
|
|
281
|
-
requestClose(): Promise<boolean>;
|
|
282
264
|
private ping;
|
|
283
265
|
private checkPing;
|
|
284
266
|
/**
|
|
285
|
-
*
|
|
267
|
+
* 重置 socket 连接和所有状态
|
|
286
268
|
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
287
269
|
*/
|
|
288
270
|
reset(isWaitConfirm?: boolean): Promise<void>;
|
|
@@ -301,6 +283,7 @@ interface IConfig {
|
|
|
301
283
|
version: string;
|
|
302
284
|
host: string;
|
|
303
285
|
log: LoggerLevel;
|
|
286
|
+
trackLogs: boolean;
|
|
304
287
|
audioRef?: HTMLAudioElement | (() => HTMLAudioElement);
|
|
305
288
|
constrains: WebrtcConstranis;
|
|
306
289
|
socket: string;
|
|
@@ -323,9 +306,7 @@ interface IConfig {
|
|
|
323
306
|
iceInfo: string[];
|
|
324
307
|
iceGatheringTimeout: number;
|
|
325
308
|
encryptionMethod: EncryptionMethodType;
|
|
326
|
-
logGather: LogGatherEnumType;
|
|
327
309
|
};
|
|
328
|
-
isAutoUpdateUserStatus: boolean;
|
|
329
310
|
}
|
|
330
311
|
declare class Config {
|
|
331
312
|
callKit: CallKit;
|
|
@@ -337,7 +318,6 @@ declare class Config {
|
|
|
337
318
|
reset: () => void;
|
|
338
319
|
validate: () => boolean;
|
|
339
320
|
isLogin: () => boolean;
|
|
340
|
-
isLogGatherEnable: () => boolean;
|
|
341
321
|
check(): boolean;
|
|
342
322
|
}
|
|
343
323
|
|
|
@@ -352,7 +332,11 @@ declare class Connect {
|
|
|
352
332
|
mediaStream?: MediaStream;
|
|
353
333
|
userAgent?: UserAgent;
|
|
354
334
|
registerer?: Registerer;
|
|
355
|
-
|
|
335
|
+
currentCallId?: string;
|
|
336
|
+
/**
|
|
337
|
+
* Whether it's a re-connected
|
|
338
|
+
*/
|
|
339
|
+
isReConnected: boolean;
|
|
356
340
|
observeOptionsHeartbeatHandler: ReturnType<typeof setTimeout> | null;
|
|
357
341
|
/**
|
|
358
342
|
* Whether it's an outgoing call
|
|
@@ -364,26 +348,18 @@ declare class Connect {
|
|
|
364
348
|
isUnprompted: boolean;
|
|
365
349
|
isCurrentSessionInvited: boolean;
|
|
366
350
|
private reconnectConfig;
|
|
367
|
-
/**
|
|
368
|
-
* Whether registered
|
|
369
|
-
* @param
|
|
370
|
-
* @deprecated Deprecated, please use isRegistered method
|
|
371
|
-
*/
|
|
372
|
-
get isRegister(): boolean;
|
|
373
|
-
/**
|
|
374
|
-
* Call hold
|
|
375
|
-
* @param isHold
|
|
376
|
-
*/
|
|
377
|
-
isHold: boolean;
|
|
378
351
|
/**
|
|
379
352
|
* Whether muted
|
|
380
353
|
*/
|
|
381
354
|
isMute: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Whether registered
|
|
357
|
+
*/
|
|
358
|
+
isRegistered: boolean;
|
|
382
359
|
constructor(callKit: CallKit);
|
|
383
360
|
reset(): void;
|
|
384
361
|
private getAduioReference;
|
|
385
362
|
permission(): Promise<void>;
|
|
386
|
-
isRegistered(): boolean;
|
|
387
363
|
/**
|
|
388
364
|
* Making connection
|
|
389
365
|
* @returns
|
|
@@ -407,13 +383,16 @@ declare class Connect {
|
|
|
407
383
|
* @returns
|
|
408
384
|
*/
|
|
409
385
|
isInit(): boolean;
|
|
410
|
-
isExecuting(): boolean;
|
|
411
386
|
clearObserveOptionsHeartbeatInterval(): void;
|
|
387
|
+
heartbeatFlag: number;
|
|
388
|
+
startHeartbeat(): void;
|
|
412
389
|
register(): Promise<void>;
|
|
413
|
-
|
|
390
|
+
private reconnectTimer?;
|
|
391
|
+
private reconnectAttempts;
|
|
392
|
+
private startReconnectTimer;
|
|
414
393
|
stop(): Promise<void>;
|
|
415
394
|
unregister(): Promise<void>;
|
|
416
|
-
call(callback:
|
|
395
|
+
call(callback: (userInfo: IConfig['userInfo']) => void): Promise<void>;
|
|
417
396
|
/**
|
|
418
397
|
* Update registration status
|
|
419
398
|
* @param register
|
|
@@ -451,39 +430,6 @@ declare class Connect {
|
|
|
451
430
|
refer(referTo: string, extra?: any): Promise<void>;
|
|
452
431
|
}
|
|
453
432
|
|
|
454
|
-
declare class User {
|
|
455
|
-
private callKit;
|
|
456
|
-
userStatus: number;
|
|
457
|
-
userChangeStatusExecuting: boolean;
|
|
458
|
-
constructor(callKit: CallKit);
|
|
459
|
-
setUserChangeStatusExecuting(state: boolean): void;
|
|
460
|
-
getUserChangeStatusExecuting(): boolean;
|
|
461
|
-
login(params: {
|
|
462
|
-
userName: string;
|
|
463
|
-
password: string;
|
|
464
|
-
}): Promise<any>;
|
|
465
|
-
loginOut(params: {
|
|
466
|
-
sessionId: string;
|
|
467
|
-
}): Promise<any>;
|
|
468
|
-
/**
|
|
469
|
-
*
|
|
470
|
-
* @param status logout(1, "unregistered"), idle(2, "free"), break(3, "nap"), busy(4, "busy")
|
|
471
|
-
*/
|
|
472
|
-
setUserStatus(status: number): Promise<void>;
|
|
473
|
-
/**
|
|
474
|
-
* Update user status
|
|
475
|
-
* @param status
|
|
476
|
-
*/
|
|
477
|
-
updateUserStatus(status: number): Promise<void>;
|
|
478
|
-
/**
|
|
479
|
-
* @description sdkLog
|
|
480
|
-
* @param params
|
|
481
|
-
* @returns
|
|
482
|
-
*/
|
|
483
|
-
sendSdkLog(data: any): Promise<any>;
|
|
484
|
-
sendHangUpReason(data: any): Promise<void>;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
433
|
interface CallKitConfig {
|
|
488
434
|
host: string;
|
|
489
435
|
audioRef: HTMLAudioElement | (() => HTMLAudioElement);
|
|
@@ -509,7 +455,6 @@ declare class CallKit {
|
|
|
509
455
|
callCenter: Call;
|
|
510
456
|
connect: Connect;
|
|
511
457
|
socket: Socket;
|
|
512
|
-
user: User;
|
|
513
458
|
listener: Listener[];
|
|
514
459
|
constructor(options: ConfigEntity);
|
|
515
460
|
login(username: string, password: string, extra?: {
|
|
@@ -524,9 +469,11 @@ declare class CallKit {
|
|
|
524
469
|
hangup(): Promise<void>;
|
|
525
470
|
hold(): void;
|
|
526
471
|
unhold(): void;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
472
|
+
/**
|
|
473
|
+
* set userstatus
|
|
474
|
+
* @param status
|
|
475
|
+
*/
|
|
476
|
+
setUserStatus(status: number): void;
|
|
530
477
|
reset(): Promise<void>;
|
|
531
478
|
on(event: kitEventType, callback: (...args: any[]) => void): void;
|
|
532
479
|
off(event: kitEventType, callback?: (...args: any[]) => void): void;
|