szdl-utils-kit 0.3.18 → 0.3.20
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 +651 -634
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
var ge = Object.defineProperty;
|
|
2
|
-
var ye = (
|
|
3
|
-
var
|
|
4
|
-
if (!t.has(
|
|
2
|
+
var ye = (y, t, e) => t in y ? ge(y, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : y[t] = e;
|
|
3
|
+
var H = (y, t, e) => (ye(y, typeof t != "symbol" ? t + "" : t, e), e), Wt = (y, t, e) => {
|
|
4
|
+
if (!t.has(y))
|
|
5
5
|
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (t.has(
|
|
7
|
+
var M = (y, t, e) => (Wt(y, t, "read from private field"), e ? e.call(y) : t.get(y)), L = (y, t, e) => {
|
|
8
|
+
if (t.has(y))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
t instanceof WeakSet ? t.add(
|
|
11
|
-
},
|
|
12
|
-
var _ = (
|
|
10
|
+
t instanceof WeakSet ? t.add(y) : t.set(y, e);
|
|
11
|
+
}, x = (y, t, e, r) => (Wt(y, t, "write to private field"), r ? r.call(y, e) : t.set(y, e), e);
|
|
12
|
+
var _ = (y, t, e) => (Wt(y, t, "access private method"), e);
|
|
13
13
|
var pe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
-
function Ne(
|
|
15
|
-
return
|
|
14
|
+
function Ne(y) {
|
|
15
|
+
return y && y.__esModule && Object.prototype.hasOwnProperty.call(y, "default") ? y.default : y;
|
|
16
16
|
}
|
|
17
17
|
var Xt = { exports: {} };
|
|
18
|
-
(function(
|
|
18
|
+
(function(y, t) {
|
|
19
19
|
(function(e) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
21
|
+
var m, g;
|
|
22
|
+
for (m = o || 0, g = this.length; m < g; m += 1)
|
|
23
|
+
if (this[m] === s)
|
|
24
|
+
return m;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
27
|
var r = this, i = function(s, o) {
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
28
|
+
for (var m = s.toString(); m.length < o; )
|
|
29
|
+
m = "0" + m;
|
|
30
|
+
return m;
|
|
31
31
|
}, a = function(s, o) {
|
|
32
32
|
return o !== e ? (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) : e;
|
|
33
|
-
},
|
|
34
|
-
var
|
|
35
|
-
return
|
|
33
|
+
}, c = function(s, o) {
|
|
34
|
+
var m, g = "";
|
|
35
|
+
return m = s.slice(o, o + 1), m !== "" && !isNaN(Number(m)) && (g += "%H"), m = s.charAt(o + 2), m !== "" && m === ":" && (g += m), m = s.slice(o + 3, o + 4), m !== "" && !isNaN(Number(m)) && (g += "%M"), m = s.charAt(o + 5), m !== "" && m === ":" && (g += m), m = s.slice(o + 6, o + 7), m !== "" && !isNaN(Number(m)) && (g += "%S"), g;
|
|
36
36
|
}, l = function(s, o) {
|
|
37
|
-
var
|
|
37
|
+
var m, g = [
|
|
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(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ?
|
|
43
|
+
], B;
|
|
44
|
+
return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? m = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? m = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (m = "%m/%d/%Y"), m) : (B = [
|
|
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, f,
|
|
50
|
+
], !isNaN(Number(B[0])) && !isNaN(Number(B[2])) && !isNaN(Number(B[4])) ? (B[1] === "-" && B[3] === "-" && (m = "%Y-%m-%d"), m) : "");
|
|
51
|
+
}, u = r.tempus, n, f, d = r.navigator || {}, A = "en", h = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -211,61 +211,61 @@ var Xt = { exports: {} };
|
|
|
211
211
|
}
|
|
212
212
|
}, O = function() {
|
|
213
213
|
return [
|
|
214
|
-
h[
|
|
215
|
-
h[
|
|
216
|
-
h[
|
|
217
|
-
h[
|
|
218
|
-
h[
|
|
219
|
-
h[
|
|
220
|
-
h[
|
|
221
|
-
h[
|
|
222
|
-
h[
|
|
223
|
-
h[
|
|
224
|
-
h[
|
|
225
|
-
h[
|
|
214
|
+
h[A].JANUARY_LONG,
|
|
215
|
+
h[A].FEBRUARY_LONG,
|
|
216
|
+
h[A].MARCH_LONG,
|
|
217
|
+
h[A].APRIL_LONG,
|
|
218
|
+
h[A].MAY_LONG,
|
|
219
|
+
h[A].JUNE_LONG,
|
|
220
|
+
h[A].JULY_LONG,
|
|
221
|
+
h[A].AUGUST_LONG,
|
|
222
|
+
h[A].SEPTEMBER_LONG,
|
|
223
|
+
h[A].OCTOBER_LONG,
|
|
224
|
+
h[A].NOVEMBER_LONG,
|
|
225
|
+
h[A].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
227
|
}, T = function() {
|
|
228
228
|
return [
|
|
229
|
-
h[
|
|
230
|
-
h[
|
|
231
|
-
h[
|
|
232
|
-
h[
|
|
233
|
-
h[
|
|
234
|
-
h[
|
|
235
|
-
h[
|
|
236
|
-
h[
|
|
237
|
-
h[
|
|
238
|
-
h[
|
|
239
|
-
h[
|
|
240
|
-
h[
|
|
229
|
+
h[A].JANUARY_SHORT,
|
|
230
|
+
h[A].FEBRUARY_SHORT,
|
|
231
|
+
h[A].MARCH_SHORT,
|
|
232
|
+
h[A].APRIL_SHORT,
|
|
233
|
+
h[A].MAY_SHORT,
|
|
234
|
+
h[A].JUNE_SHORT,
|
|
235
|
+
h[A].JULY_SHORT,
|
|
236
|
+
h[A].AUGUST_SHORT,
|
|
237
|
+
h[A].SEPTEMBER_SHORT,
|
|
238
|
+
h[A].OCTOBER_SHORT,
|
|
239
|
+
h[A].NOVEMBER_SHORT,
|
|
240
|
+
h[A].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, R = function() {
|
|
243
243
|
return [
|
|
244
|
-
h[
|
|
245
|
-
h[
|
|
246
|
-
h[
|
|
247
|
-
h[
|
|
248
|
-
h[
|
|
249
|
-
h[
|
|
250
|
-
h[
|
|
244
|
+
h[A].SUNDAY_LONG,
|
|
245
|
+
h[A].MONDAY_LONG,
|
|
246
|
+
h[A].TUESDAY_LONG,
|
|
247
|
+
h[A].WEDNESDAY_LONG,
|
|
248
|
+
h[A].THURSDAY_LONG,
|
|
249
|
+
h[A].FRIDAY_LONG,
|
|
250
|
+
h[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, b = function() {
|
|
253
253
|
return [
|
|
254
|
-
h[
|
|
255
|
-
h[
|
|
256
|
-
h[
|
|
257
|
-
h[
|
|
258
|
-
h[
|
|
259
|
-
h[
|
|
260
|
-
h[
|
|
254
|
+
h[A].SUNDAY_SHORT,
|
|
255
|
+
h[A].MONDAY_SHORT,
|
|
256
|
+
h[A].TUESDAY_SHORT,
|
|
257
|
+
h[A].WEDNESDAY_SHORT,
|
|
258
|
+
h[A].THURSDAY_SHORT,
|
|
259
|
+
h[A].FRIDAY_SHORT,
|
|
260
|
+
h[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
},
|
|
262
|
+
}, p, S, C, N, I = function(s, o, m) {
|
|
263
263
|
var g;
|
|
264
264
|
r.XMLHttpRequest ? g = new XMLHttpRequest() : g = new ActiveXObject("Microsoft.XMLHTTP"), g.onreadystatechange = function() {
|
|
265
265
|
g.readyState === 4 && (g.status === 200 ? o && (r.JSON === e ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) :
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) : m && m(g));
|
|
267
267
|
}, g.open("GET", s, !1), g.send();
|
|
268
|
-
},
|
|
268
|
+
}, E = {
|
|
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 N[o !== e ? 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 C[o !== e ? 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 S[o !== e ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(s) {
|
|
346
346
|
var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
@@ -353,7 +353,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
353
353
|
"%B": {
|
|
354
354
|
format: function(s) {
|
|
355
355
|
var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
|
|
356
|
-
return
|
|
356
|
+
return p[o !== e ? o : n.MIN_MONTH];
|
|
357
357
|
},
|
|
358
358
|
parse: function(s) {
|
|
359
359
|
var o = n.monthNames(!0).indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
@@ -415,10 +415,10 @@ 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)), m = Number(s.slice(5, 7)), g = Number(s.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: o,
|
|
421
|
-
month:
|
|
421
|
+
month: m,
|
|
422
422
|
day: g
|
|
423
423
|
};
|
|
424
424
|
},
|
|
@@ -431,22 +431,22 @@ 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)), m = Number(s.slice(3, 5)), g = Number(s.slice(6, 10));
|
|
435
435
|
return {
|
|
436
436
|
year: g,
|
|
437
437
|
month: o,
|
|
438
|
-
day:
|
|
438
|
+
day: m
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
442
442
|
maxLength: 10,
|
|
443
443
|
type: "string"
|
|
444
444
|
}
|
|
445
|
-
},
|
|
445
|
+
}, k = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, w;
|
|
449
|
+
w = function(s, o, m) {
|
|
450
450
|
return this._d = /* @__PURE__ */ new Date(), this._i = {
|
|
451
451
|
year: !1,
|
|
452
452
|
month: !1,
|
|
@@ -455,56 +455,56 @@ 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 !== e && this.set(s, o,
|
|
459
|
-
},
|
|
458
|
+
}, s !== e && this.set(s, o, m), this;
|
|
459
|
+
}, w.fn = w.prototype, w.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;
|
|
462
|
-
},
|
|
462
|
+
}, w.fn.year = function(s) {
|
|
463
463
|
if (arguments.length !== 0)
|
|
464
464
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_YEAR && Number(s) <= n.MAX_YEAR ? (this._d.setFullYear(Number(s)), this._i.year = !1) : this._i.year = Number(s) : (this._d.setFullYear(n.MIN_YEAR), this._i.year = !1);
|
|
465
465
|
else
|
|
466
466
|
return this._i.year === !1 ? this._d.getFullYear() : this._i.year;
|
|
467
467
|
return this;
|
|
468
|
-
},
|
|
468
|
+
}, w.fn.month = function(s) {
|
|
469
469
|
if (arguments.length !== 0)
|
|
470
470
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MONTH && Number(s) <= n.MAX_MONTH ? (this._d.setMonth(n.options("monthFromZero") ? Number(s) : Number(s) - 1), this._i.month = !1) : this._i.month = Number(s) : (this._d.setMonth(n.options("monthFromZero") ? n.MIN_MONTH : n.MIN_MONTH - 1), this._i.month = !1);
|
|
471
471
|
else
|
|
472
472
|
return this._i.month === !1 ? n.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
|
|
473
473
|
return this;
|
|
474
|
-
},
|
|
474
|
+
}, w.fn.day = function(s) {
|
|
475
475
|
if (arguments.length !== 0)
|
|
476
476
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_DAY && Number(s) <= this.dayCount() ? (this._d.setDate(Number(s)), this._i.day = !1) : this._i.day = Number(s) : (this._d.setDate(n.MIN_DAY), this._i.day = !1);
|
|
477
477
|
else
|
|
478
478
|
return this._i.day === !1 ? this._d.getDate() : this._i.day;
|
|
479
479
|
return this;
|
|
480
|
-
},
|
|
480
|
+
}, w.fn.hours = function(s) {
|
|
481
481
|
if (arguments.length !== 0)
|
|
482
482
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_HOURS && Number(s) <= n.MAX_HOURS ? (this._d.setHours(Number(s)), this._i.hours = !1) : this._i.hours = Number(s) : (this._d.setHours(n.MIN_HOURS), this._i.hours = !1);
|
|
483
483
|
else
|
|
484
484
|
return this._i.hours === !1 ? this._d.getHours() : this._i.hours;
|
|
485
485
|
return this;
|
|
486
|
-
},
|
|
486
|
+
}, w.fn.minutes = function(s) {
|
|
487
487
|
if (arguments.length !== 0)
|
|
488
488
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MINUTES && Number(s) <= n.MAX_MINUTES ? (this._d.setMinutes(Number(s)), this._i.minutes = !1) : this._i.minutes = Number(s) : (this._d.setMinutes(n.MIN_MINUTES), this._i.minutes = !1);
|
|
489
489
|
else
|
|
490
490
|
return this._i.minutes === !1 ? this._d.getMinutes() : this._i.minutes;
|
|
491
491
|
return this;
|
|
492
|
-
},
|
|
492
|
+
}, w.fn.seconds = function(s) {
|
|
493
493
|
if (arguments.length !== 0)
|
|
494
494
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_SECONDS && Number(s) <= n.MAX_SECONDS ? (this._d.setSeconds(Number(s)), this._i.seconds = !1) : this._i.seconds = Number(s) : (this._d.setSeconds(n.MIN_SECONDS), this._i.seconds = !1);
|
|
495
495
|
else
|
|
496
496
|
return this._i.seconds === !1 ? this._d.getSeconds() : this._i.seconds;
|
|
497
497
|
return this;
|
|
498
|
-
},
|
|
498
|
+
}, w.fn.milliseconds = function(s) {
|
|
499
499
|
if (arguments.length !== 0)
|
|
500
500
|
(typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MILLISECONDS && Number(s) <= n.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(s)), this._i.milliseconds = !1) : this._i.milliseconds = Number(s) : (this._d.setMilliseconds(n.MIN_MILLISECONDS), this._i.milliseconds = !1);
|
|
501
501
|
else
|
|
502
502
|
return this._i.milliseconds === !1 ? this._d.getMilliseconds() : this._i.milliseconds;
|
|
503
503
|
return this;
|
|
504
|
-
},
|
|
504
|
+
}, w.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
|
-
},
|
|
507
|
+
}, w.fn.set = function(s, o, m) {
|
|
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 g,
|
|
523
|
+
var g, B = [], D, U, z = [], W = 0, F = 0, G, J, Y = {}, P;
|
|
524
524
|
if (s === e)
|
|
525
|
-
return
|
|
525
|
+
return D = a(this, m), D === e && (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
|
+
}), D;
|
|
534
534
|
for (o === e && (o = n.detectFormat(s)); W < o.length; ) {
|
|
535
535
|
if (o.charAt(W) === "%") {
|
|
536
|
-
if (
|
|
537
|
-
switch (G = 0, J = "",
|
|
536
|
+
if (U = o.charAt(W) + o.charAt(W + 1), E[U] !== e) {
|
|
537
|
+
switch (G = 0, J = "", E[U].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (; G <
|
|
540
|
-
J += s.charAt(
|
|
539
|
+
for (; G < E[U].maxLength && F + G < s.length && !isNaN(Number(s.charAt(F + G))); )
|
|
540
|
+
J += s.charAt(F + G), G += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (; G <
|
|
544
|
-
J += s.charAt(
|
|
543
|
+
for (; G < E[U].maxLength && F + G < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + G)); )
|
|
544
|
+
J += s.charAt(F + G), G += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (; G <
|
|
548
|
-
J += s.charAt(
|
|
547
|
+
for (; G < E[U].maxLength && F + G < s.length; )
|
|
548
|
+
J += s.charAt(F + G), G += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (G <
|
|
552
|
-
return
|
|
551
|
+
if (G < E[U].minLength)
|
|
552
|
+
return D = a(this, m), D === e && (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
|
+
}), D;
|
|
561
|
+
B.push(U), z.push(J), G -= 1, F += G, W += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (s.charAt(
|
|
564
|
-
return
|
|
563
|
+
} else if (s.charAt(F) !== o.charAt(W))
|
|
564
|
+
return D = a(this, m), D === e && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -569,11 +569,11 @@ 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
|
-
}),
|
|
573
|
-
W += 1,
|
|
572
|
+
}), D;
|
|
573
|
+
W += 1, F += 1;
|
|
574
574
|
}
|
|
575
|
-
for (g in
|
|
576
|
-
|
|
575
|
+
for (g in B)
|
|
576
|
+
B.hasOwnProperty(g) && E.hasOwnProperty(B[g]) && (P = E[B[g]].parse(z[g]), Y = {
|
|
577
577
|
year: P.year !== e ? P.year : Y.year,
|
|
578
578
|
month: P.month !== e ? P.month : Y.month,
|
|
579
579
|
day: P.day !== e ? P.day : Y.day,
|
|
@@ -584,18 +584,18 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
584
584
|
this.day(n.MIN_DAY), this.year(Y.year), this.month(Y.month), this.day(Y.day), this.hours(Y.hours), this.minutes(Y.minutes), this.seconds(Y.seconds), this.milliseconds(Y.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
|
-
},
|
|
587
|
+
}, w.fn.leapYear = function() {
|
|
588
588
|
var s = this.year();
|
|
589
589
|
return s % 4 === 0 ? s % 100 === 0 ? s % 400 === 0 : !0 : !1;
|
|
590
|
-
},
|
|
590
|
+
}, w.fn.timestamp = function(s) {
|
|
591
591
|
return arguments.length !== 0 ? (this._d = new Date(Number(s) * (n.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : n.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
|
|
592
|
-
},
|
|
592
|
+
}, w.fn.utc = function(s) {
|
|
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
|
+
}, w.fn.dayOfWeek = function(s) {
|
|
595
595
|
if (s === "long")
|
|
596
|
-
return
|
|
596
|
+
return C[this._d.getDay()];
|
|
597
597
|
if (s === "short")
|
|
598
|
-
return
|
|
598
|
+
return N[this._d.getDay()];
|
|
599
599
|
if (s === e)
|
|
600
600
|
return this._d.getDay();
|
|
601
601
|
if (s === 0 || s === "Sunday")
|
|
@@ -612,7 +612,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
612
612
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
|
|
613
613
|
if (s === 6 || s === "Saturday")
|
|
614
614
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
|
|
615
|
-
},
|
|
615
|
+
}, w.fn.timezone = function(s) {
|
|
616
616
|
switch (s) {
|
|
617
617
|
case "hours":
|
|
618
618
|
return Math.floor(this._d.getTimezoneOffset() / 60);
|
|
@@ -621,7 +621,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
621
621
|
default:
|
|
622
622
|
return this._d.getTimezoneOffset() * 60;
|
|
623
623
|
}
|
|
624
|
-
},
|
|
624
|
+
}, w.fn.get = function(s) {
|
|
625
625
|
switch (s) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
@@ -670,148 +670,148 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
670
670
|
timestamp: this.timestamp()
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
},
|
|
674
|
-
for (var o = 0,
|
|
675
|
-
s.charAt(o) === "%" ? (g = s.charAt(o) + s.charAt(o + 1),
|
|
676
|
-
return
|
|
677
|
-
},
|
|
673
|
+
}, w.fn.format = function(s) {
|
|
674
|
+
for (var o = 0, m = "", g; o < s.length; )
|
|
675
|
+
s.charAt(o) === "%" ? (g = s.charAt(o) + s.charAt(o + 1), E[g] !== e ? (m += E[g].format(this), o += 1) : m += "%") : m += s.charAt(o), o += 1;
|
|
676
|
+
return m;
|
|
677
|
+
}, w.fn.valid = function() {
|
|
678
678
|
return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
|
|
679
|
-
},
|
|
679
|
+
}, w.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var
|
|
681
|
+
}, w.fn.between = function(s, o) {
|
|
682
|
+
var m = this.timestamp(), g = s.timestamp();
|
|
683
683
|
switch (o) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((g -
|
|
685
|
+
return Math.floor((g - m) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((g -
|
|
687
|
+
return Math.floor((g - m) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((g -
|
|
689
|
+
return Math.floor((g - m) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((g -
|
|
691
|
+
return Math.floor((g - m) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((g -
|
|
693
|
+
return Math.floor((g - m) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return g -
|
|
695
|
+
return g - m;
|
|
696
696
|
default:
|
|
697
697
|
return e;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
699
|
+
}, w.fn.calc = function(s) {
|
|
700
700
|
return s.year !== e && this._d.setFullYear(this._d.getFullYear() + s.year), s.month !== e && this._d.setMonth(this._d.getMonth() + s.month), s.day !== e && this._d.setDate(this._d.getDate() + s.day), s.hours !== e && this._d.setHours(this._d.getHours() + s.hours), s.minutes !== e && this._d.setMinutes(this._d.getMinutes() + s.minutes), s.seconds !== e && this._d.setSeconds(this._d.getSeconds() + s.seconds), s.milliseconds !== e && this._d.setMilliseconds(this._d.getMilliseconds() + s.milliseconds), this;
|
|
701
|
-
}, n = function(s, o,
|
|
702
|
-
return new
|
|
701
|
+
}, n = function(s, o, m) {
|
|
702
|
+
return new w(s, o, m);
|
|
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 === e)
|
|
705
|
-
return
|
|
706
|
-
if (
|
|
705
|
+
return k;
|
|
706
|
+
if (k.hasOwnProperty(s)) {
|
|
707
707
|
if (o === e)
|
|
708
|
-
return
|
|
709
|
-
|
|
708
|
+
return k[s];
|
|
709
|
+
k[s] = o, s === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
|
|
710
710
|
}
|
|
711
711
|
return e;
|
|
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
|
|
715
|
+
var o, m, g, B, D, U, z, W;
|
|
716
|
+
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof w ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof w ? m = s.dateTo.utc() : m = n(s.dateTo, s.formatTo !== e ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? D = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
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" ? D = {
|
|
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" && (D = {
|
|
731
731
|
year: s.period.year !== e ? s.period.year : 0,
|
|
732
732
|
month: s.period.month !== e ? s.period.month : 0,
|
|
733
733
|
day: s.period.day !== e ? s.period.day : 0,
|
|
734
734
|
hours: s.period.hours !== e ? s.period.hours : 0,
|
|
735
735
|
minutes: s.period.minutes !== e ? s.period.minutes : 0,
|
|
736
736
|
seconds: s.period.seconds !== e ? s.period.seconds : 0
|
|
737
|
-
}), s.groupBy === e ?
|
|
737
|
+
}), s.groupBy === e ? U = s.asObject === !0 ? {} : [] : (U = [], U.push([]), z = n(o).get()[s.groupBy]), W = function(J, Y, P) {
|
|
738
738
|
return s.asObject === !0 ? s.format !== e ? J[n(Y).format(s.format)] = {} : J[n(Y).format("%F %H:%M:%S")] = {} : s.format !== e ? J.push(P ? null : n(Y).format(s.format)) : J.push(P ? null : n(Y)), J;
|
|
739
739
|
}, s.groupBy !== e && s.fillNulls) {
|
|
740
|
-
var
|
|
741
|
-
year:
|
|
742
|
-
month:
|
|
743
|
-
day:
|
|
744
|
-
hours:
|
|
745
|
-
minutes:
|
|
746
|
-
seconds:
|
|
747
|
-
milliseconds:
|
|
740
|
+
var F = {
|
|
741
|
+
year: D.year ? -D.year : e,
|
|
742
|
+
month: D.month ? -D.month : e,
|
|
743
|
+
day: D.day ? -D.day : e,
|
|
744
|
+
hours: D.hours ? -D.hours : e,
|
|
745
|
+
minutes: D.minutes ? -D.minutes : e,
|
|
746
|
+
seconds: D.seconds ? -D.seconds : e,
|
|
747
|
+
milliseconds: D.milliseconds ? -D.milliseconds : e
|
|
748
748
|
};
|
|
749
|
-
for (g = n(o).calc(
|
|
750
|
-
W(
|
|
749
|
+
for (g = n(o).calc(F).utc(); n(g).get()[s.groupBy] === z; )
|
|
750
|
+
W(U[U.length - 1], g, !0), g = n(g).calc(F).utc();
|
|
751
751
|
if (s.groupBy === "week") {
|
|
752
752
|
var G = n(o).dayOfWeek();
|
|
753
|
-
for (g = n(o).dayOfWeek(0).utc();
|
|
754
|
-
W(
|
|
753
|
+
for (g = n(o).dayOfWeek(0).utc(); U[0].length < G && g < o; )
|
|
754
|
+
W(U[U.length - 1], g, !0), g = n(g).calc(D).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; o <=
|
|
758
|
-
s.groupBy === e ? W(
|
|
757
|
+
for (; o <= m; )
|
|
758
|
+
s.groupBy === e ? W(U, o) : n(o).get()[s.groupBy] === z ? W(U[U.length - 1], o) : (U.push([]), W(U[U.length - 1], o), z = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
|
|
759
759
|
if (s.groupBy !== e && s.fillNulls)
|
|
760
|
-
for (
|
|
761
|
-
W(
|
|
762
|
-
return
|
|
760
|
+
for (B = n(m).calc(D).utc(); n(B).get()[s.groupBy] === z; )
|
|
761
|
+
W(U[U.length - 1], B, !0), B = n(B).calc(D).utc();
|
|
762
|
+
return U;
|
|
763
763
|
}, n.monthNames = function(s) {
|
|
764
764
|
switch (s) {
|
|
765
765
|
case "long":
|
|
766
|
-
return
|
|
766
|
+
return p;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return S;
|
|
769
769
|
}
|
|
770
770
|
}, n.dayNames = function(s) {
|
|
771
771
|
switch (s) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return C;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return N;
|
|
776
776
|
}
|
|
777
777
|
}, n.lang = function(s) {
|
|
778
778
|
if (s !== e)
|
|
779
|
-
|
|
779
|
+
A = s, h[A] === e && (A = "en"), p = O(), S = T(), C = R(), N = b();
|
|
780
780
|
else
|
|
781
|
-
return
|
|
781
|
+
return A;
|
|
782
782
|
return e;
|
|
783
783
|
}, n.availableLangs = function() {
|
|
784
784
|
return Object.keys(h);
|
|
785
|
-
}, n.registerFormat = function(s, o,
|
|
786
|
-
|
|
785
|
+
}, n.registerFormat = function(s, o, m, g, B, D) {
|
|
786
|
+
E[s] = {
|
|
787
787
|
format: o,
|
|
788
|
-
parse:
|
|
788
|
+
parse: m,
|
|
789
789
|
minLength: g,
|
|
790
|
-
maxLength:
|
|
791
|
-
type:
|
|
790
|
+
maxLength: B,
|
|
791
|
+
type: D
|
|
792
792
|
};
|
|
793
793
|
}, n.unregisterFormat = function(s) {
|
|
794
|
-
delete
|
|
794
|
+
delete E[s];
|
|
795
795
|
}, n.detectFormat = function(s) {
|
|
796
|
-
var o,
|
|
797
|
-
return o = l(s, 0), o !== "" && (g = 10),
|
|
796
|
+
var o, m, g;
|
|
797
|
+
return o = l(s, 0), o !== "" && (g = 10), m = s.charAt(g), (m === "T" || m === " ") && (o += m, g += 1), o += c(s, g), o;
|
|
798
798
|
}, f = {
|
|
799
|
-
TempusDate:
|
|
799
|
+
TempusDate: w
|
|
800
800
|
}, n.classes = function(s, o) {
|
|
801
801
|
if (o === e)
|
|
802
802
|
return f[s];
|
|
803
803
|
f[s] = o;
|
|
804
804
|
}, n.loadTranslations = function(s) {
|
|
805
|
-
typeof s == "object" ? h = s : typeof s == "string" &&
|
|
805
|
+
typeof s == "object" ? h = s : typeof s == "string" && I(s, function(o) {
|
|
806
806
|
h = o;
|
|
807
807
|
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
},
|
|
809
|
+
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), h[A] === e && (A = "en"), p = O(), S = T(), C = R(), N = b(), y.exports && (t = y.exports = n), t.tempus = n;
|
|
810
810
|
}).call(pe);
|
|
811
811
|
})(Xt, Xt.exports);
|
|
812
812
|
var Oe = Xt.exports;
|
|
813
|
-
const
|
|
814
|
-
var
|
|
813
|
+
const Nt = /* @__PURE__ */ Ne(Oe);
|
|
814
|
+
var Tt, $t, Et, Rt, bt, Lt, at, Ot, St, te, It, ee, Q, it, $, lt, tt, ht, Mt, se, ut, Jt;
|
|
815
815
|
const j = class j {
|
|
816
816
|
constructor(t) {
|
|
817
817
|
/**
|
|
@@ -820,7 +820,7 @@ const j = class j {
|
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
L(this,
|
|
823
|
+
L(this, Tt);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
@@ -832,13 +832,13 @@ const j = class j {
|
|
|
832
832
|
* @param {{percent: number, allCount: number, allTotal: number}} snapshot - Текущий снимок прогресса.
|
|
833
833
|
* @returns {boolean} `true`, если нужно отправить callback прогресса.
|
|
834
834
|
*/
|
|
835
|
-
L(this,
|
|
835
|
+
L(this, St);
|
|
836
836
|
/**
|
|
837
837
|
* Уведомляет подписчиков о текущем состоянии лимита.
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
L(this,
|
|
841
|
+
L(this, It);
|
|
842
842
|
/**
|
|
843
843
|
* Включает состояние лимита, выдерживает паузу и затем выключает лимит.
|
|
844
844
|
* Используется как единый "cooldown" перед повторной отправкой chunk.
|
|
@@ -846,7 +846,7 @@ const j = class j {
|
|
|
846
846
|
* @param {number} [pauseMs=this.defaultPauseMs] - Длительность паузы; для batch по умолчанию 120 с, для `call()` — `callLimitPauseMs` (30 с).
|
|
847
847
|
* @returns {Promise<void>}
|
|
848
848
|
*/
|
|
849
|
-
L(this,
|
|
849
|
+
L(this, Q);
|
|
850
850
|
/**
|
|
851
851
|
* Проверяет operating-time в результате batch и ставит паузу,
|
|
852
852
|
* если сервер приблизился к лимиту выполнения.
|
|
@@ -871,7 +871,7 @@ const j = class j {
|
|
|
871
871
|
* @param {Object} params - Параметры REST-метода.
|
|
872
872
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
873
|
*/
|
|
874
|
-
L(this,
|
|
874
|
+
L(this, Mt);
|
|
875
875
|
/**
|
|
876
876
|
* Resets mutable runtime state before each public batch run.
|
|
877
877
|
* @param {Function} progressCall - Progress callback for current run.
|
|
@@ -892,10 +892,10 @@ const j = class j {
|
|
|
892
892
|
if (!this.progressData)
|
|
893
893
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
894
894
|
const t = this.totalBatchCommands || 0;
|
|
895
|
-
if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && _(this,
|
|
895
|
+
if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && _(this, Tt, $t).call(this)) {
|
|
896
896
|
let l = 0;
|
|
897
|
-
for (const
|
|
898
|
-
const h = this.progressData[
|
|
897
|
+
for (const A of this.batchCommandKeyOrder) {
|
|
898
|
+
const h = this.progressData[A];
|
|
899
899
|
if (!h)
|
|
900
900
|
continue;
|
|
901
901
|
const O = Number(h.total) || 0, T = Number(h.count) || 0;
|
|
@@ -903,8 +903,8 @@ const j = class j {
|
|
|
903
903
|
}
|
|
904
904
|
const u = l / t * 100;
|
|
905
905
|
let n = Math.max(0, Math.min(100, Math.floor(u)));
|
|
906
|
-
const f = t,
|
|
907
|
-
return { percent: n, allCount:
|
|
906
|
+
const f = t, d = Math.min(t, Math.floor(l));
|
|
907
|
+
return { percent: n, allCount: d, allTotal: f };
|
|
908
908
|
}
|
|
909
909
|
let e = 0, r = 0;
|
|
910
910
|
for (const l of Object.values(this.progressData)) {
|
|
@@ -914,8 +914,8 @@ const j = class j {
|
|
|
914
914
|
const i = Number(this.chunkRate) || 0;
|
|
915
915
|
let a = 0;
|
|
916
916
|
e ? a = r / e * 100 * i + this.totalProgress : r === 0 && e === 0 ? a = 100 * i + this.totalProgress : a = 100, a = Math.max(0, Math.min(a, 100));
|
|
917
|
-
let
|
|
918
|
-
return e > 0 && r >= e && (
|
|
917
|
+
let c = Math.floor(a);
|
|
918
|
+
return e > 0 && r >= e && (c = 100), { percent: c, allCount: r, allTotal: e };
|
|
919
919
|
}
|
|
920
920
|
/**
|
|
921
921
|
* Обновление данных прогресса выполнения
|
|
@@ -929,31 +929,31 @@ const j = class j {
|
|
|
929
929
|
if (!this.progressCall)
|
|
930
930
|
return;
|
|
931
931
|
const i = this.getData(e.data()), a = Array.isArray(i) ? i.length : 0;
|
|
932
|
-
let
|
|
932
|
+
let c = a;
|
|
933
933
|
if (typeof e.total == "function") {
|
|
934
934
|
const T = e.total();
|
|
935
935
|
if (T != null && T !== "") {
|
|
936
|
-
const
|
|
937
|
-
Number.isFinite(
|
|
936
|
+
const R = Number(T);
|
|
937
|
+
Number.isFinite(R) && (c = R);
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
|
-
r === "count" && (
|
|
940
|
+
r === "count" && (c = a);
|
|
941
941
|
let l = 1;
|
|
942
942
|
i && (l = a), this.progressData || (this.progressData = {});
|
|
943
|
-
const u = ((h = this.progressData[t]) == null ? void 0 : h.total) ?? 0, n = ((O = this.progressData[t]) == null ? void 0 : O.count) ?? 0, f = l + n,
|
|
943
|
+
const u = ((h = this.progressData[t]) == null ? void 0 : h.total) ?? 0, n = ((O = this.progressData[t]) == null ? void 0 : O.count) ?? 0, f = l + n, d = Math.max(u, c ?? 0, f);
|
|
944
944
|
if (this.progressData[t] = {
|
|
945
|
-
total:
|
|
946
|
-
count: Math.min(f,
|
|
945
|
+
total: d,
|
|
946
|
+
count: Math.min(f, d)
|
|
947
947
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
948
|
-
_(this, at,
|
|
948
|
+
_(this, at, Ot).call(this);
|
|
949
949
|
return;
|
|
950
950
|
}
|
|
951
|
-
_(this, at,
|
|
951
|
+
_(this, at, Ot).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
952
952
|
if (!this.progressCall) {
|
|
953
953
|
this.clearProgressData();
|
|
954
954
|
return;
|
|
955
955
|
}
|
|
956
|
-
_(this, at,
|
|
956
|
+
_(this, at, Ot).call(this);
|
|
957
957
|
const { percent: T } = this.progressPercent;
|
|
958
958
|
T >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
959
959
|
}, this.progressDelay));
|
|
@@ -978,7 +978,7 @@ const j = class j {
|
|
|
978
978
|
* @returns {void}
|
|
979
979
|
*/
|
|
980
980
|
setTimeLimitState(t, e, r) {
|
|
981
|
-
this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, _(this,
|
|
981
|
+
this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, _(this, It, ee).call(this);
|
|
982
982
|
}
|
|
983
983
|
/**
|
|
984
984
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1011,16 +1011,16 @@ const j = class j {
|
|
|
1011
1011
|
const a = i.filter || i.FILTER;
|
|
1012
1012
|
if (!a || typeof a != "object" || Array.isArray(a))
|
|
1013
1013
|
return [{ key: t, request: e }];
|
|
1014
|
-
for (const [
|
|
1015
|
-
if (!String(
|
|
1014
|
+
for (const [c, l] of Object.entries(a))
|
|
1015
|
+
if (!String(c).trim().startsWith("!") && Array.isArray(l) && l.length > this.filterChunkSize) {
|
|
1016
1016
|
const u = [];
|
|
1017
1017
|
for (let n = 0; n < l.length; n += this.filterChunkSize) {
|
|
1018
|
-
const f = l.slice(n, n + this.filterChunkSize),
|
|
1019
|
-
i.filter ? (
|
|
1020
|
-
key:
|
|
1021
|
-
request: { method: r, params:
|
|
1018
|
+
const f = l.slice(n, n + this.filterChunkSize), d = n === 0 ? t : `${t}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
|
|
1019
|
+
i.filter ? (A.filter = { ...a }, A.filter[c] = f) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[c] = f), u.push({
|
|
1020
|
+
key: d,
|
|
1021
|
+
request: { method: r, params: A },
|
|
1022
1022
|
originalKey: t,
|
|
1023
|
-
filterKey:
|
|
1023
|
+
filterKey: c,
|
|
1024
1024
|
chunkIndex: Math.floor(n / this.filterChunkSize)
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
@@ -1035,11 +1035,11 @@ const j = class j {
|
|
|
1035
1035
|
* @returns {Array} Объединенный массив результатов
|
|
1036
1036
|
*/
|
|
1037
1037
|
mergeSplitResults(t, e) {
|
|
1038
|
-
const r = [], i = String(e).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`),
|
|
1038
|
+
const r = [], i = String(e).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), c = Object.keys(t).filter((l) => a.test(l)).sort((l, u) => {
|
|
1039
1039
|
const n = l.match(/__chunk_(\d+)$/), f = u.match(/__chunk_(\d+)$/);
|
|
1040
1040
|
return n ? f ? parseInt(n[1]) - parseInt(f[1]) : 1 : -1;
|
|
1041
1041
|
});
|
|
1042
|
-
for (const l of
|
|
1042
|
+
for (const l of c) {
|
|
1043
1043
|
const u = t[l];
|
|
1044
1044
|
Array.isArray(u) ? r.push(...u) : u && r.push(u);
|
|
1045
1045
|
}
|
|
@@ -1062,10 +1062,10 @@ const j = class j {
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
callBatchWithTimeout(t, e) {
|
|
1064
1064
|
return new Promise((r, i) => {
|
|
1065
|
-
let a = !1,
|
|
1065
|
+
let a = !1, c = null;
|
|
1066
1066
|
const l = async (n) => {
|
|
1067
1067
|
if (!a) {
|
|
1068
|
-
a = !0,
|
|
1068
|
+
a = !0, c && clearTimeout(c);
|
|
1069
1069
|
try {
|
|
1070
1070
|
await Promise.resolve(e(n)), r();
|
|
1071
1071
|
} catch (f) {
|
|
@@ -1074,7 +1074,7 @@ const j = class j {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
}, u = async () => {
|
|
1076
1076
|
if (!a) {
|
|
1077
|
-
a = !0,
|
|
1077
|
+
a = !0, c && clearTimeout(c), console.warn(
|
|
1078
1078
|
`Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
|
|
1079
1079
|
);
|
|
1080
1080
|
const n = {};
|
|
@@ -1104,7 +1104,7 @@ const j = class j {
|
|
|
1104
1104
|
} catch (n) {
|
|
1105
1105
|
a || console.error("Error calling callBatch:", n);
|
|
1106
1106
|
}
|
|
1107
|
-
|
|
1107
|
+
c = setTimeout(async () => {
|
|
1108
1108
|
a || (console.warn(
|
|
1109
1109
|
`Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
|
|
1110
1110
|
), await u());
|
|
@@ -1131,37 +1131,37 @@ const j = class j {
|
|
|
1131
1131
|
*/
|
|
1132
1132
|
async batch(t, e, r = {}) {
|
|
1133
1133
|
_(this, ut, Jt).call(this, e);
|
|
1134
|
-
const i = {}, a = {},
|
|
1135
|
-
for (const [f,
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
1134
|
+
const i = {}, a = {}, c = {};
|
|
1135
|
+
for (const [f, d] of Object.entries(t)) {
|
|
1136
|
+
const A = this.arrayChunk(d);
|
|
1137
|
+
if (!A)
|
|
1138
1138
|
continue;
|
|
1139
|
-
const h = this.splitLargeFilters(f,
|
|
1139
|
+
const h = this.splitLargeFilters(f, A);
|
|
1140
1140
|
if (h.length === 1)
|
|
1141
|
-
a[f] =
|
|
1141
|
+
a[f] = A;
|
|
1142
1142
|
else {
|
|
1143
|
-
|
|
1143
|
+
c[f] = [];
|
|
1144
1144
|
for (const O of h)
|
|
1145
|
-
a[O.key] = O.request,
|
|
1145
|
+
a[O.key] = O.request, c[f].push(O.key);
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
1148
|
this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
|
|
1149
1149
|
(f) => {
|
|
1150
|
-
var
|
|
1151
|
-
return String(((
|
|
1150
|
+
var d;
|
|
1151
|
+
return String(((d = a[f]) == null ? void 0 : d.method) || "");
|
|
1152
1152
|
}
|
|
1153
1153
|
), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
|
|
1154
1154
|
let l = {}, u = 0;
|
|
1155
1155
|
const n = Object.keys(a).length;
|
|
1156
|
-
for (const [f,
|
|
1156
|
+
for (const [f, d] of Object.entries(a)) {
|
|
1157
1157
|
if (!this.canContinue)
|
|
1158
1158
|
break;
|
|
1159
|
-
if (l[f] =
|
|
1160
|
-
const
|
|
1159
|
+
if (l[f] = d, Object.keys(l).length >= this.limit || u + 1 === n) {
|
|
1160
|
+
const A = u + 1 === n;
|
|
1161
1161
|
await this.batchChunk(
|
|
1162
1162
|
l,
|
|
1163
1163
|
void 0,
|
|
1164
|
-
!
|
|
1164
|
+
!A,
|
|
1165
1165
|
{
|
|
1166
1166
|
disablePagination: !1,
|
|
1167
1167
|
oneBatch: !!(r != null && r.oneBatch)
|
|
@@ -1174,12 +1174,12 @@ const j = class j {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
u++;
|
|
1176
1176
|
}
|
|
1177
|
-
for (const [f,
|
|
1178
|
-
if (
|
|
1179
|
-
const
|
|
1180
|
-
for (const h of
|
|
1177
|
+
for (const [f, d] of Object.entries(c))
|
|
1178
|
+
if (d && d.length > 0) {
|
|
1179
|
+
const A = this.mergeSplitResults(i, f);
|
|
1180
|
+
for (const h of d)
|
|
1181
1181
|
delete i[h];
|
|
1182
|
-
i[f] =
|
|
1182
|
+
i[f] = A;
|
|
1183
1183
|
}
|
|
1184
1184
|
return Object.entries(this.errors).length && (i.errorsList = this.errors), e && e({ percent: 100 }), Promise.resolve(i);
|
|
1185
1185
|
}
|
|
@@ -1199,52 +1199,52 @@ const j = class j {
|
|
|
1199
1199
|
const f = this.arrayChunk(n);
|
|
1200
1200
|
if (!f)
|
|
1201
1201
|
continue;
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1202
|
+
const d = this.splitLargeFilters(u, f);
|
|
1203
|
+
if (d.length === 1)
|
|
1204
1204
|
i[u] = f;
|
|
1205
1205
|
else {
|
|
1206
1206
|
a[u] = [];
|
|
1207
|
-
for (const
|
|
1208
|
-
i[
|
|
1207
|
+
for (const A of d)
|
|
1208
|
+
i[A.key] = A.request, a[u].push(A.key);
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
1211
|
-
const
|
|
1211
|
+
const c = [], l = Object.entries(i);
|
|
1212
1212
|
for (let u = 0; u < l.length; u += this.limit) {
|
|
1213
1213
|
const n = l.slice(u, u + this.limit), f = {};
|
|
1214
|
-
for (const [
|
|
1214
|
+
for (const [d, A] of n) {
|
|
1215
1215
|
if (!this.canContinue)
|
|
1216
1216
|
break;
|
|
1217
|
-
f[
|
|
1217
|
+
f[d] = A;
|
|
1218
1218
|
}
|
|
1219
|
-
Object.keys(f).length > 0 &&
|
|
1219
|
+
Object.keys(f).length > 0 && c.push(f);
|
|
1220
1220
|
}
|
|
1221
|
-
this.chunkRate = (1 /
|
|
1222
|
-
for (const [u, n] of Object.entries(
|
|
1221
|
+
this.chunkRate = (1 / c.length).toFixed(5);
|
|
1222
|
+
for (const [u, n] of Object.entries(c)) {
|
|
1223
1223
|
if (!this.canContinue)
|
|
1224
1224
|
break;
|
|
1225
|
-
this.totalProgress = Math.round(Number(u) /
|
|
1226
|
-
const f = Number(u) ===
|
|
1227
|
-
await _(this, tt, ht).call(this, n, async (
|
|
1228
|
-
var
|
|
1229
|
-
for (const [
|
|
1225
|
+
this.totalProgress = Math.round(Number(u) / c.length * 100);
|
|
1226
|
+
const f = Number(u) === c.length - 1;
|
|
1227
|
+
await _(this, tt, ht).call(this, n, async (d) => {
|
|
1228
|
+
var A, h, O, T, R;
|
|
1229
|
+
for (const [b, p] of Object.entries(d)) {
|
|
1230
1230
|
if (!this.canContinue)
|
|
1231
1231
|
return;
|
|
1232
|
-
if (
|
|
1233
|
-
const
|
|
1234
|
-
this.errors[
|
|
1232
|
+
if (p.error()) {
|
|
1233
|
+
const E = (h = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : h.error, k = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1234
|
+
this.errors[b] = E && E.trim() || k && k.trim() || ((R = p.error()) == null ? void 0 : R.toString()) || "Неизвестная ошибка", r[b] = 0;
|
|
1235
1235
|
continue;
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
r[
|
|
1237
|
+
const S = this.getData(p.data()), C = Array.isArray(S) ? S.length : 0, I = typeof p.total == "function" && p.total() !== void 0 ? p.total() : C;
|
|
1238
|
+
r[b] = I, this.setProgressData({ key: b, value: p, type: "count" });
|
|
1239
1239
|
}
|
|
1240
|
-
await _(this, $, lt).call(this,
|
|
1240
|
+
await _(this, $, lt).call(this, d, !f);
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
1243
|
for (const [u, n] of Object.entries(a))
|
|
1244
1244
|
if (n && n.length > 0) {
|
|
1245
1245
|
let f = 0;
|
|
1246
|
-
for (const
|
|
1247
|
-
r[
|
|
1246
|
+
for (const d of n)
|
|
1247
|
+
r[d] !== void 0 && (f += r[d] || 0), delete r[d];
|
|
1248
1248
|
r[u] = f;
|
|
1249
1249
|
}
|
|
1250
1250
|
return Object.entries(this.errors).length && (r.errorsList = this.errors, this.errorLogger()), e && e({ percent: 100 }), Promise.resolve(r);
|
|
@@ -1257,36 +1257,36 @@ const j = class j {
|
|
|
1257
1257
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1258
1258
|
*/
|
|
1259
1259
|
async call({ method: t, params: e = {} }) {
|
|
1260
|
-
var r, i, a,
|
|
1260
|
+
var r, i, a, c, l, u, n;
|
|
1261
1261
|
for (; ; ) {
|
|
1262
|
-
const f = await _(this,
|
|
1262
|
+
const f = await _(this, Mt, se).call(this, t, e);
|
|
1263
1263
|
if (!f) {
|
|
1264
|
-
await _(this,
|
|
1264
|
+
await _(this, Q, it).call(this, this.callLimitPauseMs);
|
|
1265
1265
|
continue;
|
|
1266
1266
|
}
|
|
1267
|
-
const
|
|
1267
|
+
const d = {};
|
|
1268
1268
|
if (f != null && f.answer)
|
|
1269
1269
|
for (const [h, O] of Object.entries(f.answer))
|
|
1270
|
-
h !== "result" && O && (
|
|
1270
|
+
h !== "result" && O && (d[h] = O);
|
|
1271
1271
|
if (f.error()) {
|
|
1272
1272
|
const h = ((i = (r = f.error()) == null ? void 0 : r.ex) == null ? void 0 : i.error) ?? "";
|
|
1273
1273
|
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(h)) {
|
|
1274
|
-
await _(this,
|
|
1274
|
+
await _(this, Q, it).call(this, this.callLimitPauseMs);
|
|
1275
1275
|
continue;
|
|
1276
1276
|
}
|
|
1277
|
-
const O = ((a = f.error()) == null ? void 0 : a.toString()) || ((l = (
|
|
1277
|
+
const O = ((a = f.error()) == null ? void 0 : a.toString()) || ((l = (c = f.error()) == null ? void 0 : c.ex) == null ? void 0 : l.error_description) || ((n = (u = f.error()) == null ? void 0 : u.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
|
|
1278
1278
|
return {
|
|
1279
1279
|
success: !1,
|
|
1280
1280
|
data: !1,
|
|
1281
|
-
answer:
|
|
1281
|
+
answer: d,
|
|
1282
1282
|
error: O
|
|
1283
1283
|
};
|
|
1284
1284
|
}
|
|
1285
|
-
let
|
|
1286
|
-
return
|
|
1285
|
+
let A = f.data();
|
|
1286
|
+
return A != null && A.items && (A = A.items), {
|
|
1287
1287
|
success: !0,
|
|
1288
|
-
data:
|
|
1289
|
-
answer:
|
|
1288
|
+
data: A,
|
|
1289
|
+
answer: d,
|
|
1290
1290
|
error: null
|
|
1291
1291
|
};
|
|
1292
1292
|
}
|
|
@@ -1306,8 +1306,8 @@ const j = class j {
|
|
|
1306
1306
|
else {
|
|
1307
1307
|
e === "entity.item.get" ? (r.SORT || (r.SORT = { ID: "ASC" }), Array.isArray(r.select) ? r.select.includes("ID") || r.select.push("ID") : r.select = ["ID"]) : e === "tasks.task.list" ? (r.order || (r.order = {}), r.order.ID = "asc") : e === "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");
|
|
1308
1308
|
const i = e === "user.get" || e === "entity.item.get" ? r.FILTER : r.filter;
|
|
1309
|
-
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a,
|
|
1310
|
-
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof
|
|
1309
|
+
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, c]) => {
|
|
1310
|
+
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof c == "string" || Array.isArray(c) && c.length <= 50) && (r.start = -1);
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
1313
|
e === "crm.type.list" && r.order && delete r.order.ID;
|
|
@@ -1317,7 +1317,7 @@ const j = class j {
|
|
|
1317
1317
|
r = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
1318
1318
|
else {
|
|
1319
1319
|
Array.isArray(r[0]) && (r[0] = {});
|
|
1320
|
-
const [i, a,
|
|
1320
|
+
const [i, a, c, l] = r;
|
|
1321
1321
|
i.ID = "ASC", l[0] !== "" && l.includes("ID") || l.push("ID");
|
|
1322
1322
|
}
|
|
1323
1323
|
return { method: e, params: r };
|
|
@@ -1330,42 +1330,42 @@ const j = class j {
|
|
|
1330
1330
|
*/
|
|
1331
1331
|
async batchChunk(t, e, r = !0, i = {}) {
|
|
1332
1332
|
return new Promise((a) => {
|
|
1333
|
-
const
|
|
1333
|
+
const c = [];
|
|
1334
1334
|
let l;
|
|
1335
1335
|
const u = !!(i != null && i.disablePagination);
|
|
1336
1336
|
(async () => {
|
|
1337
1337
|
await _(this, tt, ht).call(this, t, async (f) => {
|
|
1338
|
-
var
|
|
1339
|
-
for (const [
|
|
1338
|
+
var A, h, O, T, R;
|
|
1339
|
+
for (const [b, p] of Object.entries(f)) {
|
|
1340
1340
|
if (!this.canContinue)
|
|
1341
1341
|
return;
|
|
1342
|
-
if (
|
|
1343
|
-
const g = (h = (
|
|
1344
|
-
this.errors[
|
|
1342
|
+
if (p.error()) {
|
|
1343
|
+
const g = (h = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : h.error, B = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1344
|
+
this.errors[b] = g && g.trim() || B && B.trim() || ((R = p.error()) == null ? void 0 : R.toString()) || "Неизвестная ошибка", l = !0;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
e === "count" ? this.result[
|
|
1348
|
-
const
|
|
1349
|
-
if (!u && (!this.canContinue ||
|
|
1350
|
-
let g = t[
|
|
1346
|
+
const S = this.getData(p.data()), C = Array.isArray(S) ? S.length : 0, N = typeof p.total == "function" && p.total() !== void 0, I = N ? p.total() : C;
|
|
1347
|
+
e === "count" ? this.result[b] ? this.result[b] += C : this.result[b] = I : this.result[b] = S, this.setProgressData({ key: b, value: p, type: e });
|
|
1348
|
+
const E = t[b], k = Array.isArray(E) ? E[0] : E == null ? void 0 : E.method, w = typeof k == "string" && (k.includes(".list") || k === "user.get" || k === "entity.item.get"), s = e === "count" ? !N && C === this.limit : w ? C === this.limit : I > this.limit && I > C, o = e !== "count" && k === "entity.item.get" && C === this.limit && !s, m = s || o;
|
|
1349
|
+
if (!u && (!this.canContinue || m)) {
|
|
1350
|
+
let g = t[b];
|
|
1351
1351
|
if (Array.isArray(g)) {
|
|
1352
|
-
const [
|
|
1353
|
-
g = [
|
|
1352
|
+
const [B, D = {}] = g;
|
|
1353
|
+
g = [B, D];
|
|
1354
1354
|
} else {
|
|
1355
|
-
const { method:
|
|
1356
|
-
g = [
|
|
1355
|
+
const { method: B, params: D = {} } = g;
|
|
1356
|
+
g = [B, D];
|
|
1357
1357
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1358
|
+
c.push([
|
|
1359
|
+
b,
|
|
1360
1360
|
g,
|
|
1361
|
-
|
|
1361
|
+
I,
|
|
1362
1362
|
{ entityItemGetScan: o }
|
|
1363
1363
|
]);
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
l > 0 && this.errorLogger();
|
|
1367
|
-
const
|
|
1368
|
-
await _(this, $, lt).call(this, f,
|
|
1367
|
+
const d = c.length > 0 || r;
|
|
1368
|
+
await _(this, $, lt).call(this, f, d), c.length ? await this.batchPayload(c, e, i).then(
|
|
1369
1369
|
() => a(this.result)
|
|
1370
1370
|
) : a(this.result);
|
|
1371
1371
|
});
|
|
@@ -1378,96 +1378,96 @@ const j = class j {
|
|
|
1378
1378
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1379
1379
|
*/
|
|
1380
1380
|
async batchPayload(t, e, r = {}) {
|
|
1381
|
-
const i = !!(r != null && r.oneBatch), a = (O, T,
|
|
1382
|
-
let
|
|
1383
|
-
this.result[O][this.result[O].length - 1].ID || (
|
|
1384
|
-
let
|
|
1385
|
-
if (JSON.stringify(
|
|
1381
|
+
const i = !!(r != null && r.oneBatch), a = (O, T, R, b) => {
|
|
1382
|
+
let p = "ID";
|
|
1383
|
+
this.result[O][this.result[O].length - 1].ID || (p = "id");
|
|
1384
|
+
let S = `${p}`;
|
|
1385
|
+
if (JSON.stringify(b[1]).toLocaleLowerCase().includes('"id":"desc"') ? S = "<" + S : S = ">" + S, T === 1 || R.length === 0)
|
|
1386
1386
|
return {
|
|
1387
|
-
field:
|
|
1388
|
-
id: this.result[O][this.result[O].length - 1][
|
|
1387
|
+
field: S,
|
|
1388
|
+
id: this.result[O][this.result[O].length - 1][p]
|
|
1389
1389
|
};
|
|
1390
|
-
let
|
|
1391
|
-
const [
|
|
1392
|
-
return (
|
|
1393
|
-
field:
|
|
1394
|
-
id: `$result[${[O, T - 1].join("__")}]${
|
|
1390
|
+
let N = "";
|
|
1391
|
+
const [I, E] = b;
|
|
1392
|
+
return (I === "tasks.task.list" || I === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(I) && (N = "[items]"), I === "crm.type.list" && (N = "[types]"), I === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
|
|
1393
|
+
field: S,
|
|
1394
|
+
id: `$result[${[O, T - 1].join("__")}]${N}[49][${p}]`
|
|
1395
1395
|
};
|
|
1396
|
-
},
|
|
1397
|
-
const [
|
|
1398
|
-
let
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1401
|
-
const [
|
|
1402
|
-
return
|
|
1396
|
+
}, c = (O, T) => {
|
|
1397
|
+
const [R, b] = O;
|
|
1398
|
+
let p = JSON.parse(JSON.stringify(b)), S;
|
|
1399
|
+
if (R === "task.item.list") {
|
|
1400
|
+
p = [...p];
|
|
1401
|
+
const [C, N, I, E] = p;
|
|
1402
|
+
return N[T.field] = T.id, [R, p];
|
|
1403
1403
|
}
|
|
1404
|
-
return ["user.get"].includes(
|
|
1404
|
+
return ["user.get"].includes(R) || p.FILTER ? (p.FILTER || (p.FILTER = {}), S = p.FILTER) : (p.filter || (p.filter = {}), S = p.filter), [
|
|
1405
1405
|
"socialnetwork.api.workgroup.list",
|
|
1406
1406
|
"tasks.task.list"
|
|
1407
|
-
].includes(
|
|
1407
|
+
].includes(R) ? S[">ID"] = T.id : S[T.field] = T.id, [R, { ...p, start: -1 }];
|
|
1408
1408
|
}, l = (O) => {
|
|
1409
|
-
Object.entries(O).forEach(([T,
|
|
1410
|
-
var
|
|
1411
|
-
const [
|
|
1412
|
-
if (Array.isArray(
|
|
1413
|
-
const
|
|
1414
|
-
this.errors[
|
|
1409
|
+
Object.entries(O).forEach(([T, R]) => {
|
|
1410
|
+
var S, C, N, I, E;
|
|
1411
|
+
const [b] = T.split("__"), p = this.getData(R.data());
|
|
1412
|
+
if (Array.isArray(p) && (e === "count" ? this.result[b] += p.length : this.result[b].push(...p)), R.error()) {
|
|
1413
|
+
const k = (C = (S = R.error()) == null ? void 0 : S.ex) == null ? void 0 : C.error, w = (I = (N = R.error()) == null ? void 0 : N.ex) == null ? void 0 : I.error_description;
|
|
1414
|
+
this.errors[b] = k && k.trim() || w && w.trim() || ((E = R.error()) == null ? void 0 : E.toString()) || "Неизвестная ошибка";
|
|
1415
1415
|
}
|
|
1416
|
-
this.setProgressData({ key:
|
|
1416
|
+
this.setProgressData({ key: b, value: R, type: e });
|
|
1417
1417
|
});
|
|
1418
1418
|
}, u = (O, T) => {
|
|
1419
1419
|
if (!Array.isArray(O) || O.length === 0)
|
|
1420
1420
|
return null;
|
|
1421
|
-
const
|
|
1422
|
-
let
|
|
1423
|
-
|
|
1424
|
-
let
|
|
1425
|
-
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ?
|
|
1421
|
+
const R = O[O.length - 1];
|
|
1422
|
+
let b = "ID";
|
|
1423
|
+
R.ID || (b = "id");
|
|
1424
|
+
let p = b;
|
|
1425
|
+
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? p = "<" + p : p = ">" + p, { field: p, id: R[b] };
|
|
1426
1426
|
}, n = 1e4, f = async (O, T) => {
|
|
1427
|
-
var
|
|
1428
|
-
let
|
|
1429
|
-
for (let
|
|
1430
|
-
const
|
|
1431
|
-
if (!
|
|
1427
|
+
var b, p;
|
|
1428
|
+
let R = this.limit;
|
|
1429
|
+
for (let S = 1; this.canContinue && R === this.limit && S <= n; S++) {
|
|
1430
|
+
const C = this.result[O], N = u(C, T);
|
|
1431
|
+
if (!N)
|
|
1432
1432
|
break;
|
|
1433
|
-
const
|
|
1434
|
-
let
|
|
1435
|
-
await _(this, tt, ht).call(this, { [
|
|
1436
|
-
|
|
1433
|
+
const I = `${O}__eiscan_${S}`, E = c(T, N);
|
|
1434
|
+
let k = null;
|
|
1435
|
+
await _(this, tt, ht).call(this, { [I]: E }, async (m) => {
|
|
1436
|
+
k = m, l(m);
|
|
1437
1437
|
});
|
|
1438
|
-
const
|
|
1439
|
-
await _(this, $, lt).call(this,
|
|
1440
|
-
const s =
|
|
1441
|
-
if ((
|
|
1442
|
-
|
|
1438
|
+
const w = S < n;
|
|
1439
|
+
await _(this, $, lt).call(this, k, w), await this.delay();
|
|
1440
|
+
const s = k == null ? void 0 : k[I];
|
|
1441
|
+
if ((b = s == null ? void 0 : s.error) != null && b.call(s)) {
|
|
1442
|
+
R = 0;
|
|
1443
1443
|
break;
|
|
1444
1444
|
}
|
|
1445
|
-
const o = this.getData((
|
|
1446
|
-
|
|
1445
|
+
const o = this.getData((p = s == null ? void 0 : s.data) == null ? void 0 : p.call(s));
|
|
1446
|
+
R = Array.isArray(o) ? o.length : 0;
|
|
1447
1447
|
}
|
|
1448
1448
|
};
|
|
1449
|
-
let
|
|
1450
|
-
const h = async (O = !0) =>
|
|
1449
|
+
let d = [], A = 0;
|
|
1450
|
+
const h = async (O = !0) => d.length ? (await _(this, tt, ht).call(this, Object.fromEntries(d), async (T) => {
|
|
1451
1451
|
l(T), await _(this, $, lt).call(this, T, O);
|
|
1452
|
-
}),
|
|
1452
|
+
}), A++, d = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1453
1453
|
for await (const O of t) {
|
|
1454
1454
|
if (!this.canContinue)
|
|
1455
1455
|
return;
|
|
1456
|
-
const [T,
|
|
1457
|
-
if (
|
|
1456
|
+
const [T, R, b, p = {}] = O;
|
|
1457
|
+
if (p.entityItemGetScan) {
|
|
1458
1458
|
if (await h(!0))
|
|
1459
1459
|
return;
|
|
1460
1460
|
if (i)
|
|
1461
1461
|
continue;
|
|
1462
|
-
await f(T,
|
|
1462
|
+
await f(T, R);
|
|
1463
1463
|
continue;
|
|
1464
1464
|
}
|
|
1465
|
-
let
|
|
1466
|
-
for (;
|
|
1467
|
-
const
|
|
1468
|
-
if (
|
|
1465
|
+
let S = 1;
|
|
1466
|
+
for (; b > S * this.limit; ) {
|
|
1467
|
+
const C = [T, S].join("__"), N = a(T, S, d, R);
|
|
1468
|
+
if (d.push([C, c(R, N)]), i && d.length === 49 && await h(!0) || d.length % 50 === 0 && await h(!0))
|
|
1469
1469
|
return;
|
|
1470
|
-
|
|
1470
|
+
S++;
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
await h(!1);
|
|
@@ -1481,29 +1481,29 @@ const j = class j {
|
|
|
1481
1481
|
}), console.groupEnd();
|
|
1482
1482
|
}
|
|
1483
1483
|
};
|
|
1484
|
-
|
|
1484
|
+
Tt = new WeakSet(), $t = function() {
|
|
1485
1485
|
const t = this.totalBatchCommands || 0, e = this.batchCommandMethods;
|
|
1486
|
-
if (t <
|
|
1486
|
+
if (t < M(j, Et) || !Array.isArray(e) || e.length !== t)
|
|
1487
1487
|
return !1;
|
|
1488
|
-
if (e.filter((a) => a === "crm.deal.list").length >=
|
|
1488
|
+
if (e.filter((a) => a === "crm.deal.list").length >= M(j, Rt))
|
|
1489
1489
|
return !0;
|
|
1490
1490
|
const i = e.filter(
|
|
1491
1491
|
(a) => typeof a == "string" && a.includes(".list")
|
|
1492
1492
|
).length;
|
|
1493
|
-
return i >=
|
|
1494
|
-
},
|
|
1493
|
+
return i >= M(j, bt) && i / t >= M(j, Lt);
|
|
1494
|
+
}, Et = new WeakMap(), Rt = new WeakMap(), bt = new WeakMap(), Lt = new WeakMap(), at = new WeakSet(), Ot = function() {
|
|
1495
1495
|
if (!this.progressCall || !this.progressData)
|
|
1496
1496
|
return;
|
|
1497
1497
|
const { percent: t, allCount: e, allTotal: r } = this.progressPercent, i = { percent: t, allCount: e, allTotal: r };
|
|
1498
|
-
_(this,
|
|
1498
|
+
_(this, St, te).call(this, i) && (this.progressCall({
|
|
1499
1499
|
data: this.progressData,
|
|
1500
1500
|
percent: t,
|
|
1501
1501
|
allCount: e,
|
|
1502
1502
|
allTotal: r
|
|
1503
1503
|
}), this.lastProgressSnapshot = i);
|
|
1504
|
-
},
|
|
1504
|
+
}, St = new WeakSet(), te = function(t) {
|
|
1505
1505
|
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== t.percent || this.lastProgressSnapshot.allCount !== t.allCount || this.lastProgressSnapshot.allTotal !== t.allTotal : !0;
|
|
1506
|
-
},
|
|
1506
|
+
}, It = new WeakSet(), ee = function() {
|
|
1507
1507
|
const t = {
|
|
1508
1508
|
limit: this.timeLimit.limit,
|
|
1509
1509
|
date: this.timeLimit.date,
|
|
@@ -1515,7 +1515,7 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1515
1515
|
} catch (r) {
|
|
1516
1516
|
console.warn("Batch timeLimit listener error:", r);
|
|
1517
1517
|
}
|
|
1518
|
-
},
|
|
1518
|
+
}, Q = new WeakSet(), it = async function(t = this.defaultPauseMs) {
|
|
1519
1519
|
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), t), await new Promise((e) => setTimeout(e, t)), this.setTimeLimitState(!1, void 0);
|
|
1520
1520
|
}, $ = new WeakSet(), lt = async function(t, e = !0) {
|
|
1521
1521
|
if (!e)
|
|
@@ -1532,43 +1532,43 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1532
1532
|
}
|
|
1533
1533
|
} catch {
|
|
1534
1534
|
}
|
|
1535
|
-
r >= this.operatingThreshold && await _(this,
|
|
1535
|
+
r >= this.operatingThreshold && await _(this, Q, it).call(this);
|
|
1536
1536
|
}, tt = new WeakSet(), ht = async function(t, e) {
|
|
1537
1537
|
let r = !1, i = t;
|
|
1538
1538
|
do
|
|
1539
1539
|
r = !1, await this.callBatchWithTimeout(i, async (a) => {
|
|
1540
1540
|
var u, n;
|
|
1541
|
-
let
|
|
1541
|
+
let c = !1;
|
|
1542
1542
|
const l = /* @__PURE__ */ new Set();
|
|
1543
|
-
for (const [f,
|
|
1544
|
-
if (!(
|
|
1543
|
+
for (const [f, d] of Object.entries(a || {})) {
|
|
1544
|
+
if (!(d != null && d.error) || !d.error())
|
|
1545
1545
|
continue;
|
|
1546
|
-
const
|
|
1547
|
-
if (
|
|
1548
|
-
|
|
1546
|
+
const A = ((n = (u = d.error()) == null ? void 0 : u.ex) == null ? void 0 : n.error) ?? "";
|
|
1547
|
+
if (A === "TIMEOUT") {
|
|
1548
|
+
c = !0;
|
|
1549
1549
|
break;
|
|
1550
1550
|
}
|
|
1551
|
-
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(
|
|
1551
|
+
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && l.add(f);
|
|
1552
1552
|
}
|
|
1553
|
-
if (
|
|
1554
|
-
r = !0, await _(this,
|
|
1553
|
+
if (c) {
|
|
1554
|
+
r = !0, await _(this, Q, it).call(this);
|
|
1555
1555
|
return;
|
|
1556
1556
|
}
|
|
1557
1557
|
if (l.size > 0) {
|
|
1558
1558
|
const f = {};
|
|
1559
|
-
for (const [
|
|
1560
|
-
l.has(
|
|
1559
|
+
for (const [A, h] of Object.entries(a || {}))
|
|
1560
|
+
l.has(A) || (f[A] = h);
|
|
1561
1561
|
Object.keys(f).length && await e(f);
|
|
1562
|
-
const
|
|
1563
|
-
for (const
|
|
1564
|
-
i[
|
|
1565
|
-
i =
|
|
1562
|
+
const d = {};
|
|
1563
|
+
for (const A of l)
|
|
1564
|
+
i[A] && (d[A] = i[A]);
|
|
1565
|
+
i = d, Object.keys(i).length && (r = !0, await _(this, Q, it).call(this));
|
|
1566
1566
|
return;
|
|
1567
1567
|
}
|
|
1568
1568
|
await e(a);
|
|
1569
1569
|
});
|
|
1570
1570
|
while (r);
|
|
1571
|
-
},
|
|
1571
|
+
}, Mt = new WeakSet(), se = function(t, e) {
|
|
1572
1572
|
return new Promise((r) => {
|
|
1573
1573
|
if (typeof this.callMethod != "function") {
|
|
1574
1574
|
r(null);
|
|
@@ -1579,8 +1579,8 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1579
1579
|
i || (i = !0, r(null));
|
|
1580
1580
|
}, this.requestTimeoutMs);
|
|
1581
1581
|
try {
|
|
1582
|
-
this.callMethod(t, e, (
|
|
1583
|
-
i || (i = !0, clearTimeout(a), r(
|
|
1582
|
+
this.callMethod(t, e, (c) => {
|
|
1583
|
+
i || (i = !0, clearTimeout(a), r(c));
|
|
1584
1584
|
});
|
|
1585
1585
|
} catch {
|
|
1586
1586
|
i || (i = !0, clearTimeout(a), r(null));
|
|
@@ -1589,12 +1589,12 @@ _t = new WeakSet(), Vt = function() {
|
|
|
1589
1589
|
}, ut = new WeakSet(), Jt = function(t) {
|
|
1590
1590
|
this.clearProgressData(), this.progressCall = typeof t == "function" ? t : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
|
|
1591
1591
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1592
|
-
L(j,
|
|
1593
|
-
L(j,
|
|
1594
|
-
L(j,
|
|
1592
|
+
L(j, Et, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1593
|
+
L(j, Rt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1594
|
+
L(j, bt, 8), L(j, Lt, 0.65);
|
|
1595
1595
|
let v = j;
|
|
1596
1596
|
var et;
|
|
1597
|
-
class
|
|
1597
|
+
class re {
|
|
1598
1598
|
constructor() {
|
|
1599
1599
|
L(this, et, {});
|
|
1600
1600
|
}
|
|
@@ -1625,7 +1625,7 @@ class se {
|
|
|
1625
1625
|
* @param {Function} params.action - Функция для выполнения
|
|
1626
1626
|
*/
|
|
1627
1627
|
actionFilter({ keyTimer: t, duration: e = 10, action: r }) {
|
|
1628
|
-
|
|
1628
|
+
M(this, et)[t] && (clearTimeout(M(this, et)[t]), M(this, et)[t] = null), r && (M(this, et)[t] = setTimeout(() => {
|
|
1629
1629
|
r();
|
|
1630
1630
|
}, e));
|
|
1631
1631
|
}
|
|
@@ -1664,21 +1664,21 @@ class se {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
}
|
|
1666
1666
|
et = new WeakMap();
|
|
1667
|
-
const xt = new
|
|
1668
|
-
var K,
|
|
1667
|
+
const xt = new re();
|
|
1668
|
+
var K, q, st, ot, ft, Z, X, rt, At, Dt, ie, mt, jt, wt, ne, kt, ae, Bt, oe;
|
|
1669
1669
|
class _e {
|
|
1670
1670
|
constructor() {
|
|
1671
1671
|
/** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
|
|
1672
|
-
L(this,
|
|
1672
|
+
L(this, Dt);
|
|
1673
1673
|
/** Вывод ошибок логера
|
|
1674
1674
|
* @param {'entity'} type - тип ошибки
|
|
1675
1675
|
*/
|
|
1676
1676
|
L(this, mt);
|
|
1677
|
-
L(this, Dt);
|
|
1678
1677
|
L(this, wt);
|
|
1679
1678
|
L(this, kt);
|
|
1679
|
+
L(this, Bt);
|
|
1680
1680
|
L(this, K, "logger");
|
|
1681
|
-
L(this,
|
|
1681
|
+
L(this, q, !1);
|
|
1682
1682
|
L(this, st, /* @__PURE__ */ new Map());
|
|
1683
1683
|
L(this, ot, {});
|
|
1684
1684
|
L(this, ft, !1);
|
|
@@ -1687,7 +1687,7 @@ class _e {
|
|
|
1687
1687
|
L(this, rt, !1);
|
|
1688
1688
|
L(this, At, !1);
|
|
1689
1689
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1690
|
-
|
|
1690
|
+
H(this, "periodClear", 3);
|
|
1691
1691
|
}
|
|
1692
1692
|
/** Инициализация логера */
|
|
1693
1693
|
async init() {
|
|
@@ -1697,27 +1697,34 @@ class _e {
|
|
|
1697
1697
|
});
|
|
1698
1698
|
if (e && Array.isArray(e))
|
|
1699
1699
|
if (e.find(
|
|
1700
|
-
(i) => i.ENTITY ==
|
|
1700
|
+
(i) => i.ENTITY == M(this, K)
|
|
1701
1701
|
))
|
|
1702
|
-
|
|
1702
|
+
x(this, q, !0);
|
|
1703
1703
|
else {
|
|
1704
1704
|
let { entityAdd: i } = await t.batch({
|
|
1705
1705
|
entityAdd: {
|
|
1706
1706
|
method: "entity.add",
|
|
1707
1707
|
params: {
|
|
1708
|
-
ENTITY:
|
|
1709
|
-
NAME:
|
|
1708
|
+
ENTITY: M(this, K),
|
|
1709
|
+
NAME: M(this, K),
|
|
1710
1710
|
ACCESS: { AU: "X" }
|
|
1711
1711
|
}
|
|
1712
1712
|
}
|
|
1713
1713
|
});
|
|
1714
|
-
i &&
|
|
1714
|
+
i && x(this, q, !0);
|
|
1715
1715
|
}
|
|
1716
|
-
return
|
|
1716
|
+
return M(this, q);
|
|
1717
1717
|
} catch (t) {
|
|
1718
1718
|
return console.error("Ошибка при инициализации логера:", t), !1;
|
|
1719
1719
|
}
|
|
1720
1720
|
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Разрешает работу start/stop без init().
|
|
1723
|
+
* Используется в PAGE_BACKGROUND_WORKER, где не нужно делать entity.get/entity.add.
|
|
1724
|
+
*/
|
|
1725
|
+
enableBackworkerMode() {
|
|
1726
|
+
return x(this, q, !0), !0;
|
|
1727
|
+
}
|
|
1721
1728
|
/**
|
|
1722
1729
|
* @param {{ type: 'call'|'batch'|'batch-total-count';
|
|
1723
1730
|
* data: {
|
|
@@ -1728,7 +1735,7 @@ class _e {
|
|
|
1728
1735
|
* @returns {string|null}
|
|
1729
1736
|
*/
|
|
1730
1737
|
start({ type: t, data: e }) {
|
|
1731
|
-
if (!
|
|
1738
|
+
if (!M(this, q))
|
|
1732
1739
|
return _(this, mt, jt).call(this, "entity"), null;
|
|
1733
1740
|
if (!t || !e)
|
|
1734
1741
|
return console.error("Невалидные данные для логирования:", { type: t, data: e }), null;
|
|
@@ -1741,7 +1748,7 @@ class _e {
|
|
|
1741
1748
|
answer: null,
|
|
1742
1749
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1743
1750
|
};
|
|
1744
|
-
return
|
|
1751
|
+
return M(this, st).set(r, i), x(this, At, !0), r;
|
|
1745
1752
|
}
|
|
1746
1753
|
/**
|
|
1747
1754
|
* @param {{
|
|
@@ -1751,19 +1758,19 @@ class _e {
|
|
|
1751
1758
|
* answer: { [key]: unknown } }}
|
|
1752
1759
|
*/
|
|
1753
1760
|
async stop({ key: t, errorList: e, status: r, answer: i }) {
|
|
1754
|
-
var
|
|
1755
|
-
if (!
|
|
1761
|
+
var c;
|
|
1762
|
+
if (!M(this, At))
|
|
1756
1763
|
return;
|
|
1757
|
-
if (!
|
|
1764
|
+
if (!M(this, q)) {
|
|
1758
1765
|
_(this, mt, jt).call(this, "entity");
|
|
1759
1766
|
return;
|
|
1760
1767
|
}
|
|
1761
|
-
let a =
|
|
1768
|
+
let a = M(this, st).get(t);
|
|
1762
1769
|
if (!a) {
|
|
1763
1770
|
console.error(`Не найдены данные логирования для ключа: ${t}`);
|
|
1764
1771
|
return;
|
|
1765
1772
|
}
|
|
1766
|
-
e && (a.errorList = e), r && (a.status = r), i && (a.answer = i), await _(this,
|
|
1773
|
+
e && (a.errorList = e), r && (a.status = r), i && (a.answer = i), await _(this, Dt, ie).call(this), a.userInfo = M(this, ot), await _(this, wt, ne).call(this), (c = a == null ? void 0 : a.data) != null && c.updateList && x(this, rt, !0), x(this, At, !1);
|
|
1767
1774
|
}
|
|
1768
1775
|
/**
|
|
1769
1776
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1771,14 +1778,14 @@ class _e {
|
|
|
1771
1778
|
async getEntityList(t) {
|
|
1772
1779
|
var e;
|
|
1773
1780
|
try {
|
|
1774
|
-
if ((e =
|
|
1775
|
-
return
|
|
1781
|
+
if ((e = M(this, X)) != null && e.length && !M(this, rt))
|
|
1782
|
+
return M(this, X);
|
|
1776
1783
|
let r = new v(BX24.callBatch), { entityList: i } = await r.batch(
|
|
1777
1784
|
{
|
|
1778
1785
|
entityList: {
|
|
1779
1786
|
method: "entity.item.get",
|
|
1780
1787
|
params: {
|
|
1781
|
-
ENTITY:
|
|
1788
|
+
ENTITY: M(this, K),
|
|
1782
1789
|
SORT: { ID: "DESC" }
|
|
1783
1790
|
}
|
|
1784
1791
|
}
|
|
@@ -1787,19 +1794,19 @@ class _e {
|
|
|
1787
1794
|
);
|
|
1788
1795
|
return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
|
|
1789
1796
|
try {
|
|
1790
|
-
const { ID:
|
|
1797
|
+
const { ID: c, DATE_CREATE: l, DETAIL_TEXT: u } = a;
|
|
1791
1798
|
return {
|
|
1792
1799
|
...JSON.parse(u),
|
|
1793
|
-
id:
|
|
1800
|
+
id: c,
|
|
1794
1801
|
dateCreate: l
|
|
1795
1802
|
};
|
|
1796
|
-
} catch (
|
|
1803
|
+
} catch (c) {
|
|
1797
1804
|
return console.error(
|
|
1798
1805
|
`Ошибка парсинга записи ${a.ID}:`,
|
|
1799
|
-
|
|
1806
|
+
c
|
|
1800
1807
|
), null;
|
|
1801
1808
|
}
|
|
1802
|
-
}).filter((a) => a !== null),
|
|
1809
|
+
}).filter((a) => a !== null), x(this, rt, !1), x(this, X, i), i);
|
|
1803
1810
|
} catch (r) {
|
|
1804
1811
|
return console.error("Ошибка при получении списка записей:", r), [];
|
|
1805
1812
|
}
|
|
@@ -1809,16 +1816,16 @@ class _e {
|
|
|
1809
1816
|
* Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
|
|
1810
1817
|
*/
|
|
1811
1818
|
runStorageMaintenance() {
|
|
1812
|
-
return _(this,
|
|
1819
|
+
return _(this, kt, ae).call(this);
|
|
1813
1820
|
}
|
|
1814
1821
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1815
1822
|
async downAllEntityJson() {
|
|
1816
1823
|
try {
|
|
1817
|
-
if (
|
|
1824
|
+
if (M(this, X) || await this.getEntityList(), !M(this, X) || M(this, X).length === 0)
|
|
1818
1825
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1819
|
-
let t =
|
|
1826
|
+
let t = Nt().format("%Y-%m-%d");
|
|
1820
1827
|
return xt.downloadFileJson(
|
|
1821
|
-
|
|
1828
|
+
M(this, X),
|
|
1822
1829
|
`sdklogger-entity-data__${t}`
|
|
1823
1830
|
), !0;
|
|
1824
1831
|
} catch (t) {
|
|
@@ -1826,23 +1833,23 @@ class _e {
|
|
|
1826
1833
|
}
|
|
1827
1834
|
}
|
|
1828
1835
|
}
|
|
1829
|
-
K = new WeakMap(),
|
|
1830
|
-
if (!
|
|
1831
|
-
return
|
|
1836
|
+
K = new WeakMap(), q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft = new WeakMap(), Z = new WeakMap(), X = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), Dt = new WeakSet(), ie = async function() {
|
|
1837
|
+
if (!M(this, ft))
|
|
1838
|
+
return M(this, Z) ? M(this, Z) : (x(this, Z, (async () => {
|
|
1832
1839
|
try {
|
|
1833
1840
|
const t = new v(BX24.callBatch), e = BX24.isAdmin(), { curUser: r } = await t.batch({
|
|
1834
1841
|
curUser: { method: "user.current" }
|
|
1835
1842
|
});
|
|
1836
|
-
|
|
1843
|
+
x(this, ot, { isAdmin: e, curUser: r });
|
|
1837
1844
|
} catch (t) {
|
|
1838
1845
|
console.error(
|
|
1839
1846
|
"Ошибка при получении информации о пользователе:",
|
|
1840
1847
|
t
|
|
1841
|
-
),
|
|
1848
|
+
), x(this, ot, { isAdmin: !1, curUser: null });
|
|
1842
1849
|
} finally {
|
|
1843
|
-
|
|
1850
|
+
x(this, ft, !0), x(this, Z, null);
|
|
1844
1851
|
}
|
|
1845
|
-
})()),
|
|
1852
|
+
})()), M(this, Z));
|
|
1846
1853
|
}, mt = new WeakSet(), jt = function(t) {
|
|
1847
1854
|
t == "entity" && xt.actionFilter({
|
|
1848
1855
|
keyTimer: "error.logger.entity",
|
|
@@ -1851,32 +1858,32 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1851
1858
|
console.error("Хранилище для логгера не инициализировано");
|
|
1852
1859
|
}
|
|
1853
1860
|
});
|
|
1854
|
-
},
|
|
1861
|
+
}, wt = new WeakSet(), ne = async function() {
|
|
1855
1862
|
try {
|
|
1856
1863
|
let t = {}, e = new v(BX24.callBatch);
|
|
1857
|
-
for (let [r, i] of
|
|
1864
|
+
for (let [r, i] of M(this, st).entries())
|
|
1858
1865
|
if (i.status) {
|
|
1859
1866
|
const a = JSON.stringify(i);
|
|
1860
1867
|
t[r] = {
|
|
1861
1868
|
method: "entity.item.add",
|
|
1862
1869
|
params: {
|
|
1863
|
-
ENTITY:
|
|
1864
|
-
NAME:
|
|
1870
|
+
ENTITY: M(this, K),
|
|
1871
|
+
NAME: M(this, K),
|
|
1865
1872
|
DETAIL_TEXT: a
|
|
1866
1873
|
}
|
|
1867
1874
|
};
|
|
1868
1875
|
}
|
|
1869
1876
|
if (Object.keys(t).length) {
|
|
1870
1877
|
let r = await e.batch(t), { errors: i } = e;
|
|
1871
|
-
for (let [a,
|
|
1872
|
-
|
|
1878
|
+
for (let [a, c] of Object.entries({ ...r, ...i }))
|
|
1879
|
+
M(this, st).delete(a);
|
|
1873
1880
|
return !0;
|
|
1874
1881
|
}
|
|
1875
1882
|
return !1;
|
|
1876
1883
|
} catch (t) {
|
|
1877
1884
|
return console.error("Ошибка при добавлении записей в хранилище:", t), !1;
|
|
1878
1885
|
}
|
|
1879
|
-
},
|
|
1886
|
+
}, kt = new WeakSet(), ae = async function() {
|
|
1880
1887
|
try {
|
|
1881
1888
|
let t = new v(BX24.callBatch), { serverTime: e } = await t.batch({
|
|
1882
1889
|
serverTime: { method: "server.time" }
|
|
@@ -1885,13 +1892,13 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1885
1892
|
console.error("Не удалось получить время сервера");
|
|
1886
1893
|
return;
|
|
1887
1894
|
}
|
|
1888
|
-
if (
|
|
1895
|
+
if (M(this, X) || await this.getEntityList(), !M(this, X) || M(this, X).length === 0)
|
|
1889
1896
|
return;
|
|
1890
|
-
let r =
|
|
1897
|
+
let r = M(this, X).filter((i) => {
|
|
1891
1898
|
try {
|
|
1892
1899
|
let { dateCreate: a } = i;
|
|
1893
|
-
return a ?
|
|
1894
|
-
|
|
1900
|
+
return a ? Nt(new Date(a)).between(
|
|
1901
|
+
Nt(new Date(e)),
|
|
1895
1902
|
"month"
|
|
1896
1903
|
) >= this.periodClear : !1;
|
|
1897
1904
|
} catch (a) {
|
|
@@ -1900,61 +1907,61 @@ K = new WeakMap(), Q = new WeakMap(), st = new WeakMap(), ot = new WeakMap(), ft
|
|
|
1900
1907
|
});
|
|
1901
1908
|
r.length > 0 && (console.log(
|
|
1902
1909
|
`Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1903
|
-
), await _(this,
|
|
1910
|
+
), await _(this, Bt, oe).call(this, r));
|
|
1904
1911
|
} catch (t) {
|
|
1905
1912
|
console.error("Ошибка при проверке периода очистки:", t);
|
|
1906
1913
|
}
|
|
1907
|
-
},
|
|
1914
|
+
}, Bt = new WeakSet(), oe = async function(t) {
|
|
1908
1915
|
try {
|
|
1909
1916
|
if (!t || t.length === 0)
|
|
1910
1917
|
return !1;
|
|
1911
1918
|
let e = new v(BX24.callBatch), r = t.filter((a) => a && a.id).map((a) => {
|
|
1912
|
-
let { id:
|
|
1919
|
+
let { id: c } = a;
|
|
1913
1920
|
return {
|
|
1914
1921
|
method: "entity.item.delete",
|
|
1915
1922
|
params: {
|
|
1916
|
-
ENTITY:
|
|
1917
|
-
ID:
|
|
1923
|
+
ENTITY: M(this, K),
|
|
1924
|
+
ID: c
|
|
1918
1925
|
}
|
|
1919
1926
|
};
|
|
1920
1927
|
});
|
|
1921
1928
|
if (r.length === 0)
|
|
1922
1929
|
return !1;
|
|
1923
1930
|
const i = await e.batch(r);
|
|
1924
|
-
return console.log(`Успешно удалено ${r.length} записей`),
|
|
1931
|
+
return console.log(`Успешно удалено ${r.length} записей`), x(this, rt, !0), i;
|
|
1925
1932
|
} catch (e) {
|
|
1926
1933
|
return console.error("Ошибка при очистке устаревших записей:", e), !1;
|
|
1927
1934
|
}
|
|
1928
1935
|
};
|
|
1929
|
-
function
|
|
1930
|
-
if (!
|
|
1936
|
+
function Zt(y) {
|
|
1937
|
+
if (!y || typeof y != "string")
|
|
1931
1938
|
return "";
|
|
1932
1939
|
try {
|
|
1933
|
-
const t = new URL(
|
|
1940
|
+
const t = new URL(y);
|
|
1934
1941
|
t.search = "", t.hash = "";
|
|
1935
1942
|
let e = t.toString();
|
|
1936
1943
|
return e.endsWith("/") && t.pathname !== "/" && (e = e.slice(0, -1)), e;
|
|
1937
1944
|
} catch {
|
|
1938
|
-
return
|
|
1945
|
+
return y.split("?")[0].split("#")[0].replace(/\/$/, "");
|
|
1939
1946
|
}
|
|
1940
1947
|
}
|
|
1941
|
-
function
|
|
1942
|
-
return !
|
|
1948
|
+
function Ae(y) {
|
|
1949
|
+
return !y || typeof y != "string" ? !1 : y.toLowerCase().includes("/marketplace/app");
|
|
1943
1950
|
}
|
|
1944
1951
|
function Te() {
|
|
1945
1952
|
var t;
|
|
1946
1953
|
if (typeof window > "u" || !((t = window.location) != null && t.href))
|
|
1947
1954
|
return "";
|
|
1948
|
-
const
|
|
1949
|
-
return
|
|
1955
|
+
const y = Zt(window.location.href);
|
|
1956
|
+
return Ae(y) ? "" : y;
|
|
1950
1957
|
}
|
|
1951
|
-
function Kt(
|
|
1952
|
-
if (!(
|
|
1958
|
+
function Kt(y) {
|
|
1959
|
+
if (!(y != null && y.appConst) || typeof y.appConst != "object")
|
|
1953
1960
|
return "";
|
|
1954
1961
|
const t = Te();
|
|
1955
|
-
return t ? (
|
|
1962
|
+
return t ? (y.appConst.pathApp = t, t) : Zt(y.appConst.pathApp ?? "");
|
|
1956
1963
|
}
|
|
1957
|
-
var ct,
|
|
1964
|
+
var ct, _t, Ct, ce, dt, vt, Ut, le, Ht, he, Gt, ue, V, nt, gt, qt, Yt, fe, yt, zt, Pt, me;
|
|
1958
1965
|
class Ie {
|
|
1959
1966
|
/**
|
|
1960
1967
|
* @param {Object} appConst - Константы приложения
|
|
@@ -1969,23 +1976,23 @@ class Ie {
|
|
|
1969
1976
|
* @returns {Batch} Shared Batch instance.
|
|
1970
1977
|
*/
|
|
1971
1978
|
L(this, ct);
|
|
1972
|
-
L(this,
|
|
1979
|
+
L(this, Ct);
|
|
1973
1980
|
/**
|
|
1974
1981
|
* `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
|
|
1975
1982
|
* иначе — заглушка.
|
|
1976
1983
|
* @param {boolean} runLoggerMaintenance
|
|
1977
1984
|
*/
|
|
1978
|
-
L(this,
|
|
1985
|
+
L(this, dt);
|
|
1979
1986
|
/**
|
|
1980
1987
|
* @returns {boolean}
|
|
1981
1988
|
*/
|
|
1982
|
-
L(this, Ht);
|
|
1983
|
-
/** Запрос данных о приложении */
|
|
1984
1989
|
L(this, Ut);
|
|
1990
|
+
/** Запрос данных о приложении */
|
|
1991
|
+
L(this, Ht);
|
|
1985
1992
|
/** Запрос данных о текущем пользователе */
|
|
1986
1993
|
L(this, Gt);
|
|
1987
1994
|
L(this, V);
|
|
1988
|
-
L(this,
|
|
1995
|
+
L(this, gt);
|
|
1989
1996
|
/**
|
|
1990
1997
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1991
1998
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -2000,26 +2007,26 @@ class Ie {
|
|
|
2000
2007
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
2001
2008
|
* @private
|
|
2002
2009
|
*/
|
|
2003
|
-
L(this,
|
|
2010
|
+
L(this, yt);
|
|
2004
2011
|
/**
|
|
2005
2012
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
2006
2013
|
* @private
|
|
2007
2014
|
*/
|
|
2008
2015
|
L(this, Pt);
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2016
|
+
H(this, "domain", "");
|
|
2017
|
+
H(this, "isAdmin", !1);
|
|
2018
|
+
H(this, "appInfo", null);
|
|
2019
|
+
H(this, "appConst", null);
|
|
2020
|
+
H(this, "userInfo", null);
|
|
2021
|
+
H(this, "placeData", null);
|
|
2022
|
+
H(this, "placeInfo", null);
|
|
2023
|
+
H(this, "logger", !1);
|
|
2024
|
+
H(this, "timeLimit", {
|
|
2018
2025
|
limit: !1,
|
|
2019
2026
|
date: void 0,
|
|
2020
2027
|
pauseMs: void 0
|
|
2021
2028
|
});
|
|
2022
|
-
|
|
2029
|
+
H(this, "batchClient", null);
|
|
2023
2030
|
this.appConst = t;
|
|
2024
2031
|
}
|
|
2025
2032
|
/**
|
|
@@ -2029,7 +2036,7 @@ class Ie {
|
|
|
2029
2036
|
* @returns {() => void} Функция отписки.
|
|
2030
2037
|
*/
|
|
2031
2038
|
subscribeTimeLimit(t) {
|
|
2032
|
-
return _(this, ct,
|
|
2039
|
+
return _(this, ct, _t).call(this).subscribeTimeLimit(t);
|
|
2033
2040
|
}
|
|
2034
2041
|
/**
|
|
2035
2042
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2045,20 +2052,24 @@ class Ie {
|
|
|
2045
2052
|
return new Promise((t, e) => {
|
|
2046
2053
|
const i = setTimeout(() => {
|
|
2047
2054
|
clearInterval(a);
|
|
2048
|
-
const
|
|
2055
|
+
const c = new Error(
|
|
2049
2056
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
2050
2057
|
);
|
|
2051
|
-
console.error(
|
|
2058
|
+
console.error(c), e(c);
|
|
2052
2059
|
}, 3e4);
|
|
2053
2060
|
let a = setInterval(() => {
|
|
2054
2061
|
window.BX24 && BX24.init(async () => {
|
|
2055
2062
|
clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
|
|
2056
|
-
const
|
|
2063
|
+
const c = _(this, Ut, le).call(this);
|
|
2057
2064
|
if (console.info(
|
|
2058
|
-
|
|
2059
|
-
), this.appInfo = await _(this,
|
|
2060
|
-
await _(this,
|
|
2061
|
-
|
|
2065
|
+
c ? "init BX24 (background worker)" : "init BX24"
|
|
2066
|
+
), this.appInfo = await _(this, Ht, he).call(this), this.userInfo = await _(this, Gt, ue).call(this), Kt(this), c)
|
|
2067
|
+
await _(this, dt, vt).call(this, !1, {
|
|
2068
|
+
skipInit: !0
|
|
2069
|
+
});
|
|
2070
|
+
else {
|
|
2071
|
+
await _(this, dt, vt).call(this, !0);
|
|
2072
|
+
const l = new re();
|
|
2062
2073
|
try {
|
|
2063
2074
|
l.noSleep();
|
|
2064
2075
|
} catch (u) {
|
|
@@ -2068,7 +2079,7 @@ class Ie {
|
|
|
2068
2079
|
);
|
|
2069
2080
|
}
|
|
2070
2081
|
}
|
|
2071
|
-
t({ isBackworker:
|
|
2082
|
+
t({ isBackworker: c });
|
|
2072
2083
|
});
|
|
2073
2084
|
}, 100);
|
|
2074
2085
|
});
|
|
@@ -2124,14 +2135,14 @@ class Ie {
|
|
|
2124
2135
|
const l = new Error("BX24 is not initialized");
|
|
2125
2136
|
throw console.error(l), l;
|
|
2126
2137
|
}
|
|
2127
|
-
const
|
|
2128
|
-
return
|
|
2129
|
-
answer:
|
|
2138
|
+
const c = await _(this, ct, _t).call(this).call({ method: t, params: e });
|
|
2139
|
+
return c.success ? (await _(this, V, nt).call(this, i, {
|
|
2140
|
+
answer: c.answer,
|
|
2130
2141
|
status: "success"
|
|
2131
|
-
}),
|
|
2132
|
-
answer:
|
|
2142
|
+
}), c.data) : (console.error(c.error), await _(this, V, nt).call(this, i, {
|
|
2143
|
+
answer: c.answer,
|
|
2133
2144
|
status: "fail",
|
|
2134
|
-
errorList: { 0:
|
|
2145
|
+
errorList: { 0: c.error || "Unknown call error" }
|
|
2135
2146
|
}), !1);
|
|
2136
2147
|
}
|
|
2137
2148
|
/**
|
|
@@ -2155,10 +2166,10 @@ class Ie {
|
|
|
2155
2166
|
*/
|
|
2156
2167
|
async batch(t, e, { errorCall: r, updateList: i, batchOptions: a } = {}) {
|
|
2157
2168
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2158
|
-
const
|
|
2159
|
-
return console.error(
|
|
2169
|
+
const c = new Error("BX24 is not initialized");
|
|
2170
|
+
return console.error(c), !1;
|
|
2160
2171
|
}
|
|
2161
|
-
return _(this,
|
|
2172
|
+
return _(this, gt, qt).call(this, {
|
|
2162
2173
|
mode: "batch",
|
|
2163
2174
|
commandList: t,
|
|
2164
2175
|
progressCall: e,
|
|
@@ -2194,7 +2205,7 @@ class Ie {
|
|
|
2194
2205
|
const a = new Error("BX24 is not initialized");
|
|
2195
2206
|
return console.error(a), !1;
|
|
2196
2207
|
}
|
|
2197
|
-
return _(this,
|
|
2208
|
+
return _(this, gt, qt).call(this, {
|
|
2198
2209
|
mode: "batch-total-count",
|
|
2199
2210
|
commandList: t,
|
|
2200
2211
|
progressCall: e,
|
|
@@ -2212,37 +2223,37 @@ class Ie {
|
|
|
2212
2223
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для встройки
|
|
2213
2224
|
*/
|
|
2214
2225
|
async placementBind(t) {
|
|
2215
|
-
var
|
|
2226
|
+
var A;
|
|
2216
2227
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2217
2228
|
return;
|
|
2218
2229
|
const { appName: e, pathApp: r } = this.appConst;
|
|
2219
|
-
let i = _(this,
|
|
2230
|
+
let i = _(this, yt, zt).call(this, t);
|
|
2220
2231
|
i = i.filter(
|
|
2221
2232
|
(h) => h.placement !== "PAGE_BACKGROUND_WORKER" && h.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2222
2233
|
);
|
|
2223
|
-
const a = _(this, Pt, me).call(this, r),
|
|
2234
|
+
const a = _(this, Pt, me).call(this, r), c = new Set(i.map((h) => h.placement));
|
|
2224
2235
|
for (const h of a)
|
|
2225
|
-
|
|
2236
|
+
c.has(h.placement) || i.push({ placement: h.placement });
|
|
2226
2237
|
if (i.length === 0)
|
|
2227
2238
|
return;
|
|
2228
2239
|
let l = e;
|
|
2229
|
-
this.domain === "szdl.bitrix24.ru" && ((
|
|
2230
|
-
const u = l.replace(" CRM", ""), n = {}, f = [],
|
|
2240
|
+
this.domain === "szdl.bitrix24.ru" && ((A = this.appInfo) != null && A.ID) && (l = `${e}: #${this.appInfo.ID}`);
|
|
2241
|
+
const u = l.replace(" CRM", ""), n = {}, f = [], d = /* @__PURE__ */ new Map();
|
|
2231
2242
|
for (const h of this.placeData)
|
|
2232
|
-
|
|
2243
|
+
d.has(h.placement) || d.set(h.placement, []), d.get(h.placement).push(h);
|
|
2233
2244
|
for (let h = 0; h < i.length; h++) {
|
|
2234
|
-
const O = i[h].placement, T =
|
|
2245
|
+
const O = i[h].placement, T = d.get(O) || [];
|
|
2235
2246
|
if (T.some(
|
|
2236
|
-
(
|
|
2247
|
+
(p) => p.handler === r
|
|
2237
2248
|
))
|
|
2238
2249
|
continue;
|
|
2239
|
-
const
|
|
2240
|
-
(
|
|
2250
|
+
const b = T.filter(
|
|
2251
|
+
(p) => p.handler !== r
|
|
2241
2252
|
);
|
|
2242
|
-
for (const
|
|
2253
|
+
for (const p of b)
|
|
2243
2254
|
f.push({
|
|
2244
2255
|
placement: O,
|
|
2245
|
-
handler:
|
|
2256
|
+
handler: p.handler
|
|
2246
2257
|
});
|
|
2247
2258
|
n[`bind_${h}`] = {
|
|
2248
2259
|
method: "placement.bind",
|
|
@@ -2269,7 +2280,7 @@ class Ie {
|
|
|
2269
2280
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2270
2281
|
*/
|
|
2271
2282
|
async placementUnBind(t) {
|
|
2272
|
-
let e = _(this,
|
|
2283
|
+
let e = _(this, yt, zt).call(this, t);
|
|
2273
2284
|
if (e = e.filter(
|
|
2274
2285
|
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2275
2286
|
), e.length === 0)
|
|
@@ -2299,7 +2310,7 @@ class Ie {
|
|
|
2299
2310
|
}
|
|
2300
2311
|
/* регистрация бота */
|
|
2301
2312
|
async regBot({ code: t, type: e, name: r }) {
|
|
2302
|
-
const { appName: i, pathApp: a, chatBotLogo:
|
|
2313
|
+
const { appName: i, pathApp: a, chatBotLogo: c } = this.appConst, l = this.appInfo.ID, u = await this.call({
|
|
2303
2314
|
method: "imbot.register",
|
|
2304
2315
|
params: {
|
|
2305
2316
|
CODE: t ?? this.appInfo.CODE,
|
|
@@ -2322,7 +2333,7 @@ class Ie {
|
|
|
2322
2333
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
2323
2334
|
EMAIL: "",
|
|
2324
2335
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
2325
|
-
PERSONAL_BIRTHDAY:
|
|
2336
|
+
PERSONAL_BIRTHDAY: Nt().format("%Y-%m-%d"),
|
|
2326
2337
|
// День рождения в формате YYYY-mm-dd
|
|
2327
2338
|
WORK_POSITION: "Почтальон",
|
|
2328
2339
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -2330,7 +2341,7 @@ class Ie {
|
|
|
2330
2341
|
// Ссылка на сайт
|
|
2331
2342
|
PERSONAL_GENDER: "M",
|
|
2332
2343
|
// Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
|
|
2333
|
-
PERSONAL_PHOTO:
|
|
2344
|
+
PERSONAL_PHOTO: c ?? ""
|
|
2334
2345
|
// Аватар чат-бота - base64
|
|
2335
2346
|
}
|
|
2336
2347
|
}
|
|
@@ -2352,12 +2363,12 @@ class Ie {
|
|
|
2352
2363
|
return this.logger.getEntityList(t);
|
|
2353
2364
|
}
|
|
2354
2365
|
}
|
|
2355
|
-
ct = new WeakSet(),
|
|
2366
|
+
ct = new WeakSet(), _t = function() {
|
|
2356
2367
|
return this.batchClient || (this.batchClient = new v({
|
|
2357
2368
|
callBatch: BX24.callBatch,
|
|
2358
2369
|
callMethod: BX24.callMethod
|
|
2359
2370
|
}), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
|
|
2360
|
-
},
|
|
2371
|
+
}, Ct = new WeakSet(), ce = function() {
|
|
2361
2372
|
return {
|
|
2362
2373
|
start: () => {
|
|
2363
2374
|
},
|
|
@@ -2366,13 +2377,13 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2366
2377
|
getEntityList: () => {
|
|
2367
2378
|
}
|
|
2368
2379
|
};
|
|
2369
|
-
},
|
|
2370
|
-
this.logger ? (this.logger = new _e(), await this.logger.init(), t && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = _(this,
|
|
2371
|
-
},
|
|
2380
|
+
}, dt = new WeakSet(), vt = async function(t, { skipInit: e = !1 } = {}) {
|
|
2381
|
+
this.logger ? (this.logger = new _e(), e ? this.logger.enableBackworkerMode() : await this.logger.init(), t && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = _(this, Ct, ce).call(this);
|
|
2382
|
+
}, Ut = new WeakSet(), le = function() {
|
|
2372
2383
|
var r, i, a;
|
|
2373
2384
|
const t = (r = this.placeInfo) == null ? void 0 : r.placement, e = (a = (i = this.placeInfo) == null ? void 0 : i.options) == null ? void 0 : a.ID;
|
|
2374
2385
|
return t === "PAGE_BACKGROUND_WORKER" || e === "PAGE_BACKGROUND_WORKER";
|
|
2375
|
-
},
|
|
2386
|
+
}, Ht = new WeakSet(), he = function() {
|
|
2376
2387
|
return this.call({ method: "app.info" });
|
|
2377
2388
|
}, Gt = new WeakSet(), ue = function() {
|
|
2378
2389
|
return this.call({ method: "user.current" });
|
|
@@ -2386,20 +2397,20 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2386
2397
|
} catch (r) {
|
|
2387
2398
|
console.error("Logger error:", r);
|
|
2388
2399
|
}
|
|
2389
|
-
},
|
|
2400
|
+
}, gt = new WeakSet(), qt = async function({
|
|
2390
2401
|
mode: t,
|
|
2391
2402
|
commandList: e,
|
|
2392
2403
|
progressCall: r,
|
|
2393
2404
|
errorCall: i,
|
|
2394
2405
|
updateList: a,
|
|
2395
|
-
batchOptions:
|
|
2406
|
+
batchOptions: c
|
|
2396
2407
|
}) {
|
|
2397
|
-
const l = _(this, ct,
|
|
2408
|
+
const l = _(this, ct, _t).call(this), u = a ? this.logger.start({
|
|
2398
2409
|
type: t,
|
|
2399
2410
|
data: t === "batch" ? { commandList: e, updateList: a } : { commandList: e }
|
|
2400
2411
|
}) : void 0;
|
|
2401
2412
|
try {
|
|
2402
|
-
const n = t === "batch" ? await l.batch(e, r,
|
|
2413
|
+
const n = t === "batch" ? await l.batch(e, r, c) : await l.batchTotalCount(e, r), f = _(this, Yt, fe).call(this, l, n, e, a);
|
|
2403
2414
|
return Object.keys(f).length ? (i && i(f), await _(this, V, nt).call(this, u, {
|
|
2404
2415
|
status: "fail",
|
|
2405
2416
|
errorList: f
|
|
@@ -2420,27 +2431,27 @@ ct = new WeakSet(), Ot = function() {
|
|
|
2420
2431
|
return u === "TIMEOUT" || u === "OPERATION_TIME_LIMIT" || u.includes("TIMEOUT") || u.includes("OPERATION_TIME_LIMIT");
|
|
2421
2432
|
}
|
|
2422
2433
|
) && i) {
|
|
2423
|
-
const l = e ? Object.keys(e).filter((
|
|
2434
|
+
const l = e ? Object.keys(e).filter((d) => d !== "errorsList") : [], u = new Set(Object.keys(t.errors || {})), n = /* @__PURE__ */ new Set();
|
|
2424
2435
|
if (e) {
|
|
2425
|
-
for (const
|
|
2426
|
-
if (!u.has(
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2436
|
+
for (const d of l)
|
|
2437
|
+
if (!u.has(d)) {
|
|
2438
|
+
const A = e[d];
|
|
2439
|
+
A != null && n.add(d);
|
|
2429
2440
|
}
|
|
2430
2441
|
}
|
|
2431
2442
|
const f = Object.values(t.errors).find(
|
|
2432
|
-
(
|
|
2433
|
-
if (typeof
|
|
2443
|
+
(d) => {
|
|
2444
|
+
if (typeof d != "string")
|
|
2434
2445
|
return !1;
|
|
2435
|
-
const
|
|
2436
|
-
return
|
|
2446
|
+
const A = d.toUpperCase();
|
|
2447
|
+
return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
|
|
2437
2448
|
}
|
|
2438
2449
|
);
|
|
2439
|
-
for (const
|
|
2440
|
-
!n.has(
|
|
2450
|
+
for (const d of Object.keys(r))
|
|
2451
|
+
!n.has(d) && !t.errors[d] && (a[d] = f || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2441
2452
|
}
|
|
2442
2453
|
return a;
|
|
2443
|
-
},
|
|
2454
|
+
}, yt = new WeakSet(), zt = function(t) {
|
|
2444
2455
|
if (!t)
|
|
2445
2456
|
return [];
|
|
2446
2457
|
let e = [];
|
|
@@ -2454,21 +2465,21 @@ const de = "szdl-utils-kit|";
|
|
|
2454
2465
|
function Ee() {
|
|
2455
2466
|
if (typeof sessionStorage > "u")
|
|
2456
2467
|
return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2457
|
-
let
|
|
2458
|
-
return
|
|
2468
|
+
let y = sessionStorage.getItem("szdl-cross-tab-instance-id");
|
|
2469
|
+
return y || (y = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", y)), y;
|
|
2459
2470
|
}
|
|
2460
2471
|
function Re() {
|
|
2461
2472
|
return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
|
|
2462
2473
|
}
|
|
2463
2474
|
const Ft = /* @__PURE__ */ new Map();
|
|
2464
|
-
function
|
|
2475
|
+
function be(y = "default") {
|
|
2465
2476
|
if (typeof BroadcastChannel > "u")
|
|
2466
2477
|
return null;
|
|
2467
|
-
const t = `${de}bc:${
|
|
2478
|
+
const t = `${de}bc:${y}`;
|
|
2468
2479
|
return Ft.has(t) || Ft.set(t, new BroadcastChannel(t)), Ft.get(t);
|
|
2469
2480
|
}
|
|
2470
|
-
function
|
|
2471
|
-
const e =
|
|
2481
|
+
function Vt(y, t) {
|
|
2482
|
+
const e = be(y);
|
|
2472
2483
|
if (e)
|
|
2473
2484
|
try {
|
|
2474
2485
|
const r = t && typeof t == "object" && !Array.isArray(t) ? t : { data: t };
|
|
@@ -2480,55 +2491,55 @@ function Zt(p, t) {
|
|
|
2480
2491
|
} catch {
|
|
2481
2492
|
}
|
|
2482
2493
|
}
|
|
2483
|
-
async function
|
|
2484
|
-
const { ifAvailable: r = !1 } = e, i = typeof
|
|
2494
|
+
async function Le(y, t, e = {}) {
|
|
2495
|
+
const { ifAvailable: r = !1 } = e, i = typeof y == "string" && y.length > 0 ? y : "default", a = `${de}${i}`;
|
|
2485
2496
|
return Re() ? navigator.locks.request(
|
|
2486
2497
|
a,
|
|
2487
2498
|
{ mode: "exclusive", ifAvailable: !!r },
|
|
2488
|
-
async (
|
|
2489
|
-
if (r &&
|
|
2499
|
+
async (c) => {
|
|
2500
|
+
if (r && c == null)
|
|
2490
2501
|
return { skipped: !0, coordination: "locks" };
|
|
2491
|
-
|
|
2502
|
+
Vt(i, { type: "lock-acquired", resource: i });
|
|
2492
2503
|
try {
|
|
2493
2504
|
return { skipped: !1, result: await t(), coordination: "locks" };
|
|
2494
2505
|
} finally {
|
|
2495
|
-
|
|
2506
|
+
Vt(i, { type: "lock-released", resource: i });
|
|
2496
2507
|
}
|
|
2497
2508
|
}
|
|
2498
2509
|
) : { skipped: !1, result: await t(), coordination: "none" };
|
|
2499
2510
|
}
|
|
2500
|
-
var
|
|
2511
|
+
var pt, Qt;
|
|
2501
2512
|
class Me {
|
|
2502
2513
|
constructor(t) {
|
|
2503
2514
|
/**
|
|
2504
2515
|
* Канонический base URL для placement (без завершающего `/`).
|
|
2505
2516
|
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2506
2517
|
*/
|
|
2507
|
-
L(this,
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2518
|
+
L(this, pt);
|
|
2519
|
+
H(this, "entityName", "tabs");
|
|
2520
|
+
H(this, "maxTabs", 20);
|
|
2521
|
+
H(this, "tabList", []);
|
|
2522
|
+
H(this, "id", 0);
|
|
2523
|
+
H(this, "hasStarted", !1);
|
|
2524
|
+
H(this, "heartbeat");
|
|
2525
|
+
H(this, "runHeartbeat");
|
|
2515
2526
|
/** Вкладка считается «мёртвой», если нет обновления lastActive дольше этого (см. refreshTabs). */
|
|
2516
|
-
|
|
2517
|
-
|
|
2527
|
+
H(this, "activeMaxPause", 10 * 1e3);
|
|
2528
|
+
H(this, "quickCleanupThreshold", 2 * 60 * 1e3);
|
|
2518
2529
|
// агрессивная очистка при переполнении
|
|
2519
2530
|
/** Должен быть заметно меньше activeMaxPause: иначе «живые» вкладки успеют удалиться до следующего тика. */
|
|
2520
|
-
|
|
2531
|
+
H(this, "pollInterval", 6 * 1e3 + Math.floor(Math.random() * 2e3));
|
|
2521
2532
|
// ~6–8 с + размазать одновременные запросы
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
var
|
|
2533
|
+
H(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
2534
|
+
H(this, "continueCondition");
|
|
2535
|
+
H(this, "defaultContinueBackground", () => !0);
|
|
2536
|
+
var c, l, u;
|
|
2526
2537
|
if (!t) {
|
|
2527
2538
|
console.error("BackgroundWorker: Нет опций конструктора");
|
|
2528
2539
|
return;
|
|
2529
2540
|
}
|
|
2530
2541
|
const { appFunc: e, bx: r, users: i, continueBackground: a } = t;
|
|
2531
|
-
this.bx = r, this.appInit = e, this.users = i, Kt(r), this.appPath = _(this,
|
|
2542
|
+
this.bx = r, this.appInit = e, this.users = i, Kt(r), this.appPath = _(this, pt, Qt).call(this, ((c = r == null ? void 0 : r.appConst) == null ? void 0 : c.pathApp) ?? ""), this.appName = ((l = r == null ? void 0 : r.appConst) == null ? void 0 : l.appName) ?? "", this.appCodeName = ((u = r == null ? void 0 : r.appConst) == null ? void 0 : u.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2532
2543
|
}
|
|
2533
2544
|
async init() {
|
|
2534
2545
|
if (!this.appInit) {
|
|
@@ -2570,8 +2581,8 @@ class Me {
|
|
|
2570
2581
|
if (typeof BX24 > "u" || !((t = BX24.placement) != null && t.info))
|
|
2571
2582
|
return !1;
|
|
2572
2583
|
try {
|
|
2573
|
-
const e = BX24.placement.info(), r = e == null ? void 0 : e.placement, i = (e == null ? void 0 : e.options) || {}, a = (i == null ? void 0 : i.URI) || "",
|
|
2574
|
-
return !
|
|
2584
|
+
const e = BX24.placement.info(), r = e == null ? void 0 : e.placement, i = (e == null ? void 0 : e.options) || {}, a = (i == null ? void 0 : i.URI) || "", c = r === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", l = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
|
|
2585
|
+
return !c || l;
|
|
2575
2586
|
} catch {
|
|
2576
2587
|
return !1;
|
|
2577
2588
|
}
|
|
@@ -2694,7 +2705,7 @@ class Me {
|
|
|
2694
2705
|
), !0;
|
|
2695
2706
|
const i = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0), a = this.isIndividualPlacement(
|
|
2696
2707
|
typeof window < "u" ? window.location.href : ""
|
|
2697
|
-
),
|
|
2708
|
+
), c = !a;
|
|
2698
2709
|
if (!i)
|
|
2699
2710
|
return !0;
|
|
2700
2711
|
let l = !1;
|
|
@@ -2709,7 +2720,7 @@ class Me {
|
|
|
2709
2720
|
}
|
|
2710
2721
|
return a ? (console.log(
|
|
2711
2722
|
"BackgroundWorker: Индивидуальная встройка - разрешено"
|
|
2712
|
-
), !0) :
|
|
2723
|
+
), !0) : c && l ? (console.log(
|
|
2713
2724
|
"BackgroundWorker: Есть личная встройка, общую не запускаем"
|
|
2714
2725
|
), !1) : (console.log(
|
|
2715
2726
|
"BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
|
|
@@ -2744,8 +2755,8 @@ class Me {
|
|
|
2744
2755
|
}
|
|
2745
2756
|
}
|
|
2746
2757
|
async refreshTabs(t = !1, e = this.activeMaxPause) {
|
|
2747
|
-
const r = [], i = [], a = Date.now(),
|
|
2748
|
-
for (const l of
|
|
2758
|
+
const r = [], i = [], a = Date.now(), c = await this.getTabs();
|
|
2759
|
+
for (const l of c) {
|
|
2749
2760
|
if (!(l != null && l.data)) {
|
|
2750
2761
|
r.push(l);
|
|
2751
2762
|
continue;
|
|
@@ -2764,20 +2775,20 @@ class Me {
|
|
|
2764
2775
|
var l, u, n, f;
|
|
2765
2776
|
const a = new Date(
|
|
2766
2777
|
((l = r.data) == null ? void 0 : l.createdAt) || ((u = r.data) == null ? void 0 : u.lastActive) || 0
|
|
2767
|
-
).getTime(),
|
|
2778
|
+
).getTime(), c = new Date(
|
|
2768
2779
|
((n = i.data) == null ? void 0 : n.createdAt) || ((f = i.data) == null ? void 0 : f.lastActive) || 0
|
|
2769
2780
|
).getTime();
|
|
2770
|
-
return a ===
|
|
2781
|
+
return a === c ? (+r.id || 0) - (+i.id || 0) : a - c;
|
|
2771
2782
|
})[0]) == null ? void 0 : e.id) || 0;
|
|
2772
2783
|
}
|
|
2773
2784
|
async runAsLeader() {
|
|
2774
2785
|
var i, a;
|
|
2775
2786
|
const t = String(((a = (i = this.bx) == null ? void 0 : i.userInfo) == null ? void 0 : a.ID) ?? "0"), e = `background-worker:${this.entityName}:${t}`;
|
|
2776
|
-
(await
|
|
2787
|
+
(await Le(
|
|
2777
2788
|
e,
|
|
2778
2789
|
async () => {
|
|
2779
2790
|
this.hasStarted = !0;
|
|
2780
|
-
const
|
|
2791
|
+
const c = Math.min(
|
|
2781
2792
|
this.activeMaxPause - 1500,
|
|
2782
2793
|
Math.max(2500, Math.floor(this.pollInterval / 2))
|
|
2783
2794
|
);
|
|
@@ -2790,7 +2801,7 @@ class Me {
|
|
|
2790
2801
|
)
|
|
2791
2802
|
);
|
|
2792
2803
|
},
|
|
2793
|
-
|
|
2804
|
+
c
|
|
2794
2805
|
);
|
|
2795
2806
|
try {
|
|
2796
2807
|
await this.appInit();
|
|
@@ -2805,15 +2816,15 @@ class Me {
|
|
|
2805
2816
|
);
|
|
2806
2817
|
}
|
|
2807
2818
|
async setBackgroundWorkerAll() {
|
|
2808
|
-
var
|
|
2809
|
-
if (!((
|
|
2819
|
+
var b, p, S, C;
|
|
2820
|
+
if (!((b = this.bx) != null && b.isAdmin)) {
|
|
2810
2821
|
console.log(
|
|
2811
2822
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2812
2823
|
);
|
|
2813
2824
|
return;
|
|
2814
2825
|
}
|
|
2815
|
-
(
|
|
2816
|
-
const t = _(this,
|
|
2826
|
+
(p = this.users) != null && p.length || await this.getEntityData(), Kt(this.bx);
|
|
2827
|
+
const t = _(this, pt, Qt).call(this, ((C = (S = this.bx) == null ? void 0 : S.appConst) == null ? void 0 : C.pathApp) ?? "");
|
|
2817
2828
|
if (!t) {
|
|
2818
2829
|
console.error(
|
|
2819
2830
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2822,71 +2833,77 @@ class Me {
|
|
|
2822
2833
|
}
|
|
2823
2834
|
const e = await this.safeCall(
|
|
2824
2835
|
() => this.bx.getPlacement()
|
|
2825
|
-
), r = /* @__PURE__ */ new Map();
|
|
2826
|
-
let
|
|
2827
|
-
(e || []).forEach((
|
|
2828
|
-
if (
|
|
2836
|
+
), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2837
|
+
let a = null;
|
|
2838
|
+
(e || []).forEach((N) => {
|
|
2839
|
+
if (N.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2829
2840
|
return;
|
|
2830
|
-
if (
|
|
2831
|
-
const
|
|
2832
|
-
|
|
2841
|
+
if (N.userId || N.handler && N.handler.includes("USER_ID=")) {
|
|
2842
|
+
const E = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
|
|
2843
|
+
if (E) {
|
|
2844
|
+
const k = +E;
|
|
2845
|
+
r.set(k, N), i.has(k) || i.set(k, []), i.get(k).push(N);
|
|
2846
|
+
}
|
|
2833
2847
|
} else
|
|
2834
|
-
|
|
2848
|
+
a = N;
|
|
2835
2849
|
});
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
const
|
|
2839
|
-
return (
|
|
2850
|
+
const c = await this.resolveAdmins(), l = await this.getEligibleUsersForBackgroundWorker(c);
|
|
2851
|
+
l.sort((N, I) => {
|
|
2852
|
+
const E = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2853
|
+
return (I.LAST_LOGIN ? new Date(I.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - E;
|
|
2840
2854
|
});
|
|
2841
|
-
const
|
|
2842
|
-
const
|
|
2843
|
-
if (!
|
|
2855
|
+
const u = 10, n = l.slice(0, u), f = n.filter((N) => {
|
|
2856
|
+
const I = r.get(+N.ID);
|
|
2857
|
+
if (!I)
|
|
2844
2858
|
return !0;
|
|
2845
|
-
const
|
|
2846
|
-
return
|
|
2847
|
-
}),
|
|
2848
|
-
for (const [
|
|
2849
|
-
const
|
|
2850
|
-
|
|
2859
|
+
const E = `${t}?USER_ID=${N.ID}/`;
|
|
2860
|
+
return I.handler !== E;
|
|
2861
|
+
}), d = [];
|
|
2862
|
+
for (const [N] of r) {
|
|
2863
|
+
const I = +N || 0;
|
|
2864
|
+
l.find((k) => +k.ID === I) || d.push(I);
|
|
2851
2865
|
}
|
|
2852
|
-
for (const
|
|
2853
|
-
const
|
|
2854
|
-
if (!
|
|
2866
|
+
for (const N of n) {
|
|
2867
|
+
const I = r.get(+N.ID);
|
|
2868
|
+
if (!I)
|
|
2855
2869
|
continue;
|
|
2856
|
-
const
|
|
2857
|
-
|
|
2870
|
+
const E = `${t}?USER_ID=${N.ID}/`;
|
|
2871
|
+
I.handler !== E && d.push(+N.ID);
|
|
2858
2872
|
}
|
|
2859
|
-
const
|
|
2860
|
-
for (const
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2873
|
+
const A = [], h = [...new Set(d)];
|
|
2874
|
+
for (const N of h) {
|
|
2875
|
+
const I = i.get(+N) || [];
|
|
2876
|
+
for (const E of I)
|
|
2877
|
+
E != null && E.handler && A.push({
|
|
2878
|
+
method: "placement.unbind",
|
|
2879
|
+
params: {
|
|
2880
|
+
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2881
|
+
HANDLER: E.handler
|
|
2882
|
+
}
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
const O = a && (f.length > 0 || a.handler !== `${t}`);
|
|
2886
|
+
O && A.push({
|
|
2870
2887
|
method: "placement.unbind",
|
|
2871
2888
|
params: {
|
|
2872
2889
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2873
|
-
HANDLER:
|
|
2890
|
+
HANDLER: a.handler || `${t}`
|
|
2874
2891
|
}
|
|
2875
2892
|
});
|
|
2876
|
-
for (const
|
|
2877
|
-
|
|
2893
|
+
for (const N of f)
|
|
2894
|
+
A.push({
|
|
2878
2895
|
method: "placement.bind",
|
|
2879
2896
|
params: {
|
|
2880
2897
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2881
|
-
HANDLER: `${t}?USER_ID=${
|
|
2898
|
+
HANDLER: `${t}?USER_ID=${N.ID}/`,
|
|
2882
2899
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2883
2900
|
OPTIONS: {
|
|
2884
|
-
errorHandlerUrl: `${t}?USER_ID=${
|
|
2901
|
+
errorHandlerUrl: `${t}?USER_ID=${N.ID}/`
|
|
2885
2902
|
},
|
|
2886
|
-
USER_ID:
|
|
2903
|
+
USER_ID: N.ID
|
|
2887
2904
|
}
|
|
2888
2905
|
});
|
|
2889
|
-
(!
|
|
2906
|
+
(!a || O) && A.push({
|
|
2890
2907
|
method: "placement.bind",
|
|
2891
2908
|
params: {
|
|
2892
2909
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -2895,24 +2912,24 @@ class Me {
|
|
|
2895
2912
|
OPTIONS: { errorHandlerUrl: `${t}` }
|
|
2896
2913
|
}
|
|
2897
2914
|
});
|
|
2898
|
-
const
|
|
2899
|
-
(
|
|
2900
|
-
),
|
|
2901
|
-
(
|
|
2915
|
+
const T = A.filter(
|
|
2916
|
+
(N) => N.method === "placement.unbind"
|
|
2917
|
+
), R = A.filter(
|
|
2918
|
+
(N) => N.method === "placement.bind"
|
|
2902
2919
|
);
|
|
2903
|
-
|
|
2920
|
+
T.length && await this.safeCall(
|
|
2904
2921
|
() => this.bx.batch(
|
|
2905
2922
|
Object.fromEntries(
|
|
2906
|
-
|
|
2923
|
+
T.map((N, I) => [`unbind_${I}`, N])
|
|
2907
2924
|
)
|
|
2908
2925
|
)
|
|
2909
|
-
),
|
|
2926
|
+
), R.length && await this.safeCall(
|
|
2910
2927
|
() => this.bx.batch(
|
|
2911
2928
|
Object.fromEntries(
|
|
2912
|
-
|
|
2929
|
+
R.map((N, I) => [`bind_${I}`, N])
|
|
2913
2930
|
)
|
|
2914
2931
|
)
|
|
2915
|
-
),
|
|
2932
|
+
), A.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
2916
2933
|
}
|
|
2917
2934
|
async resolveAdmins() {
|
|
2918
2935
|
var t, e;
|
|
@@ -2927,9 +2944,9 @@ class Me {
|
|
|
2927
2944
|
}
|
|
2928
2945
|
return a;
|
|
2929
2946
|
}
|
|
2930
|
-
const
|
|
2931
|
-
r &&
|
|
2932
|
-
const l = [...
|
|
2947
|
+
const c = /* @__PURE__ */ new Set([...a || []]);
|
|
2948
|
+
r && c.add(+r);
|
|
2949
|
+
const l = [...c].filter(Boolean);
|
|
2933
2950
|
return await this.saveAdminsList(l), l;
|
|
2934
2951
|
} catch (r) {
|
|
2935
2952
|
return console.error("BackgroundWorker: resolveAdmins error", r), [];
|
|
@@ -2988,11 +3005,11 @@ class Me {
|
|
|
2988
3005
|
}
|
|
2989
3006
|
}
|
|
2990
3007
|
}
|
|
2991
|
-
|
|
3008
|
+
pt = new WeakSet(), Qt = function(t) {
|
|
2992
3009
|
if (!t || typeof t != "string")
|
|
2993
3010
|
return "";
|
|
2994
|
-
const e =
|
|
2995
|
-
return e ?
|
|
3011
|
+
const e = Zt(t).replace(/\/+$/, "");
|
|
3012
|
+
return e ? Ae(e) ? (console.error(
|
|
2996
3013
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
2997
3014
|
), "") : e : "";
|
|
2998
3015
|
};
|
|
@@ -3000,7 +3017,7 @@ export {
|
|
|
3000
3017
|
Me as BackgroundWorker,
|
|
3001
3018
|
v as Batch,
|
|
3002
3019
|
Ie as BxBoot,
|
|
3003
|
-
|
|
3020
|
+
re as BxHelper,
|
|
3004
3021
|
_e as BxLogger,
|
|
3005
|
-
|
|
3022
|
+
Nt as tempus
|
|
3006
3023
|
};
|