@koi-design/callkit 1.0.24-beta.2 → 1.0.24-beta.3

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 CHANGED
@@ -179,7 +179,11 @@ declare const EncryptionMethod: {
179
179
  NONE: string;
180
180
  INTERNAL: string;
181
181
  };
182
- type EncryptionMethodType = (typeof EncryptionMethod)[keyof typeof EncryptionMethod];
182
+ type EncryptionMethodType = (typeof EncryptionMethod)[keyof typeof EncryptionMethod];
183
+ declare const CallSourceType: {
184
+ phoneNum: number;
185
+ workOrderId: number;
186
+ };
183
187
 
184
188
  type LoggerLevel = 'debug' | 'log' | 'warn' | 'error' | 'silent';
185
189
  declare class Logger {
@@ -261,7 +265,9 @@ interface IConfig {
261
265
  username: string;
262
266
  password: string;
263
267
  encryptionPassword: string;
268
+ sourceType: (typeof CallSourceType)[keyof typeof CallSourceType];
264
269
  extno: string;
270
+ workOrderId: string;
265
271
  userPart: string;
266
272
  agentId: string;
267
273
  fsUserId: string;
@@ -419,6 +425,11 @@ interface Listener {
419
425
  event: kitEventType;
420
426
  callback: (...args: any[]) => void;
421
427
  }
428
+ interface CallOptions {
429
+ sourceType: (typeof CallSourceType)[keyof typeof CallSourceType];
430
+ phoneNum?: string;
431
+ workOrderId?: string;
432
+ }
422
433
  declare class CallKit {
423
434
  api: Api;
424
435
  config: Config;
@@ -433,7 +444,7 @@ declare class CallKit {
433
444
  [key: string]: any;
434
445
  }): Promise<void>;
435
446
  logout(): Promise<void>;
436
- call(extno?: string | number): Promise<void>;
447
+ call(extno?: string | number, options?: CallOptions): Promise<void>;
437
448
  refer(uri: string, options?: any): Promise<void>;
438
449
  register(): Promise<void>;
439
450
  unregister(): Promise<void>;
@@ -3580,6 +3580,10 @@ var WebCall = (() => {
3580
3580
  video: false
3581
3581
  };
3582
3582
  var isAutoUpdateUserStatusDefault = true;
3583
+ var CallSourceType = {
3584
+ phoneNum: 1,
3585
+ workOrderId: 2
3586
+ };
3583
3587
 
3584
3588
  // package/call.ts
3585
3589
  var Call = class {
@@ -3596,10 +3600,20 @@ var WebCall = (() => {
3596
3600
  return;
3597
3601
  }
3598
3602
  this.callKit.connect.call(async (user) => {
3599
- const queryTrain = {
3600
- agentId: user.agentId,
3601
- phoneNum: user.extno
3602
- };
3603
+ let queryTrain = {};
3604
+ if (user.sourceType === CallSourceType.phoneNum) {
3605
+ queryTrain = {
3606
+ agentId: user.agentId,
3607
+ phoneNum: user.extno,
3608
+ sourceType: user.sourceType
3609
+ };
3610
+ } else if (user.sourceType === CallSourceType.workOrderId) {
3611
+ queryTrain = {
3612
+ agentId: user.agentId,
3613
+ workOrderId: user.workOrderId,
3614
+ sourceType: user.sourceType
3615
+ };
3616
+ }
3603
3617
  this.callKit.socket.send(SocketSendEvent.CALL, queryTrain);
3604
3618
  });
3605
3619
  }
@@ -3672,8 +3686,10 @@ var WebCall = (() => {
3672
3686
  // Password
3673
3687
  password: "",
3674
3688
  encryptionPassword: EncryptionMethod.INTERNAL,
3689
+ sourceType: CallSourceType.phoneNum,
3675
3690
  // Extension number
3676
3691
  extno: "",
3692
+ workOrderId: "",
3677
3693
  userPart: "",
3678
3694
  agentId: "",
3679
3695
  fsUserId: "",
@@ -3704,7 +3720,9 @@ var WebCall = (() => {
3704
3720
  password: "",
3705
3721
  encryptionPassword: "",
3706
3722
  userPart: "",
3723
+ sourceType: CallSourceType.phoneNum,
3707
3724
  extno: "",
3725
+ workOrderId: "",
3708
3726
  agentId: "",
3709
3727
  fsUserId: "",
3710
3728
  fsPassword: "",
@@ -19159,15 +19177,26 @@ var WebCall = (() => {
19159
19177
  this.config.reset();
19160
19178
  this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
19161
19179
  }
19162
- async call(extno) {
19180
+ async call(extno = "", options = {
19181
+ sourceType: CallSourceType.phoneNum,
19182
+ workOrderId: ""
19183
+ }) {
19163
19184
  if (!this.config.check())
19164
19185
  return;
19165
19186
  if (!this.connect.isRegistered()) {
19166
19187
  this.logger.warn("Currently not registered");
19167
19188
  return;
19168
19189
  }
19169
- if (extno) {
19170
- this.config.setUserInfo("extno", extno);
19190
+ const { sourceType, workOrderId } = options;
19191
+ this.config.setUserInfo("sourceType", sourceType);
19192
+ if (sourceType === CallSourceType.phoneNum) {
19193
+ if (extno) {
19194
+ this.config.setUserInfo("extno", extno);
19195
+ }
19196
+ } else if (sourceType === CallSourceType.workOrderId) {
19197
+ if (workOrderId) {
19198
+ this.config.setUserInfo("workOrderId", workOrderId);
19199
+ }
19171
19200
  }
19172
19201
  this.logger.debug("call");
19173
19202
  this.callCenter.callStart();