szdl-utils-kit 0.3.25 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +3 -1
- package/dist/index.js +820 -748
- package/dist/index.umd.cjs +2 -2
- package/dist/types/background-worker.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var w = (
|
|
4
|
-
if (!e.has(
|
|
1
|
+
var ke = Object.defineProperty;
|
|
2
|
+
var we = (d, e, t) => e in d ? ke(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var w = (d, e, t) => (we(d, typeof e != "symbol" ? e + "" : e, t), t), Qt = (d, e, t) => {
|
|
4
|
+
if (!e.has(d))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (e.has(
|
|
7
|
+
var b = (d, e, t) => (Qt(d, e, "read from private field"), t ? t.call(d) : e.get(d)), E = (d, e, t) => {
|
|
8
|
+
if (e.has(d))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
e instanceof WeakSet ? e.add(
|
|
11
|
-
}, x = (
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
return
|
|
10
|
+
e instanceof WeakSet ? e.add(d) : e.set(d, t);
|
|
11
|
+
}, x = (d, e, t, r) => (Qt(d, e, "write to private field"), r ? r.call(d, t) : e.set(d, t), t);
|
|
12
|
+
var p = (d, e, t) => (Qt(d, e, "access private method"), t);
|
|
13
|
+
var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
+
function Be(d) {
|
|
15
|
+
return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
|
|
16
16
|
}
|
|
17
|
-
var
|
|
18
|
-
(function(
|
|
17
|
+
var $t = { exports: {} };
|
|
18
|
+
(function(d, e) {
|
|
19
19
|
(function(t) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
21
|
+
var m, y;
|
|
22
|
+
for (m = o || 0, y = this.length; m < y; 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 !== t ? (s.year(o.year() || o.year), s.month(o.month() || o.month), s.day(o.day() || o.day), s.hours(o.hours() || o.hours), s.minutes(o.minutes() || o.minutes), s.seconds(o.seconds() || o.seconds), s.milliseconds(o.milliseconds() || o.milliseconds), s) : t;
|
|
33
|
-
},
|
|
34
|
-
var
|
|
35
|
-
return
|
|
33
|
+
}, l = function(s, o) {
|
|
34
|
+
var m, y = "";
|
|
35
|
+
return m = s.slice(o, o + 1), m !== "" && !isNaN(Number(m)) && (y += "%H"), m = s.charAt(o + 2), m !== "" && m === ":" && (y += m), m = s.slice(o + 3, o + 4), m !== "" && !isNaN(Number(m)) && (y += "%M"), m = s.charAt(o + 5), m !== "" && m === ":" && (y += m), m = s.slice(o + 6, o + 7), m !== "" && !isNaN(Number(m)) && (y += "%S"), y;
|
|
36
36
|
}, h = function(s, o) {
|
|
37
|
-
var
|
|
37
|
+
var m, y = [
|
|
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
43
|
], H;
|
|
44
|
-
return !isNaN(Number(
|
|
44
|
+
return !isNaN(Number(y[0])) && !isNaN(Number(y[2])) && !isNaN(Number(y[4])) ? (y[1] === "." && y[3] === "." ? m = "%d.%m.%Y" : y[1] === "-" && y[3] === "-" ? m = "%m-%d-%Y" : y[1] === "/" && y[3] === "/" && (m = "%m/%d/%Y"), m) : (H = [
|
|
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(H[0])) && !isNaN(Number(H[2])) && !isNaN(Number(H[4])) ? (H[1] === "-" && H[3] === "-" && (
|
|
51
|
-
},
|
|
50
|
+
], !isNaN(Number(H[0])) && !isNaN(Number(H[2])) && !isNaN(Number(H[4])) ? (H[1] === "-" && H[3] === "-" && (m = "%Y-%m-%d"), m) : "");
|
|
51
|
+
}, u = r.tempus, n, g, f = r.navigator || {}, A = "en", c = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,62 +209,62 @@ var Vt = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, N = function() {
|
|
213
213
|
return [
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
214
|
+
c[A].JANUARY_LONG,
|
|
215
|
+
c[A].FEBRUARY_LONG,
|
|
216
|
+
c[A].MARCH_LONG,
|
|
217
|
+
c[A].APRIL_LONG,
|
|
218
|
+
c[A].MAY_LONG,
|
|
219
|
+
c[A].JUNE_LONG,
|
|
220
|
+
c[A].JULY_LONG,
|
|
221
|
+
c[A].AUGUST_LONG,
|
|
222
|
+
c[A].SEPTEMBER_LONG,
|
|
223
|
+
c[A].OCTOBER_LONG,
|
|
224
|
+
c[A].NOVEMBER_LONG,
|
|
225
|
+
c[A].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
227
|
}, _ = function() {
|
|
228
228
|
return [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
229
|
+
c[A].JANUARY_SHORT,
|
|
230
|
+
c[A].FEBRUARY_SHORT,
|
|
231
|
+
c[A].MARCH_SHORT,
|
|
232
|
+
c[A].APRIL_SHORT,
|
|
233
|
+
c[A].MAY_SHORT,
|
|
234
|
+
c[A].JUNE_SHORT,
|
|
235
|
+
c[A].JULY_SHORT,
|
|
236
|
+
c[A].AUGUST_SHORT,
|
|
237
|
+
c[A].SEPTEMBER_SHORT,
|
|
238
|
+
c[A].OCTOBER_SHORT,
|
|
239
|
+
c[A].NOVEMBER_SHORT,
|
|
240
|
+
c[A].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, R = function() {
|
|
243
243
|
return [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
244
|
+
c[A].SUNDAY_LONG,
|
|
245
|
+
c[A].MONDAY_LONG,
|
|
246
|
+
c[A].TUESDAY_LONG,
|
|
247
|
+
c[A].WEDNESDAY_LONG,
|
|
248
|
+
c[A].THURSDAY_LONG,
|
|
249
|
+
c[A].FRIDAY_LONG,
|
|
250
|
+
c[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
252
|
}, k = function() {
|
|
253
253
|
return [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
254
|
+
c[A].SUNDAY_SHORT,
|
|
255
|
+
c[A].MONDAY_SHORT,
|
|
256
|
+
c[A].TUESDAY_SHORT,
|
|
257
|
+
c[A].WEDNESDAY_SHORT,
|
|
258
|
+
c[A].THURSDAY_SHORT,
|
|
259
|
+
c[A].FRIDAY_SHORT,
|
|
260
|
+
c[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
}, T,
|
|
263
|
-
var
|
|
264
|
-
r.XMLHttpRequest ?
|
|
265
|
-
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(
|
|
267
|
-
},
|
|
262
|
+
}, T, L, G, O, S = function(s, o, m) {
|
|
263
|
+
var y;
|
|
264
|
+
r.XMLHttpRequest ? y = new XMLHttpRequest() : y = new ActiveXObject("Microsoft.XMLHTTP"), y.onreadystatechange = function() {
|
|
265
|
+
y.readyState === 4 && (y.status === 200 ? o && (r.JSON === t ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(y.responseText))) : m && m(y));
|
|
267
|
+
}, y.open("GET", s, !1), y.send();
|
|
268
268
|
}, I = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(s) {
|
|
@@ -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 O[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
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 L[o !== t ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(s) {
|
|
346
346
|
var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
@@ -415,11 +415,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
415
415
|
return i(s.year() || n.MIN_YEAR, 4) + "-" + i(s.month() || n.MIN_MONTH, 2) + "-" + i(s.day() || n.MIN_DAY, 2);
|
|
416
416
|
},
|
|
417
417
|
parse: function(s) {
|
|
418
|
-
var o = Number(s.slice(0, 4)),
|
|
418
|
+
var o = Number(s.slice(0, 4)), m = Number(s.slice(5, 7)), y = Number(s.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: o,
|
|
421
|
-
month:
|
|
422
|
-
day:
|
|
421
|
+
month: m,
|
|
422
|
+
day: y
|
|
423
423
|
};
|
|
424
424
|
},
|
|
425
425
|
minLength: 10,
|
|
@@ -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)), y = Number(s.slice(6, 10));
|
|
435
435
|
return {
|
|
436
|
-
year:
|
|
436
|
+
year: y,
|
|
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
|
+
}, B = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, M;
|
|
449
|
+
M = 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 !== t && this.set(s, o,
|
|
459
|
-
},
|
|
458
|
+
}, s !== t && this.set(s, o, m), this;
|
|
459
|
+
}, M.fn = M.prototype, M.fn.dayCount = function() {
|
|
460
460
|
var s = this.month(), o = n.MAX_DAY_IN_MONTHS[s - (n.options("monthFromZero") ? 0 : 1)];
|
|
461
461
|
return this.leapYear() && s === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
|
|
462
|
-
},
|
|
462
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.fn.week = function() {
|
|
505
505
|
var s = new Date(this.year(), 0, 1), o = n(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
|
|
506
506
|
return Math.ceil(((o - s.getTime()) / 864e5 + s.getDay() + 1) / 7);
|
|
507
|
-
},
|
|
507
|
+
}, M.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
|
|
523
|
+
var y, H = [], D, C, Q = [], W = 0, F = 0, U, X, P = {}, Y;
|
|
524
524
|
if (s === t)
|
|
525
|
-
return D = a(this,
|
|
525
|
+
return D = a(this, m), D === t && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -533,23 +533,23 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
533
533
|
}), D;
|
|
534
534
|
for (o === t && (o = n.detectFormat(s)); W < o.length; ) {
|
|
535
535
|
if (o.charAt(W) === "%") {
|
|
536
|
-
if (
|
|
537
|
-
switch (U = 0, X = "", I[
|
|
536
|
+
if (C = o.charAt(W) + o.charAt(W + 1), I[C] !== t) {
|
|
537
|
+
switch (U = 0, X = "", I[C].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (; U < I[
|
|
539
|
+
for (; U < I[C].maxLength && F + U < s.length && !isNaN(Number(s.charAt(F + U))); )
|
|
540
540
|
X += s.charAt(F + U), U += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (; U < I[
|
|
543
|
+
for (; U < I[C].maxLength && F + U < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + U)); )
|
|
544
544
|
X += s.charAt(F + U), U += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (; U < I[
|
|
547
|
+
for (; U < I[C].maxLength && F + U < s.length; )
|
|
548
548
|
X += s.charAt(F + U), U += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (U < I[
|
|
552
|
-
return D = a(this,
|
|
551
|
+
if (U < I[C].minLength)
|
|
552
|
+
return D = a(this, m), D === t && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
555
555
|
day: -1,
|
|
@@ -558,10 +558,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
560
|
}), D;
|
|
561
|
-
H.push(
|
|
561
|
+
H.push(C), Q.push(X), U -= 1, F += U, W += 1;
|
|
562
562
|
}
|
|
563
563
|
} else if (s.charAt(F) !== o.charAt(W))
|
|
564
|
-
return D = a(this,
|
|
564
|
+
return D = a(this, m), D === t && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -572,8 +572,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
572
572
|
}), D;
|
|
573
573
|
W += 1, F += 1;
|
|
574
574
|
}
|
|
575
|
-
for (
|
|
576
|
-
H.hasOwnProperty(
|
|
575
|
+
for (y in H)
|
|
576
|
+
H.hasOwnProperty(y) && I.hasOwnProperty(H[y]) && (Y = I[H[y]].parse(Q[y]), P = {
|
|
577
577
|
year: Y.year !== t ? Y.year : P.year,
|
|
578
578
|
month: Y.month !== t ? Y.month : P.month,
|
|
579
579
|
day: Y.day !== t ? Y.day : P.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(P.year), this.month(P.month), this.day(P.day), this.hours(P.hours), this.minutes(P.minutes), this.seconds(P.seconds), this.milliseconds(P.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
|
-
},
|
|
587
|
+
}, M.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
|
+
}, M.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
|
+
}, M.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
|
+
}, M.fn.dayOfWeek = function(s) {
|
|
595
595
|
if (s === "long")
|
|
596
596
|
return G[this._d.getDay()];
|
|
597
597
|
if (s === "short")
|
|
598
|
-
return
|
|
598
|
+
return O[this._d.getDay()];
|
|
599
599
|
if (s === t)
|
|
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
|
+
}, M.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
|
+
}, M.fn.get = function(s) {
|
|
625
625
|
switch (s) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
@@ -670,50 +670,50 @@ 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) === "%" ? (
|
|
676
|
-
return
|
|
677
|
-
},
|
|
673
|
+
}, M.fn.format = function(s) {
|
|
674
|
+
for (var o = 0, m = "", y; o < s.length; )
|
|
675
|
+
s.charAt(o) === "%" ? (y = s.charAt(o) + s.charAt(o + 1), I[y] !== t ? (m += I[y].format(this), o += 1) : m += "%") : m += s.charAt(o), o += 1;
|
|
676
|
+
return m;
|
|
677
|
+
}, M.fn.valid = function() {
|
|
678
678
|
return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
|
|
679
|
-
},
|
|
679
|
+
}, M.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var
|
|
681
|
+
}, M.fn.between = function(s, o) {
|
|
682
|
+
var m = this.timestamp(), y = s.timestamp();
|
|
683
683
|
switch (o) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((
|
|
685
|
+
return Math.floor((y - m) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((
|
|
687
|
+
return Math.floor((y - m) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((
|
|
689
|
+
return Math.floor((y - m) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((
|
|
691
|
+
return Math.floor((y - m) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((
|
|
693
|
+
return Math.floor((y - m) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return
|
|
695
|
+
return y - m;
|
|
696
696
|
default:
|
|
697
697
|
return t;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
699
|
+
}, M.fn.calc = function(s) {
|
|
700
700
|
return s.year !== t && this._d.setFullYear(this._d.getFullYear() + s.year), s.month !== t && this._d.setMonth(this._d.getMonth() + s.month), s.day !== t && this._d.setDate(this._d.getDate() + s.day), s.hours !== t && this._d.setHours(this._d.getHours() + s.hours), s.minutes !== t && this._d.setMinutes(this._d.getMinutes() + s.minutes), s.seconds !== t && this._d.setSeconds(this._d.getSeconds() + s.seconds), s.milliseconds !== t && this._d.setMilliseconds(this._d.getMilliseconds() + s.milliseconds), this;
|
|
701
|
-
}, n = function(s, o,
|
|
702
|
-
return new
|
|
701
|
+
}, n = function(s, o, m) {
|
|
702
|
+
return new M(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 === t)
|
|
705
|
-
return
|
|
706
|
-
if (
|
|
705
|
+
return B;
|
|
706
|
+
if (B.hasOwnProperty(s)) {
|
|
707
707
|
if (o === t)
|
|
708
|
-
return
|
|
709
|
-
|
|
708
|
+
return B[s];
|
|
709
|
+
B[s] = o, s === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
|
|
710
710
|
}
|
|
711
711
|
return t;
|
|
712
712
|
}, n.noConflict = function() {
|
|
713
|
-
return r.tempus =
|
|
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, y, H, D, C, Q, W;
|
|
716
|
+
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof M ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof M ? m = s.dateTo.utc() : m = n(s.dateTo, s.formatTo !== t ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? D = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
719
719
|
day: 0,
|
|
@@ -734,7 +734,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
734
734
|
hours: s.period.hours !== t ? s.period.hours : 0,
|
|
735
735
|
minutes: s.period.minutes !== t ? s.period.minutes : 0,
|
|
736
736
|
seconds: s.period.seconds !== t ? s.period.seconds : 0
|
|
737
|
-
}), s.groupBy === t ?
|
|
737
|
+
}), s.groupBy === t ? C = s.asObject === !0 ? {} : [] : (C = [], C.push([]), Q = n(o).get()[s.groupBy]), W = function(X, P, Y) {
|
|
738
738
|
return s.asObject === !0 ? s.format !== t ? X[n(P).format(s.format)] = {} : X[n(P).format("%F %H:%M:%S")] = {} : s.format !== t ? X.push(Y ? null : n(P).format(s.format)) : X.push(Y ? null : n(P)), X;
|
|
739
739
|
}, s.groupBy !== t && s.fillNulls) {
|
|
740
740
|
var F = {
|
|
@@ -746,72 +746,72 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
746
746
|
seconds: D.seconds ? -D.seconds : t,
|
|
747
747
|
milliseconds: D.milliseconds ? -D.milliseconds : t
|
|
748
748
|
};
|
|
749
|
-
for (
|
|
750
|
-
W(
|
|
749
|
+
for (y = n(o).calc(F).utc(); n(y).get()[s.groupBy] === Q; )
|
|
750
|
+
W(C[C.length - 1], y, !0), y = n(y).calc(F).utc();
|
|
751
751
|
if (s.groupBy === "week") {
|
|
752
752
|
var U = n(o).dayOfWeek();
|
|
753
|
-
for (
|
|
754
|
-
W(
|
|
753
|
+
for (y = n(o).dayOfWeek(0).utc(); C[0].length < U && y < o; )
|
|
754
|
+
W(C[C.length - 1], y, !0), y = n(y).calc(D).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; o <=
|
|
758
|
-
s.groupBy === t ? W(
|
|
757
|
+
for (; o <= m; )
|
|
758
|
+
s.groupBy === t ? W(C, o) : n(o).get()[s.groupBy] === Q ? W(C[C.length - 1], o) : (C.push([]), W(C[C.length - 1], o), Q = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
|
|
759
759
|
if (s.groupBy !== t && s.fillNulls)
|
|
760
|
-
for (H = n(
|
|
761
|
-
W(
|
|
762
|
-
return
|
|
760
|
+
for (H = n(m).calc(D).utc(); n(H).get()[s.groupBy] === Q; )
|
|
761
|
+
W(C[C.length - 1], H, !0), H = n(H).calc(D).utc();
|
|
762
|
+
return C;
|
|
763
763
|
}, n.monthNames = function(s) {
|
|
764
764
|
switch (s) {
|
|
765
765
|
case "long":
|
|
766
766
|
return T;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return L;
|
|
769
769
|
}
|
|
770
770
|
}, n.dayNames = function(s) {
|
|
771
771
|
switch (s) {
|
|
772
772
|
case "long":
|
|
773
773
|
return G;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return O;
|
|
776
776
|
}
|
|
777
777
|
}, n.lang = function(s) {
|
|
778
778
|
if (s !== t)
|
|
779
|
-
A = s,
|
|
779
|
+
A = s, c[A] === t && (A = "en"), T = N(), L = _(), G = R(), O = k();
|
|
780
780
|
else
|
|
781
781
|
return A;
|
|
782
782
|
return t;
|
|
783
783
|
}, n.availableLangs = function() {
|
|
784
|
-
return Object.keys(
|
|
785
|
-
}, n.registerFormat = function(s, o,
|
|
784
|
+
return Object.keys(c);
|
|
785
|
+
}, n.registerFormat = function(s, o, m, y, H, D) {
|
|
786
786
|
I[s] = {
|
|
787
787
|
format: o,
|
|
788
|
-
parse:
|
|
789
|
-
minLength:
|
|
788
|
+
parse: m,
|
|
789
|
+
minLength: y,
|
|
790
790
|
maxLength: H,
|
|
791
791
|
type: D
|
|
792
792
|
};
|
|
793
793
|
}, n.unregisterFormat = function(s) {
|
|
794
794
|
delete I[s];
|
|
795
795
|
}, n.detectFormat = function(s) {
|
|
796
|
-
var o,
|
|
797
|
-
return o = h(s, 0), o !== "" && (
|
|
798
|
-
},
|
|
799
|
-
TempusDate:
|
|
796
|
+
var o, m, y;
|
|
797
|
+
return o = h(s, 0), o !== "" && (y = 10), m = s.charAt(y), (m === "T" || m === " ") && (o += m, y += 1), o += l(s, y), o;
|
|
798
|
+
}, g = {
|
|
799
|
+
TempusDate: M
|
|
800
800
|
}, n.classes = function(s, o) {
|
|
801
801
|
if (o === t)
|
|
802
|
-
return
|
|
803
|
-
|
|
802
|
+
return g[s];
|
|
803
|
+
g[s] = o;
|
|
804
804
|
}, n.loadTranslations = function(s) {
|
|
805
|
-
typeof s == "object" ?
|
|
806
|
-
|
|
805
|
+
typeof s == "object" ? c = s : typeof s == "string" && S(s, function(o) {
|
|
806
|
+
c = o;
|
|
807
807
|
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
}, A = (
|
|
810
|
-
}).call(
|
|
811
|
-
})(
|
|
812
|
-
var
|
|
813
|
-
const
|
|
814
|
-
var
|
|
809
|
+
}, A = (f.language || f.systemLanguage || f.userLanguage || "en").substr(0, 2).toLowerCase(), c[A] === t && (A = "en"), T = N(), L = _(), G = R(), O = k(), d.exports && (e = d.exports = n), e.tempus = n;
|
|
810
|
+
}).call(Ce);
|
|
811
|
+
})($t, $t.exports);
|
|
812
|
+
var He = $t.exports;
|
|
813
|
+
const Lt = /* @__PURE__ */ Be(He);
|
|
814
|
+
var It, he, Dt, kt, wt, Ct, ot, bt, Bt, ue, Ht, fe, $, ut, tt, ft, gt, te, et, dt, Ut, de, Pt, me, At, Mt, yt, ee, pt, se;
|
|
815
815
|
const J = class J {
|
|
816
816
|
constructor(e) {
|
|
817
817
|
/**
|
|
@@ -820,12 +820,12 @@ const J = class J {
|
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
E(this,
|
|
823
|
+
E(this, It);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
827
827
|
*/
|
|
828
|
-
E(this,
|
|
828
|
+
E(this, ot);
|
|
829
829
|
/**
|
|
830
830
|
* Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
|
|
831
831
|
*
|
|
@@ -838,7 +838,7 @@ const J = class J {
|
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
E(this,
|
|
841
|
+
E(this, Ht);
|
|
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
|
-
E(this,
|
|
849
|
+
E(this, $);
|
|
850
850
|
/**
|
|
851
851
|
* Проверяет operating-time в результате batch и ставит паузу,
|
|
852
852
|
* если сервер приблизился к лимиту выполнения.
|
|
@@ -855,6 +855,21 @@ const J = class J {
|
|
|
855
855
|
* @returns {Promise<number>} Максимальный operating-time среди команд.
|
|
856
856
|
*/
|
|
857
857
|
E(this, tt);
|
|
858
|
+
/**
|
|
859
|
+
* Состояние приёма «опоздавших» ответов callBatch после клиентского таймаута.
|
|
860
|
+
* Живёт на весь цикл ретраев одного chunk — ответ от более ранней попытки
|
|
861
|
+
* принимается, пока chunk ещё не завершён успешно.
|
|
862
|
+
* @returns {{
|
|
863
|
+
* inRetryCycle: boolean,
|
|
864
|
+
* inTimeoutWait: boolean,
|
|
865
|
+
* lateResult: Object|null,
|
|
866
|
+
* lateWaiters: Array<(result: Object) => void>,
|
|
867
|
+
* notifyLateResponse: (result: Object) => void,
|
|
868
|
+
* waitForLateOrLimit: () => Promise<void>,
|
|
869
|
+
* resetLateResult: () => void,
|
|
870
|
+
* }}
|
|
871
|
+
*/
|
|
872
|
+
E(this, gt);
|
|
858
873
|
/**
|
|
859
874
|
* Выполняет один chunk с автоматическим повтором после лимит-паузы.
|
|
860
875
|
* Повтор запускается при ошибках QUERY_LIMIT_EXCEEDED, OPERATION_TIME_LIMIT или TIMEOUT.
|
|
@@ -869,18 +884,19 @@ const J = class J {
|
|
|
869
884
|
*
|
|
870
885
|
* @param {string} method - Имя REST-метода.
|
|
871
886
|
* @param {Object} params - Параметры REST-метода.
|
|
887
|
+
* @param {{ onLateResponse?: (result: Object) => void }} [options] - `onLateResponse` — ответ после клиентского таймаута
|
|
872
888
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
889
|
*/
|
|
874
|
-
E(this,
|
|
890
|
+
E(this, Ut);
|
|
875
891
|
/**
|
|
876
892
|
* Код и текст ошибки подкоманды batch.
|
|
877
893
|
* `errorsList` по-прежнему отдаёт коды; описания — в `errorsListMessages`.
|
|
878
894
|
* @param {{ error?: () => { ex?: { error?: string, error_description?: string }, toString?: () => string } | null }} value
|
|
879
895
|
* @returns {{ code: string, message: string }}
|
|
880
896
|
*/
|
|
881
|
-
E(this,
|
|
882
|
-
E(this,
|
|
883
|
-
E(this,
|
|
897
|
+
E(this, Pt);
|
|
898
|
+
E(this, At);
|
|
899
|
+
E(this, yt);
|
|
884
900
|
/**
|
|
885
901
|
* Resets mutable runtime state before each public batch run.
|
|
886
902
|
* @param {Function} progressCall - Progress callback for current run.
|
|
@@ -901,31 +917,31 @@ const J = class J {
|
|
|
901
917
|
if (!this.progressData)
|
|
902
918
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
903
919
|
const e = this.totalBatchCommands || 0;
|
|
904
|
-
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length &&
|
|
905
|
-
let
|
|
906
|
-
for (const
|
|
907
|
-
const
|
|
908
|
-
if (!
|
|
920
|
+
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && p(this, It, he).call(this)) {
|
|
921
|
+
let u = 0;
|
|
922
|
+
for (const c of this.batchCommandKeyOrder) {
|
|
923
|
+
const N = this.progressData[c];
|
|
924
|
+
if (!N)
|
|
909
925
|
continue;
|
|
910
|
-
const _ = Number(
|
|
911
|
-
_ === 0 &&
|
|
926
|
+
const _ = Number(N.total) || 0, R = Number(N.count) || 0;
|
|
927
|
+
_ === 0 && R === 0 ? u += 1 : _ > 0 && (u += Math.min(1, R / _));
|
|
912
928
|
}
|
|
913
|
-
const n =
|
|
914
|
-
let
|
|
915
|
-
const
|
|
916
|
-
return { percent:
|
|
929
|
+
const n = u / e * 100;
|
|
930
|
+
let g = Math.max(0, Math.min(100, Math.floor(n)));
|
|
931
|
+
const f = e, A = Math.min(e, Math.floor(u));
|
|
932
|
+
return { percent: g, allCount: A, allTotal: f };
|
|
917
933
|
}
|
|
918
934
|
let t = 0, r = 0;
|
|
919
|
-
for (const
|
|
920
|
-
const { total: n, count:
|
|
921
|
-
t += n ?? 0, r +=
|
|
935
|
+
for (const u of Object.values(this.progressData)) {
|
|
936
|
+
const { total: n, count: g } = u;
|
|
937
|
+
t += n ?? 0, r += g ?? 0;
|
|
922
938
|
}
|
|
923
939
|
const i = Number(this.chunkRate) || 0;
|
|
924
940
|
let a = 0;
|
|
925
941
|
t ? a = r / t * 100 * i + this.totalProgress : r === 0 && t === 0 ? a = i < 1 ? this.totalProgress : 100 * i + this.totalProgress : a = 100, a = Math.max(0, Math.min(a, 100));
|
|
926
|
-
let
|
|
942
|
+
let l = Math.floor(a);
|
|
927
943
|
const h = Number(this.chunkRate) || 0;
|
|
928
|
-
return t > 0 && r >= t && h >= 1 && (
|
|
944
|
+
return t > 0 && r >= t && h >= 1 && (l = 100), { percent: l, allCount: r, allTotal: t };
|
|
929
945
|
}
|
|
930
946
|
/**
|
|
931
947
|
* Обновление данных прогресса выполнения
|
|
@@ -935,34 +951,34 @@ const J = class J {
|
|
|
935
951
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
936
952
|
*/
|
|
937
953
|
setProgressData({ key: e, value: t, type: r }) {
|
|
938
|
-
var
|
|
954
|
+
var c, N;
|
|
939
955
|
if (!this.progressCall)
|
|
940
956
|
return;
|
|
941
957
|
const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
|
|
942
|
-
let
|
|
958
|
+
let l = a;
|
|
943
959
|
if (typeof t.total == "function") {
|
|
944
960
|
const _ = t.total();
|
|
945
961
|
if (_ != null && _ !== "") {
|
|
946
|
-
const
|
|
947
|
-
Number.isFinite(
|
|
962
|
+
const R = Number(_);
|
|
963
|
+
Number.isFinite(R) && (l = R);
|
|
948
964
|
}
|
|
949
965
|
}
|
|
950
966
|
let h = 1;
|
|
951
|
-
r === "count" ? (
|
|
952
|
-
const
|
|
967
|
+
r === "count" ? (l || (l = a), h = l > 0 ? l : a > 0 ? a : 1) : i && (h = a), this.progressData || (this.progressData = {});
|
|
968
|
+
const u = ((c = this.progressData[e]) == null ? void 0 : c.total) ?? 0, n = ((N = this.progressData[e]) == null ? void 0 : N.count) ?? 0, g = h + n, f = Math.max(u, l ?? 0, g);
|
|
953
969
|
if (this.progressData[e] = {
|
|
954
|
-
total:
|
|
955
|
-
count: Math.min(
|
|
970
|
+
total: f,
|
|
971
|
+
count: Math.min(g, f)
|
|
956
972
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
957
|
-
|
|
973
|
+
p(this, ot, bt).call(this);
|
|
958
974
|
return;
|
|
959
975
|
}
|
|
960
|
-
|
|
976
|
+
p(this, ot, bt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
961
977
|
if (!this.progressCall) {
|
|
962
978
|
this.clearProgressData();
|
|
963
979
|
return;
|
|
964
980
|
}
|
|
965
|
-
|
|
981
|
+
p(this, ot, bt).call(this);
|
|
966
982
|
const { percent: _ } = this.progressPercent;
|
|
967
983
|
_ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
968
984
|
}, this.progressDelay));
|
|
@@ -987,7 +1003,7 @@ const J = class J {
|
|
|
987
1003
|
* @returns {void}
|
|
988
1004
|
*/
|
|
989
1005
|
setTimeLimitState(e, t, r) {
|
|
990
|
-
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0,
|
|
1006
|
+
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, p(this, Ht, fe).call(this);
|
|
991
1007
|
}
|
|
992
1008
|
/**
|
|
993
1009
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1020,20 +1036,20 @@ const J = class J {
|
|
|
1020
1036
|
const a = i.filter || i.FILTER;
|
|
1021
1037
|
if (!a || typeof a != "object" || Array.isArray(a))
|
|
1022
1038
|
return [{ key: e, request: t }];
|
|
1023
|
-
for (const [
|
|
1024
|
-
if (!String(
|
|
1025
|
-
const
|
|
1039
|
+
for (const [l, h] of Object.entries(a))
|
|
1040
|
+
if (!String(l).trim().startsWith("!") && Array.isArray(h) && h.length > this.filterChunkSize) {
|
|
1041
|
+
const u = [];
|
|
1026
1042
|
for (let n = 0; n < h.length; n += this.filterChunkSize) {
|
|
1027
|
-
const
|
|
1028
|
-
i.filter ? (A.filter = { ...a }, A.filter[
|
|
1029
|
-
key:
|
|
1043
|
+
const g = h.slice(n, n + this.filterChunkSize), f = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
|
|
1044
|
+
i.filter ? (A.filter = { ...a }, A.filter[l] = g) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[l] = g), u.push({
|
|
1045
|
+
key: f,
|
|
1030
1046
|
request: { method: r, params: A },
|
|
1031
1047
|
originalKey: e,
|
|
1032
|
-
filterKey:
|
|
1048
|
+
filterKey: l,
|
|
1033
1049
|
chunkIndex: Math.floor(n / this.filterChunkSize)
|
|
1034
1050
|
});
|
|
1035
1051
|
}
|
|
1036
|
-
return
|
|
1052
|
+
return u;
|
|
1037
1053
|
}
|
|
1038
1054
|
return [{ key: e, request: t }];
|
|
1039
1055
|
}
|
|
@@ -1044,13 +1060,13 @@ const J = class J {
|
|
|
1044
1060
|
* @returns {Array} Объединенный массив результатов
|
|
1045
1061
|
*/
|
|
1046
1062
|
mergeSplitResults(e, t) {
|
|
1047
|
-
const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`),
|
|
1048
|
-
const n = h.match(/__chunk_(\d+)$/),
|
|
1049
|
-
return n ?
|
|
1063
|
+
const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), l = Object.keys(e).filter((h) => a.test(h)).sort((h, u) => {
|
|
1064
|
+
const n = h.match(/__chunk_(\d+)$/), g = u.match(/__chunk_(\d+)$/);
|
|
1065
|
+
return n ? g ? parseInt(n[1]) - parseInt(g[1]) : 1 : -1;
|
|
1050
1066
|
});
|
|
1051
|
-
for (const h of
|
|
1052
|
-
const
|
|
1053
|
-
Array.isArray(
|
|
1067
|
+
for (const h of l) {
|
|
1068
|
+
const u = e[h];
|
|
1069
|
+
Array.isArray(u) ? r.push(...u) : u && r.push(u);
|
|
1054
1070
|
}
|
|
1055
1071
|
return r;
|
|
1056
1072
|
}
|
|
@@ -1067,28 +1083,32 @@ const J = class J {
|
|
|
1067
1083
|
* поэтому добавляем таймаут в 30 секунд
|
|
1068
1084
|
* @param {Object} chunk - Объект с методами для выполнения
|
|
1069
1085
|
* @param {Function} callback - Callback функция для обработки результата
|
|
1086
|
+
* @param {{ onLateResponse?: (result: Object) => void }} [options] - Опции; `onLateResponse` — ответ после клиентского таймаута
|
|
1070
1087
|
* @returns {Promise<void>}
|
|
1071
1088
|
*/
|
|
1072
|
-
callBatchWithTimeout(e, t) {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1089
|
+
callBatchWithTimeout(e, t, r = {}) {
|
|
1090
|
+
const { onLateResponse: i } = r;
|
|
1091
|
+
return new Promise((a, l) => {
|
|
1092
|
+
let h = !1, u = null;
|
|
1093
|
+
const n = async (f) => {
|
|
1094
|
+
if (h)
|
|
1095
|
+
typeof i == "function" && i(f);
|
|
1096
|
+
else {
|
|
1097
|
+
h = !0, u && clearTimeout(u);
|
|
1078
1098
|
try {
|
|
1079
|
-
await Promise.resolve(t(
|
|
1080
|
-
} catch (
|
|
1081
|
-
console.error("Error in callBatch callback:",
|
|
1099
|
+
await Promise.resolve(t(f)), a();
|
|
1100
|
+
} catch (A) {
|
|
1101
|
+
console.error("Error in callBatch callback:", A), l(A);
|
|
1082
1102
|
}
|
|
1083
1103
|
}
|
|
1084
|
-
},
|
|
1085
|
-
if (!
|
|
1086
|
-
|
|
1104
|
+
}, g = async () => {
|
|
1105
|
+
if (!h) {
|
|
1106
|
+
h = !0, u && clearTimeout(u), console.warn(
|
|
1087
1107
|
`Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
|
|
1088
1108
|
);
|
|
1089
|
-
const
|
|
1090
|
-
Object.keys(e).forEach((
|
|
1091
|
-
|
|
1109
|
+
const f = {};
|
|
1110
|
+
Object.keys(e).forEach((A) => {
|
|
1111
|
+
f[A] = {
|
|
1092
1112
|
error: () => ({
|
|
1093
1113
|
ex: {
|
|
1094
1114
|
error: "TIMEOUT",
|
|
@@ -1100,23 +1120,23 @@ const J = class J {
|
|
|
1100
1120
|
};
|
|
1101
1121
|
});
|
|
1102
1122
|
try {
|
|
1103
|
-
await Promise.resolve(t(
|
|
1104
|
-
} catch (
|
|
1105
|
-
console.error("Error in timeout callback:",
|
|
1123
|
+
await Promise.resolve(t(f)), a();
|
|
1124
|
+
} catch (A) {
|
|
1125
|
+
console.error("Error in timeout callback:", A), a();
|
|
1106
1126
|
}
|
|
1107
1127
|
}
|
|
1108
1128
|
};
|
|
1109
1129
|
try {
|
|
1110
|
-
this.callBatch(e, async (
|
|
1111
|
-
await
|
|
1130
|
+
this.callBatch(e, async (f) => {
|
|
1131
|
+
await n(f);
|
|
1112
1132
|
});
|
|
1113
|
-
} catch (
|
|
1114
|
-
|
|
1133
|
+
} catch (f) {
|
|
1134
|
+
h || console.error("Error calling callBatch:", f);
|
|
1115
1135
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1136
|
+
u = setTimeout(async () => {
|
|
1137
|
+
h || (console.warn(
|
|
1118
1138
|
`Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
|
|
1119
|
-
), await
|
|
1139
|
+
), await g());
|
|
1120
1140
|
}, this.requestTimeoutMs);
|
|
1121
1141
|
});
|
|
1122
1142
|
}
|
|
@@ -1139,34 +1159,34 @@ const J = class J {
|
|
|
1139
1159
|
* @returns {Promise<Object>}
|
|
1140
1160
|
*/
|
|
1141
1161
|
async batch(e, t, r = {}) {
|
|
1142
|
-
|
|
1143
|
-
const i = {}, a = {},
|
|
1144
|
-
for (const [
|
|
1145
|
-
const A = this.arrayChunk(
|
|
1162
|
+
p(this, pt, se).call(this, t);
|
|
1163
|
+
const i = {}, a = {}, l = {};
|
|
1164
|
+
for (const [g, f] of Object.entries(e)) {
|
|
1165
|
+
const A = this.arrayChunk(f);
|
|
1146
1166
|
if (!A)
|
|
1147
1167
|
continue;
|
|
1148
|
-
const
|
|
1149
|
-
if (
|
|
1150
|
-
a[
|
|
1168
|
+
const c = this.splitLargeFilters(g, A);
|
|
1169
|
+
if (c.length === 1)
|
|
1170
|
+
a[g] = A;
|
|
1151
1171
|
else {
|
|
1152
|
-
|
|
1153
|
-
for (const
|
|
1154
|
-
a[
|
|
1172
|
+
l[g] = [];
|
|
1173
|
+
for (const N of c)
|
|
1174
|
+
a[N.key] = N.request, l[g].push(N.key);
|
|
1155
1175
|
}
|
|
1156
1176
|
}
|
|
1157
1177
|
this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
|
|
1158
|
-
(
|
|
1159
|
-
var
|
|
1160
|
-
return String(((
|
|
1178
|
+
(g) => {
|
|
1179
|
+
var f;
|
|
1180
|
+
return String(((f = a[g]) == null ? void 0 : f.method) || "");
|
|
1161
1181
|
}
|
|
1162
1182
|
), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
|
|
1163
|
-
let h = {},
|
|
1183
|
+
let h = {}, u = 0;
|
|
1164
1184
|
const n = Object.keys(a).length;
|
|
1165
|
-
for (const [
|
|
1185
|
+
for (const [g, f] of Object.entries(a)) {
|
|
1166
1186
|
if (!this.canContinue)
|
|
1167
1187
|
break;
|
|
1168
|
-
if (h[
|
|
1169
|
-
const A =
|
|
1188
|
+
if (h[g] = f, Object.keys(h).length >= this.limit || u + 1 === n) {
|
|
1189
|
+
const A = u + 1 === n;
|
|
1170
1190
|
await this.batchChunk(
|
|
1171
1191
|
h,
|
|
1172
1192
|
void 0,
|
|
@@ -1175,22 +1195,22 @@ const J = class J {
|
|
|
1175
1195
|
disablePagination: !1,
|
|
1176
1196
|
oneBatch: !!(r != null && r.oneBatch)
|
|
1177
1197
|
}
|
|
1178
|
-
), Object.entries(this.result).forEach(([
|
|
1179
|
-
i[
|
|
1198
|
+
), Object.entries(this.result).forEach(([c, N]) => {
|
|
1199
|
+
i[c] = N;
|
|
1180
1200
|
}), this.totalProgress = Math.round(
|
|
1181
|
-
|
|
1201
|
+
u / n * 100
|
|
1182
1202
|
), h = {};
|
|
1183
1203
|
}
|
|
1184
|
-
|
|
1204
|
+
u++;
|
|
1185
1205
|
}
|
|
1186
|
-
for (const [
|
|
1187
|
-
if (
|
|
1188
|
-
const A = this.mergeSplitResults(i,
|
|
1189
|
-
for (const
|
|
1190
|
-
delete i[
|
|
1191
|
-
i[
|
|
1206
|
+
for (const [g, f] of Object.entries(l))
|
|
1207
|
+
if (f && f.length > 0) {
|
|
1208
|
+
const A = this.mergeSplitResults(i, g);
|
|
1209
|
+
for (const c of f)
|
|
1210
|
+
delete i[c];
|
|
1211
|
+
i[g] = A;
|
|
1192
1212
|
}
|
|
1193
|
-
return
|
|
1213
|
+
return p(this, yt, ee).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
|
|
1194
1214
|
}
|
|
1195
1215
|
/**
|
|
1196
1216
|
* Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
|
|
@@ -1202,59 +1222,59 @@ const J = class J {
|
|
|
1202
1222
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
1203
1223
|
*/
|
|
1204
1224
|
async batchTotalCount(e, t) {
|
|
1205
|
-
|
|
1225
|
+
p(this, pt, se).call(this, t);
|
|
1206
1226
|
const r = {}, i = {}, a = {};
|
|
1207
|
-
for (const [
|
|
1208
|
-
const
|
|
1209
|
-
if (!
|
|
1227
|
+
for (const [u, n] of Object.entries(e)) {
|
|
1228
|
+
const g = this.arrayChunk(n);
|
|
1229
|
+
if (!g)
|
|
1210
1230
|
continue;
|
|
1211
|
-
const
|
|
1212
|
-
if (
|
|
1213
|
-
i[
|
|
1231
|
+
const f = this.splitLargeFilters(u, g);
|
|
1232
|
+
if (f.length === 1)
|
|
1233
|
+
i[u] = g;
|
|
1214
1234
|
else {
|
|
1215
|
-
a[
|
|
1216
|
-
for (const A of
|
|
1217
|
-
i[A.key] = A.request, a[
|
|
1235
|
+
a[u] = [];
|
|
1236
|
+
for (const A of f)
|
|
1237
|
+
i[A.key] = A.request, a[u].push(A.key);
|
|
1218
1238
|
}
|
|
1219
1239
|
}
|
|
1220
|
-
const
|
|
1221
|
-
for (let
|
|
1222
|
-
const n = h.slice(
|
|
1223
|
-
for (const [
|
|
1240
|
+
const l = [], h = Object.entries(i);
|
|
1241
|
+
for (let u = 0; u < h.length; u += this.limit) {
|
|
1242
|
+
const n = h.slice(u, u + this.limit), g = {};
|
|
1243
|
+
for (const [f, A] of n) {
|
|
1224
1244
|
if (!this.canContinue)
|
|
1225
1245
|
break;
|
|
1226
|
-
|
|
1246
|
+
g[f] = A;
|
|
1227
1247
|
}
|
|
1228
|
-
Object.keys(
|
|
1248
|
+
Object.keys(g).length > 0 && l.push(g);
|
|
1229
1249
|
}
|
|
1230
|
-
this.chunkRate = (1 /
|
|
1231
|
-
for (const [
|
|
1250
|
+
this.chunkRate = (1 / l.length).toFixed(5);
|
|
1251
|
+
for (const [u, n] of Object.entries(l)) {
|
|
1232
1252
|
if (!this.canContinue)
|
|
1233
1253
|
break;
|
|
1234
|
-
this.totalProgress = Math.round(Number(
|
|
1235
|
-
const
|
|
1236
|
-
await
|
|
1237
|
-
for (const [A,
|
|
1254
|
+
this.totalProgress = Math.round(Number(u) / l.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
|
|
1255
|
+
const g = Number(u) === l.length - 1;
|
|
1256
|
+
await p(this, et, dt).call(this, n, async (f) => {
|
|
1257
|
+
for (const [A, c] of Object.entries(f)) {
|
|
1238
1258
|
if (!this.canContinue)
|
|
1239
1259
|
return;
|
|
1240
|
-
if (
|
|
1241
|
-
|
|
1260
|
+
if (c.error()) {
|
|
1261
|
+
p(this, At, Mt).call(this, A, c), r[A] = 0;
|
|
1242
1262
|
continue;
|
|
1243
1263
|
}
|
|
1244
|
-
const
|
|
1245
|
-
r[A] = k, this.setProgressData({ key: A, value:
|
|
1264
|
+
const N = this.getData(c.data()), _ = Array.isArray(N) ? N.length : 0, k = typeof c.total == "function" && c.total() !== void 0 ? c.total() : _;
|
|
1265
|
+
r[A] = k, this.setProgressData({ key: A, value: c, type: "count" });
|
|
1246
1266
|
}
|
|
1247
|
-
await
|
|
1267
|
+
await p(this, tt, ft).call(this, f, !g);
|
|
1248
1268
|
});
|
|
1249
1269
|
}
|
|
1250
|
-
for (const [
|
|
1270
|
+
for (const [u, n] of Object.entries(a))
|
|
1251
1271
|
if (n && n.length > 0) {
|
|
1252
|
-
let
|
|
1253
|
-
for (const
|
|
1254
|
-
r[
|
|
1255
|
-
r[
|
|
1272
|
+
let g = 0;
|
|
1273
|
+
for (const f of n)
|
|
1274
|
+
r[f] !== void 0 && (g += r[f] || 0), delete r[f];
|
|
1275
|
+
r[u] = g;
|
|
1256
1276
|
}
|
|
1257
|
-
return Object.entries(this.errors).length && (
|
|
1277
|
+
return Object.entries(this.errors).length && (p(this, yt, ee).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
|
|
1258
1278
|
}
|
|
1259
1279
|
/**
|
|
1260
1280
|
* Выполняет одиночный REST-вызов с таймаутом и авто-повтором после лимит-паузы.
|
|
@@ -1264,36 +1284,40 @@ const J = class J {
|
|
|
1264
1284
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1265
1285
|
*/
|
|
1266
1286
|
async call({ method: e, params: t = {} }) {
|
|
1267
|
-
var
|
|
1287
|
+
var i, a, l, h, u, n, g;
|
|
1288
|
+
const r = p(this, gt, te).call(this, this.callLimitPauseMs);
|
|
1268
1289
|
for (; ; ) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1290
|
+
let f = await p(this, Ut, de).call(this, e, t, {
|
|
1291
|
+
onLateResponse: (N) => r.notifyLateResponse(N)
|
|
1292
|
+
});
|
|
1293
|
+
if (!f)
|
|
1294
|
+
if (r.inRetryCycle = !0, await r.waitForLateOrLimit(), r.lateResult)
|
|
1295
|
+
f = r.lateResult, r.resetLateResult(), r.inRetryCycle = !1;
|
|
1296
|
+
else
|
|
1297
|
+
continue;
|
|
1298
|
+
const A = {};
|
|
1299
|
+
if (f != null && f.answer)
|
|
1300
|
+
for (const [N, _] of Object.entries(f.answer))
|
|
1301
|
+
N !== "result" && _ && (A[N] = _);
|
|
1302
|
+
if (f.error()) {
|
|
1303
|
+
const N = ((a = (i = f.error()) == null ? void 0 : i.ex) == null ? void 0 : a.error) ?? "";
|
|
1304
|
+
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(N)) {
|
|
1305
|
+
await p(this, $, ut).call(this, this.callLimitPauseMs);
|
|
1282
1306
|
continue;
|
|
1283
1307
|
}
|
|
1284
|
-
const
|
|
1308
|
+
const _ = ((l = f.error()) == null ? void 0 : l.toString()) || ((u = (h = f.error()) == null ? void 0 : h.ex) == null ? void 0 : u.error_description) || ((g = (n = f.error()) == null ? void 0 : n.ex) == null ? void 0 : g.error) || "Неизвестная ошибка";
|
|
1285
1309
|
return {
|
|
1286
1310
|
success: !1,
|
|
1287
1311
|
data: !1,
|
|
1288
|
-
answer:
|
|
1289
|
-
error:
|
|
1312
|
+
answer: A,
|
|
1313
|
+
error: _
|
|
1290
1314
|
};
|
|
1291
1315
|
}
|
|
1292
|
-
let
|
|
1293
|
-
return
|
|
1316
|
+
let c = f.data();
|
|
1317
|
+
return c != null && c.items && (c = c.items), r.inRetryCycle = !1, {
|
|
1294
1318
|
success: !0,
|
|
1295
|
-
data:
|
|
1296
|
-
answer:
|
|
1319
|
+
data: c,
|
|
1320
|
+
answer: A,
|
|
1297
1321
|
error: null
|
|
1298
1322
|
};
|
|
1299
1323
|
}
|
|
@@ -1313,8 +1337,8 @@ const J = class J {
|
|
|
1313
1337
|
else {
|
|
1314
1338
|
t === "entity.item.get" ? (r.SORT || (r.SORT = { ID: "ASC" }), Array.isArray(r.select) ? r.select.includes("ID") || r.select.push("ID") : r.select = ["ID"]) : t === "tasks.task.list" ? (r.order || (r.order = {}), r.order.ID = "asc") : t === "user.get" ? (r.sort || (r.sort = "ID"), r.order || (r.order = "ASC")) : r.order = { ID: "ASC", id: "ASC" }, Array.isArray(r.select) && !r.select.includes("ID") && r.select.push("ID");
|
|
1315
1339
|
const i = t === "user.get" || t === "entity.item.get" ? r.FILTER : r.filter;
|
|
1316
|
-
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a,
|
|
1317
|
-
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof
|
|
1340
|
+
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, l]) => {
|
|
1341
|
+
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (r.start = -1);
|
|
1318
1342
|
});
|
|
1319
1343
|
}
|
|
1320
1344
|
t === "crm.type.list" && r.order && delete r.order.ID;
|
|
@@ -1324,7 +1348,7 @@ const J = class J {
|
|
|
1324
1348
|
r = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
1325
1349
|
else {
|
|
1326
1350
|
Array.isArray(r[0]) && (r[0] = {});
|
|
1327
|
-
const [i, a,
|
|
1351
|
+
const [i, a, l, h] = r;
|
|
1328
1352
|
i.ID = "ASC", h[0] !== "" && h.includes("ID") || h.push("ID");
|
|
1329
1353
|
}
|
|
1330
1354
|
return { method: t, params: r };
|
|
@@ -1337,38 +1361,38 @@ const J = class J {
|
|
|
1337
1361
|
*/
|
|
1338
1362
|
async batchChunk(e, t, r = !0, i = {}) {
|
|
1339
1363
|
return new Promise((a) => {
|
|
1340
|
-
const
|
|
1364
|
+
const l = [];
|
|
1341
1365
|
let h;
|
|
1342
|
-
const
|
|
1366
|
+
const u = !!(i != null && i.disablePagination);
|
|
1343
1367
|
(async () => {
|
|
1344
|
-
await
|
|
1345
|
-
for (const [A,
|
|
1368
|
+
await p(this, et, dt).call(this, e, async (g) => {
|
|
1369
|
+
for (const [A, c] of Object.entries(g)) {
|
|
1346
1370
|
if (!this.canContinue)
|
|
1347
1371
|
return;
|
|
1348
|
-
|
|
1349
|
-
const
|
|
1350
|
-
t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = k : this.result[A] =
|
|
1351
|
-
const T = e[A],
|
|
1352
|
-
if (!
|
|
1353
|
-
let
|
|
1354
|
-
if (Array.isArray(
|
|
1355
|
-
const [
|
|
1356
|
-
|
|
1372
|
+
c.error() && (p(this, At, Mt).call(this, A, c), h = !0);
|
|
1373
|
+
const N = this.getData(c.data()), _ = Array.isArray(N) ? N.length : 0, R = typeof c.total == "function" && c.total() !== void 0, k = R ? c.total() : _;
|
|
1374
|
+
t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = k : this.result[A] = N, this.setProgressData({ key: A, value: c, type: t });
|
|
1375
|
+
const T = e[A], L = Array.isArray(T) ? T[0] : T == null ? void 0 : T.method, G = typeof L == "string" && (L.includes(".list") || L === "user.get" || L === "entity.item.get"), O = t === "count" ? !R && _ === this.limit : G ? _ === this.limit : k > this.limit && k > _, S = t !== "count" && L === "entity.item.get" && _ === this.limit && !O, I = O || S;
|
|
1376
|
+
if (!u && (!this.canContinue || I)) {
|
|
1377
|
+
let B = e[A];
|
|
1378
|
+
if (Array.isArray(B)) {
|
|
1379
|
+
const [M, s = {}] = B;
|
|
1380
|
+
B = [M, s];
|
|
1357
1381
|
} else {
|
|
1358
|
-
const { method:
|
|
1359
|
-
|
|
1382
|
+
const { method: M, params: s = {} } = B;
|
|
1383
|
+
B = [M, s];
|
|
1360
1384
|
}
|
|
1361
|
-
|
|
1385
|
+
l.push([
|
|
1362
1386
|
A,
|
|
1363
|
-
|
|
1387
|
+
B,
|
|
1364
1388
|
k,
|
|
1365
1389
|
{ entityItemGetScan: S }
|
|
1366
1390
|
]);
|
|
1367
1391
|
}
|
|
1368
1392
|
}
|
|
1369
1393
|
h > 0 && this.errorLogger();
|
|
1370
|
-
const
|
|
1371
|
-
await
|
|
1394
|
+
const f = l.length > 0 || r;
|
|
1395
|
+
await p(this, tt, ft).call(this, g, f), l.length ? await this.batchPayload(l, t, i).then(
|
|
1372
1396
|
() => a(this.result)
|
|
1373
1397
|
) : a(this.result);
|
|
1374
1398
|
});
|
|
@@ -1381,94 +1405,94 @@ const J = class J {
|
|
|
1381
1405
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1382
1406
|
*/
|
|
1383
1407
|
async batchPayload(e, t, r = {}) {
|
|
1384
|
-
const i = !!(r != null && r.oneBatch), a = (
|
|
1408
|
+
const i = !!(r != null && r.oneBatch), a = (N, _, R, k) => {
|
|
1385
1409
|
let T = "ID";
|
|
1386
|
-
this.result[
|
|
1387
|
-
let
|
|
1388
|
-
if (JSON.stringify(k[1]).toLocaleLowerCase().includes('"id":"desc"') ?
|
|
1410
|
+
this.result[N][this.result[N].length - 1].ID || (T = "id");
|
|
1411
|
+
let L = `${T}`;
|
|
1412
|
+
if (JSON.stringify(k[1]).toLocaleLowerCase().includes('"id":"desc"') ? L = "<" + L : L = ">" + L, _ === 1 || R.length === 0)
|
|
1389
1413
|
return {
|
|
1390
|
-
field:
|
|
1391
|
-
id: this.result[
|
|
1414
|
+
field: L,
|
|
1415
|
+
id: this.result[N][this.result[N].length - 1][T]
|
|
1392
1416
|
};
|
|
1393
|
-
let
|
|
1417
|
+
let O = "";
|
|
1394
1418
|
const [S, I] = k;
|
|
1395
|
-
return (S === "tasks.task.list" || S === "task.item.list") && (
|
|
1396
|
-
field:
|
|
1397
|
-
id: `$result[${[
|
|
1419
|
+
return (S === "tasks.task.list" || S === "task.item.list") && (O = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(S) && (O = "[items]"), S === "crm.type.list" && (O = "[types]"), S === "socialnetwork.api.workgroup.list" && (O = "[workgroups]"), {
|
|
1420
|
+
field: L,
|
|
1421
|
+
id: `$result[${[N, _ - 1].join("__")}]${O}[49][${T}]`
|
|
1398
1422
|
};
|
|
1399
|
-
},
|
|
1400
|
-
const [
|
|
1401
|
-
let T = JSON.parse(JSON.stringify(k)),
|
|
1402
|
-
if (
|
|
1423
|
+
}, l = (N, _) => {
|
|
1424
|
+
const [R, k] = N;
|
|
1425
|
+
let T = JSON.parse(JSON.stringify(k)), L;
|
|
1426
|
+
if (R === "task.item.list") {
|
|
1403
1427
|
T = [...T];
|
|
1404
|
-
const [G,
|
|
1405
|
-
return
|
|
1428
|
+
const [G, O, S, I] = T;
|
|
1429
|
+
return O[_.field] = _.id, [R, T];
|
|
1406
1430
|
}
|
|
1407
|
-
return ["user.get"].includes(
|
|
1431
|
+
return ["user.get"].includes(R) || T.FILTER ? (T.FILTER || (T.FILTER = {}), L = T.FILTER) : (T.filter || (T.filter = {}), L = T.filter), [
|
|
1408
1432
|
"socialnetwork.api.workgroup.list",
|
|
1409
1433
|
"tasks.task.list"
|
|
1410
|
-
].includes(
|
|
1411
|
-
}, h = (
|
|
1412
|
-
Object.entries(
|
|
1413
|
-
const [k] = _.split("__"), T = this.getData(
|
|
1414
|
-
Array.isArray(T) && (t === "count" ? this.result[k] += T.length : this.result[k].push(...T)),
|
|
1434
|
+
].includes(R) ? L[">ID"] = _.id : L[_.field] = _.id, [R, { ...T, start: -1 }];
|
|
1435
|
+
}, h = (N) => {
|
|
1436
|
+
Object.entries(N).forEach(([_, R]) => {
|
|
1437
|
+
const [k] = _.split("__"), T = this.getData(R.data());
|
|
1438
|
+
Array.isArray(T) && (t === "count" ? this.result[k] += T.length : this.result[k].push(...T)), R.error() && p(this, At, Mt).call(this, k, R), this.setProgressData({ key: k, value: R, type: t });
|
|
1415
1439
|
});
|
|
1416
|
-
},
|
|
1417
|
-
if (!Array.isArray(
|
|
1440
|
+
}, u = (N, _) => {
|
|
1441
|
+
if (!Array.isArray(N) || N.length === 0)
|
|
1418
1442
|
return null;
|
|
1419
|
-
const
|
|
1443
|
+
const R = N[N.length - 1];
|
|
1420
1444
|
let k = "ID";
|
|
1421
|
-
|
|
1445
|
+
R.ID || (k = "id");
|
|
1422
1446
|
let T = k;
|
|
1423
|
-
return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id:
|
|
1424
|
-
}, n = 1e4,
|
|
1447
|
+
return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: R[k] };
|
|
1448
|
+
}, n = 1e4, g = async (N, _) => {
|
|
1425
1449
|
var k, T;
|
|
1426
|
-
let
|
|
1427
|
-
for (let
|
|
1428
|
-
const G = this.result[
|
|
1429
|
-
if (!
|
|
1450
|
+
let R = this.limit;
|
|
1451
|
+
for (let L = 1; this.canContinue && R === this.limit && L <= n; L++) {
|
|
1452
|
+
const G = this.result[N], O = u(G, _);
|
|
1453
|
+
if (!O)
|
|
1430
1454
|
break;
|
|
1431
|
-
const S = `${
|
|
1432
|
-
let
|
|
1433
|
-
await
|
|
1434
|
-
|
|
1455
|
+
const S = `${N}__eiscan_${L}`, I = l(_, O);
|
|
1456
|
+
let B = null;
|
|
1457
|
+
await p(this, et, dt).call(this, { [S]: I }, async (m) => {
|
|
1458
|
+
B = m, h(m);
|
|
1435
1459
|
});
|
|
1436
|
-
const
|
|
1437
|
-
await
|
|
1438
|
-
const s =
|
|
1460
|
+
const M = L < n;
|
|
1461
|
+
await p(this, tt, ft).call(this, B, M), await this.delay();
|
|
1462
|
+
const s = B == null ? void 0 : B[S];
|
|
1439
1463
|
if ((k = s == null ? void 0 : s.error) != null && k.call(s)) {
|
|
1440
|
-
|
|
1464
|
+
R = 0;
|
|
1441
1465
|
break;
|
|
1442
1466
|
}
|
|
1443
1467
|
const o = this.getData((T = s == null ? void 0 : s.data) == null ? void 0 : T.call(s));
|
|
1444
|
-
|
|
1468
|
+
R = Array.isArray(o) ? o.length : 0;
|
|
1445
1469
|
}
|
|
1446
1470
|
};
|
|
1447
|
-
let
|
|
1448
|
-
const
|
|
1449
|
-
h(_), await
|
|
1450
|
-
}), A++,
|
|
1451
|
-
for await (const
|
|
1471
|
+
let f = [], A = 0;
|
|
1472
|
+
const c = async (N = !0) => f.length ? (await p(this, et, dt).call(this, Object.fromEntries(f), async (_) => {
|
|
1473
|
+
h(_), await p(this, tt, ft).call(this, _, N);
|
|
1474
|
+
}), A++, f = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1475
|
+
for await (const N of e) {
|
|
1452
1476
|
if (!this.canContinue)
|
|
1453
1477
|
return;
|
|
1454
|
-
const [_,
|
|
1478
|
+
const [_, R, k, T = {}] = N;
|
|
1455
1479
|
if (T.entityItemGetScan) {
|
|
1456
|
-
if (await
|
|
1480
|
+
if (await c(!0))
|
|
1457
1481
|
return;
|
|
1458
1482
|
if (i)
|
|
1459
1483
|
continue;
|
|
1460
|
-
await
|
|
1484
|
+
await g(_, R);
|
|
1461
1485
|
continue;
|
|
1462
1486
|
}
|
|
1463
|
-
let
|
|
1464
|
-
for (; k >
|
|
1465
|
-
const G = [_,
|
|
1466
|
-
if (
|
|
1487
|
+
let L = 1;
|
|
1488
|
+
for (; k > L * this.limit; ) {
|
|
1489
|
+
const G = [_, L].join("__"), O = a(_, L, f, R);
|
|
1490
|
+
if (f.push([G, l(R, O)]), i && f.length === 49 && await c(!0) || f.length % 50 === 0 && await c(!0))
|
|
1467
1491
|
return;
|
|
1468
|
-
|
|
1492
|
+
L++;
|
|
1469
1493
|
}
|
|
1470
1494
|
}
|
|
1471
|
-
await
|
|
1495
|
+
await c(!1);
|
|
1472
1496
|
}
|
|
1473
1497
|
/**
|
|
1474
1498
|
* Вывод ошибок в консоль в группированном виде
|
|
@@ -1479,29 +1503,29 @@ const J = class J {
|
|
|
1479
1503
|
}), console.groupEnd();
|
|
1480
1504
|
}
|
|
1481
1505
|
};
|
|
1482
|
-
|
|
1506
|
+
It = new WeakSet(), he = function() {
|
|
1483
1507
|
const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
|
|
1484
|
-
if (e <
|
|
1508
|
+
if (e < b(J, Dt) || !Array.isArray(t) || t.length !== e)
|
|
1485
1509
|
return !1;
|
|
1486
|
-
if (t.filter((a) => a === "crm.deal.list").length >=
|
|
1510
|
+
if (t.filter((a) => a === "crm.deal.list").length >= b(J, kt))
|
|
1487
1511
|
return !0;
|
|
1488
1512
|
const i = t.filter(
|
|
1489
1513
|
(a) => typeof a == "string" && a.includes(".list")
|
|
1490
1514
|
).length;
|
|
1491
|
-
return i >=
|
|
1492
|
-
},
|
|
1515
|
+
return i >= b(J, wt) && i / e >= b(J, Ct);
|
|
1516
|
+
}, Dt = new WeakMap(), kt = new WeakMap(), wt = new WeakMap(), Ct = new WeakMap(), ot = new WeakSet(), bt = function() {
|
|
1493
1517
|
if (!this.progressCall || !this.progressData)
|
|
1494
1518
|
return;
|
|
1495
1519
|
const { percent: e, allCount: t, allTotal: r } = this.progressPercent, i = { percent: e, allCount: t, allTotal: r };
|
|
1496
|
-
|
|
1520
|
+
p(this, Bt, ue).call(this, i) && (this.progressCall({
|
|
1497
1521
|
data: this.progressData,
|
|
1498
1522
|
percent: e,
|
|
1499
1523
|
allCount: t,
|
|
1500
1524
|
allTotal: r
|
|
1501
1525
|
}), this.lastProgressSnapshot = i);
|
|
1502
|
-
}, Bt = new WeakSet(),
|
|
1526
|
+
}, Bt = new WeakSet(), ue = function(e) {
|
|
1503
1527
|
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== e.percent || this.lastProgressSnapshot.allCount !== e.allCount || this.lastProgressSnapshot.allTotal !== e.allTotal : !0;
|
|
1504
|
-
},
|
|
1528
|
+
}, Ht = new WeakSet(), fe = function() {
|
|
1505
1529
|
const e = {
|
|
1506
1530
|
limit: this.timeLimit.limit,
|
|
1507
1531
|
date: this.timeLimit.date,
|
|
@@ -1513,7 +1537,7 @@ St = new WeakSet(), ce = function() {
|
|
|
1513
1537
|
} catch (r) {
|
|
1514
1538
|
console.warn("Batch timeLimit listener error:", r);
|
|
1515
1539
|
}
|
|
1516
|
-
},
|
|
1540
|
+
}, $ = new WeakSet(), ut = async function(e = this.defaultPauseMs) {
|
|
1517
1541
|
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), e), await new Promise((t) => setTimeout(t, e)), this.setTimeLimitState(!1, void 0);
|
|
1518
1542
|
}, tt = new WeakSet(), ft = async function(e, t = !0) {
|
|
1519
1543
|
if (!t)
|
|
@@ -1530,81 +1554,129 @@ St = new WeakSet(), ce = function() {
|
|
|
1530
1554
|
}
|
|
1531
1555
|
} catch {
|
|
1532
1556
|
}
|
|
1533
|
-
r >= this.operatingThreshold && await
|
|
1557
|
+
r >= this.operatingThreshold && await p(this, $, ut).call(this);
|
|
1558
|
+
}, gt = new WeakSet(), te = function(e = this.defaultPauseMs) {
|
|
1559
|
+
const t = this;
|
|
1560
|
+
return {
|
|
1561
|
+
inRetryCycle: !1,
|
|
1562
|
+
inTimeoutWait: !1,
|
|
1563
|
+
lateResult: null,
|
|
1564
|
+
lateWaiters: [],
|
|
1565
|
+
notifyLateResponse(i) {
|
|
1566
|
+
if (!(!this.inRetryCycle && !this.inTimeoutWait)) {
|
|
1567
|
+
this.lateResult = i;
|
|
1568
|
+
for (const a of this.lateWaiters)
|
|
1569
|
+
a(i);
|
|
1570
|
+
this.lateWaiters = [];
|
|
1571
|
+
}
|
|
1572
|
+
},
|
|
1573
|
+
waitForLateOrLimit() {
|
|
1574
|
+
var a;
|
|
1575
|
+
this.inTimeoutWait = !0;
|
|
1576
|
+
const i = new Promise((l) => {
|
|
1577
|
+
if (this.lateResult) {
|
|
1578
|
+
l(this.lateResult);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
this.lateWaiters.push(l);
|
|
1582
|
+
});
|
|
1583
|
+
return Promise.race([
|
|
1584
|
+
p(a = t, $, ut).call(a, e),
|
|
1585
|
+
i
|
|
1586
|
+
]).finally(() => {
|
|
1587
|
+
this.inTimeoutWait = !1;
|
|
1588
|
+
});
|
|
1589
|
+
},
|
|
1590
|
+
resetLateResult() {
|
|
1591
|
+
this.lateResult = null;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1534
1594
|
}, et = new WeakSet(), dt = async function(e, t) {
|
|
1535
1595
|
let r = !1, i = e;
|
|
1596
|
+
const a = p(this, gt, te).call(this);
|
|
1536
1597
|
do
|
|
1537
|
-
r = !1, await this.callBatchWithTimeout(
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
c =
|
|
1547
|
-
|
|
1598
|
+
r = !1, await this.callBatchWithTimeout(
|
|
1599
|
+
i,
|
|
1600
|
+
async (l) => {
|
|
1601
|
+
var n, g;
|
|
1602
|
+
let h = !1;
|
|
1603
|
+
const u = /* @__PURE__ */ new Set();
|
|
1604
|
+
for (const [f, A] of Object.entries(l || {})) {
|
|
1605
|
+
if (!(A != null && A.error) || !A.error())
|
|
1606
|
+
continue;
|
|
1607
|
+
const c = ((g = (n = A.error()) == null ? void 0 : n.ex) == null ? void 0 : g.error) ?? "";
|
|
1608
|
+
if (c === "TIMEOUT") {
|
|
1609
|
+
h = !0;
|
|
1610
|
+
break;
|
|
1611
|
+
}
|
|
1612
|
+
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(c) && u.add(f);
|
|
1548
1613
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1614
|
+
if (h) {
|
|
1615
|
+
if (a.inRetryCycle = !0, r = !0, await a.waitForLateOrLimit(), a.lateResult) {
|
|
1616
|
+
r = !1, a.inRetryCycle = !1;
|
|
1617
|
+
const f = a.lateResult;
|
|
1618
|
+
a.resetLateResult(), await t(f);
|
|
1619
|
+
}
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
if (u.size > 0) {
|
|
1623
|
+
const f = {};
|
|
1624
|
+
for (const [c, N] of Object.entries(l || {}))
|
|
1625
|
+
u.has(c) || (f[c] = N);
|
|
1626
|
+
Object.keys(f).length && await t(f);
|
|
1627
|
+
const A = {};
|
|
1628
|
+
for (const c of u)
|
|
1629
|
+
i[c] && (A[c] = i[c]);
|
|
1630
|
+
i = A, Object.keys(i).length && (r = !0, await p(this, $, ut).call(this));
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
a.inRetryCycle = !1, await t(l);
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
onLateResponse: (l) => a.notifyLateResponse(l)
|
|
1565
1637
|
}
|
|
1566
|
-
|
|
1567
|
-
});
|
|
1638
|
+
);
|
|
1568
1639
|
while (r);
|
|
1569
|
-
},
|
|
1570
|
-
|
|
1640
|
+
}, Ut = new WeakSet(), de = function(e, t, r = {}) {
|
|
1641
|
+
const { onLateResponse: i } = r;
|
|
1642
|
+
return new Promise((a) => {
|
|
1571
1643
|
if (typeof this.callMethod != "function") {
|
|
1572
|
-
|
|
1644
|
+
a(null);
|
|
1573
1645
|
return;
|
|
1574
1646
|
}
|
|
1575
|
-
let
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1647
|
+
let l = !1;
|
|
1648
|
+
const h = setTimeout(() => {
|
|
1649
|
+
l || (l = !0, a(null));
|
|
1578
1650
|
}, this.requestTimeoutMs);
|
|
1579
1651
|
try {
|
|
1580
|
-
this.callMethod(e, t, (
|
|
1581
|
-
i
|
|
1652
|
+
this.callMethod(e, t, (u) => {
|
|
1653
|
+
l ? typeof i == "function" && i(u) : (l = !0, clearTimeout(h), a(u));
|
|
1582
1654
|
});
|
|
1583
1655
|
} catch {
|
|
1584
|
-
|
|
1656
|
+
l || (l = !0, clearTimeout(h), a(null));
|
|
1585
1657
|
}
|
|
1586
1658
|
});
|
|
1587
|
-
},
|
|
1588
|
-
const t = typeof (e == null ? void 0 : e.error) == "function" ? e.error() : null, r = (t == null ? void 0 : t.ex) || {}, i = String(r.error || "").trim(), a = String(r.error_description || "").trim(),
|
|
1659
|
+
}, Pt = new WeakSet(), me = function(e) {
|
|
1660
|
+
const t = typeof (e == null ? void 0 : e.error) == "function" ? e.error() : null, r = (t == null ? void 0 : t.ex) || {}, i = String(r.error || "").trim(), a = String(r.error_description || "").trim(), l = typeof (t == null ? void 0 : t.toString) == "function" ? String(t.toString()).trim() : "";
|
|
1589
1661
|
let h = a;
|
|
1590
|
-
return !h &&
|
|
1662
|
+
return !h && l && l !== i && (h = l), h || (h = i || "Неизвестная ошибка"), {
|
|
1591
1663
|
code: i || h,
|
|
1592
1664
|
message: h
|
|
1593
1665
|
};
|
|
1594
|
-
},
|
|
1595
|
-
const { code: r, message: i } =
|
|
1666
|
+
}, At = new WeakSet(), Mt = function(e, t) {
|
|
1667
|
+
const { code: r, message: i } = p(this, Pt, me).call(this, t);
|
|
1596
1668
|
this.errors[e] = r, this.errorMessages[e] = i;
|
|
1597
|
-
},
|
|
1669
|
+
}, yt = new WeakSet(), ee = function(e) {
|
|
1598
1670
|
Object.entries(this.errors).length && (e.errorsList = { ...this.errors }, Object.entries(this.errorMessages).length && (e.errorsListMessages = { ...this.errorMessages }));
|
|
1599
|
-
}, pt = new WeakSet(),
|
|
1671
|
+
}, pt = new WeakSet(), se = function(e) {
|
|
1600
1672
|
this.clearProgressData(), this.progressCall = typeof e == "function" ? e : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.errorMessages = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
|
|
1601
1673
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1602
|
-
E(J,
|
|
1603
|
-
E(J,
|
|
1604
|
-
E(J,
|
|
1674
|
+
E(J, Dt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1675
|
+
E(J, kt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1676
|
+
E(J, wt, 8), E(J, Ct, 0.65);
|
|
1605
1677
|
let K = J;
|
|
1606
1678
|
var st;
|
|
1607
|
-
class
|
|
1679
|
+
class ge {
|
|
1608
1680
|
constructor() {
|
|
1609
1681
|
E(this, st, {});
|
|
1610
1682
|
}
|
|
@@ -1635,7 +1707,7 @@ class de {
|
|
|
1635
1707
|
* @param {Function} params.action - Функция для выполнения
|
|
1636
1708
|
*/
|
|
1637
1709
|
actionFilter({ keyTimer: e, duration: t = 10, action: r }) {
|
|
1638
|
-
|
|
1710
|
+
b(this, st)[e] && (clearTimeout(b(this, st)[e]), b(this, st)[e] = null), r && (b(this, st)[e] = setTimeout(() => {
|
|
1639
1711
|
r();
|
|
1640
1712
|
}, t));
|
|
1641
1713
|
}
|
|
@@ -1674,28 +1746,28 @@ class de {
|
|
|
1674
1746
|
}
|
|
1675
1747
|
}
|
|
1676
1748
|
st = new WeakMap();
|
|
1677
|
-
const
|
|
1678
|
-
var j, z, rt, lt,
|
|
1679
|
-
class
|
|
1749
|
+
const Zt = new ge();
|
|
1750
|
+
var j, z, rt, lt, Nt, Z, v, it, ct, Gt, ye, Ot, re, Yt, pe, Wt, Ne, xt, Oe;
|
|
1751
|
+
class Ue {
|
|
1680
1752
|
constructor() {
|
|
1681
1753
|
/** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
|
|
1682
|
-
E(this,
|
|
1754
|
+
E(this, Gt);
|
|
1683
1755
|
/** Вывод ошибок логера
|
|
1684
1756
|
* @param {'entity'} type - тип ошибки
|
|
1685
1757
|
*/
|
|
1686
|
-
E(this,
|
|
1687
|
-
E(this, Gt);
|
|
1758
|
+
E(this, Ot);
|
|
1688
1759
|
E(this, Yt);
|
|
1689
1760
|
E(this, Wt);
|
|
1761
|
+
E(this, xt);
|
|
1690
1762
|
E(this, j, "logger");
|
|
1691
1763
|
E(this, z, !1);
|
|
1692
1764
|
E(this, rt, /* @__PURE__ */ new Map());
|
|
1693
1765
|
E(this, lt, {});
|
|
1694
|
-
E(this,
|
|
1695
|
-
E(this,
|
|
1766
|
+
E(this, Nt, !1);
|
|
1767
|
+
E(this, Z, null);
|
|
1696
1768
|
E(this, v, null);
|
|
1697
1769
|
E(this, it, !1);
|
|
1698
|
-
E(this,
|
|
1770
|
+
E(this, ct, !1);
|
|
1699
1771
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1700
1772
|
w(this, "periodClear", 3);
|
|
1701
1773
|
}
|
|
@@ -1707,7 +1779,7 @@ class Ce {
|
|
|
1707
1779
|
});
|
|
1708
1780
|
if (t && Array.isArray(t))
|
|
1709
1781
|
if (t.find(
|
|
1710
|
-
(i) => i.ENTITY ==
|
|
1782
|
+
(i) => i.ENTITY == b(this, j)
|
|
1711
1783
|
))
|
|
1712
1784
|
x(this, z, !0);
|
|
1713
1785
|
else {
|
|
@@ -1715,15 +1787,15 @@ class Ce {
|
|
|
1715
1787
|
entityAdd: {
|
|
1716
1788
|
method: "entity.add",
|
|
1717
1789
|
params: {
|
|
1718
|
-
ENTITY:
|
|
1719
|
-
NAME:
|
|
1790
|
+
ENTITY: b(this, j),
|
|
1791
|
+
NAME: b(this, j),
|
|
1720
1792
|
ACCESS: { AU: "X" }
|
|
1721
1793
|
}
|
|
1722
1794
|
}
|
|
1723
1795
|
});
|
|
1724
1796
|
i && x(this, z, !0);
|
|
1725
1797
|
}
|
|
1726
|
-
return
|
|
1798
|
+
return b(this, z);
|
|
1727
1799
|
} catch (e) {
|
|
1728
1800
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1729
1801
|
}
|
|
@@ -1745,11 +1817,11 @@ class Ce {
|
|
|
1745
1817
|
* @returns {string|null}
|
|
1746
1818
|
*/
|
|
1747
1819
|
start({ type: e, data: t }) {
|
|
1748
|
-
if (!
|
|
1749
|
-
return
|
|
1820
|
+
if (!b(this, z))
|
|
1821
|
+
return p(this, Ot, re).call(this, "entity"), null;
|
|
1750
1822
|
if (!e || !t)
|
|
1751
1823
|
return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
|
|
1752
|
-
const r =
|
|
1824
|
+
const r = Zt.hash, i = {
|
|
1753
1825
|
type: e,
|
|
1754
1826
|
data: t,
|
|
1755
1827
|
userInfo: null,
|
|
@@ -1758,7 +1830,7 @@ class Ce {
|
|
|
1758
1830
|
answer: null,
|
|
1759
1831
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1760
1832
|
};
|
|
1761
|
-
return
|
|
1833
|
+
return b(this, rt).set(r, i), x(this, ct, !0), r;
|
|
1762
1834
|
}
|
|
1763
1835
|
/**
|
|
1764
1836
|
* @param {{
|
|
@@ -1768,19 +1840,19 @@ class Ce {
|
|
|
1768
1840
|
* answer: { [key]: unknown } }}
|
|
1769
1841
|
*/
|
|
1770
1842
|
async stop({ key: e, errorList: t, status: r, answer: i }) {
|
|
1771
|
-
var
|
|
1772
|
-
if (!
|
|
1843
|
+
var l;
|
|
1844
|
+
if (!b(this, ct))
|
|
1773
1845
|
return;
|
|
1774
|
-
if (!
|
|
1775
|
-
|
|
1846
|
+
if (!b(this, z)) {
|
|
1847
|
+
p(this, Ot, re).call(this, "entity");
|
|
1776
1848
|
return;
|
|
1777
1849
|
}
|
|
1778
|
-
let a =
|
|
1850
|
+
let a = b(this, rt).get(e);
|
|
1779
1851
|
if (!a) {
|
|
1780
1852
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1781
1853
|
return;
|
|
1782
1854
|
}
|
|
1783
|
-
t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await
|
|
1855
|
+
t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await p(this, Gt, ye).call(this), a.userInfo = b(this, lt), await p(this, Yt, pe).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && x(this, it, !0), x(this, ct, !1);
|
|
1784
1856
|
}
|
|
1785
1857
|
/**
|
|
1786
1858
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1788,14 +1860,14 @@ class Ce {
|
|
|
1788
1860
|
async getEntityList(e) {
|
|
1789
1861
|
var t;
|
|
1790
1862
|
try {
|
|
1791
|
-
if ((t =
|
|
1792
|
-
return
|
|
1863
|
+
if ((t = b(this, v)) != null && t.length && !b(this, it))
|
|
1864
|
+
return b(this, v);
|
|
1793
1865
|
let r = new K(BX24.callBatch), { entityList: i } = await r.batch(
|
|
1794
1866
|
{
|
|
1795
1867
|
entityList: {
|
|
1796
1868
|
method: "entity.item.get",
|
|
1797
1869
|
params: {
|
|
1798
|
-
ENTITY:
|
|
1870
|
+
ENTITY: b(this, j),
|
|
1799
1871
|
SORT: { ID: "DESC" }
|
|
1800
1872
|
}
|
|
1801
1873
|
}
|
|
@@ -1804,16 +1876,16 @@ class Ce {
|
|
|
1804
1876
|
);
|
|
1805
1877
|
return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
|
|
1806
1878
|
try {
|
|
1807
|
-
const { ID:
|
|
1879
|
+
const { ID: l, DATE_CREATE: h, DETAIL_TEXT: u } = a;
|
|
1808
1880
|
return {
|
|
1809
|
-
...JSON.parse(
|
|
1810
|
-
id:
|
|
1881
|
+
...JSON.parse(u),
|
|
1882
|
+
id: l,
|
|
1811
1883
|
dateCreate: h
|
|
1812
1884
|
};
|
|
1813
|
-
} catch (
|
|
1885
|
+
} catch (l) {
|
|
1814
1886
|
return console.error(
|
|
1815
1887
|
`Ошибка парсинга записи ${a.ID}:`,
|
|
1816
|
-
|
|
1888
|
+
l
|
|
1817
1889
|
), null;
|
|
1818
1890
|
}
|
|
1819
1891
|
}).filter((a) => a !== null), x(this, it, !1), x(this, v, i), i);
|
|
@@ -1826,16 +1898,16 @@ class Ce {
|
|
|
1826
1898
|
* Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
|
|
1827
1899
|
*/
|
|
1828
1900
|
runStorageMaintenance() {
|
|
1829
|
-
return
|
|
1901
|
+
return p(this, Wt, Ne).call(this);
|
|
1830
1902
|
}
|
|
1831
1903
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1832
1904
|
async downAllEntityJson() {
|
|
1833
1905
|
try {
|
|
1834
|
-
if (
|
|
1906
|
+
if (b(this, v) || await this.getEntityList(), !b(this, v) || b(this, v).length === 0)
|
|
1835
1907
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1836
|
-
let e =
|
|
1837
|
-
return
|
|
1838
|
-
|
|
1908
|
+
let e = Lt().format("%Y-%m-%d");
|
|
1909
|
+
return Zt.downloadFileJson(
|
|
1910
|
+
b(this, v),
|
|
1839
1911
|
`sdklogger-entity-data__${e}`
|
|
1840
1912
|
), !0;
|
|
1841
1913
|
} catch (e) {
|
|
@@ -1843,9 +1915,9 @@ class Ce {
|
|
|
1843
1915
|
}
|
|
1844
1916
|
}
|
|
1845
1917
|
}
|
|
1846
|
-
j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(),
|
|
1847
|
-
if (!
|
|
1848
|
-
return
|
|
1918
|
+
j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt = new WeakMap(), Z = new WeakMap(), v = new WeakMap(), it = new WeakMap(), ct = new WeakMap(), Gt = new WeakSet(), ye = async function() {
|
|
1919
|
+
if (!b(this, Nt))
|
|
1920
|
+
return b(this, Z) ? b(this, Z) : (x(this, Z, (async () => {
|
|
1849
1921
|
try {
|
|
1850
1922
|
const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser: r } = await e.batch({
|
|
1851
1923
|
curUser: { method: "user.current" }
|
|
@@ -1857,43 +1929,43 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
|
|
|
1857
1929
|
e
|
|
1858
1930
|
), x(this, lt, { isAdmin: !1, curUser: null });
|
|
1859
1931
|
} finally {
|
|
1860
|
-
x(this,
|
|
1932
|
+
x(this, Nt, !0), x(this, Z, null);
|
|
1861
1933
|
}
|
|
1862
|
-
})()),
|
|
1863
|
-
},
|
|
1864
|
-
e == "entity" &&
|
|
1934
|
+
})()), b(this, Z));
|
|
1935
|
+
}, Ot = new WeakSet(), re = function(e) {
|
|
1936
|
+
e == "entity" && Zt.actionFilter({
|
|
1865
1937
|
keyTimer: "error.logger.entity",
|
|
1866
1938
|
duration: 500,
|
|
1867
1939
|
action: () => {
|
|
1868
1940
|
console.error("Хранилище для логгера не инициализировано");
|
|
1869
1941
|
}
|
|
1870
1942
|
});
|
|
1871
|
-
},
|
|
1943
|
+
}, Yt = new WeakSet(), pe = async function() {
|
|
1872
1944
|
try {
|
|
1873
1945
|
let e = {}, t = new K(BX24.callBatch);
|
|
1874
|
-
for (let [r, i] of
|
|
1946
|
+
for (let [r, i] of b(this, rt).entries())
|
|
1875
1947
|
if (i.status) {
|
|
1876
1948
|
const a = JSON.stringify(i);
|
|
1877
1949
|
e[r] = {
|
|
1878
1950
|
method: "entity.item.add",
|
|
1879
1951
|
params: {
|
|
1880
|
-
ENTITY:
|
|
1881
|
-
NAME:
|
|
1952
|
+
ENTITY: b(this, j),
|
|
1953
|
+
NAME: b(this, j),
|
|
1882
1954
|
DETAIL_TEXT: a
|
|
1883
1955
|
}
|
|
1884
1956
|
};
|
|
1885
1957
|
}
|
|
1886
1958
|
if (Object.keys(e).length) {
|
|
1887
1959
|
let r = await t.batch(e), { errors: i } = t;
|
|
1888
|
-
for (let [a,
|
|
1889
|
-
|
|
1960
|
+
for (let [a, l] of Object.entries({ ...r, ...i }))
|
|
1961
|
+
b(this, rt).delete(a);
|
|
1890
1962
|
return !0;
|
|
1891
1963
|
}
|
|
1892
1964
|
return !1;
|
|
1893
1965
|
} catch (e) {
|
|
1894
1966
|
return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
|
|
1895
1967
|
}
|
|
1896
|
-
},
|
|
1968
|
+
}, Wt = new WeakSet(), Ne = async function() {
|
|
1897
1969
|
try {
|
|
1898
1970
|
let e = new K(BX24.callBatch), { serverTime: t } = await e.batch({
|
|
1899
1971
|
serverTime: { method: "server.time" }
|
|
@@ -1902,13 +1974,13 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
|
|
|
1902
1974
|
console.error("Не удалось получить время сервера");
|
|
1903
1975
|
return;
|
|
1904
1976
|
}
|
|
1905
|
-
if (
|
|
1977
|
+
if (b(this, v) || await this.getEntityList(), !b(this, v) || b(this, v).length === 0)
|
|
1906
1978
|
return;
|
|
1907
|
-
let r =
|
|
1979
|
+
let r = b(this, v).filter((i) => {
|
|
1908
1980
|
try {
|
|
1909
1981
|
let { dateCreate: a } = i;
|
|
1910
|
-
return a ?
|
|
1911
|
-
|
|
1982
|
+
return a ? Lt(new Date(a)).between(
|
|
1983
|
+
Lt(new Date(t)),
|
|
1912
1984
|
"month"
|
|
1913
1985
|
) >= this.periodClear : !1;
|
|
1914
1986
|
} catch (a) {
|
|
@@ -1917,21 +1989,21 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
|
|
|
1917
1989
|
});
|
|
1918
1990
|
r.length > 0 && (console.log(
|
|
1919
1991
|
`Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1920
|
-
), await
|
|
1992
|
+
), await p(this, xt, Oe).call(this, r));
|
|
1921
1993
|
} catch (e) {
|
|
1922
1994
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1923
1995
|
}
|
|
1924
|
-
},
|
|
1996
|
+
}, xt = new WeakSet(), Oe = async function(e) {
|
|
1925
1997
|
try {
|
|
1926
1998
|
if (!e || e.length === 0)
|
|
1927
1999
|
return !1;
|
|
1928
2000
|
let t = new K(BX24.callBatch), r = e.filter((a) => a && a.id).map((a) => {
|
|
1929
|
-
let { id:
|
|
2001
|
+
let { id: l } = a;
|
|
1930
2002
|
return {
|
|
1931
2003
|
method: "entity.item.delete",
|
|
1932
2004
|
params: {
|
|
1933
|
-
ENTITY:
|
|
1934
|
-
ID:
|
|
2005
|
+
ENTITY: b(this, j),
|
|
2006
|
+
ID: l
|
|
1935
2007
|
}
|
|
1936
2008
|
};
|
|
1937
2009
|
});
|
|
@@ -1943,36 +2015,36 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
|
|
|
1943
2015
|
return console.error("Ошибка при очистке устаревших записей:", t), !1;
|
|
1944
2016
|
}
|
|
1945
2017
|
};
|
|
1946
|
-
function
|
|
1947
|
-
if (!
|
|
2018
|
+
function le(d) {
|
|
2019
|
+
if (!d || typeof d != "string")
|
|
1948
2020
|
return "";
|
|
1949
2021
|
try {
|
|
1950
|
-
const e = new URL(
|
|
2022
|
+
const e = new URL(d);
|
|
1951
2023
|
e.search = "", e.hash = "";
|
|
1952
2024
|
let t = e.toString();
|
|
1953
2025
|
return t.endsWith("/") && e.pathname !== "/" && (t = t.slice(0, -1)), t;
|
|
1954
2026
|
} catch {
|
|
1955
|
-
return
|
|
2027
|
+
return d.split("?")[0].split("#")[0].replace(/\/$/, "");
|
|
1956
2028
|
}
|
|
1957
2029
|
}
|
|
1958
|
-
function
|
|
1959
|
-
return !
|
|
2030
|
+
function _e(d) {
|
|
2031
|
+
return !d || typeof d != "string" ? !1 : d.toLowerCase().includes("/marketplace/app");
|
|
1960
2032
|
}
|
|
1961
|
-
function
|
|
2033
|
+
function Pe() {
|
|
1962
2034
|
var e;
|
|
1963
2035
|
if (typeof window > "u" || !((e = window.location) != null && e.href))
|
|
1964
2036
|
return "";
|
|
1965
|
-
const
|
|
1966
|
-
return
|
|
2037
|
+
const d = le(window.location.href);
|
|
2038
|
+
return _e(d) ? "" : d;
|
|
1967
2039
|
}
|
|
1968
|
-
function
|
|
1969
|
-
if (!(
|
|
2040
|
+
function ie(d) {
|
|
2041
|
+
if (!(d != null && d.appConst) || typeof d.appConst != "object")
|
|
1970
2042
|
return "";
|
|
1971
|
-
const e =
|
|
1972
|
-
return e ? (
|
|
2043
|
+
const e = Pe();
|
|
2044
|
+
return e ? (d.appConst.pathApp = e, e) : le(d.appConst.pathApp ?? "");
|
|
1973
2045
|
}
|
|
1974
|
-
var
|
|
1975
|
-
class
|
|
2046
|
+
var ht, St, Ft, Te, _t, ne, vt, Ee, Xt, Re, Jt, Le, V, at, Tt, ae, jt, be, Et, oe, Kt, Me;
|
|
2047
|
+
class Je {
|
|
1976
2048
|
/**
|
|
1977
2049
|
* @param {Object} appConst - Константы приложения
|
|
1978
2050
|
* @param {string} appConst.appName - Название приложения
|
|
@@ -1985,24 +2057,24 @@ class ve {
|
|
|
1985
2057
|
*
|
|
1986
2058
|
* @returns {Batch} Shared Batch instance.
|
|
1987
2059
|
*/
|
|
1988
|
-
E(this,
|
|
1989
|
-
E(this,
|
|
2060
|
+
E(this, ht);
|
|
2061
|
+
E(this, Ft);
|
|
1990
2062
|
/**
|
|
1991
2063
|
* `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
|
|
1992
2064
|
* иначе — заглушка.
|
|
1993
2065
|
* @param {boolean} runLoggerMaintenance
|
|
1994
2066
|
*/
|
|
1995
|
-
E(this,
|
|
2067
|
+
E(this, _t);
|
|
1996
2068
|
/**
|
|
1997
2069
|
* @returns {boolean}
|
|
1998
2070
|
*/
|
|
1999
|
-
E(this, Ft);
|
|
2000
|
-
/** Запрос данных о приложении */
|
|
2001
2071
|
E(this, vt);
|
|
2002
|
-
/** Запрос данных о
|
|
2072
|
+
/** Запрос данных о приложении */
|
|
2003
2073
|
E(this, Xt);
|
|
2004
|
-
|
|
2005
|
-
E(this,
|
|
2074
|
+
/** Запрос данных о текущем пользователе */
|
|
2075
|
+
E(this, Jt);
|
|
2076
|
+
E(this, V);
|
|
2077
|
+
E(this, Tt);
|
|
2006
2078
|
/**
|
|
2007
2079
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
2008
2080
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -2012,17 +2084,17 @@ class ve {
|
|
|
2012
2084
|
* @param {Array} updateList - Список обновлений для логирования (опционально)
|
|
2013
2085
|
* @returns {Object} Расширенный список ошибок
|
|
2014
2086
|
*/
|
|
2015
|
-
E(this,
|
|
2087
|
+
E(this, jt);
|
|
2016
2088
|
/**
|
|
2017
2089
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
2018
2090
|
* @private
|
|
2019
2091
|
*/
|
|
2020
|
-
E(this,
|
|
2092
|
+
E(this, Et);
|
|
2021
2093
|
/**
|
|
2022
2094
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
2023
2095
|
* @private
|
|
2024
2096
|
*/
|
|
2025
|
-
E(this,
|
|
2097
|
+
E(this, Kt);
|
|
2026
2098
|
w(this, "domain", "");
|
|
2027
2099
|
w(this, "isAdmin", !1);
|
|
2028
2100
|
w(this, "appInfo", null);
|
|
@@ -2046,7 +2118,7 @@ class ve {
|
|
|
2046
2118
|
* @returns {() => void} Функция отписки.
|
|
2047
2119
|
*/
|
|
2048
2120
|
subscribeTimeLimit(e) {
|
|
2049
|
-
return
|
|
2121
|
+
return p(this, ht, St).call(this).subscribeTimeLimit(e);
|
|
2050
2122
|
}
|
|
2051
2123
|
/**
|
|
2052
2124
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2062,34 +2134,34 @@ class ve {
|
|
|
2062
2134
|
return new Promise((e, t) => {
|
|
2063
2135
|
const i = setTimeout(() => {
|
|
2064
2136
|
clearInterval(a);
|
|
2065
|
-
const
|
|
2137
|
+
const l = new Error(
|
|
2066
2138
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
2067
2139
|
);
|
|
2068
|
-
console.error(
|
|
2140
|
+
console.error(l), t(l);
|
|
2069
2141
|
}, 3e4);
|
|
2070
2142
|
let a = setInterval(() => {
|
|
2071
2143
|
window.BX24 && BX24.init(async () => {
|
|
2072
2144
|
clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
|
|
2073
|
-
const
|
|
2145
|
+
const l = p(this, vt, Ee).call(this);
|
|
2074
2146
|
if (console.info(
|
|
2075
|
-
|
|
2076
|
-
), this.appInfo = await
|
|
2077
|
-
await
|
|
2147
|
+
l ? "init BX24 (background worker)" : "init BX24"
|
|
2148
|
+
), this.appInfo = await p(this, Xt, Re).call(this), this.userInfo = await p(this, Jt, Le).call(this), ie(this), l)
|
|
2149
|
+
await p(this, _t, ne).call(this, !1, {
|
|
2078
2150
|
skipInit: !0
|
|
2079
2151
|
});
|
|
2080
2152
|
else {
|
|
2081
|
-
await
|
|
2082
|
-
const h = new
|
|
2153
|
+
await p(this, _t, ne).call(this, !0);
|
|
2154
|
+
const h = new ge();
|
|
2083
2155
|
try {
|
|
2084
2156
|
h.noSleep();
|
|
2085
|
-
} catch (
|
|
2157
|
+
} catch (u) {
|
|
2086
2158
|
console.warn(
|
|
2087
2159
|
"Failed to initialize noSleep:",
|
|
2088
|
-
|
|
2160
|
+
u
|
|
2089
2161
|
);
|
|
2090
2162
|
}
|
|
2091
2163
|
}
|
|
2092
|
-
e({ isBackworker:
|
|
2164
|
+
e({ isBackworker: l });
|
|
2093
2165
|
});
|
|
2094
2166
|
}, 100);
|
|
2095
2167
|
});
|
|
@@ -2145,14 +2217,14 @@ class ve {
|
|
|
2145
2217
|
const h = new Error("BX24 is not initialized");
|
|
2146
2218
|
throw console.error(h), h;
|
|
2147
2219
|
}
|
|
2148
|
-
const
|
|
2149
|
-
return
|
|
2150
|
-
answer:
|
|
2220
|
+
const l = await p(this, ht, St).call(this).call({ method: e, params: t });
|
|
2221
|
+
return l.success ? (await p(this, V, at).call(this, i, {
|
|
2222
|
+
answer: l.answer,
|
|
2151
2223
|
status: "success"
|
|
2152
|
-
}),
|
|
2153
|
-
answer:
|
|
2224
|
+
}), l.data) : (console.error(l.error), await p(this, V, at).call(this, i, {
|
|
2225
|
+
answer: l.answer,
|
|
2154
2226
|
status: "fail",
|
|
2155
|
-
errorList: { 0:
|
|
2227
|
+
errorList: { 0: l.error || "Unknown call error" }
|
|
2156
2228
|
}), !1);
|
|
2157
2229
|
}
|
|
2158
2230
|
/**
|
|
@@ -2176,10 +2248,10 @@ class ve {
|
|
|
2176
2248
|
*/
|
|
2177
2249
|
async batch(e, t, { errorCall: r, updateList: i, batchOptions: a } = {}) {
|
|
2178
2250
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2179
|
-
const
|
|
2180
|
-
return console.error(
|
|
2251
|
+
const l = new Error("BX24 is not initialized");
|
|
2252
|
+
return console.error(l), !1;
|
|
2181
2253
|
}
|
|
2182
|
-
return
|
|
2254
|
+
return p(this, Tt, ae).call(this, {
|
|
2183
2255
|
mode: "batch",
|
|
2184
2256
|
commandList: e,
|
|
2185
2257
|
progressCall: t,
|
|
@@ -2215,7 +2287,7 @@ class ve {
|
|
|
2215
2287
|
const a = new Error("BX24 is not initialized");
|
|
2216
2288
|
return console.error(a), !1;
|
|
2217
2289
|
}
|
|
2218
|
-
return
|
|
2290
|
+
return p(this, Tt, ae).call(this, {
|
|
2219
2291
|
mode: "batch-total-count",
|
|
2220
2292
|
commandList: e,
|
|
2221
2293
|
progressCall: t,
|
|
@@ -2237,42 +2309,42 @@ class ve {
|
|
|
2237
2309
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2238
2310
|
return;
|
|
2239
2311
|
const { appName: t, pathApp: r } = this.appConst;
|
|
2240
|
-
let i =
|
|
2312
|
+
let i = p(this, Et, oe).call(this, e);
|
|
2241
2313
|
i = i.filter(
|
|
2242
|
-
(
|
|
2314
|
+
(c) => c.placement !== "PAGE_BACKGROUND_WORKER" && c.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2243
2315
|
);
|
|
2244
|
-
const a =
|
|
2245
|
-
for (const
|
|
2246
|
-
|
|
2316
|
+
const a = p(this, Kt, Me).call(this, r), l = new Set(i.map((c) => c.placement));
|
|
2317
|
+
for (const c of a)
|
|
2318
|
+
l.has(c.placement) || i.push({ placement: c.placement });
|
|
2247
2319
|
if (i.length === 0)
|
|
2248
2320
|
return;
|
|
2249
2321
|
let h = t;
|
|
2250
2322
|
this.domain === "szdl.bitrix24.ru" && ((A = this.appInfo) != null && A.ID) && (h = `${t}: #${this.appInfo.ID}`);
|
|
2251
|
-
const
|
|
2252
|
-
for (const
|
|
2253
|
-
|
|
2254
|
-
for (let
|
|
2255
|
-
const { placement:
|
|
2256
|
-
if (
|
|
2257
|
-
(
|
|
2323
|
+
const u = h.replace(" CRM", ""), n = {}, g = [], f = /* @__PURE__ */ new Map();
|
|
2324
|
+
for (const c of this.placeData)
|
|
2325
|
+
f.has(c.placement) || f.set(c.placement, []), f.get(c.placement).push(c);
|
|
2326
|
+
for (let c = 0; c < i.length; c++) {
|
|
2327
|
+
const { placement: N, options: _ } = i[c], R = f.get(N) || [];
|
|
2328
|
+
if (R.some(
|
|
2329
|
+
(L) => L.handler === r
|
|
2258
2330
|
))
|
|
2259
2331
|
continue;
|
|
2260
|
-
const T =
|
|
2261
|
-
(
|
|
2332
|
+
const T = R.filter(
|
|
2333
|
+
(L) => L.handler !== r
|
|
2262
2334
|
);
|
|
2263
|
-
for (const
|
|
2264
|
-
|
|
2265
|
-
placement:
|
|
2266
|
-
handler:
|
|
2335
|
+
for (const L of T)
|
|
2336
|
+
g.push({
|
|
2337
|
+
placement: N,
|
|
2338
|
+
handler: L.handler
|
|
2267
2339
|
});
|
|
2268
|
-
n[`bind_${
|
|
2340
|
+
n[`bind_${c}`] = {
|
|
2269
2341
|
method: "placement.bind",
|
|
2270
2342
|
params: {
|
|
2271
|
-
PLACEMENT:
|
|
2343
|
+
PLACEMENT: N,
|
|
2272
2344
|
HANDLER: r,
|
|
2273
2345
|
LANG_ALL: {
|
|
2274
2346
|
ru: {
|
|
2275
|
-
TITLE:
|
|
2347
|
+
TITLE: N === "USER_PROFILE_TOOLBAR" ? u : h
|
|
2276
2348
|
}
|
|
2277
2349
|
},
|
|
2278
2350
|
OPTIONS: {
|
|
@@ -2282,8 +2354,8 @@ class ve {
|
|
|
2282
2354
|
}
|
|
2283
2355
|
};
|
|
2284
2356
|
}
|
|
2285
|
-
|
|
2286
|
-
console.log("Приложение успешно встроено в",
|
|
2357
|
+
g.length > 0 && await this.placementUnBind(g), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((c) => {
|
|
2358
|
+
console.log("Приложение успешно встроено в", c.params.PLACEMENT);
|
|
2287
2359
|
}));
|
|
2288
2360
|
}
|
|
2289
2361
|
/**
|
|
@@ -2291,7 +2363,7 @@ class ve {
|
|
|
2291
2363
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2292
2364
|
*/
|
|
2293
2365
|
async placementUnBind(e) {
|
|
2294
|
-
let t =
|
|
2366
|
+
let t = p(this, Et, oe).call(this, e);
|
|
2295
2367
|
if (t = t.filter(
|
|
2296
2368
|
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2297
2369
|
), t.length === 0)
|
|
@@ -2321,7 +2393,7 @@ class ve {
|
|
|
2321
2393
|
}
|
|
2322
2394
|
/* регистрация бота */
|
|
2323
2395
|
async regBot({ code: e, type: t, name: r }) {
|
|
2324
|
-
const { appName: i, pathApp: a, chatBotLogo:
|
|
2396
|
+
const { appName: i, pathApp: a, chatBotLogo: l } = this.appConst, h = this.appInfo.ID, u = await this.call({
|
|
2325
2397
|
method: "imbot.register",
|
|
2326
2398
|
params: {
|
|
2327
2399
|
CODE: e ?? this.appInfo.CODE,
|
|
@@ -2344,7 +2416,7 @@ class ve {
|
|
|
2344
2416
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
2345
2417
|
EMAIL: "",
|
|
2346
2418
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
2347
|
-
PERSONAL_BIRTHDAY:
|
|
2419
|
+
PERSONAL_BIRTHDAY: Lt().format("%Y-%m-%d"),
|
|
2348
2420
|
// День рождения в формате YYYY-mm-dd
|
|
2349
2421
|
WORK_POSITION: "Почтальон",
|
|
2350
2422
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -2352,12 +2424,12 @@ class ve {
|
|
|
2352
2424
|
// Ссылка на сайт
|
|
2353
2425
|
PERSONAL_GENDER: "M",
|
|
2354
2426
|
// Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
|
|
2355
|
-
PERSONAL_PHOTO:
|
|
2427
|
+
PERSONAL_PHOTO: l ?? ""
|
|
2356
2428
|
// Аватар чат-бота - base64
|
|
2357
2429
|
}
|
|
2358
2430
|
}
|
|
2359
2431
|
});
|
|
2360
|
-
return console.log("Чат-бот добавлен",
|
|
2432
|
+
return console.log("Чат-бот добавлен", u), u;
|
|
2361
2433
|
}
|
|
2362
2434
|
/* Убрать регистрацию бота */
|
|
2363
2435
|
async unRegBot(e) {
|
|
@@ -2374,12 +2446,12 @@ class ve {
|
|
|
2374
2446
|
return this.logger.getEntityList(e);
|
|
2375
2447
|
}
|
|
2376
2448
|
}
|
|
2377
|
-
|
|
2449
|
+
ht = new WeakSet(), St = function() {
|
|
2378
2450
|
return this.batchClient || (this.batchClient = new K({
|
|
2379
2451
|
callBatch: BX24.callBatch,
|
|
2380
2452
|
callMethod: BX24.callMethod
|
|
2381
2453
|
}), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
|
|
2382
|
-
},
|
|
2454
|
+
}, Ft = new WeakSet(), Te = function() {
|
|
2383
2455
|
return {
|
|
2384
2456
|
start: () => {
|
|
2385
2457
|
},
|
|
@@ -2388,17 +2460,17 @@ ut = new WeakSet(), Rt = function() {
|
|
|
2388
2460
|
getEntityList: () => {
|
|
2389
2461
|
}
|
|
2390
2462
|
};
|
|
2391
|
-
},
|
|
2392
|
-
this.logger ? (this.logger = new
|
|
2393
|
-
},
|
|
2463
|
+
}, _t = new WeakSet(), ne = async function(e, { skipInit: t = !1 } = {}) {
|
|
2464
|
+
this.logger ? (this.logger = new Ue(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = p(this, Ft, Te).call(this);
|
|
2465
|
+
}, vt = new WeakSet(), Ee = function() {
|
|
2394
2466
|
var r, i, a;
|
|
2395
2467
|
const e = (r = this.placeInfo) == null ? void 0 : r.placement, t = (a = (i = this.placeInfo) == null ? void 0 : i.options) == null ? void 0 : a.ID;
|
|
2396
2468
|
return e === "PAGE_BACKGROUND_WORKER" || t === "PAGE_BACKGROUND_WORKER";
|
|
2397
|
-
},
|
|
2469
|
+
}, Xt = new WeakSet(), Re = function() {
|
|
2398
2470
|
return this.call({ method: "app.info" });
|
|
2399
|
-
},
|
|
2471
|
+
}, Jt = new WeakSet(), Le = function() {
|
|
2400
2472
|
return this.call({ method: "user.current" });
|
|
2401
|
-
},
|
|
2473
|
+
}, V = new WeakSet(), at = async function(e, t) {
|
|
2402
2474
|
if (e)
|
|
2403
2475
|
try {
|
|
2404
2476
|
await this.logger.stop({
|
|
@@ -2408,115 +2480,115 @@ ut = new WeakSet(), Rt = function() {
|
|
|
2408
2480
|
} catch (r) {
|
|
2409
2481
|
console.error("Logger error:", r);
|
|
2410
2482
|
}
|
|
2411
|
-
},
|
|
2483
|
+
}, Tt = new WeakSet(), ae = async function({
|
|
2412
2484
|
mode: e,
|
|
2413
2485
|
commandList: t,
|
|
2414
2486
|
progressCall: r,
|
|
2415
2487
|
errorCall: i,
|
|
2416
2488
|
updateList: a,
|
|
2417
|
-
batchOptions:
|
|
2489
|
+
batchOptions: l
|
|
2418
2490
|
}) {
|
|
2419
|
-
const h =
|
|
2491
|
+
const h = p(this, ht, St).call(this), u = a ? this.logger.start({
|
|
2420
2492
|
type: e,
|
|
2421
2493
|
data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
|
|
2422
2494
|
}) : void 0;
|
|
2423
2495
|
try {
|
|
2424
|
-
const n = e === "batch" ? await h.batch(t, r,
|
|
2425
|
-
return Object.keys(
|
|
2496
|
+
const n = e === "batch" ? await h.batch(t, r, l) : await h.batchTotalCount(t, r), g = p(this, jt, be).call(this, h, n, t, a);
|
|
2497
|
+
return Object.keys(g).length ? (i && i(g), await p(this, V, at).call(this, u, {
|
|
2426
2498
|
status: "fail",
|
|
2427
|
-
errorList:
|
|
2428
|
-
})) : await
|
|
2499
|
+
errorList: g
|
|
2500
|
+
})) : await p(this, V, at).call(this, u, { status: "success" }), n;
|
|
2429
2501
|
} catch (n) {
|
|
2430
|
-
return await
|
|
2502
|
+
return await p(this, V, at).call(this, u, {
|
|
2431
2503
|
status: "fail-runtime",
|
|
2432
2504
|
errorList: { 0: n == null ? void 0 : n.toString() }
|
|
2433
2505
|
}), console.error(n), !1;
|
|
2434
2506
|
}
|
|
2435
|
-
},
|
|
2507
|
+
}, jt = new WeakSet(), be = function(e, t, r, i) {
|
|
2436
2508
|
let a = { ...e.errors };
|
|
2437
2509
|
if (Object.values(e.errors).some(
|
|
2438
2510
|
(h) => {
|
|
2439
2511
|
if (typeof h != "string")
|
|
2440
2512
|
return !1;
|
|
2441
|
-
const
|
|
2442
|
-
return
|
|
2513
|
+
const u = h.toUpperCase();
|
|
2514
|
+
return u === "TIMEOUT" || u === "OPERATION_TIME_LIMIT" || u.includes("TIMEOUT") || u.includes("OPERATION_TIME_LIMIT");
|
|
2443
2515
|
}
|
|
2444
2516
|
) && i) {
|
|
2445
2517
|
const h = t ? Object.keys(t).filter(
|
|
2446
|
-
(
|
|
2447
|
-
) : [],
|
|
2518
|
+
(f) => f !== "errorsList" && f !== "errorsListMessages"
|
|
2519
|
+
) : [], u = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
|
|
2448
2520
|
if (t) {
|
|
2449
|
-
for (const
|
|
2450
|
-
if (!
|
|
2451
|
-
const A = t[
|
|
2452
|
-
A != null && n.add(
|
|
2521
|
+
for (const f of h)
|
|
2522
|
+
if (!u.has(f)) {
|
|
2523
|
+
const A = t[f];
|
|
2524
|
+
A != null && n.add(f);
|
|
2453
2525
|
}
|
|
2454
2526
|
}
|
|
2455
|
-
const
|
|
2456
|
-
(
|
|
2457
|
-
if (typeof
|
|
2527
|
+
const g = Object.values(e.errors).find(
|
|
2528
|
+
(f) => {
|
|
2529
|
+
if (typeof f != "string")
|
|
2458
2530
|
return !1;
|
|
2459
|
-
const A =
|
|
2531
|
+
const A = f.toUpperCase();
|
|
2460
2532
|
return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
|
|
2461
2533
|
}
|
|
2462
2534
|
);
|
|
2463
|
-
for (const
|
|
2464
|
-
!n.has(
|
|
2535
|
+
for (const f of Object.keys(r))
|
|
2536
|
+
!n.has(f) && !e.errors[f] && (a[f] = g || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2465
2537
|
}
|
|
2466
2538
|
return a;
|
|
2467
|
-
},
|
|
2539
|
+
}, Et = new WeakSet(), oe = function(e) {
|
|
2468
2540
|
if (!e)
|
|
2469
2541
|
return [];
|
|
2470
2542
|
let t = [];
|
|
2471
2543
|
return Array.isArray(e) ? t = e.map(
|
|
2472
2544
|
(r) => typeof r == "string" ? { placement: r } : r
|
|
2473
2545
|
) : typeof e == "string" ? t = [{ placement: e }] : t = [e], t;
|
|
2474
|
-
},
|
|
2546
|
+
}, Kt = new WeakSet(), Me = function(e) {
|
|
2475
2547
|
return this.placeData ? this.placeData.filter((t) => !(t.placement === "PAGE_BACKGROUND_WORKER" || !t.handler || t.handler.includes(e))) : [];
|
|
2476
2548
|
};
|
|
2477
|
-
const
|
|
2478
|
-
function
|
|
2549
|
+
const Se = "szdl-utils-kit|";
|
|
2550
|
+
function Ge() {
|
|
2479
2551
|
if (typeof sessionStorage > "u")
|
|
2480
2552
|
return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2481
|
-
let
|
|
2482
|
-
return
|
|
2553
|
+
let d = sessionStorage.getItem("szdl-cross-tab-instance-id");
|
|
2554
|
+
return d || (d = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", d)), d;
|
|
2483
2555
|
}
|
|
2484
|
-
function
|
|
2556
|
+
function Ye() {
|
|
2485
2557
|
return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
|
|
2486
2558
|
}
|
|
2487
|
-
const
|
|
2488
|
-
function
|
|
2559
|
+
const Vt = /* @__PURE__ */ new Map();
|
|
2560
|
+
function We(d = "default") {
|
|
2489
2561
|
if (typeof BroadcastChannel > "u")
|
|
2490
2562
|
return null;
|
|
2491
|
-
const e = `${
|
|
2492
|
-
return
|
|
2563
|
+
const e = `${Se}bc:${d}`;
|
|
2564
|
+
return Vt.has(e) || Vt.set(e, new BroadcastChannel(e)), Vt.get(e);
|
|
2493
2565
|
}
|
|
2494
|
-
function
|
|
2495
|
-
const t =
|
|
2566
|
+
function ce(d, e) {
|
|
2567
|
+
const t = We(d);
|
|
2496
2568
|
if (t)
|
|
2497
2569
|
try {
|
|
2498
2570
|
const r = e && typeof e == "object" && !Array.isArray(e) ? e : { data: e };
|
|
2499
2571
|
t.postMessage({
|
|
2500
2572
|
...r,
|
|
2501
|
-
tabId:
|
|
2573
|
+
tabId: Ge(),
|
|
2502
2574
|
ts: Date.now()
|
|
2503
2575
|
});
|
|
2504
2576
|
} catch {
|
|
2505
2577
|
}
|
|
2506
2578
|
}
|
|
2507
|
-
async function
|
|
2508
|
-
const { ifAvailable: r = !1 } = t, i = typeof
|
|
2509
|
-
return
|
|
2579
|
+
async function xe(d, e, t = {}) {
|
|
2580
|
+
const { ifAvailable: r = !1 } = t, i = typeof d == "string" && d.length > 0 ? d : "default", a = `${Se}${i}`;
|
|
2581
|
+
return Ye() ? navigator.locks.request(
|
|
2510
2582
|
a,
|
|
2511
2583
|
{ mode: "exclusive", ifAvailable: !!r },
|
|
2512
|
-
async (
|
|
2513
|
-
if (r &&
|
|
2584
|
+
async (l) => {
|
|
2585
|
+
if (r && l == null)
|
|
2514
2586
|
return { skipped: !0, coordination: "locks" };
|
|
2515
|
-
|
|
2587
|
+
ce(i, { type: "lock-acquired", resource: i });
|
|
2516
2588
|
try {
|
|
2517
2589
|
return { skipped: !1, result: await e(), coordination: "locks" };
|
|
2518
2590
|
} finally {
|
|
2519
|
-
|
|
2591
|
+
ce(i, { type: "lock-released", resource: i });
|
|
2520
2592
|
}
|
|
2521
2593
|
}
|
|
2522
2594
|
) : { skipped: !1, result: await e(), coordination: "none" };
|
|
@@ -2537,16 +2609,16 @@ const q = {
|
|
|
2537
2609
|
/** Heartbeat лидера во время appInit; null — вычислить из poll/activeMaxPause. */
|
|
2538
2610
|
leaderHeartbeatMs: null
|
|
2539
2611
|
};
|
|
2540
|
-
function
|
|
2541
|
-
return
|
|
2542
|
-
`BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(
|
|
2612
|
+
function Fe(d) {
|
|
2613
|
+
return d == null ? "user" : d === "user" || d === "portal" ? d : (console.warn(
|
|
2614
|
+
`BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(d)} — используется 'user'`
|
|
2543
2615
|
), "user");
|
|
2544
2616
|
}
|
|
2545
|
-
function
|
|
2546
|
-
const e = { ...q, ...
|
|
2617
|
+
function ve(d = {}) {
|
|
2618
|
+
const e = { ...q, ...d };
|
|
2547
2619
|
for (const t of Object.keys(q)) {
|
|
2548
2620
|
if (t === "leaderHeartbeatMs") {
|
|
2549
|
-
const i =
|
|
2621
|
+
const i = d == null ? void 0 : d.leaderHeartbeatMs;
|
|
2550
2622
|
if (i == null) {
|
|
2551
2623
|
e.leaderHeartbeatMs = null;
|
|
2552
2624
|
continue;
|
|
@@ -2560,19 +2632,19 @@ function xe(m = {}) {
|
|
|
2560
2632
|
}
|
|
2561
2633
|
return e;
|
|
2562
2634
|
}
|
|
2563
|
-
var
|
|
2564
|
-
class
|
|
2635
|
+
var qt, Ie, Rt, Ae, nt, mt, zt, De;
|
|
2636
|
+
class je {
|
|
2565
2637
|
constructor(e) {
|
|
2566
|
-
E(this,
|
|
2638
|
+
E(this, qt);
|
|
2567
2639
|
/**
|
|
2568
2640
|
* Канонический base URL для placement (без завершающего `/`).
|
|
2569
2641
|
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2570
2642
|
*/
|
|
2571
|
-
E(this,
|
|
2643
|
+
E(this, Rt);
|
|
2572
2644
|
/** Ключ NAME в entity: userId или общий ключ портала. */
|
|
2573
2645
|
E(this, nt);
|
|
2574
2646
|
/** Имя Web Lock для подтверждения лидерства. */
|
|
2575
|
-
E(this,
|
|
2647
|
+
E(this, zt);
|
|
2576
2648
|
w(this, "entityName", "tabs");
|
|
2577
2649
|
w(this, "maxTabs", 20);
|
|
2578
2650
|
w(this, "tabList", []);
|
|
@@ -2593,7 +2665,9 @@ class Xe {
|
|
|
2593
2665
|
w(this, "defaultContinueBackground", () => !0);
|
|
2594
2666
|
/** @type {'user' | 'portal'} */
|
|
2595
2667
|
w(this, "coordinationScope", "user");
|
|
2596
|
-
|
|
2668
|
+
/** Привязывать общую встройку PAGE_BACKGROUND_WORKER без USER_ID. @default true */
|
|
2669
|
+
w(this, "bindGeneralPlacement", !0);
|
|
2670
|
+
var n, g, f;
|
|
2597
2671
|
if (!e) {
|
|
2598
2672
|
console.error("BackgroundWorker: Нет опций конструктора");
|
|
2599
2673
|
return;
|
|
@@ -2603,10 +2677,11 @@ class Xe {
|
|
|
2603
2677
|
bx: r,
|
|
2604
2678
|
users: i,
|
|
2605
2679
|
continueBackground: a,
|
|
2606
|
-
timing:
|
|
2607
|
-
coordinationScope: h
|
|
2680
|
+
timing: l,
|
|
2681
|
+
coordinationScope: h,
|
|
2682
|
+
bindGeneralPlacement: u
|
|
2608
2683
|
} = e;
|
|
2609
|
-
this.bx = r, this.appInit = t, this.users = i, this.coordinationScope =
|
|
2684
|
+
this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = Fe(h), this.bindGeneralPlacement = u !== !1, p(this, qt, Ie).call(this, l), ie(r), this.appPath = p(this, Rt, Ae).call(this, ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.pathApp) ?? ""), this.appName = ((g = r == null ? void 0 : r.appConst) == null ? void 0 : g.appName) ?? "", this.appCodeName = ((f = r == null ? void 0 : r.appConst) == null ? void 0 : f.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2610
2685
|
}
|
|
2611
2686
|
async init() {
|
|
2612
2687
|
if (!this.appInit) {
|
|
@@ -2650,8 +2725,8 @@ class Xe {
|
|
|
2650
2725
|
if (typeof BX24 > "u" || !((e = BX24.placement) != null && e.info))
|
|
2651
2726
|
return !1;
|
|
2652
2727
|
try {
|
|
2653
|
-
const t = BX24.placement.info(), r = t == null ? void 0 : t.placement, i = (t == null ? void 0 : t.options) || {}, a = (i == null ? void 0 : i.URI) || "",
|
|
2654
|
-
return !
|
|
2728
|
+
const t = BX24.placement.info(), r = t == null ? void 0 : t.placement, i = (t == null ? void 0 : t.options) || {}, a = (i == null ? void 0 : i.URI) || "", l = r === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", h = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
|
|
2729
|
+
return !l || h;
|
|
2655
2730
|
} catch {
|
|
2656
2731
|
return !1;
|
|
2657
2732
|
}
|
|
@@ -2676,7 +2751,7 @@ class Xe {
|
|
|
2676
2751
|
);
|
|
2677
2752
|
}
|
|
2678
2753
|
async getTabs() {
|
|
2679
|
-
const e =
|
|
2754
|
+
const e = p(this, nt, mt).call(this), t = await this.safeCall(
|
|
2680
2755
|
() => this.bx.call({
|
|
2681
2756
|
method: "entity.item.get",
|
|
2682
2757
|
params: {
|
|
@@ -2716,7 +2791,7 @@ class Xe {
|
|
|
2716
2791
|
method: "entity.item.add",
|
|
2717
2792
|
params: {
|
|
2718
2793
|
ENTITY: this.entityName,
|
|
2719
|
-
NAME:
|
|
2794
|
+
NAME: p(this, nt, mt).call(this),
|
|
2720
2795
|
DETAIL_TEXT: JSON.stringify(e)
|
|
2721
2796
|
}
|
|
2722
2797
|
})
|
|
@@ -2740,7 +2815,7 @@ class Xe {
|
|
|
2740
2815
|
params: {
|
|
2741
2816
|
ENTITY: this.entityName,
|
|
2742
2817
|
ID: this.id,
|
|
2743
|
-
NAME:
|
|
2818
|
+
NAME: p(this, nt, mt).call(this),
|
|
2744
2819
|
DETAIL_TEXT: JSON.stringify(t)
|
|
2745
2820
|
}
|
|
2746
2821
|
})
|
|
@@ -2769,22 +2844,22 @@ class Xe {
|
|
|
2769
2844
|
), !0;
|
|
2770
2845
|
const i = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), a = this.isIndividualPlacement(
|
|
2771
2846
|
typeof window < "u" ? window.location.href : ""
|
|
2772
|
-
),
|
|
2847
|
+
), l = !a;
|
|
2773
2848
|
if (!i)
|
|
2774
2849
|
return !0;
|
|
2775
2850
|
let h = !1;
|
|
2776
|
-
for (const
|
|
2777
|
-
if (
|
|
2851
|
+
for (const u of r) {
|
|
2852
|
+
if (u.placement !== "PAGE_BACKGROUND_WORKER" || !(u.userId || u.handler && u.handler.includes("USER_ID=")))
|
|
2778
2853
|
continue;
|
|
2779
|
-
const
|
|
2780
|
-
if (
|
|
2854
|
+
const g = u.userId || (u.handler ? this.extractUserIdFromHandler(u.handler) : null);
|
|
2855
|
+
if (g && +g === i) {
|
|
2781
2856
|
h = !0;
|
|
2782
2857
|
break;
|
|
2783
2858
|
}
|
|
2784
2859
|
}
|
|
2785
2860
|
return a ? (console.log(
|
|
2786
2861
|
"BackgroundWorker: Индивидуальная встройка - разрешено"
|
|
2787
|
-
), !0) :
|
|
2862
|
+
), !0) : l && h ? (console.log(
|
|
2788
2863
|
"BackgroundWorker: Есть личная встройка, общую не запускаем"
|
|
2789
2864
|
), !1) : (console.log(
|
|
2790
2865
|
"BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
|
|
@@ -2819,8 +2894,8 @@ class Xe {
|
|
|
2819
2894
|
}
|
|
2820
2895
|
}
|
|
2821
2896
|
async refreshTabs(e = !1, t = this.activeMaxPause) {
|
|
2822
|
-
const r = [], i = [], a = Date.now(),
|
|
2823
|
-
for (const h of
|
|
2897
|
+
const r = [], i = [], a = Date.now(), l = await this.getTabs();
|
|
2898
|
+
for (const h of l) {
|
|
2824
2899
|
if (!(h != null && h.data)) {
|
|
2825
2900
|
r.push(h);
|
|
2826
2901
|
continue;
|
|
@@ -2836,13 +2911,13 @@ class Xe {
|
|
|
2836
2911
|
selectLeaderId() {
|
|
2837
2912
|
var t;
|
|
2838
2913
|
return this.tabList.length && +((t = [...this.tabList].sort((r, i) => {
|
|
2839
|
-
var h,
|
|
2914
|
+
var h, u, n, g;
|
|
2840
2915
|
const a = new Date(
|
|
2841
|
-
((h = r.data) == null ? void 0 : h.createdAt) || ((
|
|
2842
|
-
).getTime(),
|
|
2843
|
-
((n = i.data) == null ? void 0 : n.createdAt) || ((
|
|
2916
|
+
((h = r.data) == null ? void 0 : h.createdAt) || ((u = r.data) == null ? void 0 : u.lastActive) || 0
|
|
2917
|
+
).getTime(), l = new Date(
|
|
2918
|
+
((n = i.data) == null ? void 0 : n.createdAt) || ((g = i.data) == null ? void 0 : g.lastActive) || 0
|
|
2844
2919
|
).getTime();
|
|
2845
|
-
return a ===
|
|
2920
|
+
return a === l ? (+r.id || 0) - (+i.id || 0) : a - l;
|
|
2846
2921
|
})[0]) == null ? void 0 : t.id) || 0;
|
|
2847
2922
|
}
|
|
2848
2923
|
async confirmLeaderAfterLock() {
|
|
@@ -2851,8 +2926,8 @@ class Xe {
|
|
|
2851
2926
|
return !!(e && +this.id == +e);
|
|
2852
2927
|
}
|
|
2853
2928
|
async runAsLeader() {
|
|
2854
|
-
const e =
|
|
2855
|
-
(await
|
|
2929
|
+
const e = p(this, zt, De).call(this);
|
|
2930
|
+
(await xe(
|
|
2856
2931
|
e,
|
|
2857
2932
|
async () => {
|
|
2858
2933
|
if (await this.updateTabState(!0), console.log(
|
|
@@ -2892,15 +2967,15 @@ class Xe {
|
|
|
2892
2967
|
);
|
|
2893
2968
|
}
|
|
2894
2969
|
async setBackgroundWorkerAll() {
|
|
2895
|
-
var k, T,
|
|
2970
|
+
var k, T, L, G;
|
|
2896
2971
|
if (!((k = this.bx) != null && k.isAdmin)) {
|
|
2897
2972
|
console.log(
|
|
2898
2973
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2899
2974
|
);
|
|
2900
2975
|
return;
|
|
2901
2976
|
}
|
|
2902
|
-
(T = this.users) != null && T.length || await this.getEntityData(),
|
|
2903
|
-
const e =
|
|
2977
|
+
(T = this.users) != null && T.length || await this.getEntityData(), ie(this.bx);
|
|
2978
|
+
const e = p(this, Rt, Ae).call(this, ((G = (L = this.bx) == null ? void 0 : L.appConst) == null ? void 0 : G.pathApp) ?? "");
|
|
2904
2979
|
if (!e) {
|
|
2905
2980
|
console.error(
|
|
2906
2981
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2911,47 +2986,44 @@ class Xe {
|
|
|
2911
2986
|
() => this.bx.getPlacement()
|
|
2912
2987
|
), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2913
2988
|
let a = null;
|
|
2914
|
-
(t || []).forEach((
|
|
2915
|
-
if (
|
|
2989
|
+
(t || []).forEach((O) => {
|
|
2990
|
+
if (O.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2916
2991
|
return;
|
|
2917
|
-
if (
|
|
2918
|
-
const I =
|
|
2992
|
+
if (O.userId || O.handler && O.handler.includes("USER_ID=")) {
|
|
2993
|
+
const I = O.userId || (O.handler ? this.extractUserIdFromHandler(O.handler) : null);
|
|
2919
2994
|
if (I) {
|
|
2920
|
-
const
|
|
2921
|
-
r.set(
|
|
2995
|
+
const B = +I;
|
|
2996
|
+
r.set(B, O), i.has(B) || i.set(B, []), i.get(B).push(O);
|
|
2922
2997
|
}
|
|
2923
2998
|
} else
|
|
2924
|
-
a =
|
|
2999
|
+
a = O;
|
|
2925
3000
|
});
|
|
2926
|
-
const
|
|
2927
|
-
h.sort((
|
|
2928
|
-
const I =
|
|
3001
|
+
const l = await this.resolveAdmins(), h = await this.getEligibleUsersForBackgroundWorker(l);
|
|
3002
|
+
h.sort((O, S) => {
|
|
3003
|
+
const I = O.LAST_LOGIN ? new Date(O.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2929
3004
|
return (S.LAST_LOGIN ? new Date(S.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
|
|
2930
3005
|
});
|
|
2931
|
-
const
|
|
2932
|
-
const S = r.get(+
|
|
3006
|
+
const u = 10, n = h.slice(0, u), g = n.filter((O) => {
|
|
3007
|
+
const S = r.get(+O.ID);
|
|
2933
3008
|
if (!S)
|
|
2934
3009
|
return !0;
|
|
2935
|
-
const I = `${e}?USER_ID=${
|
|
3010
|
+
const I = `${e}?USER_ID=${O.ID}/`;
|
|
2936
3011
|
return S.handler !== I;
|
|
2937
|
-
}),
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
for (const [N] of r) {
|
|
2942
|
-
const S = +N || 0;
|
|
2943
|
-
h.find((C) => +C.ID === S) || d.push(S);
|
|
3012
|
+
}), f = [];
|
|
3013
|
+
for (const [O] of r) {
|
|
3014
|
+
const S = +O || 0;
|
|
3015
|
+
h.find((B) => +B.ID === S) || f.push(S);
|
|
2944
3016
|
}
|
|
2945
|
-
for (const
|
|
2946
|
-
const S = r.get(+
|
|
3017
|
+
for (const O of n) {
|
|
3018
|
+
const S = r.get(+O.ID);
|
|
2947
3019
|
if (!S)
|
|
2948
3020
|
continue;
|
|
2949
|
-
const I = `${e}?USER_ID=${
|
|
2950
|
-
S.handler !== I &&
|
|
3021
|
+
const I = `${e}?USER_ID=${O.ID}/`;
|
|
3022
|
+
S.handler !== I && f.push(+O.ID);
|
|
2951
3023
|
}
|
|
2952
|
-
const A = [],
|
|
2953
|
-
for (const
|
|
2954
|
-
const S = i.get(+
|
|
3024
|
+
const A = [], c = [...new Set(f)];
|
|
3025
|
+
for (const O of c) {
|
|
3026
|
+
const S = i.get(+O) || [];
|
|
2955
3027
|
for (const I of S)
|
|
2956
3028
|
I != null && I.handler && A.push({
|
|
2957
3029
|
method: "placement.unbind",
|
|
@@ -2961,28 +3033,28 @@ class Xe {
|
|
|
2961
3033
|
}
|
|
2962
3034
|
});
|
|
2963
3035
|
}
|
|
2964
|
-
const
|
|
2965
|
-
|
|
3036
|
+
const N = a && (!this.bindGeneralPlacement || g.length > 0 || a.handler !== `${e}`);
|
|
3037
|
+
N && A.push({
|
|
2966
3038
|
method: "placement.unbind",
|
|
2967
3039
|
params: {
|
|
2968
3040
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2969
3041
|
HANDLER: a.handler || `${e}`
|
|
2970
3042
|
}
|
|
2971
3043
|
});
|
|
2972
|
-
for (const
|
|
3044
|
+
for (const O of g)
|
|
2973
3045
|
A.push({
|
|
2974
3046
|
method: "placement.bind",
|
|
2975
3047
|
params: {
|
|
2976
3048
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2977
|
-
HANDLER: `${e}?USER_ID=${
|
|
3049
|
+
HANDLER: `${e}?USER_ID=${O.ID}/`,
|
|
2978
3050
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2979
3051
|
OPTIONS: {
|
|
2980
|
-
errorHandlerUrl: `${e}?USER_ID=${
|
|
3052
|
+
errorHandlerUrl: `${e}?USER_ID=${O.ID}/`
|
|
2981
3053
|
},
|
|
2982
|
-
USER_ID:
|
|
3054
|
+
USER_ID: O.ID
|
|
2983
3055
|
}
|
|
2984
3056
|
});
|
|
2985
|
-
(!a ||
|
|
3057
|
+
this.bindGeneralPlacement && (!a || N) && A.push({
|
|
2986
3058
|
method: "placement.bind",
|
|
2987
3059
|
params: {
|
|
2988
3060
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -2992,20 +3064,20 @@ class Xe {
|
|
|
2992
3064
|
}
|
|
2993
3065
|
});
|
|
2994
3066
|
const _ = A.filter(
|
|
2995
|
-
(
|
|
2996
|
-
),
|
|
2997
|
-
(
|
|
3067
|
+
(O) => O.method === "placement.unbind"
|
|
3068
|
+
), R = A.filter(
|
|
3069
|
+
(O) => O.method === "placement.bind"
|
|
2998
3070
|
);
|
|
2999
3071
|
_.length && await this.safeCall(
|
|
3000
3072
|
() => this.bx.batch(
|
|
3001
3073
|
Object.fromEntries(
|
|
3002
|
-
_.map((
|
|
3074
|
+
_.map((O, S) => [`unbind_${S}`, O])
|
|
3003
3075
|
)
|
|
3004
3076
|
)
|
|
3005
|
-
),
|
|
3077
|
+
), R.length && await this.safeCall(
|
|
3006
3078
|
() => this.bx.batch(
|
|
3007
3079
|
Object.fromEntries(
|
|
3008
|
-
|
|
3080
|
+
R.map((O, S) => [`bind_${S}`, O])
|
|
3009
3081
|
)
|
|
3010
3082
|
)
|
|
3011
3083
|
), A.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
@@ -3016,16 +3088,16 @@ class Xe {
|
|
|
3016
3088
|
const r = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0), i = !!((t = this.bx) != null && t.isAdmin), a = await this.getAdminsList() || [];
|
|
3017
3089
|
if (!i) {
|
|
3018
3090
|
if (r && a.includes(+r)) {
|
|
3019
|
-
const
|
|
3091
|
+
const u = a.filter(
|
|
3020
3092
|
(n) => +n != +r
|
|
3021
3093
|
);
|
|
3022
|
-
return await this.saveAdminsList(
|
|
3094
|
+
return await this.saveAdminsList(u), u;
|
|
3023
3095
|
}
|
|
3024
3096
|
return a;
|
|
3025
3097
|
}
|
|
3026
|
-
const
|
|
3027
|
-
r &&
|
|
3028
|
-
const h = [...
|
|
3098
|
+
const l = /* @__PURE__ */ new Set([...a || []]);
|
|
3099
|
+
r && l.add(+r);
|
|
3100
|
+
const h = [...l].filter(Boolean);
|
|
3029
3101
|
return await this.saveAdminsList(h), h;
|
|
3030
3102
|
} catch (r) {
|
|
3031
3103
|
return console.error("BackgroundWorker: resolveAdmins error", r), [];
|
|
@@ -3084,33 +3156,33 @@ class Xe {
|
|
|
3084
3156
|
}
|
|
3085
3157
|
}
|
|
3086
3158
|
}
|
|
3087
|
-
|
|
3088
|
-
const t =
|
|
3159
|
+
qt = new WeakSet(), Ie = function(e) {
|
|
3160
|
+
const t = ve(e);
|
|
3089
3161
|
this.startDelay = t.startDelayMs, this.leaderConfirmDelay = t.leaderConfirmDelayMs, this.activeMaxPause = t.activeMaxPauseMs, this.quickCleanupThreshold = t.quickCleanupThresholdMs, this.pollIntervalBase = t.pollIntervalMs, this.pollIntervalJitter = t.pollIntervalJitterMs, this.pollInterval = t.pollIntervalMs + (t.pollIntervalJitterMs > 0 ? Math.floor(Math.random() * t.pollIntervalJitterMs) : 0), this.leaderHeartbeatMs = t.leaderHeartbeatMs;
|
|
3090
3162
|
const r = t.pollIntervalMs + t.pollIntervalJitterMs + t.leaderConfirmDelayMs;
|
|
3091
3163
|
t.activeMaxPauseMs < r && console.warn(
|
|
3092
3164
|
`BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${r}) — «живые» вкладки могут удаляться раньше следующего тика`
|
|
3093
3165
|
);
|
|
3094
|
-
},
|
|
3166
|
+
}, Rt = new WeakSet(), Ae = function(e) {
|
|
3095
3167
|
if (!e || typeof e != "string")
|
|
3096
3168
|
return "";
|
|
3097
|
-
const t =
|
|
3098
|
-
return t ?
|
|
3169
|
+
const t = le(e).replace(/\/+$/, "");
|
|
3170
|
+
return t ? _e(t) ? (console.error(
|
|
3099
3171
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3100
3172
|
), "") : t : "";
|
|
3101
3173
|
}, nt = new WeakSet(), mt = function() {
|
|
3102
3174
|
var e, t;
|
|
3103
3175
|
return this.coordinationScope === "portal" ? `${this.appCodeName || "app"}:portal` : String(((t = (e = this.bx) == null ? void 0 : e.userInfo) == null ? void 0 : t.ID) ?? "");
|
|
3104
|
-
},
|
|
3105
|
-
return `background-worker:${this.entityName}:${
|
|
3176
|
+
}, zt = new WeakSet(), De = function() {
|
|
3177
|
+
return `background-worker:${this.entityName}:${p(this, nt, mt).call(this)}`;
|
|
3106
3178
|
};
|
|
3107
3179
|
export {
|
|
3108
|
-
|
|
3180
|
+
je as BackgroundWorker,
|
|
3109
3181
|
K as Batch,
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3182
|
+
Je as BxBoot,
|
|
3183
|
+
ge as BxHelper,
|
|
3184
|
+
Ue as BxLogger,
|
|
3113
3185
|
q as DEFAULT_BACKGROUND_WORKER_TIMING,
|
|
3114
|
-
|
|
3115
|
-
|
|
3186
|
+
ve as resolveBackgroundWorkerTiming,
|
|
3187
|
+
Lt as tempus
|
|
3116
3188
|
};
|