szdl-utils-kit 0.3.8 → 0.3.10
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 +490 -458
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (_, e, r) => (
|
|
1
|
+
var yt = Object.defineProperty;
|
|
2
|
+
var Et = (_, e, r) => e in _ ? yt(_, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : _[e] = r;
|
|
3
|
+
var M = (_, e, r) => (Et(_, typeof e != "symbol" ? e + "" : e, r), r), lt = (_, e, r) => {
|
|
4
4
|
if (!e.has(_))
|
|
5
5
|
throw TypeError("Cannot " + r);
|
|
6
6
|
};
|
|
7
|
-
var E = (_, e, r) => (
|
|
7
|
+
var E = (_, e, r) => (lt(_, e, "read from private field"), r ? r.call(_) : e.get(_)), w = (_, e, r) => {
|
|
8
8
|
if (e.has(_))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
e instanceof WeakSet ? e.add(_) : e.set(_, r);
|
|
11
|
-
}, F = (_, e, r, i) => (
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
function
|
|
11
|
+
}, F = (_, e, r, i) => (lt(_, e, "write to private field"), i ? i.call(_, r) : e.set(_, r), r);
|
|
12
|
+
var X = (_, e, r) => (lt(_, e, "access private method"), r);
|
|
13
|
+
var Tt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
+
function Rt(_) {
|
|
15
15
|
return _ && _.__esModule && Object.prototype.hasOwnProperty.call(_, "default") ? _.default : _;
|
|
16
16
|
}
|
|
17
|
-
var
|
|
17
|
+
var ht = { exports: {} };
|
|
18
18
|
(function(_, e) {
|
|
19
19
|
(function(r) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(t, n) {
|
|
@@ -30,25 +30,25 @@ var ct = { exports: {} };
|
|
|
30
30
|
return f;
|
|
31
31
|
}, a = function(t, n) {
|
|
32
32
|
return n !== r ? (t.year(n.year() || n.year), t.month(n.month() || n.month), t.day(n.day() || n.day), t.hours(n.hours() || n.hours), t.minutes(n.minutes() || n.minutes), t.seconds(n.seconds() || n.seconds), t.milliseconds(n.milliseconds() || n.milliseconds), t) : r;
|
|
33
|
-
},
|
|
33
|
+
}, h = function(t, n) {
|
|
34
34
|
var f, m = "";
|
|
35
35
|
return f = t.slice(n, n + 1), f !== "" && !isNaN(Number(f)) && (m += "%H"), f = t.charAt(n + 2), f !== "" && f === ":" && (m += f), f = t.slice(n + 3, n + 4), f !== "" && !isNaN(Number(f)) && (m += "%M"), f = t.charAt(n + 5), f !== "" && f === ":" && (m += f), f = t.slice(n + 6, n + 7), f !== "" && !isNaN(Number(f)) && (m += "%S"), m;
|
|
36
|
-
},
|
|
36
|
+
}, u = function(t, n) {
|
|
37
37
|
var f, m = [
|
|
38
38
|
t.slice(n, n + 1),
|
|
39
39
|
t.charAt(n + 2),
|
|
40
40
|
t.slice(n + 3, n + 4),
|
|
41
41
|
t.charAt(n + 5),
|
|
42
42
|
t.slice(n + 6, n + 9)
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(m[0])) && !isNaN(Number(m[2])) && !isNaN(Number(m[4])) ? (m[1] === "." && m[3] === "." ? f = "%d.%m.%Y" : m[1] === "-" && m[3] === "-" ? f = "%m-%d-%Y" : m[1] === "/" && m[3] === "/" && (f = "%m/%d/%Y"), f) : (
|
|
43
|
+
], S;
|
|
44
|
+
return !isNaN(Number(m[0])) && !isNaN(Number(m[2])) && !isNaN(Number(m[4])) ? (m[1] === "." && m[3] === "." ? f = "%d.%m.%Y" : m[1] === "-" && m[3] === "-" ? f = "%m-%d-%Y" : m[1] === "/" && m[3] === "/" && (f = "%m/%d/%Y"), f) : (S = [
|
|
45
45
|
t.slice(n, n + 3),
|
|
46
46
|
t.charAt(n + 4),
|
|
47
47
|
t.slice(n + 5, n + 6),
|
|
48
48
|
t.charAt(n + 7),
|
|
49
49
|
t.slice(n + 8, n + 9)
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
},
|
|
50
|
+
], !isNaN(Number(S[0])) && !isNaN(Number(S[2])) && !isNaN(Number(S[4])) ? (S[1] === "-" && S[3] === "-" && (f = "%Y-%m-%d"), f) : "");
|
|
51
|
+
}, c = i.tempus, s, d, g = i.navigator || {}, A = "en", l = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,63 +209,63 @@ var ct = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
}, g = function() {
|
|
213
|
-
return [
|
|
214
|
-
A[l].JANUARY_LONG,
|
|
215
|
-
A[l].FEBRUARY_LONG,
|
|
216
|
-
A[l].MARCH_LONG,
|
|
217
|
-
A[l].APRIL_LONG,
|
|
218
|
-
A[l].MAY_LONG,
|
|
219
|
-
A[l].JUNE_LONG,
|
|
220
|
-
A[l].JULY_LONG,
|
|
221
|
-
A[l].AUGUST_LONG,
|
|
222
|
-
A[l].SEPTEMBER_LONG,
|
|
223
|
-
A[l].OCTOBER_LONG,
|
|
224
|
-
A[l].NOVEMBER_LONG,
|
|
225
|
-
A[l].DECEMBER_LONG
|
|
226
|
-
];
|
|
227
212
|
}, N = function() {
|
|
228
213
|
return [
|
|
229
|
-
A
|
|
230
|
-
A
|
|
231
|
-
A
|
|
232
|
-
A
|
|
233
|
-
A
|
|
234
|
-
A
|
|
235
|
-
A
|
|
236
|
-
A
|
|
237
|
-
A
|
|
238
|
-
A
|
|
239
|
-
A
|
|
240
|
-
A
|
|
214
|
+
l[A].JANUARY_LONG,
|
|
215
|
+
l[A].FEBRUARY_LONG,
|
|
216
|
+
l[A].MARCH_LONG,
|
|
217
|
+
l[A].APRIL_LONG,
|
|
218
|
+
l[A].MAY_LONG,
|
|
219
|
+
l[A].JUNE_LONG,
|
|
220
|
+
l[A].JULY_LONG,
|
|
221
|
+
l[A].AUGUST_LONG,
|
|
222
|
+
l[A].SEPTEMBER_LONG,
|
|
223
|
+
l[A].OCTOBER_LONG,
|
|
224
|
+
l[A].NOVEMBER_LONG,
|
|
225
|
+
l[A].DECEMBER_LONG
|
|
241
226
|
];
|
|
242
227
|
}, O = function() {
|
|
243
228
|
return [
|
|
244
|
-
A
|
|
245
|
-
A
|
|
246
|
-
A
|
|
247
|
-
A
|
|
248
|
-
A
|
|
249
|
-
A
|
|
250
|
-
A
|
|
229
|
+
l[A].JANUARY_SHORT,
|
|
230
|
+
l[A].FEBRUARY_SHORT,
|
|
231
|
+
l[A].MARCH_SHORT,
|
|
232
|
+
l[A].APRIL_SHORT,
|
|
233
|
+
l[A].MAY_SHORT,
|
|
234
|
+
l[A].JUNE_SHORT,
|
|
235
|
+
l[A].JULY_SHORT,
|
|
236
|
+
l[A].AUGUST_SHORT,
|
|
237
|
+
l[A].SEPTEMBER_SHORT,
|
|
238
|
+
l[A].OCTOBER_SHORT,
|
|
239
|
+
l[A].NOVEMBER_SHORT,
|
|
240
|
+
l[A].DECEMBER_SHORT
|
|
241
|
+
];
|
|
242
|
+
}, p = function() {
|
|
243
|
+
return [
|
|
244
|
+
l[A].SUNDAY_LONG,
|
|
245
|
+
l[A].MONDAY_LONG,
|
|
246
|
+
l[A].TUESDAY_LONG,
|
|
247
|
+
l[A].WEDNESDAY_LONG,
|
|
248
|
+
l[A].THURSDAY_LONG,
|
|
249
|
+
l[A].FRIDAY_LONG,
|
|
250
|
+
l[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, b = function() {
|
|
253
253
|
return [
|
|
254
|
-
A
|
|
255
|
-
A
|
|
256
|
-
A
|
|
257
|
-
A
|
|
258
|
-
A
|
|
259
|
-
A
|
|
260
|
-
A
|
|
254
|
+
l[A].SUNDAY_SHORT,
|
|
255
|
+
l[A].MONDAY_SHORT,
|
|
256
|
+
l[A].TUESDAY_SHORT,
|
|
257
|
+
l[A].WEDNESDAY_SHORT,
|
|
258
|
+
l[A].THURSDAY_SHORT,
|
|
259
|
+
l[A].FRIDAY_SHORT,
|
|
260
|
+
l[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
}, U, P, W,
|
|
262
|
+
}, U, P, W, L, k = function(t, n, f) {
|
|
263
263
|
var m;
|
|
264
264
|
i.XMLHttpRequest ? m = new XMLHttpRequest() : m = new ActiveXObject("Microsoft.XMLHTTP"), m.onreadystatechange = function() {
|
|
265
265
|
m.readyState === 4 && (m.status === 200 ? n && (i.JSON === r ? 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`) : n(JSON.parse(m.responseText))) : f && f(m));
|
|
267
267
|
}, m.open("GET", t, !1), m.send();
|
|
268
|
-
},
|
|
268
|
+
}, I = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(t) {
|
|
271
271
|
return o(t.day() || s.MIN_DAY, 2);
|
|
@@ -316,7 +316,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
316
316
|
"%a": {
|
|
317
317
|
format: function(t) {
|
|
318
318
|
var n = t.dayOfWeek();
|
|
319
|
-
return
|
|
319
|
+
return L[n !== r ? n : s.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
return {};
|
|
@@ -442,7 +442,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
442
442
|
maxLength: 10,
|
|
443
443
|
type: "string"
|
|
444
444
|
}
|
|
445
|
-
},
|
|
445
|
+
}, et = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
448
|
}, T;
|
|
@@ -520,7 +520,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
520
520
|
if (typeof t == "number")
|
|
521
521
|
return this._d = new Date(t * (s.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
522
522
|
if (typeof t == "object" && (t instanceof Array ? (this.day(s.MIN_DAY), this.year(t[0]), this.month(t[1]), this.day(t[2]), this.hours(t[3]), this.minutes(t[4]), this.seconds(t[5]), this.milliseconds(t[6])) : (this.day(s.MIN_DAY), this.year(t.year), this.month(t.month), this.day(t.day), this.hours(t.hours), this.minutes(t.minutes), this.seconds(t.seconds), this.milliseconds(t.milliseconds))), typeof t == "string") {
|
|
523
|
-
var m,
|
|
523
|
+
var m, S = [], y, R, j = [], C = 0, Y = 0, D, x, B = {}, H;
|
|
524
524
|
if (t === r)
|
|
525
525
|
return y = a(this, f), y === r && (this._i = {
|
|
526
526
|
year: -1,
|
|
@@ -533,22 +533,22 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
533
533
|
}), y;
|
|
534
534
|
for (n === r && (n = s.detectFormat(t)); C < n.length; ) {
|
|
535
535
|
if (n.charAt(C) === "%") {
|
|
536
|
-
if (R = n.charAt(C) + n.charAt(C + 1),
|
|
537
|
-
switch (D = 0, x = "",
|
|
536
|
+
if (R = n.charAt(C) + n.charAt(C + 1), I[R] !== r) {
|
|
537
|
+
switch (D = 0, x = "", I[R].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (; D <
|
|
539
|
+
for (; D < I[R].maxLength && Y + D < t.length && !isNaN(Number(t.charAt(Y + D))); )
|
|
540
540
|
x += t.charAt(Y + D), D += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (; D <
|
|
543
|
+
for (; D < I[R].maxLength && Y + D < t.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(Y + D)); )
|
|
544
544
|
x += t.charAt(Y + D), D += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (; D <
|
|
547
|
+
for (; D < I[R].maxLength && Y + D < t.length; )
|
|
548
548
|
x += t.charAt(Y + D), D += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (D <
|
|
551
|
+
if (D < I[R].minLength)
|
|
552
552
|
return y = a(this, f), y === r && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
@@ -558,7 +558,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
560
|
}), y;
|
|
561
|
-
|
|
561
|
+
S.push(R), j.push(x), D -= 1, Y += D, C += 1;
|
|
562
562
|
}
|
|
563
563
|
} else if (t.charAt(Y) !== n.charAt(C))
|
|
564
564
|
return y = a(this, f), y === r && (this._i = {
|
|
@@ -572,14 +572,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
572
572
|
}), y;
|
|
573
573
|
C += 1, Y += 1;
|
|
574
574
|
}
|
|
575
|
-
for (m in
|
|
576
|
-
|
|
577
|
-
year:
|
|
578
|
-
month:
|
|
579
|
-
day:
|
|
580
|
-
hours:
|
|
581
|
-
minutes:
|
|
582
|
-
seconds:
|
|
575
|
+
for (m in S)
|
|
576
|
+
S.hasOwnProperty(m) && I.hasOwnProperty(S[m]) && (H = I[S[m]].parse(j[m]), B = {
|
|
577
|
+
year: H.year !== r ? H.year : B.year,
|
|
578
|
+
month: H.month !== r ? H.month : B.month,
|
|
579
|
+
day: H.day !== r ? H.day : B.day,
|
|
580
|
+
hours: H.hours !== r ? H.hours : B.hours,
|
|
581
|
+
minutes: H.minutes !== r ? H.minutes : B.minutes,
|
|
582
|
+
seconds: H.seconds !== r ? H.seconds : B.seconds
|
|
583
583
|
});
|
|
584
584
|
this.day(s.MIN_DAY), this.year(B.year), this.month(B.month), this.day(B.day), this.hours(B.hours), this.minutes(B.minutes), this.seconds(B.seconds), this.milliseconds(B.milliseconds);
|
|
585
585
|
}
|
|
@@ -595,7 +595,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
595
595
|
if (t === "long")
|
|
596
596
|
return W[this._d.getDay()];
|
|
597
597
|
if (t === "short")
|
|
598
|
-
return
|
|
598
|
+
return L[this._d.getDay()];
|
|
599
599
|
if (t === r)
|
|
600
600
|
return this._d.getDay();
|
|
601
601
|
if (t === 0 || t === "Sunday")
|
|
@@ -672,7 +672,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
672
672
|
}
|
|
673
673
|
}, T.fn.format = function(t) {
|
|
674
674
|
for (var n = 0, f = "", m; n < t.length; )
|
|
675
|
-
t.charAt(n) === "%" ? (m = t.charAt(n) + t.charAt(n + 1),
|
|
675
|
+
t.charAt(n) === "%" ? (m = t.charAt(n) + t.charAt(n + 1), I[m] !== r ? (f += I[m].format(this), n += 1) : f += "%") : f += t.charAt(n), n += 1;
|
|
676
676
|
return f;
|
|
677
677
|
}, T.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;
|
|
@@ -702,17 +702,17 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
702
702
|
return new T(t, n, f);
|
|
703
703
|
}, s.MIN_YEAR = 1e3, s.MAX_YEAR = 3e3, s.MIN_MONTH = 1, s.MAX_MONTH = 12, s.MIN_DAY = 1, s.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], s.MIN_DAY_OF_WEEK = 0, s.MAX_DAY_OF_WEEK = 6, s.MIN_HOURS = 0, s.MAX_HOURS = 23, s.MIN_MINUTES = 0, s.MAX_MINUTES = 59, s.MIN_SECONDS = 0, s.MAX_SECONDS = 59, s.MIN_MILLISECONDS = 0, s.MAX_MILLISECONDS = 999, s.VERSION = "0.2.18", s.options = function(t, n) {
|
|
704
704
|
if (t === r)
|
|
705
|
-
return
|
|
706
|
-
if (
|
|
705
|
+
return et;
|
|
706
|
+
if (et.hasOwnProperty(t)) {
|
|
707
707
|
if (n === r)
|
|
708
|
-
return
|
|
709
|
-
|
|
708
|
+
return et[t];
|
|
709
|
+
et[t] = n, t === "monthFromZero" && (s.MIN_MONTH = n ? 0 : 1, s.MAX_MONTH = n ? 11 : 12);
|
|
710
710
|
}
|
|
711
711
|
return r;
|
|
712
712
|
}, s.noConflict = function() {
|
|
713
|
-
return i.tempus =
|
|
713
|
+
return i.tempus = c, s;
|
|
714
714
|
}, s.generate = function(t) {
|
|
715
|
-
var n, f, m,
|
|
715
|
+
var n, f, m, S, y, R, j, C;
|
|
716
716
|
if (typeof t.dateFrom != "number" && (t.dateFrom instanceof T ? n = t.dateFrom.utc() : n = s(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof T ? f = t.dateTo.utc() : f = s(t.dateTo, t.formatTo !== r ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? y = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
@@ -734,8 +734,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
734
734
|
hours: t.period.hours !== r ? t.period.hours : 0,
|
|
735
735
|
minutes: t.period.minutes !== r ? t.period.minutes : 0,
|
|
736
736
|
seconds: t.period.seconds !== r ? t.period.seconds : 0
|
|
737
|
-
}), t.groupBy === r ? R = t.asObject === !0 ? {} : [] : (R = [], R.push([]), j = s(n).get()[t.groupBy]), C = function(x, B,
|
|
738
|
-
return t.asObject === !0 ? t.format !== r ? x[s(B).format(t.format)] = {} : x[s(B).format("%F %H:%M:%S")] = {} : t.format !== r ? x.push(
|
|
737
|
+
}), t.groupBy === r ? R = t.asObject === !0 ? {} : [] : (R = [], R.push([]), j = s(n).get()[t.groupBy]), C = function(x, B, H) {
|
|
738
|
+
return t.asObject === !0 ? t.format !== r ? x[s(B).format(t.format)] = {} : x[s(B).format("%F %H:%M:%S")] = {} : t.format !== r ? x.push(H ? null : s(B).format(t.format)) : x.push(H ? null : s(B)), x;
|
|
739
739
|
}, t.groupBy !== r && t.fillNulls) {
|
|
740
740
|
var Y = {
|
|
741
741
|
year: y.year ? -y.year : r,
|
|
@@ -757,8 +757,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
757
757
|
for (; n <= f; )
|
|
758
758
|
t.groupBy === r ? C(R, n) : s(n).get()[t.groupBy] === j ? C(R[R.length - 1], n) : (R.push([]), C(R[R.length - 1], n), j = s(n).get()[t.groupBy]), n = s(n).calc(y).utc();
|
|
759
759
|
if (t.groupBy !== r && t.fillNulls)
|
|
760
|
-
for (
|
|
761
|
-
C(R[R.length - 1],
|
|
760
|
+
for (S = s(f).calc(y).utc(); s(S).get()[t.groupBy] === j; )
|
|
761
|
+
C(R[R.length - 1], S, !0), S = s(S).calc(y).utc();
|
|
762
762
|
return R;
|
|
763
763
|
}, s.monthNames = function(t) {
|
|
764
764
|
switch (t) {
|
|
@@ -772,29 +772,29 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
772
772
|
case "long":
|
|
773
773
|
return W;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return L;
|
|
776
776
|
}
|
|
777
777
|
}, s.lang = function(t) {
|
|
778
778
|
if (t !== r)
|
|
779
|
-
|
|
779
|
+
A = t, l[A] === r && (A = "en"), U = N(), P = O(), W = p(), L = b();
|
|
780
780
|
else
|
|
781
|
-
return
|
|
781
|
+
return A;
|
|
782
782
|
return r;
|
|
783
783
|
}, s.availableLangs = function() {
|
|
784
|
-
return Object.keys(
|
|
785
|
-
}, s.registerFormat = function(t, n, f, m,
|
|
786
|
-
|
|
784
|
+
return Object.keys(l);
|
|
785
|
+
}, s.registerFormat = function(t, n, f, m, S, y) {
|
|
786
|
+
I[t] = {
|
|
787
787
|
format: n,
|
|
788
788
|
parse: f,
|
|
789
789
|
minLength: m,
|
|
790
|
-
maxLength:
|
|
790
|
+
maxLength: S,
|
|
791
791
|
type: y
|
|
792
792
|
};
|
|
793
793
|
}, s.unregisterFormat = function(t) {
|
|
794
|
-
delete
|
|
794
|
+
delete I[t];
|
|
795
795
|
}, s.detectFormat = function(t) {
|
|
796
796
|
var n, f, m;
|
|
797
|
-
return n =
|
|
797
|
+
return n = u(t, 0), n !== "" && (m = 10), f = t.charAt(m), (f === "T" || f === " ") && (n += f, m += 1), n += h(t, m), n;
|
|
798
798
|
}, d = {
|
|
799
799
|
TempusDate: T
|
|
800
800
|
}, s.classes = function(t, n) {
|
|
@@ -802,15 +802,15 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
802
802
|
return d[t];
|
|
803
803
|
d[t] = n;
|
|
804
804
|
}, s.loadTranslations = function(t) {
|
|
805
|
-
typeof t == "object" ?
|
|
806
|
-
|
|
805
|
+
typeof t == "object" ? l = t : typeof t == "string" && k(t, function(n) {
|
|
806
|
+
l = n;
|
|
807
807
|
}, function(n) {
|
|
808
808
|
});
|
|
809
|
-
},
|
|
810
|
-
}).call(
|
|
811
|
-
})(
|
|
812
|
-
var
|
|
813
|
-
const
|
|
809
|
+
}, A = (g.language || g.systemLanguage || g.userLanguage || "en").substr(0, 2).toLowerCase(), l[A] === r && (A = "en"), U = N(), P = O(), W = p(), L = b(), _.exports && (e = _.exports = s), e.tempus = s;
|
|
810
|
+
}).call(Tt);
|
|
811
|
+
})(ht, ht.exports);
|
|
812
|
+
var Lt = ht.exports;
|
|
813
|
+
const rt = /* @__PURE__ */ Rt(Lt);
|
|
814
814
|
class v {
|
|
815
815
|
constructor(e) {
|
|
816
816
|
this.callBatch = e, this.result = {}, this.errors = {}, this.limit = 50, this.canContinue = !0, this.progressCall = "", this.limitCall = "", this.progressData = "", this.progressTimer = "", this.progressDelay = 100, this.oldPercent = "no", this.chunkRate = 1, this.totalProgress = 0, this.skipList = /* @__PURE__ */ new Set();
|
|
@@ -833,8 +833,8 @@ class v {
|
|
|
833
833
|
return { percent: Math.round(e), allCount: 0, allTotal: 0 };
|
|
834
834
|
let r = 0, i = 0;
|
|
835
835
|
return Object.values(this.progressData).forEach((o) => {
|
|
836
|
-
const { total: a, count:
|
|
837
|
-
r += a ?? 0, i +=
|
|
836
|
+
const { total: a, count: h } = o;
|
|
837
|
+
r += a ?? 0, i += h ?? 0;
|
|
838
838
|
}), r ? e = i / r * 100 * this.chunkRate + this.totalProgress : i === 0 && r === 0 ? e = 100 * this.chunkRate + this.totalProgress : e = 100, { percent: Math.round(e), allCount: i, allTotal: r };
|
|
839
839
|
}
|
|
840
840
|
/**
|
|
@@ -846,17 +846,17 @@ class v {
|
|
|
846
846
|
*/
|
|
847
847
|
setProgressData({ key: e, value: r, type: i }) {
|
|
848
848
|
const o = this.getData(r.data()), a = Array.isArray(o) ? o.length : 0;
|
|
849
|
-
let
|
|
850
|
-
i === "count" && (
|
|
851
|
-
let
|
|
852
|
-
o && (
|
|
853
|
-
const { percent:
|
|
849
|
+
let h = r.total() || a;
|
|
850
|
+
i === "count" && (h = a);
|
|
851
|
+
let u = 1;
|
|
852
|
+
o && (u = a), this.progressCall && (this.progressData || (this.progressData = {}), this.progressData[e] && this.progressData[e].count && (u += this.progressData[e].count), this.progressData[e] ? this.progressData[e].count = u : this.progressData[e] = { total: h, count: u }, this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
853
|
+
const { percent: c, allCount: s, allTotal: d } = this.progressPercent;
|
|
854
854
|
(this.oldPercent === "no" || this.oldPercent < this.progressPercent.percent) && (this.progressCall({
|
|
855
855
|
data: this.progressData,
|
|
856
|
-
percent:
|
|
856
|
+
percent: c,
|
|
857
857
|
allCount: s,
|
|
858
858
|
allTotal: d
|
|
859
|
-
}), this.oldPercent = this.progressPercent.percent),
|
|
859
|
+
}), this.oldPercent = this.progressPercent.percent), c >= 100 && this.clearProgressData();
|
|
860
860
|
}, this.progressDelay)));
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
@@ -877,25 +877,25 @@ class v {
|
|
|
877
877
|
callBatchWithTimeout(e, r) {
|
|
878
878
|
return new Promise((i, o) => {
|
|
879
879
|
let a = !1;
|
|
880
|
-
const
|
|
881
|
-
let
|
|
882
|
-
const
|
|
880
|
+
const h = 6e4;
|
|
881
|
+
let u = !1, c = !1, s = !1, d = null, g = null;
|
|
882
|
+
const A = async (O, p) => {
|
|
883
883
|
if (!a) {
|
|
884
|
-
a = !0, d && clearTimeout(d),
|
|
884
|
+
a = !0, d && clearTimeout(d), g && clearTimeout(g);
|
|
885
885
|
try {
|
|
886
|
-
await Promise.resolve(r(
|
|
887
|
-
} catch (
|
|
888
|
-
console.error(`Error in callBatch callback (attempt ${
|
|
886
|
+
await Promise.resolve(r(O)), i();
|
|
887
|
+
} catch (b) {
|
|
888
|
+
console.error(`Error in callBatch callback (attempt ${p}):`, b), o(b);
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
|
-
},
|
|
891
|
+
}, l = async () => {
|
|
892
892
|
if (!a) {
|
|
893
|
-
a = !0, d && clearTimeout(d),
|
|
894
|
-
`Batch request timeout after ${
|
|
893
|
+
a = !0, d && clearTimeout(d), g && clearTimeout(g), console.warn(
|
|
894
|
+
`Batch request timeout after ${h}ms on both attempts. This may indicate a CORS or network error.`
|
|
895
895
|
);
|
|
896
|
-
const
|
|
897
|
-
Object.keys(e).forEach((
|
|
898
|
-
|
|
896
|
+
const O = {};
|
|
897
|
+
Object.keys(e).forEach((p) => {
|
|
898
|
+
O[p] = {
|
|
899
899
|
error: () => ({
|
|
900
900
|
ex: {
|
|
901
901
|
error: "TIMEOUT",
|
|
@@ -907,27 +907,27 @@ class v {
|
|
|
907
907
|
};
|
|
908
908
|
});
|
|
909
909
|
try {
|
|
910
|
-
await Promise.resolve(r(
|
|
911
|
-
} catch (
|
|
912
|
-
console.error("Error in timeout callback:",
|
|
910
|
+
await Promise.resolve(r(O)), i();
|
|
911
|
+
} catch (p) {
|
|
912
|
+
console.error("Error in timeout callback:", p), i();
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
},
|
|
915
|
+
}, N = (O) => {
|
|
916
916
|
try {
|
|
917
|
-
this.callBatch(e, async (
|
|
918
|
-
|
|
917
|
+
this.callBatch(e, async (p) => {
|
|
918
|
+
O === 1 && !u && !a ? (u = !0, await A(p, 1)) : O === 2 && !s && !a && (s = !0, await A(p, 2));
|
|
919
919
|
});
|
|
920
|
-
} catch (
|
|
921
|
-
a || console.error(`Error calling callBatch (attempt ${
|
|
920
|
+
} catch (p) {
|
|
921
|
+
a || console.error(`Error calling callBatch (attempt ${O}):`, p);
|
|
922
922
|
}
|
|
923
923
|
};
|
|
924
|
-
|
|
925
|
-
!
|
|
926
|
-
`First batch request attempt timeout after ${
|
|
927
|
-
),
|
|
928
|
-
!
|
|
929
|
-
},
|
|
930
|
-
},
|
|
924
|
+
N(1), d = setTimeout(async () => {
|
|
925
|
+
!u && !a && !c && (console.warn(
|
|
926
|
+
`First batch request attempt timeout after ${h}ms. Starting second attempt...`
|
|
927
|
+
), c = !0, N(2), g = setTimeout(async () => {
|
|
928
|
+
!u && !s && !a && await l();
|
|
929
|
+
}, h));
|
|
930
|
+
}, h);
|
|
931
931
|
});
|
|
932
932
|
}
|
|
933
933
|
/**
|
|
@@ -951,20 +951,20 @@ class v {
|
|
|
951
951
|
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
952
952
|
const o = {};
|
|
953
953
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
954
|
-
let a = {},
|
|
955
|
-
for (const [
|
|
954
|
+
let a = {}, h = 0;
|
|
955
|
+
for (const [u, c] of Object.entries(e)) {
|
|
956
956
|
if (!this.canContinue)
|
|
957
957
|
break;
|
|
958
|
-
const s = this.arrayChunk(
|
|
958
|
+
const s = this.arrayChunk(c);
|
|
959
959
|
if (!s) {
|
|
960
|
-
|
|
960
|
+
h++;
|
|
961
961
|
continue;
|
|
962
962
|
}
|
|
963
|
-
a[
|
|
964
|
-
o[d] =
|
|
963
|
+
a[u] = s, (Object.keys(a).length >= 50 || h + 1 === Object.keys(e).length) && (await this.batchChunk(a), Object.entries(this.result).forEach(([d, g]) => {
|
|
964
|
+
o[d] = g;
|
|
965
965
|
}), this.totalProgress = Math.round(
|
|
966
|
-
|
|
967
|
-
), a = {}),
|
|
966
|
+
h / Object.keys(e).length * 100
|
|
967
|
+
), a = {}), h++;
|
|
968
968
|
}
|
|
969
969
|
return Object.entries(this.errors).length && (o.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(o);
|
|
970
970
|
}
|
|
@@ -982,20 +982,20 @@ class v {
|
|
|
982
982
|
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
983
983
|
const o = {};
|
|
984
984
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
985
|
-
let a = {},
|
|
986
|
-
for (const [
|
|
985
|
+
let a = {}, h = 0;
|
|
986
|
+
for (const [u, c] of Object.entries(e)) {
|
|
987
987
|
if (!this.canContinue)
|
|
988
988
|
break;
|
|
989
|
-
const s = this.arrayChunk(
|
|
989
|
+
const s = this.arrayChunk(c);
|
|
990
990
|
if (!s) {
|
|
991
|
-
|
|
991
|
+
h++;
|
|
992
992
|
continue;
|
|
993
993
|
}
|
|
994
|
-
a[
|
|
995
|
-
o[d] =
|
|
994
|
+
a[u] = s, (Object.keys(a).length >= 50 || h + 1 === Object.keys(e).length) && (await this.batchChunk(a, "count"), Object.entries(this.result).forEach(([d, g]) => {
|
|
995
|
+
o[d] = g;
|
|
996
996
|
}), this.totalProgress = Math.round(
|
|
997
|
-
|
|
998
|
-
), a = {}),
|
|
997
|
+
h / Object.keys(e).length * 100
|
|
998
|
+
), a = {}), h++;
|
|
999
999
|
}
|
|
1000
1000
|
return Object.entries(this.errors).length && (o.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(o);
|
|
1001
1001
|
}
|
|
@@ -1016,8 +1016,8 @@ class v {
|
|
|
1016
1016
|
else {
|
|
1017
1017
|
r === "tasks.task.list" ? (i.order || (i.order = {}), i.order.ID = "asc") : r === "user.get" ? (i.sort || (i.sort = "ID"), i.order || (i.order = "ASC")) : i.order = { ID: "ASC", id: "ASC" }, Array.isArray(i.select) && !i.select.includes("ID") && i.select.push("ID");
|
|
1018
1018
|
const o = r === "user.get" ? i.FILTER : i.filter;
|
|
1019
|
-
typeof o == "object" && o !== null && !Array.isArray(o) && Object.entries(o).forEach(([a,
|
|
1020
|
-
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(a) && (typeof
|
|
1019
|
+
typeof o == "object" && o !== null && !Array.isArray(o) && Object.entries(o).forEach(([a, h]) => {
|
|
1020
|
+
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(a) && (typeof h == "string" || Array.isArray(h) && h.length <= 50) && (i.start = -1);
|
|
1021
1021
|
});
|
|
1022
1022
|
}
|
|
1023
1023
|
r === "crm.type.list" && i.order && delete i.order.ID;
|
|
@@ -1027,8 +1027,8 @@ class v {
|
|
|
1027
1027
|
i = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
1028
1028
|
else {
|
|
1029
1029
|
Array.isArray(i[0]) && (i[0] = {});
|
|
1030
|
-
const [o, a,
|
|
1031
|
-
o.ID = "ASC",
|
|
1030
|
+
const [o, a, h, u] = i;
|
|
1031
|
+
o.ID = "ASC", u[0] !== "" && u.includes("ID") || u.push("ID");
|
|
1032
1032
|
}
|
|
1033
1033
|
return { method: r, params: i };
|
|
1034
1034
|
}
|
|
@@ -1042,37 +1042,37 @@ class v {
|
|
|
1042
1042
|
return new Promise((i) => {
|
|
1043
1043
|
const o = [];
|
|
1044
1044
|
let a;
|
|
1045
|
-
this.callBatchWithTimeout(e, async (
|
|
1046
|
-
var
|
|
1047
|
-
for (const [
|
|
1045
|
+
this.callBatchWithTimeout(e, async (h) => {
|
|
1046
|
+
var u, c, s, d, g, A, l;
|
|
1047
|
+
for (const [N, O] of Object.entries(h)) {
|
|
1048
1048
|
if (!this.canContinue)
|
|
1049
1049
|
return;
|
|
1050
|
-
if (
|
|
1051
|
-
switch (this.errors[
|
|
1050
|
+
if (O.error())
|
|
1051
|
+
switch (this.errors[N] = ((c = (u = O.error()) == null ? void 0 : u.ex) == null ? void 0 : c.error) ?? ((d = (s = O.error()) == null ? void 0 : s.ex) == null ? void 0 : d.error_description) ?? ((g = O.error()) == null ? void 0 : g.toString()) ?? "Неизвестная ошибка", a = !0, ((l = (A = O.error()) == null ? void 0 : A.ex) == null ? void 0 : l.error) ?? "") {
|
|
1052
1052
|
case "OPERATION_TIME_LIMIT":
|
|
1053
|
-
this.skipList.add(e[
|
|
1053
|
+
this.skipList.add(e[N].method), this.limitCall && this.limitCall(N);
|
|
1054
1054
|
break;
|
|
1055
1055
|
case "ACCESS_DENIED":
|
|
1056
|
-
this.skipList.add(e[
|
|
1056
|
+
this.skipList.add(e[N].method);
|
|
1057
1057
|
break;
|
|
1058
1058
|
case "TIMEOUT":
|
|
1059
|
-
let k = e[
|
|
1060
|
-
Array.isArray(k) ? [
|
|
1059
|
+
let k = e[N], I = "";
|
|
1060
|
+
Array.isArray(k) ? [I] = k : k != null && k.method && (I = k.method), I && this.skipList.add(I), this.limitCall && this.limitCall(N);
|
|
1061
1061
|
break;
|
|
1062
1062
|
}
|
|
1063
|
-
const
|
|
1064
|
-
r === "count" ? this.result[
|
|
1065
|
-
const W = r === "count" ? !U &&
|
|
1063
|
+
const p = this.getData(O.data()), b = Array.isArray(p) ? p.length : 0, U = typeof O.total == "function" && O.total() !== void 0, P = U ? O.total() : b;
|
|
1064
|
+
r === "count" ? this.result[N] ? this.result[N] += b : this.result[N] = P : this.result[N] = p, this.setProgressData({ key: N, value: O, type: r });
|
|
1065
|
+
const W = r === "count" ? !U && b === this.limit : P > this.limit && P > b;
|
|
1066
1066
|
if (!this.canContinue || W) {
|
|
1067
|
-
let
|
|
1068
|
-
if (Array.isArray(
|
|
1069
|
-
const [k,
|
|
1070
|
-
|
|
1067
|
+
let L = e[N];
|
|
1068
|
+
if (Array.isArray(L)) {
|
|
1069
|
+
const [k, I = {}] = L;
|
|
1070
|
+
L = [k, I];
|
|
1071
1071
|
} else {
|
|
1072
|
-
const { method: k, params:
|
|
1073
|
-
|
|
1072
|
+
const { method: k, params: I = {} } = L;
|
|
1073
|
+
L = [k, I];
|
|
1074
1074
|
}
|
|
1075
|
-
o.push([
|
|
1075
|
+
o.push([N, L, P]);
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
1078
|
a > 0 && this.errorLogger(), o.length ? await this.batchPayload(o, r).then(
|
|
@@ -1086,80 +1086,80 @@ class v {
|
|
|
1086
1086
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1087
1087
|
*/
|
|
1088
1088
|
async batchPayload(e, r) {
|
|
1089
|
-
const i = /* @__PURE__ */ new Map(), o = (
|
|
1090
|
-
let
|
|
1091
|
-
this.result[
|
|
1092
|
-
let
|
|
1093
|
-
if (JSON.stringify(
|
|
1089
|
+
const i = /* @__PURE__ */ new Map(), o = (c, s, d, g) => {
|
|
1090
|
+
let A = "ID";
|
|
1091
|
+
this.result[c][this.result[c].length - 1].ID || (A = "id");
|
|
1092
|
+
let l = `${A}`;
|
|
1093
|
+
if (JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"') ? l = "<" + l : l = ">" + l, s === 1 || d.length === 0)
|
|
1094
1094
|
return {
|
|
1095
|
-
field:
|
|
1096
|
-
id: this.result[
|
|
1095
|
+
field: l,
|
|
1096
|
+
id: this.result[c][this.result[c].length - 1][A]
|
|
1097
1097
|
};
|
|
1098
|
-
let
|
|
1099
|
-
const [
|
|
1100
|
-
return (
|
|
1101
|
-
field:
|
|
1102
|
-
id: `$result[${[
|
|
1098
|
+
let O = "";
|
|
1099
|
+
const [p, b] = g;
|
|
1100
|
+
return (p === "tasks.task.list" || p === "task.item.list") && (O = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(p) && (O = "[items]"), p === "crm.type.list" && (O = "[types]"), p === "socialnetwork.api.workgroup.list" && (O = "[workgroups]"), {
|
|
1101
|
+
field: l,
|
|
1102
|
+
id: `$result[${[c, s - 1].join("__")}]${O}[49][${A}]`
|
|
1103
1103
|
};
|
|
1104
|
-
}, a = (
|
|
1105
|
-
const [d,
|
|
1106
|
-
let
|
|
1104
|
+
}, a = (c, s) => {
|
|
1105
|
+
const [d, g] = c;
|
|
1106
|
+
let A = JSON.parse(JSON.stringify(g)), l;
|
|
1107
1107
|
if (d === "task.item.list") {
|
|
1108
|
-
|
|
1109
|
-
const [
|
|
1110
|
-
return
|
|
1108
|
+
A = [...A];
|
|
1109
|
+
const [N, O, p, b] = A;
|
|
1110
|
+
return O[s.field] = s.id, [d, A];
|
|
1111
1111
|
}
|
|
1112
|
-
return ["user.get"].includes(d) ||
|
|
1112
|
+
return ["user.get"].includes(d) || A.FILTER ? (A.FILTER || (A.FILTER = {}), l = A.FILTER) : (A.filter || (A.filter = {}), l = A.filter), [
|
|
1113
1113
|
"socialnetwork.api.workgroup.list",
|
|
1114
1114
|
"tasks.task.list"
|
|
1115
|
-
].includes(d) ?
|
|
1116
|
-
},
|
|
1117
|
-
Object.entries(
|
|
1118
|
-
var
|
|
1119
|
-
const [
|
|
1120
|
-
if (Array.isArray(
|
|
1121
|
-
this.errors[
|
|
1122
|
-
const W = ((P = (U = d.error()) == null ? void 0 : U.ex) == null ? void 0 : P.error) ?? "",
|
|
1115
|
+
].includes(d) ? l[">ID"] = s.id : l[s.field] = s.id, [d, { ...A, start: -1 }];
|
|
1116
|
+
}, h = (c) => {
|
|
1117
|
+
Object.entries(c).forEach(([s, d]) => {
|
|
1118
|
+
var l, N, O, p, b, U, P;
|
|
1119
|
+
const [g] = s.split("__"), A = this.getData(d.data());
|
|
1120
|
+
if (Array.isArray(A) && (r === "count" ? this.result[g] += A.length : this.result[g].push(...A)), d.error()) {
|
|
1121
|
+
this.errors[g] = ((N = (l = d.error()) == null ? void 0 : l.ex) == null ? void 0 : N.error) ?? ((p = (O = d.error()) == null ? void 0 : O.ex) == null ? void 0 : p.error_description) ?? ((b = d.error()) == null ? void 0 : b.toString()) ?? "Неизвестная ошибка";
|
|
1122
|
+
const W = ((P = (U = d.error()) == null ? void 0 : U.ex) == null ? void 0 : P.error) ?? "", L = i.get(g);
|
|
1123
1123
|
switch (W) {
|
|
1124
1124
|
case "OPERATION_TIME_LIMIT":
|
|
1125
|
-
|
|
1125
|
+
L && (this.skipList.add(L), this.limitCall && this.limitCall(g));
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "QUERY_LIMIT_EXCEEDED":
|
|
1128
1128
|
this.canContinue = !1;
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "ACCESS_DENIED":
|
|
1131
|
-
|
|
1131
|
+
L && this.skipList.add(L);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "TIMEOUT":
|
|
1134
|
-
|
|
1134
|
+
L && (this.skipList.add(L), this.limitCall && this.limitCall(g));
|
|
1135
1135
|
break;
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
|
-
this.setProgressData({ key:
|
|
1138
|
+
this.setProgressData({ key: g, value: d, type: r });
|
|
1139
1139
|
});
|
|
1140
1140
|
};
|
|
1141
|
-
let
|
|
1142
|
-
for await (const [
|
|
1141
|
+
let u = [];
|
|
1142
|
+
for await (const [c, s, d] of e) {
|
|
1143
1143
|
if (!this.canContinue)
|
|
1144
1144
|
return;
|
|
1145
|
-
const [
|
|
1146
|
-
if (i.set(
|
|
1145
|
+
const [g] = s;
|
|
1146
|
+
if (i.set(c, g), this.skipList.has(g))
|
|
1147
1147
|
continue;
|
|
1148
|
-
let
|
|
1149
|
-
for (; d >
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
Object.fromEntries(
|
|
1153
|
-
(
|
|
1154
|
-
|
|
1148
|
+
let A = 1;
|
|
1149
|
+
for (; d > A * 50 && !this.skipList.has(g); ) {
|
|
1150
|
+
const l = [c, A].join("__"), N = o(c, A, u, s);
|
|
1151
|
+
u.push([l, a(s, N)]), u.length % 50 === 0 && (await this.callBatchWithTimeout(
|
|
1152
|
+
Object.fromEntries(u),
|
|
1153
|
+
(O) => {
|
|
1154
|
+
h(O);
|
|
1155
1155
|
}
|
|
1156
|
-
),
|
|
1156
|
+
), u = [], await this.delay()), A++;
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
|
-
|
|
1160
|
-
Object.fromEntries(
|
|
1161
|
-
(
|
|
1162
|
-
c
|
|
1159
|
+
u.length && (await this.callBatchWithTimeout(
|
|
1160
|
+
Object.fromEntries(u),
|
|
1161
|
+
(c) => {
|
|
1162
|
+
h(c);
|
|
1163
1163
|
}
|
|
1164
1164
|
), await this.delay());
|
|
1165
1165
|
}
|
|
@@ -1173,9 +1173,9 @@ class v {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
1175
|
var K;
|
|
1176
|
-
class
|
|
1176
|
+
class mt {
|
|
1177
1177
|
constructor() {
|
|
1178
|
-
|
|
1178
|
+
w(this, K, {});
|
|
1179
1179
|
}
|
|
1180
1180
|
/**
|
|
1181
1181
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1243,28 +1243,28 @@ class ut {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
1245
1245
|
K = new WeakMap();
|
|
1246
|
-
const
|
|
1247
|
-
var
|
|
1248
|
-
class
|
|
1246
|
+
const ct = new mt();
|
|
1247
|
+
var J, Q, Z, z, G, V, q, st, dt, $, ut, it, gt, nt, Nt, ot, Ot;
|
|
1248
|
+
class bt {
|
|
1249
1249
|
constructor() {
|
|
1250
|
-
|
|
1250
|
+
w(this, st);
|
|
1251
1251
|
/** Вывод ошибок логера
|
|
1252
1252
|
* @param {'entity'} type - тип ошибки
|
|
1253
1253
|
*/
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1254
|
+
w(this, $);
|
|
1255
|
+
w(this, it);
|
|
1256
|
+
w(this, nt);
|
|
1257
|
+
w(this, ot);
|
|
1258
|
+
w(this, J, "logger");
|
|
1259
|
+
w(this, Q, !1);
|
|
1260
|
+
w(this, Z, /* @__PURE__ */ new Map());
|
|
1261
|
+
w(this, z, {});
|
|
1262
|
+
w(this, G, null);
|
|
1263
|
+
w(this, V, !1);
|
|
1264
|
+
w(this, q, !1);
|
|
1265
1265
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1266
1266
|
M(this, "periodClear", 3);
|
|
1267
|
-
|
|
1267
|
+
X(this, st, dt).call(this);
|
|
1268
1268
|
}
|
|
1269
1269
|
/** Инициализация логера */
|
|
1270
1270
|
async init() {
|
|
@@ -1274,7 +1274,7 @@ class Rt {
|
|
|
1274
1274
|
});
|
|
1275
1275
|
if (r && Array.isArray(r))
|
|
1276
1276
|
if (r.find(
|
|
1277
|
-
(o) => o.ENTITY == E(this,
|
|
1277
|
+
(o) => o.ENTITY == E(this, J)
|
|
1278
1278
|
))
|
|
1279
1279
|
F(this, Q, !0);
|
|
1280
1280
|
else {
|
|
@@ -1282,15 +1282,15 @@ class Rt {
|
|
|
1282
1282
|
entityAdd: {
|
|
1283
1283
|
method: "entity.add",
|
|
1284
1284
|
params: {
|
|
1285
|
-
ENTITY: E(this,
|
|
1286
|
-
NAME: E(this,
|
|
1285
|
+
ENTITY: E(this, J),
|
|
1286
|
+
NAME: E(this, J),
|
|
1287
1287
|
ACCESS: { AU: "X" }
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
1290
|
});
|
|
1291
1291
|
o && F(this, Q, !0);
|
|
1292
1292
|
}
|
|
1293
|
-
return
|
|
1293
|
+
return X(this, nt, Nt).call(this).catch((i) => {
|
|
1294
1294
|
console.error("Ошибка при проверке периода очистки:", i);
|
|
1295
1295
|
}), E(this, Q);
|
|
1296
1296
|
} catch (e) {
|
|
@@ -1308,10 +1308,10 @@ class Rt {
|
|
|
1308
1308
|
*/
|
|
1309
1309
|
start({ type: e, data: r }) {
|
|
1310
1310
|
if (!E(this, Q))
|
|
1311
|
-
return
|
|
1311
|
+
return X(this, $, ut).call(this, "entity"), null;
|
|
1312
1312
|
if (!e || !r)
|
|
1313
1313
|
return console.error("Невалидные данные для логирования:", { type: e, data: r }), null;
|
|
1314
|
-
const i =
|
|
1314
|
+
const i = ct.hash, o = {
|
|
1315
1315
|
type: e,
|
|
1316
1316
|
data: r,
|
|
1317
1317
|
userInfo: E(this, z),
|
|
@@ -1330,11 +1330,11 @@ class Rt {
|
|
|
1330
1330
|
* answer: { [key]: unknown } }}
|
|
1331
1331
|
*/
|
|
1332
1332
|
async stop({ key: e, errorList: r, status: i, answer: o }) {
|
|
1333
|
-
var
|
|
1333
|
+
var h;
|
|
1334
1334
|
if (!E(this, q))
|
|
1335
1335
|
return;
|
|
1336
1336
|
if (!E(this, Q)) {
|
|
1337
|
-
|
|
1337
|
+
X(this, $, ut).call(this, "entity");
|
|
1338
1338
|
return;
|
|
1339
1339
|
}
|
|
1340
1340
|
let a = E(this, Z).get(e);
|
|
@@ -1342,7 +1342,7 @@ class Rt {
|
|
|
1342
1342
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1343
1343
|
return;
|
|
1344
1344
|
}
|
|
1345
|
-
r && (a.errorList = r), i && (a.status = i), o && (a.answer = o), await
|
|
1345
|
+
r && (a.errorList = r), i && (a.status = i), o && (a.answer = o), await X(this, it, gt).call(this), (h = a == null ? void 0 : a.data) != null && h.updateList && F(this, V, !0), F(this, q, !1);
|
|
1346
1346
|
}
|
|
1347
1347
|
/**
|
|
1348
1348
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1357,7 +1357,7 @@ class Rt {
|
|
|
1357
1357
|
entityList: {
|
|
1358
1358
|
method: "entity.item.get",
|
|
1359
1359
|
params: {
|
|
1360
|
-
ENTITY: E(this,
|
|
1360
|
+
ENTITY: E(this, J),
|
|
1361
1361
|
SORT: { ID: "DESC" }
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
@@ -1366,16 +1366,16 @@ class Rt {
|
|
|
1366
1366
|
);
|
|
1367
1367
|
return !o || !Array.isArray(o) ? (console.warn("Получен невалидный список записей"), []) : (o = o.map((a) => {
|
|
1368
1368
|
try {
|
|
1369
|
-
const { ID:
|
|
1369
|
+
const { ID: h, DATE_CREATE: u, DETAIL_TEXT: c } = a;
|
|
1370
1370
|
return {
|
|
1371
|
-
...JSON.parse(
|
|
1372
|
-
id:
|
|
1373
|
-
dateCreate:
|
|
1371
|
+
...JSON.parse(c),
|
|
1372
|
+
id: h,
|
|
1373
|
+
dateCreate: u
|
|
1374
1374
|
};
|
|
1375
|
-
} catch (
|
|
1375
|
+
} catch (h) {
|
|
1376
1376
|
return console.error(
|
|
1377
1377
|
`Ошибка парсинга записи ${a.ID}:`,
|
|
1378
|
-
|
|
1378
|
+
h
|
|
1379
1379
|
), null;
|
|
1380
1380
|
}
|
|
1381
1381
|
}).filter((a) => a !== null), F(this, V, !1), F(this, G, o), o);
|
|
@@ -1388,8 +1388,8 @@ class Rt {
|
|
|
1388
1388
|
try {
|
|
1389
1389
|
if (E(this, G) || await this.getEntityList(), !E(this, G) || E(this, G).length === 0)
|
|
1390
1390
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1391
|
-
let e =
|
|
1392
|
-
return
|
|
1391
|
+
let e = rt().format("%Y-%m-%d");
|
|
1392
|
+
return ct.downloadFileJson(
|
|
1393
1393
|
E(this, G),
|
|
1394
1394
|
`sdklogger-entity-data__${e}`
|
|
1395
1395
|
), !0;
|
|
@@ -1398,7 +1398,7 @@ class Rt {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
|
-
|
|
1401
|
+
J = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G = new WeakMap(), V = new WeakMap(), q = new WeakMap(), st = new WeakSet(), dt = async function() {
|
|
1402
1402
|
try {
|
|
1403
1403
|
const e = new v(BX24.callBatch), r = BX24.isAdmin(), { curUser: i } = await e.batch({
|
|
1404
1404
|
curUser: { method: "user.current" }
|
|
@@ -1410,15 +1410,15 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1410
1410
|
e
|
|
1411
1411
|
), F(this, z, { isAdmin: !1, curUser: null });
|
|
1412
1412
|
}
|
|
1413
|
-
}, $ = new WeakSet(),
|
|
1414
|
-
e == "entity" &&
|
|
1413
|
+
}, $ = new WeakSet(), ut = function(e) {
|
|
1414
|
+
e == "entity" && ct.actionFilter({
|
|
1415
1415
|
keyTimer: "error.logger.entity",
|
|
1416
1416
|
duration: 500,
|
|
1417
1417
|
action: () => {
|
|
1418
1418
|
console.error("Хранилище для логгера не инициализировано");
|
|
1419
1419
|
}
|
|
1420
1420
|
});
|
|
1421
|
-
},
|
|
1421
|
+
}, it = new WeakSet(), gt = async function() {
|
|
1422
1422
|
try {
|
|
1423
1423
|
let e = {}, r = new v(BX24.callBatch);
|
|
1424
1424
|
for (let [i, o] of E(this, Z).entries())
|
|
@@ -1427,15 +1427,15 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1427
1427
|
e[i] = {
|
|
1428
1428
|
method: "entity.item.add",
|
|
1429
1429
|
params: {
|
|
1430
|
-
ENTITY: E(this,
|
|
1431
|
-
NAME: E(this,
|
|
1430
|
+
ENTITY: E(this, J),
|
|
1431
|
+
NAME: E(this, J),
|
|
1432
1432
|
DETAIL_TEXT: a
|
|
1433
1433
|
}
|
|
1434
1434
|
};
|
|
1435
1435
|
}
|
|
1436
1436
|
if (Object.keys(e).length) {
|
|
1437
1437
|
let i = await r.batch(e), { errors: o } = r;
|
|
1438
|
-
for (let [a,
|
|
1438
|
+
for (let [a, h] of Object.entries({ ...i, ...o }))
|
|
1439
1439
|
E(this, Z).delete(a);
|
|
1440
1440
|
return !0;
|
|
1441
1441
|
}
|
|
@@ -1443,7 +1443,7 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1443
1443
|
} catch (e) {
|
|
1444
1444
|
return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
|
|
1445
1445
|
}
|
|
1446
|
-
},
|
|
1446
|
+
}, nt = new WeakSet(), Nt = async function() {
|
|
1447
1447
|
try {
|
|
1448
1448
|
let e = new v(BX24.callBatch), { serverTime: r } = await e.batch({
|
|
1449
1449
|
serverTime: { method: "server.time" }
|
|
@@ -1457,8 +1457,8 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1457
1457
|
let i = E(this, G).filter((o) => {
|
|
1458
1458
|
try {
|
|
1459
1459
|
let { dateCreate: a } = o;
|
|
1460
|
-
return a ?
|
|
1461
|
-
|
|
1460
|
+
return a ? rt(new Date(a)).between(
|
|
1461
|
+
rt(new Date(r)),
|
|
1462
1462
|
"month"
|
|
1463
1463
|
) >= this.periodClear : !1;
|
|
1464
1464
|
} catch (a) {
|
|
@@ -1467,21 +1467,21 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1467
1467
|
});
|
|
1468
1468
|
i.length > 0 && (console.log(
|
|
1469
1469
|
`Найдено ${i.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1470
|
-
), await
|
|
1470
|
+
), await X(this, ot, Ot).call(this, i));
|
|
1471
1471
|
} catch (e) {
|
|
1472
1472
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1473
1473
|
}
|
|
1474
|
-
},
|
|
1474
|
+
}, ot = new WeakSet(), Ot = async function(e) {
|
|
1475
1475
|
try {
|
|
1476
1476
|
if (!e || e.length === 0)
|
|
1477
1477
|
return !1;
|
|
1478
1478
|
let r = new v(BX24.callBatch), i = e.filter((a) => a && a.id).map((a) => {
|
|
1479
|
-
let { id:
|
|
1479
|
+
let { id: h } = a;
|
|
1480
1480
|
return {
|
|
1481
1481
|
method: "entity.item.delete",
|
|
1482
1482
|
params: {
|
|
1483
|
-
ENTITY: E(this,
|
|
1484
|
-
ID:
|
|
1483
|
+
ENTITY: E(this, J),
|
|
1484
|
+
ID: h
|
|
1485
1485
|
}
|
|
1486
1486
|
};
|
|
1487
1487
|
});
|
|
@@ -1493,8 +1493,8 @@ X = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), G =
|
|
|
1493
1493
|
return console.error("Ошибка при очистке устаревших записей:", r), !1;
|
|
1494
1494
|
}
|
|
1495
1495
|
};
|
|
1496
|
-
var
|
|
1497
|
-
class
|
|
1496
|
+
var at, pt, At, _t, tt, ft;
|
|
1497
|
+
class St {
|
|
1498
1498
|
/**
|
|
1499
1499
|
* @param {Object} appConst - Константы приложения
|
|
1500
1500
|
* @param {string} appConst.appName - Название приложения
|
|
@@ -1502,9 +1502,19 @@ class Lt {
|
|
|
1502
1502
|
*/
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
/** Запрос данных о приложении */
|
|
1505
|
-
|
|
1505
|
+
w(this, at);
|
|
1506
1506
|
/** Запрос данных о текущем пользователе */
|
|
1507
|
-
|
|
1507
|
+
w(this, At);
|
|
1508
|
+
/**
|
|
1509
|
+
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1510
|
+
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
1511
|
+
* @param {Object} restCall - Экземпляр Batch с результатами и ошибками
|
|
1512
|
+
* @param {Object} result - Результат выполнения batch (объект с ключами успешно обработанных запросов)
|
|
1513
|
+
* @param {Object} commandList - Список команд, которые должны были быть обработаны
|
|
1514
|
+
* @param {Array} updateList - Список обновлений для логирования (опционально)
|
|
1515
|
+
* @returns {Object} Расширенный список ошибок
|
|
1516
|
+
*/
|
|
1517
|
+
w(this, tt);
|
|
1508
1518
|
M(this, "domain", "");
|
|
1509
1519
|
M(this, "isAdmin", !1);
|
|
1510
1520
|
M(this, "appInfo", null);
|
|
@@ -1524,7 +1534,7 @@ class Lt {
|
|
|
1524
1534
|
return new Promise((e, r) => {
|
|
1525
1535
|
let o = setInterval(() => {
|
|
1526
1536
|
window.BX24 && BX24.init(async () => {
|
|
1527
|
-
console.info("init BX24"), clearInterval(o), clearTimeout(a), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new
|
|
1537
|
+
console.info("init BX24"), clearInterval(o), clearTimeout(a), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new bt(), await this.logger.init()) : this.logger = {
|
|
1528
1538
|
start: () => {
|
|
1529
1539
|
},
|
|
1530
1540
|
stop: () => {
|
|
@@ -1532,14 +1542,14 @@ class Lt {
|
|
|
1532
1542
|
getEntityList: () => {
|
|
1533
1543
|
}
|
|
1534
1544
|
};
|
|
1535
|
-
const [
|
|
1536
|
-
|
|
1537
|
-
|
|
1545
|
+
const [h, u] = await Promise.all([
|
|
1546
|
+
X(this, at, pt).call(this),
|
|
1547
|
+
X(this, At, _t).call(this)
|
|
1538
1548
|
]);
|
|
1539
|
-
this.appInfo =
|
|
1540
|
-
let
|
|
1549
|
+
this.appInfo = h, this.userInfo = u;
|
|
1550
|
+
let c = new mt();
|
|
1541
1551
|
try {
|
|
1542
|
-
|
|
1552
|
+
c.noSleep();
|
|
1543
1553
|
} catch (s) {
|
|
1544
1554
|
console.warn(
|
|
1545
1555
|
"Failed to initialize noSleep:",
|
|
@@ -1551,10 +1561,10 @@ class Lt {
|
|
|
1551
1561
|
}, 100);
|
|
1552
1562
|
const a = setTimeout(() => {
|
|
1553
1563
|
clearInterval(o);
|
|
1554
|
-
const
|
|
1564
|
+
const h = new Error(
|
|
1555
1565
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
1556
1566
|
);
|
|
1557
|
-
console.error(
|
|
1567
|
+
console.error(h), r(h);
|
|
1558
1568
|
}, 3e4);
|
|
1559
1569
|
});
|
|
1560
1570
|
}
|
|
@@ -1609,18 +1619,18 @@ class Lt {
|
|
|
1609
1619
|
const a = new Error("BX24 is not initialized");
|
|
1610
1620
|
throw console.error(a), a;
|
|
1611
1621
|
}
|
|
1612
|
-
return new Promise((a,
|
|
1613
|
-
BX24.callMethod(e, r, async (
|
|
1614
|
-
let
|
|
1615
|
-
if (
|
|
1616
|
-
for (let [s, d] of Object.entries(
|
|
1617
|
-
s !== "result" && d && (
|
|
1618
|
-
if (
|
|
1619
|
-
let s =
|
|
1622
|
+
return new Promise((a, h) => {
|
|
1623
|
+
BX24.callMethod(e, r, async (u) => {
|
|
1624
|
+
let c = {};
|
|
1625
|
+
if (u != null && u.answer)
|
|
1626
|
+
for (let [s, d] of Object.entries(u.answer))
|
|
1627
|
+
s !== "result" && d && (c[s] = d);
|
|
1628
|
+
if (u.error()) {
|
|
1629
|
+
let s = u.error();
|
|
1620
1630
|
if (console.error(s), o)
|
|
1621
1631
|
try {
|
|
1622
1632
|
await this.logger.stop({
|
|
1623
|
-
answer:
|
|
1633
|
+
answer: c,
|
|
1624
1634
|
key: o,
|
|
1625
1635
|
status: "fail",
|
|
1626
1636
|
errorList: { 0: s.toString() }
|
|
@@ -1630,11 +1640,11 @@ class Lt {
|
|
|
1630
1640
|
}
|
|
1631
1641
|
a(!1);
|
|
1632
1642
|
} else {
|
|
1633
|
-
let s =
|
|
1643
|
+
let s = u.data();
|
|
1634
1644
|
if (s != null && s.items && (s = s.items), o)
|
|
1635
1645
|
try {
|
|
1636
1646
|
await this.logger.stop({
|
|
1637
|
-
answer:
|
|
1647
|
+
answer: c,
|
|
1638
1648
|
key: o,
|
|
1639
1649
|
status: "success"
|
|
1640
1650
|
});
|
|
@@ -1665,50 +1675,51 @@ class Lt {
|
|
|
1665
1675
|
* }[]
|
|
1666
1676
|
* }}
|
|
1667
1677
|
*/
|
|
1668
|
-
async batch(e, r, { errorCall: i, limitCommandSerial: o, updateList: a, limitCall:
|
|
1678
|
+
async batch(e, r, { errorCall: i, limitCommandSerial: o, updateList: a, limitCall: h } = {}) {
|
|
1669
1679
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1670
1680
|
const s = new Error("BX24 is not initialized");
|
|
1671
1681
|
return console.error(s), !1;
|
|
1672
1682
|
}
|
|
1673
|
-
let
|
|
1674
|
-
a && (
|
|
1683
|
+
let u = new v(BX24.callBatch), c;
|
|
1684
|
+
a && (c = this.logger.start({
|
|
1675
1685
|
type: "batch",
|
|
1676
1686
|
data: { commandList: e, updateList: a }
|
|
1677
1687
|
})), o && console.warn(
|
|
1678
1688
|
"limitCommandSerial is deprecated and not used in current Batch implementation"
|
|
1679
1689
|
);
|
|
1680
1690
|
try {
|
|
1681
|
-
let s = await
|
|
1691
|
+
let s = await u.batch(
|
|
1682
1692
|
e,
|
|
1683
1693
|
r,
|
|
1684
|
-
|
|
1694
|
+
h
|
|
1685
1695
|
);
|
|
1686
|
-
|
|
1687
|
-
|
|
1696
|
+
const d = X(this, tt, ft).call(this, u, s, e, a);
|
|
1697
|
+
if (Object.keys(d).length) {
|
|
1698
|
+
if (i && i(d), c)
|
|
1688
1699
|
try {
|
|
1689
1700
|
await this.logger.stop({
|
|
1690
|
-
key:
|
|
1701
|
+
key: c,
|
|
1691
1702
|
status: "fail",
|
|
1692
|
-
errorList:
|
|
1703
|
+
errorList: d
|
|
1693
1704
|
});
|
|
1694
|
-
} catch (
|
|
1695
|
-
console.error("Logger error:",
|
|
1705
|
+
} catch (g) {
|
|
1706
|
+
console.error("Logger error:", g);
|
|
1696
1707
|
}
|
|
1697
|
-
} else if (
|
|
1708
|
+
} else if (c)
|
|
1698
1709
|
try {
|
|
1699
1710
|
await this.logger.stop({
|
|
1700
|
-
key:
|
|
1711
|
+
key: c,
|
|
1701
1712
|
status: "success"
|
|
1702
1713
|
});
|
|
1703
|
-
} catch (
|
|
1704
|
-
console.error("Logger error:",
|
|
1714
|
+
} catch (g) {
|
|
1715
|
+
console.error("Logger error:", g);
|
|
1705
1716
|
}
|
|
1706
1717
|
return s;
|
|
1707
1718
|
} catch (s) {
|
|
1708
|
-
if (
|
|
1719
|
+
if (c)
|
|
1709
1720
|
try {
|
|
1710
1721
|
await this.logger.stop({
|
|
1711
|
-
key:
|
|
1722
|
+
key: c,
|
|
1712
1723
|
status: "fail-runtime",
|
|
1713
1724
|
errorList: { 0: s == null ? void 0 : s.toString() }
|
|
1714
1725
|
});
|
|
@@ -1743,53 +1754,54 @@ class Lt {
|
|
|
1743
1754
|
*/
|
|
1744
1755
|
async batchTotalCount(e, r, { errorCall: i, updateList: o, limitCall: a } = {}) {
|
|
1745
1756
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1746
|
-
const
|
|
1747
|
-
return console.error(
|
|
1757
|
+
const c = new Error("BX24 is not initialized");
|
|
1758
|
+
return console.error(c), !1;
|
|
1748
1759
|
}
|
|
1749
|
-
let
|
|
1750
|
-
o && (
|
|
1760
|
+
let h = new v(BX24.callBatch), u;
|
|
1761
|
+
o && (u = this.logger.start({
|
|
1751
1762
|
type: "batch-total-count",
|
|
1752
1763
|
data: { commandList: e }
|
|
1753
1764
|
}));
|
|
1754
1765
|
try {
|
|
1755
|
-
let
|
|
1766
|
+
let c = await h.batchTotalCount(
|
|
1756
1767
|
e,
|
|
1757
1768
|
r,
|
|
1758
1769
|
a
|
|
1759
1770
|
);
|
|
1760
|
-
|
|
1761
|
-
|
|
1771
|
+
const s = X(this, tt, ft).call(this, h, c, e, o);
|
|
1772
|
+
if (Object.keys(s).length) {
|
|
1773
|
+
if (i && i(s), u)
|
|
1762
1774
|
try {
|
|
1763
1775
|
await this.logger.stop({
|
|
1764
|
-
key:
|
|
1776
|
+
key: u,
|
|
1765
1777
|
status: "fail",
|
|
1766
|
-
errorList:
|
|
1778
|
+
errorList: s
|
|
1767
1779
|
});
|
|
1768
|
-
} catch (
|
|
1769
|
-
console.error("Logger error:",
|
|
1780
|
+
} catch (d) {
|
|
1781
|
+
console.error("Logger error:", d);
|
|
1770
1782
|
}
|
|
1771
|
-
} else if (
|
|
1783
|
+
} else if (u)
|
|
1772
1784
|
try {
|
|
1773
1785
|
await this.logger.stop({
|
|
1774
|
-
key:
|
|
1786
|
+
key: u,
|
|
1775
1787
|
status: "success"
|
|
1776
1788
|
});
|
|
1777
|
-
} catch (
|
|
1778
|
-
console.error("Logger error:",
|
|
1789
|
+
} catch (d) {
|
|
1790
|
+
console.error("Logger error:", d);
|
|
1779
1791
|
}
|
|
1780
|
-
return
|
|
1781
|
-
} catch (
|
|
1782
|
-
if (
|
|
1792
|
+
return c;
|
|
1793
|
+
} catch (c) {
|
|
1794
|
+
if (u)
|
|
1783
1795
|
try {
|
|
1784
1796
|
await this.logger.stop({
|
|
1785
|
-
key:
|
|
1797
|
+
key: u,
|
|
1786
1798
|
status: "fail-runtime",
|
|
1787
|
-
errorList: { 0:
|
|
1799
|
+
errorList: { 0: c == null ? void 0 : c.toString() }
|
|
1788
1800
|
});
|
|
1789
1801
|
} catch (s) {
|
|
1790
1802
|
console.error("Logger error:", s);
|
|
1791
1803
|
}
|
|
1792
|
-
return console.error(
|
|
1804
|
+
return console.error(c), !1;
|
|
1793
1805
|
}
|
|
1794
1806
|
}
|
|
1795
1807
|
/** Запрос данных о местах встройки приложения */
|
|
@@ -1798,81 +1810,81 @@ class Lt {
|
|
|
1798
1810
|
}
|
|
1799
1811
|
/** Встройка приложения в place */
|
|
1800
1812
|
async placementBind(e, r = !0) {
|
|
1801
|
-
var
|
|
1813
|
+
var g, A;
|
|
1802
1814
|
if (!this.isAdmin)
|
|
1803
1815
|
return;
|
|
1804
1816
|
r && await this.placementCheck();
|
|
1805
1817
|
let i = [];
|
|
1806
|
-
if (Array.isArray(e) ? i = e.map((
|
|
1818
|
+
if (Array.isArray(e) ? i = e.map((l) => typeof l == "string" ? { placement: l } : l) : typeof e == "string" ? i = [{ placement: e }] : i = [e], this.placeData = await this.getPlacement(), !this.placeData)
|
|
1807
1819
|
return;
|
|
1808
1820
|
const { appName: o, pathApp: a } = this.appConst;
|
|
1809
|
-
let
|
|
1810
|
-
this.domain === "szdl.bitrix24.ru" && ((
|
|
1811
|
-
const
|
|
1821
|
+
let h = o;
|
|
1822
|
+
this.domain === "szdl.bitrix24.ru" && ((g = this.appInfo) != null && g.ID) && (h = `${o}: #${this.appInfo.ID}`);
|
|
1823
|
+
const u = h.replace(" CRM", ""), c = {}, s = [];
|
|
1812
1824
|
let d = !1;
|
|
1813
|
-
for (let
|
|
1814
|
-
i[
|
|
1815
|
-
if (d && ((
|
|
1816
|
-
const
|
|
1825
|
+
for (let l = 0; l < i.length; l++)
|
|
1826
|
+
i[l].placement === "PAGE_BACKGROUND_WORKER_ALL" && (d = !0);
|
|
1827
|
+
if (d && ((A = this.userInfo) != null && A.ID)) {
|
|
1828
|
+
const l = this.userInfo.ID, N = `${a}?USER_ID=${l}/`;
|
|
1817
1829
|
if (!this.placeData.find(
|
|
1818
|
-
(
|
|
1830
|
+
(p) => p.placement === "PAGE_BACKGROUND_WORKER" && p.handler === N
|
|
1819
1831
|
)) {
|
|
1820
|
-
const
|
|
1832
|
+
const p = {
|
|
1821
1833
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
1822
|
-
HANDLER:
|
|
1834
|
+
HANDLER: N,
|
|
1823
1835
|
LANG_ALL: {
|
|
1824
1836
|
ru: {
|
|
1825
|
-
TITLE:
|
|
1837
|
+
TITLE: h
|
|
1826
1838
|
}
|
|
1827
1839
|
},
|
|
1828
1840
|
OPTIONS: {
|
|
1829
|
-
errorHandlerUrl:
|
|
1841
|
+
errorHandlerUrl: N
|
|
1830
1842
|
},
|
|
1831
|
-
USER_ID:
|
|
1843
|
+
USER_ID: l
|
|
1832
1844
|
};
|
|
1833
|
-
|
|
1845
|
+
c[`bind_user_${l}`] = {
|
|
1834
1846
|
method: "placement.bind",
|
|
1835
|
-
params:
|
|
1836
|
-
}, console.log(`placementBind: Добавлено индивидуальное размещение для пользователя ${
|
|
1847
|
+
params: p
|
|
1848
|
+
}, console.log(`placementBind: Добавлено индивидуальное размещение для пользователя ${l} перед общим`);
|
|
1837
1849
|
}
|
|
1838
1850
|
}
|
|
1839
|
-
for (let
|
|
1840
|
-
const
|
|
1841
|
-
let
|
|
1842
|
-
if (
|
|
1843
|
-
if (!
|
|
1844
|
-
console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${
|
|
1851
|
+
for (let l = 0; l < i.length; l++) {
|
|
1852
|
+
const N = i[l], O = N.placement, p = N.userId;
|
|
1853
|
+
let b = a, U = O;
|
|
1854
|
+
if (O === "PAGE_BACKGROUND_WORKER") {
|
|
1855
|
+
if (!p) {
|
|
1856
|
+
console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${O}`);
|
|
1845
1857
|
continue;
|
|
1846
1858
|
}
|
|
1847
|
-
|
|
1859
|
+
b = `${a}?USER_ID=${p}/`;
|
|
1848
1860
|
}
|
|
1849
|
-
if (
|
|
1850
|
-
(k) => k.placement === U && k.handler ===
|
|
1861
|
+
if (O === "PAGE_BACKGROUND_WORKER_ALL" && (U = "PAGE_BACKGROUND_WORKER"), this.placeData.find(
|
|
1862
|
+
(k) => k.placement === U && k.handler === b
|
|
1851
1863
|
))
|
|
1852
1864
|
continue;
|
|
1853
1865
|
let W = this.placeData.find(
|
|
1854
|
-
(k) => k.placement === U && k.handler !==
|
|
1866
|
+
(k) => k.placement === U && k.handler !== b
|
|
1855
1867
|
);
|
|
1856
1868
|
W && s.push({ placement: U, handler: W.handler });
|
|
1857
|
-
const
|
|
1869
|
+
const L = {
|
|
1858
1870
|
PLACEMENT: U,
|
|
1859
|
-
HANDLER:
|
|
1871
|
+
HANDLER: b,
|
|
1860
1872
|
LANG_ALL: {
|
|
1861
1873
|
ru: {
|
|
1862
|
-
TITLE: U === "USER_PROFILE_TOOLBAR" ?
|
|
1874
|
+
TITLE: U === "USER_PROFILE_TOOLBAR" ? u : h
|
|
1863
1875
|
}
|
|
1864
1876
|
},
|
|
1865
1877
|
OPTIONS: {
|
|
1866
|
-
errorHandlerUrl:
|
|
1878
|
+
errorHandlerUrl: b
|
|
1867
1879
|
}
|
|
1868
1880
|
};
|
|
1869
|
-
|
|
1881
|
+
O === "PAGE_BACKGROUND_WORKER" && p && (L.USER_ID = p), c[`bind_${l}`] = {
|
|
1870
1882
|
method: "placement.bind",
|
|
1871
|
-
params:
|
|
1883
|
+
params: L
|
|
1872
1884
|
};
|
|
1873
1885
|
}
|
|
1874
|
-
s.length > 0 && await this.placementUnBind(s), Object.keys(
|
|
1875
|
-
console.log("Приложение успешно встроено в",
|
|
1886
|
+
s.length > 0 && await this.placementUnBind(s), Object.keys(c).length > 0 && await this.batch(c), Object.keys(c).length > 0 && (this.placeData = await this.getPlacement(), Object.values(c).forEach((l) => {
|
|
1887
|
+
console.log("Приложение успешно встроено в", l.params.PLACEMENT);
|
|
1876
1888
|
}));
|
|
1877
1889
|
}
|
|
1878
1890
|
/* Отвязка встройки из place */
|
|
@@ -1881,12 +1893,12 @@ class Lt {
|
|
|
1881
1893
|
Array.isArray(e) ? r = e.map((o) => typeof o == "string" ? { placement: o } : o) : typeof e == "string" ? r = [{ placement: e }] : r = [e];
|
|
1882
1894
|
const i = {};
|
|
1883
1895
|
for (let o = 0; o < r.length; o++) {
|
|
1884
|
-
const a = r[o],
|
|
1885
|
-
PLACEMENT:
|
|
1896
|
+
const a = r[o], h = a.placement, u = a.handler, c = {
|
|
1897
|
+
PLACEMENT: h
|
|
1886
1898
|
};
|
|
1887
|
-
|
|
1899
|
+
u && (c.HANDLER = u), i[`unbind_${o}`] = {
|
|
1888
1900
|
method: "placement.unbind",
|
|
1889
|
-
params:
|
|
1901
|
+
params: c
|
|
1890
1902
|
};
|
|
1891
1903
|
}
|
|
1892
1904
|
Object.keys(i).length > 0 && (await this.batch(i), r.forEach((o) => {
|
|
@@ -1901,8 +1913,8 @@ class Lt {
|
|
|
1901
1913
|
for (const o of this.placeData) {
|
|
1902
1914
|
if (!o.handler || o.handler.includes(e))
|
|
1903
1915
|
continue;
|
|
1904
|
-
const { placement: a, handler:
|
|
1905
|
-
r.push({ placement: a, handler:
|
|
1916
|
+
const { placement: a, handler: h, userId: u } = o;
|
|
1917
|
+
r.push({ placement: a, handler: h }), i.push({ placement: a, userId: u });
|
|
1906
1918
|
}
|
|
1907
1919
|
r.length > 0 && await this.placementUnBind(r), i.length > 0 && await this.placementBind(i, !1);
|
|
1908
1920
|
}
|
|
@@ -1919,7 +1931,7 @@ class Lt {
|
|
|
1919
1931
|
}
|
|
1920
1932
|
/* регистрация бота */
|
|
1921
1933
|
regBot({ code: e, type: r, name: i }) {
|
|
1922
|
-
const { appName: o, pathApp: a, chatBotLogo:
|
|
1934
|
+
const { appName: o, pathApp: a, chatBotLogo: h } = this.appConst, u = this.appInfo.ID;
|
|
1923
1935
|
return this.call({
|
|
1924
1936
|
method: "imbot.register",
|
|
1925
1937
|
params: {
|
|
@@ -1935,7 +1947,7 @@ class Lt {
|
|
|
1935
1947
|
// строковый идентификатор чат-бота, используется только в режиме Вебхуков
|
|
1936
1948
|
PROPERTIES: {
|
|
1937
1949
|
// Личные данные чат-бота (обяз.)
|
|
1938
|
-
NAME: `${i ?? o} - бот #${
|
|
1950
|
+
NAME: `${i ?? o} - бот #${u}`,
|
|
1939
1951
|
// Имя чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
1940
1952
|
LAST_NAME: "",
|
|
1941
1953
|
// Фамилия чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
@@ -1943,7 +1955,7 @@ class Lt {
|
|
|
1943
1955
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
1944
1956
|
EMAIL: "",
|
|
1945
1957
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
1946
|
-
PERSONAL_BIRTHDAY:
|
|
1958
|
+
PERSONAL_BIRTHDAY: rt().format("%Y-%m-%d"),
|
|
1947
1959
|
// День рождения в формате YYYY-mm-dd
|
|
1948
1960
|
WORK_POSITION: "Почтальон",
|
|
1949
1961
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -1951,11 +1963,11 @@ class Lt {
|
|
|
1951
1963
|
// Ссылка на сайт
|
|
1952
1964
|
PERSONAL_GENDER: "M",
|
|
1953
1965
|
// Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
|
|
1954
|
-
PERSONAL_PHOTO:
|
|
1966
|
+
PERSONAL_PHOTO: h ?? ""
|
|
1955
1967
|
// Аватар чат-бота - base64
|
|
1956
1968
|
}
|
|
1957
1969
|
}
|
|
1958
|
-
}).then((
|
|
1970
|
+
}).then((c) => (console.log("Чат-бот добавлен", c), c));
|
|
1959
1971
|
}
|
|
1960
1972
|
/* Убрать регистрацию бота */
|
|
1961
1973
|
unRegBot(e) {
|
|
@@ -1971,12 +1983,42 @@ class Lt {
|
|
|
1971
1983
|
return this.logger.getEntityList(e);
|
|
1972
1984
|
}
|
|
1973
1985
|
}
|
|
1974
|
-
|
|
1986
|
+
at = new WeakSet(), pt = function() {
|
|
1975
1987
|
return this.call({ method: "app.info" });
|
|
1976
|
-
},
|
|
1988
|
+
}, At = new WeakSet(), _t = function() {
|
|
1977
1989
|
return this.call({ method: "user.current" });
|
|
1990
|
+
}, tt = new WeakSet(), ft = function(e, r, i, o) {
|
|
1991
|
+
let a = { ...e.errors };
|
|
1992
|
+
if (Object.values(e.errors).some(
|
|
1993
|
+
(u) => {
|
|
1994
|
+
if (typeof u != "string")
|
|
1995
|
+
return !1;
|
|
1996
|
+
const c = u.toUpperCase();
|
|
1997
|
+
return c === "TIMEOUT" || c === "OPERATION_TIME_LIMIT" || c.includes("TIMEOUT") || c.includes("OPERATION_TIME_LIMIT");
|
|
1998
|
+
}
|
|
1999
|
+
) && o) {
|
|
2000
|
+
const u = r ? Object.keys(r).filter((g) => g !== "errorsList") : [], c = new Set(Object.keys(e.errors || {})), s = /* @__PURE__ */ new Set();
|
|
2001
|
+
if (r) {
|
|
2002
|
+
for (const g of u)
|
|
2003
|
+
if (!c.has(g)) {
|
|
2004
|
+
const A = r[g];
|
|
2005
|
+
A != null && s.add(g);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
const d = Object.values(e.errors).find(
|
|
2009
|
+
(g) => {
|
|
2010
|
+
if (typeof g != "string")
|
|
2011
|
+
return !1;
|
|
2012
|
+
const A = g.toUpperCase();
|
|
2013
|
+
return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
|
|
2014
|
+
}
|
|
2015
|
+
);
|
|
2016
|
+
for (const g of Object.keys(i))
|
|
2017
|
+
!s.has(g) && !e.errors[g] && (a[g] = d || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2018
|
+
}
|
|
2019
|
+
return a;
|
|
1978
2020
|
};
|
|
1979
|
-
class
|
|
2021
|
+
class Dt {
|
|
1980
2022
|
constructor(e) {
|
|
1981
2023
|
M(this, "entityName", "tabs");
|
|
1982
2024
|
M(this, "maxTabs", 5);
|
|
@@ -2101,37 +2143,27 @@ class St {
|
|
|
2101
2143
|
return Math.round(Math.random()) ? e : -e;
|
|
2102
2144
|
}
|
|
2103
2145
|
async checkPlacementType() {
|
|
2104
|
-
var e
|
|
2146
|
+
var e;
|
|
2105
2147
|
try {
|
|
2106
|
-
const
|
|
2107
|
-
if (!
|
|
2148
|
+
const r = await this.bx.getPlacement();
|
|
2149
|
+
if (!r || !Array.isArray(r))
|
|
2108
2150
|
return console.log("BackgroundWorker: Не удалось получить список размещений, продолжаем выполнение"), !0;
|
|
2109
|
-
const
|
|
2110
|
-
if (!
|
|
2151
|
+
const i = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2152
|
+
if (!i)
|
|
2111
2153
|
return console.log("BackgroundWorker: Не удалось определить ID текущего пользователя, продолжаем выполнение"), !0;
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
N && +N === c && (l = !0), h && A.handler && h === A.handler && (d = !0);
|
|
2126
|
-
} else
|
|
2127
|
-
s = !0, h && A.handler && h === A.handler && (p = !0);
|
|
2128
|
-
if (!d && !p && h && (d = h.includes("USER_ID="), p = !d, d)) {
|
|
2129
|
-
const A = this.extractUserIdFromHandler(h);
|
|
2130
|
-
A && +A === c && (l = !0);
|
|
2131
|
-
}
|
|
2132
|
-
return d ? (console.log("BackgroundWorker: Обнаружена индивидуальная встройка, продолжаем выполнение"), !0) : p && l ? (console.log(`BackgroundWorker: Обнаружена общая встройка при наличии индивидуальной для текущего пользователя (ID: ${c}), прекращаем выполнение`), !1) : (console.log("BackgroundWorker: Проверка типа встройки пройдена, продолжаем выполнение"), !0);
|
|
2133
|
-
} catch (a) {
|
|
2134
|
-
return console.error("BackgroundWorker: Ошибка при проверке типа встройки", a), !0;
|
|
2154
|
+
const a = !!(typeof window < "u" ? window.location.href : "").includes("USER_ID=");
|
|
2155
|
+
let h = !1;
|
|
2156
|
+
for (const u of r)
|
|
2157
|
+
if (u.placement === "PAGE_BACKGROUND_WORKER" && (u.userId || u.handler && u.handler.includes("USER_ID="))) {
|
|
2158
|
+
const s = u.userId || (u.handler ? this.extractUserIdFromHandler(u.handler) : null);
|
|
2159
|
+
if (s && +s === i) {
|
|
2160
|
+
h = !0;
|
|
2161
|
+
break;
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
return a ? (console.log("BackgroundWorker: Обнаружена индивидуальная встройка, продолжаем выполнение"), !0) : !currentPlacementIsGeneral && h ? (console.log(`BackgroundWorker: Обнаружена общая встройка при наличии индивидуальной для текущего пользователя (ID: ${i}), прекращаем выполнение`), !1) : (console.log("BackgroundWorker: Проверка типа встройки пройдена, продолжаем выполнение"), !0);
|
|
2165
|
+
} catch (r) {
|
|
2166
|
+
return console.error("BackgroundWorker: Ошибка при проверке типа встройки", r), !0;
|
|
2135
2167
|
}
|
|
2136
2168
|
}
|
|
2137
2169
|
extractUserIdFromHandler(e) {
|
|
@@ -2174,14 +2206,14 @@ class St {
|
|
|
2174
2206
|
checkOtherTabs() {
|
|
2175
2207
|
var o, a;
|
|
2176
2208
|
let e = !1, r = (/* @__PURE__ */ new Date()).getTime() - new Date(this.start).getTime();
|
|
2177
|
-
for (const
|
|
2178
|
-
if (+
|
|
2209
|
+
for (const h of this.tabList)
|
|
2210
|
+
if (+h.id !== this.id && ((o = h.data) != null && o.start && (e = !0), ((a = h.data) == null ? void 0 : a.duration) > r)) {
|
|
2179
2211
|
r = !1;
|
|
2180
2212
|
break;
|
|
2181
2213
|
}
|
|
2182
2214
|
const i = !e && !!r;
|
|
2183
|
-
return this.updateTab(i).catch((
|
|
2184
|
-
console.error("BackgroundWorker: updateTab failed",
|
|
2215
|
+
return this.updateTab(i).catch((h) => {
|
|
2216
|
+
console.error("BackgroundWorker: updateTab failed", h);
|
|
2185
2217
|
}), console.log(`BackgroundWorker: Проверка вкладок - можно запускать приложение? ${i}`), i;
|
|
2186
2218
|
}
|
|
2187
2219
|
async startBackground() {
|
|
@@ -2192,60 +2224,60 @@ class St {
|
|
|
2192
2224
|
}, this.activeMinPause), await this.appInit(), this.interval && (clearInterval(this.interval), this.interval = void 0), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
2193
2225
|
}
|
|
2194
2226
|
async setBackgroundWorkerAll() {
|
|
2195
|
-
var
|
|
2196
|
-
if (!((
|
|
2227
|
+
var A, l;
|
|
2228
|
+
if (!((A = this.bx) != null && A.isAdmin)) {
|
|
2197
2229
|
console.log("BackgroundWorker: Отмена setBackgroundWorkerAll - пользователь не админ");
|
|
2198
2230
|
return;
|
|
2199
2231
|
}
|
|
2200
|
-
(
|
|
2232
|
+
(l = this.users) != null && l.length || await this.getEntityData();
|
|
2201
2233
|
const e = await this.bx.getPlacement(), r = /* @__PURE__ */ new Map();
|
|
2202
2234
|
let i = null;
|
|
2203
|
-
e.forEach((
|
|
2204
|
-
|
|
2235
|
+
e.forEach((N) => {
|
|
2236
|
+
N.placement === "PAGE_BACKGROUND_WORKER" && (N.userId ? r.set(+N.userId, N) : i = N);
|
|
2205
2237
|
}), console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i ? 1 : 0} общих привязок PAGE_BACKGROUND_WORKER`);
|
|
2206
2238
|
const o = await this.updateAdminsList(), a = await this.getEligibleUsersForBackgroundWorker(o);
|
|
2207
|
-
a.sort((
|
|
2208
|
-
const
|
|
2209
|
-
return (
|
|
2239
|
+
a.sort((N, O) => {
|
|
2240
|
+
const p = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2241
|
+
return (O.LAST_LOGIN ? new Date(O.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - p;
|
|
2210
2242
|
}), console.log(`setBackgroundWorkerAll: Найдено ${a.length} подходящих пользователей (админы и руководители)`);
|
|
2211
|
-
const
|
|
2212
|
-
(
|
|
2213
|
-
), d = i && s.length > 0,
|
|
2214
|
-
for (const [
|
|
2215
|
-
a.find((
|
|
2216
|
-
for (const
|
|
2217
|
-
this.appPath && (
|
|
2243
|
+
const h = [], u = 10, s = a.slice(0, u).filter(
|
|
2244
|
+
(N) => !r.has(+N.ID)
|
|
2245
|
+
), d = i && s.length > 0, g = [];
|
|
2246
|
+
for (const [N] of r)
|
|
2247
|
+
a.find((p) => +p.ID === N) || g.push(N);
|
|
2248
|
+
for (const N of g)
|
|
2249
|
+
this.appPath && (h.push({
|
|
2218
2250
|
method: "placement.unbind",
|
|
2219
2251
|
params: {
|
|
2220
2252
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2221
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2253
|
+
HANDLER: `${this.appPath}?USER_ID=${N}/`
|
|
2222
2254
|
}
|
|
2223
|
-
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${
|
|
2224
|
-
d && this.appPath && (
|
|
2255
|
+
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${N}`));
|
|
2256
|
+
d && this.appPath && (h.push({
|
|
2225
2257
|
method: "placement.unbind",
|
|
2226
2258
|
params: {
|
|
2227
2259
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2228
2260
|
HANDLER: i.handler || `${this.appPath}/`
|
|
2229
2261
|
}
|
|
2230
2262
|
}), console.log("setBackgroundWorkerAll: Добавлена в очередь отвязка общего бэк-воркера (для создания индивидуальных)"));
|
|
2231
|
-
for (const
|
|
2232
|
-
this.appPath &&
|
|
2263
|
+
for (const N of s)
|
|
2264
|
+
this.appPath && h.push({
|
|
2233
2265
|
method: "placement.bind",
|
|
2234
2266
|
params: {
|
|
2235
2267
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2236
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2268
|
+
HANDLER: `${this.appPath}?USER_ID=${N.ID}/`,
|
|
2237
2269
|
LANG_ALL: {
|
|
2238
2270
|
ru: {
|
|
2239
2271
|
TITLE: this.appName
|
|
2240
2272
|
}
|
|
2241
2273
|
},
|
|
2242
2274
|
OPTIONS: {
|
|
2243
|
-
errorHandlerUrl: `${this.appPath}?USER_ID=${
|
|
2275
|
+
errorHandlerUrl: `${this.appPath}?USER_ID=${N.ID}/`
|
|
2244
2276
|
},
|
|
2245
|
-
USER_ID:
|
|
2277
|
+
USER_ID: N.ID
|
|
2246
2278
|
}
|
|
2247
2279
|
});
|
|
2248
|
-
(!i || d) && this.appPath && (
|
|
2280
|
+
(!i || d) && this.appPath && (h.push({
|
|
2249
2281
|
method: "placement.bind",
|
|
2250
2282
|
params: {
|
|
2251
2283
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -2259,7 +2291,7 @@ class St {
|
|
|
2259
2291
|
errorHandlerUrl: `${this.appPath}/`
|
|
2260
2292
|
}
|
|
2261
2293
|
}
|
|
2262
|
-
}), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера (после индивидуальных)")),
|
|
2294
|
+
}), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера (после индивидуальных)")), h.length ? (console.log(`setBackgroundWorkerAll: Выполняем ${h.length} операций через batch`), await this.bx.batch(h), console.log("setBackgroundWorkerAll: Все операции batch выполнены успешно")) : console.log("setBackgroundWorkerAll: Нет операций для выполнения");
|
|
2263
2295
|
}
|
|
2264
2296
|
async getEligibleUsersForBackgroundWorker(e = []) {
|
|
2265
2297
|
return (this.users ?? []).filter((i) => i.ACTIVE === "Y" || i.ACTIVE === !0).filter((i) => {
|
|
@@ -2272,11 +2304,11 @@ class St {
|
|
|
2272
2304
|
try {
|
|
2273
2305
|
let o = await this.getAdminsList();
|
|
2274
2306
|
const a = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2275
|
-
(r = this.bx) != null && r.isAdmin && a && !o.includes(a) && (o.push(a), console.log(`updateAdminsList: Добавлен новый админ ${a}`)), !((i = this.bx) != null && i.isAdmin) && a && o.includes(a) && (o = o.filter((
|
|
2276
|
-
const
|
|
2277
|
-
(this.users ?? []).filter((
|
|
2278
|
-
),
|
|
2279
|
-
return
|
|
2307
|
+
(r = this.bx) != null && r.isAdmin && a && !o.includes(a) && (o.push(a), console.log(`updateAdminsList: Добавлен новый админ ${a}`)), !((i = this.bx) != null && i.isAdmin) && a && o.includes(a) && (o = o.filter((c) => c !== a), console.log(`updateAdminsList: Удален из списка админов пользователь ${a} (больше не админ)`));
|
|
2308
|
+
const h = new Set(
|
|
2309
|
+
(this.users ?? []).filter((c) => c.ACTIVE === "Y" || c.ACTIVE === !0).map((c) => +c.ID)
|
|
2310
|
+
), u = o.filter((c) => h.has(c));
|
|
2311
|
+
return u.length !== o.length && (console.log(`updateAdminsList: Удалено ${o.length - u.length} неактивных админов`), o = u), BX24.appOption.set("adminsList", JSON.stringify(o)), console.log(`BackgroundWorker: Список админов обновлен: ${o.length} админов`), o;
|
|
2280
2312
|
} catch (o) {
|
|
2281
2313
|
return console.error("BackgroundWorker: Ошибка при обновлении списка админов:", o), [];
|
|
2282
2314
|
}
|
|
@@ -2304,10 +2336,10 @@ class St {
|
|
|
2304
2336
|
}
|
|
2305
2337
|
}
|
|
2306
2338
|
export {
|
|
2307
|
-
|
|
2339
|
+
Dt as BackgroundWorker,
|
|
2308
2340
|
v as Batch,
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2341
|
+
St as BxBoot,
|
|
2342
|
+
mt as BxHelper,
|
|
2343
|
+
bt as BxLogger,
|
|
2344
|
+
rt as tempus
|
|
2313
2345
|
};
|