szdl-utils-kit 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +562 -535
- package/dist/index.umd.cjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
var _t = Object.defineProperty;
|
|
2
|
-
var pt = (
|
|
3
|
-
var
|
|
4
|
-
if (!e.has(
|
|
2
|
+
var pt = (O, e, r) => e in O ? _t(O, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : O[e] = r;
|
|
3
|
+
var D = (O, e, r) => (pt(O, typeof e != "symbol" ? e + "" : e, r), r), ot = (O, e, r) => {
|
|
4
|
+
if (!e.has(O))
|
|
5
5
|
throw TypeError("Cannot " + r);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (e.has(
|
|
7
|
+
var E = (O, e, r) => (ot(O, e, "read from private field"), r ? r.call(O) : e.get(O)), H = (O, e, r) => {
|
|
8
|
+
if (e.has(O))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
e instanceof WeakSet ? e.add(
|
|
11
|
-
},
|
|
12
|
-
var
|
|
10
|
+
e instanceof WeakSet ? e.add(O) : e.set(O, r);
|
|
11
|
+
}, x = (O, e, r, i) => (ot(O, e, "write to private field"), i ? i.call(O, r) : e.set(O, r), r);
|
|
12
|
+
var J = (O, e, r) => (ot(O, e, "access private method"), r);
|
|
13
13
|
var yt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
-
function Et(
|
|
15
|
-
return
|
|
14
|
+
function Et(O) {
|
|
15
|
+
return O && O.__esModule && Object.prototype.hasOwnProperty.call(O, "default") ? O.default : O;
|
|
16
16
|
}
|
|
17
17
|
var lt = { exports: {} };
|
|
18
|
-
(function(
|
|
18
|
+
(function(O, e) {
|
|
19
19
|
(function(r) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(t, n) {
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
21
|
+
var u, f;
|
|
22
|
+
for (u = n || 0, f = this.length; u < f; u += 1)
|
|
23
|
+
if (this[u] === t)
|
|
24
|
+
return u;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
27
|
var i = this, A = function(t, n) {
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
},
|
|
28
|
+
for (var u = t.toString(); u.length < n; )
|
|
29
|
+
u = "0" + u;
|
|
30
|
+
return u;
|
|
31
|
+
}, a = function(t, n) {
|
|
32
32
|
return n !== r ? (t.year(n.year() || n.year), t.month(n.month() || n.month), t.day(n.day() || n.day), t.hours(n.hours() || n.hours), t.minutes(n.minutes() || n.minutes), t.seconds(n.seconds() || n.seconds), t.milliseconds(n.milliseconds() || n.milliseconds), t) : r;
|
|
33
|
-
},
|
|
34
|
-
var
|
|
35
|
-
return
|
|
33
|
+
}, l = function(t, n) {
|
|
34
|
+
var u, f = "";
|
|
35
|
+
return u = t.slice(n, n + 1), u !== "" && !isNaN(Number(u)) && (f += "%H"), u = t.charAt(n + 2), u !== "" && u === ":" && (f += u), u = t.slice(n + 3, n + 4), u !== "" && !isNaN(Number(u)) && (f += "%M"), u = t.charAt(n + 5), u !== "" && u === ":" && (f += u), u = t.slice(n + 6, n + 7), u !== "" && !isNaN(Number(u)) && (f += "%S"), f;
|
|
36
36
|
}, m = function(t, n) {
|
|
37
|
-
var
|
|
37
|
+
var u, f = [
|
|
38
38
|
t.slice(n, n + 1),
|
|
39
39
|
t.charAt(n + 2),
|
|
40
40
|
t.slice(n + 3, n + 4),
|
|
41
41
|
t.charAt(n + 5),
|
|
42
42
|
t.slice(n + 6, n + 9)
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(f[0])) && !isNaN(Number(f[2])) && !isNaN(Number(f[4])) ? (f[1] === "." && f[3] === "." ?
|
|
43
|
+
], b;
|
|
44
|
+
return !isNaN(Number(f[0])) && !isNaN(Number(f[2])) && !isNaN(Number(f[4])) ? (f[1] === "." && f[3] === "." ? u = "%d.%m.%Y" : f[1] === "-" && f[3] === "-" ? u = "%m-%d-%Y" : f[1] === "/" && f[3] === "/" && (u = "%m/%d/%Y"), u) : (b = [
|
|
45
45
|
t.slice(n, n + 3),
|
|
46
46
|
t.charAt(n + 4),
|
|
47
47
|
t.slice(n + 5, n + 6),
|
|
48
48
|
t.charAt(n + 7),
|
|
49
49
|
t.slice(n + 8, n + 9)
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
},
|
|
50
|
+
], !isNaN(Number(b[0])) && !isNaN(Number(b[2])) && !isNaN(Number(b[4])) ? (b[1] === "-" && b[3] === "-" && (u = "%Y-%m-%d"), u) : "");
|
|
51
|
+
}, c = i.tempus, s, g, _ = i.navigator || {}, h = "en", o = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,63 +209,63 @@ var lt = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, d = function() {
|
|
213
213
|
return [
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
214
|
+
o[h].JANUARY_LONG,
|
|
215
|
+
o[h].FEBRUARY_LONG,
|
|
216
|
+
o[h].MARCH_LONG,
|
|
217
|
+
o[h].APRIL_LONG,
|
|
218
|
+
o[h].MAY_LONG,
|
|
219
|
+
o[h].JUNE_LONG,
|
|
220
|
+
o[h].JULY_LONG,
|
|
221
|
+
o[h].AUGUST_LONG,
|
|
222
|
+
o[h].SEPTEMBER_LONG,
|
|
223
|
+
o[h].OCTOBER_LONG,
|
|
224
|
+
o[h].NOVEMBER_LONG,
|
|
225
|
+
o[h].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
|
-
},
|
|
227
|
+
}, N = function() {
|
|
228
228
|
return [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
229
|
+
o[h].JANUARY_SHORT,
|
|
230
|
+
o[h].FEBRUARY_SHORT,
|
|
231
|
+
o[h].MARCH_SHORT,
|
|
232
|
+
o[h].APRIL_SHORT,
|
|
233
|
+
o[h].MAY_SHORT,
|
|
234
|
+
o[h].JUNE_SHORT,
|
|
235
|
+
o[h].JULY_SHORT,
|
|
236
|
+
o[h].AUGUST_SHORT,
|
|
237
|
+
o[h].SEPTEMBER_SHORT,
|
|
238
|
+
o[h].OCTOBER_SHORT,
|
|
239
|
+
o[h].NOVEMBER_SHORT,
|
|
240
|
+
o[h].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, y = function() {
|
|
243
243
|
return [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
244
|
+
o[h].SUNDAY_LONG,
|
|
245
|
+
o[h].MONDAY_LONG,
|
|
246
|
+
o[h].TUESDAY_LONG,
|
|
247
|
+
o[h].WEDNESDAY_LONG,
|
|
248
|
+
o[h].THURSDAY_LONG,
|
|
249
|
+
o[h].FRIDAY_LONG,
|
|
250
|
+
o[h].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, I = function() {
|
|
253
253
|
return [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
254
|
+
o[h].SUNDAY_SHORT,
|
|
255
|
+
o[h].MONDAY_SHORT,
|
|
256
|
+
o[h].TUESDAY_SHORT,
|
|
257
|
+
o[h].WEDNESDAY_SHORT,
|
|
258
|
+
o[h].THURSDAY_SHORT,
|
|
259
|
+
o[h].FRIDAY_SHORT,
|
|
260
|
+
o[h].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
},
|
|
262
|
+
}, B, G, P, L, W = function(t, n, u) {
|
|
263
263
|
var f;
|
|
264
264
|
i.XMLHttpRequest ? f = new XMLHttpRequest() : f = new ActiveXObject("Microsoft.XMLHTTP"), f.onreadystatechange = function() {
|
|
265
265
|
f.readyState === 4 && (f.status === 200 ? n && (i.JSON === r ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(f.responseText))) :
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(f.responseText))) : u && u(f));
|
|
267
267
|
}, f.open("GET", t, !1), f.send();
|
|
268
|
-
},
|
|
268
|
+
}, k = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(t) {
|
|
271
271
|
return A(t.day() || s.MIN_DAY, 2);
|
|
@@ -316,7 +316,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
316
316
|
"%a": {
|
|
317
317
|
format: function(t) {
|
|
318
318
|
var n = t.dayOfWeek();
|
|
319
|
-
return
|
|
319
|
+
return L[n !== r ? n : s.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
return {};
|
|
@@ -328,7 +328,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
328
328
|
"%A": {
|
|
329
329
|
format: function(t) {
|
|
330
330
|
var n = t.dayOfWeek();
|
|
331
|
-
return
|
|
331
|
+
return P[n !== r ? n : s.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
334
334
|
return {};
|
|
@@ -340,7 +340,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
340
340
|
"%b": {
|
|
341
341
|
format: function(t) {
|
|
342
342
|
var n = s.options("monthFromZero") ? t.month() : t.month() - 1;
|
|
343
|
-
return
|
|
343
|
+
return G[n !== r ? n : s.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(t) {
|
|
346
346
|
var n = s.monthNames().indexOf(t) + (s.options("monthFromZero") ? 0 : 1);
|
|
@@ -353,7 +353,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
353
353
|
"%B": {
|
|
354
354
|
format: function(t) {
|
|
355
355
|
var n = s.options("monthFromZero") ? t.month() : t.month() - 1;
|
|
356
|
-
return
|
|
356
|
+
return B[n !== r ? n : s.MIN_MONTH];
|
|
357
357
|
},
|
|
358
358
|
parse: function(t) {
|
|
359
359
|
var n = s.monthNames(!0).indexOf(t) + (s.options("monthFromZero") ? 0 : 1);
|
|
@@ -415,10 +415,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
415
415
|
return A(t.year() || s.MIN_YEAR, 4) + "-" + A(t.month() || s.MIN_MONTH, 2) + "-" + A(t.day() || s.MIN_DAY, 2);
|
|
416
416
|
},
|
|
417
417
|
parse: function(t) {
|
|
418
|
-
var n = Number(t.slice(0, 4)),
|
|
418
|
+
var n = Number(t.slice(0, 4)), u = Number(t.slice(5, 7)), f = Number(t.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: n,
|
|
421
|
-
month:
|
|
421
|
+
month: u,
|
|
422
422
|
day: f
|
|
423
423
|
};
|
|
424
424
|
},
|
|
@@ -431,11 +431,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
431
431
|
return A(t.month() || s.MIN_MONTH, 2) + "/" + A(t.day() || s.MIN_DAY, 2) + "/" + A(t.year() || s.MIN_YEAR, 4);
|
|
432
432
|
},
|
|
433
433
|
parse: function(t) {
|
|
434
|
-
var n = Number(t.slice(0, 2)),
|
|
434
|
+
var n = Number(t.slice(0, 2)), u = Number(t.slice(3, 5)), f = Number(t.slice(6, 10));
|
|
435
435
|
return {
|
|
436
436
|
year: f,
|
|
437
437
|
month: n,
|
|
438
|
-
day:
|
|
438
|
+
day: u
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
@@ -445,8 +445,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
445
445
|
}, tt = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, T;
|
|
449
|
+
T = function(t, n, u) {
|
|
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`) : n(JSON.pars
|
|
|
455
455
|
minutes: !1,
|
|
456
456
|
seconds: !1,
|
|
457
457
|
milliseconds: !1
|
|
458
|
-
}, t !== r && this.set(t, n,
|
|
459
|
-
},
|
|
458
|
+
}, t !== r && this.set(t, n, u), this;
|
|
459
|
+
}, T.fn = T.prototype, T.fn.dayCount = function() {
|
|
460
460
|
var t = this.month(), n = s.MAX_DAY_IN_MONTHS[t - (s.options("monthFromZero") ? 0 : 1)];
|
|
461
461
|
return this.leapYear() && t === (s.options("monthFromZero") ? 1 : 2) && (n += 1), n;
|
|
462
|
-
},
|
|
462
|
+
}, T.fn.year = function(t) {
|
|
463
463
|
if (arguments.length !== 0)
|
|
464
464
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_YEAR && Number(t) <= s.MAX_YEAR ? (this._d.setFullYear(Number(t)), this._i.year = !1) : this._i.year = Number(t) : (this._d.setFullYear(s.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
|
+
}, T.fn.month = function(t) {
|
|
469
469
|
if (arguments.length !== 0)
|
|
470
470
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MONTH && Number(t) <= s.MAX_MONTH ? (this._d.setMonth(s.options("monthFromZero") ? Number(t) : Number(t) - 1), this._i.month = !1) : this._i.month = Number(t) : (this._d.setMonth(s.options("monthFromZero") ? s.MIN_MONTH : s.MIN_MONTH - 1), this._i.month = !1);
|
|
471
471
|
else
|
|
472
472
|
return this._i.month === !1 ? s.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
|
|
473
473
|
return this;
|
|
474
|
-
},
|
|
474
|
+
}, T.fn.day = function(t) {
|
|
475
475
|
if (arguments.length !== 0)
|
|
476
476
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_DAY && Number(t) <= this.dayCount() ? (this._d.setDate(Number(t)), this._i.day = !1) : this._i.day = Number(t) : (this._d.setDate(s.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
|
+
}, T.fn.hours = function(t) {
|
|
481
481
|
if (arguments.length !== 0)
|
|
482
482
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_HOURS && Number(t) <= s.MAX_HOURS ? (this._d.setHours(Number(t)), this._i.hours = !1) : this._i.hours = Number(t) : (this._d.setHours(s.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
|
+
}, T.fn.minutes = function(t) {
|
|
487
487
|
if (arguments.length !== 0)
|
|
488
488
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MINUTES && Number(t) <= s.MAX_MINUTES ? (this._d.setMinutes(Number(t)), this._i.minutes = !1) : this._i.minutes = Number(t) : (this._d.setMinutes(s.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
|
+
}, T.fn.seconds = function(t) {
|
|
493
493
|
if (arguments.length !== 0)
|
|
494
494
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_SECONDS && Number(t) <= s.MAX_SECONDS ? (this._d.setSeconds(Number(t)), this._i.seconds = !1) : this._i.seconds = Number(t) : (this._d.setSeconds(s.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
|
+
}, T.fn.milliseconds = function(t) {
|
|
499
499
|
if (arguments.length !== 0)
|
|
500
500
|
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MILLISECONDS && Number(t) <= s.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(t)), this._i.milliseconds = !1) : this._i.milliseconds = Number(t) : (this._d.setMilliseconds(s.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
|
+
}, T.fn.week = function() {
|
|
505
505
|
var t = new Date(this.year(), 0, 1), n = s(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
|
|
506
506
|
return Math.ceil(((n - t.getTime()) / 864e5 + t.getDay() + 1) / 7);
|
|
507
|
-
},
|
|
507
|
+
}, T.fn.set = function(t, n, u) {
|
|
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`) : n(JSON.pars
|
|
|
520
520
|
if (typeof t == "number")
|
|
521
521
|
return this._d = new Date(t * (s.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
522
522
|
if (typeof t == "object" && (t instanceof Array ? (this.day(s.MIN_DAY), this.year(t[0]), this.month(t[1]), this.day(t[2]), this.hours(t[3]), this.minutes(t[4]), this.seconds(t[5]), this.milliseconds(t[6])) : (this.day(s.MIN_DAY), this.year(t.year), this.month(t.month), this.day(t.day), this.hours(t.hours), this.minutes(t.minutes), this.seconds(t.seconds), this.milliseconds(t.milliseconds))), typeof t == "string") {
|
|
523
|
-
var f,
|
|
523
|
+
var f, b = [], p, R, j = [], w = 0, Y = 0, S, F, M = {}, U;
|
|
524
524
|
if (t === r)
|
|
525
|
-
return
|
|
525
|
+
return p = a(this, u), p === r && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -530,26 +530,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
530
530
|
minutes: -1,
|
|
531
531
|
seconds: -1,
|
|
532
532
|
milliseconds: -1
|
|
533
|
-
}),
|
|
534
|
-
for (n === r && (n = s.detectFormat(t));
|
|
535
|
-
if (n.charAt(
|
|
536
|
-
if (
|
|
537
|
-
switch (
|
|
533
|
+
}), p;
|
|
534
|
+
for (n === r && (n = s.detectFormat(t)); w < n.length; ) {
|
|
535
|
+
if (n.charAt(w) === "%") {
|
|
536
|
+
if (R = n.charAt(w) + n.charAt(w + 1), k[R] !== r) {
|
|
537
|
+
switch (S = 0, F = "", k[R].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (;
|
|
540
|
-
|
|
539
|
+
for (; S < k[R].maxLength && Y + S < t.length && !isNaN(Number(t.charAt(Y + S))); )
|
|
540
|
+
F += t.charAt(Y + S), S += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (;
|
|
544
|
-
|
|
543
|
+
for (; S < k[R].maxLength && Y + S < t.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(Y + S)); )
|
|
544
|
+
F += t.charAt(Y + S), S += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (;
|
|
548
|
-
|
|
547
|
+
for (; S < k[R].maxLength && Y + S < t.length; )
|
|
548
|
+
F += t.charAt(Y + S), S += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (
|
|
552
|
-
return
|
|
551
|
+
if (S < k[R].minLength)
|
|
552
|
+
return p = a(this, u), p === r && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
555
555
|
day: -1,
|
|
@@ -557,11 +557,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
557
557
|
minutes: -1,
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
|
-
}),
|
|
561
|
-
|
|
560
|
+
}), p;
|
|
561
|
+
b.push(R), j.push(F), S -= 1, Y += S, w += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (t.charAt(
|
|
564
|
-
return
|
|
563
|
+
} else if (t.charAt(Y) !== n.charAt(w))
|
|
564
|
+
return p = a(this, u), p === r && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -569,33 +569,33 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
569
569
|
minutes: -1,
|
|
570
570
|
seconds: -1,
|
|
571
571
|
milliseconds: -1
|
|
572
|
-
}),
|
|
573
|
-
|
|
572
|
+
}), p;
|
|
573
|
+
w += 1, Y += 1;
|
|
574
574
|
}
|
|
575
|
-
for (f in
|
|
576
|
-
|
|
577
|
-
year:
|
|
578
|
-
month:
|
|
579
|
-
day:
|
|
580
|
-
hours:
|
|
581
|
-
minutes:
|
|
582
|
-
seconds:
|
|
575
|
+
for (f in b)
|
|
576
|
+
b.hasOwnProperty(f) && k.hasOwnProperty(b[f]) && (U = k[b[f]].parse(j[f]), M = {
|
|
577
|
+
year: U.year !== r ? U.year : M.year,
|
|
578
|
+
month: U.month !== r ? U.month : M.month,
|
|
579
|
+
day: U.day !== r ? U.day : M.day,
|
|
580
|
+
hours: U.hours !== r ? U.hours : M.hours,
|
|
581
|
+
minutes: U.minutes !== r ? U.minutes : M.minutes,
|
|
582
|
+
seconds: U.seconds !== r ? U.seconds : M.seconds
|
|
583
583
|
});
|
|
584
|
-
this.day(s.MIN_DAY), this.year(
|
|
584
|
+
this.day(s.MIN_DAY), this.year(M.year), this.month(M.month), this.day(M.day), this.hours(M.hours), this.minutes(M.minutes), this.seconds(M.seconds), this.milliseconds(M.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
|
-
},
|
|
587
|
+
}, T.fn.leapYear = function() {
|
|
588
588
|
var t = this.year();
|
|
589
589
|
return t % 4 === 0 ? t % 100 === 0 ? t % 400 === 0 : !0 : !1;
|
|
590
|
-
},
|
|
590
|
+
}, T.fn.timestamp = function(t) {
|
|
591
591
|
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (s.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : s.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
|
|
592
|
-
},
|
|
592
|
+
}, T.fn.utc = function(t) {
|
|
593
593
|
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (s.options("useMilliseconds") ? 1 : 1e3)), this) : s.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
|
|
594
|
-
},
|
|
594
|
+
}, T.fn.dayOfWeek = function(t) {
|
|
595
595
|
if (t === "long")
|
|
596
|
-
return
|
|
596
|
+
return P[this._d.getDay()];
|
|
597
597
|
if (t === "short")
|
|
598
|
-
return
|
|
598
|
+
return L[this._d.getDay()];
|
|
599
599
|
if (t === r)
|
|
600
600
|
return this._d.getDay();
|
|
601
601
|
if (t === 0 || t === "Sunday")
|
|
@@ -612,7 +612,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
612
612
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
|
|
613
613
|
if (t === 6 || t === "Saturday")
|
|
614
614
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
|
|
615
|
-
},
|
|
615
|
+
}, T.fn.timezone = function(t) {
|
|
616
616
|
switch (t) {
|
|
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`) : n(JSON.pars
|
|
|
621
621
|
default:
|
|
622
622
|
return this._d.getTimezoneOffset() * 60;
|
|
623
623
|
}
|
|
624
|
-
},
|
|
624
|
+
}, T.fn.get = function(t) {
|
|
625
625
|
switch (t) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
@@ -670,36 +670,36 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
670
670
|
timestamp: this.timestamp()
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
},
|
|
674
|
-
for (var n = 0,
|
|
675
|
-
t.charAt(n) === "%" ? (f = t.charAt(n) + t.charAt(n + 1),
|
|
676
|
-
return
|
|
677
|
-
},
|
|
673
|
+
}, T.fn.format = function(t) {
|
|
674
|
+
for (var n = 0, u = "", f; n < t.length; )
|
|
675
|
+
t.charAt(n) === "%" ? (f = t.charAt(n) + t.charAt(n + 1), k[f] !== r ? (u += k[f].format(this), n += 1) : u += "%") : u += t.charAt(n), n += 1;
|
|
676
|
+
return u;
|
|
677
|
+
}, T.fn.valid = function() {
|
|
678
678
|
return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
|
|
679
|
-
},
|
|
679
|
+
}, T.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var
|
|
681
|
+
}, T.fn.between = function(t, n) {
|
|
682
|
+
var u = this.timestamp(), f = t.timestamp();
|
|
683
683
|
switch (n) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((f -
|
|
685
|
+
return Math.floor((f - u) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((f -
|
|
687
|
+
return Math.floor((f - u) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((f -
|
|
689
|
+
return Math.floor((f - u) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((f -
|
|
691
|
+
return Math.floor((f - u) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((f -
|
|
693
|
+
return Math.floor((f - u) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return f -
|
|
695
|
+
return f - u;
|
|
696
696
|
default:
|
|
697
697
|
return r;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
699
|
+
}, T.fn.calc = function(t) {
|
|
700
700
|
return t.year !== r && this._d.setFullYear(this._d.getFullYear() + t.year), t.month !== r && this._d.setMonth(this._d.getMonth() + t.month), t.day !== r && this._d.setDate(this._d.getDate() + t.day), t.hours !== r && this._d.setHours(this._d.getHours() + t.hours), t.minutes !== r && this._d.setMinutes(this._d.getMinutes() + t.minutes), t.seconds !== r && this._d.setSeconds(this._d.getSeconds() + t.seconds), t.milliseconds !== r && this._d.setMilliseconds(this._d.getMilliseconds() + t.milliseconds), this;
|
|
701
|
-
}, s = function(t, n,
|
|
702
|
-
return new
|
|
701
|
+
}, s = function(t, n, u) {
|
|
702
|
+
return new T(t, n, u);
|
|
703
703
|
}, s.MIN_YEAR = 1e3, s.MAX_YEAR = 3e3, s.MIN_MONTH = 1, s.MAX_MONTH = 12, s.MIN_DAY = 1, s.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], s.MIN_DAY_OF_WEEK = 0, s.MAX_DAY_OF_WEEK = 6, s.MIN_HOURS = 0, s.MAX_HOURS = 23, s.MIN_MINUTES = 0, s.MAX_MINUTES = 59, s.MIN_SECONDS = 0, s.MAX_SECONDS = 59, s.MIN_MILLISECONDS = 0, s.MAX_MILLISECONDS = 999, s.VERSION = "0.2.18", s.options = function(t, n) {
|
|
704
704
|
if (t === r)
|
|
705
705
|
return tt;
|
|
@@ -710,108 +710,108 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
710
710
|
}
|
|
711
711
|
return r;
|
|
712
712
|
}, s.noConflict = function() {
|
|
713
|
-
return i.tempus =
|
|
713
|
+
return i.tempus = c, s;
|
|
714
714
|
}, s.generate = function(t) {
|
|
715
|
-
var n,
|
|
716
|
-
if (typeof t.dateFrom != "number" && (t.dateFrom instanceof
|
|
715
|
+
var n, u, f, b, p, R, j, w;
|
|
716
|
+
if (typeof t.dateFrom != "number" && (t.dateFrom instanceof T ? n = t.dateFrom.utc() : n = s(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof T ? u = t.dateTo.utc() : u = s(t.dateTo, t.formatTo !== r ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? p = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
719
719
|
day: 0,
|
|
720
720
|
hours: 0,
|
|
721
721
|
minutes: 0,
|
|
722
722
|
seconds: t.period
|
|
723
|
-
} : typeof t.period == "string" ?
|
|
723
|
+
} : typeof t.period == "string" ? p = {
|
|
724
724
|
year: t.period === "year" ? 1 : 0,
|
|
725
725
|
month: t.period === "month" ? 1 : 0,
|
|
726
726
|
day: t.period === "day" ? 1 : 0,
|
|
727
727
|
hours: t.period === "hours" ? 1 : 0,
|
|
728
728
|
minutes: t.period === "minutes" ? 1 : 0,
|
|
729
729
|
seconds: t.period === "seconds" ? 1 : 0
|
|
730
|
-
} : typeof t.period == "object" && (
|
|
730
|
+
} : typeof t.period == "object" && (p = {
|
|
731
731
|
year: t.period.year !== r ? t.period.year : 0,
|
|
732
732
|
month: t.period.month !== r ? t.period.month : 0,
|
|
733
733
|
day: t.period.day !== r ? t.period.day : 0,
|
|
734
734
|
hours: t.period.hours !== r ? t.period.hours : 0,
|
|
735
735
|
minutes: t.period.minutes !== r ? t.period.minutes : 0,
|
|
736
736
|
seconds: t.period.seconds !== r ? t.period.seconds : 0
|
|
737
|
-
}), t.groupBy === r ?
|
|
738
|
-
return t.asObject === !0 ? t.format !== r ?
|
|
737
|
+
}), t.groupBy === r ? R = t.asObject === !0 ? {} : [] : (R = [], R.push([]), j = s(n).get()[t.groupBy]), w = function(F, M, U) {
|
|
738
|
+
return t.asObject === !0 ? t.format !== r ? F[s(M).format(t.format)] = {} : F[s(M).format("%F %H:%M:%S")] = {} : t.format !== r ? F.push(U ? null : s(M).format(t.format)) : F.push(U ? null : s(M)), F;
|
|
739
739
|
}, t.groupBy !== r && t.fillNulls) {
|
|
740
|
-
var
|
|
741
|
-
year:
|
|
742
|
-
month:
|
|
743
|
-
day:
|
|
744
|
-
hours:
|
|
745
|
-
minutes:
|
|
746
|
-
seconds:
|
|
747
|
-
milliseconds:
|
|
740
|
+
var Y = {
|
|
741
|
+
year: p.year ? -p.year : r,
|
|
742
|
+
month: p.month ? -p.month : r,
|
|
743
|
+
day: p.day ? -p.day : r,
|
|
744
|
+
hours: p.hours ? -p.hours : r,
|
|
745
|
+
minutes: p.minutes ? -p.minutes : r,
|
|
746
|
+
seconds: p.seconds ? -p.seconds : r,
|
|
747
|
+
milliseconds: p.milliseconds ? -p.milliseconds : r
|
|
748
748
|
};
|
|
749
|
-
for (f = s(n).calc(
|
|
750
|
-
|
|
749
|
+
for (f = s(n).calc(Y).utc(); s(f).get()[t.groupBy] === j; )
|
|
750
|
+
w(R[R.length - 1], f, !0), f = s(f).calc(Y).utc();
|
|
751
751
|
if (t.groupBy === "week") {
|
|
752
|
-
var
|
|
753
|
-
for (f = s(n).dayOfWeek(0).utc();
|
|
754
|
-
|
|
752
|
+
var S = s(n).dayOfWeek();
|
|
753
|
+
for (f = s(n).dayOfWeek(0).utc(); R[0].length < S && f < n; )
|
|
754
|
+
w(R[R.length - 1], f, !0), f = s(f).calc(p).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; n <=
|
|
758
|
-
t.groupBy === r ?
|
|
757
|
+
for (; n <= u; )
|
|
758
|
+
t.groupBy === r ? w(R, n) : s(n).get()[t.groupBy] === j ? w(R[R.length - 1], n) : (R.push([]), w(R[R.length - 1], n), j = s(n).get()[t.groupBy]), n = s(n).calc(p).utc();
|
|
759
759
|
if (t.groupBy !== r && t.fillNulls)
|
|
760
|
-
for (
|
|
761
|
-
|
|
762
|
-
return
|
|
760
|
+
for (b = s(u).calc(p).utc(); s(b).get()[t.groupBy] === j; )
|
|
761
|
+
w(R[R.length - 1], b, !0), b = s(b).calc(p).utc();
|
|
762
|
+
return R;
|
|
763
763
|
}, s.monthNames = function(t) {
|
|
764
764
|
switch (t) {
|
|
765
765
|
case "long":
|
|
766
|
-
return
|
|
766
|
+
return B;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return G;
|
|
769
769
|
}
|
|
770
770
|
}, s.dayNames = function(t) {
|
|
771
771
|
switch (t) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return P;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return L;
|
|
776
776
|
}
|
|
777
777
|
}, s.lang = function(t) {
|
|
778
778
|
if (t !== r)
|
|
779
|
-
|
|
779
|
+
h = t, o[h] === r && (h = "en"), B = d(), G = N(), P = y(), L = I();
|
|
780
780
|
else
|
|
781
|
-
return
|
|
781
|
+
return h;
|
|
782
782
|
return r;
|
|
783
783
|
}, s.availableLangs = function() {
|
|
784
|
-
return Object.keys(
|
|
785
|
-
}, s.registerFormat = function(t, n,
|
|
786
|
-
|
|
784
|
+
return Object.keys(o);
|
|
785
|
+
}, s.registerFormat = function(t, n, u, f, b, p) {
|
|
786
|
+
k[t] = {
|
|
787
787
|
format: n,
|
|
788
|
-
parse:
|
|
788
|
+
parse: u,
|
|
789
789
|
minLength: f,
|
|
790
|
-
maxLength:
|
|
791
|
-
type:
|
|
790
|
+
maxLength: b,
|
|
791
|
+
type: p
|
|
792
792
|
};
|
|
793
793
|
}, s.unregisterFormat = function(t) {
|
|
794
|
-
delete
|
|
794
|
+
delete k[t];
|
|
795
795
|
}, s.detectFormat = function(t) {
|
|
796
|
-
var n,
|
|
797
|
-
return n = m(t, 0), n !== "" && (f = 10),
|
|
798
|
-
},
|
|
799
|
-
TempusDate:
|
|
796
|
+
var n, u, f;
|
|
797
|
+
return n = m(t, 0), n !== "" && (f = 10), u = t.charAt(f), (u === "T" || u === " ") && (n += u, f += 1), n += l(t, f), n;
|
|
798
|
+
}, g = {
|
|
799
|
+
TempusDate: T
|
|
800
800
|
}, s.classes = function(t, n) {
|
|
801
801
|
if (n === r)
|
|
802
|
-
return
|
|
803
|
-
|
|
802
|
+
return g[t];
|
|
803
|
+
g[t] = n;
|
|
804
804
|
}, s.loadTranslations = function(t) {
|
|
805
|
-
typeof t == "object" ?
|
|
806
|
-
|
|
805
|
+
typeof t == "object" ? o = t : typeof t == "string" && W(t, function(n) {
|
|
806
|
+
o = n;
|
|
807
807
|
}, function(n) {
|
|
808
808
|
});
|
|
809
|
-
},
|
|
809
|
+
}, h = (_.language || _.systemLanguage || _.userLanguage || "en").substr(0, 2).toLowerCase(), o[h] === r && (h = "en"), B = d(), G = N(), P = y(), L = I(), O.exports && (e = O.exports = s), e.tempus = s;
|
|
810
810
|
}).call(yt);
|
|
811
811
|
})(lt, lt.exports);
|
|
812
812
|
var Tt = lt.exports;
|
|
813
813
|
const et = /* @__PURE__ */ Et(Tt);
|
|
814
|
-
class
|
|
814
|
+
class v {
|
|
815
815
|
constructor(e) {
|
|
816
816
|
this.callBatch = e, this.result = {}, this.errors = {}, this.limit = 50, this.canContinue = !0, this.progressCall = "", this.limitCall = "", this.progressData = "", this.progressTimer = "", this.progressDelay = 100, this.oldPercent = "no", this.chunkRate = 1, this.totalProgress = 0, this.skipList = /* @__PURE__ */ new Set();
|
|
817
817
|
}
|
|
@@ -833,8 +833,8 @@ class j {
|
|
|
833
833
|
return { percent: Math.round(e), allCount: 0, allTotal: 0 };
|
|
834
834
|
let r = 0, i = 0;
|
|
835
835
|
return Object.values(this.progressData).forEach((A) => {
|
|
836
|
-
const { total:
|
|
837
|
-
r +=
|
|
836
|
+
const { total: a, count: l } = A;
|
|
837
|
+
r += a ?? 0, i += l ?? 0;
|
|
838
838
|
}), r ? e = i / r * 100 * this.chunkRate + this.totalProgress : i === 0 && r === 0 ? e = 100 * this.chunkRate + this.totalProgress : e = 100, { percent: Math.round(e), allCount: i, allTotal: r };
|
|
839
839
|
}
|
|
840
840
|
/**
|
|
@@ -845,18 +845,18 @@ class j {
|
|
|
845
845
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
846
846
|
*/
|
|
847
847
|
setProgressData({ key: e, value: r, type: i }) {
|
|
848
|
-
const A = this.getData(r.data()),
|
|
849
|
-
let
|
|
850
|
-
i === "count" && (
|
|
848
|
+
const A = this.getData(r.data()), a = Array.isArray(A) ? A.length : 0;
|
|
849
|
+
let l = r.total() || a;
|
|
850
|
+
i === "count" && (l = a);
|
|
851
851
|
let m = 1;
|
|
852
|
-
A && (m =
|
|
853
|
-
const { percent:
|
|
852
|
+
A && (m = a), this.progressCall && (this.progressData || (this.progressData = {}), this.progressData[e] && this.progressData[e].count && (m += this.progressData[e].count), this.progressData[e] ? this.progressData[e].count = m : this.progressData[e] = { total: l, count: m }, this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
853
|
+
const { percent: c, allCount: s, allTotal: g } = this.progressPercent;
|
|
854
854
|
(this.oldPercent === "no" || this.oldPercent < this.progressPercent.percent) && (this.progressCall({
|
|
855
855
|
data: this.progressData,
|
|
856
|
-
percent:
|
|
856
|
+
percent: c,
|
|
857
857
|
allCount: s,
|
|
858
|
-
allTotal:
|
|
859
|
-
}), this.oldPercent = this.progressPercent.percent),
|
|
858
|
+
allTotal: g
|
|
859
|
+
}), this.oldPercent = this.progressPercent.percent), c >= 100 && this.clearProgressData();
|
|
860
860
|
}, this.progressDelay)));
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
@@ -887,20 +887,20 @@ class j {
|
|
|
887
887
|
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
888
888
|
const A = {};
|
|
889
889
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
890
|
-
let
|
|
891
|
-
for (const [m,
|
|
890
|
+
let a = {}, l = 0;
|
|
891
|
+
for (const [m, c] of Object.entries(e)) {
|
|
892
892
|
if (!this.canContinue)
|
|
893
893
|
break;
|
|
894
|
-
const s = this.arrayChunk(
|
|
894
|
+
const s = this.arrayChunk(c);
|
|
895
895
|
if (!s) {
|
|
896
|
-
|
|
896
|
+
l++;
|
|
897
897
|
continue;
|
|
898
898
|
}
|
|
899
|
-
|
|
900
|
-
A[
|
|
899
|
+
a[m] = s, (Object.keys(a).length >= 50 || l + 1 === Object.keys(e).length) && (await this.batchChunk(a), Object.entries(this.result).forEach(([g, _]) => {
|
|
900
|
+
A[g] = _;
|
|
901
901
|
}), this.totalProgress = Math.round(
|
|
902
|
-
|
|
903
|
-
),
|
|
902
|
+
l / Object.keys(e).length * 100
|
|
903
|
+
), a = {}), l++;
|
|
904
904
|
}
|
|
905
905
|
return Object.entries(this.errors).length && (A.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(A);
|
|
906
906
|
}
|
|
@@ -918,20 +918,20 @@ class j {
|
|
|
918
918
|
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
919
919
|
const A = {};
|
|
920
920
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
921
|
-
let
|
|
922
|
-
for (const [m,
|
|
921
|
+
let a = {}, l = 0;
|
|
922
|
+
for (const [m, c] of Object.entries(e)) {
|
|
923
923
|
if (!this.canContinue)
|
|
924
924
|
break;
|
|
925
|
-
const s = this.arrayChunk(
|
|
925
|
+
const s = this.arrayChunk(c);
|
|
926
926
|
if (!s) {
|
|
927
|
-
|
|
927
|
+
l++;
|
|
928
928
|
continue;
|
|
929
929
|
}
|
|
930
|
-
|
|
931
|
-
A[
|
|
930
|
+
a[m] = s, (Object.keys(a).length >= 50 || l + 1 === Object.keys(e).length) && (await this.batchChunk(a, "count"), Object.entries(this.result).forEach(([g, _]) => {
|
|
931
|
+
A[g] = _;
|
|
932
932
|
}), this.totalProgress = Math.round(
|
|
933
|
-
|
|
934
|
-
),
|
|
933
|
+
l / Object.keys(e).length * 100
|
|
934
|
+
), a = {}), l++;
|
|
935
935
|
}
|
|
936
936
|
return Object.entries(this.errors).length && (A.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(A);
|
|
937
937
|
}
|
|
@@ -952,8 +952,8 @@ class j {
|
|
|
952
952
|
else {
|
|
953
953
|
r === "tasks.task.list" ? (i.order || (i.order = {}), i.order.ID = "asc") : r === "user.get" ? (i.sort || (i.sort = "ID"), i.order || (i.order = "ASC")) : i.order = { ID: "ASC", id: "ASC" }, Array.isArray(i.select) && !i.select.includes("ID") && i.select.push("ID");
|
|
954
954
|
const A = r === "user.get" ? i.FILTER : i.filter;
|
|
955
|
-
typeof A == "object" && A !== null && !Array.isArray(A) && Object.entries(A).forEach(([
|
|
956
|
-
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(
|
|
955
|
+
typeof A == "object" && A !== null && !Array.isArray(A) && Object.entries(A).forEach(([a, l]) => {
|
|
956
|
+
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (i.start = -1);
|
|
957
957
|
});
|
|
958
958
|
}
|
|
959
959
|
r === "crm.type.list" && i.order && delete i.order.ID;
|
|
@@ -963,7 +963,7 @@ class j {
|
|
|
963
963
|
i = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
964
964
|
else {
|
|
965
965
|
Array.isArray(i[0]) && (i[0] = {});
|
|
966
|
-
const [A,
|
|
966
|
+
const [A, a, l, m] = i;
|
|
967
967
|
A.ID = "ASC", m[0] !== "" && m.includes("ID") || m.push("ID");
|
|
968
968
|
}
|
|
969
969
|
return { method: r, params: i };
|
|
@@ -977,40 +977,40 @@ class j {
|
|
|
977
977
|
async batchChunk(e, r) {
|
|
978
978
|
return new Promise((i) => {
|
|
979
979
|
const A = [];
|
|
980
|
-
let
|
|
981
|
-
this.callBatch(e, async (
|
|
982
|
-
var m,
|
|
983
|
-
for (const [
|
|
980
|
+
let a;
|
|
981
|
+
this.callBatch(e, async (l) => {
|
|
982
|
+
var m, c, s, g, _, h, o;
|
|
983
|
+
for (const [d, N] of Object.entries(l)) {
|
|
984
984
|
if (!this.canContinue)
|
|
985
985
|
return;
|
|
986
|
-
if (
|
|
987
|
-
switch (this.errors[
|
|
986
|
+
if (N.error())
|
|
987
|
+
switch (this.errors[d] = ((c = (m = N.error()) == null ? void 0 : m.ex) == null ? void 0 : c.error) ?? ((g = (s = N.error()) == null ? void 0 : s.ex) == null ? void 0 : g.error_description) ?? ((_ = N.error()) == null ? void 0 : _.toString()) ?? "Неизвестная ошибка", a = !0, ((o = (h = N.error()) == null ? void 0 : h.ex) == null ? void 0 : o.error) ?? "") {
|
|
988
988
|
case "OPERATION_TIME_LIMIT":
|
|
989
|
-
this.skipList.add(e[
|
|
989
|
+
this.skipList.add(e[d].method), this.limitCall && this.limitCall(d);
|
|
990
990
|
break;
|
|
991
991
|
case "QUERY_LIMIT_EXCEEDED":
|
|
992
992
|
this.canContinue = !1;
|
|
993
993
|
break;
|
|
994
994
|
case "ACCESS_DENIED":
|
|
995
|
-
this.skipList.add(e[
|
|
995
|
+
this.skipList.add(e[d].method);
|
|
996
996
|
break;
|
|
997
997
|
}
|
|
998
|
-
const
|
|
999
|
-
r === "count" ? this.result[
|
|
1000
|
-
const
|
|
1001
|
-
if (!this.canContinue ||
|
|
1002
|
-
let
|
|
1003
|
-
if (Array.isArray(
|
|
1004
|
-
const [
|
|
1005
|
-
|
|
998
|
+
const y = this.getData(N.data()), I = Array.isArray(y) ? y.length : 0, B = typeof N.total == "function" && N.total() !== void 0, G = B ? N.total() : I;
|
|
999
|
+
r === "count" ? this.result[d] ? this.result[d] += I : this.result[d] = G : this.result[d] = y, this.setProgressData({ key: d, value: N, type: r });
|
|
1000
|
+
const P = r === "count" ? !B && I === this.limit : G > this.limit && G > I;
|
|
1001
|
+
if (!this.canContinue || P) {
|
|
1002
|
+
let L = e[d];
|
|
1003
|
+
if (Array.isArray(L)) {
|
|
1004
|
+
const [W, k = {}] = L;
|
|
1005
|
+
L = [W, k];
|
|
1006
1006
|
} else {
|
|
1007
|
-
const { method:
|
|
1008
|
-
|
|
1007
|
+
const { method: W, params: k = {} } = L;
|
|
1008
|
+
L = [W, k];
|
|
1009
1009
|
}
|
|
1010
|
-
A.push([
|
|
1010
|
+
A.push([d, L, G]);
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
|
|
1013
|
+
a > 0 && this.errorLogger(), A.length ? await this.batchPayload(A, r).then(
|
|
1014
1014
|
() => i(this.result)
|
|
1015
1015
|
) : i(this.result);
|
|
1016
1016
|
});
|
|
@@ -1021,82 +1021,82 @@ class j {
|
|
|
1021
1021
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1022
1022
|
*/
|
|
1023
1023
|
async batchPayload(e, r) {
|
|
1024
|
-
const i = /* @__PURE__ */ new Map(), A = (
|
|
1025
|
-
let
|
|
1026
|
-
this.result[
|
|
1027
|
-
let
|
|
1028
|
-
if (JSON.stringify(
|
|
1024
|
+
const i = /* @__PURE__ */ new Map(), A = (c, s, g, _) => {
|
|
1025
|
+
let h = "ID";
|
|
1026
|
+
this.result[c][this.result[c].length - 1].ID || (h = "id");
|
|
1027
|
+
let o = `${h}`;
|
|
1028
|
+
if (JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? o = "<" + o : o = ">" + o, s === 1 || g.length === 0)
|
|
1029
1029
|
return {
|
|
1030
|
-
field:
|
|
1031
|
-
id: this.result[
|
|
1030
|
+
field: o,
|
|
1031
|
+
id: this.result[c][this.result[c].length - 1][h]
|
|
1032
1032
|
};
|
|
1033
|
-
let
|
|
1034
|
-
const [
|
|
1035
|
-
return (
|
|
1036
|
-
field:
|
|
1037
|
-
id: `$result[${[
|
|
1033
|
+
let N = "";
|
|
1034
|
+
const [y, I] = _;
|
|
1035
|
+
return (y === "tasks.task.list" || y === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(y) && (N = "[items]"), y === "crm.type.list" && (N = "[types]"), y === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
|
|
1036
|
+
field: o,
|
|
1037
|
+
id: `$result[${[c, s - 1].join("__")}]${N}[49][${h}]`
|
|
1038
1038
|
};
|
|
1039
|
-
},
|
|
1040
|
-
const [
|
|
1041
|
-
let
|
|
1042
|
-
if (
|
|
1043
|
-
|
|
1044
|
-
const [
|
|
1045
|
-
return
|
|
1039
|
+
}, a = (c, s) => {
|
|
1040
|
+
const [g, _] = c;
|
|
1041
|
+
let h = JSON.parse(JSON.stringify(_)), o;
|
|
1042
|
+
if (g === "task.item.list") {
|
|
1043
|
+
h = [...h];
|
|
1044
|
+
const [d, N, y, I] = h;
|
|
1045
|
+
return N[s.field] = s.id, [g, h];
|
|
1046
1046
|
}
|
|
1047
|
-
return ["user.get"].includes(
|
|
1047
|
+
return ["user.get"].includes(g) || h.FILTER ? (h.FILTER || (h.FILTER = {}), o = h.FILTER) : (h.filter || (h.filter = {}), o = h.filter), [
|
|
1048
1048
|
"socialnetwork.api.workgroup.list",
|
|
1049
1049
|
"tasks.task.list"
|
|
1050
|
-
].includes(
|
|
1051
|
-
},
|
|
1052
|
-
Object.entries(
|
|
1053
|
-
var
|
|
1054
|
-
const [
|
|
1055
|
-
if (Array.isArray(
|
|
1056
|
-
this.errors[
|
|
1057
|
-
const
|
|
1058
|
-
if (
|
|
1059
|
-
this.limitCall && this.limitCall(
|
|
1060
|
-
const
|
|
1061
|
-
switch (
|
|
1050
|
+
].includes(g) ? o[">ID"] = s.id : o[s.field] = s.id, [g, { ...h, start: -1 }];
|
|
1051
|
+
}, l = (c) => {
|
|
1052
|
+
Object.entries(c).forEach(([s, g]) => {
|
|
1053
|
+
var o, d, N, y, I, B, G;
|
|
1054
|
+
const [_] = s.split("__"), h = this.getData(g.data());
|
|
1055
|
+
if (Array.isArray(h) && (r === "count" ? this.result[_] += h.length : this.result[_].push(...h)), g.error()) {
|
|
1056
|
+
this.errors[_] = ((d = (o = g.error()) == null ? void 0 : o.ex) == null ? void 0 : d.error) ?? ((y = (N = g.error()) == null ? void 0 : N.ex) == null ? void 0 : y.error_description) ?? ((I = g.error()) == null ? void 0 : I.toString()) ?? "Неизвестная ошибка";
|
|
1057
|
+
const P = ((G = (B = g.error()) == null ? void 0 : B.ex) == null ? void 0 : G.error) ?? "";
|
|
1058
|
+
if (P === "OPERATION_TIME_LIMIT") {
|
|
1059
|
+
this.limitCall && this.limitCall(_);
|
|
1060
|
+
const L = i.get(_);
|
|
1061
|
+
switch (P) {
|
|
1062
1062
|
case "OPERATION_TIME_LIMIT":
|
|
1063
|
-
|
|
1063
|
+
L && (this.skipList.add(L), this.limitCall && this.limitCall(_));
|
|
1064
1064
|
break;
|
|
1065
1065
|
case "QUERY_LIMIT_EXCEEDED":
|
|
1066
1066
|
this.canContinue = !1;
|
|
1067
1067
|
break;
|
|
1068
1068
|
case "ACCESS_DENIED":
|
|
1069
|
-
this.skipList.add(
|
|
1069
|
+
this.skipList.add(L);
|
|
1070
1070
|
break;
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
-
this.setProgressData({ key:
|
|
1074
|
+
this.setProgressData({ key: _, value: g, type: r });
|
|
1075
1075
|
});
|
|
1076
1076
|
};
|
|
1077
1077
|
let m = [];
|
|
1078
|
-
for await (const [
|
|
1078
|
+
for await (const [c, s, g] of e) {
|
|
1079
1079
|
if (!this.canContinue)
|
|
1080
1080
|
return;
|
|
1081
|
-
const [
|
|
1082
|
-
if (i.set(
|
|
1081
|
+
const [_] = s;
|
|
1082
|
+
if (i.set(c, _), this.skipList.has(_))
|
|
1083
1083
|
continue;
|
|
1084
|
-
let
|
|
1085
|
-
for (;
|
|
1086
|
-
const
|
|
1087
|
-
m.push([
|
|
1088
|
-
(
|
|
1084
|
+
let h = 1;
|
|
1085
|
+
for (; g > h * 50 && !this.skipList.has(_); ) {
|
|
1086
|
+
const o = [c, h].join("__"), d = A(c, h, m, s);
|
|
1087
|
+
m.push([o, a(s, d)]), m.length % 50 === 0 && (await new Promise(
|
|
1088
|
+
(N) => this.callBatch(
|
|
1089
1089
|
Object.fromEntries(m),
|
|
1090
|
-
(
|
|
1091
|
-
|
|
1090
|
+
(y) => {
|
|
1091
|
+
l(y), N();
|
|
1092
1092
|
}
|
|
1093
1093
|
)
|
|
1094
|
-
), m = [], await this.delay()),
|
|
1094
|
+
), m = [], await this.delay()), h++;
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
m.length && (await new Promise(
|
|
1098
|
-
(
|
|
1099
|
-
|
|
1098
|
+
(c) => this.callBatch(Object.fromEntries(m), (s) => {
|
|
1099
|
+
l(s), c();
|
|
1100
1100
|
})
|
|
1101
1101
|
), await this.delay());
|
|
1102
1102
|
}
|
|
@@ -1109,10 +1109,10 @@ class j {
|
|
|
1109
1109
|
}), console.groupEnd();
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
|
-
var
|
|
1112
|
+
var Z;
|
|
1113
1113
|
class ut {
|
|
1114
1114
|
constructor() {
|
|
1115
|
-
H(this,
|
|
1115
|
+
H(this, Z, {});
|
|
1116
1116
|
}
|
|
1117
1117
|
/**
|
|
1118
1118
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1141,7 +1141,7 @@ class ut {
|
|
|
1141
1141
|
* @param {Function} params.action - Функция для выполнения
|
|
1142
1142
|
*/
|
|
1143
1143
|
actionFilter({ keyTimer: e, duration: r = 10, action: i }) {
|
|
1144
|
-
|
|
1144
|
+
E(this, Z)[e] && (clearTimeout(E(this, Z)[e]), E(this, Z)[e] = null), i && (E(this, Z)[e] = setTimeout(() => {
|
|
1145
1145
|
i();
|
|
1146
1146
|
}, r));
|
|
1147
1147
|
}
|
|
@@ -1173,15 +1173,15 @@ class ut {
|
|
|
1173
1173
|
* @param {string} filename - Имя файла без расширения
|
|
1174
1174
|
*/
|
|
1175
1175
|
downloadFileJson(e, r) {
|
|
1176
|
-
let i = new Blob([JSON.stringify(e)], { type: "application/json" }), A = URL.createObjectURL(i),
|
|
1177
|
-
|
|
1178
|
-
document.body.removeChild(
|
|
1176
|
+
let i = new Blob([JSON.stringify(e)], { type: "application/json" }), A = URL.createObjectURL(i), a = document.createElement("a");
|
|
1177
|
+
a.style.display = "none", a.href = A, a.download = `${r}.json`, document.body.appendChild(a), a.click(), setTimeout(() => {
|
|
1178
|
+
document.body.removeChild(a), URL.revokeObjectURL(A);
|
|
1179
1179
|
}, 200);
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
|
-
|
|
1182
|
+
Z = new WeakMap();
|
|
1183
1183
|
const ht = new ut();
|
|
1184
|
-
var
|
|
1184
|
+
var X, Q, K, z, C, V, q, rt, ft, $, ct, st, mt, it, dt, nt, gt;
|
|
1185
1185
|
class Rt {
|
|
1186
1186
|
constructor() {
|
|
1187
1187
|
H(this, rt);
|
|
@@ -1192,44 +1192,44 @@ class Rt {
|
|
|
1192
1192
|
H(this, st);
|
|
1193
1193
|
H(this, it);
|
|
1194
1194
|
H(this, nt);
|
|
1195
|
-
H(this,
|
|
1195
|
+
H(this, X, "logger");
|
|
1196
1196
|
H(this, Q, !1);
|
|
1197
|
-
H(this,
|
|
1197
|
+
H(this, K, /* @__PURE__ */ new Map());
|
|
1198
1198
|
H(this, z, {});
|
|
1199
1199
|
H(this, C, null);
|
|
1200
1200
|
H(this, V, !1);
|
|
1201
|
-
H(this,
|
|
1201
|
+
H(this, q, !1);
|
|
1202
1202
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1203
|
-
|
|
1204
|
-
|
|
1203
|
+
D(this, "periodClear", 3);
|
|
1204
|
+
J(this, rt, ft).call(this);
|
|
1205
1205
|
}
|
|
1206
1206
|
/** Инициализация логера */
|
|
1207
1207
|
async init() {
|
|
1208
1208
|
try {
|
|
1209
|
-
let e = new
|
|
1209
|
+
let e = new v(BX24.callBatch), { entityList: r } = await e.batch({
|
|
1210
1210
|
entityList: { method: "entity.get" }
|
|
1211
1211
|
});
|
|
1212
1212
|
if (r && Array.isArray(r))
|
|
1213
1213
|
if (r.find(
|
|
1214
|
-
(A) => A.ENTITY ==
|
|
1214
|
+
(A) => A.ENTITY == E(this, X)
|
|
1215
1215
|
))
|
|
1216
|
-
|
|
1216
|
+
x(this, Q, !0);
|
|
1217
1217
|
else {
|
|
1218
1218
|
let { entityAdd: A } = await e.batch({
|
|
1219
1219
|
entityAdd: {
|
|
1220
1220
|
method: "entity.add",
|
|
1221
1221
|
params: {
|
|
1222
|
-
ENTITY:
|
|
1223
|
-
NAME:
|
|
1222
|
+
ENTITY: E(this, X),
|
|
1223
|
+
NAME: E(this, X),
|
|
1224
1224
|
ACCESS: { AU: "X" }
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
1227
|
});
|
|
1228
|
-
A &&
|
|
1228
|
+
A && x(this, Q, !0);
|
|
1229
1229
|
}
|
|
1230
|
-
return
|
|
1230
|
+
return J(this, it, dt).call(this).catch((i) => {
|
|
1231
1231
|
console.error("Ошибка при проверке периода очистки:", i);
|
|
1232
|
-
}),
|
|
1232
|
+
}), E(this, Q);
|
|
1233
1233
|
} catch (e) {
|
|
1234
1234
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1235
1235
|
}
|
|
@@ -1244,20 +1244,20 @@ class Rt {
|
|
|
1244
1244
|
* @returns {string|null}
|
|
1245
1245
|
*/
|
|
1246
1246
|
start({ type: e, data: r }) {
|
|
1247
|
-
if (!
|
|
1248
|
-
return
|
|
1247
|
+
if (!E(this, Q))
|
|
1248
|
+
return J(this, $, ct).call(this, "entity"), null;
|
|
1249
1249
|
if (!e || !r)
|
|
1250
1250
|
return console.error("Невалидные данные для логирования:", { type: e, data: r }), null;
|
|
1251
1251
|
const i = ht.hash, A = {
|
|
1252
1252
|
type: e,
|
|
1253
1253
|
data: r,
|
|
1254
|
-
userInfo:
|
|
1254
|
+
userInfo: E(this, z),
|
|
1255
1255
|
errorList: {},
|
|
1256
1256
|
status: "",
|
|
1257
1257
|
answer: null,
|
|
1258
1258
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1259
1259
|
};
|
|
1260
|
-
return
|
|
1260
|
+
return E(this, K).set(i, A), x(this, q, !0), i;
|
|
1261
1261
|
}
|
|
1262
1262
|
/**
|
|
1263
1263
|
* @param {{
|
|
@@ -1267,19 +1267,19 @@ class Rt {
|
|
|
1267
1267
|
* answer: { [key]: unknown } }}
|
|
1268
1268
|
*/
|
|
1269
1269
|
async stop({ key: e, errorList: r, status: i, answer: A }) {
|
|
1270
|
-
var
|
|
1271
|
-
if (!
|
|
1270
|
+
var l;
|
|
1271
|
+
if (!E(this, q))
|
|
1272
1272
|
return;
|
|
1273
|
-
if (!
|
|
1274
|
-
|
|
1273
|
+
if (!E(this, Q)) {
|
|
1274
|
+
J(this, $, ct).call(this, "entity");
|
|
1275
1275
|
return;
|
|
1276
1276
|
}
|
|
1277
|
-
let
|
|
1278
|
-
if (!
|
|
1277
|
+
let a = E(this, K).get(e);
|
|
1278
|
+
if (!a) {
|
|
1279
1279
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1280
1280
|
return;
|
|
1281
1281
|
}
|
|
1282
|
-
r && (
|
|
1282
|
+
r && (a.errorList = r), i && (a.status = i), A && (a.answer = A), await J(this, st, mt).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && x(this, V, !0), x(this, q, !1);
|
|
1283
1283
|
}
|
|
1284
1284
|
/**
|
|
1285
1285
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1287,35 +1287,35 @@ class Rt {
|
|
|
1287
1287
|
async getEntityList(e) {
|
|
1288
1288
|
var r;
|
|
1289
1289
|
try {
|
|
1290
|
-
if ((r =
|
|
1291
|
-
return
|
|
1292
|
-
let i = new
|
|
1290
|
+
if ((r = E(this, C)) != null && r.length && !E(this, V))
|
|
1291
|
+
return E(this, C);
|
|
1292
|
+
let i = new v(BX24.callBatch), { entityList: A } = await i.batch(
|
|
1293
1293
|
{
|
|
1294
1294
|
entityList: {
|
|
1295
1295
|
method: "entity.item.get",
|
|
1296
1296
|
params: {
|
|
1297
|
-
ENTITY:
|
|
1297
|
+
ENTITY: E(this, X),
|
|
1298
1298
|
SORT: { ID: "DESC" }
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
},
|
|
1302
1302
|
e
|
|
1303
1303
|
);
|
|
1304
|
-
return !A || !Array.isArray(A) ? (console.warn("Получен невалидный список записей"), []) : (A = A.map((
|
|
1304
|
+
return !A || !Array.isArray(A) ? (console.warn("Получен невалидный список записей"), []) : (A = A.map((a) => {
|
|
1305
1305
|
try {
|
|
1306
|
-
const { ID:
|
|
1306
|
+
const { ID: l, DATE_CREATE: m, DETAIL_TEXT: c } = a;
|
|
1307
1307
|
return {
|
|
1308
|
-
...JSON.parse(
|
|
1309
|
-
id:
|
|
1308
|
+
...JSON.parse(c),
|
|
1309
|
+
id: l,
|
|
1310
1310
|
dateCreate: m
|
|
1311
1311
|
};
|
|
1312
|
-
} catch (
|
|
1312
|
+
} catch (l) {
|
|
1313
1313
|
return console.error(
|
|
1314
|
-
`Ошибка парсинга записи ${
|
|
1315
|
-
|
|
1314
|
+
`Ошибка парсинга записи ${a.ID}:`,
|
|
1315
|
+
l
|
|
1316
1316
|
), null;
|
|
1317
1317
|
}
|
|
1318
|
-
}).filter((
|
|
1318
|
+
}).filter((a) => a !== null), x(this, V, !1), x(this, C, A), A);
|
|
1319
1319
|
} catch (i) {
|
|
1320
1320
|
return console.error("Ошибка при получении списка записей:", i), [];
|
|
1321
1321
|
}
|
|
@@ -1323,11 +1323,11 @@ class Rt {
|
|
|
1323
1323
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1324
1324
|
async downAllEntityJson() {
|
|
1325
1325
|
try {
|
|
1326
|
-
if (
|
|
1326
|
+
if (E(this, C) || await this.getEntityList(), !E(this, C) || E(this, C).length === 0)
|
|
1327
1327
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1328
1328
|
let e = et().format("%Y-%m-%d");
|
|
1329
1329
|
return ht.downloadFileJson(
|
|
1330
|
-
|
|
1330
|
+
E(this, C),
|
|
1331
1331
|
`sdklogger-entity-data__${e}`
|
|
1332
1332
|
), !0;
|
|
1333
1333
|
} catch (e) {
|
|
@@ -1335,17 +1335,17 @@ class Rt {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
|
-
|
|
1338
|
+
X = new WeakMap(), Q = new WeakMap(), K = new WeakMap(), z = new WeakMap(), C = new WeakMap(), V = new WeakMap(), q = new WeakMap(), rt = new WeakSet(), ft = async function() {
|
|
1339
1339
|
try {
|
|
1340
|
-
const e = new
|
|
1340
|
+
const e = new v(BX24.callBatch), r = BX24.isAdmin(), { curUser: i } = await e.batch({
|
|
1341
1341
|
curUser: { method: "user.current" }
|
|
1342
1342
|
});
|
|
1343
|
-
|
|
1343
|
+
x(this, z, { isAdmin: r, curUser: i });
|
|
1344
1344
|
} catch (e) {
|
|
1345
1345
|
console.error(
|
|
1346
1346
|
"Ошибка при получении информации о пользователе:",
|
|
1347
1347
|
e
|
|
1348
|
-
),
|
|
1348
|
+
), x(this, z, { isAdmin: !1, curUser: null });
|
|
1349
1349
|
}
|
|
1350
1350
|
}, $ = new WeakSet(), ct = function(e) {
|
|
1351
1351
|
e == "entity" && ht.actionFilter({
|
|
@@ -1357,23 +1357,23 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), C =
|
|
|
1357
1357
|
});
|
|
1358
1358
|
}, st = new WeakSet(), mt = async function() {
|
|
1359
1359
|
try {
|
|
1360
|
-
let e = {}, r = new
|
|
1361
|
-
for (let [i, A] of
|
|
1360
|
+
let e = {}, r = new v(BX24.callBatch);
|
|
1361
|
+
for (let [i, A] of E(this, K).entries())
|
|
1362
1362
|
if (A.status) {
|
|
1363
|
-
const
|
|
1363
|
+
const a = JSON.stringify(A);
|
|
1364
1364
|
e[i] = {
|
|
1365
1365
|
method: "entity.item.add",
|
|
1366
1366
|
params: {
|
|
1367
|
-
ENTITY:
|
|
1368
|
-
NAME:
|
|
1369
|
-
DETAIL_TEXT:
|
|
1367
|
+
ENTITY: E(this, X),
|
|
1368
|
+
NAME: E(this, X),
|
|
1369
|
+
DETAIL_TEXT: a
|
|
1370
1370
|
}
|
|
1371
1371
|
};
|
|
1372
1372
|
}
|
|
1373
1373
|
if (Object.keys(e).length) {
|
|
1374
1374
|
let i = await r.batch(e), { errors: A } = r;
|
|
1375
|
-
for (let [
|
|
1376
|
-
|
|
1375
|
+
for (let [a, l] of Object.entries({ ...i, ...A }))
|
|
1376
|
+
E(this, K).delete(a);
|
|
1377
1377
|
return !0;
|
|
1378
1378
|
}
|
|
1379
1379
|
return !1;
|
|
@@ -1382,29 +1382,29 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), C =
|
|
|
1382
1382
|
}
|
|
1383
1383
|
}, it = new WeakSet(), dt = async function() {
|
|
1384
1384
|
try {
|
|
1385
|
-
let e = new
|
|
1385
|
+
let e = new v(BX24.callBatch), { serverTime: r } = await e.batch({
|
|
1386
1386
|
serverTime: { method: "server.time" }
|
|
1387
1387
|
});
|
|
1388
1388
|
if (!r) {
|
|
1389
1389
|
console.error("Не удалось получить время сервера");
|
|
1390
1390
|
return;
|
|
1391
1391
|
}
|
|
1392
|
-
if (
|
|
1392
|
+
if (E(this, C) || await this.getEntityList(), !E(this, C) || E(this, C).length === 0)
|
|
1393
1393
|
return;
|
|
1394
|
-
let i =
|
|
1394
|
+
let i = E(this, C).filter((A) => {
|
|
1395
1395
|
try {
|
|
1396
|
-
let { dateCreate:
|
|
1397
|
-
return
|
|
1396
|
+
let { dateCreate: a } = A;
|
|
1397
|
+
return a ? et(new Date(a)).between(
|
|
1398
1398
|
et(new Date(r)),
|
|
1399
1399
|
"month"
|
|
1400
1400
|
) >= this.periodClear : !1;
|
|
1401
|
-
} catch (
|
|
1402
|
-
return console.error("Ошибка при проверке даты записи:",
|
|
1401
|
+
} catch (a) {
|
|
1402
|
+
return console.error("Ошибка при проверке даты записи:", a), !1;
|
|
1403
1403
|
}
|
|
1404
1404
|
});
|
|
1405
1405
|
i.length > 0 && (console.log(
|
|
1406
1406
|
`Найдено ${i.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1407
|
-
), await
|
|
1407
|
+
), await J(this, nt, gt).call(this, i));
|
|
1408
1408
|
} catch (e) {
|
|
1409
1409
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1410
1410
|
}
|
|
@@ -1412,25 +1412,25 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), C =
|
|
|
1412
1412
|
try {
|
|
1413
1413
|
if (!e || e.length === 0)
|
|
1414
1414
|
return !1;
|
|
1415
|
-
let r = new
|
|
1416
|
-
let { id:
|
|
1415
|
+
let r = new v(BX24.callBatch), i = e.filter((a) => a && a.id).map((a) => {
|
|
1416
|
+
let { id: l } = a;
|
|
1417
1417
|
return {
|
|
1418
1418
|
method: "entity.item.delete",
|
|
1419
1419
|
params: {
|
|
1420
|
-
ENTITY:
|
|
1421
|
-
ID:
|
|
1420
|
+
ENTITY: E(this, X),
|
|
1421
|
+
ID: l
|
|
1422
1422
|
}
|
|
1423
1423
|
};
|
|
1424
1424
|
});
|
|
1425
1425
|
if (i.length === 0)
|
|
1426
1426
|
return !1;
|
|
1427
1427
|
const A = await r.batch(i);
|
|
1428
|
-
return console.log(`Успешно удалено ${i.length} записей`),
|
|
1428
|
+
return console.log(`Успешно удалено ${i.length} записей`), x(this, V, !0), A;
|
|
1429
1429
|
} catch (r) {
|
|
1430
1430
|
return console.error("Ошибка при очистке устаревших записей:", r), !1;
|
|
1431
1431
|
}
|
|
1432
1432
|
};
|
|
1433
|
-
var At, Nt,
|
|
1433
|
+
var At, Nt, at, Ot;
|
|
1434
1434
|
class bt {
|
|
1435
1435
|
/**
|
|
1436
1436
|
* @param {Object} appConst - Константы приложения
|
|
@@ -1441,15 +1441,15 @@ class bt {
|
|
|
1441
1441
|
/** Запрос данных о приложении */
|
|
1442
1442
|
H(this, At);
|
|
1443
1443
|
/** Запрос данных о текущем пользователе */
|
|
1444
|
-
H(this,
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1444
|
+
H(this, at);
|
|
1445
|
+
D(this, "domain", "");
|
|
1446
|
+
D(this, "isAdmin", !1);
|
|
1447
|
+
D(this, "appInfo", null);
|
|
1448
|
+
D(this, "appConst", null);
|
|
1449
|
+
D(this, "userInfo", null);
|
|
1450
|
+
D(this, "placeData", null);
|
|
1451
|
+
D(this, "placeInfo", null);
|
|
1452
|
+
D(this, "logger", !1);
|
|
1453
1453
|
this.appConst = e;
|
|
1454
1454
|
}
|
|
1455
1455
|
/**
|
|
@@ -1461,7 +1461,7 @@ class bt {
|
|
|
1461
1461
|
return new Promise((e, r) => {
|
|
1462
1462
|
let A = setInterval(() => {
|
|
1463
1463
|
window.BX24 && BX24.init(async () => {
|
|
1464
|
-
console.info("init BX24"), clearInterval(A), clearTimeout(
|
|
1464
|
+
console.info("init BX24"), clearInterval(A), clearTimeout(a), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new Rt(), await this.logger.init()) : this.logger = {
|
|
1465
1465
|
start: () => {
|
|
1466
1466
|
},
|
|
1467
1467
|
stop: () => {
|
|
@@ -1469,14 +1469,14 @@ class bt {
|
|
|
1469
1469
|
getEntityList: () => {
|
|
1470
1470
|
}
|
|
1471
1471
|
};
|
|
1472
|
-
const [
|
|
1473
|
-
|
|
1474
|
-
|
|
1472
|
+
const [l, m] = await Promise.all([
|
|
1473
|
+
J(this, At, Nt).call(this),
|
|
1474
|
+
J(this, at, Ot).call(this)
|
|
1475
1475
|
]);
|
|
1476
|
-
this.appInfo =
|
|
1477
|
-
let
|
|
1476
|
+
this.appInfo = l, this.userInfo = m;
|
|
1477
|
+
let c = new ut();
|
|
1478
1478
|
try {
|
|
1479
|
-
|
|
1479
|
+
c.noSleep();
|
|
1480
1480
|
} catch (s) {
|
|
1481
1481
|
console.warn(
|
|
1482
1482
|
"Failed to initialize noSleep:",
|
|
@@ -1486,12 +1486,12 @@ class bt {
|
|
|
1486
1486
|
e(!0);
|
|
1487
1487
|
});
|
|
1488
1488
|
}, 100);
|
|
1489
|
-
const
|
|
1489
|
+
const a = setTimeout(() => {
|
|
1490
1490
|
clearInterval(A);
|
|
1491
|
-
const
|
|
1491
|
+
const l = new Error(
|
|
1492
1492
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
1493
1493
|
);
|
|
1494
|
-
console.error(
|
|
1494
|
+
console.error(l), r(l);
|
|
1495
1495
|
}, 3e4);
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
@@ -1543,42 +1543,42 @@ class bt {
|
|
|
1543
1543
|
type: "call",
|
|
1544
1544
|
data: { method: e, params: r, updateList: i }
|
|
1545
1545
|
})), r || (r = {}), typeof BX24 > "u" || !BX24.callMethod) {
|
|
1546
|
-
const
|
|
1547
|
-
throw console.error(
|
|
1546
|
+
const a = new Error("BX24 is not initialized");
|
|
1547
|
+
throw console.error(a), a;
|
|
1548
1548
|
}
|
|
1549
|
-
return new Promise((
|
|
1549
|
+
return new Promise((a, l) => {
|
|
1550
1550
|
BX24.callMethod(e, r, async (m) => {
|
|
1551
|
-
let
|
|
1551
|
+
let c = {};
|
|
1552
1552
|
if (m != null && m.answer)
|
|
1553
|
-
for (let [s,
|
|
1554
|
-
s !== "result" &&
|
|
1553
|
+
for (let [s, g] of Object.entries(m.answer))
|
|
1554
|
+
s !== "result" && g && (c[s] = g);
|
|
1555
1555
|
if (m.error()) {
|
|
1556
1556
|
let s = m.error();
|
|
1557
1557
|
if (console.error(s), A)
|
|
1558
1558
|
try {
|
|
1559
1559
|
await this.logger.stop({
|
|
1560
|
-
answer:
|
|
1560
|
+
answer: c,
|
|
1561
1561
|
key: A,
|
|
1562
1562
|
status: "fail",
|
|
1563
1563
|
errorList: { 0: s.toString() }
|
|
1564
1564
|
});
|
|
1565
|
-
} catch (
|
|
1566
|
-
console.error("Logger error:",
|
|
1565
|
+
} catch (g) {
|
|
1566
|
+
console.error("Logger error:", g);
|
|
1567
1567
|
}
|
|
1568
|
-
|
|
1568
|
+
a(!1);
|
|
1569
1569
|
} else {
|
|
1570
1570
|
let s = m.data();
|
|
1571
1571
|
if (s != null && s.items && (s = s.items), A)
|
|
1572
1572
|
try {
|
|
1573
1573
|
await this.logger.stop({
|
|
1574
|
-
answer:
|
|
1574
|
+
answer: c,
|
|
1575
1575
|
key: A,
|
|
1576
1576
|
status: "success"
|
|
1577
1577
|
});
|
|
1578
|
-
} catch (
|
|
1579
|
-
console.error("Logger error:",
|
|
1578
|
+
} catch (g) {
|
|
1579
|
+
console.error("Logger error:", g);
|
|
1580
1580
|
}
|
|
1581
|
-
|
|
1581
|
+
a(s);
|
|
1582
1582
|
}
|
|
1583
1583
|
});
|
|
1584
1584
|
});
|
|
@@ -1602,15 +1602,15 @@ class bt {
|
|
|
1602
1602
|
* }[]
|
|
1603
1603
|
* }}
|
|
1604
1604
|
*/
|
|
1605
|
-
async batch(e, r, { errorCall: i, limitCommandSerial: A, updateList:
|
|
1605
|
+
async batch(e, r, { errorCall: i, limitCommandSerial: A, updateList: a, limitCall: l } = {}) {
|
|
1606
1606
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1607
1607
|
const s = new Error("BX24 is not initialized");
|
|
1608
1608
|
return console.error(s), !1;
|
|
1609
1609
|
}
|
|
1610
|
-
let m = new
|
|
1611
|
-
|
|
1610
|
+
let m = new v(BX24.callBatch), c;
|
|
1611
|
+
a && (c = this.logger.start({
|
|
1612
1612
|
type: "batch",
|
|
1613
|
-
data: { commandList: e, updateList:
|
|
1613
|
+
data: { commandList: e, updateList: a }
|
|
1614
1614
|
})), A && console.warn(
|
|
1615
1615
|
"limitCommandSerial is deprecated and not used in current Batch implementation"
|
|
1616
1616
|
);
|
|
@@ -1618,39 +1618,39 @@ class bt {
|
|
|
1618
1618
|
let s = await m.batch(
|
|
1619
1619
|
e,
|
|
1620
1620
|
r,
|
|
1621
|
-
|
|
1621
|
+
l
|
|
1622
1622
|
);
|
|
1623
1623
|
if (Object.keys(m.errors).length) {
|
|
1624
|
-
if (i && i(m.errors),
|
|
1624
|
+
if (i && i(m.errors), c)
|
|
1625
1625
|
try {
|
|
1626
1626
|
await this.logger.stop({
|
|
1627
|
-
key:
|
|
1627
|
+
key: c,
|
|
1628
1628
|
status: "fail",
|
|
1629
1629
|
errorList: m.errors
|
|
1630
1630
|
});
|
|
1631
|
-
} catch (
|
|
1632
|
-
console.error("Logger error:",
|
|
1631
|
+
} catch (g) {
|
|
1632
|
+
console.error("Logger error:", g);
|
|
1633
1633
|
}
|
|
1634
|
-
} else if (
|
|
1634
|
+
} else if (c)
|
|
1635
1635
|
try {
|
|
1636
1636
|
await this.logger.stop({
|
|
1637
|
-
key:
|
|
1637
|
+
key: c,
|
|
1638
1638
|
status: "success"
|
|
1639
1639
|
});
|
|
1640
|
-
} catch (
|
|
1641
|
-
console.error("Logger error:",
|
|
1640
|
+
} catch (g) {
|
|
1641
|
+
console.error("Logger error:", g);
|
|
1642
1642
|
}
|
|
1643
1643
|
return s;
|
|
1644
1644
|
} catch (s) {
|
|
1645
|
-
if (
|
|
1645
|
+
if (c)
|
|
1646
1646
|
try {
|
|
1647
1647
|
await this.logger.stop({
|
|
1648
|
-
key:
|
|
1648
|
+
key: c,
|
|
1649
1649
|
status: "fail-runtime",
|
|
1650
1650
|
errorList: { 0: s == null ? void 0 : s.toString() }
|
|
1651
1651
|
});
|
|
1652
|
-
} catch (
|
|
1653
|
-
console.error("Logger error:",
|
|
1652
|
+
} catch (g) {
|
|
1653
|
+
console.error("Logger error:", g);
|
|
1654
1654
|
}
|
|
1655
1655
|
return console.error(s), !1;
|
|
1656
1656
|
}
|
|
@@ -1678,29 +1678,29 @@ class bt {
|
|
|
1678
1678
|
* }}
|
|
1679
1679
|
* @returns {Promise<Object|false>}
|
|
1680
1680
|
*/
|
|
1681
|
-
async batchTotalCount(e, r, { errorCall: i, updateList: A, limitCall:
|
|
1681
|
+
async batchTotalCount(e, r, { errorCall: i, updateList: A, limitCall: a } = {}) {
|
|
1682
1682
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1683
|
-
const
|
|
1684
|
-
return console.error(
|
|
1683
|
+
const c = new Error("BX24 is not initialized");
|
|
1684
|
+
return console.error(c), !1;
|
|
1685
1685
|
}
|
|
1686
|
-
let
|
|
1686
|
+
let l = new v(BX24.callBatch), m;
|
|
1687
1687
|
A && (m = this.logger.start({
|
|
1688
1688
|
type: "batch-total-count",
|
|
1689
1689
|
data: { commandList: e }
|
|
1690
1690
|
}));
|
|
1691
1691
|
try {
|
|
1692
|
-
let
|
|
1692
|
+
let c = await l.batchTotalCount(
|
|
1693
1693
|
e,
|
|
1694
1694
|
r,
|
|
1695
|
-
|
|
1695
|
+
a
|
|
1696
1696
|
);
|
|
1697
|
-
if (Object.keys(
|
|
1698
|
-
if (i && i(
|
|
1697
|
+
if (Object.keys(l.errors).length) {
|
|
1698
|
+
if (i && i(l.errors), m)
|
|
1699
1699
|
try {
|
|
1700
1700
|
await this.logger.stop({
|
|
1701
1701
|
key: m,
|
|
1702
1702
|
status: "fail",
|
|
1703
|
-
errorList:
|
|
1703
|
+
errorList: l.errors
|
|
1704
1704
|
});
|
|
1705
1705
|
} catch (s) {
|
|
1706
1706
|
console.error("Logger error:", s);
|
|
@@ -1714,19 +1714,19 @@ class bt {
|
|
|
1714
1714
|
} catch (s) {
|
|
1715
1715
|
console.error("Logger error:", s);
|
|
1716
1716
|
}
|
|
1717
|
-
return
|
|
1718
|
-
} catch (
|
|
1717
|
+
return c;
|
|
1718
|
+
} catch (c) {
|
|
1719
1719
|
if (m)
|
|
1720
1720
|
try {
|
|
1721
1721
|
await this.logger.stop({
|
|
1722
1722
|
key: m,
|
|
1723
1723
|
status: "fail-runtime",
|
|
1724
|
-
errorList: { 0:
|
|
1724
|
+
errorList: { 0: c == null ? void 0 : c.toString() }
|
|
1725
1725
|
});
|
|
1726
1726
|
} catch (s) {
|
|
1727
1727
|
console.error("Logger error:", s);
|
|
1728
1728
|
}
|
|
1729
|
-
return console.error(
|
|
1729
|
+
return console.error(c), !1;
|
|
1730
1730
|
}
|
|
1731
1731
|
}
|
|
1732
1732
|
/** Запрос данных о местах встройки приложения */
|
|
@@ -1735,54 +1735,81 @@ class bt {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
/** Встройка приложения в place */
|
|
1737
1737
|
async placementBind(e, r = !0) {
|
|
1738
|
-
var
|
|
1738
|
+
var _, h;
|
|
1739
1739
|
if (!this.isAdmin)
|
|
1740
1740
|
return;
|
|
1741
1741
|
r && await this.placementCheck();
|
|
1742
1742
|
let i = [];
|
|
1743
|
-
if (Array.isArray(e) ? i = e.map((
|
|
1743
|
+
if (Array.isArray(e) ? i = e.map((o) => typeof o == "string" ? { placement: o } : o) : typeof e == "string" ? i = [{ placement: e }] : i = [e], this.placeData = await this.getPlacement(), !this.placeData)
|
|
1744
1744
|
return;
|
|
1745
|
-
const { appName: A, pathApp:
|
|
1746
|
-
let
|
|
1747
|
-
this.domain === "szdl.bitrix24.ru" && ((
|
|
1748
|
-
const m =
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1745
|
+
const { appName: A, pathApp: a } = this.appConst;
|
|
1746
|
+
let l = A;
|
|
1747
|
+
this.domain === "szdl.bitrix24.ru" && ((_ = this.appInfo) != null && _.ID) && (l = `${A}: #${this.appInfo.ID}`);
|
|
1748
|
+
const m = l.replace(" CRM", ""), c = {}, s = [];
|
|
1749
|
+
let g = !1;
|
|
1750
|
+
for (let o = 0; o < i.length; o++)
|
|
1751
|
+
i[o].placement === "PAGE_BACKGROUND_WORKER_ALL" && (g = !0);
|
|
1752
|
+
if (g && ((h = this.userInfo) != null && h.ID)) {
|
|
1753
|
+
const o = this.userInfo.ID, d = `${a}?USER_ID=${o}/`;
|
|
1754
|
+
if (!this.placeData.find(
|
|
1755
|
+
(y) => y.placement === "PAGE_BACKGROUND_WORKER" && y.handler === d
|
|
1756
|
+
)) {
|
|
1757
|
+
const y = {
|
|
1758
|
+
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
1759
|
+
HANDLER: d,
|
|
1760
|
+
LANG_ALL: {
|
|
1761
|
+
ru: {
|
|
1762
|
+
TITLE: l
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
OPTIONS: {
|
|
1766
|
+
errorHandlerUrl: d
|
|
1767
|
+
},
|
|
1768
|
+
USER_ID: o
|
|
1769
|
+
};
|
|
1770
|
+
c[`bind_user_${o}`] = {
|
|
1771
|
+
method: "placement.bind",
|
|
1772
|
+
params: y
|
|
1773
|
+
}, console.log(`placementBind: Добавлено индивидуальное размещение для пользователя ${o} перед общим`);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
for (let o = 0; o < i.length; o++) {
|
|
1777
|
+
const d = i[o], N = d.placement, y = d.userId;
|
|
1778
|
+
let I = a, B = N;
|
|
1779
|
+
if (N === "PAGE_BACKGROUND_WORKER") {
|
|
1753
1780
|
if (!y) {
|
|
1754
|
-
console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${
|
|
1781
|
+
console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${N}`);
|
|
1755
1782
|
continue;
|
|
1756
1783
|
}
|
|
1757
|
-
|
|
1784
|
+
I = `${a}?USER_ID=${y}/`;
|
|
1758
1785
|
}
|
|
1759
|
-
if (
|
|
1760
|
-
(
|
|
1786
|
+
if (N === "PAGE_BACKGROUND_WORKER_ALL" && (B = "PAGE_BACKGROUND_WORKER"), this.placeData.find(
|
|
1787
|
+
(W) => W.placement === B && W.handler === I
|
|
1761
1788
|
))
|
|
1762
1789
|
continue;
|
|
1763
1790
|
let P = this.placeData.find(
|
|
1764
|
-
(
|
|
1791
|
+
(W) => W.placement === B && W.handler !== I
|
|
1765
1792
|
);
|
|
1766
|
-
P && s.push({ placement:
|
|
1767
|
-
const
|
|
1768
|
-
PLACEMENT:
|
|
1769
|
-
HANDLER:
|
|
1793
|
+
P && s.push({ placement: B, handler: P.handler });
|
|
1794
|
+
const L = {
|
|
1795
|
+
PLACEMENT: B,
|
|
1796
|
+
HANDLER: I,
|
|
1770
1797
|
LANG_ALL: {
|
|
1771
1798
|
ru: {
|
|
1772
|
-
TITLE:
|
|
1799
|
+
TITLE: B === "USER_PROFILE_TOOLBAR" ? m : l
|
|
1773
1800
|
}
|
|
1774
1801
|
},
|
|
1775
1802
|
OPTIONS: {
|
|
1776
|
-
errorHandlerUrl:
|
|
1803
|
+
errorHandlerUrl: I
|
|
1777
1804
|
}
|
|
1778
1805
|
};
|
|
1779
|
-
|
|
1806
|
+
N === "PAGE_BACKGROUND_WORKER" && y && (L.USER_ID = y), c[`bind_${o}`] = {
|
|
1780
1807
|
method: "placement.bind",
|
|
1781
|
-
params:
|
|
1808
|
+
params: L
|
|
1782
1809
|
};
|
|
1783
1810
|
}
|
|
1784
|
-
s.length > 0 && await this.placementUnBind(s), Object.keys(
|
|
1785
|
-
console.log("Приложение успешно встроено в",
|
|
1811
|
+
s.length > 0 && await this.placementUnBind(s), Object.keys(c).length > 0 && await this.batch(c), Object.keys(c).length > 0 && (this.placeData = await this.getPlacement(), Object.values(c).forEach((o) => {
|
|
1812
|
+
console.log("Приложение успешно встроено в", o.params.PLACEMENT);
|
|
1786
1813
|
}));
|
|
1787
1814
|
}
|
|
1788
1815
|
/* Отвязка встройки из place */
|
|
@@ -1791,12 +1818,12 @@ class bt {
|
|
|
1791
1818
|
Array.isArray(e) ? r = e.map((A) => typeof A == "string" ? { placement: A } : A) : typeof e == "string" ? r = [{ placement: e }] : r = [e];
|
|
1792
1819
|
const i = {};
|
|
1793
1820
|
for (let A = 0; A < r.length; A++) {
|
|
1794
|
-
const
|
|
1795
|
-
PLACEMENT:
|
|
1821
|
+
const a = r[A], l = a.placement, m = a.handler, c = {
|
|
1822
|
+
PLACEMENT: l
|
|
1796
1823
|
};
|
|
1797
|
-
m && (
|
|
1824
|
+
m && (c.HANDLER = m), i[`unbind_${A}`] = {
|
|
1798
1825
|
method: "placement.unbind",
|
|
1799
|
-
params:
|
|
1826
|
+
params: c
|
|
1800
1827
|
};
|
|
1801
1828
|
}
|
|
1802
1829
|
Object.keys(i).length > 0 && (await this.batch(i), r.forEach((A) => {
|
|
@@ -1811,8 +1838,8 @@ class bt {
|
|
|
1811
1838
|
for (const A of this.placeData) {
|
|
1812
1839
|
if (!A.handler || A.handler.includes(e))
|
|
1813
1840
|
continue;
|
|
1814
|
-
const { placement:
|
|
1815
|
-
r.push({ placement:
|
|
1841
|
+
const { placement: a, handler: l, userId: m } = A;
|
|
1842
|
+
r.push({ placement: a, handler: l }), i.push({ placement: a, userId: m });
|
|
1816
1843
|
}
|
|
1817
1844
|
r.length > 0 && await this.placementUnBind(r), i.length > 0 && await this.placementBind(i, !1);
|
|
1818
1845
|
}
|
|
@@ -1829,7 +1856,7 @@ class bt {
|
|
|
1829
1856
|
}
|
|
1830
1857
|
/* регистрация бота */
|
|
1831
1858
|
regBot({ code: e, type: r, name: i }) {
|
|
1832
|
-
const { appName: A, pathApp:
|
|
1859
|
+
const { appName: A, pathApp: a, chatBotLogo: l } = this.appConst, m = this.appInfo.ID;
|
|
1833
1860
|
return this.call({
|
|
1834
1861
|
method: "imbot.register",
|
|
1835
1862
|
params: {
|
|
@@ -1837,7 +1864,7 @@ class bt {
|
|
|
1837
1864
|
// Строковой идентификатор бота, уникальный в рамках вашего приложения (обяз.)
|
|
1838
1865
|
TYPE: r ?? "O",
|
|
1839
1866
|
// Тип бота, B - чат-бот, ответы поступают сразу, H - человек, ответы поступают с задержкой от 2-х до 10 секунд, O - чат-бот для Открытых линий, S - чат-бот с повышенными привилегиями (supervisor)
|
|
1840
|
-
EVENT_HANDLER:
|
|
1867
|
+
EVENT_HANDLER: a,
|
|
1841
1868
|
// Ссылка на обработчик событий, поступивших от сервера - см. Обработчики событий ниже (обяз).
|
|
1842
1869
|
OPENLINE: "Y",
|
|
1843
1870
|
// Включение режима поддержки Открытых линий, можно не указывать, если TYPE = 'O'
|
|
@@ -1861,11 +1888,11 @@ class bt {
|
|
|
1861
1888
|
// Ссылка на сайт
|
|
1862
1889
|
PERSONAL_GENDER: "M",
|
|
1863
1890
|
// Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
|
|
1864
|
-
PERSONAL_PHOTO:
|
|
1891
|
+
PERSONAL_PHOTO: l ?? ""
|
|
1865
1892
|
// Аватар чат-бота - base64
|
|
1866
1893
|
}
|
|
1867
1894
|
}
|
|
1868
|
-
}).then((
|
|
1895
|
+
}).then((c) => (console.log("Чат-бот добавлен", c), c));
|
|
1869
1896
|
}
|
|
1870
1897
|
/* Убрать регистрацию бота */
|
|
1871
1898
|
unRegBot(e) {
|
|
@@ -1883,27 +1910,27 @@ class bt {
|
|
|
1883
1910
|
}
|
|
1884
1911
|
At = new WeakSet(), Nt = function() {
|
|
1885
1912
|
return this.call({ method: "app.info" });
|
|
1886
|
-
},
|
|
1913
|
+
}, at = new WeakSet(), Ot = function() {
|
|
1887
1914
|
return this.call({ method: "user.current" });
|
|
1888
1915
|
};
|
|
1889
1916
|
class St {
|
|
1890
1917
|
constructor(e) {
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1918
|
+
D(this, "entityName", "tabs");
|
|
1919
|
+
D(this, "maxTabs", 5);
|
|
1920
|
+
D(this, "interval");
|
|
1921
|
+
D(this, "id", 0);
|
|
1922
|
+
D(this, "tabList", []);
|
|
1923
|
+
D(this, "random", this.getRandomNum());
|
|
1924
|
+
D(this, "continueCondition");
|
|
1925
|
+
D(this, "defaultContinueBackground", () => !0);
|
|
1926
|
+
D(this, "activeMaxPause", 60 * 1e3 * 5 + this.random);
|
|
1927
|
+
D(this, "activeMinPause", 60 * 1e3 * 3 + this.random);
|
|
1901
1928
|
if (!e) {
|
|
1902
1929
|
console.error("В бек-воркер не переданы настройки, отмена вызова"), console.log("BackgroundWorker: Отмена конструктора - отсутствуют опции");
|
|
1903
1930
|
return;
|
|
1904
1931
|
}
|
|
1905
|
-
const { appFunc: r, bx: i, users: A, continueBackground:
|
|
1906
|
-
this.bx = i, this.appPath = i.appConst.pathApp ?? "", this.appName = i.appConst.appName ?? "", this.appInit = r, this.users = A, this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof
|
|
1932
|
+
const { appFunc: r, bx: i, users: A, continueBackground: a } = e;
|
|
1933
|
+
this.bx = i, this.appPath = i.appConst.pathApp ?? "", this.appName = i.appConst.appName ?? "", this.appInit = r, this.users = A, this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
1907
1934
|
}
|
|
1908
1935
|
async init() {
|
|
1909
1936
|
if (!this.appInit) {
|
|
@@ -2038,16 +2065,16 @@ class St {
|
|
|
2038
2065
|
e && (await this.pause(Math.round(Number(Math.random().toFixed(2)) * 1e4)), this.tabList = await this.getFilteredTabList(), e = this.checkOtherTabs(), e && await this.startBackground());
|
|
2039
2066
|
}
|
|
2040
2067
|
checkOtherTabs() {
|
|
2041
|
-
var A,
|
|
2068
|
+
var A, a;
|
|
2042
2069
|
let e = !1, r = (/* @__PURE__ */ new Date()).getTime() - new Date(this.start).getTime();
|
|
2043
|
-
for (const
|
|
2044
|
-
if (+
|
|
2070
|
+
for (const l of this.tabList)
|
|
2071
|
+
if (+l.id !== this.id && ((A = l.data) != null && A.start && (e = !0), ((a = l.data) == null ? void 0 : a.duration) > r)) {
|
|
2045
2072
|
r = !1;
|
|
2046
2073
|
break;
|
|
2047
2074
|
}
|
|
2048
2075
|
const i = !e && !!r;
|
|
2049
|
-
return this.updateTab(i).catch((
|
|
2050
|
-
console.error("BackgroundWorker: updateTab failed",
|
|
2076
|
+
return this.updateTab(i).catch((l) => {
|
|
2077
|
+
console.error("BackgroundWorker: updateTab failed", l);
|
|
2051
2078
|
}), console.log(`BackgroundWorker: Проверка вкладок - можно запускать приложение? ${i}`), i;
|
|
2052
2079
|
}
|
|
2053
2080
|
async startBackground() {
|
|
@@ -2058,67 +2085,74 @@ class St {
|
|
|
2058
2085
|
}, this.activeMinPause), await this.appInit(), this.interval && (clearInterval(this.interval), this.interval = void 0), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
2059
2086
|
}
|
|
2060
2087
|
async setBackgroundWorkerAll() {
|
|
2061
|
-
var
|
|
2062
|
-
if (!((
|
|
2088
|
+
var h, o;
|
|
2089
|
+
if (!((h = this.bx) != null && h.isAdmin)) {
|
|
2063
2090
|
console.log("BackgroundWorker: Отмена setBackgroundWorkerAll - пользователь не админ");
|
|
2064
2091
|
return;
|
|
2065
2092
|
}
|
|
2066
|
-
(
|
|
2093
|
+
(o = this.users) != null && o.length || await this.getEntityData();
|
|
2067
2094
|
const e = await this.bx.getPlacement(), r = /* @__PURE__ */ new Map();
|
|
2068
2095
|
let i = null;
|
|
2069
|
-
e.forEach((
|
|
2070
|
-
|
|
2096
|
+
e.forEach((d) => {
|
|
2097
|
+
d.placement === "PAGE_BACKGROUND_WORKER" && (d.userId ? r.set(+d.userId, d) : i = d);
|
|
2071
2098
|
}), console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i ? 1 : 0} общих привязок PAGE_BACKGROUND_WORKER`);
|
|
2072
|
-
const A = await this.
|
|
2073
|
-
|
|
2074
|
-
const y =
|
|
2075
|
-
return (
|
|
2076
|
-
}), console.log(`setBackgroundWorkerAll: Найдено ${
|
|
2077
|
-
const
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
ru: {
|
|
2085
|
-
TITLE: this.appName
|
|
2086
|
-
}
|
|
2087
|
-
},
|
|
2088
|
-
OPTIONS: {
|
|
2089
|
-
errorHandlerUrl: `${this.appPath}/`
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
}), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера"));
|
|
2093
|
-
const m = 10, u = o.slice(0, m), s = [];
|
|
2094
|
-
for (const [a] of r)
|
|
2095
|
-
o.find((y) => +y.ID === a) || s.push(a);
|
|
2096
|
-
for (const a of s)
|
|
2097
|
-
this.appPath && (h.push({
|
|
2099
|
+
const A = await this.updateAdminsList(), a = await this.getEligibleUsersForBackgroundWorker(A);
|
|
2100
|
+
a.sort((d, N) => {
|
|
2101
|
+
const y = d.LAST_LOGIN ? new Date(d.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2102
|
+
return (N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - y;
|
|
2103
|
+
}), console.log(`setBackgroundWorkerAll: Найдено ${a.length} подходящих пользователей (админы и руководители)`);
|
|
2104
|
+
const l = [], m = 10, s = a.slice(0, m).filter(
|
|
2105
|
+
(d) => !r.has(+d.ID)
|
|
2106
|
+
), g = i && s.length > 0, _ = [];
|
|
2107
|
+
for (const [d] of r)
|
|
2108
|
+
a.find((y) => +y.ID === d) || _.push(d);
|
|
2109
|
+
for (const d of _)
|
|
2110
|
+
this.appPath && (l.push({
|
|
2098
2111
|
method: "placement.unbind",
|
|
2099
2112
|
params: {
|
|
2100
2113
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2101
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2114
|
+
HANDLER: `${this.appPath}?USER_ID=${d}/`
|
|
2102
2115
|
}
|
|
2103
|
-
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${
|
|
2104
|
-
|
|
2105
|
-
|
|
2116
|
+
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${d}`));
|
|
2117
|
+
g && this.appPath && (l.push({
|
|
2118
|
+
method: "placement.unbind",
|
|
2119
|
+
params: {
|
|
2120
|
+
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2121
|
+
HANDLER: i.handler || `${this.appPath}/`
|
|
2122
|
+
}
|
|
2123
|
+
}), console.log("setBackgroundWorkerAll: Добавлена в очередь отвязка общего бэк-воркера (для создания индивидуальных)"));
|
|
2124
|
+
for (const d of s)
|
|
2125
|
+
this.appPath && l.push({
|
|
2106
2126
|
method: "placement.bind",
|
|
2107
2127
|
params: {
|
|
2108
2128
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2109
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2129
|
+
HANDLER: `${this.appPath}?USER_ID=${d.ID}/`,
|
|
2110
2130
|
LANG_ALL: {
|
|
2111
2131
|
ru: {
|
|
2112
2132
|
TITLE: this.appName
|
|
2113
2133
|
}
|
|
2114
2134
|
},
|
|
2115
2135
|
OPTIONS: {
|
|
2116
|
-
errorHandlerUrl: `${this.appPath}?USER_ID=${
|
|
2136
|
+
errorHandlerUrl: `${this.appPath}?USER_ID=${d.ID}/`
|
|
2117
2137
|
},
|
|
2118
|
-
USER_ID:
|
|
2138
|
+
USER_ID: d.ID
|
|
2119
2139
|
}
|
|
2120
2140
|
});
|
|
2121
|
-
|
|
2141
|
+
(!i || g) && this.appPath && (l.push({
|
|
2142
|
+
method: "placement.bind",
|
|
2143
|
+
params: {
|
|
2144
|
+
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2145
|
+
HANDLER: `${this.appPath}/`,
|
|
2146
|
+
LANG_ALL: {
|
|
2147
|
+
ru: {
|
|
2148
|
+
TITLE: this.appName
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
OPTIONS: {
|
|
2152
|
+
errorHandlerUrl: `${this.appPath}/`
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера (после индивидуальных)")), l.length ? (console.log(`setBackgroundWorkerAll: Выполняем ${l.length} операций через batch`), await this.bx.batch(l), console.log("setBackgroundWorkerAll: Все операции batch выполнены успешно")) : console.log("setBackgroundWorkerAll: Нет операций для выполнения");
|
|
2122
2156
|
}
|
|
2123
2157
|
async getEligibleUsersForBackgroundWorker(e = []) {
|
|
2124
2158
|
return (this.users ?? []).filter((i) => i.ACTIVE === "Y" || i.ACTIVE === !0).filter((i) => {
|
|
@@ -2129,20 +2163,13 @@ class St {
|
|
|
2129
2163
|
async updateAdminsList() {
|
|
2130
2164
|
var e, r, i;
|
|
2131
2165
|
try {
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
}
|
|
2140
|
-
const h = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2141
|
-
(r = this.bx) != null && r.isAdmin && h && !o.includes(h) && (o.push(h), console.log(`updateAdminsList: Добавлен новый админ ${h}`)), !((i = this.bx) != null && i.isAdmin) && h && o.includes(h) && (o = o.filter((s) => s !== h), console.log(`updateAdminsList: Удален из списка админов пользователь ${h} (больше не админ)`));
|
|
2142
|
-
const m = new Set(
|
|
2143
|
-
(this.users ?? []).filter((s) => s.ACTIVE === "Y" || s.ACTIVE === !0).map((s) => +s.ID)
|
|
2144
|
-
), u = o.filter((s) => m.has(s));
|
|
2145
|
-
return u.length !== o.length && (console.log(`updateAdminsList: Удалено ${o.length - u.length} неактивных админов`), o = u), BX24.appOption.set("adminsList", JSON.stringify(o)), console.log(`BackgroundWorker: Список админов обновлен: ${o.length} админов`), o;
|
|
2166
|
+
let A = await this.getAdminsList();
|
|
2167
|
+
const a = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2168
|
+
(r = this.bx) != null && r.isAdmin && a && !A.includes(a) && (A.push(a), console.log(`updateAdminsList: Добавлен новый админ ${a}`)), !((i = this.bx) != null && i.isAdmin) && a && A.includes(a) && (A = A.filter((c) => c !== a), console.log(`updateAdminsList: Удален из списка админов пользователь ${a} (больше не админ)`));
|
|
2169
|
+
const l = new Set(
|
|
2170
|
+
(this.users ?? []).filter((c) => c.ACTIVE === "Y" || c.ACTIVE === !0).map((c) => +c.ID)
|
|
2171
|
+
), m = A.filter((c) => l.has(c));
|
|
2172
|
+
return m.length !== A.length && (console.log(`updateAdminsList: Удалено ${A.length - m.length} неактивных админов`), A = m), BX24.appOption.set("adminsList", JSON.stringify(A)), console.log(`BackgroundWorker: Список админов обновлен: ${A.length} админов`), A;
|
|
2146
2173
|
} catch (A) {
|
|
2147
2174
|
return console.error("BackgroundWorker: Ошибка при обновлении списка админов:", A), [];
|
|
2148
2175
|
}
|
|
@@ -2171,7 +2198,7 @@ class St {
|
|
|
2171
2198
|
}
|
|
2172
2199
|
export {
|
|
2173
2200
|
St as BackgroundWorker,
|
|
2174
|
-
|
|
2201
|
+
v as Batch,
|
|
2175
2202
|
bt as BxBoot,
|
|
2176
2203
|
ut as BxHelper,
|
|
2177
2204
|
Rt as BxLogger,
|