webitel-sdk 26.4.20 → 26.4.21

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.cjs CHANGED
@@ -27,6 +27,7 @@ let ee_ts = require("ee-ts");
27
27
  let jssip_lib_JsSIP_js = require("jssip/lib/JsSIP.js");
28
28
  jssip_lib_JsSIP_js = __toESM(jssip_lib_JsSIP_js);
29
29
  let events = require("events");
30
+ let case_anything = require("case-anything");
30
31
  let ee_ts_lib_ee_js = require("ee-ts/lib/ee.js");
31
32
  //#region src/url-shim.ts
32
33
  function parse(path, _parseQueryString = false) {
@@ -66707,7 +66708,7 @@ _defineProperty(SipPhone$1, "userAgent", `Webitel-Phone/${version$1}`);
66707
66708
  _defineProperty(SipPhone$1, "sipVersion", version$1);
66708
66709
  //#endregion
66709
66710
  //#region src/version.ts
66710
- const version = "26.4.20";
66711
+ const version = "26.4.21";
66711
66712
  //#endregion
66712
66713
  //#region src/socket/errors.ts
66713
66714
  /**
@@ -66853,6 +66854,75 @@ var PauseNotAllowedError = class PauseNotAllowedError extends Error {
66853
66854
  };
66854
66855
  _defineProperty(PauseNotAllowedError, "id", "app.agent.set_pause.not_allow");
66855
66856
  //#endregion
66857
+ //#region src/socket/utils.ts
66858
+ /**
66859
+ * Рекурсивно конвертує ключі обʼєкта/масиву в camelCase.
66860
+ * @function
66861
+ * @param {unknown} input - Вхідне значення.
66862
+ * @returns {unknown} - Значення з camelCase-ключами.
66863
+ */
66864
+ function camelizeKeys(input) {
66865
+ if (Array.isArray(input)) return input.map(camelizeKeys);
66866
+ if (input && typeof input === "object") {
66867
+ const res = {};
66868
+ for (const [key, value] of Object.entries(input)) res[(0, case_anything.camelCase)(key)] = camelizeKeys(value);
66869
+ return res;
66870
+ }
66871
+ return input;
66872
+ }
66873
+ /**
66874
+ * Функція, що форматує URI WebSocket.
66875
+ * @function
66876
+ * @param {string} host - Хост.
66877
+ * @returns {string} - URI WebSocket.
66878
+ */
66879
+ function formatWebSocketUri(host) {
66880
+ return host.replace(/^http/, "ws");
66881
+ }
66882
+ /**
66883
+ * Функція, що форматує базовий URI.
66884
+ * @function
66885
+ * @param {string} host - Хост.
66886
+ * @returns {string} - Базовий URI.
66887
+ */
66888
+ function formatBaseUri(host) {
66889
+ let res = host.replace(/^ws/, "http");
66890
+ if (res.endsWith("/")) res = res.slice(0, -1);
66891
+ if (res.endsWith("/ws")) res = res.slice(0, -3);
66892
+ return res;
66893
+ }
66894
+ /**
66895
+ * Функція, що розбиває рядок на частини заданої довжини.
66896
+ * @function
66897
+ * @param {string} str - Рядок.
66898
+ * @param {number} len - Довжина частини.
66899
+ * @returns {string[]} - Масив частин рядка.
66900
+ */
66901
+ function chunkString(str, len) {
66902
+ const size = Math.ceil(str.length / len);
66903
+ const r = new Array(size);
66904
+ let offset = 0;
66905
+ for (let i = 0; i < size; i++) {
66906
+ r[i] = str.substring(offset, offset + len);
66907
+ offset += len;
66908
+ }
66909
+ return r;
66910
+ }
66911
+ function generateId() {
66912
+ return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
66913
+ }
66914
+ function generateTimestampFilename() {
66915
+ const now = /* @__PURE__ */ new Date();
66916
+ const pad = (num) => String(num).padStart(2, "0");
66917
+ const year = now.getFullYear();
66918
+ const month = pad(now.getMonth() + 1);
66919
+ const day = pad(now.getDate());
66920
+ const hours = pad(now.getHours());
66921
+ const minutes = pad(now.getMinutes());
66922
+ const seconds = pad(now.getSeconds());
66923
+ return `${`${year}-${month}-${day}`}_${`${hours}_${minutes}_${seconds}`}`;
66924
+ }
66925
+ //#endregion
66856
66926
  //#region src/socket/task.ts
66857
66927
  /**
66858
66928
  * Перелік станів завдання.
@@ -67340,6 +67410,15 @@ var Task = class {
67340
67410
  return this.communication.destination;
67341
67411
  }
67342
67412
  /**
67413
+ * Превʼю чату в camelCase (сире значення по сокету — snake_case).
67414
+ * @returns {ThreadPreview | undefined}
67415
+ */
67416
+ get thread() {
67417
+ const raw = this.distribute.communication.thread;
67418
+ if (!raw) return;
67419
+ return camelizeKeys(raw);
67420
+ }
67421
+ /**
67343
67422
  * Отримати ім'я для відображення.
67344
67423
  * @returns {string | null}
67345
67424
  */
@@ -68066,60 +68145,6 @@ function removeWaitingList(list, attemptId) {
68066
68145
  return false;
68067
68146
  }
68068
68147
  //#endregion
68069
- //#region src/socket/utils.ts
68070
- /**
68071
- * Функція, що форматує URI WebSocket.
68072
- * @function
68073
- * @param {string} host - Хост.
68074
- * @returns {string} - URI WebSocket.
68075
- */
68076
- function formatWebSocketUri(host) {
68077
- return host.replace(/^http/, "ws");
68078
- }
68079
- /**
68080
- * Функція, що форматує базовий URI.
68081
- * @function
68082
- * @param {string} host - Хост.
68083
- * @returns {string} - Базовий URI.
68084
- */
68085
- function formatBaseUri(host) {
68086
- let res = host.replace(/^ws/, "http");
68087
- if (res.endsWith("/")) res = res.slice(0, -1);
68088
- if (res.endsWith("/ws")) res = res.slice(0, -3);
68089
- return res;
68090
- }
68091
- /**
68092
- * Функція, що розбиває рядок на частини заданої довжини.
68093
- * @function
68094
- * @param {string} str - Рядок.
68095
- * @param {number} len - Довжина частини.
68096
- * @returns {string[]} - Масив частин рядка.
68097
- */
68098
- function chunkString(str, len) {
68099
- const size = Math.ceil(str.length / len);
68100
- const r = new Array(size);
68101
- let offset = 0;
68102
- for (let i = 0; i < size; i++) {
68103
- r[i] = str.substring(offset, offset + len);
68104
- offset += len;
68105
- }
68106
- return r;
68107
- }
68108
- function generateId() {
68109
- return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
68110
- }
68111
- function generateTimestampFilename() {
68112
- const now = /* @__PURE__ */ new Date();
68113
- const pad = (num) => String(num).padStart(2, "0");
68114
- const year = now.getFullYear();
68115
- const month = pad(now.getMonth() + 1);
68116
- const day = pad(now.getDate());
68117
- const hours = pad(now.getHours());
68118
- const minutes = pad(now.getMinutes());
68119
- const seconds = pad(now.getSeconds());
68120
- return `${`${year}-${month}-${day}`}_${`${hours}_${minutes}_${seconds}`}`;
68121
- }
68122
- //#endregion
68123
68148
  //#region src/screen/storage.ts
68124
68149
  var StorageMediaCapture = class extends ee_ts.EventEmitter {
68125
68150
  constructor(id, name, mediaStream, iceServers, sdpResolver, token) {
@@ -70992,6 +71017,16 @@ var Client = class extends ee_ts.EventEmitter {
70992
71017
  };
70993
71018
  return this.registerCallClient(this.connectionInfo.b2bua ? new SipPhone$1(this, audioProcessing) : new SipPhone(this.instanceId, this._config.debug, audioProcessing));
70994
71019
  }
71020
+ async latency() {
71021
+ const ack = {
71022
+ client_ts: 0,
71023
+ client_ack_ts: 0,
71024
+ server_ts: 0,
71025
+ server_ack_ts: 0
71026
+ };
71027
+ Object.assign(ack, await this.request(`latency_start`, ack));
71028
+ return this.calculateLatency(ack);
71029
+ }
70995
71030
  async calculateLatency(ack) {
70996
71031
  ack.client_ts = Date.now();
70997
71032
  Object.assign(ack, await this.request(`latency_ack`, {