szdl-utils-kit 0.3.28 → 0.3.30
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/Readme.md +1 -1
- package/dist/index.js +459 -472
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var ke = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var Ce = (d, e, t) => e in d ? ke(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var D = (d, e, t) => (Ce(d, typeof e != "symbol" ? e + "" : e, t), t), Qt = (d, e, t) => {
|
|
4
4
|
if (!e.has(d))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var L = (d, e, t) => (Qt(d, e, "read from private field"), t ? t.call(d) : e.get(d)), E = (d, e, t) => {
|
|
8
8
|
if (e.has(d))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
e instanceof WeakSet ? e.add(d) : e.set(d, t);
|
|
11
11
|
}, x = (d, e, t, r) => (Qt(d, e, "write to private field"), r ? r.call(d, t) : e.set(d, t), t);
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var N = (d, e, t) => (Qt(d, e, "access private method"), t);
|
|
13
|
+
var we = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
14
|
function Be(d) {
|
|
15
15
|
return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
|
|
16
16
|
}
|
|
@@ -18,37 +18,37 @@ var $t = { exports: {} };
|
|
|
18
18
|
(function(d, e) {
|
|
19
19
|
(function(t) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
21
|
+
var g, p;
|
|
22
|
+
for (g = o || 0, p = this.length; g < p; g += 1)
|
|
23
|
+
if (this[g] === s)
|
|
24
|
+
return g;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
27
|
var r = this, i = function(s, o) {
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
28
|
+
for (var g = s.toString(); g.length < o; )
|
|
29
|
+
g = "0" + g;
|
|
30
|
+
return g;
|
|
31
31
|
}, a = function(s, o) {
|
|
32
32
|
return o !== t ? (s.year(o.year() || o.year), s.month(o.month() || o.month), s.day(o.day() || o.day), s.hours(o.hours() || o.hours), s.minutes(o.minutes() || o.minutes), s.seconds(o.seconds() || o.seconds), s.milliseconds(o.milliseconds() || o.milliseconds), s) : t;
|
|
33
33
|
}, l = function(s, o) {
|
|
34
|
-
var
|
|
35
|
-
return
|
|
34
|
+
var g, p = "";
|
|
35
|
+
return g = s.slice(o, o + 1), g !== "" && !isNaN(Number(g)) && (p += "%H"), g = s.charAt(o + 2), g !== "" && g === ":" && (p += g), g = s.slice(o + 3, o + 4), g !== "" && !isNaN(Number(g)) && (p += "%M"), g = s.charAt(o + 5), g !== "" && g === ":" && (p += g), g = s.slice(o + 6, o + 7), g !== "" && !isNaN(Number(g)) && (p += "%S"), p;
|
|
36
36
|
}, h = function(s, o) {
|
|
37
|
-
var
|
|
37
|
+
var g, p = [
|
|
38
38
|
s.slice(o, o + 1),
|
|
39
39
|
s.charAt(o + 2),
|
|
40
40
|
s.slice(o + 3, o + 4),
|
|
41
41
|
s.charAt(o + 5),
|
|
42
42
|
s.slice(o + 6, o + 9)
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(
|
|
43
|
+
], U;
|
|
44
|
+
return !isNaN(Number(p[0])) && !isNaN(Number(p[2])) && !isNaN(Number(p[4])) ? (p[1] === "." && p[3] === "." ? g = "%d.%m.%Y" : p[1] === "-" && p[3] === "-" ? g = "%m-%d-%Y" : p[1] === "/" && p[3] === "/" && (g = "%m/%d/%Y"), g) : (U = [
|
|
45
45
|
s.slice(o, o + 3),
|
|
46
46
|
s.charAt(o + 4),
|
|
47
47
|
s.slice(o + 5, o + 6),
|
|
48
48
|
s.charAt(o + 7),
|
|
49
49
|
s.slice(o + 8, o + 9)
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
}, u = r.tempus, n,
|
|
50
|
+
], !isNaN(Number(U[0])) && !isNaN(Number(U[2])) && !isNaN(Number(U[4])) ? (U[1] === "-" && U[3] === "-" && (g = "%Y-%m-%d"), g) : "");
|
|
51
|
+
}, u = r.tempus, n, m, f = r.navigator || {}, A = "en", c = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,7 +209,7 @@ var $t = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, O = function() {
|
|
213
213
|
return [
|
|
214
214
|
c[A].JANUARY_LONG,
|
|
215
215
|
c[A].FEBRUARY_LONG,
|
|
@@ -249,7 +249,7 @@ var $t = { exports: {} };
|
|
|
249
249
|
c[A].FRIDAY_LONG,
|
|
250
250
|
c[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, I = function() {
|
|
253
253
|
return [
|
|
254
254
|
c[A].SUNDAY_SHORT,
|
|
255
255
|
c[A].MONDAY_SHORT,
|
|
@@ -259,13 +259,13 @@ var $t = { exports: {} };
|
|
|
259
259
|
c[A].FRIDAY_SHORT,
|
|
260
260
|
c[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
}, T,
|
|
263
|
-
var
|
|
264
|
-
r.XMLHttpRequest ?
|
|
265
|
-
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(
|
|
267
|
-
},
|
|
268
|
-
},
|
|
262
|
+
}, T, y, k, b, H = function(s, o, g) {
|
|
263
|
+
var p;
|
|
264
|
+
r.XMLHttpRequest ? p = new XMLHttpRequest() : p = new ActiveXObject("Microsoft.XMLHTTP"), p.onreadystatechange = function() {
|
|
265
|
+
p.readyState === 4 && (p.status === 200 ? o && (r.JSON === t ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(p.responseText))) : g && g(p));
|
|
267
|
+
}, p.open("GET", s, !1), p.send();
|
|
268
|
+
}, w = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(s) {
|
|
271
271
|
return i(s.day() || n.MIN_DAY, 2);
|
|
@@ -316,7 +316,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
316
316
|
"%a": {
|
|
317
317
|
format: function(s) {
|
|
318
318
|
var o = s.dayOfWeek();
|
|
319
|
-
return
|
|
319
|
+
return b[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
return {};
|
|
@@ -328,7 +328,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
328
328
|
"%A": {
|
|
329
329
|
format: function(s) {
|
|
330
330
|
var o = s.dayOfWeek();
|
|
331
|
-
return
|
|
331
|
+
return k[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
334
334
|
return {};
|
|
@@ -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 y[o !== t ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(s) {
|
|
346
346
|
var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
@@ -415,11 +415,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
415
415
|
return i(s.year() || n.MIN_YEAR, 4) + "-" + i(s.month() || n.MIN_MONTH, 2) + "-" + i(s.day() || n.MIN_DAY, 2);
|
|
416
416
|
},
|
|
417
417
|
parse: function(s) {
|
|
418
|
-
var o = Number(s.slice(0, 4)),
|
|
418
|
+
var o = Number(s.slice(0, 4)), g = Number(s.slice(5, 7)), p = Number(s.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: o,
|
|
421
|
-
month:
|
|
422
|
-
day:
|
|
421
|
+
month: g,
|
|
422
|
+
day: p
|
|
423
423
|
};
|
|
424
424
|
},
|
|
425
425
|
minLength: 10,
|
|
@@ -431,11 +431,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
431
431
|
return i(s.month() || n.MIN_MONTH, 2) + "/" + i(s.day() || n.MIN_DAY, 2) + "/" + i(s.year() || n.MIN_YEAR, 4);
|
|
432
432
|
},
|
|
433
433
|
parse: function(s) {
|
|
434
|
-
var o = Number(s.slice(0, 2)),
|
|
434
|
+
var o = Number(s.slice(0, 2)), g = Number(s.slice(3, 5)), p = Number(s.slice(6, 10));
|
|
435
435
|
return {
|
|
436
|
-
year:
|
|
436
|
+
year: p,
|
|
437
437
|
month: o,
|
|
438
|
-
day:
|
|
438
|
+
day: g
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
@@ -446,7 +446,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
448
|
}, M;
|
|
449
|
-
M = function(s, o,
|
|
449
|
+
M = function(s, o, g) {
|
|
450
450
|
return this._d = /* @__PURE__ */ new Date(), this._i = {
|
|
451
451
|
year: !1,
|
|
452
452
|
month: !1,
|
|
@@ -455,7 +455,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
455
455
|
minutes: !1,
|
|
456
456
|
seconds: !1,
|
|
457
457
|
milliseconds: !1
|
|
458
|
-
}, s !== t && this.set(s, o,
|
|
458
|
+
}, s !== t && this.set(s, o, g), this;
|
|
459
459
|
}, M.fn = M.prototype, M.fn.dayCount = function() {
|
|
460
460
|
var s = this.month(), o = n.MAX_DAY_IN_MONTHS[s - (n.options("monthFromZero") ? 0 : 1)];
|
|
461
461
|
return this.leapYear() && s === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
|
|
@@ -504,7 +504,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
504
504
|
}, M.fn.week = function() {
|
|
505
505
|
var s = new Date(this.year(), 0, 1), o = n(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
|
|
506
506
|
return Math.ceil(((o - s.getTime()) / 864e5 + s.getDay() + 1) / 7);
|
|
507
|
-
}, M.fn.set = function(s, o,
|
|
507
|
+
}, M.fn.set = function(s, o, g) {
|
|
508
508
|
if (this._i = {
|
|
509
509
|
year: !1,
|
|
510
510
|
month: !1,
|
|
@@ -520,9 +520,9 @@ 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
|
|
523
|
+
var p, U = [], S, C, Z = [], W = 0, F = 0, P, X, G = {}, Y;
|
|
524
524
|
if (s === t)
|
|
525
|
-
return
|
|
525
|
+
return S = a(this, g), S === t && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -530,26 +530,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
530
530
|
minutes: -1,
|
|
531
531
|
seconds: -1,
|
|
532
532
|
milliseconds: -1
|
|
533
|
-
}),
|
|
533
|
+
}), S;
|
|
534
534
|
for (o === t && (o = n.detectFormat(s)); W < o.length; ) {
|
|
535
535
|
if (o.charAt(W) === "%") {
|
|
536
|
-
if (C = o.charAt(W) + o.charAt(W + 1),
|
|
537
|
-
switch (
|
|
536
|
+
if (C = o.charAt(W) + o.charAt(W + 1), w[C] !== t) {
|
|
537
|
+
switch (P = 0, X = "", w[C].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (;
|
|
540
|
-
X += s.charAt(F +
|
|
539
|
+
for (; P < w[C].maxLength && F + P < s.length && !isNaN(Number(s.charAt(F + P))); )
|
|
540
|
+
X += s.charAt(F + P), P += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (;
|
|
544
|
-
X += s.charAt(F +
|
|
543
|
+
for (; P < w[C].maxLength && F + P < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + P)); )
|
|
544
|
+
X += s.charAt(F + P), P += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (;
|
|
548
|
-
X += s.charAt(F +
|
|
547
|
+
for (; P < w[C].maxLength && F + P < s.length; )
|
|
548
|
+
X += s.charAt(F + P), P += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (
|
|
552
|
-
return
|
|
551
|
+
if (P < w[C].minLength)
|
|
552
|
+
return S = a(this, g), S === t && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
555
555
|
day: -1,
|
|
@@ -557,11 +557,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
557
557
|
minutes: -1,
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
|
-
}),
|
|
561
|
-
|
|
560
|
+
}), S;
|
|
561
|
+
U.push(C), Z.push(X), P -= 1, F += P, W += 1;
|
|
562
562
|
}
|
|
563
563
|
} else if (s.charAt(F) !== o.charAt(W))
|
|
564
|
-
return
|
|
564
|
+
return S = a(this, g), S === t && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -569,19 +569,19 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
569
569
|
minutes: -1,
|
|
570
570
|
seconds: -1,
|
|
571
571
|
milliseconds: -1
|
|
572
|
-
}),
|
|
572
|
+
}), S;
|
|
573
573
|
W += 1, F += 1;
|
|
574
574
|
}
|
|
575
|
-
for (
|
|
576
|
-
|
|
577
|
-
year: Y.year !== t ? Y.year :
|
|
578
|
-
month: Y.month !== t ? Y.month :
|
|
579
|
-
day: Y.day !== t ? Y.day :
|
|
580
|
-
hours: Y.hours !== t ? Y.hours :
|
|
581
|
-
minutes: Y.minutes !== t ? Y.minutes :
|
|
582
|
-
seconds: Y.seconds !== t ? Y.seconds :
|
|
575
|
+
for (p in U)
|
|
576
|
+
U.hasOwnProperty(p) && w.hasOwnProperty(U[p]) && (Y = w[U[p]].parse(Z[p]), G = {
|
|
577
|
+
year: Y.year !== t ? Y.year : G.year,
|
|
578
|
+
month: Y.month !== t ? Y.month : G.month,
|
|
579
|
+
day: Y.day !== t ? Y.day : G.day,
|
|
580
|
+
hours: Y.hours !== t ? Y.hours : G.hours,
|
|
581
|
+
minutes: Y.minutes !== t ? Y.minutes : G.minutes,
|
|
582
|
+
seconds: Y.seconds !== t ? Y.seconds : G.seconds
|
|
583
583
|
});
|
|
584
|
-
this.day(n.MIN_DAY), this.year(
|
|
584
|
+
this.day(n.MIN_DAY), this.year(G.year), this.month(G.month), this.day(G.day), this.hours(G.hours), this.minutes(G.minutes), this.seconds(G.seconds), this.milliseconds(G.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
587
|
}, M.fn.leapYear = function() {
|
|
@@ -593,9 +593,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
593
593
|
return arguments.length !== 0 ? (this._d = new Date(Number(s) * (n.options("useMilliseconds") ? 1 : 1e3)), this) : n.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
|
|
594
594
|
}, M.fn.dayOfWeek = function(s) {
|
|
595
595
|
if (s === "long")
|
|
596
|
-
return
|
|
596
|
+
return k[this._d.getDay()];
|
|
597
597
|
if (s === "short")
|
|
598
|
-
return
|
|
598
|
+
return b[this._d.getDay()];
|
|
599
599
|
if (s === t)
|
|
600
600
|
return this._d.getDay();
|
|
601
601
|
if (s === 0 || s === "Sunday")
|
|
@@ -671,35 +671,35 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
673
|
}, M.fn.format = function(s) {
|
|
674
|
-
for (var o = 0,
|
|
675
|
-
s.charAt(o) === "%" ? (
|
|
676
|
-
return
|
|
674
|
+
for (var o = 0, g = "", p; o < s.length; )
|
|
675
|
+
s.charAt(o) === "%" ? (p = s.charAt(o) + s.charAt(o + 1), w[p] !== t ? (g += w[p].format(this), o += 1) : g += "%") : g += s.charAt(o), o += 1;
|
|
676
|
+
return g;
|
|
677
677
|
}, M.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;
|
|
679
679
|
}, M.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
681
|
}, M.fn.between = function(s, o) {
|
|
682
|
-
var
|
|
682
|
+
var g = this.timestamp(), p = s.timestamp();
|
|
683
683
|
switch (o) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((
|
|
685
|
+
return Math.floor((p - g) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((
|
|
687
|
+
return Math.floor((p - g) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((
|
|
689
|
+
return Math.floor((p - g) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((
|
|
691
|
+
return Math.floor((p - g) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((
|
|
693
|
+
return Math.floor((p - g) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return
|
|
695
|
+
return p - g;
|
|
696
696
|
default:
|
|
697
697
|
return t;
|
|
698
698
|
}
|
|
699
699
|
}, M.fn.calc = function(s) {
|
|
700
700
|
return s.year !== t && this._d.setFullYear(this._d.getFullYear() + s.year), s.month !== t && this._d.setMonth(this._d.getMonth() + s.month), s.day !== t && this._d.setDate(this._d.getDate() + s.day), s.hours !== t && this._d.setHours(this._d.getHours() + s.hours), s.minutes !== t && this._d.setMinutes(this._d.getMinutes() + s.minutes), s.seconds !== t && this._d.setSeconds(this._d.getSeconds() + s.seconds), s.milliseconds !== t && this._d.setMilliseconds(this._d.getMilliseconds() + s.milliseconds), this;
|
|
701
|
-
}, n = function(s, o,
|
|
702
|
-
return new M(s, o,
|
|
701
|
+
}, n = function(s, o, g) {
|
|
702
|
+
return new M(s, o, g);
|
|
703
703
|
}, n.MIN_YEAR = 1e3, n.MAX_YEAR = 3e3, n.MIN_MONTH = 1, n.MAX_MONTH = 12, n.MIN_DAY = 1, n.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], n.MIN_DAY_OF_WEEK = 0, n.MAX_DAY_OF_WEEK = 6, n.MIN_HOURS = 0, n.MAX_HOURS = 23, n.MIN_MINUTES = 0, n.MAX_MINUTES = 59, n.MIN_SECONDS = 0, n.MAX_SECONDS = 59, n.MIN_MILLISECONDS = 0, n.MAX_MILLISECONDS = 999, n.VERSION = "0.2.18", n.options = function(s, o) {
|
|
704
704
|
if (s === t)
|
|
705
705
|
return B;
|
|
@@ -712,106 +712,106 @@ 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,
|
|
716
|
-
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof M ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof M ?
|
|
715
|
+
var o, g, p, U, S, C, Z, W;
|
|
716
|
+
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof M ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof M ? g = s.dateTo.utc() : g = n(s.dateTo, s.formatTo !== t ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? S = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
719
719
|
day: 0,
|
|
720
720
|
hours: 0,
|
|
721
721
|
minutes: 0,
|
|
722
722
|
seconds: s.period
|
|
723
|
-
} : typeof s.period == "string" ?
|
|
723
|
+
} : typeof s.period == "string" ? S = {
|
|
724
724
|
year: s.period === "year" ? 1 : 0,
|
|
725
725
|
month: s.period === "month" ? 1 : 0,
|
|
726
726
|
day: s.period === "day" ? 1 : 0,
|
|
727
727
|
hours: s.period === "hours" ? 1 : 0,
|
|
728
728
|
minutes: s.period === "minutes" ? 1 : 0,
|
|
729
729
|
seconds: s.period === "seconds" ? 1 : 0
|
|
730
|
-
} : typeof s.period == "object" && (
|
|
730
|
+
} : typeof s.period == "object" && (S = {
|
|
731
731
|
year: s.period.year !== t ? s.period.year : 0,
|
|
732
732
|
month: s.period.month !== t ? s.period.month : 0,
|
|
733
733
|
day: s.period.day !== t ? s.period.day : 0,
|
|
734
734
|
hours: s.period.hours !== t ? s.period.hours : 0,
|
|
735
735
|
minutes: s.period.minutes !== t ? s.period.minutes : 0,
|
|
736
736
|
seconds: s.period.seconds !== t ? s.period.seconds : 0
|
|
737
|
-
}), s.groupBy === t ? C = s.asObject === !0 ? {} : [] : (C = [], C.push([]),
|
|
738
|
-
return s.asObject === !0 ? s.format !== t ? X[n(
|
|
737
|
+
}), s.groupBy === t ? C = s.asObject === !0 ? {} : [] : (C = [], C.push([]), Z = n(o).get()[s.groupBy]), W = function(X, G, Y) {
|
|
738
|
+
return s.asObject === !0 ? s.format !== t ? X[n(G).format(s.format)] = {} : X[n(G).format("%F %H:%M:%S")] = {} : s.format !== t ? X.push(Y ? null : n(G).format(s.format)) : X.push(Y ? null : n(G)), X;
|
|
739
739
|
}, s.groupBy !== t && s.fillNulls) {
|
|
740
740
|
var F = {
|
|
741
|
-
year:
|
|
742
|
-
month:
|
|
743
|
-
day:
|
|
744
|
-
hours:
|
|
745
|
-
minutes:
|
|
746
|
-
seconds:
|
|
747
|
-
milliseconds:
|
|
741
|
+
year: S.year ? -S.year : t,
|
|
742
|
+
month: S.month ? -S.month : t,
|
|
743
|
+
day: S.day ? -S.day : t,
|
|
744
|
+
hours: S.hours ? -S.hours : t,
|
|
745
|
+
minutes: S.minutes ? -S.minutes : t,
|
|
746
|
+
seconds: S.seconds ? -S.seconds : t,
|
|
747
|
+
milliseconds: S.milliseconds ? -S.milliseconds : t
|
|
748
748
|
};
|
|
749
|
-
for (
|
|
750
|
-
W(C[C.length - 1],
|
|
749
|
+
for (p = n(o).calc(F).utc(); n(p).get()[s.groupBy] === Z; )
|
|
750
|
+
W(C[C.length - 1], p, !0), p = n(p).calc(F).utc();
|
|
751
751
|
if (s.groupBy === "week") {
|
|
752
|
-
var
|
|
753
|
-
for (
|
|
754
|
-
W(C[C.length - 1],
|
|
752
|
+
var P = n(o).dayOfWeek();
|
|
753
|
+
for (p = n(o).dayOfWeek(0).utc(); C[0].length < P && p < o; )
|
|
754
|
+
W(C[C.length - 1], p, !0), p = n(p).calc(S).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; o <=
|
|
758
|
-
s.groupBy === t ? W(C, o) : n(o).get()[s.groupBy] ===
|
|
757
|
+
for (; o <= g; )
|
|
758
|
+
s.groupBy === t ? W(C, o) : n(o).get()[s.groupBy] === Z ? W(C[C.length - 1], o) : (C.push([]), W(C[C.length - 1], o), Z = n(o).get()[s.groupBy]), o = n(o).calc(S).utc();
|
|
759
759
|
if (s.groupBy !== t && s.fillNulls)
|
|
760
|
-
for (
|
|
761
|
-
W(C[C.length - 1],
|
|
760
|
+
for (U = n(g).calc(S).utc(); n(U).get()[s.groupBy] === Z; )
|
|
761
|
+
W(C[C.length - 1], U, !0), U = n(U).calc(S).utc();
|
|
762
762
|
return C;
|
|
763
763
|
}, n.monthNames = function(s) {
|
|
764
764
|
switch (s) {
|
|
765
765
|
case "long":
|
|
766
766
|
return T;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return y;
|
|
769
769
|
}
|
|
770
770
|
}, n.dayNames = function(s) {
|
|
771
771
|
switch (s) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return k;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return b;
|
|
776
776
|
}
|
|
777
777
|
}, n.lang = function(s) {
|
|
778
778
|
if (s !== t)
|
|
779
|
-
A = s, c[A] === t && (A = "en"), T =
|
|
779
|
+
A = s, c[A] === t && (A = "en"), T = O(), y = _(), k = R(), b = I();
|
|
780
780
|
else
|
|
781
781
|
return A;
|
|
782
782
|
return t;
|
|
783
783
|
}, n.availableLangs = function() {
|
|
784
784
|
return Object.keys(c);
|
|
785
|
-
}, n.registerFormat = function(s, o,
|
|
786
|
-
|
|
785
|
+
}, n.registerFormat = function(s, o, g, p, U, S) {
|
|
786
|
+
w[s] = {
|
|
787
787
|
format: o,
|
|
788
|
-
parse:
|
|
789
|
-
minLength:
|
|
790
|
-
maxLength:
|
|
791
|
-
type:
|
|
788
|
+
parse: g,
|
|
789
|
+
minLength: p,
|
|
790
|
+
maxLength: U,
|
|
791
|
+
type: S
|
|
792
792
|
};
|
|
793
793
|
}, n.unregisterFormat = function(s) {
|
|
794
|
-
delete
|
|
794
|
+
delete w[s];
|
|
795
795
|
}, n.detectFormat = function(s) {
|
|
796
|
-
var o,
|
|
797
|
-
return o = h(s, 0), o !== "" && (
|
|
798
|
-
},
|
|
796
|
+
var o, g, p;
|
|
797
|
+
return o = h(s, 0), o !== "" && (p = 10), g = s.charAt(p), (g === "T" || g === " ") && (o += g, p += 1), o += l(s, p), o;
|
|
798
|
+
}, m = {
|
|
799
799
|
TempusDate: M
|
|
800
800
|
}, n.classes = function(s, o) {
|
|
801
801
|
if (o === t)
|
|
802
|
-
return
|
|
803
|
-
|
|
802
|
+
return m[s];
|
|
803
|
+
m[s] = o;
|
|
804
804
|
}, n.loadTranslations = function(s) {
|
|
805
|
-
typeof s == "object" ? c = s : typeof s == "string" &&
|
|
805
|
+
typeof s == "object" ? c = s : typeof s == "string" && H(s, function(o) {
|
|
806
806
|
c = o;
|
|
807
807
|
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
}, A = (f.language || f.systemLanguage || f.userLanguage || "en").substr(0, 2).toLowerCase(), c[A] === t && (A = "en"), T =
|
|
810
|
-
}).call(
|
|
809
|
+
}, A = (f.language || f.systemLanguage || f.userLanguage || "en").substr(0, 2).toLowerCase(), c[A] === t && (A = "en"), T = O(), y = _(), k = R(), b = I(), d.exports && (e = d.exports = n), e.tempus = n;
|
|
810
|
+
}).call(we);
|
|
811
811
|
})($t, $t.exports);
|
|
812
812
|
var He = $t.exports;
|
|
813
813
|
const Lt = /* @__PURE__ */ Be(He);
|
|
814
|
-
var It, he, Dt, kt,
|
|
814
|
+
var It, he, Dt, kt, Ct, wt, At, bt, Bt, ue, Ht, fe, et, ft, z, tt, gt, te, st, dt, Ut, de, Pt, me, lt, Mt, yt, ee, pt, se;
|
|
815
815
|
const J = class J {
|
|
816
816
|
constructor(e) {
|
|
817
817
|
/**
|
|
@@ -825,7 +825,7 @@ const J = class J {
|
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
827
827
|
*/
|
|
828
|
-
E(this,
|
|
828
|
+
E(this, At);
|
|
829
829
|
/**
|
|
830
830
|
* Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
|
|
831
831
|
*
|
|
@@ -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
|
-
E(this,
|
|
849
|
+
E(this, et);
|
|
850
850
|
/**
|
|
851
851
|
* Проверяет operating-time в результате batch и ставит паузу,
|
|
852
852
|
* если сервер приблизился к лимиту выполнения.
|
|
@@ -854,7 +854,7 @@ const J = class J {
|
|
|
854
854
|
* @param {Object} result - Результат текущего batch-запроса.
|
|
855
855
|
* @returns {Promise<number>} Максимальный operating-time среди команд.
|
|
856
856
|
*/
|
|
857
|
-
E(this,
|
|
857
|
+
E(this, z);
|
|
858
858
|
/**
|
|
859
859
|
* Состояние приёма «опоздавших» ответов callBatch после клиентского таймаута.
|
|
860
860
|
* Живёт на весь цикл ретраев одного chunk — ответ от более ранней попытки
|
|
@@ -878,7 +878,7 @@ const J = class J {
|
|
|
878
878
|
* @param {(result: Object) => Promise<void>} processResult - Обработчик успешного результата chunk.
|
|
879
879
|
* @returns {Promise<void>}
|
|
880
880
|
*/
|
|
881
|
-
E(this,
|
|
881
|
+
E(this, st);
|
|
882
882
|
/**
|
|
883
883
|
* Выполняет BX24.callMethod с таймаутом ожидания ответа.
|
|
884
884
|
*
|
|
@@ -895,7 +895,7 @@ const J = class J {
|
|
|
895
895
|
* @returns {{ code: string, message: string }}
|
|
896
896
|
*/
|
|
897
897
|
E(this, Pt);
|
|
898
|
-
E(this,
|
|
898
|
+
E(this, lt);
|
|
899
899
|
E(this, yt);
|
|
900
900
|
/**
|
|
901
901
|
* Resets mutable runtime state before each public batch run.
|
|
@@ -917,24 +917,24 @@ const J = class J {
|
|
|
917
917
|
if (!this.progressData)
|
|
918
918
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
919
919
|
const e = this.totalBatchCommands || 0;
|
|
920
|
-
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length &&
|
|
920
|
+
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && N(this, It, he).call(this)) {
|
|
921
921
|
let u = 0;
|
|
922
922
|
for (const c of this.batchCommandKeyOrder) {
|
|
923
|
-
const
|
|
924
|
-
if (!
|
|
923
|
+
const O = this.progressData[c];
|
|
924
|
+
if (!O)
|
|
925
925
|
continue;
|
|
926
|
-
const _ = Number(
|
|
926
|
+
const _ = Number(O.total) || 0, R = Number(O.count) || 0;
|
|
927
927
|
_ === 0 && R === 0 ? u += 1 : _ > 0 && (u += Math.min(1, R / _));
|
|
928
928
|
}
|
|
929
929
|
const n = u / e * 100;
|
|
930
|
-
let
|
|
930
|
+
let m = Math.max(0, Math.min(100, Math.floor(n)));
|
|
931
931
|
const f = e, A = Math.min(e, Math.floor(u));
|
|
932
|
-
return { percent:
|
|
932
|
+
return { percent: m, allCount: A, allTotal: f };
|
|
933
933
|
}
|
|
934
934
|
let t = 0, r = 0;
|
|
935
935
|
for (const u of Object.values(this.progressData)) {
|
|
936
|
-
const { total: n, count:
|
|
937
|
-
t += n ?? 0, r +=
|
|
936
|
+
const { total: n, count: m } = u;
|
|
937
|
+
t += n ?? 0, r += m ?? 0;
|
|
938
938
|
}
|
|
939
939
|
const i = Number(this.chunkRate) || 0;
|
|
940
940
|
let a = 0;
|
|
@@ -951,7 +951,7 @@ const J = class J {
|
|
|
951
951
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
952
952
|
*/
|
|
953
953
|
setProgressData({ key: e, value: t, type: r }) {
|
|
954
|
-
var c,
|
|
954
|
+
var c, O;
|
|
955
955
|
if (!this.progressCall)
|
|
956
956
|
return;
|
|
957
957
|
const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
|
|
@@ -965,20 +965,20 @@ const J = class J {
|
|
|
965
965
|
}
|
|
966
966
|
let h = 1;
|
|
967
967
|
r === "count" ? (l || (l = a), h = l > 0 ? l : a > 0 ? a : 1) : i && (h = a), this.progressData || (this.progressData = {});
|
|
968
|
-
const u = ((c = this.progressData[e]) == null ? void 0 : c.total) ?? 0, n = ((
|
|
968
|
+
const u = ((c = this.progressData[e]) == null ? void 0 : c.total) ?? 0, n = ((O = this.progressData[e]) == null ? void 0 : O.count) ?? 0, m = h + n, f = Math.max(u, l ?? 0, m);
|
|
969
969
|
if (this.progressData[e] = {
|
|
970
970
|
total: f,
|
|
971
|
-
count: Math.min(
|
|
971
|
+
count: Math.min(m, f)
|
|
972
972
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
973
|
-
|
|
973
|
+
N(this, At, bt).call(this);
|
|
974
974
|
return;
|
|
975
975
|
}
|
|
976
|
-
|
|
976
|
+
N(this, At, bt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
977
977
|
if (!this.progressCall) {
|
|
978
978
|
this.clearProgressData();
|
|
979
979
|
return;
|
|
980
980
|
}
|
|
981
|
-
|
|
981
|
+
N(this, At, bt).call(this);
|
|
982
982
|
const { percent: _ } = this.progressPercent;
|
|
983
983
|
_ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
984
984
|
}, this.progressDelay));
|
|
@@ -1003,7 +1003,7 @@ const J = class J {
|
|
|
1003
1003
|
* @returns {void}
|
|
1004
1004
|
*/
|
|
1005
1005
|
setTimeLimitState(e, t, r) {
|
|
1006
|
-
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0,
|
|
1006
|
+
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, N(this, Ht, fe).call(this);
|
|
1007
1007
|
}
|
|
1008
1008
|
/**
|
|
1009
1009
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1040,8 +1040,8 @@ const J = class J {
|
|
|
1040
1040
|
if (!String(l).trim().startsWith("!") && Array.isArray(h) && h.length > this.filterChunkSize) {
|
|
1041
1041
|
const u = [];
|
|
1042
1042
|
for (let n = 0; n < h.length; n += this.filterChunkSize) {
|
|
1043
|
-
const
|
|
1044
|
-
i.filter ? (A.filter = { ...a }, A.filter[l] =
|
|
1043
|
+
const m = h.slice(n, n + this.filterChunkSize), f = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
|
|
1044
|
+
i.filter ? (A.filter = { ...a }, A.filter[l] = m) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[l] = m), u.push({
|
|
1045
1045
|
key: f,
|
|
1046
1046
|
request: { method: r, params: A },
|
|
1047
1047
|
originalKey: e,
|
|
@@ -1061,8 +1061,8 @@ const J = class J {
|
|
|
1061
1061
|
*/
|
|
1062
1062
|
mergeSplitResults(e, t) {
|
|
1063
1063
|
const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), l = Object.keys(e).filter((h) => a.test(h)).sort((h, u) => {
|
|
1064
|
-
const n = h.match(/__chunk_(\d+)$/),
|
|
1065
|
-
return n ?
|
|
1064
|
+
const n = h.match(/__chunk_(\d+)$/), m = u.match(/__chunk_(\d+)$/);
|
|
1065
|
+
return n ? m ? parseInt(n[1]) - parseInt(m[1]) : 1 : -1;
|
|
1066
1066
|
});
|
|
1067
1067
|
for (const h of l) {
|
|
1068
1068
|
const u = e[h];
|
|
@@ -1101,7 +1101,7 @@ const J = class J {
|
|
|
1101
1101
|
console.error("Error in callBatch callback:", A), l(A);
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
|
-
},
|
|
1104
|
+
}, m = async () => {
|
|
1105
1105
|
if (!h) {
|
|
1106
1106
|
h = !0, u && clearTimeout(u), console.warn(
|
|
1107
1107
|
`Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
|
|
@@ -1136,7 +1136,7 @@ const J = class J {
|
|
|
1136
1136
|
u = setTimeout(async () => {
|
|
1137
1137
|
h || (console.warn(
|
|
1138
1138
|
`Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
|
|
1139
|
-
), await
|
|
1139
|
+
), await m());
|
|
1140
1140
|
}, this.requestTimeoutMs);
|
|
1141
1141
|
});
|
|
1142
1142
|
}
|
|
@@ -1159,33 +1159,33 @@ const J = class J {
|
|
|
1159
1159
|
* @returns {Promise<Object>}
|
|
1160
1160
|
*/
|
|
1161
1161
|
async batch(e, t, r = {}) {
|
|
1162
|
-
|
|
1162
|
+
N(this, pt, se).call(this, t);
|
|
1163
1163
|
const i = {}, a = {}, l = {};
|
|
1164
|
-
for (const [
|
|
1164
|
+
for (const [m, f] of Object.entries(e)) {
|
|
1165
1165
|
const A = this.arrayChunk(f);
|
|
1166
1166
|
if (!A)
|
|
1167
1167
|
continue;
|
|
1168
|
-
const c = this.splitLargeFilters(
|
|
1168
|
+
const c = this.splitLargeFilters(m, A);
|
|
1169
1169
|
if (c.length === 1)
|
|
1170
|
-
a[
|
|
1170
|
+
a[m] = A;
|
|
1171
1171
|
else {
|
|
1172
|
-
l[
|
|
1173
|
-
for (const
|
|
1174
|
-
a[
|
|
1172
|
+
l[m] = [];
|
|
1173
|
+
for (const O of c)
|
|
1174
|
+
a[O.key] = O.request, l[m].push(O.key);
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
1177
|
this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
|
|
1178
|
-
(
|
|
1178
|
+
(m) => {
|
|
1179
1179
|
var f;
|
|
1180
|
-
return String(((f = a[
|
|
1180
|
+
return String(((f = a[m]) == null ? void 0 : f.method) || "");
|
|
1181
1181
|
}
|
|
1182
1182
|
), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
|
|
1183
1183
|
let h = {}, u = 0;
|
|
1184
1184
|
const n = Object.keys(a).length;
|
|
1185
|
-
for (const [
|
|
1185
|
+
for (const [m, f] of Object.entries(a)) {
|
|
1186
1186
|
if (!this.canContinue)
|
|
1187
1187
|
break;
|
|
1188
|
-
if (h[
|
|
1188
|
+
if (h[m] = f, Object.keys(h).length >= this.limit || u + 1 === n) {
|
|
1189
1189
|
const A = u + 1 === n;
|
|
1190
1190
|
await this.batchChunk(
|
|
1191
1191
|
h,
|
|
@@ -1195,22 +1195,22 @@ const J = class J {
|
|
|
1195
1195
|
disablePagination: !1,
|
|
1196
1196
|
oneBatch: !!(r != null && r.oneBatch)
|
|
1197
1197
|
}
|
|
1198
|
-
), Object.entries(this.result).forEach(([c,
|
|
1199
|
-
i[c] =
|
|
1198
|
+
), Object.entries(this.result).forEach(([c, O]) => {
|
|
1199
|
+
i[c] = O;
|
|
1200
1200
|
}), this.totalProgress = Math.round(
|
|
1201
1201
|
u / n * 100
|
|
1202
1202
|
), h = {};
|
|
1203
1203
|
}
|
|
1204
1204
|
u++;
|
|
1205
1205
|
}
|
|
1206
|
-
for (const [
|
|
1206
|
+
for (const [m, f] of Object.entries(l))
|
|
1207
1207
|
if (f && f.length > 0) {
|
|
1208
|
-
const A = this.mergeSplitResults(i,
|
|
1208
|
+
const A = this.mergeSplitResults(i, m);
|
|
1209
1209
|
for (const c of f)
|
|
1210
1210
|
delete i[c];
|
|
1211
|
-
i[
|
|
1211
|
+
i[m] = A;
|
|
1212
1212
|
}
|
|
1213
|
-
return
|
|
1213
|
+
return N(this, yt, ee).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
|
|
1214
1214
|
}
|
|
1215
1215
|
/**
|
|
1216
1216
|
* Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
|
|
@@ -1222,15 +1222,15 @@ const J = class J {
|
|
|
1222
1222
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
1223
1223
|
*/
|
|
1224
1224
|
async batchTotalCount(e, t) {
|
|
1225
|
-
|
|
1225
|
+
N(this, pt, se).call(this, t);
|
|
1226
1226
|
const r = {}, i = {}, a = {};
|
|
1227
1227
|
for (const [u, n] of Object.entries(e)) {
|
|
1228
|
-
const
|
|
1229
|
-
if (!
|
|
1228
|
+
const m = this.arrayChunk(n);
|
|
1229
|
+
if (!m)
|
|
1230
1230
|
continue;
|
|
1231
|
-
const f = this.splitLargeFilters(u,
|
|
1231
|
+
const f = this.splitLargeFilters(u, m);
|
|
1232
1232
|
if (f.length === 1)
|
|
1233
|
-
i[u] =
|
|
1233
|
+
i[u] = m;
|
|
1234
1234
|
else {
|
|
1235
1235
|
a[u] = [];
|
|
1236
1236
|
for (const A of f)
|
|
@@ -1239,42 +1239,42 @@ const J = class J {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
const l = [], h = Object.entries(i);
|
|
1241
1241
|
for (let u = 0; u < h.length; u += this.limit) {
|
|
1242
|
-
const n = h.slice(u, u + this.limit),
|
|
1242
|
+
const n = h.slice(u, u + this.limit), m = {};
|
|
1243
1243
|
for (const [f, A] of n) {
|
|
1244
1244
|
if (!this.canContinue)
|
|
1245
1245
|
break;
|
|
1246
|
-
|
|
1246
|
+
m[f] = A;
|
|
1247
1247
|
}
|
|
1248
|
-
Object.keys(
|
|
1248
|
+
Object.keys(m).length > 0 && l.push(m);
|
|
1249
1249
|
}
|
|
1250
1250
|
this.chunkRate = (1 / l.length).toFixed(5);
|
|
1251
1251
|
for (const [u, n] of Object.entries(l)) {
|
|
1252
1252
|
if (!this.canContinue)
|
|
1253
1253
|
break;
|
|
1254
1254
|
this.totalProgress = Math.round(Number(u) / l.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
|
|
1255
|
-
const
|
|
1256
|
-
await
|
|
1255
|
+
const m = Number(u) === l.length - 1;
|
|
1256
|
+
await N(this, st, dt).call(this, n, async (f) => {
|
|
1257
1257
|
for (const [A, c] of Object.entries(f)) {
|
|
1258
1258
|
if (!this.canContinue)
|
|
1259
1259
|
return;
|
|
1260
1260
|
if (c.error()) {
|
|
1261
|
-
|
|
1261
|
+
N(this, lt, Mt).call(this, A, c), r[A] = 0;
|
|
1262
1262
|
continue;
|
|
1263
1263
|
}
|
|
1264
|
-
const
|
|
1265
|
-
r[A] =
|
|
1264
|
+
const O = this.getData(c.data()), _ = Array.isArray(O) ? O.length : 0, I = typeof c.total == "function" && c.total() !== void 0 ? c.total() : _;
|
|
1265
|
+
r[A] = I, this.setProgressData({ key: A, value: c, type: "count" });
|
|
1266
1266
|
}
|
|
1267
|
-
await
|
|
1267
|
+
await N(this, z, tt).call(this, f, !m);
|
|
1268
1268
|
});
|
|
1269
1269
|
}
|
|
1270
1270
|
for (const [u, n] of Object.entries(a))
|
|
1271
1271
|
if (n && n.length > 0) {
|
|
1272
|
-
let
|
|
1272
|
+
let m = 0;
|
|
1273
1273
|
for (const f of n)
|
|
1274
|
-
r[f] !== void 0 && (
|
|
1275
|
-
r[u] =
|
|
1274
|
+
r[f] !== void 0 && (m += r[f] || 0), delete r[f];
|
|
1275
|
+
r[u] = m;
|
|
1276
1276
|
}
|
|
1277
|
-
return Object.entries(this.errors).length && (
|
|
1277
|
+
return Object.entries(this.errors).length && (N(this, yt, ee).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
|
|
1278
1278
|
}
|
|
1279
1279
|
/**
|
|
1280
1280
|
* Выполняет одиночный REST-вызов с таймаутом и авто-повтором после лимит-паузы.
|
|
@@ -1284,11 +1284,11 @@ const J = class J {
|
|
|
1284
1284
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1285
1285
|
*/
|
|
1286
1286
|
async call({ method: e, params: t = {} }) {
|
|
1287
|
-
var i, a, l, h, u, n,
|
|
1288
|
-
const r =
|
|
1287
|
+
var i, a, l, h, u, n, m;
|
|
1288
|
+
const r = N(this, gt, te).call(this, this.callLimitPauseMs);
|
|
1289
1289
|
for (; ; ) {
|
|
1290
|
-
let f = await
|
|
1291
|
-
onLateResponse: (
|
|
1290
|
+
let f = await N(this, Ut, de).call(this, e, t, {
|
|
1291
|
+
onLateResponse: (O) => r.notifyLateResponse(O)
|
|
1292
1292
|
});
|
|
1293
1293
|
if (!f)
|
|
1294
1294
|
if (r.inRetryCycle = !0, await r.waitForLateOrLimit(), r.lateResult)
|
|
@@ -1297,15 +1297,15 @@ const J = class J {
|
|
|
1297
1297
|
continue;
|
|
1298
1298
|
const A = {};
|
|
1299
1299
|
if (f != null && f.answer)
|
|
1300
|
-
for (const [
|
|
1301
|
-
|
|
1300
|
+
for (const [O, _] of Object.entries(f.answer))
|
|
1301
|
+
O !== "result" && _ && (A[O] = _);
|
|
1302
1302
|
if (f.error()) {
|
|
1303
|
-
const
|
|
1304
|
-
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(
|
|
1305
|
-
await
|
|
1303
|
+
const O = ((a = (i = f.error()) == null ? void 0 : i.ex) == null ? void 0 : a.error) ?? "";
|
|
1304
|
+
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(O)) {
|
|
1305
|
+
await N(this, et, ft).call(this, this.callLimitPauseMs);
|
|
1306
1306
|
continue;
|
|
1307
1307
|
}
|
|
1308
|
-
const _ = ((l = f.error()) == null ? void 0 : l.toString()) || ((u = (h = f.error()) == null ? void 0 : h.ex) == null ? void 0 : u.error_description) || ((
|
|
1308
|
+
const _ = ((l = f.error()) == null ? void 0 : l.toString()) || ((u = (h = f.error()) == null ? void 0 : h.ex) == null ? void 0 : u.error_description) || ((m = (n = f.error()) == null ? void 0 : n.ex) == null ? void 0 : m.error) || "Неизвестная ошибка";
|
|
1309
1309
|
return {
|
|
1310
1310
|
success: !1,
|
|
1311
1311
|
data: !1,
|
|
@@ -1329,14 +1329,12 @@ const J = class J {
|
|
|
1329
1329
|
*/
|
|
1330
1330
|
arrayChunk(e) {
|
|
1331
1331
|
let t = "", r = {};
|
|
1332
|
-
if (Array.isArray(e) ? [t] = e : (t = e.method, r = e.params), (t.includes("list") || t === "user.get" || t === "entity.item.get") && t !== "task.item.list") {
|
|
1332
|
+
if (Array.isArray(e) ? [t] = e : (t = e.method, r = e.params), (t.includes("list") || t === "user.get" || t === "entity.item.get" || t === "sonet_group.get") && t !== "task.item.list") {
|
|
1333
1333
|
if (!r)
|
|
1334
|
-
r = t === "entity.item.get" ? { SORT: { ID: "ASC" } } : {
|
|
1335
|
-
order: { ID: "ASC", id: "ASC" }
|
|
1336
|
-
};
|
|
1334
|
+
r = t === "entity.item.get" ? { SORT: { ID: "ASC" } } : t === "sonet_group.get" ? { ORDER: { ID: "ASC" } } : t.startsWith("crm.") ? { order: { ID: "ASC", id: "ASC" } } : { order: { ID: "ASC" } };
|
|
1337
1335
|
else {
|
|
1338
|
-
t === "entity.item.get" ? (r.SORT || (r.SORT = { ID: "ASC" }), Array.isArray(r.select) ? r.select.includes("ID") || r.select.push("ID") : r.select = ["ID"]) : t === "tasks.task.list" ? (r.order || (r.order = {}), r.order.ID = "asc") : t === "user.get" ? (r.sort || (r.sort = "ID"), r.order || (r.order = "ASC")) : r.order = { ID: "ASC", id: "ASC" }, Array.isArray(r.select) && !r.select.includes("ID") && r.select.push("ID");
|
|
1339
|
-
const i = t === "user.get" || t === "entity.item.get" ? r.FILTER : r.filter;
|
|
1336
|
+
t === "entity.item.get" ? (r.SORT || (r.SORT = { ID: "ASC" }), Array.isArray(r.select) ? r.select.includes("ID") || r.select.push("ID") : r.select = ["ID"]) : t === "sonet_group.get" ? r.ORDER ? !r.ORDER.ID && !r.ORDER.id && (r.ORDER.ID = "ASC") : r.ORDER = { ID: "ASC" } : t === "tasks.task.list" ? (r.order || (r.order = {}), r.order.ID = "asc") : t === "user.get" ? (r.sort || (r.sort = "ID"), r.order || (r.order = "ASC")) : t.startsWith("crm.") ? r.order = { ID: "ASC", id: "ASC" } : r.order ? !r.order.ID && !r.order.id && (r.order.ID = "ASC") : r.order = { ID: "ASC" }, Array.isArray(r.select) && !r.select.includes("ID") && r.select.push("ID");
|
|
1337
|
+
const i = t === "user.get" || t === "entity.item.get" || t === "sonet_group.get" ? r.FILTER : r.filter;
|
|
1340
1338
|
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, l]) => {
|
|
1341
1339
|
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (r.start = -1);
|
|
1342
1340
|
});
|
|
@@ -1365,15 +1363,15 @@ const J = class J {
|
|
|
1365
1363
|
let h;
|
|
1366
1364
|
const u = !!(i != null && i.disablePagination);
|
|
1367
1365
|
(async () => {
|
|
1368
|
-
await
|
|
1369
|
-
for (const [A, c] of Object.entries(
|
|
1366
|
+
await N(this, st, dt).call(this, e, async (m) => {
|
|
1367
|
+
for (const [A, c] of Object.entries(m)) {
|
|
1370
1368
|
if (!this.canContinue)
|
|
1371
1369
|
return;
|
|
1372
|
-
c.error() && (
|
|
1373
|
-
const
|
|
1374
|
-
t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] =
|
|
1375
|
-
const T = e[A],
|
|
1376
|
-
if (!u && (!this.canContinue ||
|
|
1370
|
+
c.error() && (N(this, lt, Mt).call(this, A, c), h = !0);
|
|
1371
|
+
const O = this.getData(c.data()), _ = Array.isArray(O) ? O.length : 0, R = typeof c.total == "function" && c.total() !== void 0, I = R ? c.total() : _;
|
|
1372
|
+
t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = I : this.result[A] = O, this.setProgressData({ key: A, value: c, type: t });
|
|
1373
|
+
const T = e[A], y = Array.isArray(T) ? T[0] : T == null ? void 0 : T.method, k = typeof y == "string" && (y.includes(".list") || y.endsWith("getlist") || y === "user.get" || y === "entity.item.get" || y === "sonet_group.get"), b = t === "count" ? !R && _ === this.limit : k ? _ === this.limit : I > this.limit && I > _, H = t !== "count" && y === "entity.item.get" && _ === this.limit && !b, w = b || H;
|
|
1374
|
+
if (!u && (!this.canContinue || w)) {
|
|
1377
1375
|
let B = e[A];
|
|
1378
1376
|
if (Array.isArray(B)) {
|
|
1379
1377
|
const [M, s = {}] = B;
|
|
@@ -1385,14 +1383,14 @@ const J = class J {
|
|
|
1385
1383
|
l.push([
|
|
1386
1384
|
A,
|
|
1387
1385
|
B,
|
|
1388
|
-
|
|
1389
|
-
{ entityItemGetScan:
|
|
1386
|
+
I,
|
|
1387
|
+
{ entityItemGetScan: H }
|
|
1390
1388
|
]);
|
|
1391
1389
|
}
|
|
1392
1390
|
}
|
|
1393
1391
|
h > 0 && this.errorLogger();
|
|
1394
1392
|
const f = l.length > 0 || r;
|
|
1395
|
-
await
|
|
1393
|
+
await N(this, z, tt).call(this, m, f), l.length ? await this.batchPayload(l, t, i).then(
|
|
1396
1394
|
() => a(this.result)
|
|
1397
1395
|
) : a(this.result);
|
|
1398
1396
|
});
|
|
@@ -1405,91 +1403,92 @@ const J = class J {
|
|
|
1405
1403
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1406
1404
|
*/
|
|
1407
1405
|
async batchPayload(e, t, r = {}) {
|
|
1408
|
-
const i = !!(r != null && r.oneBatch), a = (
|
|
1406
|
+
const i = !!(r != null && r.oneBatch), a = (O, _, R, I) => {
|
|
1409
1407
|
let T = "ID";
|
|
1410
|
-
this.result[
|
|
1411
|
-
let
|
|
1412
|
-
if (JSON.stringify(
|
|
1408
|
+
this.result[O][this.result[O].length - 1].ID || (T = "id");
|
|
1409
|
+
let y = `${T}`;
|
|
1410
|
+
if (JSON.stringify(I[1]).toLocaleLowerCase().includes('"id":"desc"') ? y = "<" + y : y = ">" + y, _ === 1 || R.length === 0)
|
|
1413
1411
|
return {
|
|
1414
|
-
field:
|
|
1415
|
-
id: this.result[
|
|
1412
|
+
field: y,
|
|
1413
|
+
id: this.result[O][this.result[O].length - 1][T]
|
|
1416
1414
|
};
|
|
1417
|
-
let
|
|
1418
|
-
const [
|
|
1419
|
-
return (
|
|
1420
|
-
field:
|
|
1421
|
-
id: `$result[${[
|
|
1415
|
+
let b = "";
|
|
1416
|
+
const [H, w] = I;
|
|
1417
|
+
return (H === "tasks.task.list" || H === "task.item.list") && (b = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(H) && (b = "[items]"), H === "crm.type.list" && (b = "[types]"), H === "socialnetwork.api.workgroup.list" && (b = "[workgroups]"), {
|
|
1418
|
+
field: y,
|
|
1419
|
+
id: `$result[${[O, _ - 1].join("__")}]${b}[49][${T}]`
|
|
1422
1420
|
};
|
|
1423
|
-
}, l = (
|
|
1424
|
-
const [R,
|
|
1425
|
-
let T = JSON.parse(JSON.stringify(
|
|
1421
|
+
}, l = (O, _) => {
|
|
1422
|
+
const [R, I] = O;
|
|
1423
|
+
let T = JSON.parse(JSON.stringify(I)), y;
|
|
1426
1424
|
if (R === "task.item.list") {
|
|
1427
1425
|
T = [...T];
|
|
1428
|
-
const [
|
|
1429
|
-
return
|
|
1426
|
+
const [k, b, H, w] = T;
|
|
1427
|
+
return b[_.field] = _.id, [R, T];
|
|
1430
1428
|
}
|
|
1431
|
-
return ["user.get"].includes(R) || T.FILTER ? (T.FILTER || (T.FILTER = {}),
|
|
1429
|
+
return ["user.get", "sonet_group.get"].includes(R) || T.FILTER ? (T.FILTER || (T.FILTER = {}), y = T.FILTER) : (T.filter || (T.filter = {}), y = T.filter), [
|
|
1432
1430
|
"socialnetwork.api.workgroup.list",
|
|
1433
1431
|
"tasks.task.list"
|
|
1434
|
-
].includes(R) ?
|
|
1435
|
-
}, h = (
|
|
1436
|
-
Object.entries(
|
|
1437
|
-
const [
|
|
1438
|
-
Array.isArray(T) && (t === "count" ? this.result[
|
|
1432
|
+
].includes(R) ? y[">ID"] = _.id : y[_.field] = _.id, [R, { ...T, start: -1 }];
|
|
1433
|
+
}, h = (O) => {
|
|
1434
|
+
Object.entries(O).forEach(([_, R]) => {
|
|
1435
|
+
const [I] = _.split("__"), T = this.getData(R.data());
|
|
1436
|
+
Array.isArray(T) && (t === "count" ? this.result[I] += T.length : this.result[I].push(...T)), R.error() && N(this, lt, Mt).call(this, I, R), this.setProgressData({ key: I, value: R, type: t });
|
|
1439
1437
|
});
|
|
1440
|
-
}, u = (
|
|
1441
|
-
if (!Array.isArray(
|
|
1438
|
+
}, u = (O, _) => {
|
|
1439
|
+
if (!Array.isArray(O) || O.length === 0)
|
|
1442
1440
|
return null;
|
|
1443
|
-
const R =
|
|
1444
|
-
let
|
|
1445
|
-
R.ID || (
|
|
1446
|
-
let T =
|
|
1447
|
-
return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: R[
|
|
1448
|
-
}, n = 1e4,
|
|
1449
|
-
var
|
|
1450
|
-
let
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
if (!O)
|
|
1441
|
+
const R = O[O.length - 1];
|
|
1442
|
+
let I = "ID";
|
|
1443
|
+
R.ID || (I = "id");
|
|
1444
|
+
let T = I;
|
|
1445
|
+
return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: R[I] };
|
|
1446
|
+
}, n = 1e4, m = async (O, _) => {
|
|
1447
|
+
var R, I;
|
|
1448
|
+
for (let T = 1; this.canContinue && T <= n; T++) {
|
|
1449
|
+
const y = this.result[O], k = u(y, _);
|
|
1450
|
+
if (!k)
|
|
1454
1451
|
break;
|
|
1455
|
-
const
|
|
1456
|
-
let
|
|
1457
|
-
await
|
|
1458
|
-
|
|
1452
|
+
const b = `${O}__page_${T}`, H = l(_, k);
|
|
1453
|
+
let w = null;
|
|
1454
|
+
await N(this, st, dt).call(this, { [b]: H }, async (o) => {
|
|
1455
|
+
w = o, h(o);
|
|
1459
1456
|
});
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
if ((k = s == null ? void 0 : s.error) != null && k.call(s)) {
|
|
1464
|
-
R = 0;
|
|
1457
|
+
const B = w == null ? void 0 : w[b];
|
|
1458
|
+
if ((R = B == null ? void 0 : B.error) != null && R.call(B)) {
|
|
1459
|
+
await N(this, z, tt).call(this, w, !1);
|
|
1465
1460
|
break;
|
|
1466
1461
|
}
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1462
|
+
const M = this.getData((I = B == null ? void 0 : B.data) == null ? void 0 : I.call(B));
|
|
1463
|
+
if ((Array.isArray(M) ? M.length : 0) === 0) {
|
|
1464
|
+
await N(this, z, tt).call(this, w, !1);
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
await N(this, z, tt).call(this, w, T < n);
|
|
1469
1468
|
}
|
|
1470
1469
|
};
|
|
1471
1470
|
let f = [], A = 0;
|
|
1472
|
-
const c = async (
|
|
1473
|
-
h(_), await
|
|
1471
|
+
const c = async (O = !0) => f.length ? (await N(this, st, dt).call(this, Object.fromEntries(f), async (_) => {
|
|
1472
|
+
h(_), await N(this, z, tt).call(this, _, O);
|
|
1474
1473
|
}), A++, f = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1475
|
-
for await (const
|
|
1474
|
+
for await (const O of e) {
|
|
1476
1475
|
if (!this.canContinue)
|
|
1477
1476
|
return;
|
|
1478
|
-
const [_, R,
|
|
1479
|
-
if (T.entityItemGetScan) {
|
|
1477
|
+
const [_, R, I, T = {}] = O;
|
|
1478
|
+
if (T.entityItemGetScan || !i) {
|
|
1480
1479
|
if (await c(!0))
|
|
1481
1480
|
return;
|
|
1482
1481
|
if (i)
|
|
1483
1482
|
continue;
|
|
1484
|
-
await
|
|
1483
|
+
await m(_, R);
|
|
1485
1484
|
continue;
|
|
1486
1485
|
}
|
|
1487
|
-
let
|
|
1488
|
-
for (;
|
|
1489
|
-
const
|
|
1490
|
-
if (f.push([
|
|
1486
|
+
let y = 1;
|
|
1487
|
+
for (; I > y * this.limit; ) {
|
|
1488
|
+
const k = [_, y].join("__"), b = a(_, y, f, R);
|
|
1489
|
+
if (f.push([k, l(R, b)]), i && f.length === 49 && await c(!0) || f.length % 50 === 0 && await c(!0))
|
|
1491
1490
|
return;
|
|
1492
|
-
|
|
1491
|
+
y++;
|
|
1493
1492
|
}
|
|
1494
1493
|
}
|
|
1495
1494
|
await c(!1);
|
|
@@ -1505,19 +1504,19 @@ const J = class J {
|
|
|
1505
1504
|
};
|
|
1506
1505
|
It = new WeakSet(), he = function() {
|
|
1507
1506
|
const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
|
|
1508
|
-
if (e <
|
|
1507
|
+
if (e < L(J, Dt) || !Array.isArray(t) || t.length !== e)
|
|
1509
1508
|
return !1;
|
|
1510
|
-
if (t.filter((a) => a === "crm.deal.list").length >=
|
|
1509
|
+
if (t.filter((a) => a === "crm.deal.list").length >= L(J, kt))
|
|
1511
1510
|
return !0;
|
|
1512
1511
|
const i = t.filter(
|
|
1513
1512
|
(a) => typeof a == "string" && a.includes(".list")
|
|
1514
1513
|
).length;
|
|
1515
|
-
return i >=
|
|
1516
|
-
}, Dt = new WeakMap(), kt = new WeakMap(),
|
|
1514
|
+
return i >= L(J, Ct) && i / e >= L(J, wt);
|
|
1515
|
+
}, Dt = new WeakMap(), kt = new WeakMap(), Ct = new WeakMap(), wt = new WeakMap(), At = new WeakSet(), bt = function() {
|
|
1517
1516
|
if (!this.progressCall || !this.progressData)
|
|
1518
1517
|
return;
|
|
1519
1518
|
const { percent: e, allCount: t, allTotal: r } = this.progressPercent, i = { percent: e, allCount: t, allTotal: r };
|
|
1520
|
-
|
|
1519
|
+
N(this, Bt, ue).call(this, i) && (this.progressCall({
|
|
1521
1520
|
data: this.progressData,
|
|
1522
1521
|
percent: e,
|
|
1523
1522
|
allCount: t,
|
|
@@ -1537,9 +1536,9 @@ It = new WeakSet(), he = function() {
|
|
|
1537
1536
|
} catch (r) {
|
|
1538
1537
|
console.warn("Batch timeLimit listener error:", r);
|
|
1539
1538
|
}
|
|
1540
|
-
},
|
|
1539
|
+
}, et = new WeakSet(), ft = async function(e = this.defaultPauseMs) {
|
|
1541
1540
|
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), e), await new Promise((t) => setTimeout(t, e)), this.setTimeLimitState(!1, void 0);
|
|
1542
|
-
},
|
|
1541
|
+
}, z = new WeakSet(), tt = async function(e, t = !0) {
|
|
1543
1542
|
if (!t)
|
|
1544
1543
|
return 0;
|
|
1545
1544
|
let r = 0;
|
|
@@ -1554,7 +1553,7 @@ It = new WeakSet(), he = function() {
|
|
|
1554
1553
|
}
|
|
1555
1554
|
} catch {
|
|
1556
1555
|
}
|
|
1557
|
-
r >= this.operatingThreshold && await
|
|
1556
|
+
r >= this.operatingThreshold && await N(this, et, ft).call(this);
|
|
1558
1557
|
}, gt = new WeakSet(), te = function(e = this.defaultPauseMs) {
|
|
1559
1558
|
const t = this;
|
|
1560
1559
|
return {
|
|
@@ -1581,7 +1580,7 @@ It = new WeakSet(), he = function() {
|
|
|
1581
1580
|
this.lateWaiters.push(l);
|
|
1582
1581
|
});
|
|
1583
1582
|
return Promise.race([
|
|
1584
|
-
|
|
1583
|
+
N(a = t, et, ft).call(a, e),
|
|
1585
1584
|
i
|
|
1586
1585
|
]).finally(() => {
|
|
1587
1586
|
this.inTimeoutWait = !1;
|
|
@@ -1591,20 +1590,20 @@ It = new WeakSet(), he = function() {
|
|
|
1591
1590
|
this.lateResult = null;
|
|
1592
1591
|
}
|
|
1593
1592
|
};
|
|
1594
|
-
},
|
|
1593
|
+
}, st = new WeakSet(), dt = async function(e, t) {
|
|
1595
1594
|
let r = !1, i = e;
|
|
1596
|
-
const a =
|
|
1595
|
+
const a = N(this, gt, te).call(this);
|
|
1597
1596
|
do
|
|
1598
1597
|
r = !1, await this.callBatchWithTimeout(
|
|
1599
1598
|
i,
|
|
1600
1599
|
async (l) => {
|
|
1601
|
-
var n,
|
|
1600
|
+
var n, m;
|
|
1602
1601
|
let h = !1;
|
|
1603
1602
|
const u = /* @__PURE__ */ new Set();
|
|
1604
1603
|
for (const [f, A] of Object.entries(l || {})) {
|
|
1605
1604
|
if (!(A != null && A.error) || !A.error())
|
|
1606
1605
|
continue;
|
|
1607
|
-
const c = ((
|
|
1606
|
+
const c = ((m = (n = A.error()) == null ? void 0 : n.ex) == null ? void 0 : m.error) ?? "";
|
|
1608
1607
|
if (c === "TIMEOUT") {
|
|
1609
1608
|
h = !0;
|
|
1610
1609
|
break;
|
|
@@ -1621,13 +1620,13 @@ It = new WeakSet(), he = function() {
|
|
|
1621
1620
|
}
|
|
1622
1621
|
if (u.size > 0) {
|
|
1623
1622
|
const f = {};
|
|
1624
|
-
for (const [c,
|
|
1625
|
-
u.has(c) || (f[c] =
|
|
1623
|
+
for (const [c, O] of Object.entries(l || {}))
|
|
1624
|
+
u.has(c) || (f[c] = O);
|
|
1626
1625
|
Object.keys(f).length && await t(f);
|
|
1627
1626
|
const A = {};
|
|
1628
1627
|
for (const c of u)
|
|
1629
1628
|
i[c] && (A[c] = i[c]);
|
|
1630
|
-
i = A, Object.keys(i).length && (r = !0, await
|
|
1629
|
+
i = A, Object.keys(i).length && (r = !0, await N(this, et, ft).call(this));
|
|
1631
1630
|
return;
|
|
1632
1631
|
}
|
|
1633
1632
|
a.inRetryCycle = !1, await t(l);
|
|
@@ -1663,8 +1662,8 @@ It = new WeakSet(), he = function() {
|
|
|
1663
1662
|
code: i || h,
|
|
1664
1663
|
message: h
|
|
1665
1664
|
};
|
|
1666
|
-
},
|
|
1667
|
-
const { code: r, message: i } =
|
|
1665
|
+
}, lt = new WeakSet(), Mt = function(e, t) {
|
|
1666
|
+
const { code: r, message: i } = N(this, Pt, me).call(this, t);
|
|
1668
1667
|
this.errors[e] = r, this.errorMessages[e] = i;
|
|
1669
1668
|
}, yt = new WeakSet(), ee = function(e) {
|
|
1670
1669
|
Object.entries(this.errors).length && (e.errorsList = { ...this.errors }, Object.entries(this.errorMessages).length && (e.errorsListMessages = { ...this.errorMessages }));
|
|
@@ -1673,12 +1672,12 @@ It = new WeakSet(), he = function() {
|
|
|
1673
1672
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1674
1673
|
E(J, Dt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1675
1674
|
E(J, kt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1676
|
-
E(J,
|
|
1675
|
+
E(J, Ct, 8), E(J, wt, 0.65);
|
|
1677
1676
|
let K = J;
|
|
1678
|
-
var
|
|
1677
|
+
var rt;
|
|
1679
1678
|
class ge {
|
|
1680
1679
|
constructor() {
|
|
1681
|
-
E(this,
|
|
1680
|
+
E(this, rt, {});
|
|
1682
1681
|
}
|
|
1683
1682
|
/**
|
|
1684
1683
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1707,7 +1706,7 @@ class ge {
|
|
|
1707
1706
|
* @param {Function} params.action - Функция для выполнения
|
|
1708
1707
|
*/
|
|
1709
1708
|
actionFilter({ keyTimer: e, duration: t = 10, action: r }) {
|
|
1710
|
-
|
|
1709
|
+
L(this, rt)[e] && (clearTimeout(L(this, rt)[e]), L(this, rt)[e] = null), r && (L(this, rt)[e] = setTimeout(() => {
|
|
1711
1710
|
r();
|
|
1712
1711
|
}, t));
|
|
1713
1712
|
}
|
|
@@ -1745,9 +1744,9 @@ class ge {
|
|
|
1745
1744
|
}, 200);
|
|
1746
1745
|
}
|
|
1747
1746
|
}
|
|
1748
|
-
|
|
1747
|
+
rt = new WeakMap();
|
|
1749
1748
|
const Zt = new ge();
|
|
1750
|
-
var j,
|
|
1749
|
+
var j, Q, it, ct, Nt, V, v, nt, ht, Gt, ye, Ot, re, Yt, pe, Wt, Ne, xt, Oe;
|
|
1751
1750
|
class Ue {
|
|
1752
1751
|
constructor() {
|
|
1753
1752
|
/** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
|
|
@@ -1760,16 +1759,16 @@ class Ue {
|
|
|
1760
1759
|
E(this, Wt);
|
|
1761
1760
|
E(this, xt);
|
|
1762
1761
|
E(this, j, "logger");
|
|
1763
|
-
E(this,
|
|
1764
|
-
E(this,
|
|
1765
|
-
E(this,
|
|
1762
|
+
E(this, Q, !1);
|
|
1763
|
+
E(this, it, /* @__PURE__ */ new Map());
|
|
1764
|
+
E(this, ct, {});
|
|
1766
1765
|
E(this, Nt, !1);
|
|
1767
|
-
E(this,
|
|
1766
|
+
E(this, V, null);
|
|
1768
1767
|
E(this, v, null);
|
|
1769
|
-
E(this,
|
|
1770
|
-
E(this,
|
|
1768
|
+
E(this, nt, !1);
|
|
1769
|
+
E(this, ht, !1);
|
|
1771
1770
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1772
|
-
|
|
1771
|
+
D(this, "periodClear", 3);
|
|
1773
1772
|
}
|
|
1774
1773
|
/** Инициализация логера */
|
|
1775
1774
|
async init() {
|
|
@@ -1779,23 +1778,23 @@ class Ue {
|
|
|
1779
1778
|
});
|
|
1780
1779
|
if (t && Array.isArray(t))
|
|
1781
1780
|
if (t.find(
|
|
1782
|
-
(i) => i.ENTITY ==
|
|
1781
|
+
(i) => i.ENTITY == L(this, j)
|
|
1783
1782
|
))
|
|
1784
|
-
x(this,
|
|
1783
|
+
x(this, Q, !0);
|
|
1785
1784
|
else {
|
|
1786
1785
|
let { entityAdd: i } = await e.batch({
|
|
1787
1786
|
entityAdd: {
|
|
1788
1787
|
method: "entity.add",
|
|
1789
1788
|
params: {
|
|
1790
|
-
ENTITY:
|
|
1791
|
-
NAME:
|
|
1789
|
+
ENTITY: L(this, j),
|
|
1790
|
+
NAME: L(this, j),
|
|
1792
1791
|
ACCESS: { AU: "X" }
|
|
1793
1792
|
}
|
|
1794
1793
|
}
|
|
1795
1794
|
});
|
|
1796
|
-
i && x(this,
|
|
1795
|
+
i && x(this, Q, !0);
|
|
1797
1796
|
}
|
|
1798
|
-
return
|
|
1797
|
+
return L(this, Q);
|
|
1799
1798
|
} catch (e) {
|
|
1800
1799
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1801
1800
|
}
|
|
@@ -1805,7 +1804,7 @@ class Ue {
|
|
|
1805
1804
|
* Используется в PAGE_BACKGROUND_WORKER, где не нужно делать entity.get/entity.add.
|
|
1806
1805
|
*/
|
|
1807
1806
|
enableBackworkerMode() {
|
|
1808
|
-
return x(this,
|
|
1807
|
+
return x(this, Q, !0), !0;
|
|
1809
1808
|
}
|
|
1810
1809
|
/**
|
|
1811
1810
|
* @param {{ type: 'call'|'batch'|'batch-total-count';
|
|
@@ -1817,8 +1816,8 @@ class Ue {
|
|
|
1817
1816
|
* @returns {string|null}
|
|
1818
1817
|
*/
|
|
1819
1818
|
start({ type: e, data: t }) {
|
|
1820
|
-
if (!
|
|
1821
|
-
return
|
|
1819
|
+
if (!L(this, Q))
|
|
1820
|
+
return N(this, Ot, re).call(this, "entity"), null;
|
|
1822
1821
|
if (!e || !t)
|
|
1823
1822
|
return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
|
|
1824
1823
|
const r = Zt.hash, i = {
|
|
@@ -1830,7 +1829,7 @@ class Ue {
|
|
|
1830
1829
|
answer: null,
|
|
1831
1830
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1832
1831
|
};
|
|
1833
|
-
return
|
|
1832
|
+
return L(this, it).set(r, i), x(this, ht, !0), r;
|
|
1834
1833
|
}
|
|
1835
1834
|
/**
|
|
1836
1835
|
* @param {{
|
|
@@ -1841,18 +1840,18 @@ class Ue {
|
|
|
1841
1840
|
*/
|
|
1842
1841
|
async stop({ key: e, errorList: t, status: r, answer: i }) {
|
|
1843
1842
|
var l;
|
|
1844
|
-
if (!
|
|
1843
|
+
if (!L(this, ht))
|
|
1845
1844
|
return;
|
|
1846
|
-
if (!
|
|
1847
|
-
|
|
1845
|
+
if (!L(this, Q)) {
|
|
1846
|
+
N(this, Ot, re).call(this, "entity");
|
|
1848
1847
|
return;
|
|
1849
1848
|
}
|
|
1850
|
-
let a =
|
|
1849
|
+
let a = L(this, it).get(e);
|
|
1851
1850
|
if (!a) {
|
|
1852
1851
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1853
1852
|
return;
|
|
1854
1853
|
}
|
|
1855
|
-
t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await
|
|
1854
|
+
t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await N(this, Gt, ye).call(this), a.userInfo = L(this, ct), await N(this, Yt, pe).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && x(this, nt, !0), x(this, ht, !1);
|
|
1856
1855
|
}
|
|
1857
1856
|
/**
|
|
1858
1857
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1860,14 +1859,14 @@ class Ue {
|
|
|
1860
1859
|
async getEntityList(e) {
|
|
1861
1860
|
var t;
|
|
1862
1861
|
try {
|
|
1863
|
-
if ((t =
|
|
1864
|
-
return
|
|
1862
|
+
if ((t = L(this, v)) != null && t.length && !L(this, nt))
|
|
1863
|
+
return L(this, v);
|
|
1865
1864
|
let r = new K(BX24.callBatch), { entityList: i } = await r.batch(
|
|
1866
1865
|
{
|
|
1867
1866
|
entityList: {
|
|
1868
1867
|
method: "entity.item.get",
|
|
1869
1868
|
params: {
|
|
1870
|
-
ENTITY:
|
|
1869
|
+
ENTITY: L(this, j),
|
|
1871
1870
|
SORT: { ID: "DESC" }
|
|
1872
1871
|
}
|
|
1873
1872
|
}
|
|
@@ -1888,7 +1887,7 @@ class Ue {
|
|
|
1888
1887
|
l
|
|
1889
1888
|
), null;
|
|
1890
1889
|
}
|
|
1891
|
-
}).filter((a) => a !== null), x(this,
|
|
1890
|
+
}).filter((a) => a !== null), x(this, nt, !1), x(this, v, i), i);
|
|
1892
1891
|
} catch (r) {
|
|
1893
1892
|
return console.error("Ошибка при получении списка записей:", r), [];
|
|
1894
1893
|
}
|
|
@@ -1898,16 +1897,16 @@ class Ue {
|
|
|
1898
1897
|
* Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
|
|
1899
1898
|
*/
|
|
1900
1899
|
runStorageMaintenance() {
|
|
1901
|
-
return
|
|
1900
|
+
return N(this, Wt, Ne).call(this);
|
|
1902
1901
|
}
|
|
1903
1902
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1904
1903
|
async downAllEntityJson() {
|
|
1905
1904
|
try {
|
|
1906
|
-
if (
|
|
1905
|
+
if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
|
|
1907
1906
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1908
1907
|
let e = Lt().format("%Y-%m-%d");
|
|
1909
1908
|
return Zt.downloadFileJson(
|
|
1910
|
-
|
|
1909
|
+
L(this, v),
|
|
1911
1910
|
`sdklogger-entity-data__${e}`
|
|
1912
1911
|
), !0;
|
|
1913
1912
|
} catch (e) {
|
|
@@ -1915,23 +1914,23 @@ class Ue {
|
|
|
1915
1914
|
}
|
|
1916
1915
|
}
|
|
1917
1916
|
}
|
|
1918
|
-
j = new WeakMap(),
|
|
1919
|
-
if (!
|
|
1920
|
-
return
|
|
1917
|
+
j = new WeakMap(), Q = new WeakMap(), it = new WeakMap(), ct = new WeakMap(), Nt = new WeakMap(), V = new WeakMap(), v = new WeakMap(), nt = new WeakMap(), ht = new WeakMap(), Gt = new WeakSet(), ye = async function() {
|
|
1918
|
+
if (!L(this, Nt))
|
|
1919
|
+
return L(this, V) ? L(this, V) : (x(this, V, (async () => {
|
|
1921
1920
|
try {
|
|
1922
1921
|
const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser: r } = await e.batch({
|
|
1923
1922
|
curUser: { method: "user.current" }
|
|
1924
1923
|
});
|
|
1925
|
-
x(this,
|
|
1924
|
+
x(this, ct, { isAdmin: t, curUser: r });
|
|
1926
1925
|
} catch (e) {
|
|
1927
1926
|
console.error(
|
|
1928
1927
|
"Ошибка при получении информации о пользователе:",
|
|
1929
1928
|
e
|
|
1930
|
-
), x(this,
|
|
1929
|
+
), x(this, ct, { isAdmin: !1, curUser: null });
|
|
1931
1930
|
} finally {
|
|
1932
|
-
x(this, Nt, !0), x(this,
|
|
1931
|
+
x(this, Nt, !0), x(this, V, null);
|
|
1933
1932
|
}
|
|
1934
|
-
})()),
|
|
1933
|
+
})()), L(this, V));
|
|
1935
1934
|
}, Ot = new WeakSet(), re = function(e) {
|
|
1936
1935
|
e == "entity" && Zt.actionFilter({
|
|
1937
1936
|
keyTimer: "error.logger.entity",
|
|
@@ -1943,14 +1942,14 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
1943
1942
|
}, Yt = new WeakSet(), pe = async function() {
|
|
1944
1943
|
try {
|
|
1945
1944
|
let e = {}, t = new K(BX24.callBatch);
|
|
1946
|
-
for (let [r, i] of
|
|
1945
|
+
for (let [r, i] of L(this, it).entries())
|
|
1947
1946
|
if (i.status) {
|
|
1948
1947
|
const a = JSON.stringify(i);
|
|
1949
1948
|
e[r] = {
|
|
1950
1949
|
method: "entity.item.add",
|
|
1951
1950
|
params: {
|
|
1952
|
-
ENTITY:
|
|
1953
|
-
NAME:
|
|
1951
|
+
ENTITY: L(this, j),
|
|
1952
|
+
NAME: L(this, j),
|
|
1954
1953
|
DETAIL_TEXT: a
|
|
1955
1954
|
}
|
|
1956
1955
|
};
|
|
@@ -1958,7 +1957,7 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
1958
1957
|
if (Object.keys(e).length) {
|
|
1959
1958
|
let r = await t.batch(e), { errors: i } = t;
|
|
1960
1959
|
for (let [a, l] of Object.entries({ ...r, ...i }))
|
|
1961
|
-
|
|
1960
|
+
L(this, it).delete(a);
|
|
1962
1961
|
return !0;
|
|
1963
1962
|
}
|
|
1964
1963
|
return !1;
|
|
@@ -1974,9 +1973,9 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
1974
1973
|
console.error("Не удалось получить время сервера");
|
|
1975
1974
|
return;
|
|
1976
1975
|
}
|
|
1977
|
-
if (
|
|
1976
|
+
if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
|
|
1978
1977
|
return;
|
|
1979
|
-
let r =
|
|
1978
|
+
let r = L(this, v).filter((i) => {
|
|
1980
1979
|
try {
|
|
1981
1980
|
let { dateCreate: a } = i;
|
|
1982
1981
|
return a ? Lt(new Date(a)).between(
|
|
@@ -1989,7 +1988,7 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
1989
1988
|
});
|
|
1990
1989
|
r.length > 0 && (console.log(
|
|
1991
1990
|
`Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1992
|
-
), await
|
|
1991
|
+
), await N(this, xt, Oe).call(this, r));
|
|
1993
1992
|
} catch (e) {
|
|
1994
1993
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1995
1994
|
}
|
|
@@ -2002,7 +2001,7 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
2002
2001
|
return {
|
|
2003
2002
|
method: "entity.item.delete",
|
|
2004
2003
|
params: {
|
|
2005
|
-
ENTITY:
|
|
2004
|
+
ENTITY: L(this, j),
|
|
2006
2005
|
ID: l
|
|
2007
2006
|
}
|
|
2008
2007
|
};
|
|
@@ -2010,7 +2009,7 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt
|
|
|
2010
2009
|
if (r.length === 0)
|
|
2011
2010
|
return !1;
|
|
2012
2011
|
const i = await t.batch(r);
|
|
2013
|
-
return console.log(`Успешно удалено ${r.length} записей`), x(this,
|
|
2012
|
+
return console.log(`Успешно удалено ${r.length} записей`), x(this, nt, !0), i;
|
|
2014
2013
|
} catch (t) {
|
|
2015
2014
|
return console.error("Ошибка при очистке устаревших записей:", t), !1;
|
|
2016
2015
|
}
|
|
@@ -2043,7 +2042,7 @@ function ie(d) {
|
|
|
2043
2042
|
const e = Pe();
|
|
2044
2043
|
return e ? (d.appConst.pathApp = e, e) : le(d.appConst.pathApp ?? "");
|
|
2045
2044
|
}
|
|
2046
|
-
var
|
|
2045
|
+
var ut, St, Ft, Te, _t, ne, vt, Ee, Xt, Re, Jt, Le, $, ot, Tt, ae, jt, be, Et, oe, Kt, Me;
|
|
2047
2046
|
class Je {
|
|
2048
2047
|
/**
|
|
2049
2048
|
* @param {Object} appConst - Константы приложения
|
|
@@ -2057,7 +2056,7 @@ class Je {
|
|
|
2057
2056
|
*
|
|
2058
2057
|
* @returns {Batch} Shared Batch instance.
|
|
2059
2058
|
*/
|
|
2060
|
-
E(this,
|
|
2059
|
+
E(this, ut);
|
|
2061
2060
|
E(this, Ft);
|
|
2062
2061
|
/**
|
|
2063
2062
|
* `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
|
|
@@ -2073,7 +2072,7 @@ class Je {
|
|
|
2073
2072
|
E(this, Xt);
|
|
2074
2073
|
/** Запрос данных о текущем пользователе */
|
|
2075
2074
|
E(this, Jt);
|
|
2076
|
-
E(this,
|
|
2075
|
+
E(this, $);
|
|
2077
2076
|
E(this, Tt);
|
|
2078
2077
|
/**
|
|
2079
2078
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
@@ -2095,20 +2094,20 @@ class Je {
|
|
|
2095
2094
|
* @private
|
|
2096
2095
|
*/
|
|
2097
2096
|
E(this, Kt);
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2097
|
+
D(this, "domain", "");
|
|
2098
|
+
D(this, "isAdmin", !1);
|
|
2099
|
+
D(this, "appInfo", null);
|
|
2100
|
+
D(this, "appConst", null);
|
|
2101
|
+
D(this, "userInfo", null);
|
|
2102
|
+
D(this, "placeData", null);
|
|
2103
|
+
D(this, "placeInfo", null);
|
|
2104
|
+
D(this, "logger", !1);
|
|
2105
|
+
D(this, "timeLimit", {
|
|
2107
2106
|
limit: !1,
|
|
2108
2107
|
date: void 0,
|
|
2109
2108
|
pauseMs: void 0
|
|
2110
2109
|
});
|
|
2111
|
-
|
|
2110
|
+
D(this, "batchClient", null);
|
|
2112
2111
|
this.appConst = e;
|
|
2113
2112
|
}
|
|
2114
2113
|
/**
|
|
@@ -2118,7 +2117,7 @@ class Je {
|
|
|
2118
2117
|
* @returns {() => void} Функция отписки.
|
|
2119
2118
|
*/
|
|
2120
2119
|
subscribeTimeLimit(e) {
|
|
2121
|
-
return
|
|
2120
|
+
return N(this, ut, St).call(this).subscribeTimeLimit(e);
|
|
2122
2121
|
}
|
|
2123
2122
|
/**
|
|
2124
2123
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2142,15 +2141,15 @@ class Je {
|
|
|
2142
2141
|
let a = setInterval(() => {
|
|
2143
2142
|
window.BX24 && BX24.init(async () => {
|
|
2144
2143
|
clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
|
|
2145
|
-
const l =
|
|
2144
|
+
const l = N(this, vt, Ee).call(this);
|
|
2146
2145
|
if (console.info(
|
|
2147
2146
|
l ? "init BX24 (background worker)" : "init BX24"
|
|
2148
|
-
), this.appInfo = await
|
|
2149
|
-
await
|
|
2147
|
+
), this.appInfo = await N(this, Xt, Re).call(this), this.userInfo = await N(this, Jt, Le).call(this), ie(this), l)
|
|
2148
|
+
await N(this, _t, ne).call(this, !1, {
|
|
2150
2149
|
skipInit: !0
|
|
2151
2150
|
});
|
|
2152
2151
|
else {
|
|
2153
|
-
await
|
|
2152
|
+
await N(this, _t, ne).call(this, !0);
|
|
2154
2153
|
const h = new ge();
|
|
2155
2154
|
try {
|
|
2156
2155
|
h.noSleep();
|
|
@@ -2217,11 +2216,11 @@ class Je {
|
|
|
2217
2216
|
const h = new Error("BX24 is not initialized");
|
|
2218
2217
|
throw console.error(h), h;
|
|
2219
2218
|
}
|
|
2220
|
-
const l = await
|
|
2221
|
-
return l.success ? (await
|
|
2219
|
+
const l = await N(this, ut, St).call(this).call({ method: e, params: t });
|
|
2220
|
+
return l.success ? (await N(this, $, ot).call(this, i, {
|
|
2222
2221
|
answer: l.answer,
|
|
2223
2222
|
status: "success"
|
|
2224
|
-
}), l.data) : (console.error(l.error), await
|
|
2223
|
+
}), l.data) : (console.error(l.error), await N(this, $, ot).call(this, i, {
|
|
2225
2224
|
answer: l.answer,
|
|
2226
2225
|
status: "fail",
|
|
2227
2226
|
errorList: { 0: l.error || "Unknown call error" }
|
|
@@ -2251,7 +2250,7 @@ class Je {
|
|
|
2251
2250
|
const l = new Error("BX24 is not initialized");
|
|
2252
2251
|
return console.error(l), !1;
|
|
2253
2252
|
}
|
|
2254
|
-
return
|
|
2253
|
+
return N(this, Tt, ae).call(this, {
|
|
2255
2254
|
mode: "batch",
|
|
2256
2255
|
commandList: e,
|
|
2257
2256
|
progressCall: t,
|
|
@@ -2287,7 +2286,7 @@ class Je {
|
|
|
2287
2286
|
const a = new Error("BX24 is not initialized");
|
|
2288
2287
|
return console.error(a), !1;
|
|
2289
2288
|
}
|
|
2290
|
-
return
|
|
2289
|
+
return N(this, Tt, ae).call(this, {
|
|
2291
2290
|
mode: "batch-total-count",
|
|
2292
2291
|
commandList: e,
|
|
2293
2292
|
progressCall: t,
|
|
@@ -2309,42 +2308,42 @@ class Je {
|
|
|
2309
2308
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2310
2309
|
return;
|
|
2311
2310
|
const { appName: t, pathApp: r } = this.appConst;
|
|
2312
|
-
let i =
|
|
2311
|
+
let i = N(this, Et, oe).call(this, e);
|
|
2313
2312
|
i = i.filter(
|
|
2314
2313
|
(c) => c.placement !== "PAGE_BACKGROUND_WORKER" && c.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2315
2314
|
);
|
|
2316
|
-
const a =
|
|
2315
|
+
const a = N(this, Kt, Me).call(this, r), l = new Set(i.map((c) => c.placement));
|
|
2317
2316
|
for (const c of a)
|
|
2318
2317
|
l.has(c.placement) || i.push({ placement: c.placement });
|
|
2319
2318
|
if (i.length === 0)
|
|
2320
2319
|
return;
|
|
2321
2320
|
let h = t;
|
|
2322
2321
|
this.domain === "szdl.bitrix24.ru" && ((A = this.appInfo) != null && A.ID) && (h = `${t}: #${this.appInfo.ID}`);
|
|
2323
|
-
const u = h.replace(" CRM", ""), n = {},
|
|
2322
|
+
const u = h.replace(" CRM", ""), n = {}, m = [], f = /* @__PURE__ */ new Map();
|
|
2324
2323
|
for (const c of this.placeData)
|
|
2325
2324
|
f.has(c.placement) || f.set(c.placement, []), f.get(c.placement).push(c);
|
|
2326
2325
|
for (let c = 0; c < i.length; c++) {
|
|
2327
|
-
const { placement:
|
|
2326
|
+
const { placement: O, options: _ } = i[c], R = f.get(O) || [];
|
|
2328
2327
|
if (R.some(
|
|
2329
|
-
(
|
|
2328
|
+
(y) => y.handler === r
|
|
2330
2329
|
))
|
|
2331
2330
|
continue;
|
|
2332
2331
|
const T = R.filter(
|
|
2333
|
-
(
|
|
2332
|
+
(y) => y.handler !== r
|
|
2334
2333
|
);
|
|
2335
|
-
for (const
|
|
2336
|
-
|
|
2337
|
-
placement:
|
|
2338
|
-
handler:
|
|
2334
|
+
for (const y of T)
|
|
2335
|
+
m.push({
|
|
2336
|
+
placement: O,
|
|
2337
|
+
handler: y.handler
|
|
2339
2338
|
});
|
|
2340
2339
|
n[`bind_${c}`] = {
|
|
2341
2340
|
method: "placement.bind",
|
|
2342
2341
|
params: {
|
|
2343
|
-
PLACEMENT:
|
|
2342
|
+
PLACEMENT: O,
|
|
2344
2343
|
HANDLER: r,
|
|
2345
2344
|
LANG_ALL: {
|
|
2346
2345
|
ru: {
|
|
2347
|
-
TITLE:
|
|
2346
|
+
TITLE: O === "USER_PROFILE_TOOLBAR" ? u : h
|
|
2348
2347
|
}
|
|
2349
2348
|
},
|
|
2350
2349
|
OPTIONS: {
|
|
@@ -2354,7 +2353,7 @@ class Je {
|
|
|
2354
2353
|
}
|
|
2355
2354
|
};
|
|
2356
2355
|
}
|
|
2357
|
-
|
|
2356
|
+
m.length > 0 && await this.placementUnBind(m), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((c) => {
|
|
2358
2357
|
console.log("Приложение успешно встроено в", c.params.PLACEMENT);
|
|
2359
2358
|
}));
|
|
2360
2359
|
}
|
|
@@ -2363,7 +2362,7 @@ class Je {
|
|
|
2363
2362
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2364
2363
|
*/
|
|
2365
2364
|
async placementUnBind(e) {
|
|
2366
|
-
let t =
|
|
2365
|
+
let t = N(this, Et, oe).call(this, e);
|
|
2367
2366
|
if (t = t.filter(
|
|
2368
2367
|
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2369
2368
|
), t.length === 0)
|
|
@@ -2446,7 +2445,7 @@ class Je {
|
|
|
2446
2445
|
return this.logger.getEntityList(e);
|
|
2447
2446
|
}
|
|
2448
2447
|
}
|
|
2449
|
-
|
|
2448
|
+
ut = new WeakSet(), St = function() {
|
|
2450
2449
|
return this.batchClient || (this.batchClient = new K({
|
|
2451
2450
|
callBatch: BX24.callBatch,
|
|
2452
2451
|
callMethod: BX24.callMethod
|
|
@@ -2461,7 +2460,7 @@ ht = new WeakSet(), St = function() {
|
|
|
2461
2460
|
}
|
|
2462
2461
|
};
|
|
2463
2462
|
}, _t = new WeakSet(), ne = async function(e, { skipInit: t = !1 } = {}) {
|
|
2464
|
-
this.logger ? (this.logger = new Ue(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger =
|
|
2463
|
+
this.logger ? (this.logger = new Ue(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = N(this, Ft, Te).call(this);
|
|
2465
2464
|
}, vt = new WeakSet(), Ee = function() {
|
|
2466
2465
|
var r, i, a;
|
|
2467
2466
|
const e = (r = this.placeInfo) == null ? void 0 : r.placement, t = (a = (i = this.placeInfo) == null ? void 0 : i.options) == null ? void 0 : a.ID;
|
|
@@ -2470,7 +2469,7 @@ ht = new WeakSet(), St = function() {
|
|
|
2470
2469
|
return this.call({ method: "app.info" });
|
|
2471
2470
|
}, Jt = new WeakSet(), Le = function() {
|
|
2472
2471
|
return this.call({ method: "user.current" });
|
|
2473
|
-
},
|
|
2472
|
+
}, $ = new WeakSet(), ot = async function(e, t) {
|
|
2474
2473
|
if (e)
|
|
2475
2474
|
try {
|
|
2476
2475
|
await this.logger.stop({
|
|
@@ -2488,18 +2487,18 @@ ht = new WeakSet(), St = function() {
|
|
|
2488
2487
|
updateList: a,
|
|
2489
2488
|
batchOptions: l
|
|
2490
2489
|
}) {
|
|
2491
|
-
const h =
|
|
2490
|
+
const h = N(this, ut, St).call(this), u = a ? this.logger.start({
|
|
2492
2491
|
type: e,
|
|
2493
2492
|
data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
|
|
2494
2493
|
}) : void 0;
|
|
2495
2494
|
try {
|
|
2496
|
-
const n = e === "batch" ? await h.batch(t, r, l) : await h.batchTotalCount(t, r),
|
|
2497
|
-
return Object.keys(
|
|
2495
|
+
const n = e === "batch" ? await h.batch(t, r, l) : await h.batchTotalCount(t, r), m = N(this, jt, be).call(this, h, n, t, a);
|
|
2496
|
+
return Object.keys(m).length ? (i && i(m), await N(this, $, ot).call(this, u, {
|
|
2498
2497
|
status: "fail",
|
|
2499
|
-
errorList:
|
|
2500
|
-
})) : await
|
|
2498
|
+
errorList: m
|
|
2499
|
+
})) : await N(this, $, ot).call(this, u, { status: "success" }), n;
|
|
2501
2500
|
} catch (n) {
|
|
2502
|
-
return await
|
|
2501
|
+
return await N(this, $, ot).call(this, u, {
|
|
2503
2502
|
status: "fail-runtime",
|
|
2504
2503
|
errorList: { 0: n == null ? void 0 : n.toString() }
|
|
2505
2504
|
}), console.error(n), !1;
|
|
@@ -2524,7 +2523,7 @@ ht = new WeakSet(), St = function() {
|
|
|
2524
2523
|
A != null && n.add(f);
|
|
2525
2524
|
}
|
|
2526
2525
|
}
|
|
2527
|
-
const
|
|
2526
|
+
const m = Object.values(e.errors).find(
|
|
2528
2527
|
(f) => {
|
|
2529
2528
|
if (typeof f != "string")
|
|
2530
2529
|
return !1;
|
|
@@ -2533,7 +2532,7 @@ ht = new WeakSet(), St = function() {
|
|
|
2533
2532
|
}
|
|
2534
2533
|
);
|
|
2535
2534
|
for (const f of Object.keys(r))
|
|
2536
|
-
!n.has(f) && !e.errors[f] && (a[f] =
|
|
2535
|
+
!n.has(f) && !e.errors[f] && (a[f] = m || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2537
2536
|
}
|
|
2538
2537
|
return a;
|
|
2539
2538
|
}, Et = new WeakSet(), oe = function(e) {
|
|
@@ -2632,7 +2631,7 @@ function ve(d = {}) {
|
|
|
2632
2631
|
}
|
|
2633
2632
|
return e;
|
|
2634
2633
|
}
|
|
2635
|
-
var qt, Ie, Rt, Ae,
|
|
2634
|
+
var qt, Ie, Rt, Ae, at, mt, zt, De;
|
|
2636
2635
|
class je {
|
|
2637
2636
|
constructor(e) {
|
|
2638
2637
|
E(this, qt);
|
|
@@ -2642,32 +2641,32 @@ class je {
|
|
|
2642
2641
|
*/
|
|
2643
2642
|
E(this, Rt);
|
|
2644
2643
|
/** Ключ NAME в entity: userId или общий ключ портала. */
|
|
2645
|
-
E(this,
|
|
2644
|
+
E(this, at);
|
|
2646
2645
|
/** Имя Web Lock для подтверждения лидерства. */
|
|
2647
2646
|
E(this, zt);
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2647
|
+
D(this, "entityName", "tabs");
|
|
2648
|
+
D(this, "maxTabs", 20);
|
|
2649
|
+
D(this, "tabList", []);
|
|
2650
|
+
D(this, "id", 0);
|
|
2651
|
+
D(this, "hasStarted", !1);
|
|
2652
|
+
D(this, "heartbeat");
|
|
2653
|
+
D(this, "runHeartbeat");
|
|
2654
|
+
D(this, "startDelay", 0);
|
|
2655
|
+
D(this, "activeMaxPause", q.activeMaxPauseMs);
|
|
2656
|
+
D(this, "quickCleanupThreshold", q.quickCleanupThresholdMs);
|
|
2657
|
+
D(this, "pollInterval", q.pollIntervalMs);
|
|
2658
|
+
D(this, "pollIntervalBase", q.pollIntervalMs);
|
|
2659
|
+
D(this, "pollIntervalJitter", q.pollIntervalJitterMs);
|
|
2660
|
+
D(this, "leaderConfirmDelay", q.leaderConfirmDelayMs);
|
|
2661
|
+
D(this, "leaderHeartbeatMs", null);
|
|
2662
|
+
D(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
2663
|
+
D(this, "continueCondition");
|
|
2664
|
+
D(this, "defaultContinueBackground", () => !0);
|
|
2666
2665
|
/** @type {'user' | 'portal'} */
|
|
2667
|
-
|
|
2666
|
+
D(this, "coordinationScope", "user");
|
|
2668
2667
|
/** Привязывать общую встройку PAGE_BACKGROUND_WORKER без USER_ID. @default true */
|
|
2669
|
-
|
|
2670
|
-
var n,
|
|
2668
|
+
D(this, "bindGeneralPlacement", !0);
|
|
2669
|
+
var n, m, f;
|
|
2671
2670
|
if (!e) {
|
|
2672
2671
|
console.error("BackgroundWorker: Нет опций конструктора");
|
|
2673
2672
|
return;
|
|
@@ -2681,7 +2680,7 @@ class je {
|
|
|
2681
2680
|
coordinationScope: h,
|
|
2682
2681
|
bindGeneralPlacement: u
|
|
2683
2682
|
} = e;
|
|
2684
|
-
this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = Fe(h), this.bindGeneralPlacement = u !== !1,
|
|
2683
|
+
this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = Fe(h), this.bindGeneralPlacement = u !== !1, N(this, qt, Ie).call(this, l), ie(r), this.appPath = N(this, Rt, Ae).call(this, ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.pathApp) ?? ""), this.appName = ((m = r == null ? void 0 : r.appConst) == null ? void 0 : m.appName) ?? "", this.appCodeName = ((f = r == null ? void 0 : r.appConst) == null ? void 0 : f.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2685
2684
|
}
|
|
2686
2685
|
async init() {
|
|
2687
2686
|
if (!this.appInit) {
|
|
@@ -2751,7 +2750,7 @@ class je {
|
|
|
2751
2750
|
);
|
|
2752
2751
|
}
|
|
2753
2752
|
async getTabs() {
|
|
2754
|
-
const e =
|
|
2753
|
+
const e = N(this, at, mt).call(this), t = await this.safeCall(
|
|
2755
2754
|
() => this.bx.call({
|
|
2756
2755
|
method: "entity.item.get",
|
|
2757
2756
|
params: {
|
|
@@ -2791,7 +2790,7 @@ class je {
|
|
|
2791
2790
|
method: "entity.item.add",
|
|
2792
2791
|
params: {
|
|
2793
2792
|
ENTITY: this.entityName,
|
|
2794
|
-
NAME:
|
|
2793
|
+
NAME: N(this, at, mt).call(this),
|
|
2795
2794
|
DETAIL_TEXT: JSON.stringify(e)
|
|
2796
2795
|
}
|
|
2797
2796
|
})
|
|
@@ -2815,7 +2814,7 @@ class je {
|
|
|
2815
2814
|
params: {
|
|
2816
2815
|
ENTITY: this.entityName,
|
|
2817
2816
|
ID: this.id,
|
|
2818
|
-
NAME:
|
|
2817
|
+
NAME: N(this, at, mt).call(this),
|
|
2819
2818
|
DETAIL_TEXT: JSON.stringify(t)
|
|
2820
2819
|
}
|
|
2821
2820
|
})
|
|
@@ -2851,8 +2850,8 @@ class je {
|
|
|
2851
2850
|
for (const u of r) {
|
|
2852
2851
|
if (u.placement !== "PAGE_BACKGROUND_WORKER" || !(u.userId || u.handler && u.handler.includes("USER_ID=")))
|
|
2853
2852
|
continue;
|
|
2854
|
-
const
|
|
2855
|
-
if (
|
|
2853
|
+
const m = u.userId || (u.handler ? this.extractUserIdFromHandler(u.handler) : null);
|
|
2854
|
+
if (m && +m === i) {
|
|
2856
2855
|
h = !0;
|
|
2857
2856
|
break;
|
|
2858
2857
|
}
|
|
@@ -2911,11 +2910,11 @@ class je {
|
|
|
2911
2910
|
selectLeaderId() {
|
|
2912
2911
|
var t;
|
|
2913
2912
|
return this.tabList.length && +((t = [...this.tabList].sort((r, i) => {
|
|
2914
|
-
var h, u, n,
|
|
2913
|
+
var h, u, n, m;
|
|
2915
2914
|
const a = new Date(
|
|
2916
2915
|
((h = r.data) == null ? void 0 : h.createdAt) || ((u = r.data) == null ? void 0 : u.lastActive) || 0
|
|
2917
2916
|
).getTime(), l = new Date(
|
|
2918
|
-
((n = i.data) == null ? void 0 : n.createdAt) || ((
|
|
2917
|
+
((n = i.data) == null ? void 0 : n.createdAt) || ((m = i.data) == null ? void 0 : m.lastActive) || 0
|
|
2919
2918
|
).getTime();
|
|
2920
2919
|
return a === l ? (+r.id || 0) - (+i.id || 0) : a - l;
|
|
2921
2920
|
})[0]) == null ? void 0 : t.id) || 0;
|
|
@@ -2926,7 +2925,7 @@ class je {
|
|
|
2926
2925
|
return !!(e && +this.id == +e);
|
|
2927
2926
|
}
|
|
2928
2927
|
async runAsLeader() {
|
|
2929
|
-
const e =
|
|
2928
|
+
const e = N(this, zt, De).call(this);
|
|
2930
2929
|
(await xe(
|
|
2931
2930
|
e,
|
|
2932
2931
|
async () => {
|
|
@@ -2967,15 +2966,15 @@ class je {
|
|
|
2967
2966
|
);
|
|
2968
2967
|
}
|
|
2969
2968
|
async setBackgroundWorkerAll() {
|
|
2970
|
-
var
|
|
2971
|
-
if (!((
|
|
2969
|
+
var _, R, I, T;
|
|
2970
|
+
if (!((_ = this.bx) != null && _.isAdmin)) {
|
|
2972
2971
|
console.log(
|
|
2973
2972
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2974
2973
|
);
|
|
2975
2974
|
return;
|
|
2976
2975
|
}
|
|
2977
|
-
(
|
|
2978
|
-
const e =
|
|
2976
|
+
(R = this.users) != null && R.length || await this.getEntityData(), ie(this.bx);
|
|
2977
|
+
const e = N(this, Rt, Ae).call(this, ((T = (I = this.bx) == null ? void 0 : I.appConst) == null ? void 0 : T.pathApp) ?? "");
|
|
2979
2978
|
if (!e) {
|
|
2980
2979
|
console.error(
|
|
2981
2980
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2986,75 +2985,75 @@ class je {
|
|
|
2986
2985
|
() => this.bx.getPlacement()
|
|
2987
2986
|
), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2988
2987
|
let a = null;
|
|
2989
|
-
(t || []).forEach((
|
|
2990
|
-
if (
|
|
2988
|
+
(t || []).forEach((y) => {
|
|
2989
|
+
if (y.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2991
2990
|
return;
|
|
2992
|
-
if (
|
|
2993
|
-
const
|
|
2994
|
-
if (
|
|
2995
|
-
const
|
|
2996
|
-
r.set(
|
|
2991
|
+
if (y.userId || y.handler && y.handler.includes("USER_ID=")) {
|
|
2992
|
+
const b = y.userId || (y.handler ? this.extractUserIdFromHandler(y.handler) : null);
|
|
2993
|
+
if (b) {
|
|
2994
|
+
const H = +b;
|
|
2995
|
+
r.set(H, y), i.has(H) || i.set(H, []), i.get(H).push(y);
|
|
2997
2996
|
}
|
|
2998
2997
|
} else
|
|
2999
|
-
a =
|
|
2998
|
+
a = y;
|
|
3000
2999
|
});
|
|
3001
3000
|
const l = await this.resolveAdmins(), h = await this.getEligibleUsersForBackgroundWorker(l);
|
|
3002
|
-
h.sort((
|
|
3003
|
-
const
|
|
3004
|
-
return (
|
|
3001
|
+
h.sort((y, k) => {
|
|
3002
|
+
const b = y.LAST_LOGIN ? new Date(y.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
3003
|
+
return (k.LAST_LOGIN ? new Date(k.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - b;
|
|
3005
3004
|
});
|
|
3006
|
-
const u = 10, n = h.slice(0, u),
|
|
3007
|
-
const
|
|
3008
|
-
if (!
|
|
3005
|
+
const u = 10, n = h.slice(0, u), m = n.filter((y) => {
|
|
3006
|
+
const k = r.get(+y.ID);
|
|
3007
|
+
if (!k)
|
|
3009
3008
|
return !0;
|
|
3010
|
-
const
|
|
3011
|
-
return
|
|
3009
|
+
const b = `${e}?USER_ID=${y.ID}/`;
|
|
3010
|
+
return k.handler !== b;
|
|
3012
3011
|
}), f = [];
|
|
3013
|
-
for (const [
|
|
3014
|
-
const
|
|
3015
|
-
h.find((
|
|
3012
|
+
for (const [y] of r) {
|
|
3013
|
+
const k = +y || 0;
|
|
3014
|
+
h.find((H) => +H.ID === k) || f.push(k);
|
|
3016
3015
|
}
|
|
3017
|
-
for (const
|
|
3018
|
-
const
|
|
3019
|
-
if (!
|
|
3016
|
+
for (const y of n) {
|
|
3017
|
+
const k = r.get(+y.ID);
|
|
3018
|
+
if (!k)
|
|
3020
3019
|
continue;
|
|
3021
|
-
const
|
|
3022
|
-
|
|
3020
|
+
const b = `${e}?USER_ID=${y.ID}/`;
|
|
3021
|
+
k.handler !== b && f.push(+y.ID);
|
|
3023
3022
|
}
|
|
3024
3023
|
const A = [], c = [...new Set(f)];
|
|
3025
|
-
for (const
|
|
3026
|
-
const
|
|
3027
|
-
for (const
|
|
3028
|
-
|
|
3024
|
+
for (const y of c) {
|
|
3025
|
+
const k = i.get(+y) || [];
|
|
3026
|
+
for (const b of k)
|
|
3027
|
+
b != null && b.handler && A.push({
|
|
3029
3028
|
method: "placement.unbind",
|
|
3030
3029
|
params: {
|
|
3031
3030
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
3032
|
-
HANDLER:
|
|
3031
|
+
HANDLER: b.handler
|
|
3033
3032
|
}
|
|
3034
3033
|
});
|
|
3035
3034
|
}
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3035
|
+
const O = a && (!this.bindGeneralPlacement || m.length > 0 || a.handler !== `${e}`);
|
|
3036
|
+
O && A.push({
|
|
3038
3037
|
method: "placement.unbind",
|
|
3039
3038
|
params: {
|
|
3040
3039
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
3041
3040
|
HANDLER: a.handler || `${e}`
|
|
3042
3041
|
}
|
|
3043
3042
|
});
|
|
3044
|
-
for (const
|
|
3043
|
+
for (const y of m)
|
|
3045
3044
|
A.push({
|
|
3046
3045
|
method: "placement.bind",
|
|
3047
3046
|
params: {
|
|
3048
3047
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
3049
|
-
HANDLER: `${e}?USER_ID=${
|
|
3048
|
+
HANDLER: `${e}?USER_ID=${y.ID}/`,
|
|
3050
3049
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
3051
3050
|
OPTIONS: {
|
|
3052
|
-
errorHandlerUrl: `${e}?USER_ID=${
|
|
3051
|
+
errorHandlerUrl: `${e}?USER_ID=${y.ID}/`
|
|
3053
3052
|
},
|
|
3054
|
-
USER_ID:
|
|
3053
|
+
USER_ID: y.ID
|
|
3055
3054
|
}
|
|
3056
3055
|
});
|
|
3057
|
-
this.bindGeneralPlacement && (!a ||
|
|
3056
|
+
this.bindGeneralPlacement && (!a || O) && A.push({
|
|
3058
3057
|
method: "placement.bind",
|
|
3059
3058
|
params: {
|
|
3060
3059
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -3062,25 +3061,13 @@ class je {
|
|
|
3062
3061
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
3063
3062
|
OPTIONS: { errorHandlerUrl: `${e}` }
|
|
3064
3063
|
}
|
|
3065
|
-
})
|
|
3066
|
-
const _ = A.filter(
|
|
3067
|
-
(O) => O.method === "placement.unbind"
|
|
3068
|
-
), R = A.filter(
|
|
3069
|
-
(O) => O.method === "placement.bind"
|
|
3070
|
-
);
|
|
3071
|
-
_.length && await this.safeCall(
|
|
3072
|
-
() => this.bx.batch(
|
|
3073
|
-
Object.fromEntries(
|
|
3074
|
-
_.map((O, S) => [`unbind_${S}`, O])
|
|
3075
|
-
)
|
|
3076
|
-
)
|
|
3077
|
-
), R.length && await this.safeCall(
|
|
3064
|
+
}), A.length ? await this.safeCall(
|
|
3078
3065
|
() => this.bx.batch(
|
|
3079
3066
|
Object.fromEntries(
|
|
3080
|
-
|
|
3067
|
+
A.map((y, k) => [`placement_${k}`, y])
|
|
3081
3068
|
)
|
|
3082
3069
|
)
|
|
3083
|
-
)
|
|
3070
|
+
) : console.log("setBackgroundWorkerAll: Нет операций");
|
|
3084
3071
|
}
|
|
3085
3072
|
async resolveAdmins() {
|
|
3086
3073
|
var e, t;
|
|
@@ -3170,11 +3157,11 @@ qt = new WeakSet(), Ie = function(e) {
|
|
|
3170
3157
|
return t ? _e(t) ? (console.error(
|
|
3171
3158
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3172
3159
|
), "") : t : "";
|
|
3173
|
-
},
|
|
3160
|
+
}, at = new WeakSet(), mt = function() {
|
|
3174
3161
|
var e, t;
|
|
3175
3162
|
return this.coordinationScope === "portal" ? `${this.appCodeName || "app"}:portal` : String(((t = (e = this.bx) == null ? void 0 : e.userInfo) == null ? void 0 : t.ID) ?? "");
|
|
3176
3163
|
}, zt = new WeakSet(), De = function() {
|
|
3177
|
-
return `background-worker:${this.entityName}:${
|
|
3164
|
+
return `background-worker:${this.entityName}:${N(this, at, mt).call(this)}`;
|
|
3178
3165
|
};
|
|
3179
3166
|
export {
|
|
3180
3167
|
je as BackgroundWorker,
|