szdl-utils-kit 0.3.19 → 0.3.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/dist/index.js +229 -217
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var M = (y, t, e) => (Wt(y, t, "read from private field"), e ? e.call(y) : t.get
|
|
|
8
8
|
if (t.has(y))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(y) : t.set(y, e);
|
|
11
|
-
},
|
|
11
|
+
}, x = (y, t, e, r) => (Wt(y, t, "write to private field"), r ? r.call(y, e) : t.set(y, e), e);
|
|
12
12
|
var _ = (y, t, e) => (Wt(y, t, "access private method"), e);
|
|
13
13
|
var pe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
14
|
function Ne(y) {
|
|
@@ -239,7 +239,7 @@ var Xt = { exports: {} };
|
|
|
239
239
|
h[A].NOVEMBER_SHORT,
|
|
240
240
|
h[A].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, b = function() {
|
|
243
243
|
return [
|
|
244
244
|
h[A].SUNDAY_LONG,
|
|
245
245
|
h[A].MONDAY_LONG,
|
|
@@ -249,7 +249,7 @@ var Xt = { exports: {} };
|
|
|
249
249
|
h[A].FRIDAY_LONG,
|
|
250
250
|
h[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, S = function() {
|
|
253
253
|
return [
|
|
254
254
|
h[A].SUNDAY_SHORT,
|
|
255
255
|
h[A].MONDAY_SHORT,
|
|
@@ -259,13 +259,13 @@ var Xt = { exports: {} };
|
|
|
259
259
|
h[A].FRIDAY_SHORT,
|
|
260
260
|
h[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
}, p,
|
|
262
|
+
}, p, E, C, N, I = function(s, o, m) {
|
|
263
263
|
var g;
|
|
264
264
|
r.XMLHttpRequest ? g = new XMLHttpRequest() : g = new ActiveXObject("Microsoft.XMLHTTP"), g.onreadystatechange = function() {
|
|
265
265
|
g.readyState === 4 && (g.status === 200 ? o && (r.JSON === e ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
266
|
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) : m && m(g));
|
|
267
267
|
}, g.open("GET", s, !1), g.send();
|
|
268
|
-
},
|
|
268
|
+
}, R = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(s) {
|
|
271
271
|
return i(s.day() || n.MIN_DAY, 2);
|
|
@@ -340,7 +340,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
340
340
|
"%b": {
|
|
341
341
|
format: function(s) {
|
|
342
342
|
var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
|
|
343
|
-
return
|
|
343
|
+
return E[o !== e ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(s) {
|
|
346
346
|
var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
@@ -520,7 +520,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
520
520
|
if (typeof s == "number")
|
|
521
521
|
return this._d = new Date(s * (n.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
522
522
|
if (typeof s == "object" && (s instanceof Array ? (this.day(n.MIN_DAY), this.year(s[0]), this.month(s[1]), this.day(s[2]), this.hours(s[3]), this.minutes(s[4]), this.seconds(s[5]), this.milliseconds(s[6])) : (this.day(n.MIN_DAY), this.year(s.year), this.month(s.month), this.day(s.day), this.hours(s.hours), this.minutes(s.minutes), this.seconds(s.seconds), this.milliseconds(s.milliseconds))), typeof s == "string") {
|
|
523
|
-
var g, B = [], D, U,
|
|
523
|
+
var g, B = [], D, U, z = [], W = 0, F = 0, G, J, Y = {}, P;
|
|
524
524
|
if (s === e)
|
|
525
525
|
return D = a(this, m), D === e && (this._i = {
|
|
526
526
|
year: -1,
|
|
@@ -533,22 +533,22 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
533
533
|
}), D;
|
|
534
534
|
for (o === e && (o = n.detectFormat(s)); W < o.length; ) {
|
|
535
535
|
if (o.charAt(W) === "%") {
|
|
536
|
-
if (U = o.charAt(W) + o.charAt(W + 1),
|
|
537
|
-
switch (G = 0, J = "",
|
|
536
|
+
if (U = o.charAt(W) + o.charAt(W + 1), R[U] !== e) {
|
|
537
|
+
switch (G = 0, J = "", R[U].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (; G <
|
|
540
|
-
J += s.charAt(
|
|
539
|
+
for (; G < R[U].maxLength && F + G < s.length && !isNaN(Number(s.charAt(F + G))); )
|
|
540
|
+
J += s.charAt(F + G), G += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (; G <
|
|
544
|
-
J += s.charAt(
|
|
543
|
+
for (; G < R[U].maxLength && F + G < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + G)); )
|
|
544
|
+
J += s.charAt(F + G), G += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (; G <
|
|
548
|
-
J += s.charAt(
|
|
547
|
+
for (; G < R[U].maxLength && F + G < s.length; )
|
|
548
|
+
J += s.charAt(F + G), G += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (G <
|
|
551
|
+
if (G < R[U].minLength)
|
|
552
552
|
return D = a(this, m), D === e && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
@@ -558,9 +558,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
560
|
}), D;
|
|
561
|
-
B.push(U),
|
|
561
|
+
B.push(U), z.push(J), G -= 1, F += G, W += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (s.charAt(
|
|
563
|
+
} else if (s.charAt(F) !== o.charAt(W))
|
|
564
564
|
return D = a(this, m), D === e && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
@@ -570,10 +570,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
570
570
|
seconds: -1,
|
|
571
571
|
milliseconds: -1
|
|
572
572
|
}), D;
|
|
573
|
-
W += 1,
|
|
573
|
+
W += 1, F += 1;
|
|
574
574
|
}
|
|
575
575
|
for (g in B)
|
|
576
|
-
B.hasOwnProperty(g) &&
|
|
576
|
+
B.hasOwnProperty(g) && R.hasOwnProperty(B[g]) && (P = R[B[g]].parse(z[g]), Y = {
|
|
577
577
|
year: P.year !== e ? P.year : Y.year,
|
|
578
578
|
month: P.month !== e ? P.month : Y.month,
|
|
579
579
|
day: P.day !== e ? P.day : Y.day,
|
|
@@ -672,7 +672,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
672
672
|
}
|
|
673
673
|
}, w.fn.format = function(s) {
|
|
674
674
|
for (var o = 0, m = "", g; o < s.length; )
|
|
675
|
-
s.charAt(o) === "%" ? (g = s.charAt(o) + s.charAt(o + 1),
|
|
675
|
+
s.charAt(o) === "%" ? (g = s.charAt(o) + s.charAt(o + 1), R[g] !== e ? (m += R[g].format(this), o += 1) : m += "%") : m += s.charAt(o), o += 1;
|
|
676
676
|
return m;
|
|
677
677
|
}, w.fn.valid = function() {
|
|
678
678
|
return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
|
|
@@ -712,7 +712,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
712
712
|
}, n.noConflict = function() {
|
|
713
713
|
return r.tempus = u, n;
|
|
714
714
|
}, n.generate = function(s) {
|
|
715
|
-
var o, m, g, B, D, U,
|
|
715
|
+
var o, m, g, B, D, U, z, W;
|
|
716
716
|
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof w ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof w ? m = s.dateTo.utc() : m = n(s.dateTo, s.formatTo !== e ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? D = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
@@ -734,10 +734,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
734
734
|
hours: s.period.hours !== e ? s.period.hours : 0,
|
|
735
735
|
minutes: s.period.minutes !== e ? s.period.minutes : 0,
|
|
736
736
|
seconds: s.period.seconds !== e ? s.period.seconds : 0
|
|
737
|
-
}), s.groupBy === e ? U = s.asObject === !0 ? {} : [] : (U = [], U.push([]),
|
|
737
|
+
}), s.groupBy === e ? U = s.asObject === !0 ? {} : [] : (U = [], U.push([]), z = n(o).get()[s.groupBy]), W = function(J, Y, P) {
|
|
738
738
|
return s.asObject === !0 ? s.format !== e ? J[n(Y).format(s.format)] = {} : J[n(Y).format("%F %H:%M:%S")] = {} : s.format !== e ? J.push(P ? null : n(Y).format(s.format)) : J.push(P ? null : n(Y)), J;
|
|
739
739
|
}, s.groupBy !== e && s.fillNulls) {
|
|
740
|
-
var
|
|
740
|
+
var F = {
|
|
741
741
|
year: D.year ? -D.year : e,
|
|
742
742
|
month: D.month ? -D.month : e,
|
|
743
743
|
day: D.day ? -D.day : e,
|
|
@@ -746,8 +746,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
746
746
|
seconds: D.seconds ? -D.seconds : e,
|
|
747
747
|
milliseconds: D.milliseconds ? -D.milliseconds : e
|
|
748
748
|
};
|
|
749
|
-
for (g = n(o).calc(
|
|
750
|
-
W(U[U.length - 1], g, !0), g = n(g).calc(
|
|
749
|
+
for (g = n(o).calc(F).utc(); n(g).get()[s.groupBy] === z; )
|
|
750
|
+
W(U[U.length - 1], g, !0), g = n(g).calc(F).utc();
|
|
751
751
|
if (s.groupBy === "week") {
|
|
752
752
|
var G = n(o).dayOfWeek();
|
|
753
753
|
for (g = n(o).dayOfWeek(0).utc(); U[0].length < G && g < o; )
|
|
@@ -755,9 +755,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
for (; o <= m; )
|
|
758
|
-
s.groupBy === e ? W(U, o) : n(o).get()[s.groupBy] ===
|
|
758
|
+
s.groupBy === e ? W(U, o) : n(o).get()[s.groupBy] === z ? W(U[U.length - 1], o) : (U.push([]), W(U[U.length - 1], o), z = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
|
|
759
759
|
if (s.groupBy !== e && s.fillNulls)
|
|
760
|
-
for (B = n(m).calc(D).utc(); n(B).get()[s.groupBy] ===
|
|
760
|
+
for (B = n(m).calc(D).utc(); n(B).get()[s.groupBy] === z; )
|
|
761
761
|
W(U[U.length - 1], B, !0), B = n(B).calc(D).utc();
|
|
762
762
|
return U;
|
|
763
763
|
}, n.monthNames = function(s) {
|
|
@@ -765,7 +765,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
765
765
|
case "long":
|
|
766
766
|
return p;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return E;
|
|
769
769
|
}
|
|
770
770
|
}, n.dayNames = function(s) {
|
|
771
771
|
switch (s) {
|
|
@@ -776,14 +776,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
776
776
|
}
|
|
777
777
|
}, n.lang = function(s) {
|
|
778
778
|
if (s !== e)
|
|
779
|
-
A = s, h[A] === e && (A = "en"), p = O(),
|
|
779
|
+
A = s, h[A] === e && (A = "en"), p = O(), E = T(), C = b(), N = S();
|
|
780
780
|
else
|
|
781
781
|
return A;
|
|
782
782
|
return e;
|
|
783
783
|
}, n.availableLangs = function() {
|
|
784
784
|
return Object.keys(h);
|
|
785
785
|
}, n.registerFormat = function(s, o, m, g, B, D) {
|
|
786
|
-
|
|
786
|
+
R[s] = {
|
|
787
787
|
format: o,
|
|
788
788
|
parse: m,
|
|
789
789
|
minLength: g,
|
|
@@ -791,7 +791,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
791
791
|
type: D
|
|
792
792
|
};
|
|
793
793
|
}, n.unregisterFormat = function(s) {
|
|
794
|
-
delete
|
|
794
|
+
delete R[s];
|
|
795
795
|
}, n.detectFormat = function(s) {
|
|
796
796
|
var o, m, g;
|
|
797
797
|
return o = l(s, 0), o !== "" && (g = 10), m = s.charAt(g), (m === "T" || m === " ") && (o += m, g += 1), o += c(s, g), o;
|
|
@@ -806,12 +806,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
806
806
|
h = o;
|
|
807
807
|
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), h[A] === e && (A = "en"), p = O(),
|
|
809
|
+
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), h[A] === e && (A = "en"), p = O(), E = T(), C = b(), N = S(), y.exports && (t = y.exports = n), t.tempus = n;
|
|
810
810
|
}).call(pe);
|
|
811
811
|
})(Xt, Xt.exports);
|
|
812
812
|
var Oe = Xt.exports;
|
|
813
|
-
const
|
|
814
|
-
var
|
|
813
|
+
const Nt = /* @__PURE__ */ Ne(Oe);
|
|
814
|
+
var Tt, $t, Et, bt, Rt, Lt, at, Ot, St, te, It, ee, Q, it, $, lt, tt, ht, Mt, se, ut, Jt;
|
|
815
815
|
const j = class j {
|
|
816
816
|
constructor(t) {
|
|
817
817
|
/**
|
|
@@ -820,7 +820,7 @@ const j = class j {
|
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
L(this,
|
|
823
|
+
L(this, Tt);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
@@ -832,13 +832,13 @@ const j = class j {
|
|
|
832
832
|
* @param {{percent: number, allCount: number, allTotal: number}} snapshot - Текущий снимок прогресса.
|
|
833
833
|
* @returns {boolean} `true`, если нужно отправить callback прогресса.
|
|
834
834
|
*/
|
|
835
|
-
L(this,
|
|
835
|
+
L(this, St);
|
|
836
836
|
/**
|
|
837
837
|
* Уведомляет подписчиков о текущем состоянии лимита.
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
L(this,
|
|
841
|
+
L(this, It);
|
|
842
842
|
/**
|
|
843
843
|
* Включает состояние лимита, выдерживает паузу и затем выключает лимит.
|
|
844
844
|
* Используется как единый "cooldown" перед повторной отправкой chunk.
|
|
@@ -846,7 +846,7 @@ const j = class j {
|
|
|
846
846
|
* @param {number} [pauseMs=this.defaultPauseMs] - Длительность паузы; для batch по умолчанию 120 с, для `call()` — `callLimitPauseMs` (30 с).
|
|
847
847
|
* @returns {Promise<void>}
|
|
848
848
|
*/
|
|
849
|
-
L(this,
|
|
849
|
+
L(this, Q);
|
|
850
850
|
/**
|
|
851
851
|
* Проверяет operating-time в результате batch и ставит паузу,
|
|
852
852
|
* если сервер приблизился к лимиту выполнения.
|
|
@@ -871,7 +871,7 @@ const j = class j {
|
|
|
871
871
|
* @param {Object} params - Параметры REST-метода.
|
|
872
872
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
873
|
*/
|
|
874
|
-
L(this,
|
|
874
|
+
L(this, Mt);
|
|
875
875
|
/**
|
|
876
876
|
* Resets mutable runtime state before each public batch run.
|
|
877
877
|
* @param {Function} progressCall - Progress callback for current run.
|
|
@@ -892,7 +892,7 @@ const j = class j {
|
|
|
892
892
|
if (!this.progressData)
|
|
893
893
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
894
894
|
const t = this.totalBatchCommands || 0;
|
|
895
|
-
if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && _(this,
|
|
895
|
+
if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && _(this, Tt, $t).call(this)) {
|
|
896
896
|
let l = 0;
|
|
897
897
|
for (const A of this.batchCommandKeyOrder) {
|
|
898
898
|
const h = this.progressData[A];
|
|
@@ -933,8 +933,8 @@ const j = class j {
|
|
|
933
933
|
if (typeof e.total == "function") {
|
|
934
934
|
const T = e.total();
|
|
935
935
|
if (T != null && T !== "") {
|
|
936
|
-
const
|
|
937
|
-
Number.isFinite(
|
|
936
|
+
const b = Number(T);
|
|
937
|
+
Number.isFinite(b) && (c = b);
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
940
|
r === "count" && (c = a);
|
|
@@ -945,15 +945,15 @@ const j = class j {
|
|
|
945
945
|
total: d,
|
|
946
946
|
count: Math.min(f, d)
|
|
947
947
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
948
|
-
_(this, at,
|
|
948
|
+
_(this, at, Ot).call(this);
|
|
949
949
|
return;
|
|
950
950
|
}
|
|
951
|
-
_(this, at,
|
|
951
|
+
_(this, at, Ot).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
952
952
|
if (!this.progressCall) {
|
|
953
953
|
this.clearProgressData();
|
|
954
954
|
return;
|
|
955
955
|
}
|
|
956
|
-
_(this, at,
|
|
956
|
+
_(this, at, Ot).call(this);
|
|
957
957
|
const { percent: T } = this.progressPercent;
|
|
958
958
|
T >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
959
959
|
}, this.progressDelay));
|
|
@@ -978,7 +978,7 @@ const j = class j {
|
|
|
978
978
|
* @returns {void}
|
|
979
979
|
*/
|
|
980
980
|
setTimeLimitState(t, e, r) {
|
|
981
|
-
this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, _(this,
|
|
981
|
+
this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, _(this, It, ee).call(this);
|
|
982
982
|
}
|
|
983
983
|
/**
|
|
984
984
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1225,17 +1225,17 @@ const j = class j {
|
|
|
1225
1225
|
this.totalProgress = Math.round(Number(u) / c.length * 100);
|
|
1226
1226
|
const f = Number(u) === c.length - 1;
|
|
1227
1227
|
await _(this, tt, ht).call(this, n, async (d) => {
|
|
1228
|
-
var A, h, O, T,
|
|
1229
|
-
for (const [
|
|
1228
|
+
var A, h, O, T, b;
|
|
1229
|
+
for (const [S, p] of Object.entries(d)) {
|
|
1230
1230
|
if (!this.canContinue)
|
|
1231
1231
|
return;
|
|
1232
1232
|
if (p.error()) {
|
|
1233
|
-
const
|
|
1234
|
-
this.errors[
|
|
1233
|
+
const R = (h = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : h.error, k = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1234
|
+
this.errors[S] = R && R.trim() || k && k.trim() || ((b = p.error()) == null ? void 0 : b.toString()) || "Неизвестная ошибка", r[S] = 0;
|
|
1235
1235
|
continue;
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
r[
|
|
1237
|
+
const E = this.getData(p.data()), C = Array.isArray(E) ? E.length : 0, I = typeof p.total == "function" && p.total() !== void 0 ? p.total() : C;
|
|
1238
|
+
r[S] = I, this.setProgressData({ key: S, value: p, type: "count" });
|
|
1239
1239
|
}
|
|
1240
1240
|
await _(this, $, lt).call(this, d, !f);
|
|
1241
1241
|
});
|
|
@@ -1259,9 +1259,9 @@ const j = class j {
|
|
|
1259
1259
|
async call({ method: t, params: e = {} }) {
|
|
1260
1260
|
var r, i, a, c, l, u, n;
|
|
1261
1261
|
for (; ; ) {
|
|
1262
|
-
const f = await _(this,
|
|
1262
|
+
const f = await _(this, Mt, se).call(this, t, e);
|
|
1263
1263
|
if (!f) {
|
|
1264
|
-
await _(this,
|
|
1264
|
+
await _(this, Q, it).call(this, this.callLimitPauseMs);
|
|
1265
1265
|
continue;
|
|
1266
1266
|
}
|
|
1267
1267
|
const d = {};
|
|
@@ -1271,7 +1271,7 @@ const j = class j {
|
|
|
1271
1271
|
if (f.error()) {
|
|
1272
1272
|
const h = ((i = (r = f.error()) == null ? void 0 : r.ex) == null ? void 0 : i.error) ?? "";
|
|
1273
1273
|
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(h)) {
|
|
1274
|
-
await _(this,
|
|
1274
|
+
await _(this, Q, it).call(this, this.callLimitPauseMs);
|
|
1275
1275
|
continue;
|
|
1276
1276
|
}
|
|
1277
1277
|
const O = ((a = f.error()) == null ? void 0 : a.toString()) || ((l = (c = f.error()) == null ? void 0 : c.ex) == null ? void 0 : l.error_description) || ((n = (u = f.error()) == null ? void 0 : u.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
|
|
@@ -1335,19 +1335,19 @@ const j = class j {
|
|
|
1335
1335
|
const u = !!(i != null && i.disablePagination);
|
|
1336
1336
|
(async () => {
|
|
1337
1337
|
await _(this, tt, ht).call(this, t, async (f) => {
|
|
1338
|
-
var A, h, O, T,
|
|
1339
|
-
for (const [
|
|
1338
|
+
var A, h, O, T, b;
|
|
1339
|
+
for (const [S, p] of Object.entries(f)) {
|
|
1340
1340
|
if (!this.canContinue)
|
|
1341
1341
|
return;
|
|
1342
1342
|
if (p.error()) {
|
|
1343
1343
|
const g = (h = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : h.error, B = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1344
|
-
this.errors[
|
|
1344
|
+
this.errors[S] = g && g.trim() || B && B.trim() || ((b = p.error()) == null ? void 0 : b.toString()) || "Неизвестная ошибка", l = !0;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
e === "count" ? this.result[
|
|
1348
|
-
const
|
|
1346
|
+
const E = this.getData(p.data()), C = Array.isArray(E) ? E.length : 0, N = typeof p.total == "function" && p.total() !== void 0, I = N ? p.total() : C;
|
|
1347
|
+
e === "count" ? this.result[S] ? this.result[S] += C : this.result[S] = I : this.result[S] = E, this.setProgressData({ key: S, value: p, type: e });
|
|
1348
|
+
const R = t[S], k = Array.isArray(R) ? R[0] : R == null ? void 0 : R.method, w = typeof k == "string" && (k.includes(".list") || k === "user.get" || k === "entity.item.get"), s = e === "count" ? !N && C === this.limit : w ? C === this.limit : I > this.limit && I > C, o = e !== "count" && k === "entity.item.get" && C === this.limit && !s, m = s || o;
|
|
1349
1349
|
if (!u && (!this.canContinue || m)) {
|
|
1350
|
-
let g = t[
|
|
1350
|
+
let g = t[S];
|
|
1351
1351
|
if (Array.isArray(g)) {
|
|
1352
1352
|
const [B, D = {}] = g;
|
|
1353
1353
|
g = [B, D];
|
|
@@ -1356,7 +1356,7 @@ const j = class j {
|
|
|
1356
1356
|
g = [B, D];
|
|
1357
1357
|
}
|
|
1358
1358
|
c.push([
|
|
1359
|
-
|
|
1359
|
+
S,
|
|
1360
1360
|
g,
|
|
1361
1361
|
I,
|
|
1362
1362
|
{ entityItemGetScan: o }
|
|
@@ -1378,72 +1378,72 @@ const j = class j {
|
|
|
1378
1378
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1379
1379
|
*/
|
|
1380
1380
|
async batchPayload(t, e, r = {}) {
|
|
1381
|
-
const i = !!(r != null && r.oneBatch), a = (O, T,
|
|
1381
|
+
const i = !!(r != null && r.oneBatch), a = (O, T, b, S) => {
|
|
1382
1382
|
let p = "ID";
|
|
1383
1383
|
this.result[O][this.result[O].length - 1].ID || (p = "id");
|
|
1384
|
-
let
|
|
1385
|
-
if (JSON.stringify(
|
|
1384
|
+
let E = `${p}`;
|
|
1385
|
+
if (JSON.stringify(S[1]).toLocaleLowerCase().includes('"id":"desc"') ? E = "<" + E : E = ">" + E, T === 1 || b.length === 0)
|
|
1386
1386
|
return {
|
|
1387
|
-
field:
|
|
1387
|
+
field: E,
|
|
1388
1388
|
id: this.result[O][this.result[O].length - 1][p]
|
|
1389
1389
|
};
|
|
1390
1390
|
let N = "";
|
|
1391
|
-
const [I,
|
|
1391
|
+
const [I, R] = S;
|
|
1392
1392
|
return (I === "tasks.task.list" || I === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(I) && (N = "[items]"), I === "crm.type.list" && (N = "[types]"), I === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
|
|
1393
|
-
field:
|
|
1393
|
+
field: E,
|
|
1394
1394
|
id: `$result[${[O, T - 1].join("__")}]${N}[49][${p}]`
|
|
1395
1395
|
};
|
|
1396
1396
|
}, c = (O, T) => {
|
|
1397
|
-
const [
|
|
1398
|
-
let p = JSON.parse(JSON.stringify(
|
|
1399
|
-
if (
|
|
1397
|
+
const [b, S] = O;
|
|
1398
|
+
let p = JSON.parse(JSON.stringify(S)), E;
|
|
1399
|
+
if (b === "task.item.list") {
|
|
1400
1400
|
p = [...p];
|
|
1401
|
-
const [C, N, I,
|
|
1402
|
-
return N[T.field] = T.id, [
|
|
1401
|
+
const [C, N, I, R] = p;
|
|
1402
|
+
return N[T.field] = T.id, [b, p];
|
|
1403
1403
|
}
|
|
1404
|
-
return ["user.get"].includes(
|
|
1404
|
+
return ["user.get"].includes(b) || p.FILTER ? (p.FILTER || (p.FILTER = {}), E = p.FILTER) : (p.filter || (p.filter = {}), E = p.filter), [
|
|
1405
1405
|
"socialnetwork.api.workgroup.list",
|
|
1406
1406
|
"tasks.task.list"
|
|
1407
|
-
].includes(
|
|
1407
|
+
].includes(b) ? E[">ID"] = T.id : E[T.field] = T.id, [b, { ...p, start: -1 }];
|
|
1408
1408
|
}, l = (O) => {
|
|
1409
|
-
Object.entries(O).forEach(([T,
|
|
1410
|
-
var
|
|
1411
|
-
const [
|
|
1412
|
-
if (Array.isArray(p) && (e === "count" ? this.result[
|
|
1413
|
-
const k = (C = (
|
|
1414
|
-
this.errors[
|
|
1409
|
+
Object.entries(O).forEach(([T, b]) => {
|
|
1410
|
+
var E, C, N, I, R;
|
|
1411
|
+
const [S] = T.split("__"), p = this.getData(b.data());
|
|
1412
|
+
if (Array.isArray(p) && (e === "count" ? this.result[S] += p.length : this.result[S].push(...p)), b.error()) {
|
|
1413
|
+
const k = (C = (E = b.error()) == null ? void 0 : E.ex) == null ? void 0 : C.error, w = (I = (N = b.error()) == null ? void 0 : N.ex) == null ? void 0 : I.error_description;
|
|
1414
|
+
this.errors[S] = k && k.trim() || w && w.trim() || ((R = b.error()) == null ? void 0 : R.toString()) || "Неизвестная ошибка";
|
|
1415
1415
|
}
|
|
1416
|
-
this.setProgressData({ key:
|
|
1416
|
+
this.setProgressData({ key: S, value: b, type: e });
|
|
1417
1417
|
});
|
|
1418
1418
|
}, u = (O, T) => {
|
|
1419
1419
|
if (!Array.isArray(O) || O.length === 0)
|
|
1420
1420
|
return null;
|
|
1421
|
-
const
|
|
1422
|
-
let
|
|
1423
|
-
|
|
1424
|
-
let p =
|
|
1425
|
-
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? p = "<" + p : p = ">" + p, { field: p, id:
|
|
1421
|
+
const b = O[O.length - 1];
|
|
1422
|
+
let S = "ID";
|
|
1423
|
+
b.ID || (S = "id");
|
|
1424
|
+
let p = S;
|
|
1425
|
+
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? p = "<" + p : p = ">" + p, { field: p, id: b[S] };
|
|
1426
1426
|
}, n = 1e4, f = async (O, T) => {
|
|
1427
|
-
var
|
|
1428
|
-
let
|
|
1429
|
-
for (let
|
|
1427
|
+
var S, p;
|
|
1428
|
+
let b = this.limit;
|
|
1429
|
+
for (let E = 1; this.canContinue && b === this.limit && E <= n; E++) {
|
|
1430
1430
|
const C = this.result[O], N = u(C, T);
|
|
1431
1431
|
if (!N)
|
|
1432
1432
|
break;
|
|
1433
|
-
const I = `${O}__eiscan_${
|
|
1433
|
+
const I = `${O}__eiscan_${E}`, R = c(T, N);
|
|
1434
1434
|
let k = null;
|
|
1435
|
-
await _(this, tt, ht).call(this, { [I]:
|
|
1435
|
+
await _(this, tt, ht).call(this, { [I]: R }, async (m) => {
|
|
1436
1436
|
k = m, l(m);
|
|
1437
1437
|
});
|
|
1438
|
-
const w =
|
|
1438
|
+
const w = E < n;
|
|
1439
1439
|
await _(this, $, lt).call(this, k, w), await this.delay();
|
|
1440
1440
|
const s = k == null ? void 0 : k[I];
|
|
1441
|
-
if ((
|
|
1442
|
-
|
|
1441
|
+
if ((S = s == null ? void 0 : s.error) != null && S.call(s)) {
|
|
1442
|
+
b = 0;
|
|
1443
1443
|
break;
|
|
1444
1444
|
}
|
|
1445
1445
|
const o = this.getData((p = s == null ? void 0 : s.data) == null ? void 0 : p.call(s));
|
|
1446
|
-
|
|
1446
|
+
b = Array.isArray(o) ? o.length : 0;
|
|
1447
1447
|
}
|
|
1448
1448
|
};
|
|
1449
1449
|
let d = [], A = 0;
|
|
@@ -1453,21 +1453,21 @@ const j = class j {
|
|
|
1453
1453
|
for await (const O of t) {
|
|
1454
1454
|
if (!this.canContinue)
|
|
1455
1455
|
return;
|
|
1456
|
-
const [T,
|
|
1456
|
+
const [T, b, S, p = {}] = O;
|
|
1457
1457
|
if (p.entityItemGetScan) {
|
|
1458
1458
|
if (await h(!0))
|
|
1459
1459
|
return;
|
|
1460
1460
|
if (i)
|
|
1461
1461
|
continue;
|
|
1462
|
-
await f(T,
|
|
1462
|
+
await f(T, b);
|
|
1463
1463
|
continue;
|
|
1464
1464
|
}
|
|
1465
|
-
let
|
|
1466
|
-
for (;
|
|
1467
|
-
const C = [T,
|
|
1468
|
-
if (d.push([C, c(
|
|
1465
|
+
let E = 1;
|
|
1466
|
+
for (; S > E * this.limit; ) {
|
|
1467
|
+
const C = [T, E].join("__"), N = a(T, E, d, b);
|
|
1468
|
+
if (d.push([C, c(b, N)]), i && d.length === 49 && await h(!0) || d.length % 50 === 0 && await h(!0))
|
|
1469
1469
|
return;
|
|
1470
|
-
|
|
1470
|
+
E++;
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
await h(!1);
|
|
@@ -1481,29 +1481,29 @@ const j = class j {
|
|
|
1481
1481
|
}), console.groupEnd();
|
|
1482
1482
|
}
|
|
1483
1483
|
};
|
|
1484
|
-
|
|
1484
|
+
Tt = new WeakSet(), $t = function() {
|
|
1485
1485
|
const t = this.totalBatchCommands || 0, e = this.batchCommandMethods;
|
|
1486
|
-
if (t < M(j,
|
|
1486
|
+
if (t < M(j, Et) || !Array.isArray(e) || e.length !== t)
|
|
1487
1487
|
return !1;
|
|
1488
|
-
if (e.filter((a) => a === "crm.deal.list").length >= M(j,
|
|
1488
|
+
if (e.filter((a) => a === "crm.deal.list").length >= M(j, bt))
|
|
1489
1489
|
return !0;
|
|
1490
1490
|
const i = e.filter(
|
|
1491
1491
|
(a) => typeof a == "string" && a.includes(".list")
|
|
1492
1492
|
).length;
|
|
1493
|
-
return i >= M(j, Rt) && i / t >= M(j,
|
|
1494
|
-
},
|
|
1493
|
+
return i >= M(j, Rt) && i / t >= M(j, Lt);
|
|
1494
|
+
}, Et = new WeakMap(), bt = new WeakMap(), Rt = new WeakMap(), Lt = new WeakMap(), at = new WeakSet(), Ot = function() {
|
|
1495
1495
|
if (!this.progressCall || !this.progressData)
|
|
1496
1496
|
return;
|
|
1497
1497
|
const { percent: t, allCount: e, allTotal: r } = this.progressPercent, i = { percent: t, allCount: e, allTotal: r };
|
|
1498
|
-
_(this,
|
|
1498
|
+
_(this, St, te).call(this, i) && (this.progressCall({
|
|
1499
1499
|
data: this.progressData,
|
|
1500
1500
|
percent: t,
|
|
1501
1501
|
allCount: e,
|
|
1502
1502
|
allTotal: r
|
|
1503
1503
|
}), this.lastProgressSnapshot = i);
|
|
1504
|
-
},
|
|
1504
|
+
}, St = new WeakSet(), te = function(t) {
|
|
1505
1505
|
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== t.percent || this.lastProgressSnapshot.allCount !== t.allCount || this.lastProgressSnapshot.allTotal !== t.allTotal : !0;
|
|
1506
|
-
},
|
|
1506
|
+
}, It = new WeakSet(), ee = function() {
|
|
1507
1507
|
const t = {
|
|
1508
1508
|
limit: this.timeLimit.limit,
|
|
1509
1509
|
date: this.timeLimit.date,
|
|
@@ -1515,7 +1515,7 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1515
1515
|
} catch (r) {
|
|
1516
1516
|
console.warn("Batch timeLimit listener error:", r);
|
|
1517
1517
|
}
|
|
1518
|
-
},
|
|
1518
|
+
}, Q = new WeakSet(), it = async function(t = this.defaultPauseMs) {
|
|
1519
1519
|
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), t), await new Promise((e) => setTimeout(e, t)), this.setTimeLimitState(!1, void 0);
|
|
1520
1520
|
}, $ = new WeakSet(), lt = async function(t, e = !0) {
|
|
1521
1521
|
if (!e)
|
|
@@ -1532,7 +1532,7 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1532
1532
|
}
|
|
1533
1533
|
} catch {
|
|
1534
1534
|
}
|
|
1535
|
-
r >= this.operatingThreshold && await _(this,
|
|
1535
|
+
r >= this.operatingThreshold && await _(this, Q, it).call(this);
|
|
1536
1536
|
}, tt = new WeakSet(), ht = async function(t, e) {
|
|
1537
1537
|
let r = !1, i = t;
|
|
1538
1538
|
do
|
|
@@ -1551,7 +1551,7 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1551
1551
|
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && l.add(f);
|
|
1552
1552
|
}
|
|
1553
1553
|
if (c) {
|
|
1554
|
-
r = !0, await _(this,
|
|
1554
|
+
r = !0, await _(this, Q, it).call(this);
|
|
1555
1555
|
return;
|
|
1556
1556
|
}
|
|
1557
1557
|
if (l.size > 0) {
|
|
@@ -1562,13 +1562,13 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1562
1562
|
const d = {};
|
|
1563
1563
|
for (const A of l)
|
|
1564
1564
|
i[A] && (d[A] = i[A]);
|
|
1565
|
-
i = d, Object.keys(i).length && (r = !0, await _(this,
|
|
1565
|
+
i = d, Object.keys(i).length && (r = !0, await _(this, Q, it).call(this));
|
|
1566
1566
|
return;
|
|
1567
1567
|
}
|
|
1568
1568
|
await e(a);
|
|
1569
1569
|
});
|
|
1570
1570
|
while (r);
|
|
1571
|
-
},
|
|
1571
|
+
}, Mt = new WeakSet(), se = function(t, e) {
|
|
1572
1572
|
return new Promise((r) => {
|
|
1573
1573
|
if (typeof this.callMethod != "function") {
|
|
1574
1574
|
r(null);
|
|
@@ -1589,12 +1589,12 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1589
1589
|
}, ut = new WeakSet(), Jt = function(t) {
|
|
1590
1590
|
this.clearProgressData(), this.progressCall = typeof t == "function" ? t : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
|
|
1591
1591
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1592
|
-
L(j,
|
|
1593
|
-
L(j,
|
|
1594
|
-
L(j, Rt, 8), L(j,
|
|
1592
|
+
L(j, Et, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1593
|
+
L(j, bt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1594
|
+
L(j, Rt, 8), L(j, Lt, 0.65);
|
|
1595
1595
|
let v = j;
|
|
1596
1596
|
var et;
|
|
1597
|
-
class
|
|
1597
|
+
class re {
|
|
1598
1598
|
constructor() {
|
|
1599
1599
|
L(this, et, {});
|
|
1600
1600
|
}
|
|
@@ -1664,21 +1664,21 @@ class se {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
}
|
|
1666
1666
|
et = new WeakMap();
|
|
1667
|
-
const xt = new
|
|
1668
|
-
var K,
|
|
1667
|
+
const xt = new re();
|
|
1668
|
+
var K, q, st, ot, ft, Z, X, rt, At, Dt, ie, mt, jt, wt, ne, kt, ae, Bt, oe;
|
|
1669
1669
|
class _e {
|
|
1670
1670
|
constructor() {
|
|
1671
1671
|
/** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
|
|
1672
|
-
L(this,
|
|
1672
|
+
L(this, Dt);
|
|
1673
1673
|
/** Вывод ошибок логера
|
|
1674
1674
|
* @param {'entity'} type - тип ошибки
|
|
1675
1675
|
*/
|
|
1676
1676
|
L(this, mt);
|
|
1677
|
-
L(this, Dt);
|
|
1678
1677
|
L(this, wt);
|
|
1679
1678
|
L(this, kt);
|
|
1679
|
+
L(this, Bt);
|
|
1680
1680
|
L(this, K, "logger");
|
|
1681
|
-
L(this,
|
|
1681
|
+
L(this, q, !1);
|
|
1682
1682
|
L(this, st, /* @__PURE__ */ new Map());
|
|
1683
1683
|
L(this, ot, {});
|
|
1684
1684
|
L(this, ft, !1);
|
|
@@ -1699,7 +1699,7 @@ class _e {
|
|
|
1699
1699
|
if (e.find(
|
|
1700
1700
|
(i) => i.ENTITY == M(this, K)
|
|
1701
1701
|
))
|
|
1702
|
-
|
|
1702
|
+
x(this, q, !0);
|
|
1703
1703
|
else {
|
|
1704
1704
|
let { entityAdd: i } = await t.batch({
|
|
1705
1705
|
entityAdd: {
|
|
@@ -1711,13 +1711,20 @@ class _e {
|
|
|
1711
1711
|
}
|
|
1712
1712
|
}
|
|
1713
1713
|
});
|
|
1714
|
-
i &&
|
|
1714
|
+
i && x(this, q, !0);
|
|
1715
1715
|
}
|
|
1716
|
-
return M(this,
|
|
1716
|
+
return M(this, q);
|
|
1717
1717
|
} catch (t) {
|
|
1718
1718
|
return console.error("Ошибка при инициализации логера:", t), !1;
|
|
1719
1719
|
}
|
|
1720
1720
|
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Разрешает работу start/stop без init().
|
|
1723
|
+
* Используется в PAGE_BACKGROUND_WORKER, где не нужно делать entity.get/entity.add.
|
|
1724
|
+
*/
|
|
1725
|
+
enableBackworkerMode() {
|
|
1726
|
+
return x(this, q, !0), !0;
|
|
1727
|
+
}
|
|
1721
1728
|
/**
|
|
1722
1729
|
* @param {{ type: 'call'|'batch'|'batch-total-count';
|
|
1723
1730
|
* data: {
|
|
@@ -1728,7 +1735,7 @@ class _e {
|
|
|
1728
1735
|
* @returns {string|null}
|
|
1729
1736
|
*/
|
|
1730
1737
|
start({ type: t, data: e }) {
|
|
1731
|
-
if (!M(this,
|
|
1738
|
+
if (!M(this, q))
|
|
1732
1739
|
return _(this, mt, jt).call(this, "entity"), null;
|
|
1733
1740
|
if (!t || !e)
|
|
1734
1741
|
return console.error("Невалидные данные для логирования:", { type: t, data: e }), null;
|
|
@@ -1741,7 +1748,7 @@ class _e {
|
|
|
1741
1748
|
answer: null,
|
|
1742
1749
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1743
1750
|
};
|
|
1744
|
-
return M(this, st).set(r, i),
|
|
1751
|
+
return M(this, st).set(r, i), x(this, At, !0), r;
|
|
1745
1752
|
}
|
|
1746
1753
|
/**
|
|
1747
1754
|
* @param {{
|
|
@@ -1754,7 +1761,7 @@ class _e {
|
|
|
1754
1761
|
var c;
|
|
1755
1762
|
if (!M(this, At))
|
|
1756
1763
|
return;
|
|
1757
|
-
if (!M(this,
|
|
1764
|
+
if (!M(this, q)) {
|
|
1758
1765
|
_(this, mt, jt).call(this, "entity");
|
|
1759
1766
|
return;
|
|
1760
1767
|
}
|
|
@@ -1763,7 +1770,7 @@ class _e {
|
|
|
1763
1770
|
console.error(`Не найдены данные логирования для ключа: ${t}`);
|
|
1764
1771
|
return;
|
|
1765
1772
|
}
|
|
1766
|
-
e && (a.errorList = e), r && (a.status = r), i && (a.answer = i), await _(this,
|
|
1773
|
+
e && (a.errorList = e), r && (a.status = r), i && (a.answer = i), await _(this, Dt, ie).call(this), a.userInfo = M(this, ot), await _(this, wt, ne).call(this), (c = a == null ? void 0 : a.data) != null && c.updateList && x(this, rt, !0), x(this, At, !1);
|
|
1767
1774
|
}
|
|
1768
1775
|
/**
|
|
1769
1776
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1799,7 +1806,7 @@ class _e {
|
|
|
1799
1806
|
c
|
|
1800
1807
|
), null;
|
|
1801
1808
|
}
|
|
1802
|
-
}).filter((a) => a !== null),
|
|
1809
|
+
}).filter((a) => a !== null), x(this, rt, !1), x(this, X, i), i);
|
|
1803
1810
|
} catch (r) {
|
|
1804
1811
|
return console.error("Ошибка при получении списка записей:", r), [];
|
|
1805
1812
|
}
|
|
@@ -1809,14 +1816,14 @@ class _e {
|
|
|
1809
1816
|
* Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
|
|
1810
1817
|
*/
|
|
1811
1818
|
runStorageMaintenance() {
|
|
1812
|
-
return _(this,
|
|
1819
|
+
return _(this, kt, ae).call(this);
|
|
1813
1820
|
}
|
|
1814
1821
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1815
1822
|
async downAllEntityJson() {
|
|
1816
1823
|
try {
|
|
1817
1824
|
if (M(this, X) || await this.getEntityList(), !M(this, X) || M(this, X).length === 0)
|
|
1818
1825
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1819
|
-
let t =
|
|
1826
|
+
let t = Nt().format("%Y-%m-%d");
|
|
1820
1827
|
return xt.downloadFileJson(
|
|
1821
1828
|
M(this, X),
|
|
1822
1829
|
`sdklogger-entity-data__${t}`
|
|
@@ -1826,21 +1833,21 @@ class _e {
|
|
|
1826
1833
|
}
|
|
1827
1834
|
}
|
|
1828
1835
|
}
|
|
1829
|
-
K = new WeakMap(),
|
|
1836
|
+
K = new WeakMap(), q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft = new WeakMap(), Z = new WeakMap(), X = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), Dt = new WeakSet(), ie = async function() {
|
|
1830
1837
|
if (!M(this, ft))
|
|
1831
|
-
return M(this, Z) ? M(this, Z) : (
|
|
1838
|
+
return M(this, Z) ? M(this, Z) : (x(this, Z, (async () => {
|
|
1832
1839
|
try {
|
|
1833
1840
|
const t = new v(BX24.callBatch), e = BX24.isAdmin(), { curUser: r } = await t.batch({
|
|
1834
1841
|
curUser: { method: "user.current" }
|
|
1835
1842
|
});
|
|
1836
|
-
|
|
1843
|
+
x(this, ot, { isAdmin: e, curUser: r });
|
|
1837
1844
|
} catch (t) {
|
|
1838
1845
|
console.error(
|
|
1839
1846
|
"Ошибка при получении информации о пользователе:",
|
|
1840
1847
|
t
|
|
1841
|
-
),
|
|
1848
|
+
), x(this, ot, { isAdmin: !1, curUser: null });
|
|
1842
1849
|
} finally {
|
|
1843
|
-
|
|
1850
|
+
x(this, ft, !0), x(this, Z, null);
|
|
1844
1851
|
}
|
|
1845
1852
|
})()), M(this, Z));
|
|
1846
1853
|
}, mt = new WeakSet(), jt = function(t) {
|
|
@@ -1851,7 +1858,7 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1851
1858
|
console.error("Хранилище для логгера не инициализировано");
|
|
1852
1859
|
}
|
|
1853
1860
|
});
|
|
1854
|
-
},
|
|
1861
|
+
}, wt = new WeakSet(), ne = async function() {
|
|
1855
1862
|
try {
|
|
1856
1863
|
let t = {}, e = new v(BX24.callBatch);
|
|
1857
1864
|
for (let [r, i] of M(this, st).entries())
|
|
@@ -1876,7 +1883,7 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1876
1883
|
} catch (t) {
|
|
1877
1884
|
return console.error("Ошибка при добавлении записей в хранилище:", t), !1;
|
|
1878
1885
|
}
|
|
1879
|
-
},
|
|
1886
|
+
}, kt = new WeakSet(), ae = async function() {
|
|
1880
1887
|
try {
|
|
1881
1888
|
let t = new v(BX24.callBatch), { serverTime: e } = await t.batch({
|
|
1882
1889
|
serverTime: { method: "server.time" }
|
|
@@ -1890,8 +1897,8 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1890
1897
|
let r = M(this, X).filter((i) => {
|
|
1891
1898
|
try {
|
|
1892
1899
|
let { dateCreate: a } = i;
|
|
1893
|
-
return a ?
|
|
1894
|
-
|
|
1900
|
+
return a ? Nt(new Date(a)).between(
|
|
1901
|
+
Nt(new Date(e)),
|
|
1895
1902
|
"month"
|
|
1896
1903
|
) >= this.periodClear : !1;
|
|
1897
1904
|
} catch (a) {
|
|
@@ -1900,11 +1907,11 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1900
1907
|
});
|
|
1901
1908
|
r.length > 0 && (console.log(
|
|
1902
1909
|
`Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1903
|
-
), await _(this,
|
|
1910
|
+
), await _(this, Bt, oe).call(this, r));
|
|
1904
1911
|
} catch (t) {
|
|
1905
1912
|
console.error("Ошибка при проверке периода очистки:", t);
|
|
1906
1913
|
}
|
|
1907
|
-
},
|
|
1914
|
+
}, Bt = new WeakSet(), oe = async function(t) {
|
|
1908
1915
|
try {
|
|
1909
1916
|
if (!t || t.length === 0)
|
|
1910
1917
|
return !1;
|
|
@@ -1921,12 +1928,12 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1921
1928
|
if (r.length === 0)
|
|
1922
1929
|
return !1;
|
|
1923
1930
|
const i = await e.batch(r);
|
|
1924
|
-
return console.log(`Успешно удалено ${r.length} записей`),
|
|
1931
|
+
return console.log(`Успешно удалено ${r.length} записей`), x(this, rt, !0), i;
|
|
1925
1932
|
} catch (e) {
|
|
1926
1933
|
return console.error("Ошибка при очистке устаревших записей:", e), !1;
|
|
1927
1934
|
}
|
|
1928
1935
|
};
|
|
1929
|
-
function
|
|
1936
|
+
function Zt(y) {
|
|
1930
1937
|
if (!y || typeof y != "string")
|
|
1931
1938
|
return "";
|
|
1932
1939
|
try {
|
|
@@ -1938,23 +1945,23 @@ function Qt(y) {
|
|
|
1938
1945
|
return y.split("?")[0].split("#")[0].replace(/\/$/, "");
|
|
1939
1946
|
}
|
|
1940
1947
|
}
|
|
1941
|
-
function
|
|
1948
|
+
function Ae(y) {
|
|
1942
1949
|
return !y || typeof y != "string" ? !1 : y.toLowerCase().includes("/marketplace/app");
|
|
1943
1950
|
}
|
|
1944
1951
|
function Te() {
|
|
1945
1952
|
var t;
|
|
1946
1953
|
if (typeof window > "u" || !((t = window.location) != null && t.href))
|
|
1947
1954
|
return "";
|
|
1948
|
-
const y =
|
|
1949
|
-
return
|
|
1955
|
+
const y = Zt(window.location.href);
|
|
1956
|
+
return Ae(y) ? "" : y;
|
|
1950
1957
|
}
|
|
1951
1958
|
function Kt(y) {
|
|
1952
1959
|
if (!(y != null && y.appConst) || typeof y.appConst != "object")
|
|
1953
1960
|
return "";
|
|
1954
1961
|
const t = Te();
|
|
1955
|
-
return t ? (y.appConst.pathApp = t, t) :
|
|
1962
|
+
return t ? (y.appConst.pathApp = t, t) : Zt(y.appConst.pathApp ?? "");
|
|
1956
1963
|
}
|
|
1957
|
-
var ct,
|
|
1964
|
+
var ct, _t, Ct, ce, dt, vt, Ut, le, Ht, he, Gt, ue, V, nt, gt, qt, Yt, fe, yt, zt, Pt, me;
|
|
1958
1965
|
class Ie {
|
|
1959
1966
|
/**
|
|
1960
1967
|
* @param {Object} appConst - Константы приложения
|
|
@@ -1969,13 +1976,13 @@ class Ie {
|
|
|
1969
1976
|
* @returns {Batch} Shared Batch instance.
|
|
1970
1977
|
*/
|
|
1971
1978
|
L(this, ct);
|
|
1972
|
-
L(this,
|
|
1979
|
+
L(this, Ct);
|
|
1973
1980
|
/**
|
|
1974
1981
|
* `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
|
|
1975
1982
|
* иначе — заглушка.
|
|
1976
1983
|
* @param {boolean} runLoggerMaintenance
|
|
1977
1984
|
*/
|
|
1978
|
-
L(this,
|
|
1985
|
+
L(this, dt);
|
|
1979
1986
|
/**
|
|
1980
1987
|
* @returns {boolean}
|
|
1981
1988
|
*/
|
|
@@ -1985,7 +1992,7 @@ class Ie {
|
|
|
1985
1992
|
/** Запрос данных о текущем пользователе */
|
|
1986
1993
|
L(this, Gt);
|
|
1987
1994
|
L(this, V);
|
|
1988
|
-
L(this,
|
|
1995
|
+
L(this, gt);
|
|
1989
1996
|
/**
|
|
1990
1997
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1991
1998
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -2000,7 +2007,7 @@ class Ie {
|
|
|
2000
2007
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
2001
2008
|
* @private
|
|
2002
2009
|
*/
|
|
2003
|
-
L(this,
|
|
2010
|
+
L(this, yt);
|
|
2004
2011
|
/**
|
|
2005
2012
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
2006
2013
|
* @private
|
|
@@ -2029,7 +2036,7 @@ class Ie {
|
|
|
2029
2036
|
* @returns {() => void} Функция отписки.
|
|
2030
2037
|
*/
|
|
2031
2038
|
subscribeTimeLimit(t) {
|
|
2032
|
-
return _(this, ct,
|
|
2039
|
+
return _(this, ct, _t).call(this).subscribeTimeLimit(t);
|
|
2033
2040
|
}
|
|
2034
2041
|
/**
|
|
2035
2042
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2056,9 +2063,13 @@ class Ie {
|
|
|
2056
2063
|
const c = _(this, Ut, le).call(this);
|
|
2057
2064
|
if (console.info(
|
|
2058
2065
|
c ? "init BX24 (background worker)" : "init BX24"
|
|
2059
|
-
), this.appInfo = await _(this, Ht, he).call(this), this.userInfo = await _(this, Gt, ue).call(this), Kt(this),
|
|
2060
|
-
await _(this,
|
|
2061
|
-
|
|
2066
|
+
), this.appInfo = await _(this, Ht, he).call(this), this.userInfo = await _(this, Gt, ue).call(this), Kt(this), c)
|
|
2067
|
+
await _(this, dt, vt).call(this, !1, {
|
|
2068
|
+
skipInit: !0
|
|
2069
|
+
});
|
|
2070
|
+
else {
|
|
2071
|
+
await _(this, dt, vt).call(this, !0);
|
|
2072
|
+
const l = new re();
|
|
2062
2073
|
try {
|
|
2063
2074
|
l.noSleep();
|
|
2064
2075
|
} catch (u) {
|
|
@@ -2124,7 +2135,7 @@ class Ie {
|
|
|
2124
2135
|
const l = new Error("BX24 is not initialized");
|
|
2125
2136
|
throw console.error(l), l;
|
|
2126
2137
|
}
|
|
2127
|
-
const c = await _(this, ct,
|
|
2138
|
+
const c = await _(this, ct, _t).call(this).call({ method: t, params: e });
|
|
2128
2139
|
return c.success ? (await _(this, V, nt).call(this, i, {
|
|
2129
2140
|
answer: c.answer,
|
|
2130
2141
|
status: "success"
|
|
@@ -2158,7 +2169,7 @@ class Ie {
|
|
|
2158
2169
|
const c = new Error("BX24 is not initialized");
|
|
2159
2170
|
return console.error(c), !1;
|
|
2160
2171
|
}
|
|
2161
|
-
return _(this,
|
|
2172
|
+
return _(this, gt, qt).call(this, {
|
|
2162
2173
|
mode: "batch",
|
|
2163
2174
|
commandList: t,
|
|
2164
2175
|
progressCall: e,
|
|
@@ -2194,7 +2205,7 @@ class Ie {
|
|
|
2194
2205
|
const a = new Error("BX24 is not initialized");
|
|
2195
2206
|
return console.error(a), !1;
|
|
2196
2207
|
}
|
|
2197
|
-
return _(this,
|
|
2208
|
+
return _(this, gt, qt).call(this, {
|
|
2198
2209
|
mode: "batch-total-count",
|
|
2199
2210
|
commandList: t,
|
|
2200
2211
|
progressCall: e,
|
|
@@ -2216,7 +2227,7 @@ class Ie {
|
|
|
2216
2227
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2217
2228
|
return;
|
|
2218
2229
|
const { appName: e, pathApp: r } = this.appConst;
|
|
2219
|
-
let i = _(this,
|
|
2230
|
+
let i = _(this, yt, zt).call(this, t);
|
|
2220
2231
|
i = i.filter(
|
|
2221
2232
|
(h) => h.placement !== "PAGE_BACKGROUND_WORKER" && h.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2222
2233
|
);
|
|
@@ -2231,18 +2242,18 @@ class Ie {
|
|
|
2231
2242
|
for (const h of this.placeData)
|
|
2232
2243
|
d.has(h.placement) || d.set(h.placement, []), d.get(h.placement).push(h);
|
|
2233
2244
|
for (let h = 0; h < i.length; h++) {
|
|
2234
|
-
const O = i[h]
|
|
2235
|
-
if (
|
|
2236
|
-
(
|
|
2245
|
+
const { placement: O, options: T } = i[h], b = d.get(O) || [];
|
|
2246
|
+
if (b.some(
|
|
2247
|
+
(E) => E.handler === r
|
|
2237
2248
|
))
|
|
2238
2249
|
continue;
|
|
2239
|
-
const
|
|
2240
|
-
(
|
|
2250
|
+
const p = b.filter(
|
|
2251
|
+
(E) => E.handler !== r
|
|
2241
2252
|
);
|
|
2242
|
-
for (const
|
|
2253
|
+
for (const E of p)
|
|
2243
2254
|
f.push({
|
|
2244
2255
|
placement: O,
|
|
2245
|
-
handler:
|
|
2256
|
+
handler: E.handler
|
|
2246
2257
|
});
|
|
2247
2258
|
n[`bind_${h}`] = {
|
|
2248
2259
|
method: "placement.bind",
|
|
@@ -2255,7 +2266,8 @@ class Ie {
|
|
|
2255
2266
|
}
|
|
2256
2267
|
},
|
|
2257
2268
|
OPTIONS: {
|
|
2258
|
-
errorHandlerUrl: r
|
|
2269
|
+
errorHandlerUrl: r,
|
|
2270
|
+
...T && typeof T == "object" ? T : {}
|
|
2259
2271
|
}
|
|
2260
2272
|
}
|
|
2261
2273
|
};
|
|
@@ -2269,7 +2281,7 @@ class Ie {
|
|
|
2269
2281
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2270
2282
|
*/
|
|
2271
2283
|
async placementUnBind(t) {
|
|
2272
|
-
let e = _(this,
|
|
2284
|
+
let e = _(this, yt, zt).call(this, t);
|
|
2273
2285
|
if (e = e.filter(
|
|
2274
2286
|
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2275
2287
|
), e.length === 0)
|
|
@@ -2322,7 +2334,7 @@ class Ie {
|
|
|
2322
2334
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
2323
2335
|
EMAIL: "",
|
|
2324
2336
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
2325
|
-
PERSONAL_BIRTHDAY:
|
|
2337
|
+
PERSONAL_BIRTHDAY: Nt().format("%Y-%m-%d"),
|
|
2326
2338
|
// День рождения в формате YYYY-mm-dd
|
|
2327
2339
|
WORK_POSITION: "Почтальон",
|
|
2328
2340
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -2352,12 +2364,12 @@ class Ie {
|
|
|
2352
2364
|
return this.logger.getEntityList(t);
|
|
2353
2365
|
}
|
|
2354
2366
|
}
|
|
2355
|
-
ct = new WeakSet(),
|
|
2367
|
+
ct = new WeakSet(), _t = function() {
|
|
2356
2368
|
return this.batchClient || (this.batchClient = new v({
|
|
2357
2369
|
callBatch: BX24.callBatch,
|
|
2358
2370
|
callMethod: BX24.callMethod
|
|
2359
2371
|
}), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
|
|
2360
|
-
},
|
|
2372
|
+
}, Ct = new WeakSet(), ce = function() {
|
|
2361
2373
|
return {
|
|
2362
2374
|
start: () => {
|
|
2363
2375
|
},
|
|
@@ -2366,8 +2378,8 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2366
2378
|
getEntityList: () => {
|
|
2367
2379
|
}
|
|
2368
2380
|
};
|
|
2369
|
-
},
|
|
2370
|
-
this.logger ? (this.logger = new _e(), await this.logger.init(), t && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = _(this,
|
|
2381
|
+
}, dt = new WeakSet(), vt = async function(t, { skipInit: e = !1 } = {}) {
|
|
2382
|
+
this.logger ? (this.logger = new _e(), e ? this.logger.enableBackworkerMode() : await this.logger.init(), t && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = _(this, Ct, ce).call(this);
|
|
2371
2383
|
}, Ut = new WeakSet(), le = function() {
|
|
2372
2384
|
var r, i, a;
|
|
2373
2385
|
const t = (r = this.placeInfo) == null ? void 0 : r.placement, e = (a = (i = this.placeInfo) == null ? void 0 : i.options) == null ? void 0 : a.ID;
|
|
@@ -2386,7 +2398,7 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2386
2398
|
} catch (r) {
|
|
2387
2399
|
console.error("Logger error:", r);
|
|
2388
2400
|
}
|
|
2389
|
-
},
|
|
2401
|
+
}, gt = new WeakSet(), qt = async function({
|
|
2390
2402
|
mode: t,
|
|
2391
2403
|
commandList: e,
|
|
2392
2404
|
progressCall: r,
|
|
@@ -2394,7 +2406,7 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2394
2406
|
updateList: a,
|
|
2395
2407
|
batchOptions: c
|
|
2396
2408
|
}) {
|
|
2397
|
-
const l = _(this, ct,
|
|
2409
|
+
const l = _(this, ct, _t).call(this), u = a ? this.logger.start({
|
|
2398
2410
|
type: t,
|
|
2399
2411
|
data: t === "batch" ? { commandList: e, updateList: a } : { commandList: e }
|
|
2400
2412
|
}) : void 0;
|
|
@@ -2440,7 +2452,7 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2440
2452
|
!n.has(d) && !t.errors[d] && (a[d] = f || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2441
2453
|
}
|
|
2442
2454
|
return a;
|
|
2443
|
-
},
|
|
2455
|
+
}, yt = new WeakSet(), zt = function(t) {
|
|
2444
2456
|
if (!t)
|
|
2445
2457
|
return [];
|
|
2446
2458
|
let e = [];
|
|
@@ -2457,18 +2469,18 @@ function Ee() {
|
|
|
2457
2469
|
let y = sessionStorage.getItem("szdl-cross-tab-instance-id");
|
|
2458
2470
|
return y || (y = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", y)), y;
|
|
2459
2471
|
}
|
|
2460
|
-
function
|
|
2472
|
+
function be() {
|
|
2461
2473
|
return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
|
|
2462
2474
|
}
|
|
2463
2475
|
const Ft = /* @__PURE__ */ new Map();
|
|
2464
|
-
function
|
|
2476
|
+
function Re(y = "default") {
|
|
2465
2477
|
if (typeof BroadcastChannel > "u")
|
|
2466
2478
|
return null;
|
|
2467
2479
|
const t = `${de}bc:${y}`;
|
|
2468
2480
|
return Ft.has(t) || Ft.set(t, new BroadcastChannel(t)), Ft.get(t);
|
|
2469
2481
|
}
|
|
2470
|
-
function
|
|
2471
|
-
const e =
|
|
2482
|
+
function Vt(y, t) {
|
|
2483
|
+
const e = Re(y);
|
|
2472
2484
|
if (e)
|
|
2473
2485
|
try {
|
|
2474
2486
|
const r = t && typeof t == "object" && !Array.isArray(t) ? t : { data: t };
|
|
@@ -2482,29 +2494,29 @@ function Zt(y, t) {
|
|
|
2482
2494
|
}
|
|
2483
2495
|
async function Le(y, t, e = {}) {
|
|
2484
2496
|
const { ifAvailable: r = !1 } = e, i = typeof y == "string" && y.length > 0 ? y : "default", a = `${de}${i}`;
|
|
2485
|
-
return
|
|
2497
|
+
return be() ? navigator.locks.request(
|
|
2486
2498
|
a,
|
|
2487
2499
|
{ mode: "exclusive", ifAvailable: !!r },
|
|
2488
2500
|
async (c) => {
|
|
2489
2501
|
if (r && c == null)
|
|
2490
2502
|
return { skipped: !0, coordination: "locks" };
|
|
2491
|
-
|
|
2503
|
+
Vt(i, { type: "lock-acquired", resource: i });
|
|
2492
2504
|
try {
|
|
2493
2505
|
return { skipped: !1, result: await t(), coordination: "locks" };
|
|
2494
2506
|
} finally {
|
|
2495
|
-
|
|
2507
|
+
Vt(i, { type: "lock-released", resource: i });
|
|
2496
2508
|
}
|
|
2497
2509
|
}
|
|
2498
2510
|
) : { skipped: !1, result: await t(), coordination: "none" };
|
|
2499
2511
|
}
|
|
2500
|
-
var
|
|
2512
|
+
var pt, Qt;
|
|
2501
2513
|
class Me {
|
|
2502
2514
|
constructor(t) {
|
|
2503
2515
|
/**
|
|
2504
2516
|
* Канонический base URL для placement (без завершающего `/`).
|
|
2505
2517
|
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2506
2518
|
*/
|
|
2507
|
-
L(this,
|
|
2519
|
+
L(this, pt);
|
|
2508
2520
|
H(this, "entityName", "tabs");
|
|
2509
2521
|
H(this, "maxTabs", 20);
|
|
2510
2522
|
H(this, "tabList", []);
|
|
@@ -2528,7 +2540,7 @@ class Me {
|
|
|
2528
2540
|
return;
|
|
2529
2541
|
}
|
|
2530
2542
|
const { appFunc: e, bx: r, users: i, continueBackground: a } = t;
|
|
2531
|
-
this.bx = r, this.appInit = e, this.users = i, Kt(r), this.appPath = _(this,
|
|
2543
|
+
this.bx = r, this.appInit = e, this.users = i, Kt(r), this.appPath = _(this, pt, Qt).call(this, ((c = r == null ? void 0 : r.appConst) == null ? void 0 : c.pathApp) ?? ""), this.appName = ((l = r == null ? void 0 : r.appConst) == null ? void 0 : l.appName) ?? "", this.appCodeName = ((u = r == null ? void 0 : r.appConst) == null ? void 0 : u.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2532
2544
|
}
|
|
2533
2545
|
async init() {
|
|
2534
2546
|
if (!this.appInit) {
|
|
@@ -2805,15 +2817,15 @@ class Me {
|
|
|
2805
2817
|
);
|
|
2806
2818
|
}
|
|
2807
2819
|
async setBackgroundWorkerAll() {
|
|
2808
|
-
var
|
|
2809
|
-
if (!((
|
|
2820
|
+
var S, p, E, C;
|
|
2821
|
+
if (!((S = this.bx) != null && S.isAdmin)) {
|
|
2810
2822
|
console.log(
|
|
2811
2823
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2812
2824
|
);
|
|
2813
2825
|
return;
|
|
2814
2826
|
}
|
|
2815
2827
|
(p = this.users) != null && p.length || await this.getEntityData(), Kt(this.bx);
|
|
2816
|
-
const t = _(this,
|
|
2828
|
+
const t = _(this, pt, Qt).call(this, ((C = (E = this.bx) == null ? void 0 : E.appConst) == null ? void 0 : C.pathApp) ?? "");
|
|
2817
2829
|
if (!t) {
|
|
2818
2830
|
console.error(
|
|
2819
2831
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2828,9 +2840,9 @@ class Me {
|
|
|
2828
2840
|
if (N.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2829
2841
|
return;
|
|
2830
2842
|
if (N.userId || N.handler && N.handler.includes("USER_ID=")) {
|
|
2831
|
-
const
|
|
2832
|
-
if (
|
|
2833
|
-
const k = +
|
|
2843
|
+
const R = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
|
|
2844
|
+
if (R) {
|
|
2845
|
+
const k = +R;
|
|
2834
2846
|
r.set(k, N), i.has(k) || i.set(k, []), i.get(k).push(N);
|
|
2835
2847
|
}
|
|
2836
2848
|
} else
|
|
@@ -2838,15 +2850,15 @@ class Me {
|
|
|
2838
2850
|
});
|
|
2839
2851
|
const c = await this.resolveAdmins(), l = await this.getEligibleUsersForBackgroundWorker(c);
|
|
2840
2852
|
l.sort((N, I) => {
|
|
2841
|
-
const
|
|
2842
|
-
return (I.LAST_LOGIN ? new Date(I.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) -
|
|
2853
|
+
const R = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2854
|
+
return (I.LAST_LOGIN ? new Date(I.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - R;
|
|
2843
2855
|
});
|
|
2844
2856
|
const u = 10, n = l.slice(0, u), f = n.filter((N) => {
|
|
2845
2857
|
const I = r.get(+N.ID);
|
|
2846
2858
|
if (!I)
|
|
2847
2859
|
return !0;
|
|
2848
|
-
const
|
|
2849
|
-
return I.handler !==
|
|
2860
|
+
const R = `${t}?USER_ID=${N.ID}/`;
|
|
2861
|
+
return I.handler !== R;
|
|
2850
2862
|
}), d = [];
|
|
2851
2863
|
for (const [N] of r) {
|
|
2852
2864
|
const I = +N || 0;
|
|
@@ -2856,18 +2868,18 @@ class Me {
|
|
|
2856
2868
|
const I = r.get(+N.ID);
|
|
2857
2869
|
if (!I)
|
|
2858
2870
|
continue;
|
|
2859
|
-
const
|
|
2860
|
-
I.handler !==
|
|
2871
|
+
const R = `${t}?USER_ID=${N.ID}/`;
|
|
2872
|
+
I.handler !== R && d.push(+N.ID);
|
|
2861
2873
|
}
|
|
2862
2874
|
const A = [], h = [...new Set(d)];
|
|
2863
2875
|
for (const N of h) {
|
|
2864
2876
|
const I = i.get(+N) || [];
|
|
2865
|
-
for (const
|
|
2866
|
-
|
|
2877
|
+
for (const R of I)
|
|
2878
|
+
R != null && R.handler && A.push({
|
|
2867
2879
|
method: "placement.unbind",
|
|
2868
2880
|
params: {
|
|
2869
2881
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2870
|
-
HANDLER:
|
|
2882
|
+
HANDLER: R.handler
|
|
2871
2883
|
}
|
|
2872
2884
|
});
|
|
2873
2885
|
}
|
|
@@ -2903,7 +2915,7 @@ class Me {
|
|
|
2903
2915
|
});
|
|
2904
2916
|
const T = A.filter(
|
|
2905
2917
|
(N) => N.method === "placement.unbind"
|
|
2906
|
-
),
|
|
2918
|
+
), b = A.filter(
|
|
2907
2919
|
(N) => N.method === "placement.bind"
|
|
2908
2920
|
);
|
|
2909
2921
|
T.length && await this.safeCall(
|
|
@@ -2912,10 +2924,10 @@ class Me {
|
|
|
2912
2924
|
T.map((N, I) => [`unbind_${I}`, N])
|
|
2913
2925
|
)
|
|
2914
2926
|
)
|
|
2915
|
-
),
|
|
2927
|
+
), b.length && await this.safeCall(
|
|
2916
2928
|
() => this.bx.batch(
|
|
2917
2929
|
Object.fromEntries(
|
|
2918
|
-
|
|
2930
|
+
b.map((N, I) => [`bind_${I}`, N])
|
|
2919
2931
|
)
|
|
2920
2932
|
)
|
|
2921
2933
|
), A.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
@@ -2994,11 +3006,11 @@ class Me {
|
|
|
2994
3006
|
}
|
|
2995
3007
|
}
|
|
2996
3008
|
}
|
|
2997
|
-
|
|
3009
|
+
pt = new WeakSet(), Qt = function(t) {
|
|
2998
3010
|
if (!t || typeof t != "string")
|
|
2999
3011
|
return "";
|
|
3000
|
-
const e =
|
|
3001
|
-
return e ?
|
|
3012
|
+
const e = Zt(t).replace(/\/+$/, "");
|
|
3013
|
+
return e ? Ae(e) ? (console.error(
|
|
3002
3014
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3003
3015
|
), "") : e : "";
|
|
3004
3016
|
};
|
|
@@ -3006,7 +3018,7 @@ export {
|
|
|
3006
3018
|
Me as BackgroundWorker,
|
|
3007
3019
|
v as Batch,
|
|
3008
3020
|
Ie as BxBoot,
|
|
3009
|
-
|
|
3021
|
+
re as BxHelper,
|
|
3010
3022
|
_e as BxLogger,
|
|
3011
|
-
|
|
3023
|
+
Nt as tempus
|
|
3012
3024
|
};
|