webitel-sdk 26.4.42 → 26.4.44
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 +122 -10
- package/index.cjs.map +1 -1
- package/index.mjs +122 -11
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/socket/agent.d.ts +29 -1
- package/socket/agent.d.ts.map +1 -1
- package/socket/task.d.ts +2 -0
- package/socket/task.d.ts.map +1 -1
- package/version.d.ts +1 -1
package/index.cjs
CHANGED
|
@@ -66734,7 +66734,7 @@ _defineProperty(SipPhone$1, "userAgent", `Webitel-Phone/${version$1}`);
|
|
|
66734
66734
|
_defineProperty(SipPhone$1, "sipVersion", version$1);
|
|
66735
66735
|
//#endregion
|
|
66736
66736
|
//#region src/version.ts
|
|
66737
|
-
const version = "26.4.
|
|
66737
|
+
const version = "26.4.44";
|
|
66738
66738
|
//#endregion
|
|
66739
66739
|
//#region src/socket/errors.ts
|
|
66740
66740
|
/**
|
|
@@ -67287,6 +67287,10 @@ var Task = class {
|
|
|
67287
67287
|
get memberJoinedAt() {
|
|
67288
67288
|
return this.distribute.member_joined_at;
|
|
67289
67289
|
}
|
|
67290
|
+
get acceptTimeoutSec() {
|
|
67291
|
+
var _this$distribute;
|
|
67292
|
+
return ((_this$distribute = this.distribute) === null || _this$distribute === void 0 ? void 0 : _this$distribute.team_accept_timeout) || 0;
|
|
67293
|
+
}
|
|
67290
67294
|
get autosave() {
|
|
67291
67295
|
return !!this.distribute.autosave;
|
|
67292
67296
|
}
|
|
@@ -67640,6 +67644,59 @@ function formFields(fields) {
|
|
|
67640
67644
|
}
|
|
67641
67645
|
//#endregion
|
|
67642
67646
|
//#region src/socket/agent.ts
|
|
67647
|
+
let WaitingCallSortField = /* @__PURE__ */ function(WaitingCallSortField) {
|
|
67648
|
+
WaitingCallSortField["Name"] = "name";
|
|
67649
|
+
WaitingCallSortField["DateTime"] = "joined_at";
|
|
67650
|
+
WaitingCallSortField["Duration"] = "duration";
|
|
67651
|
+
WaitingCallSortField["Queue"] = "queue";
|
|
67652
|
+
return WaitingCallSortField;
|
|
67653
|
+
}({});
|
|
67654
|
+
const DEFAULT_WAITING_CALLS_SIZE = 20;
|
|
67655
|
+
const nameCollator = new Intl.Collator(void 0, {
|
|
67656
|
+
numeric: true,
|
|
67657
|
+
sensitivity: "base"
|
|
67658
|
+
});
|
|
67659
|
+
const waitingCallSortFields = new Set(Object.values(WaitingCallSortField));
|
|
67660
|
+
const isWaitingCallSortField = (value) => waitingCallSortFields.has(value);
|
|
67661
|
+
const parseSort = (sort) => {
|
|
67662
|
+
if (!sort) return null;
|
|
67663
|
+
const first = sort.charAt(0);
|
|
67664
|
+
const field = (first === "+" || first === "-" || first === " " ? sort.slice(1) : sort).trim();
|
|
67665
|
+
if (!isWaitingCallSortField(field)) return null;
|
|
67666
|
+
return {
|
|
67667
|
+
field,
|
|
67668
|
+
direction: first === "-" ? -1 : 1
|
|
67669
|
+
};
|
|
67670
|
+
};
|
|
67671
|
+
const getQueueName = (queue) => queue && "name" in queue && typeof queue.name === "string" ? queue.name : "";
|
|
67672
|
+
const parseContact = (value) => {
|
|
67673
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
67674
|
+
const { id, name } = value;
|
|
67675
|
+
if (id === void 0 || id === null || id === "" || id === 0) return void 0;
|
|
67676
|
+
return {
|
|
67677
|
+
id: typeof id === "number" ? id : 0,
|
|
67678
|
+
name: typeof name === "string" ? name : ""
|
|
67679
|
+
};
|
|
67680
|
+
};
|
|
67681
|
+
const normalizeSize = (value) => Number.isFinite(value) ? Math.max(1, Math.floor(value)) : DEFAULT_WAITING_CALLS_SIZE;
|
|
67682
|
+
const waitingCallComparators = {
|
|
67683
|
+
["name"]: (a, b) => nameCollator.compare(a.displayName, b.displayName),
|
|
67684
|
+
["joined_at"]: (a, b) => a.joinedAt - b.joinedAt,
|
|
67685
|
+
["duration"]: (a, b) => b.joinedAt - a.joinedAt,
|
|
67686
|
+
["queue"]: (a, b) => nameCollator.compare(getQueueName(a.queue), getQueueName(b.queue))
|
|
67687
|
+
};
|
|
67688
|
+
const PHONE_QUERY_PATTERN = /^[\d\s+()\-.]+$/;
|
|
67689
|
+
const filterWaitingCalls = (calls, q) => {
|
|
67690
|
+
const text = q.trim().toLocaleLowerCase();
|
|
67691
|
+
if (text === "") return calls;
|
|
67692
|
+
const digits = PHONE_QUERY_PATTERN.test(text) ? text.replace(/\D/g, "") : "";
|
|
67693
|
+
return calls.filter((call) => call.displayName.toLocaleLowerCase().includes(text) || call.displayNumber.toLocaleLowerCase().includes(text) || digits !== "" && call.displayNumber.replace(/\D/g, "").includes(digits));
|
|
67694
|
+
};
|
|
67695
|
+
const sortWaitingCalls = (calls, sort) => {
|
|
67696
|
+
if (!sort) return [...calls];
|
|
67697
|
+
const compare = waitingCallComparators[sort.field];
|
|
67698
|
+
return [...calls].sort((a, b) => compare(a, b) * sort.direction || a.attemptId - b.attemptId);
|
|
67699
|
+
};
|
|
67643
67700
|
/**
|
|
67644
67701
|
* Перелік статусів агента.
|
|
67645
67702
|
* @enum {string}
|
|
@@ -67779,6 +67836,15 @@ var Agent = class {
|
|
|
67779
67836
|
_defineProperty(this, "_listOfflineMembers", void 0);
|
|
67780
67837
|
_defineProperty(this, "lastStatusChange", void 0);
|
|
67781
67838
|
_defineProperty(this, "_waitingChatsSize", 0);
|
|
67839
|
+
_defineProperty(this, "_waitingCalls", []);
|
|
67840
|
+
_defineProperty(this, "_waitingCallsQuery", {
|
|
67841
|
+
q: "",
|
|
67842
|
+
size: DEFAULT_WAITING_CALLS_SIZE,
|
|
67843
|
+
sort: null
|
|
67844
|
+
});
|
|
67845
|
+
_defineProperty(this, "_waitingCallsVisible", DEFAULT_WAITING_CALLS_SIZE);
|
|
67846
|
+
_defineProperty(this, "_waitingCallsTotal", 0);
|
|
67847
|
+
_defineProperty(this, "_waitingCallsAll", 0);
|
|
67782
67848
|
this.task = /* @__PURE__ */ new Map();
|
|
67783
67849
|
this._channels = /* @__PURE__ */ new Map();
|
|
67784
67850
|
this.initChannels(info.channels);
|
|
@@ -67826,6 +67892,15 @@ var Agent = class {
|
|
|
67826
67892
|
get statusComment() {
|
|
67827
67893
|
return this.info.status_comment;
|
|
67828
67894
|
}
|
|
67895
|
+
get waitingCallsTotal() {
|
|
67896
|
+
return this._waitingCallsTotal;
|
|
67897
|
+
}
|
|
67898
|
+
get hasMoreWaitingCalls() {
|
|
67899
|
+
return this._waitingCallsVisible < this._waitingCallsTotal;
|
|
67900
|
+
}
|
|
67901
|
+
get waitingCallsQuery() {
|
|
67902
|
+
return this._waitingCallsQuery;
|
|
67903
|
+
}
|
|
67829
67904
|
/**
|
|
67830
67905
|
* Метод, що повертає, чи є агент адміністратором.
|
|
67831
67906
|
* @method
|
|
@@ -67858,6 +67933,9 @@ var Agent = class {
|
|
|
67858
67933
|
get supervisor() {
|
|
67859
67934
|
return this.info.supervisor;
|
|
67860
67935
|
}
|
|
67936
|
+
get waitingCallsAllCount() {
|
|
67937
|
+
return this._waitingCallsAll;
|
|
67938
|
+
}
|
|
67861
67939
|
/**
|
|
67862
67940
|
* Метод, що повертає аудитора агента.
|
|
67863
67941
|
* @method
|
|
@@ -67900,19 +67978,26 @@ var Agent = class {
|
|
|
67900
67978
|
*/
|
|
67901
67979
|
setWaitingList(e) {
|
|
67902
67980
|
if (e) {
|
|
67903
|
-
this.
|
|
67981
|
+
this._waitingCalls.length = 0;
|
|
67904
67982
|
this.waitingListChats.length = 0;
|
|
67905
67983
|
this._waitingChatsSize = 0;
|
|
67906
|
-
if (this.status !== "online")
|
|
67907
|
-
|
|
67984
|
+
if (this.status !== "online") {
|
|
67985
|
+
this.refreshWaitingCalls();
|
|
67986
|
+
return;
|
|
67987
|
+
}
|
|
67988
|
+
const now = Date.now();
|
|
67989
|
+
for (const el of e.calls || []) this._waitingCalls.push({
|
|
67908
67990
|
displayName: el.communication.name || "",
|
|
67909
67991
|
displayNumber: el.communication.destination || "",
|
|
67910
67992
|
attemptId: el.attempt_id,
|
|
67911
67993
|
sessionId: el.session_id,
|
|
67912
67994
|
deadline: el.deadline,
|
|
67913
67995
|
queue: el.queue,
|
|
67914
|
-
wait: el.wait
|
|
67996
|
+
wait: el.wait,
|
|
67997
|
+
joinedAt: now - el.wait * 1e3,
|
|
67998
|
+
contact: parseContact(el.contact)
|
|
67915
67999
|
});
|
|
68000
|
+
this.refreshWaitingCalls();
|
|
67916
68001
|
if (Array.isArray(e.chats)) this._waitingChatsSize = e.chats.length;
|
|
67917
68002
|
for (const el of e.chats || []) {
|
|
67918
68003
|
this.waitingListChats.push({
|
|
@@ -67937,11 +68022,13 @@ var Agent = class {
|
|
|
67937
68022
|
* @param {keyable | undefined} e - Об'єкт зі списком членів, які очікують на відповідь.
|
|
67938
68023
|
*/
|
|
67939
68024
|
deleteWaitingAttempt(e) {
|
|
67940
|
-
if (e)
|
|
67941
|
-
|
|
67942
|
-
|
|
67943
|
-
|
|
68025
|
+
if (!e) return;
|
|
68026
|
+
const attemptId = e.attempt_id;
|
|
68027
|
+
if (removeWaitingList(this._waitingCalls, attemptId)) {
|
|
68028
|
+
this.refreshWaitingCalls();
|
|
68029
|
+
return;
|
|
67944
68030
|
}
|
|
68031
|
+
if (removeWaitingList(this.waitingListChats, attemptId)) this._waitingChatsSize--;
|
|
67945
68032
|
}
|
|
67946
68033
|
/**
|
|
67947
68034
|
* Метод, що перехоплює спробу.
|
|
@@ -68142,7 +68229,8 @@ var Agent = class {
|
|
|
68142
68229
|
this.info.on_demand = e.on_demand || false;
|
|
68143
68230
|
this.initChannels(e.channels);
|
|
68144
68231
|
} else {
|
|
68145
|
-
this.
|
|
68232
|
+
this._waitingCalls.length = 0;
|
|
68233
|
+
this.refreshWaitingCalls();
|
|
68146
68234
|
this.waitingListChats.length = 0;
|
|
68147
68235
|
this._waitingChatsSize = 0;
|
|
68148
68236
|
}
|
|
@@ -68193,6 +68281,29 @@ var Agent = class {
|
|
|
68193
68281
|
hasTask(task) {
|
|
68194
68282
|
return this.task.has(task.id);
|
|
68195
68283
|
}
|
|
68284
|
+
setWaitingCallsQuery(patch) {
|
|
68285
|
+
const next = {
|
|
68286
|
+
...this._waitingCallsQuery,
|
|
68287
|
+
...patch
|
|
68288
|
+
};
|
|
68289
|
+
next.size = normalizeSize(next.size);
|
|
68290
|
+
this._waitingCallsQuery = next;
|
|
68291
|
+
this._waitingCallsVisible = next.size;
|
|
68292
|
+
this.refreshWaitingCalls();
|
|
68293
|
+
}
|
|
68294
|
+
loadMoreWaitingCalls() {
|
|
68295
|
+
if (!this.hasMoreWaitingCalls) return false;
|
|
68296
|
+
this._waitingCallsVisible += this._waitingCallsQuery.size;
|
|
68297
|
+
this.refreshWaitingCalls();
|
|
68298
|
+
return true;
|
|
68299
|
+
}
|
|
68300
|
+
refreshWaitingCalls() {
|
|
68301
|
+
const { q, sort } = this._waitingCallsQuery;
|
|
68302
|
+
const result = sortWaitingCalls(filterWaitingCalls(this._waitingCalls, q), parseSort(sort));
|
|
68303
|
+
this._waitingCallsTotal = result.length;
|
|
68304
|
+
this._waitingCallsAll = this._waitingCalls.length;
|
|
68305
|
+
this.waitingListCalls.splice(0, this.waitingListCalls.length, ...result.slice(0, this._waitingCallsVisible));
|
|
68306
|
+
}
|
|
68196
68307
|
initChannels(channels) {
|
|
68197
68308
|
for (const c of channels) this._channels.set(c.channel, c);
|
|
68198
68309
|
}
|
|
@@ -71949,6 +72060,7 @@ exports.VariablesApiFactory = VariablesApiFactory;
|
|
|
71949
72060
|
exports.VariablesApiFp = VariablesApiFp;
|
|
71950
72061
|
exports.VideoMediaFlow = VideoMediaFlow;
|
|
71951
72062
|
exports.WEBSOCKET_EVENT_CALL_MEDIA_METRIC = WEBSOCKET_EVENT_CALL_MEDIA_METRIC;
|
|
72063
|
+
exports.WaitingCallSortField = WaitingCallSortField;
|
|
71952
72064
|
exports.WebHookServiceApi = WebHookServiceApi;
|
|
71953
72065
|
exports.WebHookServiceApiAxiosParamCreator = WebHookServiceApiAxiosParamCreator;
|
|
71954
72066
|
exports.WebHookServiceApiFactory = WebHookServiceApiFactory;
|