webitel-sdk 23.7.4 → 23.7.6

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.
@@ -42760,6 +42760,66 @@
42760
42760
  };
42761
42761
  var version = getVersion();
42762
42762
 
42763
+ (function (TypeErrors) {
42764
+ TypeErrors["RolePermission"] = "api.context.permissions.app_error";
42765
+ TypeErrors["LicencePermission"] = "api.context.permissions.license";
42766
+ TypeErrors["PauseNotAllow"] = "app.agent.set_pause.not_allow";
42767
+ })(exports.TypeErrors || (exports.TypeErrors = {}));
42768
+ var DeviceNotFoundError = /** @class */ (function (_super) {
42769
+ tslib.__extends(DeviceNotFoundError, _super);
42770
+ function DeviceNotFoundError(msg) {
42771
+ var _this = _super.call(this, msg) || this;
42772
+ _this.id = DeviceNotFoundError.id;
42773
+ return _this;
42774
+ }
42775
+ DeviceNotFoundError.id = "device_not_found";
42776
+ return DeviceNotFoundError;
42777
+ }(Error));
42778
+ // tslint:disable-next-line: max-classes-per-file
42779
+ var DeviceNotAllowPermissionError = /** @class */ (function (_super) {
42780
+ tslib.__extends(DeviceNotAllowPermissionError, _super);
42781
+ function DeviceNotAllowPermissionError(msg) {
42782
+ var _this = _super.call(this, msg) || this;
42783
+ _this.id = DeviceNotAllowPermissionError.id;
42784
+ return _this;
42785
+ }
42786
+ DeviceNotAllowPermissionError.id = "device_not_allow";
42787
+ return DeviceNotAllowPermissionError;
42788
+ }(Error));
42789
+ // tslint:disable-next-line: max-classes-per-file
42790
+ var RolePermissionError = /** @class */ (function (_super) {
42791
+ tslib.__extends(RolePermissionError, _super);
42792
+ function RolePermissionError(msg) {
42793
+ var _this = _super.call(this, msg) || this;
42794
+ _this.id = RolePermissionError.id;
42795
+ return _this;
42796
+ }
42797
+ RolePermissionError.id = exports.TypeErrors.RolePermission;
42798
+ return RolePermissionError;
42799
+ }(Error));
42800
+ // tslint:disable-next-line: max-classes-per-file
42801
+ var LicencePermissionError = /** @class */ (function (_super) {
42802
+ tslib.__extends(LicencePermissionError, _super);
42803
+ function LicencePermissionError(msg) {
42804
+ var _this = _super.call(this, msg) || this;
42805
+ _this.id = LicencePermissionError.id;
42806
+ return _this;
42807
+ }
42808
+ LicencePermissionError.id = exports.TypeErrors.LicencePermission;
42809
+ return LicencePermissionError;
42810
+ }(Error));
42811
+ // tslint:disable-next-line: max-classes-per-file
42812
+ var PauseNotAllowedError = /** @class */ (function (_super) {
42813
+ tslib.__extends(PauseNotAllowedError, _super);
42814
+ function PauseNotAllowedError(msg) {
42815
+ var _this = _super.call(this, msg) || this;
42816
+ _this.id = PauseNotAllowedError.id;
42817
+ return _this;
42818
+ }
42819
+ PauseNotAllowedError.id = exports.TypeErrors.PauseNotAllow;
42820
+ return PauseNotAllowedError;
42821
+ }(Error));
42822
+
42763
42823
  (function (JobState) {
42764
42824
  JobState["Distribute"] = "distribute";
42765
42825
  JobState["Offering"] = "offering";
@@ -43192,6 +43252,8 @@
43192
43252
  this._channels = new Map();
43193
43253
  this.initChannels(info.channels);
43194
43254
  this._listOfflineMembers = null;
43255
+ this.waitingListChats = [];
43256
+ this.waitingListCalls = [];
43195
43257
  this.lastStatusChange = Date.now() - this.info.status_duration * 1000;
43196
43258
  }
43197
43259
  Object.defineProperty(Agent.prototype, "agentId", {
@@ -43279,6 +43341,43 @@
43279
43341
  configurable: true
43280
43342
  });
43281
43343
  // todo need refactor
43344
+ Agent.prototype.setWaitingList = function (e) {
43345
+ if (e) {
43346
+ var list = e.list;
43347
+ this.waitingListCalls.length = 0;
43348
+ this.waitingListChats.length = 0;
43349
+ for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
43350
+ var el = list_1[_i];
43351
+ switch (el.channel) {
43352
+ case exports.ChannelType.Call:
43353
+ this.waitingListCalls.push(el);
43354
+ break;
43355
+ case exports.ChannelType.Chat:
43356
+ this.waitingListChats.push(el);
43357
+ break;
43358
+ default:
43359
+ }
43360
+ }
43361
+ }
43362
+ };
43363
+ Agent.prototype.deleteWaitingAttempt = function (e) {
43364
+ if (e) {
43365
+ var attemptId = e.attempt_id;
43366
+ if (!removeWaitingList(this.waitingListCalls, attemptId)) {
43367
+ removeWaitingList(this.waitingListChats, attemptId);
43368
+ }
43369
+ }
43370
+ };
43371
+ Agent.prototype.interceptAttempt = function (id) {
43372
+ return tslib.__awaiter(this, void 0, void 0, function () {
43373
+ return tslib.__generator(this, function (_a) {
43374
+ return [2 /*return*/, this.client.request("cc_intercept_attempt", {
43375
+ attempt_id: id,
43376
+ agent_id: this.agentId,
43377
+ })];
43378
+ });
43379
+ });
43380
+ };
43282
43381
  Agent.prototype.onChannelEvent = function (e) {
43283
43382
  var task;
43284
43383
  switch (e.status) {
@@ -43425,8 +43524,21 @@
43425
43524
  };
43426
43525
  Agent.prototype.pause = function (payload) {
43427
43526
  return tslib.__awaiter(this, void 0, void 0, function () {
43527
+ var e_1;
43428
43528
  return tslib.__generator(this, function (_a) {
43429
- return [2 /*return*/, this.client.agentSetPause(this.agentId, payload)];
43529
+ switch (_a.label) {
43530
+ case 0:
43531
+ _a.trys.push([0, 2, , 3]);
43532
+ return [4 /*yield*/, this.client.agentSetPause(this.agentId, payload)];
43533
+ case 1: return [2 /*return*/, _a.sent()];
43534
+ case 2:
43535
+ e_1 = _a.sent();
43536
+ if (e_1.id === exports.TypeErrors.PauseNotAllow) {
43537
+ return [2 /*return*/, new PauseNotAllowedError(e_1.detail)];
43538
+ }
43539
+ return [2 /*return*/, e_1];
43540
+ case 3: return [2 /*return*/];
43541
+ }
43430
43542
  });
43431
43543
  });
43432
43544
  };
@@ -43507,6 +43619,15 @@
43507
43619
  };
43508
43620
  return Agent;
43509
43621
  }());
43622
+ function removeWaitingList(list, attemptId) {
43623
+ for (var i = 0; i < list.length; i++) {
43624
+ if (list[i].attempt_id === attemptId) {
43625
+ list.splice(i, 1);
43626
+ return true;
43627
+ }
43628
+ }
43629
+ return false;
43630
+ }
43510
43631
 
43511
43632
  (function (CallReportingStatus) {
43512
43633
  CallReportingStatus["Abandoned"] = "abandoned";
@@ -44745,57 +44866,11 @@
44745
44866
  return m;
44746
44867
  }
44747
44868
 
44748
- (function (TypeErrors) {
44749
- TypeErrors["RolePermission"] = "api.context.permissions.app_error";
44750
- TypeErrors["LicencePermission"] = "api.context.permissions.license";
44751
- })(exports.TypeErrors || (exports.TypeErrors = {}));
44752
- var DeviceNotFoundError = /** @class */ (function (_super) {
44753
- tslib.__extends(DeviceNotFoundError, _super);
44754
- function DeviceNotFoundError(msg) {
44755
- var _this = _super.call(this, msg) || this;
44756
- _this.id = DeviceNotFoundError.id;
44757
- return _this;
44758
- }
44759
- DeviceNotFoundError.id = "device_not_found";
44760
- return DeviceNotFoundError;
44761
- }(Error));
44762
- // tslint:disable-next-line: max-classes-per-file
44763
- var DeviceNotAllowPermissionError = /** @class */ (function (_super) {
44764
- tslib.__extends(DeviceNotAllowPermissionError, _super);
44765
- function DeviceNotAllowPermissionError(msg) {
44766
- var _this = _super.call(this, msg) || this;
44767
- _this.id = DeviceNotAllowPermissionError.id;
44768
- return _this;
44769
- }
44770
- DeviceNotAllowPermissionError.id = "device_not_allow";
44771
- return DeviceNotAllowPermissionError;
44772
- }(Error));
44773
- // tslint:disable-next-line: max-classes-per-file
44774
- var RolePermissionError = /** @class */ (function (_super) {
44775
- tslib.__extends(RolePermissionError, _super);
44776
- function RolePermissionError(msg) {
44777
- var _this = _super.call(this, msg) || this;
44778
- _this.id = RolePermissionError.id;
44779
- return _this;
44780
- }
44781
- RolePermissionError.id = exports.TypeErrors.RolePermission;
44782
- return RolePermissionError;
44783
- }(Error));
44784
- // tslint:disable-next-line: max-classes-per-file
44785
- var LicencePermissionError = /** @class */ (function (_super) {
44786
- tslib.__extends(LicencePermissionError, _super);
44787
- function LicencePermissionError(msg) {
44788
- var _this = _super.call(this, msg) || this;
44789
- _this.id = LicencePermissionError.id;
44790
- return _this;
44791
- }
44792
- LicencePermissionError.id = exports.TypeErrors.LicencePermission;
44793
- return LicencePermissionError;
44794
- }(Error));
44795
-
44796
44869
  var NotificationActions;
44797
44870
  (function (NotificationActions) {
44798
44871
  NotificationActions["HideMember"] = "hide_member";
44872
+ NotificationActions["HideAttempt"] = "hide_attempt";
44873
+ NotificationActions["WaitingList"] = "waiting_list";
44799
44874
  })(NotificationActions || (NotificationActions = {}));
44800
44875
 
44801
44876
  var SOCKET_URL_SUFFIX = 'websocket';
@@ -45632,6 +45707,16 @@
45632
45707
  }
45633
45708
  }
45634
45709
  break;
45710
+ case NotificationActions.WaitingList:
45711
+ if (this.agent) {
45712
+ this.agent.setWaitingList(e.body);
45713
+ }
45714
+ break;
45715
+ case NotificationActions.HideAttempt:
45716
+ if (this.agent) {
45717
+ this.agent.deleteWaitingAttempt(e.body);
45718
+ }
45719
+ break;
45635
45720
  default:
45636
45721
  this.log.error("notification \"" + e.action + "\" not handled");
45637
45722
  }
@@ -46558,6 +46643,7 @@
46558
46643
  exports.DeviceNotAllowPermissionError = DeviceNotAllowPermissionError;
46559
46644
  exports.RolePermissionError = RolePermissionError;
46560
46645
  exports.LicencePermissionError = LicencePermissionError;
46646
+ exports.PauseNotAllowedError = PauseNotAllowedError;
46561
46647
  exports.SipClient = SipClient;
46562
46648
  exports.ExternalClient = ExternalClient;
46563
46649
  exports.SipPhone = SipPhone;