szdl-utils-kit 0.3.24 → 0.3.25
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 -5
- package/dist/index.js +827 -815
- package/dist/index.umd.cjs +2 -2
- package/dist/types/batch.d.ts +3 -1
- 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 Ie = Object.defineProperty;
|
|
2
|
+
var De = (m, e, t) => e in m ? Ie(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t;
|
|
3
|
+
var w = (m, e, t) => (De(m, typeof e != "symbol" ? e + "" : e, t), t), zt = (m, e, t) => {
|
|
4
|
+
if (!e.has(m))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (e.has(
|
|
7
|
+
var L = (m, e, t) => (zt(m, e, "read from private field"), t ? t.call(m) : e.get(m)), E = (m, e, t) => {
|
|
8
|
+
if (e.has(m))
|
|
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(m) : e.set(m, t);
|
|
11
|
+
}, x = (m, e, t, r) => (zt(m, e, "write to private field"), r ? r.call(m, t) : e.set(m, t), t);
|
|
12
|
+
var y = (m, e, t) => (zt(m, e, "access private method"), t);
|
|
13
|
+
var ke = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
+
function we(m) {
|
|
15
|
+
return m && m.__esModule && Object.prototype.hasOwnProperty.call(m, "default") ? m.default : m;
|
|
16
16
|
}
|
|
17
|
-
var
|
|
18
|
-
(function(
|
|
17
|
+
var Vt = { exports: {} };
|
|
18
|
+
(function(m, e) {
|
|
19
19
|
(function(t) {
|
|
20
|
-
Array.prototype.indexOf || (Array.prototype.indexOf = function(
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
20
|
+
Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
|
|
21
|
+
var g, p;
|
|
22
|
+
for (g = o || 0, p = this.length; g < p; g += 1)
|
|
23
|
+
if (this[g] === s)
|
|
24
|
+
return g;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
|
-
var
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
}, a = function(
|
|
32
|
-
return o !== t ? (
|
|
33
|
-
}, c = function(
|
|
34
|
-
var
|
|
35
|
-
return
|
|
36
|
-
}, h = function(
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(p[0])) && !isNaN(Number(p[2])) && !isNaN(Number(p[4])) ? (p[1] === "." && p[3] === "." ?
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
}, f =
|
|
27
|
+
var r = this, i = function(s, o) {
|
|
28
|
+
for (var g = s.toString(); g.length < o; )
|
|
29
|
+
g = "0" + g;
|
|
30
|
+
return g;
|
|
31
|
+
}, a = function(s, o) {
|
|
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
|
+
}, c = function(s, o) {
|
|
34
|
+
var g, p = "";
|
|
35
|
+
return g = s.slice(o, o + 1), g !== "" && !isNaN(Number(g)) && (p += "%H"), g = s.charAt(o + 2), g !== "" && g === ":" && (p += g), g = s.slice(o + 3, o + 4), g !== "" && !isNaN(Number(g)) && (p += "%M"), g = s.charAt(o + 5), g !== "" && g === ":" && (p += g), g = s.slice(o + 6, o + 7), g !== "" && !isNaN(Number(g)) && (p += "%S"), p;
|
|
36
|
+
}, h = function(s, o) {
|
|
37
|
+
var g, p = [
|
|
38
|
+
s.slice(o, o + 1),
|
|
39
|
+
s.charAt(o + 2),
|
|
40
|
+
s.slice(o + 3, o + 4),
|
|
41
|
+
s.charAt(o + 5),
|
|
42
|
+
s.slice(o + 6, o + 9)
|
|
43
|
+
], H;
|
|
44
|
+
return !isNaN(Number(p[0])) && !isNaN(Number(p[2])) && !isNaN(Number(p[4])) ? (p[1] === "." && p[3] === "." ? g = "%d.%m.%Y" : p[1] === "-" && p[3] === "-" ? g = "%m-%d-%Y" : p[1] === "/" && p[3] === "/" && (g = "%m/%d/%Y"), g) : (H = [
|
|
45
|
+
s.slice(o, o + 3),
|
|
46
|
+
s.charAt(o + 4),
|
|
47
|
+
s.slice(o + 5, o + 6),
|
|
48
|
+
s.charAt(o + 7),
|
|
49
|
+
s.slice(o + 8, o + 9)
|
|
50
|
+
], !isNaN(Number(H[0])) && !isNaN(Number(H[2])) && !isNaN(Number(H[4])) ? (H[1] === "-" && H[3] === "-" && (g = "%Y-%m-%d"), g) : "");
|
|
51
|
+
}, f = r.tempus, n, u, d = r.navigator || {}, A = "en", l = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,7 +209,7 @@ var qt = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, O = function() {
|
|
213
213
|
return [
|
|
214
214
|
l[A].JANUARY_LONG,
|
|
215
215
|
l[A].FEBRUARY_LONG,
|
|
@@ -224,7 +224,7 @@ var qt = { exports: {} };
|
|
|
224
224
|
l[A].NOVEMBER_LONG,
|
|
225
225
|
l[A].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
|
-
},
|
|
227
|
+
}, _ = function() {
|
|
228
228
|
return [
|
|
229
229
|
l[A].JANUARY_SHORT,
|
|
230
230
|
l[A].FEBRUARY_SHORT,
|
|
@@ -239,7 +239,7 @@ var qt = { exports: {} };
|
|
|
239
239
|
l[A].NOVEMBER_SHORT,
|
|
240
240
|
l[A].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, b = function() {
|
|
243
243
|
return [
|
|
244
244
|
l[A].SUNDAY_LONG,
|
|
245
245
|
l[A].MONDAY_LONG,
|
|
@@ -249,7 +249,7 @@ var qt = { exports: {} };
|
|
|
249
249
|
l[A].FRIDAY_LONG,
|
|
250
250
|
l[A].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, k = function() {
|
|
253
253
|
return [
|
|
254
254
|
l[A].SUNDAY_SHORT,
|
|
255
255
|
l[A].MONDAY_SHORT,
|
|
@@ -259,19 +259,19 @@ var qt = { exports: {} };
|
|
|
259
259
|
l[A].FRIDAY_SHORT,
|
|
260
260
|
l[A].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
},
|
|
262
|
+
}, T, M, G, N, S = function(s, o, g) {
|
|
263
263
|
var p;
|
|
264
|
-
|
|
265
|
-
p.readyState === 4 && (p.status === 200 ? o && (
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(p.responseText))) :
|
|
267
|
-
}, p.open("GET",
|
|
268
|
-
},
|
|
264
|
+
r.XMLHttpRequest ? p = new XMLHttpRequest() : p = new ActiveXObject("Microsoft.XMLHTTP"), p.onreadystatechange = function() {
|
|
265
|
+
p.readyState === 4 && (p.status === 200 ? o && (r.JSON === t ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(p.responseText))) : g && g(p));
|
|
267
|
+
}, p.open("GET", s, !1), p.send();
|
|
268
|
+
}, I = {
|
|
269
269
|
"%d": {
|
|
270
|
-
format: function(
|
|
271
|
-
return i(
|
|
270
|
+
format: function(s) {
|
|
271
|
+
return i(s.day() || n.MIN_DAY, 2);
|
|
272
272
|
},
|
|
273
|
-
parse: function(
|
|
274
|
-
var o = Number(
|
|
273
|
+
parse: function(s) {
|
|
274
|
+
var o = Number(s);
|
|
275
275
|
return { day: isNaN(o) ? t : o };
|
|
276
276
|
},
|
|
277
277
|
minLength: 2,
|
|
@@ -279,11 +279,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
279
279
|
type: "number"
|
|
280
280
|
},
|
|
281
281
|
"%m": {
|
|
282
|
-
format: function(
|
|
283
|
-
return i(
|
|
282
|
+
format: function(s) {
|
|
283
|
+
return i(s.month() || n.MIN_MONTH, 2);
|
|
284
284
|
},
|
|
285
|
-
parse: function(
|
|
286
|
-
var o = Number(
|
|
285
|
+
parse: function(s) {
|
|
286
|
+
var o = Number(s);
|
|
287
287
|
return { month: isNaN(o) ? t : o };
|
|
288
288
|
},
|
|
289
289
|
minLength: 2,
|
|
@@ -291,11 +291,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
291
291
|
type: "number"
|
|
292
292
|
},
|
|
293
293
|
"%Y": {
|
|
294
|
-
format: function(
|
|
295
|
-
return i(
|
|
294
|
+
format: function(s) {
|
|
295
|
+
return i(s.year() || n.MIN_YEAR, 4);
|
|
296
296
|
},
|
|
297
|
-
parse: function(
|
|
298
|
-
var o = Number(
|
|
297
|
+
parse: function(s) {
|
|
298
|
+
var o = Number(s);
|
|
299
299
|
return { year: isNaN(o) ? t : o };
|
|
300
300
|
},
|
|
301
301
|
minLength: 4,
|
|
@@ -303,8 +303,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
303
303
|
type: "number"
|
|
304
304
|
},
|
|
305
305
|
"%w": {
|
|
306
|
-
format: function(
|
|
307
|
-
return
|
|
306
|
+
format: function(s) {
|
|
307
|
+
return s.dayOfWeek() || n.MIN_DAY_OF_WEEK;
|
|
308
308
|
},
|
|
309
309
|
parse: function() {
|
|
310
310
|
return {};
|
|
@@ -314,9 +314,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
314
314
|
type: "number"
|
|
315
315
|
},
|
|
316
316
|
"%a": {
|
|
317
|
-
format: function(
|
|
318
|
-
var o =
|
|
319
|
-
return
|
|
317
|
+
format: function(s) {
|
|
318
|
+
var o = s.dayOfWeek();
|
|
319
|
+
return N[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
return {};
|
|
@@ -326,9 +326,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
326
326
|
type: "word"
|
|
327
327
|
},
|
|
328
328
|
"%A": {
|
|
329
|
-
format: function(
|
|
330
|
-
var o =
|
|
331
|
-
return
|
|
329
|
+
format: function(s) {
|
|
330
|
+
var o = s.dayOfWeek();
|
|
331
|
+
return G[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
334
334
|
return {};
|
|
@@ -338,12 +338,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
338
338
|
type: "word"
|
|
339
339
|
},
|
|
340
340
|
"%b": {
|
|
341
|
-
format: function(
|
|
342
|
-
var o = n.options("monthFromZero") ?
|
|
343
|
-
return
|
|
341
|
+
format: function(s) {
|
|
342
|
+
var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
|
|
343
|
+
return M[o !== t ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
|
-
parse: function(
|
|
346
|
-
var o = n.monthNames().indexOf(
|
|
345
|
+
parse: function(s) {
|
|
346
|
+
var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
347
347
|
return { month: o !== -1 ? o : t };
|
|
348
348
|
},
|
|
349
349
|
minLength: 1,
|
|
@@ -351,12 +351,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
351
351
|
type: "word"
|
|
352
352
|
},
|
|
353
353
|
"%B": {
|
|
354
|
-
format: function(
|
|
355
|
-
var o = n.options("monthFromZero") ?
|
|
356
|
-
return
|
|
354
|
+
format: function(s) {
|
|
355
|
+
var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
|
|
356
|
+
return T[o !== t ? o : n.MIN_MONTH];
|
|
357
357
|
},
|
|
358
|
-
parse: function(
|
|
359
|
-
var o = n.monthNames(!0).indexOf(
|
|
358
|
+
parse: function(s) {
|
|
359
|
+
var o = n.monthNames(!0).indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
|
|
360
360
|
return { month: o !== -1 ? o : t };
|
|
361
361
|
},
|
|
362
362
|
minLength: 1,
|
|
@@ -364,11 +364,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
364
364
|
type: "word"
|
|
365
365
|
},
|
|
366
366
|
"%H": {
|
|
367
|
-
format: function(
|
|
368
|
-
return i(
|
|
367
|
+
format: function(s) {
|
|
368
|
+
return i(s.hours() || n.MIN_HOURS, 2);
|
|
369
369
|
},
|
|
370
|
-
parse: function(
|
|
371
|
-
var o = Number(
|
|
370
|
+
parse: function(s) {
|
|
371
|
+
var o = Number(s);
|
|
372
372
|
return { hours: isNaN(o) ? t : o };
|
|
373
373
|
},
|
|
374
374
|
minLength: 2,
|
|
@@ -376,11 +376,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
376
376
|
type: "number"
|
|
377
377
|
},
|
|
378
378
|
"%M": {
|
|
379
|
-
format: function(
|
|
380
|
-
return i(
|
|
379
|
+
format: function(s) {
|
|
380
|
+
return i(s.minutes() || n.MIN_MINUTES, 2);
|
|
381
381
|
},
|
|
382
|
-
parse: function(
|
|
383
|
-
var o = Number(
|
|
382
|
+
parse: function(s) {
|
|
383
|
+
var o = Number(s);
|
|
384
384
|
return { minutes: isNaN(o) ? t : o };
|
|
385
385
|
},
|
|
386
386
|
minLength: 2,
|
|
@@ -388,11 +388,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
388
388
|
type: "number"
|
|
389
389
|
},
|
|
390
390
|
"%S": {
|
|
391
|
-
format: function(
|
|
392
|
-
return i(
|
|
391
|
+
format: function(s) {
|
|
392
|
+
return i(s.seconds() || n.MIN_SECONDS, 2);
|
|
393
393
|
},
|
|
394
|
-
parse: function(
|
|
395
|
-
var o = Number(
|
|
394
|
+
parse: function(s) {
|
|
395
|
+
var o = Number(s);
|
|
396
396
|
return { seconds: isNaN(o) ? t : o };
|
|
397
397
|
},
|
|
398
398
|
minLength: 2,
|
|
@@ -400,25 +400,25 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
400
400
|
type: "number"
|
|
401
401
|
},
|
|
402
402
|
"%s": {
|
|
403
|
-
format: function(
|
|
404
|
-
return
|
|
403
|
+
format: function(s) {
|
|
404
|
+
return s.timestamp();
|
|
405
405
|
},
|
|
406
|
-
parse: function(
|
|
407
|
-
return isNaN(Number(
|
|
406
|
+
parse: function(s) {
|
|
407
|
+
return isNaN(Number(s)) ? {} : n(Number(s)).get();
|
|
408
408
|
},
|
|
409
409
|
minLength: 1,
|
|
410
410
|
maxLength: 20,
|
|
411
411
|
type: "number"
|
|
412
412
|
},
|
|
413
413
|
"%F": {
|
|
414
|
-
format: function(
|
|
415
|
-
return i(
|
|
414
|
+
format: function(s) {
|
|
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
|
-
parse: function(
|
|
418
|
-
var o = Number(
|
|
417
|
+
parse: function(s) {
|
|
418
|
+
var o = Number(s.slice(0, 4)), g = Number(s.slice(5, 7)), p = Number(s.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: o,
|
|
421
|
-
month:
|
|
421
|
+
month: g,
|
|
422
422
|
day: p
|
|
423
423
|
};
|
|
424
424
|
},
|
|
@@ -427,26 +427,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
427
427
|
type: "string"
|
|
428
428
|
},
|
|
429
429
|
"%D": {
|
|
430
|
-
format: function(
|
|
431
|
-
return i(
|
|
430
|
+
format: function(s) {
|
|
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
|
-
parse: function(
|
|
434
|
-
var o = Number(
|
|
433
|
+
parse: function(s) {
|
|
434
|
+
var o = Number(s.slice(0, 2)), g = Number(s.slice(3, 5)), p = Number(s.slice(6, 10));
|
|
435
435
|
return {
|
|
436
436
|
year: p,
|
|
437
437
|
month: o,
|
|
438
|
-
day:
|
|
438
|
+
day: g
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
442
442
|
maxLength: 10,
|
|
443
443
|
type: "string"
|
|
444
444
|
}
|
|
445
|
-
},
|
|
445
|
+
}, C = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, R;
|
|
449
|
+
R = function(s, o, g) {
|
|
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
|
-
},
|
|
459
|
-
},
|
|
460
|
-
var
|
|
461
|
-
return this.leapYear() &&
|
|
462
|
-
},
|
|
458
|
+
}, s !== t && this.set(s, o, g), this;
|
|
459
|
+
}, R.fn = R.prototype, R.fn.dayCount = function() {
|
|
460
|
+
var s = this.month(), o = n.MAX_DAY_IN_MONTHS[s - (n.options("monthFromZero") ? 0 : 1)];
|
|
461
|
+
return this.leapYear() && s === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
|
|
462
|
+
}, R.fn.year = function(s) {
|
|
463
463
|
if (arguments.length !== 0)
|
|
464
|
-
(typeof
|
|
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
|
+
}, R.fn.month = function(s) {
|
|
469
469
|
if (arguments.length !== 0)
|
|
470
|
-
(typeof
|
|
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
|
+
}, R.fn.day = function(s) {
|
|
475
475
|
if (arguments.length !== 0)
|
|
476
|
-
(typeof
|
|
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
|
+
}, R.fn.hours = function(s) {
|
|
481
481
|
if (arguments.length !== 0)
|
|
482
|
-
(typeof
|
|
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
|
+
}, R.fn.minutes = function(s) {
|
|
487
487
|
if (arguments.length !== 0)
|
|
488
|
-
(typeof
|
|
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
|
+
}, R.fn.seconds = function(s) {
|
|
493
493
|
if (arguments.length !== 0)
|
|
494
|
-
(typeof
|
|
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
|
+
}, R.fn.milliseconds = function(s) {
|
|
499
499
|
if (arguments.length !== 0)
|
|
500
|
-
(typeof
|
|
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
|
-
},
|
|
505
|
-
var
|
|
506
|
-
return Math.ceil(((o -
|
|
507
|
-
},
|
|
504
|
+
}, R.fn.week = function() {
|
|
505
|
+
var s = new Date(this.year(), 0, 1), o = n(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
|
|
506
|
+
return Math.ceil(((o - s.getTime()) / 864e5 + s.getDay() + 1) / 7);
|
|
507
|
+
}, R.fn.set = function(s, o, g) {
|
|
508
508
|
if (this._i = {
|
|
509
509
|
year: !1,
|
|
510
510
|
month: !1,
|
|
@@ -513,16 +513,16 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
513
513
|
minutes: !1,
|
|
514
514
|
seconds: !1,
|
|
515
515
|
milliseconds: !1
|
|
516
|
-
},
|
|
516
|
+
}, s === t)
|
|
517
517
|
return this._d = /* @__PURE__ */ new Date(), this;
|
|
518
|
-
if (
|
|
519
|
-
return this._d =
|
|
520
|
-
if (typeof
|
|
521
|
-
return this._d = new Date(
|
|
522
|
-
if (typeof
|
|
523
|
-
var p,
|
|
524
|
-
if (
|
|
525
|
-
return D = a(this,
|
|
518
|
+
if (s instanceof Date)
|
|
519
|
+
return this._d = s, this;
|
|
520
|
+
if (typeof s == "number")
|
|
521
|
+
return this._d = new Date(s * (n.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
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 p, H = [], D, B, Q = [], W = 0, F = 0, U, X, P = {}, Y;
|
|
524
|
+
if (s === t)
|
|
525
|
+
return D = a(this, g), D === t && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -531,25 +531,25 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
531
531
|
seconds: -1,
|
|
532
532
|
milliseconds: -1
|
|
533
533
|
}), D;
|
|
534
|
-
for (o === t && (o = n.detectFormat(
|
|
534
|
+
for (o === t && (o = n.detectFormat(s)); W < o.length; ) {
|
|
535
535
|
if (o.charAt(W) === "%") {
|
|
536
|
-
if (
|
|
537
|
-
switch (
|
|
536
|
+
if (B = o.charAt(W) + o.charAt(W + 1), I[B] !== t) {
|
|
537
|
+
switch (U = 0, X = "", I[B].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (;
|
|
540
|
-
X +=
|
|
539
|
+
for (; U < I[B].maxLength && F + U < s.length && !isNaN(Number(s.charAt(F + U))); )
|
|
540
|
+
X += s.charAt(F + U), U += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (;
|
|
544
|
-
X +=
|
|
543
|
+
for (; U < I[B].maxLength && F + U < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + U)); )
|
|
544
|
+
X += s.charAt(F + U), U += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (;
|
|
548
|
-
X +=
|
|
547
|
+
for (; U < I[B].maxLength && F + U < s.length; )
|
|
548
|
+
X += s.charAt(F + U), U += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (
|
|
552
|
-
return D = a(this,
|
|
551
|
+
if (U < I[B].minLength)
|
|
552
|
+
return D = a(this, g), 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
|
-
|
|
561
|
+
H.push(B), Q.push(X), U -= 1, F += U, W += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (
|
|
564
|
-
return D = a(this,
|
|
563
|
+
} else if (s.charAt(F) !== o.charAt(W))
|
|
564
|
+
return D = a(this, g), D === t && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -572,48 +572,48 @@ 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 (p in
|
|
576
|
-
|
|
577
|
-
year: Y.year !== t ? Y.year :
|
|
578
|
-
month: Y.month !== t ? Y.month :
|
|
579
|
-
day: Y.day !== t ? Y.day :
|
|
580
|
-
hours: Y.hours !== t ? Y.hours :
|
|
581
|
-
minutes: Y.minutes !== t ? Y.minutes :
|
|
582
|
-
seconds: Y.seconds !== t ? Y.seconds :
|
|
575
|
+
for (p in H)
|
|
576
|
+
H.hasOwnProperty(p) && I.hasOwnProperty(H[p]) && (Y = I[H[p]].parse(Q[p]), P = {
|
|
577
|
+
year: Y.year !== t ? Y.year : P.year,
|
|
578
|
+
month: Y.month !== t ? Y.month : P.month,
|
|
579
|
+
day: Y.day !== t ? Y.day : P.day,
|
|
580
|
+
hours: Y.hours !== t ? Y.hours : P.hours,
|
|
581
|
+
minutes: Y.minutes !== t ? Y.minutes : P.minutes,
|
|
582
|
+
seconds: Y.seconds !== t ? Y.seconds : P.seconds
|
|
583
583
|
});
|
|
584
|
-
this.day(n.MIN_DAY), this.year(
|
|
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
|
-
},
|
|
588
|
-
var
|
|
589
|
-
return
|
|
590
|
-
},
|
|
591
|
-
return arguments.length !== 0 ? (this._d = new Date(Number(
|
|
592
|
-
},
|
|
593
|
-
return arguments.length !== 0 ? (this._d = new Date(Number(
|
|
594
|
-
},
|
|
595
|
-
if (
|
|
596
|
-
return
|
|
597
|
-
if (
|
|
598
|
-
return
|
|
599
|
-
if (
|
|
587
|
+
}, R.fn.leapYear = function() {
|
|
588
|
+
var s = this.year();
|
|
589
|
+
return s % 4 === 0 ? s % 100 === 0 ? s % 400 === 0 : !0 : !1;
|
|
590
|
+
}, R.fn.timestamp = function(s) {
|
|
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
|
+
}, R.fn.utc = function(s) {
|
|
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
|
+
}, R.fn.dayOfWeek = function(s) {
|
|
595
|
+
if (s === "long")
|
|
596
|
+
return G[this._d.getDay()];
|
|
597
|
+
if (s === "short")
|
|
598
|
+
return N[this._d.getDay()];
|
|
599
|
+
if (s === t)
|
|
600
600
|
return this._d.getDay();
|
|
601
|
-
if (
|
|
601
|
+
if (s === 0 || s === "Sunday")
|
|
602
602
|
return this.calc({ day: -this.dayOfWeek() });
|
|
603
|
-
if (
|
|
603
|
+
if (s === 1 || s === "Monday")
|
|
604
604
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -6 : 1) - this.dayOfWeek() });
|
|
605
|
-
if (
|
|
605
|
+
if (s === 2 || s === "Tuesday")
|
|
606
606
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -5 : 2) - this.dayOfWeek() });
|
|
607
|
-
if (
|
|
607
|
+
if (s === 3 || s === "Wednesday")
|
|
608
608
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -4 : 3) - this.dayOfWeek() });
|
|
609
|
-
if (
|
|
609
|
+
if (s === 4 || s === "Thursday")
|
|
610
610
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -3 : 4) - this.dayOfWeek() });
|
|
611
|
-
if (
|
|
611
|
+
if (s === 5 || s === "Friday")
|
|
612
612
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
|
|
613
|
-
if (
|
|
613
|
+
if (s === 6 || s === "Saturday")
|
|
614
614
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
|
|
615
|
-
},
|
|
616
|
-
switch (
|
|
615
|
+
}, R.fn.timezone = function(s) {
|
|
616
|
+
switch (s) {
|
|
617
617
|
case "hours":
|
|
618
618
|
return Math.floor(this._d.getTimezoneOffset() / 60);
|
|
619
619
|
case "minutes":
|
|
@@ -621,8 +621,8 @@ 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
|
-
},
|
|
625
|
-
switch (
|
|
624
|
+
}, R.fn.get = function(s) {
|
|
625
|
+
switch (s) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
628
628
|
this.year(),
|
|
@@ -670,73 +670,73 @@ 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
|
-
|
|
676
|
-
return
|
|
677
|
-
},
|
|
673
|
+
}, R.fn.format = function(s) {
|
|
674
|
+
for (var o = 0, g = "", p; o < s.length; )
|
|
675
|
+
s.charAt(o) === "%" ? (p = s.charAt(o) + s.charAt(o + 1), I[p] !== t ? (g += I[p].format(this), o += 1) : g += "%") : g += s.charAt(o), o += 1;
|
|
676
|
+
return g;
|
|
677
|
+
}, R.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
|
+
}, R.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var
|
|
681
|
+
}, R.fn.between = function(s, o) {
|
|
682
|
+
var g = this.timestamp(), p = s.timestamp();
|
|
683
683
|
switch (o) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((p -
|
|
685
|
+
return Math.floor((p - g) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((p -
|
|
687
|
+
return Math.floor((p - g) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((p -
|
|
689
|
+
return Math.floor((p - g) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((p -
|
|
691
|
+
return Math.floor((p - g) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((p -
|
|
693
|
+
return Math.floor((p - g) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return p -
|
|
695
|
+
return p - g;
|
|
696
696
|
default:
|
|
697
697
|
return t;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
700
|
-
return
|
|
701
|
-
}, n = function(
|
|
702
|
-
return new
|
|
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(
|
|
704
|
-
if (
|
|
705
|
-
return
|
|
706
|
-
if (
|
|
699
|
+
}, R.fn.calc = function(s) {
|
|
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, g) {
|
|
702
|
+
return new R(s, o, g);
|
|
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
|
+
if (s === t)
|
|
705
|
+
return C;
|
|
706
|
+
if (C.hasOwnProperty(s)) {
|
|
707
707
|
if (o === t)
|
|
708
|
-
return
|
|
709
|
-
|
|
708
|
+
return C[s];
|
|
709
|
+
C[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
|
|
714
|
-
}, n.generate = function(
|
|
715
|
-
var o,
|
|
716
|
-
if (typeof
|
|
713
|
+
return r.tempus = f, n;
|
|
714
|
+
}, n.generate = function(s) {
|
|
715
|
+
var o, g, p, H, D, B, Q, W;
|
|
716
|
+
if (typeof s.dateFrom != "number" && (s.dateFrom instanceof R ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof R ? g = s.dateTo.utc() : g = 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,
|
|
720
720
|
hours: 0,
|
|
721
721
|
minutes: 0,
|
|
722
|
-
seconds:
|
|
723
|
-
} : typeof
|
|
724
|
-
year:
|
|
725
|
-
month:
|
|
726
|
-
day:
|
|
727
|
-
hours:
|
|
728
|
-
minutes:
|
|
729
|
-
seconds:
|
|
730
|
-
} : typeof
|
|
731
|
-
year:
|
|
732
|
-
month:
|
|
733
|
-
day:
|
|
734
|
-
hours:
|
|
735
|
-
minutes:
|
|
736
|
-
seconds:
|
|
737
|
-
}),
|
|
738
|
-
return
|
|
739
|
-
},
|
|
722
|
+
seconds: s.period
|
|
723
|
+
} : typeof s.period == "string" ? D = {
|
|
724
|
+
year: s.period === "year" ? 1 : 0,
|
|
725
|
+
month: s.period === "month" ? 1 : 0,
|
|
726
|
+
day: s.period === "day" ? 1 : 0,
|
|
727
|
+
hours: s.period === "hours" ? 1 : 0,
|
|
728
|
+
minutes: s.period === "minutes" ? 1 : 0,
|
|
729
|
+
seconds: s.period === "seconds" ? 1 : 0
|
|
730
|
+
} : typeof s.period == "object" && (D = {
|
|
731
|
+
year: s.period.year !== t ? s.period.year : 0,
|
|
732
|
+
month: s.period.month !== t ? s.period.month : 0,
|
|
733
|
+
day: s.period.day !== t ? s.period.day : 0,
|
|
734
|
+
hours: s.period.hours !== t ? s.period.hours : 0,
|
|
735
|
+
minutes: s.period.minutes !== t ? s.period.minutes : 0,
|
|
736
|
+
seconds: s.period.seconds !== t ? s.period.seconds : 0
|
|
737
|
+
}), s.groupBy === t ? B = s.asObject === !0 ? {} : [] : (B = [], B.push([]), Q = n(o).get()[s.groupBy]), W = function(X, P, Y) {
|
|
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
|
+
}, s.groupBy !== t && s.fillNulls) {
|
|
740
740
|
var F = {
|
|
741
741
|
year: D.year ? -D.year : t,
|
|
742
742
|
month: D.month ? -D.month : t,
|
|
@@ -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 (p = n(o).calc(F).utc(); n(p).get()[
|
|
750
|
-
W(
|
|
751
|
-
if (
|
|
752
|
-
var
|
|
753
|
-
for (p = n(o).dayOfWeek(0).utc();
|
|
754
|
-
W(
|
|
749
|
+
for (p = n(o).calc(F).utc(); n(p).get()[s.groupBy] === Q; )
|
|
750
|
+
W(B[B.length - 1], p, !0), p = n(p).calc(F).utc();
|
|
751
|
+
if (s.groupBy === "week") {
|
|
752
|
+
var U = n(o).dayOfWeek();
|
|
753
|
+
for (p = n(o).dayOfWeek(0).utc(); B[0].length < U && p < o; )
|
|
754
|
+
W(B[B.length - 1], p, !0), p = n(p).calc(D).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; o <=
|
|
758
|
-
|
|
759
|
-
if (
|
|
760
|
-
for (
|
|
761
|
-
W(
|
|
762
|
-
return
|
|
763
|
-
}, n.monthNames = function(
|
|
764
|
-
switch (
|
|
757
|
+
for (; o <= g; )
|
|
758
|
+
s.groupBy === t ? W(B, o) : n(o).get()[s.groupBy] === Q ? W(B[B.length - 1], o) : (B.push([]), W(B[B.length - 1], o), Q = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
|
|
759
|
+
if (s.groupBy !== t && s.fillNulls)
|
|
760
|
+
for (H = n(g).calc(D).utc(); n(H).get()[s.groupBy] === Q; )
|
|
761
|
+
W(B[B.length - 1], H, !0), H = n(H).calc(D).utc();
|
|
762
|
+
return B;
|
|
763
|
+
}, n.monthNames = function(s) {
|
|
764
|
+
switch (s) {
|
|
765
765
|
case "long":
|
|
766
|
-
return
|
|
766
|
+
return T;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return M;
|
|
769
769
|
}
|
|
770
|
-
}, n.dayNames = function(
|
|
771
|
-
switch (
|
|
770
|
+
}, n.dayNames = function(s) {
|
|
771
|
+
switch (s) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return G;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return N;
|
|
776
776
|
}
|
|
777
|
-
}, n.lang = function(
|
|
778
|
-
if (
|
|
779
|
-
A =
|
|
777
|
+
}, n.lang = function(s) {
|
|
778
|
+
if (s !== t)
|
|
779
|
+
A = s, l[A] === t && (A = "en"), T = O(), M = _(), G = b(), N = k();
|
|
780
780
|
else
|
|
781
781
|
return A;
|
|
782
782
|
return t;
|
|
783
783
|
}, n.availableLangs = function() {
|
|
784
784
|
return Object.keys(l);
|
|
785
|
-
}, n.registerFormat = function(
|
|
786
|
-
|
|
785
|
+
}, n.registerFormat = function(s, o, g, p, H, D) {
|
|
786
|
+
I[s] = {
|
|
787
787
|
format: o,
|
|
788
|
-
parse:
|
|
788
|
+
parse: g,
|
|
789
789
|
minLength: p,
|
|
790
|
-
maxLength:
|
|
790
|
+
maxLength: H,
|
|
791
791
|
type: D
|
|
792
792
|
};
|
|
793
|
-
}, n.unregisterFormat = function(
|
|
794
|
-
delete
|
|
795
|
-
}, n.detectFormat = function(
|
|
796
|
-
var o,
|
|
797
|
-
return o = h(
|
|
793
|
+
}, n.unregisterFormat = function(s) {
|
|
794
|
+
delete I[s];
|
|
795
|
+
}, n.detectFormat = function(s) {
|
|
796
|
+
var o, g, p;
|
|
797
|
+
return o = h(s, 0), o !== "" && (p = 10), g = s.charAt(p), (g === "T" || g === " ") && (o += g, p += 1), o += c(s, p), o;
|
|
798
798
|
}, u = {
|
|
799
|
-
TempusDate:
|
|
800
|
-
}, n.classes = function(
|
|
799
|
+
TempusDate: R
|
|
800
|
+
}, n.classes = function(s, o) {
|
|
801
801
|
if (o === t)
|
|
802
|
-
return u[
|
|
803
|
-
u[
|
|
804
|
-
}, n.loadTranslations = function(
|
|
805
|
-
typeof
|
|
802
|
+
return u[s];
|
|
803
|
+
u[s] = o;
|
|
804
|
+
}, n.loadTranslations = function(s) {
|
|
805
|
+
typeof s == "object" ? l = s : typeof s == "string" && S(s, function(o) {
|
|
806
806
|
l = o;
|
|
807
807
|
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), l[A] === t && (A = "en"),
|
|
810
|
-
}).call(
|
|
811
|
-
})(
|
|
812
|
-
var
|
|
813
|
-
const
|
|
814
|
-
var
|
|
809
|
+
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), l[A] === t && (A = "en"), T = O(), M = _(), G = b(), N = k(), m.exports && (e = m.exports = n), e.tempus = n;
|
|
810
|
+
}).call(ke);
|
|
811
|
+
})(Vt, Vt.exports);
|
|
812
|
+
var Be = Vt.exports;
|
|
813
|
+
const bt = /* @__PURE__ */ we(Be);
|
|
814
|
+
var St, ce, It, Dt, kt, wt, At, Mt, Bt, le, Ct, he, Z, at, tt, ft, et, dt, Ht, ue, Ut, fe, ct, Lt, gt, $t, pt, te;
|
|
815
815
|
const J = class J {
|
|
816
816
|
constructor(e) {
|
|
817
817
|
/**
|
|
@@ -820,25 +820,25 @@ const J = class J {
|
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
|
|
823
|
+
E(this, St);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
827
827
|
*/
|
|
828
|
-
|
|
828
|
+
E(this, At);
|
|
829
829
|
/**
|
|
830
830
|
* Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
|
|
831
831
|
*
|
|
832
832
|
* @param {{percent: number, allCount: number, allTotal: number}} snapshot - Текущий снимок прогресса.
|
|
833
833
|
* @returns {boolean} `true`, если нужно отправить callback прогресса.
|
|
834
834
|
*/
|
|
835
|
-
|
|
835
|
+
E(this, Bt);
|
|
836
836
|
/**
|
|
837
837
|
* Уведомляет подписчиков о текущем состоянии лимита.
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
|
|
841
|
+
E(this, Ct);
|
|
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
|
-
|
|
849
|
+
E(this, Z);
|
|
850
850
|
/**
|
|
851
851
|
* Проверяет operating-time в результате batch и ставит паузу,
|
|
852
852
|
* если сервер приблизился к лимиту выполнения.
|
|
@@ -854,7 +854,7 @@ const J = class J {
|
|
|
854
854
|
* @param {Object} result - Результат текущего batch-запроса.
|
|
855
855
|
* @returns {Promise<number>} Максимальный operating-time среди команд.
|
|
856
856
|
*/
|
|
857
|
-
|
|
857
|
+
E(this, tt);
|
|
858
858
|
/**
|
|
859
859
|
* Выполняет один chunk с автоматическим повтором после лимит-паузы.
|
|
860
860
|
* Повтор запускается при ошибках QUERY_LIMIT_EXCEEDED, OPERATION_TIME_LIMIT или TIMEOUT.
|
|
@@ -863,7 +863,7 @@ const J = class J {
|
|
|
863
863
|
* @param {(result: Object) => Promise<void>} processResult - Обработчик успешного результата chunk.
|
|
864
864
|
* @returns {Promise<void>}
|
|
865
865
|
*/
|
|
866
|
-
|
|
866
|
+
E(this, et);
|
|
867
867
|
/**
|
|
868
868
|
* Выполняет BX24.callMethod с таймаутом ожидания ответа.
|
|
869
869
|
*
|
|
@@ -871,14 +871,23 @@ const J = class J {
|
|
|
871
871
|
* @param {Object} params - Параметры REST-метода.
|
|
872
872
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
873
|
*/
|
|
874
|
-
|
|
874
|
+
E(this, Ht);
|
|
875
|
+
/**
|
|
876
|
+
* Код и текст ошибки подкоманды batch.
|
|
877
|
+
* `errorsList` по-прежнему отдаёт коды; описания — в `errorsListMessages`.
|
|
878
|
+
* @param {{ error?: () => { ex?: { error?: string, error_description?: string }, toString?: () => string } | null }} value
|
|
879
|
+
* @returns {{ code: string, message: string }}
|
|
880
|
+
*/
|
|
881
|
+
E(this, Ut);
|
|
882
|
+
E(this, ct);
|
|
883
|
+
E(this, gt);
|
|
875
884
|
/**
|
|
876
885
|
* Resets mutable runtime state before each public batch run.
|
|
877
886
|
* @param {Function} progressCall - Progress callback for current run.
|
|
878
887
|
* @returns {void}
|
|
879
888
|
*/
|
|
880
|
-
|
|
881
|
-
typeof e == "function" ? (this.callBatch = e, this.callMethod = null) : (this.callBatch = (e == null ? void 0 : e.callBatch) || null, this.callMethod = (e == null ? void 0 : e.callMethod) || null), this.result = {}, this.errors = {}, this.timeLimit = {
|
|
889
|
+
E(this, pt);
|
|
890
|
+
typeof e == "function" ? (this.callBatch = e, this.callMethod = null) : (this.callBatch = (e == null ? void 0 : e.callBatch) || null, this.callMethod = (e == null ? void 0 : e.callMethod) || null), this.result = {}, this.errors = {}, this.errorMessages = {}, this.timeLimit = {
|
|
882
891
|
limit: !1,
|
|
883
892
|
date: void 0,
|
|
884
893
|
pauseMs: void 0
|
|
@@ -892,31 +901,31 @@ const J = class J {
|
|
|
892
901
|
if (!this.progressData)
|
|
893
902
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
894
903
|
const e = this.totalBatchCommands || 0;
|
|
895
|
-
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length &&
|
|
904
|
+
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && y(this, St, ce).call(this)) {
|
|
896
905
|
let f = 0;
|
|
897
906
|
for (const l of this.batchCommandKeyOrder) {
|
|
898
|
-
const
|
|
899
|
-
if (!
|
|
907
|
+
const O = this.progressData[l];
|
|
908
|
+
if (!O)
|
|
900
909
|
continue;
|
|
901
|
-
const
|
|
902
|
-
|
|
910
|
+
const _ = Number(O.total) || 0, b = Number(O.count) || 0;
|
|
911
|
+
_ === 0 && b === 0 ? f += 1 : _ > 0 && (f += Math.min(1, b / _));
|
|
903
912
|
}
|
|
904
913
|
const n = f / e * 100;
|
|
905
914
|
let u = Math.max(0, Math.min(100, Math.floor(n)));
|
|
906
915
|
const d = e, A = Math.min(e, Math.floor(f));
|
|
907
916
|
return { percent: u, allCount: A, allTotal: d };
|
|
908
917
|
}
|
|
909
|
-
let t = 0,
|
|
918
|
+
let t = 0, r = 0;
|
|
910
919
|
for (const f of Object.values(this.progressData)) {
|
|
911
920
|
const { total: n, count: u } = f;
|
|
912
|
-
t += n ?? 0,
|
|
921
|
+
t += n ?? 0, r += u ?? 0;
|
|
913
922
|
}
|
|
914
923
|
const i = Number(this.chunkRate) || 0;
|
|
915
924
|
let a = 0;
|
|
916
|
-
t ? a =
|
|
925
|
+
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));
|
|
917
926
|
let c = Math.floor(a);
|
|
918
927
|
const h = Number(this.chunkRate) || 0;
|
|
919
|
-
return t > 0 &&
|
|
928
|
+
return t > 0 && r >= t && h >= 1 && (c = 100), { percent: c, allCount: r, allTotal: t };
|
|
920
929
|
}
|
|
921
930
|
/**
|
|
922
931
|
* Обновление данных прогресса выполнения
|
|
@@ -925,37 +934,37 @@ const J = class J {
|
|
|
925
934
|
* @param {Object} params.value - Значение ответа от API
|
|
926
935
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
927
936
|
*/
|
|
928
|
-
setProgressData({ key: e, value: t, type:
|
|
929
|
-
var l,
|
|
937
|
+
setProgressData({ key: e, value: t, type: r }) {
|
|
938
|
+
var l, O;
|
|
930
939
|
if (!this.progressCall)
|
|
931
940
|
return;
|
|
932
941
|
const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
|
|
933
942
|
let c = a;
|
|
934
943
|
if (typeof t.total == "function") {
|
|
935
|
-
const
|
|
936
|
-
if (
|
|
937
|
-
const
|
|
938
|
-
Number.isFinite(
|
|
944
|
+
const _ = t.total();
|
|
945
|
+
if (_ != null && _ !== "") {
|
|
946
|
+
const b = Number(_);
|
|
947
|
+
Number.isFinite(b) && (c = b);
|
|
939
948
|
}
|
|
940
949
|
}
|
|
941
950
|
let h = 1;
|
|
942
|
-
|
|
943
|
-
const f = ((l = this.progressData[e]) == null ? void 0 : l.total) ?? 0, n = ((
|
|
951
|
+
r === "count" ? (c || (c = a), h = c > 0 ? c : a > 0 ? a : 1) : i && (h = a), this.progressData || (this.progressData = {});
|
|
952
|
+
const f = ((l = this.progressData[e]) == null ? void 0 : l.total) ?? 0, n = ((O = this.progressData[e]) == null ? void 0 : O.count) ?? 0, u = h + n, d = Math.max(f, c ?? 0, u);
|
|
944
953
|
if (this.progressData[e] = {
|
|
945
954
|
total: d,
|
|
946
955
|
count: Math.min(u, d)
|
|
947
956
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
948
|
-
|
|
957
|
+
y(this, At, Mt).call(this);
|
|
949
958
|
return;
|
|
950
959
|
}
|
|
951
|
-
|
|
960
|
+
y(this, At, Mt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
952
961
|
if (!this.progressCall) {
|
|
953
962
|
this.clearProgressData();
|
|
954
963
|
return;
|
|
955
964
|
}
|
|
956
|
-
|
|
957
|
-
const { percent:
|
|
958
|
-
|
|
965
|
+
y(this, At, Mt).call(this);
|
|
966
|
+
const { percent: _ } = this.progressPercent;
|
|
967
|
+
_ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
959
968
|
}, this.progressDelay));
|
|
960
969
|
}
|
|
961
970
|
/**
|
|
@@ -977,8 +986,8 @@ const J = class J {
|
|
|
977
986
|
* @param {number|undefined} pauseMs - Длительность текущей лимит-паузы (мс); при снятии лимита не передаётся.
|
|
978
987
|
* @returns {void}
|
|
979
988
|
*/
|
|
980
|
-
setTimeLimitState(e, t,
|
|
981
|
-
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof
|
|
989
|
+
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, y(this, Ct, he).call(this);
|
|
982
991
|
}
|
|
983
992
|
/**
|
|
984
993
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1005,7 +1014,7 @@ const J = class J {
|
|
|
1005
1014
|
* @returns {Array} Массив запросов (может быть один или несколько)
|
|
1006
1015
|
*/
|
|
1007
1016
|
splitLargeFilters(e, t) {
|
|
1008
|
-
const { method:
|
|
1017
|
+
const { method: r, params: i } = t;
|
|
1009
1018
|
if (!i)
|
|
1010
1019
|
return [{ key: e, request: t }];
|
|
1011
1020
|
const a = i.filter || i.FILTER;
|
|
@@ -1018,7 +1027,7 @@ const J = class J {
|
|
|
1018
1027
|
const u = h.slice(n, n + this.filterChunkSize), d = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
|
|
1019
1028
|
i.filter ? (A.filter = { ...a }, A.filter[c] = u) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[c] = u), f.push({
|
|
1020
1029
|
key: d,
|
|
1021
|
-
request: { method:
|
|
1030
|
+
request: { method: r, params: A },
|
|
1022
1031
|
originalKey: e,
|
|
1023
1032
|
filterKey: c,
|
|
1024
1033
|
chunkIndex: Math.floor(n / this.filterChunkSize)
|
|
@@ -1035,15 +1044,15 @@ const J = class J {
|
|
|
1035
1044
|
* @returns {Array} Объединенный массив результатов
|
|
1036
1045
|
*/
|
|
1037
1046
|
mergeSplitResults(e, t) {
|
|
1038
|
-
const
|
|
1047
|
+
const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), c = Object.keys(e).filter((h) => a.test(h)).sort((h, f) => {
|
|
1039
1048
|
const n = h.match(/__chunk_(\d+)$/), u = f.match(/__chunk_(\d+)$/);
|
|
1040
1049
|
return n ? u ? parseInt(n[1]) - parseInt(u[1]) : 1 : -1;
|
|
1041
1050
|
});
|
|
1042
1051
|
for (const h of c) {
|
|
1043
1052
|
const f = e[h];
|
|
1044
|
-
Array.isArray(f) ?
|
|
1053
|
+
Array.isArray(f) ? r.push(...f) : f && r.push(f);
|
|
1045
1054
|
}
|
|
1046
|
-
return
|
|
1055
|
+
return r;
|
|
1047
1056
|
}
|
|
1048
1057
|
/**
|
|
1049
1058
|
* Задержка между запросами
|
|
@@ -1061,13 +1070,13 @@ const J = class J {
|
|
|
1061
1070
|
* @returns {Promise<void>}
|
|
1062
1071
|
*/
|
|
1063
1072
|
callBatchWithTimeout(e, t) {
|
|
1064
|
-
return new Promise((
|
|
1073
|
+
return new Promise((r, i) => {
|
|
1065
1074
|
let a = !1, c = null;
|
|
1066
1075
|
const h = async (n) => {
|
|
1067
1076
|
if (!a) {
|
|
1068
1077
|
a = !0, c && clearTimeout(c);
|
|
1069
1078
|
try {
|
|
1070
|
-
await Promise.resolve(t(n)),
|
|
1079
|
+
await Promise.resolve(t(n)), r();
|
|
1071
1080
|
} catch (u) {
|
|
1072
1081
|
console.error("Error in callBatch callback:", u), i(u);
|
|
1073
1082
|
}
|
|
@@ -1091,9 +1100,9 @@ const J = class J {
|
|
|
1091
1100
|
};
|
|
1092
1101
|
});
|
|
1093
1102
|
try {
|
|
1094
|
-
await Promise.resolve(t(n)),
|
|
1103
|
+
await Promise.resolve(t(n)), r();
|
|
1095
1104
|
} catch (u) {
|
|
1096
|
-
console.error("Error in timeout callback:", u),
|
|
1105
|
+
console.error("Error in timeout callback:", u), r();
|
|
1097
1106
|
}
|
|
1098
1107
|
}
|
|
1099
1108
|
};
|
|
@@ -1129,8 +1138,8 @@ const J = class J {
|
|
|
1129
1138
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения.
|
|
1130
1139
|
* @returns {Promise<Object>}
|
|
1131
1140
|
*/
|
|
1132
|
-
async batch(e, t,
|
|
1133
|
-
|
|
1141
|
+
async batch(e, t, r = {}) {
|
|
1142
|
+
y(this, pt, te).call(this, t);
|
|
1134
1143
|
const i = {}, a = {}, c = {};
|
|
1135
1144
|
for (const [u, d] of Object.entries(e)) {
|
|
1136
1145
|
const A = this.arrayChunk(d);
|
|
@@ -1141,8 +1150,8 @@ const J = class J {
|
|
|
1141
1150
|
a[u] = A;
|
|
1142
1151
|
else {
|
|
1143
1152
|
c[u] = [];
|
|
1144
|
-
for (const
|
|
1145
|
-
a[
|
|
1153
|
+
for (const O of l)
|
|
1154
|
+
a[O.key] = O.request, c[u].push(O.key);
|
|
1146
1155
|
}
|
|
1147
1156
|
}
|
|
1148
1157
|
this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
|
|
@@ -1164,10 +1173,10 @@ const J = class J {
|
|
|
1164
1173
|
!A,
|
|
1165
1174
|
{
|
|
1166
1175
|
disablePagination: !1,
|
|
1167
|
-
oneBatch: !!(
|
|
1176
|
+
oneBatch: !!(r != null && r.oneBatch)
|
|
1168
1177
|
}
|
|
1169
|
-
), Object.entries(this.result).forEach(([l,
|
|
1170
|
-
i[l] =
|
|
1178
|
+
), Object.entries(this.result).forEach(([l, O]) => {
|
|
1179
|
+
i[l] = O;
|
|
1171
1180
|
}), this.totalProgress = Math.round(
|
|
1172
1181
|
f / n * 100
|
|
1173
1182
|
), h = {};
|
|
@@ -1181,7 +1190,7 @@ const J = class J {
|
|
|
1181
1190
|
delete i[l];
|
|
1182
1191
|
i[u] = A;
|
|
1183
1192
|
}
|
|
1184
|
-
return
|
|
1193
|
+
return y(this, gt, $t).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
|
|
1185
1194
|
}
|
|
1186
1195
|
/**
|
|
1187
1196
|
* Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
|
|
@@ -1193,8 +1202,8 @@ const J = class J {
|
|
|
1193
1202
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
1194
1203
|
*/
|
|
1195
1204
|
async batchTotalCount(e, t) {
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1205
|
+
y(this, pt, te).call(this, t);
|
|
1206
|
+
const r = {}, i = {}, a = {};
|
|
1198
1207
|
for (const [f, n] of Object.entries(e)) {
|
|
1199
1208
|
const u = this.arrayChunk(n);
|
|
1200
1209
|
if (!u)
|
|
@@ -1224,30 +1233,28 @@ const J = class J {
|
|
|
1224
1233
|
break;
|
|
1225
1234
|
this.totalProgress = Math.round(Number(f) / c.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
|
|
1226
1235
|
const u = Number(f) === c.length - 1;
|
|
1227
|
-
await
|
|
1228
|
-
|
|
1229
|
-
for (const [M, N] of Object.entries(d)) {
|
|
1236
|
+
await y(this, et, dt).call(this, n, async (d) => {
|
|
1237
|
+
for (const [A, l] of Object.entries(d)) {
|
|
1230
1238
|
if (!this.canContinue)
|
|
1231
1239
|
return;
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
this.errors[M] = R && R.trim() || B && B.trim() || ((E = N.error()) == null ? void 0 : E.toString()) || "Неизвестная ошибка", s[M] = 0;
|
|
1240
|
+
if (l.error()) {
|
|
1241
|
+
y(this, ct, Lt).call(this, A, l), r[A] = 0;
|
|
1235
1242
|
continue;
|
|
1236
1243
|
}
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1244
|
+
const O = this.getData(l.data()), _ = Array.isArray(O) ? O.length : 0, k = typeof l.total == "function" && l.total() !== void 0 ? l.total() : _;
|
|
1245
|
+
r[A] = k, this.setProgressData({ key: A, value: l, type: "count" });
|
|
1239
1246
|
}
|
|
1240
|
-
await
|
|
1247
|
+
await y(this, tt, ft).call(this, d, !u);
|
|
1241
1248
|
});
|
|
1242
1249
|
}
|
|
1243
1250
|
for (const [f, n] of Object.entries(a))
|
|
1244
1251
|
if (n && n.length > 0) {
|
|
1245
1252
|
let u = 0;
|
|
1246
1253
|
for (const d of n)
|
|
1247
|
-
|
|
1248
|
-
|
|
1254
|
+
r[d] !== void 0 && (u += r[d] || 0), delete r[d];
|
|
1255
|
+
r[f] = u;
|
|
1249
1256
|
}
|
|
1250
|
-
return Object.entries(this.errors).length && (
|
|
1257
|
+
return Object.entries(this.errors).length && (y(this, gt, $t).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
|
|
1251
1258
|
}
|
|
1252
1259
|
/**
|
|
1253
1260
|
* Выполняет одиночный REST-вызов с таймаутом и авто-повтором после лимит-паузы.
|
|
@@ -1257,29 +1264,29 @@ const J = class J {
|
|
|
1257
1264
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1258
1265
|
*/
|
|
1259
1266
|
async call({ method: e, params: t = {} }) {
|
|
1260
|
-
var
|
|
1267
|
+
var r, i, a, c, h, f, n;
|
|
1261
1268
|
for (; ; ) {
|
|
1262
|
-
const u = await
|
|
1269
|
+
const u = await y(this, Ht, ue).call(this, e, t);
|
|
1263
1270
|
if (!u) {
|
|
1264
|
-
await
|
|
1271
|
+
await y(this, Z, at).call(this, this.callLimitPauseMs);
|
|
1265
1272
|
continue;
|
|
1266
1273
|
}
|
|
1267
1274
|
const d = {};
|
|
1268
1275
|
if (u != null && u.answer)
|
|
1269
|
-
for (const [l,
|
|
1270
|
-
l !== "result" &&
|
|
1276
|
+
for (const [l, O] of Object.entries(u.answer))
|
|
1277
|
+
l !== "result" && O && (d[l] = O);
|
|
1271
1278
|
if (u.error()) {
|
|
1272
|
-
const l = ((i = (
|
|
1279
|
+
const l = ((i = (r = u.error()) == null ? void 0 : r.ex) == null ? void 0 : i.error) ?? "";
|
|
1273
1280
|
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(l)) {
|
|
1274
|
-
await
|
|
1281
|
+
await y(this, Z, at).call(this, this.callLimitPauseMs);
|
|
1275
1282
|
continue;
|
|
1276
1283
|
}
|
|
1277
|
-
const
|
|
1284
|
+
const O = ((a = u.error()) == null ? void 0 : a.toString()) || ((h = (c = u.error()) == null ? void 0 : c.ex) == null ? void 0 : h.error_description) || ((n = (f = u.error()) == null ? void 0 : f.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
|
|
1278
1285
|
return {
|
|
1279
1286
|
success: !1,
|
|
1280
1287
|
data: !1,
|
|
1281
1288
|
answer: d,
|
|
1282
|
-
error:
|
|
1289
|
+
error: O
|
|
1283
1290
|
};
|
|
1284
1291
|
}
|
|
1285
1292
|
let A = u.data();
|
|
@@ -1297,30 +1304,30 @@ const J = class J {
|
|
|
1297
1304
|
* @param {Array/Object} request - Массив/объект методов
|
|
1298
1305
|
*/
|
|
1299
1306
|
arrayChunk(e) {
|
|
1300
|
-
let t = "",
|
|
1301
|
-
if (Array.isArray(e) ? [t] = e : (t = e.method,
|
|
1302
|
-
if (!
|
|
1303
|
-
|
|
1307
|
+
let t = "", r = {};
|
|
1308
|
+
if (Array.isArray(e) ? [t] = e : (t = e.method, r = e.params), (t.includes("list") || t === "user.get" || t === "entity.item.get") && t !== "task.item.list") {
|
|
1309
|
+
if (!r)
|
|
1310
|
+
r = t === "entity.item.get" ? { SORT: { ID: "ASC" } } : {
|
|
1304
1311
|
order: { ID: "ASC", id: "ASC" }
|
|
1305
1312
|
};
|
|
1306
1313
|
else {
|
|
1307
|
-
t === "entity.item.get" ? (
|
|
1308
|
-
const i = t === "user.get" || t === "entity.item.get" ?
|
|
1314
|
+
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
|
+
const i = t === "user.get" || t === "entity.item.get" ? r.FILTER : r.filter;
|
|
1309
1316
|
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, c]) => {
|
|
1310
|
-
(
|
|
1317
|
+
(r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof c == "string" || Array.isArray(c) && c.length <= 50) && (r.start = -1);
|
|
1311
1318
|
});
|
|
1312
1319
|
}
|
|
1313
|
-
t === "crm.type.list" &&
|
|
1320
|
+
t === "crm.type.list" && r.order && delete r.order.ID;
|
|
1314
1321
|
}
|
|
1315
1322
|
if (t === "task.item.list")
|
|
1316
|
-
if (!
|
|
1317
|
-
|
|
1323
|
+
if (!r)
|
|
1324
|
+
r = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
1318
1325
|
else {
|
|
1319
|
-
Array.isArray(
|
|
1320
|
-
const [i, a, c, h] =
|
|
1326
|
+
Array.isArray(r[0]) && (r[0] = {});
|
|
1327
|
+
const [i, a, c, h] = r;
|
|
1321
1328
|
i.ID = "ASC", h[0] !== "" && h.includes("ID") || h.push("ID");
|
|
1322
1329
|
}
|
|
1323
|
-
return { method: t, params:
|
|
1330
|
+
return { method: t, params: r };
|
|
1324
1331
|
}
|
|
1325
1332
|
/** Выполняет первичный запрос с массивом методов
|
|
1326
1333
|
* При наличии более 50 элементов в нем, подготоваливаем данные и передаем в this.batchPayload
|
|
@@ -1328,44 +1335,40 @@ const J = class J {
|
|
|
1328
1335
|
* @param {Array} query - Тот же массив с методами
|
|
1329
1336
|
* @returns {Object} Объект с результатами запросов
|
|
1330
1337
|
*/
|
|
1331
|
-
async batchChunk(e, t,
|
|
1338
|
+
async batchChunk(e, t, r = !0, i = {}) {
|
|
1332
1339
|
return new Promise((a) => {
|
|
1333
1340
|
const c = [];
|
|
1334
1341
|
let h;
|
|
1335
1342
|
const f = !!(i != null && i.disablePagination);
|
|
1336
1343
|
(async () => {
|
|
1337
|
-
await
|
|
1338
|
-
|
|
1339
|
-
for (const [M, N] of Object.entries(u)) {
|
|
1344
|
+
await y(this, et, dt).call(this, e, async (u) => {
|
|
1345
|
+
for (const [A, l] of Object.entries(u)) {
|
|
1340
1346
|
if (!this.canContinue)
|
|
1341
1347
|
return;
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
if (Array.isArray(p)) {
|
|
1352
|
-
const [C, D = {}] = p;
|
|
1353
|
-
p = [C, D];
|
|
1348
|
+
l.error() && (y(this, ct, Lt).call(this, A, l), h = !0);
|
|
1349
|
+
const O = this.getData(l.data()), _ = Array.isArray(O) ? O.length : 0, b = typeof l.total == "function" && l.total() !== void 0, k = b ? l.total() : _;
|
|
1350
|
+
t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = k : this.result[A] = O, this.setProgressData({ key: A, value: l, type: t });
|
|
1351
|
+
const T = e[A], M = Array.isArray(T) ? T[0] : T == null ? void 0 : T.method, G = typeof M == "string" && (M.includes(".list") || M === "user.get" || M === "entity.item.get"), N = t === "count" ? !b && _ === this.limit : G ? _ === this.limit : k > this.limit && k > _, S = t !== "count" && M === "entity.item.get" && _ === this.limit && !N, I = N || S;
|
|
1352
|
+
if (!f && (!this.canContinue || I)) {
|
|
1353
|
+
let C = e[A];
|
|
1354
|
+
if (Array.isArray(C)) {
|
|
1355
|
+
const [R, s = {}] = C;
|
|
1356
|
+
C = [R, s];
|
|
1354
1357
|
} else {
|
|
1355
|
-
const { method:
|
|
1356
|
-
|
|
1358
|
+
const { method: R, params: s = {} } = C;
|
|
1359
|
+
C = [R, s];
|
|
1357
1360
|
}
|
|
1358
1361
|
c.push([
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
{ entityItemGetScan:
|
|
1362
|
+
A,
|
|
1363
|
+
C,
|
|
1364
|
+
k,
|
|
1365
|
+
{ entityItemGetScan: S }
|
|
1363
1366
|
]);
|
|
1364
1367
|
}
|
|
1365
1368
|
}
|
|
1366
1369
|
h > 0 && this.errorLogger();
|
|
1367
|
-
const d = c.length > 0 ||
|
|
1368
|
-
await
|
|
1370
|
+
const d = c.length > 0 || r;
|
|
1371
|
+
await y(this, tt, ft).call(this, u, d), c.length ? await this.batchPayload(c, t, i).then(
|
|
1369
1372
|
() => a(this.result)
|
|
1370
1373
|
) : a(this.result);
|
|
1371
1374
|
});
|
|
@@ -1377,97 +1380,92 @@ const J = class J {
|
|
|
1377
1380
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1378
1381
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1379
1382
|
*/
|
|
1380
|
-
async batchPayload(e, t,
|
|
1381
|
-
const i = !!(
|
|
1382
|
-
let
|
|
1383
|
-
this.result[
|
|
1384
|
-
let
|
|
1385
|
-
if (JSON.stringify(
|
|
1383
|
+
async batchPayload(e, t, r = {}) {
|
|
1384
|
+
const i = !!(r != null && r.oneBatch), a = (O, _, b, k) => {
|
|
1385
|
+
let T = "ID";
|
|
1386
|
+
this.result[O][this.result[O].length - 1].ID || (T = "id");
|
|
1387
|
+
let M = `${T}`;
|
|
1388
|
+
if (JSON.stringify(k[1]).toLocaleLowerCase().includes('"id":"desc"') ? M = "<" + M : M = ">" + M, _ === 1 || b.length === 0)
|
|
1386
1389
|
return {
|
|
1387
|
-
field:
|
|
1388
|
-
id: this.result[
|
|
1390
|
+
field: M,
|
|
1391
|
+
id: this.result[O][this.result[O].length - 1][T]
|
|
1389
1392
|
};
|
|
1390
|
-
let
|
|
1391
|
-
const [S,
|
|
1392
|
-
return (S === "tasks.task.list" || S === "task.item.list") && (
|
|
1393
|
-
field:
|
|
1394
|
-
id: `$result[${[
|
|
1393
|
+
let N = "";
|
|
1394
|
+
const [S, I] = k;
|
|
1395
|
+
return (S === "tasks.task.list" || S === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(S) && (N = "[items]"), S === "crm.type.list" && (N = "[types]"), S === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
|
|
1396
|
+
field: M,
|
|
1397
|
+
id: `$result[${[O, _ - 1].join("__")}]${N}[49][${T}]`
|
|
1395
1398
|
};
|
|
1396
|
-
}, c = (
|
|
1397
|
-
const [
|
|
1398
|
-
let
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1401
|
-
const [
|
|
1402
|
-
return
|
|
1399
|
+
}, c = (O, _) => {
|
|
1400
|
+
const [b, k] = O;
|
|
1401
|
+
let T = JSON.parse(JSON.stringify(k)), M;
|
|
1402
|
+
if (b === "task.item.list") {
|
|
1403
|
+
T = [...T];
|
|
1404
|
+
const [G, N, S, I] = T;
|
|
1405
|
+
return N[_.field] = _.id, [b, T];
|
|
1403
1406
|
}
|
|
1404
|
-
return ["user.get"].includes(
|
|
1407
|
+
return ["user.get"].includes(b) || T.FILTER ? (T.FILTER || (T.FILTER = {}), M = T.FILTER) : (T.filter || (T.filter = {}), M = T.filter), [
|
|
1405
1408
|
"socialnetwork.api.workgroup.list",
|
|
1406
1409
|
"tasks.task.list"
|
|
1407
|
-
].includes(
|
|
1408
|
-
}, h = (
|
|
1409
|
-
Object.entries(
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
if (Array.isArray(N) && (t === "count" ? this.result[M] += N.length : this.result[M].push(...N)), E.error()) {
|
|
1413
|
-
const B = (H = (b = E.error()) == null ? void 0 : b.ex) == null ? void 0 : H.error, k = (S = (y = E.error()) == null ? void 0 : y.ex) == null ? void 0 : S.error_description;
|
|
1414
|
-
this.errors[M] = B && B.trim() || k && k.trim() || ((R = E.error()) == null ? void 0 : R.toString()) || "Неизвестная ошибка";
|
|
1415
|
-
}
|
|
1416
|
-
this.setProgressData({ key: M, value: E, type: t });
|
|
1410
|
+
].includes(b) ? M[">ID"] = _.id : M[_.field] = _.id, [b, { ...T, start: -1 }];
|
|
1411
|
+
}, h = (O) => {
|
|
1412
|
+
Object.entries(O).forEach(([_, b]) => {
|
|
1413
|
+
const [k] = _.split("__"), T = this.getData(b.data());
|
|
1414
|
+
Array.isArray(T) && (t === "count" ? this.result[k] += T.length : this.result[k].push(...T)), b.error() && y(this, ct, Lt).call(this, k, b), this.setProgressData({ key: k, value: b, type: t });
|
|
1417
1415
|
});
|
|
1418
|
-
}, f = (
|
|
1419
|
-
if (!Array.isArray(
|
|
1416
|
+
}, f = (O, _) => {
|
|
1417
|
+
if (!Array.isArray(O) || O.length === 0)
|
|
1420
1418
|
return null;
|
|
1421
|
-
const
|
|
1422
|
-
let
|
|
1423
|
-
|
|
1424
|
-
let
|
|
1425
|
-
return JSON.stringify(
|
|
1426
|
-
}, n = 1e4, u = async (
|
|
1427
|
-
var
|
|
1428
|
-
let
|
|
1429
|
-
for (let
|
|
1430
|
-
const
|
|
1431
|
-
if (!
|
|
1419
|
+
const b = O[O.length - 1];
|
|
1420
|
+
let k = "ID";
|
|
1421
|
+
b.ID || (k = "id");
|
|
1422
|
+
let T = k;
|
|
1423
|
+
return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: b[k] };
|
|
1424
|
+
}, n = 1e4, u = async (O, _) => {
|
|
1425
|
+
var k, T;
|
|
1426
|
+
let b = this.limit;
|
|
1427
|
+
for (let M = 1; this.canContinue && b === this.limit && M <= n; M++) {
|
|
1428
|
+
const G = this.result[O], N = f(G, _);
|
|
1429
|
+
if (!N)
|
|
1432
1430
|
break;
|
|
1433
|
-
const S = `${
|
|
1434
|
-
let
|
|
1435
|
-
await
|
|
1436
|
-
|
|
1431
|
+
const S = `${O}__eiscan_${M}`, I = c(_, N);
|
|
1432
|
+
let C = null;
|
|
1433
|
+
await y(this, et, dt).call(this, { [S]: I }, async (g) => {
|
|
1434
|
+
C = g, h(g);
|
|
1437
1435
|
});
|
|
1438
|
-
const
|
|
1439
|
-
await
|
|
1440
|
-
const
|
|
1441
|
-
if ((
|
|
1442
|
-
|
|
1436
|
+
const R = M < n;
|
|
1437
|
+
await y(this, tt, ft).call(this, C, R), await this.delay();
|
|
1438
|
+
const s = C == null ? void 0 : C[S];
|
|
1439
|
+
if ((k = s == null ? void 0 : s.error) != null && k.call(s)) {
|
|
1440
|
+
b = 0;
|
|
1443
1441
|
break;
|
|
1444
1442
|
}
|
|
1445
|
-
const o = this.getData((
|
|
1446
|
-
|
|
1443
|
+
const o = this.getData((T = s == null ? void 0 : s.data) == null ? void 0 : T.call(s));
|
|
1444
|
+
b = Array.isArray(o) ? o.length : 0;
|
|
1447
1445
|
}
|
|
1448
1446
|
};
|
|
1449
1447
|
let d = [], A = 0;
|
|
1450
|
-
const l = async (
|
|
1451
|
-
h(
|
|
1448
|
+
const l = async (O = !0) => d.length ? (await y(this, et, dt).call(this, Object.fromEntries(d), async (_) => {
|
|
1449
|
+
h(_), await y(this, tt, ft).call(this, _, O);
|
|
1452
1450
|
}), A++, d = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1453
|
-
for await (const
|
|
1451
|
+
for await (const O of e) {
|
|
1454
1452
|
if (!this.canContinue)
|
|
1455
1453
|
return;
|
|
1456
|
-
const [
|
|
1457
|
-
if (
|
|
1454
|
+
const [_, b, k, T = {}] = O;
|
|
1455
|
+
if (T.entityItemGetScan) {
|
|
1458
1456
|
if (await l(!0))
|
|
1459
1457
|
return;
|
|
1460
1458
|
if (i)
|
|
1461
1459
|
continue;
|
|
1462
|
-
await u(
|
|
1460
|
+
await u(_, b);
|
|
1463
1461
|
continue;
|
|
1464
1462
|
}
|
|
1465
|
-
let
|
|
1466
|
-
for (;
|
|
1467
|
-
const
|
|
1468
|
-
if (d.push([
|
|
1463
|
+
let M = 1;
|
|
1464
|
+
for (; k > M * this.limit; ) {
|
|
1465
|
+
const G = [_, M].join("__"), N = a(_, M, d, b);
|
|
1466
|
+
if (d.push([G, c(b, N)]), i && d.length === 49 && await l(!0) || d.length % 50 === 0 && await l(!0))
|
|
1469
1467
|
return;
|
|
1470
|
-
|
|
1468
|
+
M++;
|
|
1471
1469
|
}
|
|
1472
1470
|
}
|
|
1473
1471
|
await l(!1);
|
|
@@ -1481,29 +1479,29 @@ const J = class J {
|
|
|
1481
1479
|
}), console.groupEnd();
|
|
1482
1480
|
}
|
|
1483
1481
|
};
|
|
1484
|
-
|
|
1482
|
+
St = new WeakSet(), ce = function() {
|
|
1485
1483
|
const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
|
|
1486
|
-
if (e <
|
|
1484
|
+
if (e < L(J, It) || !Array.isArray(t) || t.length !== e)
|
|
1487
1485
|
return !1;
|
|
1488
|
-
if (t.filter((a) => a === "crm.deal.list").length >=
|
|
1486
|
+
if (t.filter((a) => a === "crm.deal.list").length >= L(J, Dt))
|
|
1489
1487
|
return !0;
|
|
1490
1488
|
const i = t.filter(
|
|
1491
1489
|
(a) => typeof a == "string" && a.includes(".list")
|
|
1492
1490
|
).length;
|
|
1493
|
-
return i >=
|
|
1494
|
-
},
|
|
1491
|
+
return i >= L(J, kt) && i / e >= L(J, wt);
|
|
1492
|
+
}, It = new WeakMap(), Dt = new WeakMap(), kt = new WeakMap(), wt = new WeakMap(), At = new WeakSet(), Mt = function() {
|
|
1495
1493
|
if (!this.progressCall || !this.progressData)
|
|
1496
1494
|
return;
|
|
1497
|
-
const { percent: e, allCount: t, allTotal:
|
|
1498
|
-
|
|
1495
|
+
const { percent: e, allCount: t, allTotal: r } = this.progressPercent, i = { percent: e, allCount: t, allTotal: r };
|
|
1496
|
+
y(this, Bt, le).call(this, i) && (this.progressCall({
|
|
1499
1497
|
data: this.progressData,
|
|
1500
1498
|
percent: e,
|
|
1501
1499
|
allCount: t,
|
|
1502
|
-
allTotal:
|
|
1500
|
+
allTotal: r
|
|
1503
1501
|
}), this.lastProgressSnapshot = i);
|
|
1504
|
-
},
|
|
1502
|
+
}, Bt = new WeakSet(), le = function(e) {
|
|
1505
1503
|
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== e.percent || this.lastProgressSnapshot.allCount !== e.allCount || this.lastProgressSnapshot.allTotal !== e.allTotal : !0;
|
|
1506
|
-
},
|
|
1504
|
+
}, Ct = new WeakSet(), he = function() {
|
|
1507
1505
|
const e = {
|
|
1508
1506
|
limit: this.timeLimit.limit,
|
|
1509
1507
|
date: this.timeLimit.date,
|
|
@@ -1512,15 +1510,15 @@ Lt = new WeakSet(), ie = function() {
|
|
|
1512
1510
|
for (const t of this.timeLimitListeners)
|
|
1513
1511
|
try {
|
|
1514
1512
|
t(e);
|
|
1515
|
-
} catch (
|
|
1516
|
-
console.warn("Batch timeLimit listener error:",
|
|
1513
|
+
} catch (r) {
|
|
1514
|
+
console.warn("Batch timeLimit listener error:", r);
|
|
1517
1515
|
}
|
|
1518
1516
|
}, Z = new WeakSet(), at = async function(e = this.defaultPauseMs) {
|
|
1519
1517
|
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), e), await new Promise((t) => setTimeout(t, e)), this.setTimeLimitState(!1, void 0);
|
|
1520
|
-
}, tt = new WeakSet(),
|
|
1518
|
+
}, tt = new WeakSet(), ft = async function(e, t = !0) {
|
|
1521
1519
|
if (!t)
|
|
1522
1520
|
return 0;
|
|
1523
|
-
let
|
|
1521
|
+
let r = 0;
|
|
1524
1522
|
if (!e || typeof e != "object")
|
|
1525
1523
|
return 0;
|
|
1526
1524
|
for (const i of Object.values(e))
|
|
@@ -1528,15 +1526,15 @@ Lt = new WeakSet(), ie = function() {
|
|
|
1528
1526
|
try {
|
|
1529
1527
|
if (typeof i.time == "function") {
|
|
1530
1528
|
const a = i.time();
|
|
1531
|
-
a && typeof a.operating == "number" && (
|
|
1529
|
+
a && typeof a.operating == "number" && (r = Math.max(r, a.operating));
|
|
1532
1530
|
}
|
|
1533
1531
|
} catch {
|
|
1534
1532
|
}
|
|
1535
|
-
|
|
1536
|
-
}, et = new WeakSet(),
|
|
1537
|
-
let
|
|
1533
|
+
r >= this.operatingThreshold && await y(this, Z, at).call(this);
|
|
1534
|
+
}, et = new WeakSet(), dt = async function(e, t) {
|
|
1535
|
+
let r = !1, i = e;
|
|
1538
1536
|
do
|
|
1539
|
-
|
|
1537
|
+
r = !1, await this.callBatchWithTimeout(i, async (a) => {
|
|
1540
1538
|
var f, n;
|
|
1541
1539
|
let c = !1;
|
|
1542
1540
|
const h = /* @__PURE__ */ new Set();
|
|
@@ -1551,7 +1549,7 @@ Lt = new WeakSet(), ie = function() {
|
|
|
1551
1549
|
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && h.add(u);
|
|
1552
1550
|
}
|
|
1553
1551
|
if (c) {
|
|
1554
|
-
|
|
1552
|
+
r = !0, await y(this, Z, at).call(this);
|
|
1555
1553
|
return;
|
|
1556
1554
|
}
|
|
1557
1555
|
if (h.size > 0) {
|
|
@@ -1562,41 +1560,53 @@ Lt = new WeakSet(), ie = function() {
|
|
|
1562
1560
|
const d = {};
|
|
1563
1561
|
for (const A of h)
|
|
1564
1562
|
i[A] && (d[A] = i[A]);
|
|
1565
|
-
i = d, Object.keys(i).length && (
|
|
1563
|
+
i = d, Object.keys(i).length && (r = !0, await y(this, Z, at).call(this));
|
|
1566
1564
|
return;
|
|
1567
1565
|
}
|
|
1568
1566
|
await t(a);
|
|
1569
1567
|
});
|
|
1570
|
-
while (
|
|
1571
|
-
},
|
|
1572
|
-
return new Promise((
|
|
1568
|
+
while (r);
|
|
1569
|
+
}, Ht = new WeakSet(), ue = function(e, t) {
|
|
1570
|
+
return new Promise((r) => {
|
|
1573
1571
|
if (typeof this.callMethod != "function") {
|
|
1574
|
-
|
|
1572
|
+
r(null);
|
|
1575
1573
|
return;
|
|
1576
1574
|
}
|
|
1577
1575
|
let i = !1;
|
|
1578
1576
|
const a = setTimeout(() => {
|
|
1579
|
-
i || (i = !0,
|
|
1577
|
+
i || (i = !0, r(null));
|
|
1580
1578
|
}, this.requestTimeoutMs);
|
|
1581
1579
|
try {
|
|
1582
1580
|
this.callMethod(e, t, (c) => {
|
|
1583
|
-
i || (i = !0, clearTimeout(a),
|
|
1581
|
+
i || (i = !0, clearTimeout(a), r(c));
|
|
1584
1582
|
});
|
|
1585
1583
|
} catch {
|
|
1586
|
-
i || (i = !0, clearTimeout(a),
|
|
1584
|
+
i || (i = !0, clearTimeout(a), r(null));
|
|
1587
1585
|
}
|
|
1588
1586
|
});
|
|
1589
|
-
},
|
|
1590
|
-
|
|
1587
|
+
}, Ut = new WeakSet(), fe = function(e) {
|
|
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(), c = typeof (t == null ? void 0 : t.toString) == "function" ? String(t.toString()).trim() : "";
|
|
1589
|
+
let h = a;
|
|
1590
|
+
return !h && c && c !== i && (h = c), h || (h = i || "Неизвестная ошибка"), {
|
|
1591
|
+
code: i || h,
|
|
1592
|
+
message: h
|
|
1593
|
+
};
|
|
1594
|
+
}, ct = new WeakSet(), Lt = function(e, t) {
|
|
1595
|
+
const { code: r, message: i } = y(this, Ut, fe).call(this, t);
|
|
1596
|
+
this.errors[e] = r, this.errorMessages[e] = i;
|
|
1597
|
+
}, gt = new WeakSet(), $t = function(e) {
|
|
1598
|
+
Object.entries(this.errors).length && (e.errorsList = { ...this.errors }, Object.entries(this.errorMessages).length && (e.errorsListMessages = { ...this.errorMessages }));
|
|
1599
|
+
}, pt = new WeakSet(), te = function(e) {
|
|
1600
|
+
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);
|
|
1591
1601
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1602
|
+
E(J, It, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1603
|
+
E(J, Dt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1604
|
+
E(J, kt, 8), E(J, wt, 0.65);
|
|
1595
1605
|
let K = J;
|
|
1596
|
-
var
|
|
1597
|
-
class
|
|
1606
|
+
var st;
|
|
1607
|
+
class de {
|
|
1598
1608
|
constructor() {
|
|
1599
|
-
|
|
1609
|
+
E(this, st, {});
|
|
1600
1610
|
}
|
|
1601
1611
|
/**
|
|
1602
1612
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1611,11 +1621,11 @@ class Ae {
|
|
|
1611
1621
|
* @returns {string}
|
|
1612
1622
|
*/
|
|
1613
1623
|
createHash(e) {
|
|
1614
|
-
let t = "abcdefghijklmnopqrstuvwxyz0123456789",
|
|
1624
|
+
let t = "abcdefghijklmnopqrstuvwxyz0123456789", r = "";
|
|
1615
1625
|
e = e || 6;
|
|
1616
1626
|
for (let i = 0; i < e; i++)
|
|
1617
|
-
|
|
1618
|
-
return
|
|
1627
|
+
r += t.charAt(Math.floor(Math.random() * t.length));
|
|
1628
|
+
return r;
|
|
1619
1629
|
}
|
|
1620
1630
|
/**
|
|
1621
1631
|
* Фильтр часто запускаемых действий (debounce)
|
|
@@ -1624,9 +1634,9 @@ class Ae {
|
|
|
1624
1634
|
* @param {number} params.duration - Задержка в миллисекундах (по умолчанию 10)
|
|
1625
1635
|
* @param {Function} params.action - Функция для выполнения
|
|
1626
1636
|
*/
|
|
1627
|
-
actionFilter({ keyTimer: e, duration: t = 10, action:
|
|
1628
|
-
|
|
1629
|
-
|
|
1637
|
+
actionFilter({ keyTimer: e, duration: t = 10, action: r }) {
|
|
1638
|
+
L(this, st)[e] && (clearTimeout(L(this, st)[e]), L(this, st)[e] = null), r && (L(this, st)[e] = setTimeout(() => {
|
|
1639
|
+
r();
|
|
1630
1640
|
}, t));
|
|
1631
1641
|
}
|
|
1632
1642
|
/**
|
|
@@ -1657,35 +1667,35 @@ class Ae {
|
|
|
1657
1667
|
* @param {string} filename - Имя файла без расширения
|
|
1658
1668
|
*/
|
|
1659
1669
|
downloadFileJson(e, t) {
|
|
1660
|
-
let
|
|
1670
|
+
let r = new Blob([JSON.stringify(e)], { type: "application/json" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1661
1671
|
a.style.display = "none", a.href = i, a.download = `${t}.json`, document.body.appendChild(a), a.click(), setTimeout(() => {
|
|
1662
1672
|
document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1663
1673
|
}, 200);
|
|
1664
1674
|
}
|
|
1665
1675
|
}
|
|
1666
|
-
|
|
1667
|
-
const
|
|
1668
|
-
var j, z,
|
|
1669
|
-
class
|
|
1676
|
+
st = new WeakMap();
|
|
1677
|
+
const Qt = new de();
|
|
1678
|
+
var j, z, rt, lt, yt, V, v, it, ht, Pt, me, Nt, ee, Gt, ge, Yt, pe, Wt, ye;
|
|
1679
|
+
class Ce {
|
|
1670
1680
|
constructor() {
|
|
1671
1681
|
/** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
|
|
1672
|
-
|
|
1682
|
+
E(this, Pt);
|
|
1673
1683
|
/** Вывод ошибок логера
|
|
1674
1684
|
* @param {'entity'} type - тип ошибки
|
|
1675
1685
|
*/
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1686
|
+
E(this, Nt);
|
|
1687
|
+
E(this, Gt);
|
|
1688
|
+
E(this, Yt);
|
|
1689
|
+
E(this, Wt);
|
|
1690
|
+
E(this, j, "logger");
|
|
1691
|
+
E(this, z, !1);
|
|
1692
|
+
E(this, rt, /* @__PURE__ */ new Map());
|
|
1693
|
+
E(this, lt, {});
|
|
1694
|
+
E(this, yt, !1);
|
|
1695
|
+
E(this, V, null);
|
|
1696
|
+
E(this, v, null);
|
|
1697
|
+
E(this, it, !1);
|
|
1698
|
+
E(this, ht, !1);
|
|
1689
1699
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1690
1700
|
w(this, "periodClear", 3);
|
|
1691
1701
|
}
|
|
@@ -1697,7 +1707,7 @@ class Se {
|
|
|
1697
1707
|
});
|
|
1698
1708
|
if (t && Array.isArray(t))
|
|
1699
1709
|
if (t.find(
|
|
1700
|
-
(i) => i.ENTITY ==
|
|
1710
|
+
(i) => i.ENTITY == L(this, j)
|
|
1701
1711
|
))
|
|
1702
1712
|
x(this, z, !0);
|
|
1703
1713
|
else {
|
|
@@ -1705,15 +1715,15 @@ class Se {
|
|
|
1705
1715
|
entityAdd: {
|
|
1706
1716
|
method: "entity.add",
|
|
1707
1717
|
params: {
|
|
1708
|
-
ENTITY:
|
|
1709
|
-
NAME:
|
|
1718
|
+
ENTITY: L(this, j),
|
|
1719
|
+
NAME: L(this, j),
|
|
1710
1720
|
ACCESS: { AU: "X" }
|
|
1711
1721
|
}
|
|
1712
1722
|
}
|
|
1713
1723
|
});
|
|
1714
1724
|
i && x(this, z, !0);
|
|
1715
1725
|
}
|
|
1716
|
-
return
|
|
1726
|
+
return L(this, z);
|
|
1717
1727
|
} catch (e) {
|
|
1718
1728
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1719
1729
|
}
|
|
@@ -1735,11 +1745,11 @@ class Se {
|
|
|
1735
1745
|
* @returns {string|null}
|
|
1736
1746
|
*/
|
|
1737
1747
|
start({ type: e, data: t }) {
|
|
1738
|
-
if (!
|
|
1739
|
-
return
|
|
1748
|
+
if (!L(this, z))
|
|
1749
|
+
return y(this, Nt, ee).call(this, "entity"), null;
|
|
1740
1750
|
if (!e || !t)
|
|
1741
1751
|
return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
|
|
1742
|
-
const
|
|
1752
|
+
const r = Qt.hash, i = {
|
|
1743
1753
|
type: e,
|
|
1744
1754
|
data: t,
|
|
1745
1755
|
userInfo: null,
|
|
@@ -1748,7 +1758,7 @@ class Se {
|
|
|
1748
1758
|
answer: null,
|
|
1749
1759
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1750
1760
|
};
|
|
1751
|
-
return
|
|
1761
|
+
return L(this, rt).set(r, i), x(this, ht, !0), r;
|
|
1752
1762
|
}
|
|
1753
1763
|
/**
|
|
1754
1764
|
* @param {{
|
|
@@ -1757,20 +1767,20 @@ class Se {
|
|
|
1757
1767
|
* status: 'success'|'fail'|'fail-runtime',
|
|
1758
1768
|
* answer: { [key]: unknown } }}
|
|
1759
1769
|
*/
|
|
1760
|
-
async stop({ key: e, errorList: t, status:
|
|
1770
|
+
async stop({ key: e, errorList: t, status: r, answer: i }) {
|
|
1761
1771
|
var c;
|
|
1762
|
-
if (!
|
|
1772
|
+
if (!L(this, ht))
|
|
1763
1773
|
return;
|
|
1764
|
-
if (!
|
|
1765
|
-
|
|
1774
|
+
if (!L(this, z)) {
|
|
1775
|
+
y(this, Nt, ee).call(this, "entity");
|
|
1766
1776
|
return;
|
|
1767
1777
|
}
|
|
1768
|
-
let a =
|
|
1778
|
+
let a = L(this, rt).get(e);
|
|
1769
1779
|
if (!a) {
|
|
1770
1780
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1771
1781
|
return;
|
|
1772
1782
|
}
|
|
1773
|
-
t && (a.errorList = t),
|
|
1783
|
+
t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await y(this, Pt, me).call(this), a.userInfo = L(this, lt), await y(this, Gt, ge).call(this), (c = a == null ? void 0 : a.data) != null && c.updateList && x(this, it, !0), x(this, ht, !1);
|
|
1774
1784
|
}
|
|
1775
1785
|
/**
|
|
1776
1786
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
@@ -1778,14 +1788,14 @@ class Se {
|
|
|
1778
1788
|
async getEntityList(e) {
|
|
1779
1789
|
var t;
|
|
1780
1790
|
try {
|
|
1781
|
-
if ((t =
|
|
1782
|
-
return
|
|
1783
|
-
let
|
|
1791
|
+
if ((t = L(this, v)) != null && t.length && !L(this, it))
|
|
1792
|
+
return L(this, v);
|
|
1793
|
+
let r = new K(BX24.callBatch), { entityList: i } = await r.batch(
|
|
1784
1794
|
{
|
|
1785
1795
|
entityList: {
|
|
1786
1796
|
method: "entity.item.get",
|
|
1787
1797
|
params: {
|
|
1788
|
-
ENTITY:
|
|
1798
|
+
ENTITY: L(this, j),
|
|
1789
1799
|
SORT: { ID: "DESC" }
|
|
1790
1800
|
}
|
|
1791
1801
|
}
|
|
@@ -1807,8 +1817,8 @@ class Se {
|
|
|
1807
1817
|
), null;
|
|
1808
1818
|
}
|
|
1809
1819
|
}).filter((a) => a !== null), x(this, it, !1), x(this, v, i), i);
|
|
1810
|
-
} catch (
|
|
1811
|
-
return console.error("Ошибка при получении списка записей:",
|
|
1820
|
+
} catch (r) {
|
|
1821
|
+
return console.error("Ошибка при получении списка записей:", r), [];
|
|
1812
1822
|
}
|
|
1813
1823
|
}
|
|
1814
1824
|
/**
|
|
@@ -1816,16 +1826,16 @@ class Se {
|
|
|
1816
1826
|
* Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
|
|
1817
1827
|
*/
|
|
1818
1828
|
runStorageMaintenance() {
|
|
1819
|
-
return
|
|
1829
|
+
return y(this, Yt, pe).call(this);
|
|
1820
1830
|
}
|
|
1821
1831
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1822
1832
|
async downAllEntityJson() {
|
|
1823
1833
|
try {
|
|
1824
|
-
if (
|
|
1834
|
+
if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
|
|
1825
1835
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1826
|
-
let e =
|
|
1827
|
-
return
|
|
1828
|
-
|
|
1836
|
+
let e = bt().format("%Y-%m-%d");
|
|
1837
|
+
return Qt.downloadFileJson(
|
|
1838
|
+
L(this, v),
|
|
1829
1839
|
`sdklogger-entity-data__${e}`
|
|
1830
1840
|
), !0;
|
|
1831
1841
|
} catch (e) {
|
|
@@ -1833,57 +1843,57 @@ class Se {
|
|
|
1833
1843
|
}
|
|
1834
1844
|
}
|
|
1835
1845
|
}
|
|
1836
|
-
j = new WeakMap(), z = new WeakMap(),
|
|
1837
|
-
if (!
|
|
1838
|
-
return
|
|
1846
|
+
j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt = new WeakMap(), V = new WeakMap(), v = new WeakMap(), it = new WeakMap(), ht = new WeakMap(), Pt = new WeakSet(), me = async function() {
|
|
1847
|
+
if (!L(this, yt))
|
|
1848
|
+
return L(this, V) ? L(this, V) : (x(this, V, (async () => {
|
|
1839
1849
|
try {
|
|
1840
|
-
const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser:
|
|
1850
|
+
const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser: r } = await e.batch({
|
|
1841
1851
|
curUser: { method: "user.current" }
|
|
1842
1852
|
});
|
|
1843
|
-
x(this,
|
|
1853
|
+
x(this, lt, { isAdmin: t, curUser: r });
|
|
1844
1854
|
} catch (e) {
|
|
1845
1855
|
console.error(
|
|
1846
1856
|
"Ошибка при получении информации о пользователе:",
|
|
1847
1857
|
e
|
|
1848
|
-
), x(this,
|
|
1858
|
+
), x(this, lt, { isAdmin: !1, curUser: null });
|
|
1849
1859
|
} finally {
|
|
1850
|
-
x(this,
|
|
1860
|
+
x(this, yt, !0), x(this, V, null);
|
|
1851
1861
|
}
|
|
1852
|
-
})()),
|
|
1853
|
-
},
|
|
1854
|
-
e == "entity" &&
|
|
1862
|
+
})()), L(this, V));
|
|
1863
|
+
}, Nt = new WeakSet(), ee = function(e) {
|
|
1864
|
+
e == "entity" && Qt.actionFilter({
|
|
1855
1865
|
keyTimer: "error.logger.entity",
|
|
1856
1866
|
duration: 500,
|
|
1857
1867
|
action: () => {
|
|
1858
1868
|
console.error("Хранилище для логгера не инициализировано");
|
|
1859
1869
|
}
|
|
1860
1870
|
});
|
|
1861
|
-
},
|
|
1871
|
+
}, Gt = new WeakSet(), ge = async function() {
|
|
1862
1872
|
try {
|
|
1863
1873
|
let e = {}, t = new K(BX24.callBatch);
|
|
1864
|
-
for (let [
|
|
1874
|
+
for (let [r, i] of L(this, rt).entries())
|
|
1865
1875
|
if (i.status) {
|
|
1866
1876
|
const a = JSON.stringify(i);
|
|
1867
|
-
e[
|
|
1877
|
+
e[r] = {
|
|
1868
1878
|
method: "entity.item.add",
|
|
1869
1879
|
params: {
|
|
1870
|
-
ENTITY:
|
|
1871
|
-
NAME:
|
|
1880
|
+
ENTITY: L(this, j),
|
|
1881
|
+
NAME: L(this, j),
|
|
1872
1882
|
DETAIL_TEXT: a
|
|
1873
1883
|
}
|
|
1874
1884
|
};
|
|
1875
1885
|
}
|
|
1876
1886
|
if (Object.keys(e).length) {
|
|
1877
|
-
let
|
|
1878
|
-
for (let [a, c] of Object.entries({ ...
|
|
1879
|
-
|
|
1887
|
+
let r = await t.batch(e), { errors: i } = t;
|
|
1888
|
+
for (let [a, c] of Object.entries({ ...r, ...i }))
|
|
1889
|
+
L(this, rt).delete(a);
|
|
1880
1890
|
return !0;
|
|
1881
1891
|
}
|
|
1882
1892
|
return !1;
|
|
1883
1893
|
} catch (e) {
|
|
1884
1894
|
return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
|
|
1885
1895
|
}
|
|
1886
|
-
},
|
|
1896
|
+
}, Yt = new WeakSet(), pe = async function() {
|
|
1887
1897
|
try {
|
|
1888
1898
|
let e = new K(BX24.callBatch), { serverTime: t } = await e.batch({
|
|
1889
1899
|
serverTime: { method: "server.time" }
|
|
@@ -1892,77 +1902,77 @@ j = new WeakMap(), z = new WeakMap(), st = new WeakMap(), ct = new WeakMap(), gt
|
|
|
1892
1902
|
console.error("Не удалось получить время сервера");
|
|
1893
1903
|
return;
|
|
1894
1904
|
}
|
|
1895
|
-
if (
|
|
1905
|
+
if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
|
|
1896
1906
|
return;
|
|
1897
|
-
let
|
|
1907
|
+
let r = L(this, v).filter((i) => {
|
|
1898
1908
|
try {
|
|
1899
1909
|
let { dateCreate: a } = i;
|
|
1900
|
-
return a ?
|
|
1901
|
-
|
|
1910
|
+
return a ? bt(new Date(a)).between(
|
|
1911
|
+
bt(new Date(t)),
|
|
1902
1912
|
"month"
|
|
1903
1913
|
) >= this.periodClear : !1;
|
|
1904
1914
|
} catch (a) {
|
|
1905
1915
|
return console.error("Ошибка при проверке даты записи:", a), !1;
|
|
1906
1916
|
}
|
|
1907
1917
|
});
|
|
1908
|
-
|
|
1909
|
-
`Найдено ${
|
|
1910
|
-
), await
|
|
1918
|
+
r.length > 0 && (console.log(
|
|
1919
|
+
`Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1920
|
+
), await y(this, Wt, ye).call(this, r));
|
|
1911
1921
|
} catch (e) {
|
|
1912
1922
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1913
1923
|
}
|
|
1914
|
-
},
|
|
1924
|
+
}, Wt = new WeakSet(), ye = async function(e) {
|
|
1915
1925
|
try {
|
|
1916
1926
|
if (!e || e.length === 0)
|
|
1917
1927
|
return !1;
|
|
1918
|
-
let t = new K(BX24.callBatch),
|
|
1928
|
+
let t = new K(BX24.callBatch), r = e.filter((a) => a && a.id).map((a) => {
|
|
1919
1929
|
let { id: c } = a;
|
|
1920
1930
|
return {
|
|
1921
1931
|
method: "entity.item.delete",
|
|
1922
1932
|
params: {
|
|
1923
|
-
ENTITY:
|
|
1933
|
+
ENTITY: L(this, j),
|
|
1924
1934
|
ID: c
|
|
1925
1935
|
}
|
|
1926
1936
|
};
|
|
1927
1937
|
});
|
|
1928
|
-
if (
|
|
1938
|
+
if (r.length === 0)
|
|
1929
1939
|
return !1;
|
|
1930
|
-
const i = await t.batch(
|
|
1931
|
-
return console.log(`Успешно удалено ${
|
|
1940
|
+
const i = await t.batch(r);
|
|
1941
|
+
return console.log(`Успешно удалено ${r.length} записей`), x(this, it, !0), i;
|
|
1932
1942
|
} catch (t) {
|
|
1933
1943
|
return console.error("Ошибка при очистке устаревших записей:", t), !1;
|
|
1934
1944
|
}
|
|
1935
1945
|
};
|
|
1936
|
-
function
|
|
1937
|
-
if (!
|
|
1946
|
+
function oe(m) {
|
|
1947
|
+
if (!m || typeof m != "string")
|
|
1938
1948
|
return "";
|
|
1939
1949
|
try {
|
|
1940
|
-
const e = new URL(
|
|
1950
|
+
const e = new URL(m);
|
|
1941
1951
|
e.search = "", e.hash = "";
|
|
1942
1952
|
let t = e.toString();
|
|
1943
1953
|
return t.endsWith("/") && e.pathname !== "/" && (t = t.slice(0, -1)), t;
|
|
1944
1954
|
} catch {
|
|
1945
|
-
return
|
|
1955
|
+
return m.split("?")[0].split("#")[0].replace(/\/$/, "");
|
|
1946
1956
|
}
|
|
1947
1957
|
}
|
|
1948
|
-
function
|
|
1949
|
-
return !
|
|
1958
|
+
function Ne(m) {
|
|
1959
|
+
return !m || typeof m != "string" ? !1 : m.toLowerCase().includes("/marketplace/app");
|
|
1950
1960
|
}
|
|
1951
|
-
function
|
|
1961
|
+
function He() {
|
|
1952
1962
|
var e;
|
|
1953
1963
|
if (typeof window > "u" || !((e = window.location) != null && e.href))
|
|
1954
1964
|
return "";
|
|
1955
|
-
const
|
|
1956
|
-
return
|
|
1965
|
+
const m = oe(window.location.href);
|
|
1966
|
+
return Ne(m) ? "" : m;
|
|
1957
1967
|
}
|
|
1958
|
-
function
|
|
1959
|
-
if (!(
|
|
1968
|
+
function se(m) {
|
|
1969
|
+
if (!(m != null && m.appConst) || typeof m.appConst != "object")
|
|
1960
1970
|
return "";
|
|
1961
|
-
const e =
|
|
1962
|
-
return e ? (
|
|
1971
|
+
const e = He();
|
|
1972
|
+
return e ? (m.appConst.pathApp = e, e) : oe(m.appConst.pathApp ?? "");
|
|
1963
1973
|
}
|
|
1964
|
-
var
|
|
1965
|
-
class
|
|
1974
|
+
var ut, Rt, xt, Oe, Ot, re, Ft, _e, vt, Te, Xt, Ee, $, ot, _t, ie, Jt, be, Tt, ne, jt, Me;
|
|
1975
|
+
class ve {
|
|
1966
1976
|
/**
|
|
1967
1977
|
* @param {Object} appConst - Константы приложения
|
|
1968
1978
|
* @param {string} appConst.appName - Название приложения
|
|
@@ -1975,24 +1985,24 @@ class Pe {
|
|
|
1975
1985
|
*
|
|
1976
1986
|
* @returns {Batch} Shared Batch instance.
|
|
1977
1987
|
*/
|
|
1978
|
-
|
|
1979
|
-
|
|
1988
|
+
E(this, ut);
|
|
1989
|
+
E(this, xt);
|
|
1980
1990
|
/**
|
|
1981
1991
|
* `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
|
|
1982
1992
|
* иначе — заглушка.
|
|
1983
1993
|
* @param {boolean} runLoggerMaintenance
|
|
1984
1994
|
*/
|
|
1985
|
-
|
|
1995
|
+
E(this, Ot);
|
|
1986
1996
|
/**
|
|
1987
1997
|
* @returns {boolean}
|
|
1988
1998
|
*/
|
|
1989
|
-
|
|
1999
|
+
E(this, Ft);
|
|
1990
2000
|
/** Запрос данных о приложении */
|
|
1991
|
-
|
|
2001
|
+
E(this, vt);
|
|
1992
2002
|
/** Запрос данных о текущем пользователе */
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
2003
|
+
E(this, Xt);
|
|
2004
|
+
E(this, $);
|
|
2005
|
+
E(this, _t);
|
|
1996
2006
|
/**
|
|
1997
2007
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1998
2008
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -2002,17 +2012,17 @@ class Pe {
|
|
|
2002
2012
|
* @param {Array} updateList - Список обновлений для логирования (опционально)
|
|
2003
2013
|
* @returns {Object} Расширенный список ошибок
|
|
2004
2014
|
*/
|
|
2005
|
-
|
|
2015
|
+
E(this, Jt);
|
|
2006
2016
|
/**
|
|
2007
2017
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
2008
2018
|
* @private
|
|
2009
2019
|
*/
|
|
2010
|
-
|
|
2020
|
+
E(this, Tt);
|
|
2011
2021
|
/**
|
|
2012
2022
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
2013
2023
|
* @private
|
|
2014
2024
|
*/
|
|
2015
|
-
|
|
2025
|
+
E(this, jt);
|
|
2016
2026
|
w(this, "domain", "");
|
|
2017
2027
|
w(this, "isAdmin", !1);
|
|
2018
2028
|
w(this, "appInfo", null);
|
|
@@ -2036,7 +2046,7 @@ class Pe {
|
|
|
2036
2046
|
* @returns {() => void} Функция отписки.
|
|
2037
2047
|
*/
|
|
2038
2048
|
subscribeTimeLimit(e) {
|
|
2039
|
-
return
|
|
2049
|
+
return y(this, ut, Rt).call(this).subscribeTimeLimit(e);
|
|
2040
2050
|
}
|
|
2041
2051
|
/**
|
|
2042
2052
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2060,16 +2070,16 @@ class Pe {
|
|
|
2060
2070
|
let a = setInterval(() => {
|
|
2061
2071
|
window.BX24 && BX24.init(async () => {
|
|
2062
2072
|
clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
|
|
2063
|
-
const c =
|
|
2073
|
+
const c = y(this, Ft, _e).call(this);
|
|
2064
2074
|
if (console.info(
|
|
2065
2075
|
c ? "init BX24 (background worker)" : "init BX24"
|
|
2066
|
-
), this.appInfo = await
|
|
2067
|
-
await
|
|
2076
|
+
), this.appInfo = await y(this, vt, Te).call(this), this.userInfo = await y(this, Xt, Ee).call(this), se(this), c)
|
|
2077
|
+
await y(this, Ot, re).call(this, !1, {
|
|
2068
2078
|
skipInit: !0
|
|
2069
2079
|
});
|
|
2070
2080
|
else {
|
|
2071
|
-
await
|
|
2072
|
-
const h = new
|
|
2081
|
+
await y(this, Ot, re).call(this, !0);
|
|
2082
|
+
const h = new de();
|
|
2073
2083
|
try {
|
|
2074
2084
|
h.noSleep();
|
|
2075
2085
|
} catch (f) {
|
|
@@ -2126,20 +2136,20 @@ class Pe {
|
|
|
2126
2136
|
* }[]
|
|
2127
2137
|
* }[]
|
|
2128
2138
|
*/
|
|
2129
|
-
async call({ method: e, params: t, updateList:
|
|
2139
|
+
async call({ method: e, params: t, updateList: r }) {
|
|
2130
2140
|
let i;
|
|
2131
|
-
if (
|
|
2141
|
+
if (r && (i = this.logger.start({
|
|
2132
2142
|
type: "call",
|
|
2133
|
-
data: { method: e, params: t, updateList:
|
|
2143
|
+
data: { method: e, params: t, updateList: r }
|
|
2134
2144
|
})), t || (t = {}), typeof BX24 > "u" || !BX24.callMethod) {
|
|
2135
2145
|
const h = new Error("BX24 is not initialized");
|
|
2136
2146
|
throw console.error(h), h;
|
|
2137
2147
|
}
|
|
2138
|
-
const c = await
|
|
2139
|
-
return c.success ? (await
|
|
2148
|
+
const c = await y(this, ut, Rt).call(this).call({ method: e, params: t });
|
|
2149
|
+
return c.success ? (await y(this, $, ot).call(this, i, {
|
|
2140
2150
|
answer: c.answer,
|
|
2141
2151
|
status: "success"
|
|
2142
|
-
}), c.data) : (console.error(c.error), await
|
|
2152
|
+
}), c.data) : (console.error(c.error), await y(this, $, ot).call(this, i, {
|
|
2143
2153
|
answer: c.answer,
|
|
2144
2154
|
status: "fail",
|
|
2145
2155
|
errorList: { 0: c.error || "Unknown call error" }
|
|
@@ -2164,16 +2174,16 @@ class Pe {
|
|
|
2164
2174
|
* }[]
|
|
2165
2175
|
* }}
|
|
2166
2176
|
*/
|
|
2167
|
-
async batch(e, t, { errorCall:
|
|
2177
|
+
async batch(e, t, { errorCall: r, updateList: i, batchOptions: a } = {}) {
|
|
2168
2178
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2169
2179
|
const c = new Error("BX24 is not initialized");
|
|
2170
2180
|
return console.error(c), !1;
|
|
2171
2181
|
}
|
|
2172
|
-
return
|
|
2182
|
+
return y(this, _t, ie).call(this, {
|
|
2173
2183
|
mode: "batch",
|
|
2174
2184
|
commandList: e,
|
|
2175
2185
|
progressCall: t,
|
|
2176
|
-
errorCall:
|
|
2186
|
+
errorCall: r,
|
|
2177
2187
|
updateList: i,
|
|
2178
2188
|
batchOptions: a
|
|
2179
2189
|
});
|
|
@@ -2200,16 +2210,16 @@ class Pe {
|
|
|
2200
2210
|
* }}
|
|
2201
2211
|
* @returns {Promise<Object|false>}
|
|
2202
2212
|
*/
|
|
2203
|
-
async batchTotalCount(e, t, { errorCall:
|
|
2213
|
+
async batchTotalCount(e, t, { errorCall: r, updateList: i } = {}) {
|
|
2204
2214
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2205
2215
|
const a = new Error("BX24 is not initialized");
|
|
2206
2216
|
return console.error(a), !1;
|
|
2207
2217
|
}
|
|
2208
|
-
return
|
|
2218
|
+
return y(this, _t, ie).call(this, {
|
|
2209
2219
|
mode: "batch-total-count",
|
|
2210
2220
|
commandList: e,
|
|
2211
2221
|
progressCall: t,
|
|
2212
|
-
errorCall:
|
|
2222
|
+
errorCall: r,
|
|
2213
2223
|
updateList: i
|
|
2214
2224
|
});
|
|
2215
2225
|
}
|
|
@@ -2226,12 +2236,12 @@ class Pe {
|
|
|
2226
2236
|
var A;
|
|
2227
2237
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2228
2238
|
return;
|
|
2229
|
-
const { appName: t, pathApp:
|
|
2230
|
-
let i =
|
|
2239
|
+
const { appName: t, pathApp: r } = this.appConst;
|
|
2240
|
+
let i = y(this, Tt, ne).call(this, e);
|
|
2231
2241
|
i = i.filter(
|
|
2232
2242
|
(l) => l.placement !== "PAGE_BACKGROUND_WORKER" && l.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2233
2243
|
);
|
|
2234
|
-
const a =
|
|
2244
|
+
const a = y(this, jt, Me).call(this, r), c = new Set(i.map((l) => l.placement));
|
|
2235
2245
|
for (const l of a)
|
|
2236
2246
|
c.has(l.placement) || i.push({ placement: l.placement });
|
|
2237
2247
|
if (i.length === 0)
|
|
@@ -2242,32 +2252,32 @@ class Pe {
|
|
|
2242
2252
|
for (const l of this.placeData)
|
|
2243
2253
|
d.has(l.placement) || d.set(l.placement, []), d.get(l.placement).push(l);
|
|
2244
2254
|
for (let l = 0; l < i.length; l++) {
|
|
2245
|
-
const { placement:
|
|
2246
|
-
if (
|
|
2247
|
-
(
|
|
2255
|
+
const { placement: O, options: _ } = i[l], b = d.get(O) || [];
|
|
2256
|
+
if (b.some(
|
|
2257
|
+
(M) => M.handler === r
|
|
2248
2258
|
))
|
|
2249
2259
|
continue;
|
|
2250
|
-
const
|
|
2251
|
-
(
|
|
2260
|
+
const T = b.filter(
|
|
2261
|
+
(M) => M.handler !== r
|
|
2252
2262
|
);
|
|
2253
|
-
for (const
|
|
2263
|
+
for (const M of T)
|
|
2254
2264
|
u.push({
|
|
2255
|
-
placement:
|
|
2256
|
-
handler:
|
|
2265
|
+
placement: O,
|
|
2266
|
+
handler: M.handler
|
|
2257
2267
|
});
|
|
2258
2268
|
n[`bind_${l}`] = {
|
|
2259
2269
|
method: "placement.bind",
|
|
2260
2270
|
params: {
|
|
2261
|
-
PLACEMENT:
|
|
2262
|
-
HANDLER:
|
|
2271
|
+
PLACEMENT: O,
|
|
2272
|
+
HANDLER: r,
|
|
2263
2273
|
LANG_ALL: {
|
|
2264
2274
|
ru: {
|
|
2265
|
-
TITLE:
|
|
2275
|
+
TITLE: O === "USER_PROFILE_TOOLBAR" ? f : h
|
|
2266
2276
|
}
|
|
2267
2277
|
},
|
|
2268
2278
|
OPTIONS: {
|
|
2269
|
-
errorHandlerUrl:
|
|
2270
|
-
...
|
|
2279
|
+
errorHandlerUrl: r,
|
|
2280
|
+
..._ && typeof _ == "object" ? _ : {}
|
|
2271
2281
|
}
|
|
2272
2282
|
}
|
|
2273
2283
|
};
|
|
@@ -2281,22 +2291,22 @@ class Pe {
|
|
|
2281
2291
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2282
2292
|
*/
|
|
2283
2293
|
async placementUnBind(e) {
|
|
2284
|
-
let t =
|
|
2294
|
+
let t = y(this, Tt, ne).call(this, e);
|
|
2285
2295
|
if (t = t.filter(
|
|
2286
2296
|
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2287
2297
|
), t.length === 0)
|
|
2288
2298
|
return;
|
|
2289
|
-
const
|
|
2299
|
+
const r = {};
|
|
2290
2300
|
for (let i = 0; i < t.length; i++) {
|
|
2291
2301
|
const a = {
|
|
2292
2302
|
PLACEMENT: t[i].placement
|
|
2293
2303
|
};
|
|
2294
|
-
t[i].handler && (a.HANDLER = t[i].handler),
|
|
2304
|
+
t[i].handler && (a.HANDLER = t[i].handler), r[`unbind_${i}`] = {
|
|
2295
2305
|
method: "placement.unbind",
|
|
2296
2306
|
params: a
|
|
2297
2307
|
};
|
|
2298
2308
|
}
|
|
2299
|
-
await this.batch(
|
|
2309
|
+
await this.batch(r), t.forEach((i) => {
|
|
2300
2310
|
console.log("Встройка отвязана", i.placement);
|
|
2301
2311
|
});
|
|
2302
2312
|
}
|
|
@@ -2310,7 +2320,7 @@ class Pe {
|
|
|
2310
2320
|
return console.log("chat-bot list:", t), t;
|
|
2311
2321
|
}
|
|
2312
2322
|
/* регистрация бота */
|
|
2313
|
-
async regBot({ code: e, type: t, name:
|
|
2323
|
+
async regBot({ code: e, type: t, name: r }) {
|
|
2314
2324
|
const { appName: i, pathApp: a, chatBotLogo: c } = this.appConst, h = this.appInfo.ID, f = await this.call({
|
|
2315
2325
|
method: "imbot.register",
|
|
2316
2326
|
params: {
|
|
@@ -2326,7 +2336,7 @@ class Pe {
|
|
|
2326
2336
|
// строковый идентификатор чат-бота, используется только в режиме Вебхуков
|
|
2327
2337
|
PROPERTIES: {
|
|
2328
2338
|
// Личные данные чат-бота (обяз.)
|
|
2329
|
-
NAME: `${
|
|
2339
|
+
NAME: `${r ?? i} - бот #${h}`,
|
|
2330
2340
|
// Имя чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
2331
2341
|
LAST_NAME: "",
|
|
2332
2342
|
// Фамилия чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
@@ -2334,7 +2344,7 @@ class Pe {
|
|
|
2334
2344
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
2335
2345
|
EMAIL: "",
|
|
2336
2346
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
2337
|
-
PERSONAL_BIRTHDAY:
|
|
2347
|
+
PERSONAL_BIRTHDAY: bt().format("%Y-%m-%d"),
|
|
2338
2348
|
// День рождения в формате YYYY-mm-dd
|
|
2339
2349
|
WORK_POSITION: "Почтальон",
|
|
2340
2350
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -2364,12 +2374,12 @@ class Pe {
|
|
|
2364
2374
|
return this.logger.getEntityList(e);
|
|
2365
2375
|
}
|
|
2366
2376
|
}
|
|
2367
|
-
|
|
2377
|
+
ut = new WeakSet(), Rt = function() {
|
|
2368
2378
|
return this.batchClient || (this.batchClient = new K({
|
|
2369
2379
|
callBatch: BX24.callBatch,
|
|
2370
2380
|
callMethod: BX24.callMethod
|
|
2371
2381
|
}), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
|
|
2372
|
-
},
|
|
2382
|
+
}, xt = new WeakSet(), Oe = function() {
|
|
2373
2383
|
return {
|
|
2374
2384
|
start: () => {
|
|
2375
2385
|
},
|
|
@@ -2378,15 +2388,15 @@ ht = new WeakSet(), bt = function() {
|
|
|
2378
2388
|
getEntityList: () => {
|
|
2379
2389
|
}
|
|
2380
2390
|
};
|
|
2381
|
-
},
|
|
2382
|
-
this.logger ? (this.logger = new
|
|
2383
|
-
},
|
|
2384
|
-
var
|
|
2385
|
-
const e = (
|
|
2391
|
+
}, Ot = new WeakSet(), re = async function(e, { skipInit: t = !1 } = {}) {
|
|
2392
|
+
this.logger ? (this.logger = new Ce(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = y(this, xt, Oe).call(this);
|
|
2393
|
+
}, Ft = new WeakSet(), _e = function() {
|
|
2394
|
+
var r, i, a;
|
|
2395
|
+
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;
|
|
2386
2396
|
return e === "PAGE_BACKGROUND_WORKER" || t === "PAGE_BACKGROUND_WORKER";
|
|
2387
|
-
},
|
|
2397
|
+
}, vt = new WeakSet(), Te = function() {
|
|
2388
2398
|
return this.call({ method: "app.info" });
|
|
2389
|
-
},
|
|
2399
|
+
}, Xt = new WeakSet(), Ee = function() {
|
|
2390
2400
|
return this.call({ method: "user.current" });
|
|
2391
2401
|
}, $ = new WeakSet(), ot = async function(e, t) {
|
|
2392
2402
|
if (e)
|
|
@@ -2395,34 +2405,34 @@ ht = new WeakSet(), bt = function() {
|
|
|
2395
2405
|
key: e,
|
|
2396
2406
|
...t
|
|
2397
2407
|
});
|
|
2398
|
-
} catch (
|
|
2399
|
-
console.error("Logger error:",
|
|
2408
|
+
} catch (r) {
|
|
2409
|
+
console.error("Logger error:", r);
|
|
2400
2410
|
}
|
|
2401
|
-
},
|
|
2411
|
+
}, _t = new WeakSet(), ie = async function({
|
|
2402
2412
|
mode: e,
|
|
2403
2413
|
commandList: t,
|
|
2404
|
-
progressCall:
|
|
2414
|
+
progressCall: r,
|
|
2405
2415
|
errorCall: i,
|
|
2406
2416
|
updateList: a,
|
|
2407
2417
|
batchOptions: c
|
|
2408
2418
|
}) {
|
|
2409
|
-
const h =
|
|
2419
|
+
const h = y(this, ut, Rt).call(this), f = a ? this.logger.start({
|
|
2410
2420
|
type: e,
|
|
2411
2421
|
data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
|
|
2412
2422
|
}) : void 0;
|
|
2413
2423
|
try {
|
|
2414
|
-
const n = e === "batch" ? await h.batch(t,
|
|
2415
|
-
return Object.keys(u).length ? (i && i(u), await
|
|
2424
|
+
const n = e === "batch" ? await h.batch(t, r, c) : await h.batchTotalCount(t, r), u = y(this, Jt, be).call(this, h, n, t, a);
|
|
2425
|
+
return Object.keys(u).length ? (i && i(u), await y(this, $, ot).call(this, f, {
|
|
2416
2426
|
status: "fail",
|
|
2417
2427
|
errorList: u
|
|
2418
|
-
})) : await
|
|
2428
|
+
})) : await y(this, $, ot).call(this, f, { status: "success" }), n;
|
|
2419
2429
|
} catch (n) {
|
|
2420
|
-
return await
|
|
2430
|
+
return await y(this, $, ot).call(this, f, {
|
|
2421
2431
|
status: "fail-runtime",
|
|
2422
2432
|
errorList: { 0: n == null ? void 0 : n.toString() }
|
|
2423
2433
|
}), console.error(n), !1;
|
|
2424
2434
|
}
|
|
2425
|
-
},
|
|
2435
|
+
}, Jt = new WeakSet(), be = function(e, t, r, i) {
|
|
2426
2436
|
let a = { ...e.errors };
|
|
2427
2437
|
if (Object.values(e.errors).some(
|
|
2428
2438
|
(h) => {
|
|
@@ -2432,7 +2442,9 @@ ht = new WeakSet(), bt = function() {
|
|
|
2432
2442
|
return f === "TIMEOUT" || f === "OPERATION_TIME_LIMIT" || f.includes("TIMEOUT") || f.includes("OPERATION_TIME_LIMIT");
|
|
2433
2443
|
}
|
|
2434
2444
|
) && i) {
|
|
2435
|
-
const h = t ? Object.keys(t).filter(
|
|
2445
|
+
const h = t ? Object.keys(t).filter(
|
|
2446
|
+
(d) => d !== "errorsList" && d !== "errorsListMessages"
|
|
2447
|
+
) : [], f = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
|
|
2436
2448
|
if (t) {
|
|
2437
2449
|
for (const d of h)
|
|
2438
2450
|
if (!f.has(d)) {
|
|
@@ -2448,63 +2460,63 @@ ht = new WeakSet(), bt = function() {
|
|
|
2448
2460
|
return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
|
|
2449
2461
|
}
|
|
2450
2462
|
);
|
|
2451
|
-
for (const d of Object.keys(
|
|
2463
|
+
for (const d of Object.keys(r))
|
|
2452
2464
|
!n.has(d) && !e.errors[d] && (a[d] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2453
2465
|
}
|
|
2454
2466
|
return a;
|
|
2455
|
-
},
|
|
2467
|
+
}, Tt = new WeakSet(), ne = function(e) {
|
|
2456
2468
|
if (!e)
|
|
2457
2469
|
return [];
|
|
2458
2470
|
let t = [];
|
|
2459
2471
|
return Array.isArray(e) ? t = e.map(
|
|
2460
|
-
(
|
|
2472
|
+
(r) => typeof r == "string" ? { placement: r } : r
|
|
2461
2473
|
) : typeof e == "string" ? t = [{ placement: e }] : t = [e], t;
|
|
2462
|
-
},
|
|
2474
|
+
}, jt = new WeakSet(), Me = function(e) {
|
|
2463
2475
|
return this.placeData ? this.placeData.filter((t) => !(t.placement === "PAGE_BACKGROUND_WORKER" || !t.handler || t.handler.includes(e))) : [];
|
|
2464
2476
|
};
|
|
2465
|
-
const
|
|
2466
|
-
function
|
|
2477
|
+
const Le = "szdl-utils-kit|";
|
|
2478
|
+
function Ue() {
|
|
2467
2479
|
if (typeof sessionStorage > "u")
|
|
2468
2480
|
return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2469
|
-
let
|
|
2470
|
-
return
|
|
2481
|
+
let m = sessionStorage.getItem("szdl-cross-tab-instance-id");
|
|
2482
|
+
return m || (m = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", m)), m;
|
|
2471
2483
|
}
|
|
2472
|
-
function
|
|
2484
|
+
function Pe() {
|
|
2473
2485
|
return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
|
|
2474
2486
|
}
|
|
2475
|
-
const
|
|
2476
|
-
function
|
|
2487
|
+
const Zt = /* @__PURE__ */ new Map();
|
|
2488
|
+
function Ge(m = "default") {
|
|
2477
2489
|
if (typeof BroadcastChannel > "u")
|
|
2478
2490
|
return null;
|
|
2479
|
-
const e = `${
|
|
2480
|
-
return
|
|
2491
|
+
const e = `${Le}bc:${m}`;
|
|
2492
|
+
return Zt.has(e) || Zt.set(e, new BroadcastChannel(e)), Zt.get(e);
|
|
2481
2493
|
}
|
|
2482
|
-
function
|
|
2483
|
-
const t =
|
|
2494
|
+
function Ae(m, e) {
|
|
2495
|
+
const t = Ge(m);
|
|
2484
2496
|
if (t)
|
|
2485
2497
|
try {
|
|
2486
|
-
const
|
|
2498
|
+
const r = e && typeof e == "object" && !Array.isArray(e) ? e : { data: e };
|
|
2487
2499
|
t.postMessage({
|
|
2488
|
-
...
|
|
2489
|
-
tabId:
|
|
2500
|
+
...r,
|
|
2501
|
+
tabId: Ue(),
|
|
2490
2502
|
ts: Date.now()
|
|
2491
2503
|
});
|
|
2492
2504
|
} catch {
|
|
2493
2505
|
}
|
|
2494
2506
|
}
|
|
2495
|
-
async function
|
|
2496
|
-
const { ifAvailable:
|
|
2497
|
-
return
|
|
2507
|
+
async function Ye(m, e, t = {}) {
|
|
2508
|
+
const { ifAvailable: r = !1 } = t, i = typeof m == "string" && m.length > 0 ? m : "default", a = `${Le}${i}`;
|
|
2509
|
+
return Pe() ? navigator.locks.request(
|
|
2498
2510
|
a,
|
|
2499
|
-
{ mode: "exclusive", ifAvailable: !!
|
|
2511
|
+
{ mode: "exclusive", ifAvailable: !!r },
|
|
2500
2512
|
async (c) => {
|
|
2501
|
-
if (
|
|
2513
|
+
if (r && c == null)
|
|
2502
2514
|
return { skipped: !0, coordination: "locks" };
|
|
2503
|
-
|
|
2515
|
+
Ae(i, { type: "lock-acquired", resource: i });
|
|
2504
2516
|
try {
|
|
2505
2517
|
return { skipped: !1, result: await e(), coordination: "locks" };
|
|
2506
2518
|
} finally {
|
|
2507
|
-
|
|
2519
|
+
Ae(i, { type: "lock-released", resource: i });
|
|
2508
2520
|
}
|
|
2509
2521
|
}
|
|
2510
2522
|
) : { skipped: !1, result: await e(), coordination: "none" };
|
|
@@ -2525,16 +2537,16 @@ const q = {
|
|
|
2525
2537
|
/** Heartbeat лидера во время appInit; null — вычислить из poll/activeMaxPause. */
|
|
2526
2538
|
leaderHeartbeatMs: null
|
|
2527
2539
|
};
|
|
2528
|
-
function
|
|
2529
|
-
return
|
|
2530
|
-
`BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(
|
|
2540
|
+
function We(m) {
|
|
2541
|
+
return m == null ? "user" : m === "user" || m === "portal" ? m : (console.warn(
|
|
2542
|
+
`BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(m)} — используется 'user'`
|
|
2531
2543
|
), "user");
|
|
2532
2544
|
}
|
|
2533
|
-
function
|
|
2534
|
-
const e = { ...q, ...
|
|
2545
|
+
function xe(m = {}) {
|
|
2546
|
+
const e = { ...q, ...m };
|
|
2535
2547
|
for (const t of Object.keys(q)) {
|
|
2536
2548
|
if (t === "leaderHeartbeatMs") {
|
|
2537
|
-
const i =
|
|
2549
|
+
const i = m == null ? void 0 : m.leaderHeartbeatMs;
|
|
2538
2550
|
if (i == null) {
|
|
2539
2551
|
e.leaderHeartbeatMs = null;
|
|
2540
2552
|
continue;
|
|
@@ -2543,24 +2555,24 @@ function He(g = {}) {
|
|
|
2543
2555
|
e.leaderHeartbeatMs = Number.isFinite(a) && a >= 0 ? a : null;
|
|
2544
2556
|
continue;
|
|
2545
2557
|
}
|
|
2546
|
-
const
|
|
2547
|
-
e[t] = Number.isFinite(
|
|
2558
|
+
const r = Number(e[t]);
|
|
2559
|
+
e[t] = Number.isFinite(r) && r >= 0 ? r : q[t];
|
|
2548
2560
|
}
|
|
2549
2561
|
return e;
|
|
2550
2562
|
}
|
|
2551
|
-
var
|
|
2552
|
-
class
|
|
2563
|
+
var Kt, Re, Et, ae, nt, mt, qt, Se;
|
|
2564
|
+
class Xe {
|
|
2553
2565
|
constructor(e) {
|
|
2554
|
-
|
|
2566
|
+
E(this, Kt);
|
|
2555
2567
|
/**
|
|
2556
2568
|
* Канонический base URL для placement (без завершающего `/`).
|
|
2557
2569
|
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2558
2570
|
*/
|
|
2559
|
-
|
|
2571
|
+
E(this, Et);
|
|
2560
2572
|
/** Ключ NAME в entity: userId или общий ключ портала. */
|
|
2561
|
-
|
|
2573
|
+
E(this, nt);
|
|
2562
2574
|
/** Имя Web Lock для подтверждения лидерства. */
|
|
2563
|
-
|
|
2575
|
+
E(this, qt);
|
|
2564
2576
|
w(this, "entityName", "tabs");
|
|
2565
2577
|
w(this, "maxTabs", 20);
|
|
2566
2578
|
w(this, "tabList", []);
|
|
@@ -2588,13 +2600,13 @@ class Ge {
|
|
|
2588
2600
|
}
|
|
2589
2601
|
const {
|
|
2590
2602
|
appFunc: t,
|
|
2591
|
-
bx:
|
|
2603
|
+
bx: r,
|
|
2592
2604
|
users: i,
|
|
2593
2605
|
continueBackground: a,
|
|
2594
2606
|
timing: c,
|
|
2595
2607
|
coordinationScope: h
|
|
2596
2608
|
} = e;
|
|
2597
|
-
this.bx =
|
|
2609
|
+
this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = We(h), y(this, Kt, Re).call(this, c), se(r), this.appPath = y(this, Et, ae).call(this, ((f = r == null ? void 0 : r.appConst) == null ? void 0 : f.pathApp) ?? ""), this.appName = ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.appName) ?? "", this.appCodeName = ((u = r == null ? void 0 : r.appConst) == null ? void 0 : u.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2598
2610
|
}
|
|
2599
2611
|
async init() {
|
|
2600
2612
|
if (!this.appInit) {
|
|
@@ -2627,8 +2639,8 @@ class Ge {
|
|
|
2627
2639
|
return;
|
|
2628
2640
|
}
|
|
2629
2641
|
await this.refreshTabs(!0), await this.ensureTabRegistered();
|
|
2630
|
-
const t = this.selectLeaderId(),
|
|
2631
|
-
await this.updateTabState(
|
|
2642
|
+
const t = this.selectLeaderId(), r = t && +this.id == +t;
|
|
2643
|
+
await this.updateTabState(r), r && !this.hasStarted && await this.runAsLeader();
|
|
2632
2644
|
}
|
|
2633
2645
|
stopTimers() {
|
|
2634
2646
|
this.heartbeat && (clearInterval(this.heartbeat), this.heartbeat = void 0), this.runHeartbeat && (clearInterval(this.runHeartbeat), this.runHeartbeat = void 0);
|
|
@@ -2638,18 +2650,18 @@ class Ge {
|
|
|
2638
2650
|
if (typeof BX24 > "u" || !((e = BX24.placement) != null && e.info))
|
|
2639
2651
|
return !1;
|
|
2640
2652
|
try {
|
|
2641
|
-
const t = BX24.placement.info(),
|
|
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) || "", c = 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));
|
|
2642
2654
|
return !c || h;
|
|
2643
2655
|
} catch {
|
|
2644
2656
|
return !1;
|
|
2645
2657
|
}
|
|
2646
2658
|
}
|
|
2647
2659
|
async checkEntity() {
|
|
2648
|
-
var
|
|
2660
|
+
var r;
|
|
2649
2661
|
const e = await this.safeCall(
|
|
2650
2662
|
() => this.bx.call({ method: "entity.get" })
|
|
2651
2663
|
);
|
|
2652
|
-
((
|
|
2664
|
+
((r = e == null ? void 0 : e.find) == null ? void 0 : r.call(
|
|
2653
2665
|
e,
|
|
2654
2666
|
(i) => i.ENTITY === this.entityName
|
|
2655
2667
|
)) || await this.safeCall(
|
|
@@ -2664,7 +2676,7 @@ class Ge {
|
|
|
2664
2676
|
);
|
|
2665
2677
|
}
|
|
2666
2678
|
async getTabs() {
|
|
2667
|
-
const e =
|
|
2679
|
+
const e = y(this, nt, mt).call(this), t = await this.safeCall(
|
|
2668
2680
|
() => this.bx.call({
|
|
2669
2681
|
method: "entity.item.get",
|
|
2670
2682
|
params: {
|
|
@@ -2674,19 +2686,19 @@ class Ge {
|
|
|
2674
2686
|
}
|
|
2675
2687
|
})
|
|
2676
2688
|
);
|
|
2677
|
-
return !Array.isArray(t) || !t.length ? [] : t.map((
|
|
2678
|
-
if (!
|
|
2689
|
+
return !Array.isArray(t) || !t.length ? [] : t.map((r) => {
|
|
2690
|
+
if (!r)
|
|
2679
2691
|
return { id: void 0, data: void 0 };
|
|
2680
2692
|
try {
|
|
2681
|
-
const i = JSON.parse(
|
|
2682
|
-
return { id: +
|
|
2693
|
+
const i = JSON.parse(r.DETAIL_TEXT);
|
|
2694
|
+
return { id: +r.ID || 0, data: i };
|
|
2683
2695
|
} catch (i) {
|
|
2684
|
-
return console.log("BackgroundWorker: parse tab error", i), { id: +
|
|
2696
|
+
return console.log("BackgroundWorker: parse tab error", i), { id: +r.ID || 0, data: void 0 };
|
|
2685
2697
|
}
|
|
2686
2698
|
});
|
|
2687
2699
|
}
|
|
2688
2700
|
async ensureTabRegistered() {
|
|
2689
|
-
var
|
|
2701
|
+
var r, i;
|
|
2690
2702
|
if (this.id)
|
|
2691
2703
|
return +this.id || 0;
|
|
2692
2704
|
if (this.tabList.length >= this.maxTabs && await this.refreshTabs(!0, this.quickCleanupThreshold), this.tabList.length >= this.maxTabs)
|
|
@@ -2698,13 +2710,13 @@ class Ge {
|
|
|
2698
2710
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2699
2711
|
start: !1,
|
|
2700
2712
|
sessionId: this.sessionId,
|
|
2701
|
-
userId: (i = (
|
|
2713
|
+
userId: (i = (r = this.bx) == null ? void 0 : r.userInfo) == null ? void 0 : i.ID
|
|
2702
2714
|
}, t = await this.safeCall(
|
|
2703
2715
|
() => this.bx.call({
|
|
2704
2716
|
method: "entity.item.add",
|
|
2705
2717
|
params: {
|
|
2706
2718
|
ENTITY: this.entityName,
|
|
2707
|
-
NAME:
|
|
2719
|
+
NAME: y(this, nt, mt).call(this),
|
|
2708
2720
|
DETAIL_TEXT: JSON.stringify(e)
|
|
2709
2721
|
}
|
|
2710
2722
|
})
|
|
@@ -2712,7 +2724,7 @@ class Ge {
|
|
|
2712
2724
|
return this.id = +t || 0, this.id;
|
|
2713
2725
|
}
|
|
2714
2726
|
async updateTabState(e) {
|
|
2715
|
-
var
|
|
2727
|
+
var r, i;
|
|
2716
2728
|
if (!this.id)
|
|
2717
2729
|
return;
|
|
2718
2730
|
const t = {
|
|
@@ -2720,7 +2732,7 @@ class Ge {
|
|
|
2720
2732
|
createdAt: this.start.toISOString(),
|
|
2721
2733
|
start: e,
|
|
2722
2734
|
sessionId: this.sessionId,
|
|
2723
|
-
userId: (i = (
|
|
2735
|
+
userId: (i = (r = this.bx) == null ? void 0 : r.userInfo) == null ? void 0 : i.ID
|
|
2724
2736
|
};
|
|
2725
2737
|
await this.safeCall(
|
|
2726
2738
|
() => this.bx.call({
|
|
@@ -2728,7 +2740,7 @@ class Ge {
|
|
|
2728
2740
|
params: {
|
|
2729
2741
|
ENTITY: this.entityName,
|
|
2730
2742
|
ID: this.id,
|
|
2731
|
-
NAME:
|
|
2743
|
+
NAME: y(this, nt, mt).call(this),
|
|
2732
2744
|
DETAIL_TEXT: JSON.stringify(t)
|
|
2733
2745
|
}
|
|
2734
2746
|
})
|
|
@@ -2737,9 +2749,9 @@ class Ge {
|
|
|
2737
2749
|
async deleteTabs(e = []) {
|
|
2738
2750
|
if (!e.length)
|
|
2739
2751
|
return;
|
|
2740
|
-
const t = e.map((
|
|
2752
|
+
const t = e.map((r) => ({
|
|
2741
2753
|
method: "entity.item.delete",
|
|
2742
|
-
params: { ENTITY: this.entityName, ID:
|
|
2754
|
+
params: { ENTITY: this.entityName, ID: r.id }
|
|
2743
2755
|
}));
|
|
2744
2756
|
await this.safeCall(() => this.bx.batch(t));
|
|
2745
2757
|
}
|
|
@@ -2748,10 +2760,10 @@ class Ge {
|
|
|
2748
2760
|
try {
|
|
2749
2761
|
if (!((e = this.bx) != null && e.isAdmin))
|
|
2750
2762
|
return !0;
|
|
2751
|
-
const
|
|
2763
|
+
const r = await this.safeCall(
|
|
2752
2764
|
() => this.bx.getPlacement()
|
|
2753
2765
|
);
|
|
2754
|
-
if (!
|
|
2766
|
+
if (!r || !Array.isArray(r))
|
|
2755
2767
|
return console.log(
|
|
2756
2768
|
"BackgroundWorker: Не получили список размещений, продолжаем"
|
|
2757
2769
|
), !0;
|
|
@@ -2761,7 +2773,7 @@ class Ge {
|
|
|
2761
2773
|
if (!i)
|
|
2762
2774
|
return !0;
|
|
2763
2775
|
let h = !1;
|
|
2764
|
-
for (const f of
|
|
2776
|
+
for (const f of r) {
|
|
2765
2777
|
if (f.placement !== "PAGE_BACKGROUND_WORKER" || !(f.userId || f.handler && f.handler.includes("USER_ID=")))
|
|
2766
2778
|
continue;
|
|
2767
2779
|
const u = f.userId || (f.handler ? this.extractUserIdFromHandler(f.handler) : null);
|
|
@@ -2777,10 +2789,10 @@ class Ge {
|
|
|
2777
2789
|
), !1) : (console.log(
|
|
2778
2790
|
"BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
|
|
2779
2791
|
), !0);
|
|
2780
|
-
} catch (
|
|
2792
|
+
} catch (r) {
|
|
2781
2793
|
return console.error(
|
|
2782
2794
|
"BackgroundWorker: Ошибка при проверке типа встройки",
|
|
2783
|
-
|
|
2795
|
+
r
|
|
2784
2796
|
), !0;
|
|
2785
2797
|
}
|
|
2786
2798
|
}
|
|
@@ -2807,30 +2819,30 @@ class Ge {
|
|
|
2807
2819
|
}
|
|
2808
2820
|
}
|
|
2809
2821
|
async refreshTabs(e = !1, t = this.activeMaxPause) {
|
|
2810
|
-
const
|
|
2822
|
+
const r = [], i = [], a = Date.now(), c = await this.getTabs();
|
|
2811
2823
|
for (const h of c) {
|
|
2812
2824
|
if (!(h != null && h.data)) {
|
|
2813
|
-
|
|
2825
|
+
r.push(h);
|
|
2814
2826
|
continue;
|
|
2815
2827
|
}
|
|
2816
2828
|
if (a - new Date(h.data.lastActive || 0).getTime() > t) {
|
|
2817
|
-
|
|
2829
|
+
r.push(h);
|
|
2818
2830
|
continue;
|
|
2819
2831
|
}
|
|
2820
2832
|
i.push(h);
|
|
2821
2833
|
}
|
|
2822
|
-
return e &&
|
|
2834
|
+
return e && r.length && await this.deleteTabs(r), this.tabList = i, i;
|
|
2823
2835
|
}
|
|
2824
2836
|
selectLeaderId() {
|
|
2825
2837
|
var t;
|
|
2826
|
-
return this.tabList.length && +((t = [...this.tabList].sort((
|
|
2838
|
+
return this.tabList.length && +((t = [...this.tabList].sort((r, i) => {
|
|
2827
2839
|
var h, f, n, u;
|
|
2828
2840
|
const a = new Date(
|
|
2829
|
-
((h =
|
|
2841
|
+
((h = r.data) == null ? void 0 : h.createdAt) || ((f = r.data) == null ? void 0 : f.lastActive) || 0
|
|
2830
2842
|
).getTime(), c = new Date(
|
|
2831
2843
|
((n = i.data) == null ? void 0 : n.createdAt) || ((u = i.data) == null ? void 0 : u.lastActive) || 0
|
|
2832
2844
|
).getTime();
|
|
2833
|
-
return a === c ? (+
|
|
2845
|
+
return a === c ? (+r.id || 0) - (+i.id || 0) : a - c;
|
|
2834
2846
|
})[0]) == null ? void 0 : t.id) || 0;
|
|
2835
2847
|
}
|
|
2836
2848
|
async confirmLeaderAfterLock() {
|
|
@@ -2839,8 +2851,8 @@ class Ge {
|
|
|
2839
2851
|
return !!(e && +this.id == +e);
|
|
2840
2852
|
}
|
|
2841
2853
|
async runAsLeader() {
|
|
2842
|
-
const e =
|
|
2843
|
-
(await
|
|
2854
|
+
const e = y(this, qt, Se).call(this);
|
|
2855
|
+
(await Ye(
|
|
2844
2856
|
e,
|
|
2845
2857
|
async () => {
|
|
2846
2858
|
if (await this.updateTabState(!0), console.log(
|
|
@@ -2880,15 +2892,15 @@ class Ge {
|
|
|
2880
2892
|
);
|
|
2881
2893
|
}
|
|
2882
2894
|
async setBackgroundWorkerAll() {
|
|
2883
|
-
var
|
|
2884
|
-
if (!((
|
|
2895
|
+
var k, T, M, G;
|
|
2896
|
+
if (!((k = this.bx) != null && k.isAdmin)) {
|
|
2885
2897
|
console.log(
|
|
2886
2898
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2887
2899
|
);
|
|
2888
2900
|
return;
|
|
2889
2901
|
}
|
|
2890
|
-
(
|
|
2891
|
-
const e =
|
|
2902
|
+
(T = this.users) != null && T.length || await this.getEntityData(), se(this.bx);
|
|
2903
|
+
const e = y(this, Et, ae).call(this, ((G = (M = this.bx) == null ? void 0 : M.appConst) == null ? void 0 : G.pathApp) ?? "");
|
|
2892
2904
|
if (!e) {
|
|
2893
2905
|
console.error(
|
|
2894
2906
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2897,80 +2909,80 @@ class Ge {
|
|
|
2897
2909
|
}
|
|
2898
2910
|
const t = await this.safeCall(
|
|
2899
2911
|
() => this.bx.getPlacement()
|
|
2900
|
-
),
|
|
2912
|
+
), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2901
2913
|
let a = null;
|
|
2902
|
-
(t || []).forEach((
|
|
2903
|
-
if (
|
|
2914
|
+
(t || []).forEach((N) => {
|
|
2915
|
+
if (N.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2904
2916
|
return;
|
|
2905
|
-
if (
|
|
2906
|
-
const
|
|
2907
|
-
if (
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2917
|
+
if (N.userId || N.handler && N.handler.includes("USER_ID=")) {
|
|
2918
|
+
const I = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
|
|
2919
|
+
if (I) {
|
|
2920
|
+
const C = +I;
|
|
2921
|
+
r.set(C, N), i.has(C) || i.set(C, []), i.get(C).push(N);
|
|
2910
2922
|
}
|
|
2911
2923
|
} else
|
|
2912
|
-
a =
|
|
2924
|
+
a = N;
|
|
2913
2925
|
});
|
|
2914
2926
|
const c = await this.resolveAdmins(), h = await this.getEligibleUsersForBackgroundWorker(c);
|
|
2915
|
-
h.sort((
|
|
2916
|
-
const
|
|
2917
|
-
return (S.LAST_LOGIN ? new Date(S.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) -
|
|
2927
|
+
h.sort((N, S) => {
|
|
2928
|
+
const I = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2929
|
+
return (S.LAST_LOGIN ? new Date(S.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
|
|
2918
2930
|
});
|
|
2919
|
-
const f = 10, n = this.coordinationScope === "portal" ? [] : h.slice(0, f), u = n.filter((
|
|
2920
|
-
const S =
|
|
2931
|
+
const f = 10, n = this.coordinationScope === "portal" ? [] : h.slice(0, f), u = n.filter((N) => {
|
|
2932
|
+
const S = r.get(+N.ID);
|
|
2921
2933
|
if (!S)
|
|
2922
2934
|
return !0;
|
|
2923
|
-
const
|
|
2924
|
-
return S.handler !==
|
|
2935
|
+
const I = `${e}?USER_ID=${N.ID}/`;
|
|
2936
|
+
return S.handler !== I;
|
|
2925
2937
|
}), d = [];
|
|
2926
2938
|
if (this.coordinationScope === "portal")
|
|
2927
|
-
for (const
|
|
2928
|
-
d.push(+
|
|
2929
|
-
for (const [
|
|
2930
|
-
const S = +
|
|
2931
|
-
h.find((
|
|
2939
|
+
for (const N of r.keys())
|
|
2940
|
+
d.push(+N);
|
|
2941
|
+
for (const [N] of r) {
|
|
2942
|
+
const S = +N || 0;
|
|
2943
|
+
h.find((C) => +C.ID === S) || d.push(S);
|
|
2932
2944
|
}
|
|
2933
|
-
for (const
|
|
2934
|
-
const S =
|
|
2945
|
+
for (const N of n) {
|
|
2946
|
+
const S = r.get(+N.ID);
|
|
2935
2947
|
if (!S)
|
|
2936
2948
|
continue;
|
|
2937
|
-
const
|
|
2938
|
-
S.handler !==
|
|
2949
|
+
const I = `${e}?USER_ID=${N.ID}/`;
|
|
2950
|
+
S.handler !== I && d.push(+N.ID);
|
|
2939
2951
|
}
|
|
2940
2952
|
const A = [], l = [...new Set(d)];
|
|
2941
|
-
for (const
|
|
2942
|
-
const S = i.get(+
|
|
2943
|
-
for (const
|
|
2944
|
-
|
|
2953
|
+
for (const N of l) {
|
|
2954
|
+
const S = i.get(+N) || [];
|
|
2955
|
+
for (const I of S)
|
|
2956
|
+
I != null && I.handler && A.push({
|
|
2945
2957
|
method: "placement.unbind",
|
|
2946
2958
|
params: {
|
|
2947
2959
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2948
|
-
HANDLER:
|
|
2960
|
+
HANDLER: I.handler
|
|
2949
2961
|
}
|
|
2950
2962
|
});
|
|
2951
2963
|
}
|
|
2952
|
-
const
|
|
2953
|
-
|
|
2964
|
+
const O = a && (u.length > 0 || a.handler !== `${e}`);
|
|
2965
|
+
O && A.push({
|
|
2954
2966
|
method: "placement.unbind",
|
|
2955
2967
|
params: {
|
|
2956
2968
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2957
2969
|
HANDLER: a.handler || `${e}`
|
|
2958
2970
|
}
|
|
2959
2971
|
});
|
|
2960
|
-
for (const
|
|
2972
|
+
for (const N of u)
|
|
2961
2973
|
A.push({
|
|
2962
2974
|
method: "placement.bind",
|
|
2963
2975
|
params: {
|
|
2964
2976
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2965
|
-
HANDLER: `${e}?USER_ID=${
|
|
2977
|
+
HANDLER: `${e}?USER_ID=${N.ID}/`,
|
|
2966
2978
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2967
2979
|
OPTIONS: {
|
|
2968
|
-
errorHandlerUrl: `${e}?USER_ID=${
|
|
2980
|
+
errorHandlerUrl: `${e}?USER_ID=${N.ID}/`
|
|
2969
2981
|
},
|
|
2970
|
-
USER_ID:
|
|
2982
|
+
USER_ID: N.ID
|
|
2971
2983
|
}
|
|
2972
2984
|
});
|
|
2973
|
-
(!a ||
|
|
2985
|
+
(!a || O) && A.push({
|
|
2974
2986
|
method: "placement.bind",
|
|
2975
2987
|
params: {
|
|
2976
2988
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -2979,21 +2991,21 @@ class Ge {
|
|
|
2979
2991
|
OPTIONS: { errorHandlerUrl: `${e}` }
|
|
2980
2992
|
}
|
|
2981
2993
|
});
|
|
2982
|
-
const
|
|
2983
|
-
(
|
|
2984
|
-
),
|
|
2985
|
-
(
|
|
2994
|
+
const _ = A.filter(
|
|
2995
|
+
(N) => N.method === "placement.unbind"
|
|
2996
|
+
), b = A.filter(
|
|
2997
|
+
(N) => N.method === "placement.bind"
|
|
2986
2998
|
);
|
|
2987
|
-
|
|
2999
|
+
_.length && await this.safeCall(
|
|
2988
3000
|
() => this.bx.batch(
|
|
2989
3001
|
Object.fromEntries(
|
|
2990
|
-
|
|
3002
|
+
_.map((N, S) => [`unbind_${S}`, N])
|
|
2991
3003
|
)
|
|
2992
3004
|
)
|
|
2993
|
-
),
|
|
3005
|
+
), b.length && await this.safeCall(
|
|
2994
3006
|
() => this.bx.batch(
|
|
2995
3007
|
Object.fromEntries(
|
|
2996
|
-
|
|
3008
|
+
b.map((N, S) => [`bind_${S}`, N])
|
|
2997
3009
|
)
|
|
2998
3010
|
)
|
|
2999
3011
|
), A.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
@@ -3001,29 +3013,29 @@ class Ge {
|
|
|
3001
3013
|
async resolveAdmins() {
|
|
3002
3014
|
var e, t;
|
|
3003
3015
|
try {
|
|
3004
|
-
const
|
|
3016
|
+
const r = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0), i = !!((t = this.bx) != null && t.isAdmin), a = await this.getAdminsList() || [];
|
|
3005
3017
|
if (!i) {
|
|
3006
|
-
if (
|
|
3018
|
+
if (r && a.includes(+r)) {
|
|
3007
3019
|
const f = a.filter(
|
|
3008
|
-
(n) => +n != +
|
|
3020
|
+
(n) => +n != +r
|
|
3009
3021
|
);
|
|
3010
3022
|
return await this.saveAdminsList(f), f;
|
|
3011
3023
|
}
|
|
3012
3024
|
return a;
|
|
3013
3025
|
}
|
|
3014
3026
|
const c = /* @__PURE__ */ new Set([...a || []]);
|
|
3015
|
-
|
|
3027
|
+
r && c.add(+r);
|
|
3016
3028
|
const h = [...c].filter(Boolean);
|
|
3017
3029
|
return await this.saveAdminsList(h), h;
|
|
3018
|
-
} catch (
|
|
3019
|
-
return console.error("BackgroundWorker: resolveAdmins error",
|
|
3030
|
+
} catch (r) {
|
|
3031
|
+
return console.error("BackgroundWorker: resolveAdmins error", r), [];
|
|
3020
3032
|
}
|
|
3021
3033
|
}
|
|
3022
3034
|
async getEligibleUsersForBackgroundWorker(e = []) {
|
|
3023
3035
|
const t = (this.users ?? []).filter(
|
|
3024
3036
|
(i) => i.ACTIVE === "Y" || i.ACTIVE === !0
|
|
3025
|
-
),
|
|
3026
|
-
return t.filter((i) =>
|
|
3037
|
+
), r = e.map((i) => +i || 0).filter(Boolean);
|
|
3038
|
+
return t.filter((i) => r.includes(+i.ID || 0));
|
|
3027
3039
|
}
|
|
3028
3040
|
async saveAdminsList(e = []) {
|
|
3029
3041
|
try {
|
|
@@ -3035,7 +3047,7 @@ class Ge {
|
|
|
3035
3047
|
async getAdminsList() {
|
|
3036
3048
|
try {
|
|
3037
3049
|
const e = BX24.appOption.get("adminsList"), t = e ? JSON.parse(e) : [];
|
|
3038
|
-
return Array.isArray(t) ? t.map((
|
|
3050
|
+
return Array.isArray(t) ? t.map((r) => +r || 0).filter(Boolean) : [];
|
|
3039
3051
|
} catch (e) {
|
|
3040
3052
|
return console.error("BackgroundWorker: getAdminsList error", e), [];
|
|
3041
3053
|
}
|
|
@@ -3044,7 +3056,7 @@ class Ge {
|
|
|
3044
3056
|
const e = {
|
|
3045
3057
|
users: { method: "user.get", params: { filter: { ACTIVE: "Y" } } }
|
|
3046
3058
|
}, { users: t } = await this.safeCall(
|
|
3047
|
-
() => this.bx.batch(e).then((
|
|
3059
|
+
() => this.bx.batch(e).then((r) => r ? (Array.isArray(r.users) || (r.users = []), r) : { users: [] })
|
|
3048
3060
|
);
|
|
3049
3061
|
this.users = t;
|
|
3050
3062
|
}
|
|
@@ -3057,9 +3069,9 @@ class Ge {
|
|
|
3057
3069
|
(e = this.bx) != null && e.isAdmin && ((t = this.users) != null && t.length || await this.getEntityData(), await this.setBackgroundWorkerAll());
|
|
3058
3070
|
}
|
|
3059
3071
|
pause(e = 500, t) {
|
|
3060
|
-
return new Promise((
|
|
3072
|
+
return new Promise((r) => {
|
|
3061
3073
|
setTimeout(() => {
|
|
3062
|
-
t && t(),
|
|
3074
|
+
t && t(), r(!0);
|
|
3063
3075
|
}, e);
|
|
3064
3076
|
});
|
|
3065
3077
|
}
|
|
@@ -3072,33 +3084,33 @@ class Ge {
|
|
|
3072
3084
|
}
|
|
3073
3085
|
}
|
|
3074
3086
|
}
|
|
3075
|
-
|
|
3076
|
-
const t =
|
|
3087
|
+
Kt = new WeakSet(), Re = function(e) {
|
|
3088
|
+
const t = xe(e);
|
|
3077
3089
|
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;
|
|
3078
|
-
const
|
|
3079
|
-
t.activeMaxPauseMs <
|
|
3080
|
-
`BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${
|
|
3090
|
+
const r = t.pollIntervalMs + t.pollIntervalJitterMs + t.leaderConfirmDelayMs;
|
|
3091
|
+
t.activeMaxPauseMs < r && console.warn(
|
|
3092
|
+
`BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${r}) — «живые» вкладки могут удаляться раньше следующего тика`
|
|
3081
3093
|
);
|
|
3082
|
-
},
|
|
3094
|
+
}, Et = new WeakSet(), ae = function(e) {
|
|
3083
3095
|
if (!e || typeof e != "string")
|
|
3084
3096
|
return "";
|
|
3085
|
-
const t =
|
|
3086
|
-
return t ?
|
|
3097
|
+
const t = oe(e).replace(/\/+$/, "");
|
|
3098
|
+
return t ? Ne(t) ? (console.error(
|
|
3087
3099
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3088
3100
|
), "") : t : "";
|
|
3089
|
-
}, nt = new WeakSet(),
|
|
3101
|
+
}, nt = new WeakSet(), mt = function() {
|
|
3090
3102
|
var e, t;
|
|
3091
3103
|
return this.coordinationScope === "portal" ? `${this.appCodeName || "app"}:portal` : String(((t = (e = this.bx) == null ? void 0 : e.userInfo) == null ? void 0 : t.ID) ?? "");
|
|
3092
|
-
},
|
|
3093
|
-
return `background-worker:${this.entityName}:${
|
|
3104
|
+
}, qt = new WeakSet(), Se = function() {
|
|
3105
|
+
return `background-worker:${this.entityName}:${y(this, nt, mt).call(this)}`;
|
|
3094
3106
|
};
|
|
3095
3107
|
export {
|
|
3096
|
-
|
|
3108
|
+
Xe as BackgroundWorker,
|
|
3097
3109
|
K as Batch,
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3110
|
+
ve as BxBoot,
|
|
3111
|
+
de as BxHelper,
|
|
3112
|
+
Ce as BxLogger,
|
|
3101
3113
|
q as DEFAULT_BACKGROUND_WORKER_TIMING,
|
|
3102
|
-
|
|
3103
|
-
|
|
3114
|
+
xe as resolveBackgroundWorkerTiming,
|
|
3115
|
+
bt as tempus
|
|
3104
3116
|
};
|