webitel-sdk 26.4.32 → 26.4.34

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/index.mjs CHANGED
@@ -66709,7 +66709,7 @@ _defineProperty(SipPhone$1, "userAgent", `Webitel-Phone/${version$1}`);
66709
66709
  _defineProperty(SipPhone$1, "sipVersion", version$1);
66710
66710
  //#endregion
66711
66711
  //#region src/version.ts
66712
- const version = "26.4.32";
66712
+ const version = "26.4.34";
66713
66713
  //#endregion
66714
66714
  //#region src/socket/errors.ts
66715
66715
  /**
@@ -67164,6 +67164,8 @@ var Task = class {
67164
67164
  "_autoAnswerTimerId",
67165
67165
  void 0
67166
67166
  );
67167
+ _defineProperty(this, "_baseProcessingSec", 0);
67168
+ _defineProperty(this, "_renewedSec", 0);
67167
67169
  this.id = e.attempt_id;
67168
67170
  this.state = "offering";
67169
67171
  this.setState(e.status);
@@ -67338,7 +67340,10 @@ var Task = class {
67338
67340
  setProcessing(now, p) {
67339
67341
  this.state = "processing";
67340
67342
  this.closedAt = now;
67341
- if (!this.startProcessingAt) this.startProcessingAt = Date.now();
67343
+ if (!this.startProcessingAt) {
67344
+ this.startProcessingAt = Date.now();
67345
+ this._baseProcessingSec = p.sec;
67346
+ }
67342
67347
  if (p.sec && !p.timeout) p.timeout = Date.now() + p.sec * 1e3;
67343
67348
  this._processing = p;
67344
67349
  }
@@ -67379,9 +67384,8 @@ var Task = class {
67379
67384
  * @returns {number | null}
67380
67385
  */
67381
67386
  get processingSec() {
67382
- var _this$_processing2;
67383
- if (!((_this$_processing2 = this._processing) === null || _this$_processing2 === void 0 ? void 0 : _this$_processing2.sec)) return null;
67384
- return this._processing.sec;
67387
+ var _this$_processing$sec, _this$_processing2;
67388
+ return (_this$_processing$sec = (_this$_processing2 = this._processing) === null || _this$_processing2 === void 0 ? void 0 : _this$_processing2.sec) !== null && _this$_processing$sec !== void 0 ? _this$_processing$sec : null;
67385
67389
  }
67386
67390
  /**
67387
67391
  * Отримати спробу.
@@ -67529,10 +67533,16 @@ var Task = class {
67529
67533
  * @returns {Promise<any>}
67530
67534
  */
67531
67535
  async renew(sec) {
67532
- return this.client.request("cc_renewal", {
67536
+ const renewSec = sec || this.processingSec;
67537
+ const res = await this.client.request("cc_renewal", {
67533
67538
  attempt_id: this.id,
67534
- renewal_sec: sec ? sec : this.processingSec
67539
+ renewal_sec: renewSec
67535
67540
  });
67541
+ this._renewedSec += renewSec !== null && renewSec !== void 0 ? renewSec : 0;
67542
+ return res;
67543
+ }
67544
+ get totalProcessingSec() {
67545
+ return this._processing ? this._baseProcessingSec + this._renewedSec : null;
67536
67546
  }
67537
67547
  /**
67538
67548
  * Виконати дію з формою.
@@ -67719,6 +67729,7 @@ var Agent = class {
67719
67729
  _defineProperty(this, "_channels", void 0);
67720
67730
  _defineProperty(this, "_listOfflineMembers", void 0);
67721
67731
  _defineProperty(this, "lastStatusChange", void 0);
67732
+ _defineProperty(this, "_waitingChatsSize", 0);
67722
67733
  this.task = /* @__PURE__ */ new Map();
67723
67734
  this._channels = /* @__PURE__ */ new Map();
67724
67735
  this.initChannels(info.channels);
@@ -67736,6 +67747,9 @@ var Agent = class {
67736
67747
  get agentId() {
67737
67748
  return this.info.agent_id;
67738
67749
  }
67750
+ get waitingChatsSize() {
67751
+ return this._waitingChatsSize;
67752
+ }
67739
67753
  /**
67740
67754
  * Метод, що повертає статус "On Demand".
67741
67755
  * @method
@@ -67839,6 +67853,7 @@ var Agent = class {
67839
67853
  if (e) {
67840
67854
  this.waitingListCalls.length = 0;
67841
67855
  this.waitingListChats.length = 0;
67856
+ this._waitingChatsSize = 0;
67842
67857
  if (this.status !== "online") return;
67843
67858
  for (const el of e.calls || []) this.waitingListCalls.push({
67844
67859
  displayName: el.communication.name || "",
@@ -67849,6 +67864,7 @@ var Agent = class {
67849
67864
  queue: el.queue,
67850
67865
  wait: el.wait
67851
67866
  });
67867
+ if (Array.isArray(e.chats)) this._waitingChatsSize = e.chats.length;
67852
67868
  for (const el of e.chats || []) {
67853
67869
  this.waitingListChats.push({
67854
67870
  chat: el.communication.chat || "",
@@ -67874,7 +67890,8 @@ var Agent = class {
67874
67890
  deleteWaitingAttempt(e) {
67875
67891
  if (e) {
67876
67892
  const attemptId = e.attempt_id;
67877
- if (!removeWaitingList(this.waitingListCalls, attemptId)) removeWaitingList(this.waitingListChats, attemptId);
67893
+ if (removeWaitingList(this.waitingListCalls, attemptId)) return;
67894
+ if (removeWaitingList(this.waitingListChats, attemptId)) this._waitingChatsSize--;
67878
67895
  }
67879
67896
  }
67880
67897
  /**
@@ -68078,6 +68095,7 @@ var Agent = class {
68078
68095
  } else {
68079
68096
  this.waitingListCalls.length = 0;
68080
68097
  this.waitingListChats.length = 0;
68098
+ this._waitingChatsSize = 0;
68081
68099
  }
68082
68100
  this.info.online_status = formatStatusPreset(e.status_preset);
68083
68101
  this.info.status = e.status;