szdl-utils-kit 0.3.15 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1201 -1093
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
if (!
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var ne = (p, t, e) => t in p ? ie(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e;
|
|
3
|
+
var C = (p, t, e) => (ne(p, typeof t != "symbol" ? t + "" : t, e), e), wt = (p, t, e) => {
|
|
4
|
+
if (!t.has(p))
|
|
5
5
|
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
7
|
+
var S = (p, t, e) => (wt(p, t, "read from private field"), e ? e.call(p) : t.get(p)), D = (p, t, e) => {
|
|
8
|
+
if (t.has(p))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
|
|
11
|
-
}, J = (
|
|
12
|
-
var E = (
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
return
|
|
10
|
+
t instanceof WeakSet ? t.add(p) : t.set(p, e);
|
|
11
|
+
}, J = (p, t, e, s) => (wt(p, t, "write to private field"), s ? s.call(p, e) : t.set(p, e), e);
|
|
12
|
+
var E = (p, t, e) => (wt(p, t, "access private method"), e);
|
|
13
|
+
var oe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
+
function ae(p) {
|
|
15
|
+
return p && p.__esModule && Object.prototype.hasOwnProperty.call(p, "default") ? p.default : p;
|
|
16
16
|
}
|
|
17
|
-
var
|
|
18
|
-
(function(
|
|
17
|
+
var Ht = { exports: {} };
|
|
18
|
+
(function(p, t) {
|
|
19
19
|
(function(e) {
|
|
20
|
-
Array.prototype.indexOf || (Array.prototype.indexOf = function(
|
|
20
|
+
Array.prototype.indexOf || (Array.prototype.indexOf = function(r, o) {
|
|
21
21
|
var d, g;
|
|
22
|
-
for (d =
|
|
23
|
-
if (this[d] ===
|
|
22
|
+
for (d = o || 0, g = this.length; d < g; d += 1)
|
|
23
|
+
if (this[d] === r)
|
|
24
24
|
return d;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
|
-
var s = this,
|
|
28
|
-
for (var d =
|
|
27
|
+
var s = this, i = function(r, o) {
|
|
28
|
+
for (var d = r.toString(); d.length < o; )
|
|
29
29
|
d = "0" + d;
|
|
30
30
|
return d;
|
|
31
|
-
},
|
|
32
|
-
return
|
|
33
|
-
},
|
|
31
|
+
}, a = function(r, o) {
|
|
32
|
+
return o !== e ? (r.year(o.year() || o.year), r.month(o.month() || o.month), r.day(o.day() || o.day), r.hours(o.hours() || o.hours), r.minutes(o.minutes() || o.minutes), r.seconds(o.seconds() || o.seconds), r.milliseconds(o.milliseconds() || o.milliseconds), r) : e;
|
|
33
|
+
}, l = function(r, o) {
|
|
34
34
|
var d, g = "";
|
|
35
|
-
return d =
|
|
36
|
-
}, A = function(
|
|
35
|
+
return d = r.slice(o, o + 1), d !== "" && !isNaN(Number(d)) && (g += "%H"), d = r.charAt(o + 2), d !== "" && d === ":" && (g += d), d = r.slice(o + 3, o + 4), d !== "" && !isNaN(Number(d)) && (g += "%M"), d = r.charAt(o + 5), d !== "" && d === ":" && (g += d), d = r.slice(o + 6, o + 7), d !== "" && !isNaN(Number(d)) && (g += "%S"), g;
|
|
36
|
+
}, A = function(r, o) {
|
|
37
37
|
var d, g = [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? d = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? d = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (d = "%m/%d/%Y"), d) : (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
},
|
|
38
|
+
r.slice(o, o + 1),
|
|
39
|
+
r.charAt(o + 2),
|
|
40
|
+
r.slice(o + 3, o + 4),
|
|
41
|
+
r.charAt(o + 5),
|
|
42
|
+
r.slice(o + 6, o + 9)
|
|
43
|
+
], w;
|
|
44
|
+
return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? d = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? d = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (d = "%m/%d/%Y"), d) : (w = [
|
|
45
|
+
r.slice(o, o + 3),
|
|
46
|
+
r.charAt(o + 4),
|
|
47
|
+
r.slice(o + 5, o + 6),
|
|
48
|
+
r.charAt(o + 7),
|
|
49
|
+
r.slice(o + 8, o + 9)
|
|
50
|
+
], !isNaN(Number(w[0])) && !isNaN(Number(w[2])) && !isNaN(Number(w[4])) ? (w[1] === "-" && w[3] === "-" && (d = "%Y-%m-%d"), d) : "");
|
|
51
|
+
}, h = s.tempus, n, u, m = s.navigator || {}, c = "en", f = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -224,7 +224,7 @@ var Ct = { exports: {} };
|
|
|
224
224
|
f[c].NOVEMBER_LONG,
|
|
225
225
|
f[c].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
|
-
},
|
|
227
|
+
}, T = function() {
|
|
228
228
|
return [
|
|
229
229
|
f[c].JANUARY_SHORT,
|
|
230
230
|
f[c].FEBRUARY_SHORT,
|
|
@@ -239,7 +239,7 @@ var Ct = { exports: {} };
|
|
|
239
239
|
f[c].NOVEMBER_SHORT,
|
|
240
240
|
f[c].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, _ = function() {
|
|
243
243
|
return [
|
|
244
244
|
f[c].SUNDAY_LONG,
|
|
245
245
|
f[c].MONDAY_LONG,
|
|
@@ -249,7 +249,7 @@ var Ct = { exports: {} };
|
|
|
249
249
|
f[c].FRIDAY_LONG,
|
|
250
250
|
f[c].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, R = function() {
|
|
253
253
|
return [
|
|
254
254
|
f[c].SUNDAY_SHORT,
|
|
255
255
|
f[c].MONDAY_SHORT,
|
|
@@ -259,52 +259,52 @@ var Ct = { exports: {} };
|
|
|
259
259
|
f[c].FRIDAY_SHORT,
|
|
260
260
|
f[c].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
},
|
|
262
|
+
}, N, y, L, I, H = function(r, o, d) {
|
|
263
263
|
var g;
|
|
264
264
|
s.XMLHttpRequest ? g = new XMLHttpRequest() : g = new ActiveXObject("Microsoft.XMLHTTP"), g.onreadystatechange = function() {
|
|
265
|
-
g.readyState === 4 && (g.status === 200 ?
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) :
|
|
267
|
-
}, g.open("GET",
|
|
268
|
-
},
|
|
265
|
+
g.readyState === 4 && (g.status === 200 ? o && (s.JSON === e ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) : d && d(g));
|
|
267
|
+
}, g.open("GET", r, !1), g.send();
|
|
268
|
+
}, k = {
|
|
269
269
|
"%d": {
|
|
270
|
-
format: function(
|
|
271
|
-
return
|
|
270
|
+
format: function(r) {
|
|
271
|
+
return i(r.day() || n.MIN_DAY, 2);
|
|
272
272
|
},
|
|
273
|
-
parse: function(
|
|
274
|
-
var
|
|
275
|
-
return { day: isNaN(
|
|
273
|
+
parse: function(r) {
|
|
274
|
+
var o = Number(r);
|
|
275
|
+
return { day: isNaN(o) ? e : o };
|
|
276
276
|
},
|
|
277
277
|
minLength: 2,
|
|
278
278
|
maxLength: 2,
|
|
279
279
|
type: "number"
|
|
280
280
|
},
|
|
281
281
|
"%m": {
|
|
282
|
-
format: function(
|
|
283
|
-
return
|
|
282
|
+
format: function(r) {
|
|
283
|
+
return i(r.month() || n.MIN_MONTH, 2);
|
|
284
284
|
},
|
|
285
|
-
parse: function(
|
|
286
|
-
var
|
|
287
|
-
return { month: isNaN(
|
|
285
|
+
parse: function(r) {
|
|
286
|
+
var o = Number(r);
|
|
287
|
+
return { month: isNaN(o) ? e : o };
|
|
288
288
|
},
|
|
289
289
|
minLength: 2,
|
|
290
290
|
maxLength: 2,
|
|
291
291
|
type: "number"
|
|
292
292
|
},
|
|
293
293
|
"%Y": {
|
|
294
|
-
format: function(
|
|
295
|
-
return
|
|
294
|
+
format: function(r) {
|
|
295
|
+
return i(r.year() || n.MIN_YEAR, 4);
|
|
296
296
|
},
|
|
297
|
-
parse: function(
|
|
298
|
-
var
|
|
299
|
-
return { year: isNaN(
|
|
297
|
+
parse: function(r) {
|
|
298
|
+
var o = Number(r);
|
|
299
|
+
return { year: isNaN(o) ? e : o };
|
|
300
300
|
},
|
|
301
301
|
minLength: 4,
|
|
302
302
|
maxLength: 4,
|
|
303
303
|
type: "number"
|
|
304
304
|
},
|
|
305
305
|
"%w": {
|
|
306
|
-
format: function(
|
|
307
|
-
return
|
|
306
|
+
format: function(r) {
|
|
307
|
+
return r.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`) : a(JSON.pars
|
|
|
314
314
|
type: "number"
|
|
315
315
|
},
|
|
316
316
|
"%a": {
|
|
317
|
-
format: function(
|
|
318
|
-
var
|
|
319
|
-
return
|
|
317
|
+
format: function(r) {
|
|
318
|
+
var o = r.dayOfWeek();
|
|
319
|
+
return I[o !== e ? 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`) : a(JSON.pars
|
|
|
326
326
|
type: "word"
|
|
327
327
|
},
|
|
328
328
|
"%A": {
|
|
329
|
-
format: function(
|
|
330
|
-
var
|
|
331
|
-
return
|
|
329
|
+
format: function(r) {
|
|
330
|
+
var o = r.dayOfWeek();
|
|
331
|
+
return L[o !== e ? o : n.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
334
334
|
return {};
|
|
@@ -338,86 +338,86 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
338
338
|
type: "word"
|
|
339
339
|
},
|
|
340
340
|
"%b": {
|
|
341
|
-
format: function(
|
|
342
|
-
var
|
|
343
|
-
return
|
|
341
|
+
format: function(r) {
|
|
342
|
+
var o = n.options("monthFromZero") ? r.month() : r.month() - 1;
|
|
343
|
+
return y[o !== e ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
|
-
parse: function(
|
|
346
|
-
var
|
|
347
|
-
return { month:
|
|
345
|
+
parse: function(r) {
|
|
346
|
+
var o = n.monthNames().indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
|
|
347
|
+
return { month: o !== -1 ? o : e };
|
|
348
348
|
},
|
|
349
349
|
minLength: 1,
|
|
350
350
|
maxLength: 999,
|
|
351
351
|
type: "word"
|
|
352
352
|
},
|
|
353
353
|
"%B": {
|
|
354
|
-
format: function(
|
|
355
|
-
var
|
|
356
|
-
return
|
|
354
|
+
format: function(r) {
|
|
355
|
+
var o = n.options("monthFromZero") ? r.month() : r.month() - 1;
|
|
356
|
+
return N[o !== e ? o : n.MIN_MONTH];
|
|
357
357
|
},
|
|
358
|
-
parse: function(
|
|
359
|
-
var
|
|
360
|
-
return { month:
|
|
358
|
+
parse: function(r) {
|
|
359
|
+
var o = n.monthNames(!0).indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
|
|
360
|
+
return { month: o !== -1 ? o : e };
|
|
361
361
|
},
|
|
362
362
|
minLength: 1,
|
|
363
363
|
maxLength: 999,
|
|
364
364
|
type: "word"
|
|
365
365
|
},
|
|
366
366
|
"%H": {
|
|
367
|
-
format: function(
|
|
368
|
-
return
|
|
367
|
+
format: function(r) {
|
|
368
|
+
return i(r.hours() || n.MIN_HOURS, 2);
|
|
369
369
|
},
|
|
370
|
-
parse: function(
|
|
371
|
-
var
|
|
372
|
-
return { hours: isNaN(
|
|
370
|
+
parse: function(r) {
|
|
371
|
+
var o = Number(r);
|
|
372
|
+
return { hours: isNaN(o) ? e : o };
|
|
373
373
|
},
|
|
374
374
|
minLength: 2,
|
|
375
375
|
maxLength: 2,
|
|
376
376
|
type: "number"
|
|
377
377
|
},
|
|
378
378
|
"%M": {
|
|
379
|
-
format: function(
|
|
380
|
-
return
|
|
379
|
+
format: function(r) {
|
|
380
|
+
return i(r.minutes() || n.MIN_MINUTES, 2);
|
|
381
381
|
},
|
|
382
|
-
parse: function(
|
|
383
|
-
var
|
|
384
|
-
return { minutes: isNaN(
|
|
382
|
+
parse: function(r) {
|
|
383
|
+
var o = Number(r);
|
|
384
|
+
return { minutes: isNaN(o) ? e : o };
|
|
385
385
|
},
|
|
386
386
|
minLength: 2,
|
|
387
387
|
maxLength: 2,
|
|
388
388
|
type: "number"
|
|
389
389
|
},
|
|
390
390
|
"%S": {
|
|
391
|
-
format: function(
|
|
392
|
-
return
|
|
391
|
+
format: function(r) {
|
|
392
|
+
return i(r.seconds() || n.MIN_SECONDS, 2);
|
|
393
393
|
},
|
|
394
|
-
parse: function(
|
|
395
|
-
var
|
|
396
|
-
return { seconds: isNaN(
|
|
394
|
+
parse: function(r) {
|
|
395
|
+
var o = Number(r);
|
|
396
|
+
return { seconds: isNaN(o) ? e : o };
|
|
397
397
|
},
|
|
398
398
|
minLength: 2,
|
|
399
399
|
maxLength: 2,
|
|
400
400
|
type: "number"
|
|
401
401
|
},
|
|
402
402
|
"%s": {
|
|
403
|
-
format: function(
|
|
404
|
-
return
|
|
403
|
+
format: function(r) {
|
|
404
|
+
return r.timestamp();
|
|
405
405
|
},
|
|
406
|
-
parse: function(
|
|
407
|
-
return isNaN(Number(
|
|
406
|
+
parse: function(r) {
|
|
407
|
+
return isNaN(Number(r)) ? {} : n(Number(r)).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
|
|
414
|
+
format: function(r) {
|
|
415
|
+
return i(r.year() || n.MIN_YEAR, 4) + "-" + i(r.month() || n.MIN_MONTH, 2) + "-" + i(r.day() || n.MIN_DAY, 2);
|
|
416
416
|
},
|
|
417
|
-
parse: function(
|
|
418
|
-
var
|
|
417
|
+
parse: function(r) {
|
|
418
|
+
var o = Number(r.slice(0, 4)), d = Number(r.slice(5, 7)), g = Number(r.slice(8, 10));
|
|
419
419
|
return {
|
|
420
|
-
year:
|
|
420
|
+
year: o,
|
|
421
421
|
month: d,
|
|
422
422
|
day: g
|
|
423
423
|
};
|
|
@@ -427,14 +427,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
427
427
|
type: "string"
|
|
428
428
|
},
|
|
429
429
|
"%D": {
|
|
430
|
-
format: function(
|
|
431
|
-
return
|
|
430
|
+
format: function(r) {
|
|
431
|
+
return i(r.month() || n.MIN_MONTH, 2) + "/" + i(r.day() || n.MIN_DAY, 2) + "/" + i(r.year() || n.MIN_YEAR, 4);
|
|
432
432
|
},
|
|
433
|
-
parse: function(
|
|
434
|
-
var
|
|
433
|
+
parse: function(r) {
|
|
434
|
+
var o = Number(r.slice(0, 2)), d = Number(r.slice(3, 5)), g = Number(r.slice(6, 10));
|
|
435
435
|
return {
|
|
436
436
|
year: g,
|
|
437
|
-
month:
|
|
437
|
+
month: o,
|
|
438
438
|
day: d
|
|
439
439
|
};
|
|
440
440
|
},
|
|
@@ -442,11 +442,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
442
442
|
maxLength: 10,
|
|
443
443
|
type: "string"
|
|
444
444
|
}
|
|
445
|
-
},
|
|
445
|
+
}, U = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, M;
|
|
449
|
+
M = function(r, o, d) {
|
|
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`) : a(JSON.pars
|
|
|
455
455
|
minutes: !1,
|
|
456
456
|
seconds: !1,
|
|
457
457
|
milliseconds: !1
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
var
|
|
461
|
-
return this.leapYear() &&
|
|
462
|
-
},
|
|
458
|
+
}, r !== e && this.set(r, o, d), this;
|
|
459
|
+
}, M.fn = M.prototype, M.fn.dayCount = function() {
|
|
460
|
+
var r = this.month(), o = n.MAX_DAY_IN_MONTHS[r - (n.options("monthFromZero") ? 0 : 1)];
|
|
461
|
+
return this.leapYear() && r === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
|
|
462
|
+
}, M.fn.year = function(r) {
|
|
463
463
|
if (arguments.length !== 0)
|
|
464
|
-
(typeof
|
|
464
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_YEAR && Number(r) <= n.MAX_YEAR ? (this._d.setFullYear(Number(r)), this._i.year = !1) : this._i.year = Number(r) : (this._d.setFullYear(n.MIN_YEAR), this._i.year = !1);
|
|
465
465
|
else
|
|
466
466
|
return this._i.year === !1 ? this._d.getFullYear() : this._i.year;
|
|
467
467
|
return this;
|
|
468
|
-
},
|
|
468
|
+
}, M.fn.month = function(r) {
|
|
469
469
|
if (arguments.length !== 0)
|
|
470
|
-
(typeof
|
|
470
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MONTH && Number(r) <= n.MAX_MONTH ? (this._d.setMonth(n.options("monthFromZero") ? Number(r) : Number(r) - 1), this._i.month = !1) : this._i.month = Number(r) : (this._d.setMonth(n.options("monthFromZero") ? n.MIN_MONTH : n.MIN_MONTH - 1), this._i.month = !1);
|
|
471
471
|
else
|
|
472
|
-
return this._i.month === !1 ?
|
|
472
|
+
return this._i.month === !1 ? n.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
|
|
473
473
|
return this;
|
|
474
|
-
},
|
|
474
|
+
}, M.fn.day = function(r) {
|
|
475
475
|
if (arguments.length !== 0)
|
|
476
|
-
(typeof
|
|
476
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_DAY && Number(r) <= this.dayCount() ? (this._d.setDate(Number(r)), this._i.day = !1) : this._i.day = Number(r) : (this._d.setDate(n.MIN_DAY), this._i.day = !1);
|
|
477
477
|
else
|
|
478
478
|
return this._i.day === !1 ? this._d.getDate() : this._i.day;
|
|
479
479
|
return this;
|
|
480
|
-
},
|
|
480
|
+
}, M.fn.hours = function(r) {
|
|
481
481
|
if (arguments.length !== 0)
|
|
482
|
-
(typeof
|
|
482
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_HOURS && Number(r) <= n.MAX_HOURS ? (this._d.setHours(Number(r)), this._i.hours = !1) : this._i.hours = Number(r) : (this._d.setHours(n.MIN_HOURS), this._i.hours = !1);
|
|
483
483
|
else
|
|
484
484
|
return this._i.hours === !1 ? this._d.getHours() : this._i.hours;
|
|
485
485
|
return this;
|
|
486
|
-
},
|
|
486
|
+
}, M.fn.minutes = function(r) {
|
|
487
487
|
if (arguments.length !== 0)
|
|
488
|
-
(typeof
|
|
488
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MINUTES && Number(r) <= n.MAX_MINUTES ? (this._d.setMinutes(Number(r)), this._i.minutes = !1) : this._i.minutes = Number(r) : (this._d.setMinutes(n.MIN_MINUTES), this._i.minutes = !1);
|
|
489
489
|
else
|
|
490
490
|
return this._i.minutes === !1 ? this._d.getMinutes() : this._i.minutes;
|
|
491
491
|
return this;
|
|
492
|
-
},
|
|
492
|
+
}, M.fn.seconds = function(r) {
|
|
493
493
|
if (arguments.length !== 0)
|
|
494
|
-
(typeof
|
|
494
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_SECONDS && Number(r) <= n.MAX_SECONDS ? (this._d.setSeconds(Number(r)), this._i.seconds = !1) : this._i.seconds = Number(r) : (this._d.setSeconds(n.MIN_SECONDS), this._i.seconds = !1);
|
|
495
495
|
else
|
|
496
496
|
return this._i.seconds === !1 ? this._d.getSeconds() : this._i.seconds;
|
|
497
497
|
return this;
|
|
498
|
-
},
|
|
498
|
+
}, M.fn.milliseconds = function(r) {
|
|
499
499
|
if (arguments.length !== 0)
|
|
500
|
-
(typeof
|
|
500
|
+
(typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MILLISECONDS && Number(r) <= n.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(r)), this._i.milliseconds = !1) : this._i.milliseconds = Number(r) : (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(((
|
|
507
|
-
},
|
|
504
|
+
}, M.fn.week = function() {
|
|
505
|
+
var r = 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 - r.getTime()) / 864e5 + r.getDay() + 1) / 7);
|
|
507
|
+
}, M.fn.set = function(r, o, d) {
|
|
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`) : a(JSON.pars
|
|
|
513
513
|
minutes: !1,
|
|
514
514
|
seconds: !1,
|
|
515
515
|
milliseconds: !1
|
|
516
|
-
},
|
|
516
|
+
}, r === e)
|
|
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 g,
|
|
524
|
-
if (
|
|
525
|
-
return
|
|
518
|
+
if (r instanceof Date)
|
|
519
|
+
return this._d = r, this;
|
|
520
|
+
if (typeof r == "number")
|
|
521
|
+
return this._d = new Date(r * (n.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
522
|
+
if (typeof r == "object" && (r instanceof Array ? (this.day(n.MIN_DAY), this.year(r[0]), this.month(r[1]), this.day(r[2]), this.hours(r[3]), this.minutes(r[4]), this.seconds(r[5]), this.milliseconds(r[6])) : (this.day(n.MIN_DAY), this.year(r.year), this.month(r.month), this.day(r.day), this.hours(r.hours), this.minutes(r.minutes), this.seconds(r.seconds), this.milliseconds(r.milliseconds))), typeof r == "string") {
|
|
523
|
+
var g, w = [], b, B, z = [], W = 0, x = 0, Y, X, G = {}, P;
|
|
524
|
+
if (r === e)
|
|
525
|
+
return b = a(this, d), b === e && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -530,26 +530,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
530
530
|
minutes: -1,
|
|
531
531
|
seconds: -1,
|
|
532
532
|
milliseconds: -1
|
|
533
|
-
}),
|
|
534
|
-
for (
|
|
535
|
-
if (
|
|
536
|
-
if (B =
|
|
537
|
-
switch (
|
|
533
|
+
}), b;
|
|
534
|
+
for (o === e && (o = n.detectFormat(r)); W < o.length; ) {
|
|
535
|
+
if (o.charAt(W) === "%") {
|
|
536
|
+
if (B = o.charAt(W) + o.charAt(W + 1), k[B] !== e) {
|
|
537
|
+
switch (Y = 0, X = "", k[B].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (;
|
|
540
|
-
X +=
|
|
539
|
+
for (; Y < k[B].maxLength && x + Y < r.length && !isNaN(Number(r.charAt(x + Y))); )
|
|
540
|
+
X += r.charAt(x + Y), Y += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (;
|
|
544
|
-
X +=
|
|
543
|
+
for (; Y < k[B].maxLength && x + Y < r.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(r.charAt(x + Y)); )
|
|
544
|
+
X += r.charAt(x + Y), Y += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (;
|
|
548
|
-
X +=
|
|
547
|
+
for (; Y < k[B].maxLength && x + Y < r.length; )
|
|
548
|
+
X += r.charAt(x + Y), Y += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (
|
|
552
|
-
return
|
|
551
|
+
if (Y < k[B].minLength)
|
|
552
|
+
return b = a(this, d), b === e && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
555
555
|
day: -1,
|
|
@@ -557,11 +557,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
557
557
|
minutes: -1,
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
|
-
}),
|
|
561
|
-
|
|
560
|
+
}), b;
|
|
561
|
+
w.push(B), z.push(X), Y -= 1, x += Y, W += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (
|
|
564
|
-
return
|
|
563
|
+
} else if (r.charAt(x) !== o.charAt(W))
|
|
564
|
+
return b = a(this, d), b === e && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -569,51 +569,51 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
569
569
|
minutes: -1,
|
|
570
570
|
seconds: -1,
|
|
571
571
|
milliseconds: -1
|
|
572
|
-
}),
|
|
572
|
+
}), b;
|
|
573
573
|
W += 1, x += 1;
|
|
574
574
|
}
|
|
575
|
-
for (g in
|
|
576
|
-
|
|
577
|
-
year:
|
|
578
|
-
month:
|
|
579
|
-
day:
|
|
580
|
-
hours:
|
|
581
|
-
minutes:
|
|
582
|
-
seconds:
|
|
575
|
+
for (g in w)
|
|
576
|
+
w.hasOwnProperty(g) && k.hasOwnProperty(w[g]) && (P = k[w[g]].parse(z[g]), G = {
|
|
577
|
+
year: P.year !== e ? P.year : G.year,
|
|
578
|
+
month: P.month !== e ? P.month : G.month,
|
|
579
|
+
day: P.day !== e ? P.day : G.day,
|
|
580
|
+
hours: P.hours !== e ? P.hours : G.hours,
|
|
581
|
+
minutes: P.minutes !== e ? P.minutes : G.minutes,
|
|
582
|
+
seconds: P.seconds !== e ? P.seconds : G.seconds
|
|
583
583
|
});
|
|
584
|
-
this.day(
|
|
584
|
+
this.day(n.MIN_DAY), this.year(G.year), this.month(G.month), this.day(G.day), this.hours(G.hours), this.minutes(G.minutes), this.seconds(G.seconds), this.milliseconds(G.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
|
-
},
|
|
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
|
+
}, M.fn.leapYear = function() {
|
|
588
|
+
var r = this.year();
|
|
589
|
+
return r % 4 === 0 ? r % 100 === 0 ? r % 400 === 0 : !0 : !1;
|
|
590
|
+
}, M.fn.timestamp = function(r) {
|
|
591
|
+
return arguments.length !== 0 ? (this._d = new Date(Number(r) * (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
|
+
}, M.fn.utc = function(r) {
|
|
593
|
+
return arguments.length !== 0 ? (this._d = new Date(Number(r) * (n.options("useMilliseconds") ? 1 : 1e3)), this) : n.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
|
|
594
|
+
}, M.fn.dayOfWeek = function(r) {
|
|
595
|
+
if (r === "long")
|
|
596
|
+
return L[this._d.getDay()];
|
|
597
|
+
if (r === "short")
|
|
598
|
+
return I[this._d.getDay()];
|
|
599
|
+
if (r === e)
|
|
600
600
|
return this._d.getDay();
|
|
601
|
-
if (
|
|
601
|
+
if (r === 0 || r === "Sunday")
|
|
602
602
|
return this.calc({ day: -this.dayOfWeek() });
|
|
603
|
-
if (
|
|
603
|
+
if (r === 1 || r === "Monday")
|
|
604
604
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -6 : 1) - this.dayOfWeek() });
|
|
605
|
-
if (
|
|
605
|
+
if (r === 2 || r === "Tuesday")
|
|
606
606
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -5 : 2) - this.dayOfWeek() });
|
|
607
|
-
if (
|
|
607
|
+
if (r === 3 || r === "Wednesday")
|
|
608
608
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -4 : 3) - this.dayOfWeek() });
|
|
609
|
-
if (
|
|
609
|
+
if (r === 4 || r === "Thursday")
|
|
610
610
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -3 : 4) - this.dayOfWeek() });
|
|
611
|
-
if (
|
|
611
|
+
if (r === 5 || r === "Friday")
|
|
612
612
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
|
|
613
|
-
if (
|
|
613
|
+
if (r === 6 || r === "Saturday")
|
|
614
614
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
|
|
615
|
-
},
|
|
616
|
-
switch (
|
|
615
|
+
}, M.fn.timezone = function(r) {
|
|
616
|
+
switch (r) {
|
|
617
617
|
case "hours":
|
|
618
618
|
return Math.floor(this._d.getTimezoneOffset() / 60);
|
|
619
619
|
case "minutes":
|
|
@@ -621,12 +621,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
621
621
|
default:
|
|
622
622
|
return this._d.getTimezoneOffset() * 60;
|
|
623
623
|
}
|
|
624
|
-
},
|
|
625
|
-
switch (
|
|
624
|
+
}, M.fn.get = function(r) {
|
|
625
|
+
switch (r) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
628
628
|
this.year(),
|
|
629
|
-
this.month() - (
|
|
629
|
+
this.month() - (n.options("monthFromZero") ? 0 : 1),
|
|
630
630
|
this.day(),
|
|
631
631
|
this.hours(),
|
|
632
632
|
this.minutes(),
|
|
@@ -636,7 +636,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
636
636
|
case "DateUTC":
|
|
637
637
|
return new Date(Date.UTC(
|
|
638
638
|
this.year(),
|
|
639
|
-
this.month() - (
|
|
639
|
+
this.month() - (n.options("monthFromZero") ? 0 : 1),
|
|
640
640
|
this.day(),
|
|
641
641
|
this.hours(),
|
|
642
642
|
this.minutes(),
|
|
@@ -670,17 +670,17 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
670
670
|
timestamp: this.timestamp()
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
},
|
|
674
|
-
for (var
|
|
675
|
-
|
|
673
|
+
}, M.fn.format = function(r) {
|
|
674
|
+
for (var o = 0, d = "", g; o < r.length; )
|
|
675
|
+
r.charAt(o) === "%" ? (g = r.charAt(o) + r.charAt(o + 1), k[g] !== e ? (d += k[g].format(this), o += 1) : d += "%") : d += r.charAt(o), o += 1;
|
|
676
676
|
return d;
|
|
677
|
-
},
|
|
677
|
+
}, M.fn.valid = function() {
|
|
678
678
|
return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
|
|
679
|
-
},
|
|
679
|
+
}, M.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var d = this.timestamp(), g =
|
|
683
|
-
switch (
|
|
681
|
+
}, M.fn.between = function(r, o) {
|
|
682
|
+
var d = this.timestamp(), g = r.timestamp();
|
|
683
|
+
switch (o) {
|
|
684
684
|
case "year":
|
|
685
685
|
return Math.floor((g - d) / 31556952);
|
|
686
686
|
case "month":
|
|
@@ -696,149 +696,149 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
|
|
|
696
696
|
default:
|
|
697
697
|
return e;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
700
|
-
return
|
|
701
|
-
},
|
|
702
|
-
return new
|
|
703
|
-
},
|
|
704
|
-
if (
|
|
705
|
-
return
|
|
706
|
-
if (
|
|
707
|
-
if (
|
|
708
|
-
return
|
|
709
|
-
|
|
699
|
+
}, M.fn.calc = function(r) {
|
|
700
|
+
return r.year !== e && this._d.setFullYear(this._d.getFullYear() + r.year), r.month !== e && this._d.setMonth(this._d.getMonth() + r.month), r.day !== e && this._d.setDate(this._d.getDate() + r.day), r.hours !== e && this._d.setHours(this._d.getHours() + r.hours), r.minutes !== e && this._d.setMinutes(this._d.getMinutes() + r.minutes), r.seconds !== e && this._d.setSeconds(this._d.getSeconds() + r.seconds), r.milliseconds !== e && this._d.setMilliseconds(this._d.getMilliseconds() + r.milliseconds), this;
|
|
701
|
+
}, n = function(r, o, d) {
|
|
702
|
+
return new M(r, o, d);
|
|
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(r, o) {
|
|
704
|
+
if (r === e)
|
|
705
|
+
return U;
|
|
706
|
+
if (U.hasOwnProperty(r)) {
|
|
707
|
+
if (o === e)
|
|
708
|
+
return U[r];
|
|
709
|
+
U[r] = o, r === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
|
|
710
710
|
}
|
|
711
711
|
return e;
|
|
712
|
-
},
|
|
713
|
-
return s.tempus =
|
|
714
|
-
},
|
|
715
|
-
var
|
|
716
|
-
if (typeof
|
|
712
|
+
}, n.noConflict = function() {
|
|
713
|
+
return s.tempus = h, n;
|
|
714
|
+
}, n.generate = function(r) {
|
|
715
|
+
var o, d, g, w, b, B, z, W;
|
|
716
|
+
if (typeof r.dateFrom != "number" && (r.dateFrom instanceof M ? o = r.dateFrom.utc() : o = n(r.dateFrom, r.formatFrom).utc()), typeof r.dateTo != "number" && (r.dateTo instanceof M ? d = r.dateTo.utc() : d = n(r.dateTo, r.formatTo !== e ? r.formatTo : r.formatFrom).utc()), typeof r.period == "number" ? b = {
|
|
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: r.period
|
|
723
|
+
} : typeof r.period == "string" ? b = {
|
|
724
|
+
year: r.period === "year" ? 1 : 0,
|
|
725
|
+
month: r.period === "month" ? 1 : 0,
|
|
726
|
+
day: r.period === "day" ? 1 : 0,
|
|
727
|
+
hours: r.period === "hours" ? 1 : 0,
|
|
728
|
+
minutes: r.period === "minutes" ? 1 : 0,
|
|
729
|
+
seconds: r.period === "seconds" ? 1 : 0
|
|
730
|
+
} : typeof r.period == "object" && (b = {
|
|
731
|
+
year: r.period.year !== e ? r.period.year : 0,
|
|
732
|
+
month: r.period.month !== e ? r.period.month : 0,
|
|
733
|
+
day: r.period.day !== e ? r.period.day : 0,
|
|
734
|
+
hours: r.period.hours !== e ? r.period.hours : 0,
|
|
735
|
+
minutes: r.period.minutes !== e ? r.period.minutes : 0,
|
|
736
|
+
seconds: r.period.seconds !== e ? r.period.seconds : 0
|
|
737
|
+
}), r.groupBy === e ? B = r.asObject === !0 ? {} : [] : (B = [], B.push([]), z = n(o).get()[r.groupBy]), W = function(X, G, P) {
|
|
738
|
+
return r.asObject === !0 ? r.format !== e ? X[n(G).format(r.format)] = {} : X[n(G).format("%F %H:%M:%S")] = {} : r.format !== e ? X.push(P ? null : n(G).format(r.format)) : X.push(P ? null : n(G)), X;
|
|
739
|
+
}, r.groupBy !== e && r.fillNulls) {
|
|
740
740
|
var x = {
|
|
741
|
-
year:
|
|
742
|
-
month:
|
|
743
|
-
day:
|
|
744
|
-
hours:
|
|
745
|
-
minutes:
|
|
746
|
-
seconds:
|
|
747
|
-
milliseconds:
|
|
741
|
+
year: b.year ? -b.year : e,
|
|
742
|
+
month: b.month ? -b.month : e,
|
|
743
|
+
day: b.day ? -b.day : e,
|
|
744
|
+
hours: b.hours ? -b.hours : e,
|
|
745
|
+
minutes: b.minutes ? -b.minutes : e,
|
|
746
|
+
seconds: b.seconds ? -b.seconds : e,
|
|
747
|
+
milliseconds: b.milliseconds ? -b.milliseconds : e
|
|
748
748
|
};
|
|
749
|
-
for (g =
|
|
750
|
-
W(B[B.length - 1], g, !0), g =
|
|
751
|
-
if (
|
|
752
|
-
var
|
|
753
|
-
for (g =
|
|
754
|
-
W(B[B.length - 1], g, !0), g =
|
|
749
|
+
for (g = n(o).calc(x).utc(); n(g).get()[r.groupBy] === z; )
|
|
750
|
+
W(B[B.length - 1], g, !0), g = n(g).calc(x).utc();
|
|
751
|
+
if (r.groupBy === "week") {
|
|
752
|
+
var Y = n(o).dayOfWeek();
|
|
753
|
+
for (g = n(o).dayOfWeek(0).utc(); B[0].length < Y && g < o; )
|
|
754
|
+
W(B[B.length - 1], g, !0), g = n(g).calc(b).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (;
|
|
758
|
-
|
|
759
|
-
if (
|
|
760
|
-
for (
|
|
761
|
-
W(B[B.length - 1],
|
|
757
|
+
for (; o <= d; )
|
|
758
|
+
r.groupBy === e ? W(B, o) : n(o).get()[r.groupBy] === z ? W(B[B.length - 1], o) : (B.push([]), W(B[B.length - 1], o), z = n(o).get()[r.groupBy]), o = n(o).calc(b).utc();
|
|
759
|
+
if (r.groupBy !== e && r.fillNulls)
|
|
760
|
+
for (w = n(d).calc(b).utc(); n(w).get()[r.groupBy] === z; )
|
|
761
|
+
W(B[B.length - 1], w, !0), w = n(w).calc(b).utc();
|
|
762
762
|
return B;
|
|
763
|
-
},
|
|
764
|
-
switch (
|
|
763
|
+
}, n.monthNames = function(r) {
|
|
764
|
+
switch (r) {
|
|
765
765
|
case "long":
|
|
766
|
-
return
|
|
766
|
+
return N;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return y;
|
|
769
769
|
}
|
|
770
|
-
},
|
|
771
|
-
switch (
|
|
770
|
+
}, n.dayNames = function(r) {
|
|
771
|
+
switch (r) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return L;
|
|
774
774
|
default:
|
|
775
|
-
return
|
|
775
|
+
return I;
|
|
776
776
|
}
|
|
777
|
-
},
|
|
778
|
-
if (
|
|
779
|
-
c =
|
|
777
|
+
}, n.lang = function(r) {
|
|
778
|
+
if (r !== e)
|
|
779
|
+
c = r, f[c] === e && (c = "en"), N = O(), y = T(), L = _(), I = R();
|
|
780
780
|
else
|
|
781
781
|
return c;
|
|
782
782
|
return e;
|
|
783
|
-
},
|
|
783
|
+
}, n.availableLangs = function() {
|
|
784
784
|
return Object.keys(f);
|
|
785
|
-
},
|
|
786
|
-
|
|
787
|
-
format:
|
|
785
|
+
}, n.registerFormat = function(r, o, d, g, w, b) {
|
|
786
|
+
k[r] = {
|
|
787
|
+
format: o,
|
|
788
788
|
parse: d,
|
|
789
789
|
minLength: g,
|
|
790
|
-
maxLength:
|
|
791
|
-
type:
|
|
790
|
+
maxLength: w,
|
|
791
|
+
type: b
|
|
792
792
|
};
|
|
793
|
-
},
|
|
794
|
-
delete
|
|
795
|
-
},
|
|
796
|
-
var
|
|
797
|
-
return
|
|
793
|
+
}, n.unregisterFormat = function(r) {
|
|
794
|
+
delete k[r];
|
|
795
|
+
}, n.detectFormat = function(r) {
|
|
796
|
+
var o, d, g;
|
|
797
|
+
return o = A(r, 0), o !== "" && (g = 10), d = r.charAt(g), (d === "T" || d === " ") && (o += d, g += 1), o += l(r, g), o;
|
|
798
798
|
}, u = {
|
|
799
|
-
TempusDate:
|
|
800
|
-
},
|
|
801
|
-
if (
|
|
802
|
-
return u[
|
|
803
|
-
u[
|
|
804
|
-
},
|
|
805
|
-
typeof
|
|
806
|
-
f =
|
|
807
|
-
}, function(
|
|
799
|
+
TempusDate: M
|
|
800
|
+
}, n.classes = function(r, o) {
|
|
801
|
+
if (o === e)
|
|
802
|
+
return u[r];
|
|
803
|
+
u[r] = o;
|
|
804
|
+
}, n.loadTranslations = function(r) {
|
|
805
|
+
typeof r == "object" ? f = r : typeof r == "string" && H(r, function(o) {
|
|
806
|
+
f = o;
|
|
807
|
+
}, function(o) {
|
|
808
808
|
});
|
|
809
|
-
}, c = (
|
|
810
|
-
}).call(
|
|
811
|
-
})(
|
|
812
|
-
var
|
|
813
|
-
const
|
|
814
|
-
var
|
|
809
|
+
}, c = (m.language || m.systemLanguage || m.userLanguage || "en").substr(0, 2).toLowerCase(), f[c] === e && (c = "en"), N = O(), y = T(), L = _(), I = R(), p.exports && (t = p.exports = n), t.tempus = n;
|
|
810
|
+
}).call(oe);
|
|
811
|
+
})(Ht, Ht.exports);
|
|
812
|
+
var Ae = Ht.exports;
|
|
813
|
+
const dt = /* @__PURE__ */ ae(Ae);
|
|
814
|
+
var yt, Jt, pt, Nt, Ot, _t, it, gt, Tt, jt, Et, Kt, Q, st, Z, at, V, At, Lt, vt, lt, Ut;
|
|
815
815
|
const j = class j {
|
|
816
|
-
constructor(
|
|
816
|
+
constructor(t) {
|
|
817
817
|
/**
|
|
818
818
|
* Режим «прогресс по доле завершённых подкоманд» — только когда пачка похожа на
|
|
819
819
|
* много параллельных list (crm.deal.list × N и т.п.). Иначе сохраняется старая
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
|
|
823
|
+
D(this, yt);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
827
827
|
*/
|
|
828
|
-
|
|
828
|
+
D(this, it);
|
|
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
|
+
D(this, Tt);
|
|
836
836
|
/**
|
|
837
837
|
* Уведомляет подписчиков о текущем состоянии лимита.
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
|
|
841
|
+
D(this, Et);
|
|
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
|
+
D(this, Q);
|
|
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
|
+
D(this, Z);
|
|
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
|
+
D(this, V);
|
|
867
867
|
/**
|
|
868
868
|
* Выполняет BX24.callMethod с таймаутом ожидания ответа.
|
|
869
869
|
*
|
|
@@ -871,14 +871,14 @@ const j = class j {
|
|
|
871
871
|
* @param {Object} params - Параметры REST-метода.
|
|
872
872
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
873
|
*/
|
|
874
|
-
|
|
874
|
+
D(this, Lt);
|
|
875
875
|
/**
|
|
876
876
|
* Resets mutable runtime state before each public batch run.
|
|
877
877
|
* @param {Function} progressCall - Progress callback for current run.
|
|
878
878
|
* @returns {void}
|
|
879
879
|
*/
|
|
880
|
-
|
|
881
|
-
typeof
|
|
880
|
+
D(this, lt);
|
|
881
|
+
typeof t == "function" ? (this.callBatch = t, this.callMethod = null) : (this.callBatch = (t == null ? void 0 : t.callBatch) || null, this.callMethod = (t == null ? void 0 : t.callMethod) || null), this.result = {}, this.errors = {}, this.timeLimit = {
|
|
882
882
|
limit: !1,
|
|
883
883
|
date: void 0,
|
|
884
884
|
pauseMs: void 0
|
|
@@ -891,31 +891,31 @@ const j = class j {
|
|
|
891
891
|
get progressPercent() {
|
|
892
892
|
if (!this.progressData)
|
|
893
893
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
894
|
-
const
|
|
895
|
-
if (
|
|
894
|
+
const t = this.totalBatchCommands || 0;
|
|
895
|
+
if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && E(this, yt, Jt).call(this)) {
|
|
896
896
|
let A = 0;
|
|
897
897
|
for (const c of this.batchCommandKeyOrder) {
|
|
898
898
|
const f = this.progressData[c];
|
|
899
899
|
if (!f)
|
|
900
900
|
continue;
|
|
901
|
-
const O = Number(f.total) || 0,
|
|
902
|
-
O === 0 &&
|
|
901
|
+
const O = Number(f.total) || 0, T = Number(f.count) || 0;
|
|
902
|
+
O === 0 && T === 0 ? A += 1 : O > 0 && (A += Math.min(1, T / O));
|
|
903
903
|
}
|
|
904
|
-
const
|
|
905
|
-
let
|
|
906
|
-
const u =
|
|
907
|
-
return { percent:
|
|
904
|
+
const h = A / t * 100;
|
|
905
|
+
let n = Math.max(0, Math.min(100, Math.floor(h)));
|
|
906
|
+
const u = t, m = Math.min(t, Math.floor(A));
|
|
907
|
+
return { percent: n, allCount: m, allTotal: u };
|
|
908
908
|
}
|
|
909
909
|
let e = 0, s = 0;
|
|
910
910
|
for (const A of Object.values(this.progressData)) {
|
|
911
|
-
const { total:
|
|
912
|
-
e +=
|
|
911
|
+
const { total: h, count: n } = A;
|
|
912
|
+
e += h ?? 0, s += n ?? 0;
|
|
913
913
|
}
|
|
914
|
-
const
|
|
915
|
-
let
|
|
916
|
-
e ?
|
|
917
|
-
let
|
|
918
|
-
return e > 0 && s >= e && (
|
|
914
|
+
const i = Number(this.chunkRate) || 0;
|
|
915
|
+
let a = 0;
|
|
916
|
+
e ? a = s / e * 100 * i + this.totalProgress : s === 0 && e === 0 ? a = 100 * i + this.totalProgress : a = 100, a = Math.max(0, Math.min(a, 100));
|
|
917
|
+
let l = Math.floor(a);
|
|
918
|
+
return e > 0 && s >= e && (l = 100), { percent: l, allCount: s, allTotal: e };
|
|
919
919
|
}
|
|
920
920
|
/**
|
|
921
921
|
* Обновление данных прогресса выполнения
|
|
@@ -924,38 +924,38 @@ const j = class j {
|
|
|
924
924
|
* @param {Object} params.value - Значение ответа от API
|
|
925
925
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
926
926
|
*/
|
|
927
|
-
setProgressData({ key:
|
|
927
|
+
setProgressData({ key: t, value: e, type: s }) {
|
|
928
928
|
var f, O;
|
|
929
929
|
if (!this.progressCall)
|
|
930
930
|
return;
|
|
931
|
-
const
|
|
932
|
-
let
|
|
931
|
+
const i = this.getData(e.data()), a = Array.isArray(i) ? i.length : 0;
|
|
932
|
+
let l = a;
|
|
933
933
|
if (typeof e.total == "function") {
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
const
|
|
937
|
-
Number.isFinite(
|
|
934
|
+
const T = e.total();
|
|
935
|
+
if (T != null && T !== "") {
|
|
936
|
+
const _ = Number(T);
|
|
937
|
+
Number.isFinite(_) && (l = _);
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
|
-
s === "count" && (
|
|
940
|
+
s === "count" && (l = a);
|
|
941
941
|
let A = 1;
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
if (this.progressData[
|
|
945
|
-
total:
|
|
946
|
-
count: Math.min(u,
|
|
942
|
+
i && (A = a), this.progressData || (this.progressData = {});
|
|
943
|
+
const h = ((f = this.progressData[t]) == null ? void 0 : f.total) ?? 0, n = ((O = this.progressData[t]) == null ? void 0 : O.count) ?? 0, u = A + n, m = Math.max(h, l ?? 0, u);
|
|
944
|
+
if (this.progressData[t] = {
|
|
945
|
+
total: m,
|
|
946
|
+
count: Math.min(u, m)
|
|
947
947
|
}, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
|
|
948
|
-
E(this, it,
|
|
948
|
+
E(this, it, gt).call(this);
|
|
949
949
|
return;
|
|
950
950
|
}
|
|
951
|
-
E(this, it,
|
|
951
|
+
E(this, it, gt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
952
952
|
if (!this.progressCall) {
|
|
953
953
|
this.clearProgressData();
|
|
954
954
|
return;
|
|
955
955
|
}
|
|
956
|
-
E(this, it,
|
|
957
|
-
const { percent:
|
|
958
|
-
|
|
956
|
+
E(this, it, gt).call(this);
|
|
957
|
+
const { percent: T } = this.progressPercent;
|
|
958
|
+
T >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
|
|
959
959
|
}, this.progressDelay));
|
|
960
960
|
}
|
|
961
961
|
/**
|
|
@@ -963,10 +963,10 @@ const j = class j {
|
|
|
963
963
|
* @param {Object} data - Ответ от API
|
|
964
964
|
* @returns {any} Данные из ответа
|
|
965
965
|
*/
|
|
966
|
-
getData(
|
|
967
|
-
if (
|
|
968
|
-
return
|
|
969
|
-
let e = (
|
|
966
|
+
getData(t) {
|
|
967
|
+
if (t == null)
|
|
968
|
+
return t;
|
|
969
|
+
let e = (t == null ? void 0 : t.items) ?? (t == null ? void 0 : t.tasks) ?? (t == null ? void 0 : t.types) ?? (t == null ? void 0 : t.type) ?? (t == null ? void 0 : t.fields) ?? (t == null ? void 0 : t.workgroups) ?? t;
|
|
970
970
|
return e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.result) && (e = e.result), e;
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
@@ -977,8 +977,8 @@ const j = class j {
|
|
|
977
977
|
* @param {number|undefined} pauseMs - Длительность текущей лимит-паузы (мс); при снятии лимита не передаётся.
|
|
978
978
|
* @returns {void}
|
|
979
979
|
*/
|
|
980
|
-
setTimeLimitState(
|
|
981
|
-
this.timeLimit.limit = !!
|
|
980
|
+
setTimeLimitState(t, e, s) {
|
|
981
|
+
this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof s == "number" && s > 0 ? this.timeLimit.pauseMs = s : this.timeLimit.pauseMs = void 0, E(this, Et, Kt).call(this);
|
|
982
982
|
}
|
|
983
983
|
/**
|
|
984
984
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -987,14 +987,14 @@ const j = class j {
|
|
|
987
987
|
* @param {(state: {limit: boolean, date?: string, pauseMs?: number}) => void} callback - Обработчик состояния лимита.
|
|
988
988
|
* @returns {() => void} Функция отписки.
|
|
989
989
|
*/
|
|
990
|
-
subscribeTimeLimit(
|
|
991
|
-
return typeof
|
|
992
|
-
} : (this.timeLimitListeners.add(
|
|
990
|
+
subscribeTimeLimit(t) {
|
|
991
|
+
return typeof t != "function" ? () => {
|
|
992
|
+
} : (this.timeLimitListeners.add(t), t({
|
|
993
993
|
limit: this.timeLimit.limit,
|
|
994
994
|
date: this.timeLimit.date,
|
|
995
995
|
pauseMs: this.timeLimit.pauseMs
|
|
996
996
|
}), () => {
|
|
997
|
-
this.timeLimitListeners.delete(
|
|
997
|
+
this.timeLimitListeners.delete(t);
|
|
998
998
|
});
|
|
999
999
|
}
|
|
1000
1000
|
/**
|
|
@@ -1004,29 +1004,29 @@ const j = class j {
|
|
|
1004
1004
|
* @param {Object} request - Объект запроса {method, params}
|
|
1005
1005
|
* @returns {Array} Массив запросов (может быть один или несколько)
|
|
1006
1006
|
*/
|
|
1007
|
-
splitLargeFilters(
|
|
1008
|
-
const { method: s, params:
|
|
1009
|
-
if (!
|
|
1010
|
-
return [{ key:
|
|
1011
|
-
const
|
|
1012
|
-
if (!
|
|
1013
|
-
return [{ key:
|
|
1014
|
-
for (const [
|
|
1015
|
-
if (!String(
|
|
1016
|
-
const
|
|
1017
|
-
for (let
|
|
1018
|
-
const u = A.slice(
|
|
1019
|
-
|
|
1020
|
-
key:
|
|
1007
|
+
splitLargeFilters(t, e) {
|
|
1008
|
+
const { method: s, params: i } = e;
|
|
1009
|
+
if (!i)
|
|
1010
|
+
return [{ key: t, request: e }];
|
|
1011
|
+
const a = i.filter || i.FILTER;
|
|
1012
|
+
if (!a || typeof a != "object" || Array.isArray(a))
|
|
1013
|
+
return [{ key: t, request: e }];
|
|
1014
|
+
for (const [l, A] of Object.entries(a))
|
|
1015
|
+
if (!String(l).trim().startsWith("!") && Array.isArray(A) && A.length > this.filterChunkSize) {
|
|
1016
|
+
const h = [];
|
|
1017
|
+
for (let n = 0; n < A.length; n += this.filterChunkSize) {
|
|
1018
|
+
const u = A.slice(n, n + this.filterChunkSize), m = n === 0 ? t : `${t}__chunk_${Math.floor(n / this.filterChunkSize)}`, c = { ...i };
|
|
1019
|
+
i.filter ? (c.filter = { ...a }, c.filter[l] = u) : i.FILTER && (c.FILTER = { ...a }, c.FILTER[l] = u), h.push({
|
|
1020
|
+
key: m,
|
|
1021
1021
|
request: { method: s, params: c },
|
|
1022
|
-
originalKey:
|
|
1023
|
-
filterKey:
|
|
1024
|
-
chunkIndex: Math.floor(
|
|
1022
|
+
originalKey: t,
|
|
1023
|
+
filterKey: l,
|
|
1024
|
+
chunkIndex: Math.floor(n / this.filterChunkSize)
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
1027
|
-
return
|
|
1027
|
+
return h;
|
|
1028
1028
|
}
|
|
1029
|
-
return [{ key:
|
|
1029
|
+
return [{ key: t, request: e }];
|
|
1030
1030
|
}
|
|
1031
1031
|
/**
|
|
1032
1032
|
* Объединяет результаты разбитых запросов обратно в один результат
|
|
@@ -1034,14 +1034,14 @@ const j = class j {
|
|
|
1034
1034
|
* @param {string} originalKey - Оригинальный ключ запроса
|
|
1035
1035
|
* @returns {Array} Объединенный массив результатов
|
|
1036
1036
|
*/
|
|
1037
|
-
mergeSplitResults(
|
|
1038
|
-
const s = [],
|
|
1039
|
-
const
|
|
1040
|
-
return
|
|
1037
|
+
mergeSplitResults(t, e) {
|
|
1038
|
+
const s = [], i = String(e).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), l = Object.keys(t).filter((A) => a.test(A)).sort((A, h) => {
|
|
1039
|
+
const n = A.match(/__chunk_(\d+)$/), u = h.match(/__chunk_(\d+)$/);
|
|
1040
|
+
return n ? u ? parseInt(n[1]) - parseInt(u[1]) : 1 : -1;
|
|
1041
1041
|
});
|
|
1042
|
-
for (const A of
|
|
1043
|
-
const
|
|
1044
|
-
Array.isArray(
|
|
1042
|
+
for (const A of l) {
|
|
1043
|
+
const h = t[A];
|
|
1044
|
+
Array.isArray(h) ? s.push(...h) : h && s.push(h);
|
|
1045
1045
|
}
|
|
1046
1046
|
return s;
|
|
1047
1047
|
}
|
|
@@ -1060,26 +1060,26 @@ const j = class j {
|
|
|
1060
1060
|
* @param {Function} callback - Callback функция для обработки результата
|
|
1061
1061
|
* @returns {Promise<void>}
|
|
1062
1062
|
*/
|
|
1063
|
-
callBatchWithTimeout(
|
|
1064
|
-
return new Promise((s,
|
|
1065
|
-
let
|
|
1066
|
-
const A = async (
|
|
1067
|
-
if (!
|
|
1068
|
-
|
|
1063
|
+
callBatchWithTimeout(t, e) {
|
|
1064
|
+
return new Promise((s, i) => {
|
|
1065
|
+
let a = !1, l = null;
|
|
1066
|
+
const A = async (n) => {
|
|
1067
|
+
if (!a) {
|
|
1068
|
+
a = !0, l && clearTimeout(l);
|
|
1069
1069
|
try {
|
|
1070
|
-
await Promise.resolve(e(
|
|
1070
|
+
await Promise.resolve(e(n)), s();
|
|
1071
1071
|
} catch (u) {
|
|
1072
|
-
console.error("Error in callBatch callback:", u),
|
|
1072
|
+
console.error("Error in callBatch callback:", u), i(u);
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
|
-
},
|
|
1076
|
-
if (!
|
|
1077
|
-
|
|
1075
|
+
}, h = async () => {
|
|
1076
|
+
if (!a) {
|
|
1077
|
+
a = !0, l && clearTimeout(l), console.warn(
|
|
1078
1078
|
`Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
|
|
1079
1079
|
);
|
|
1080
|
-
const
|
|
1081
|
-
Object.keys(
|
|
1082
|
-
|
|
1080
|
+
const n = {};
|
|
1081
|
+
Object.keys(t).forEach((u) => {
|
|
1082
|
+
n[u] = {
|
|
1083
1083
|
error: () => ({
|
|
1084
1084
|
ex: {
|
|
1085
1085
|
error: "TIMEOUT",
|
|
@@ -1091,23 +1091,23 @@ const j = class j {
|
|
|
1091
1091
|
};
|
|
1092
1092
|
});
|
|
1093
1093
|
try {
|
|
1094
|
-
await Promise.resolve(e(
|
|
1094
|
+
await Promise.resolve(e(n)), s();
|
|
1095
1095
|
} catch (u) {
|
|
1096
1096
|
console.error("Error in timeout callback:", u), s();
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
};
|
|
1100
1100
|
try {
|
|
1101
|
-
this.callBatch(
|
|
1102
|
-
await A(
|
|
1101
|
+
this.callBatch(t, async (n) => {
|
|
1102
|
+
await A(n);
|
|
1103
1103
|
});
|
|
1104
|
-
} catch (
|
|
1105
|
-
|
|
1104
|
+
} catch (n) {
|
|
1105
|
+
a || console.error("Error calling callBatch:", n);
|
|
1106
1106
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
l = setTimeout(async () => {
|
|
1108
|
+
a || (console.warn(
|
|
1109
1109
|
`Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
|
|
1110
|
-
), await
|
|
1110
|
+
), await h());
|
|
1111
1111
|
}, this.requestTimeoutMs);
|
|
1112
1112
|
});
|
|
1113
1113
|
}
|
|
@@ -1129,35 +1129,35 @@ const j = class j {
|
|
|
1129
1129
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения.
|
|
1130
1130
|
* @returns {Promise<Object>}
|
|
1131
1131
|
*/
|
|
1132
|
-
async batch(
|
|
1133
|
-
E(this,
|
|
1134
|
-
const
|
|
1135
|
-
for (const [u,
|
|
1136
|
-
const c = this.arrayChunk(
|
|
1132
|
+
async batch(t, e, s = {}) {
|
|
1133
|
+
E(this, lt, Ut).call(this, e);
|
|
1134
|
+
const i = {}, a = {}, l = {};
|
|
1135
|
+
for (const [u, m] of Object.entries(t)) {
|
|
1136
|
+
const c = this.arrayChunk(m);
|
|
1137
1137
|
if (!c)
|
|
1138
1138
|
continue;
|
|
1139
1139
|
const f = this.splitLargeFilters(u, c);
|
|
1140
1140
|
if (f.length === 1)
|
|
1141
|
-
|
|
1141
|
+
a[u] = c;
|
|
1142
1142
|
else {
|
|
1143
|
-
|
|
1143
|
+
l[u] = [];
|
|
1144
1144
|
for (const O of f)
|
|
1145
|
-
|
|
1145
|
+
a[O.key] = O.request, l[u].push(O.key);
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
|
-
this.batchCommandKeyOrder = Object.keys(
|
|
1148
|
+
this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
|
|
1149
1149
|
(u) => {
|
|
1150
|
-
var
|
|
1151
|
-
return String(((
|
|
1150
|
+
var m;
|
|
1151
|
+
return String(((m = a[u]) == null ? void 0 : m.method) || "");
|
|
1152
1152
|
}
|
|
1153
|
-
), this.chunkRate = (1 / Math.ceil(Object.keys(
|
|
1154
|
-
let A = {},
|
|
1155
|
-
const
|
|
1156
|
-
for (const [u,
|
|
1153
|
+
), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
|
|
1154
|
+
let A = {}, h = 0;
|
|
1155
|
+
const n = Object.keys(a).length;
|
|
1156
|
+
for (const [u, m] of Object.entries(a)) {
|
|
1157
1157
|
if (!this.canContinue)
|
|
1158
1158
|
break;
|
|
1159
|
-
if (A[u] =
|
|
1160
|
-
const c =
|
|
1159
|
+
if (A[u] = m, Object.keys(A).length >= this.limit || h + 1 === n) {
|
|
1160
|
+
const c = h + 1 === n;
|
|
1161
1161
|
await this.batchChunk(
|
|
1162
1162
|
A,
|
|
1163
1163
|
void 0,
|
|
@@ -1167,21 +1167,21 @@ const j = class j {
|
|
|
1167
1167
|
oneBatch: !!(s != null && s.oneBatch)
|
|
1168
1168
|
}
|
|
1169
1169
|
), Object.entries(this.result).forEach(([f, O]) => {
|
|
1170
|
-
|
|
1170
|
+
i[f] = O;
|
|
1171
1171
|
}), this.totalProgress = Math.round(
|
|
1172
|
-
|
|
1172
|
+
h / n * 100
|
|
1173
1173
|
), A = {};
|
|
1174
1174
|
}
|
|
1175
|
-
|
|
1175
|
+
h++;
|
|
1176
1176
|
}
|
|
1177
|
-
for (const [u,
|
|
1178
|
-
if (
|
|
1179
|
-
const c = this.mergeSplitResults(
|
|
1180
|
-
for (const f of
|
|
1181
|
-
delete
|
|
1182
|
-
|
|
1177
|
+
for (const [u, m] of Object.entries(l))
|
|
1178
|
+
if (m && m.length > 0) {
|
|
1179
|
+
const c = this.mergeSplitResults(i, u);
|
|
1180
|
+
for (const f of m)
|
|
1181
|
+
delete i[f];
|
|
1182
|
+
i[u] = c;
|
|
1183
1183
|
}
|
|
1184
|
-
return Object.entries(this.errors).length && (
|
|
1184
|
+
return Object.entries(this.errors).length && (i.errorsList = this.errors), e && e({ percent: 100 }), Promise.resolve(i);
|
|
1185
1185
|
}
|
|
1186
1186
|
/**
|
|
1187
1187
|
* Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
|
|
@@ -1192,60 +1192,60 @@ const j = class j {
|
|
|
1192
1192
|
* @param {Function} progressCall - Callback для отслеживания прогресса
|
|
1193
1193
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
1194
1194
|
*/
|
|
1195
|
-
async batchTotalCount(
|
|
1196
|
-
E(this,
|
|
1197
|
-
const s = {},
|
|
1198
|
-
for (const [
|
|
1199
|
-
const u = this.arrayChunk(
|
|
1195
|
+
async batchTotalCount(t, e) {
|
|
1196
|
+
E(this, lt, Ut).call(this, e);
|
|
1197
|
+
const s = {}, i = {}, a = {};
|
|
1198
|
+
for (const [h, n] of Object.entries(t)) {
|
|
1199
|
+
const u = this.arrayChunk(n);
|
|
1200
1200
|
if (!u)
|
|
1201
1201
|
continue;
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
|
|
1202
|
+
const m = this.splitLargeFilters(h, u);
|
|
1203
|
+
if (m.length === 1)
|
|
1204
|
+
i[h] = u;
|
|
1205
1205
|
else {
|
|
1206
|
-
|
|
1207
|
-
for (const c of
|
|
1208
|
-
|
|
1206
|
+
a[h] = [];
|
|
1207
|
+
for (const c of m)
|
|
1208
|
+
i[c.key] = c.request, a[h].push(c.key);
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
1211
|
-
const
|
|
1212
|
-
for (let
|
|
1213
|
-
const
|
|
1214
|
-
for (const [
|
|
1211
|
+
const l = [], A = Object.entries(i);
|
|
1212
|
+
for (let h = 0; h < A.length; h += this.limit) {
|
|
1213
|
+
const n = A.slice(h, h + this.limit), u = {};
|
|
1214
|
+
for (const [m, c] of n) {
|
|
1215
1215
|
if (!this.canContinue)
|
|
1216
1216
|
break;
|
|
1217
|
-
u[
|
|
1217
|
+
u[m] = c;
|
|
1218
1218
|
}
|
|
1219
|
-
Object.keys(u).length > 0 &&
|
|
1219
|
+
Object.keys(u).length > 0 && l.push(u);
|
|
1220
1220
|
}
|
|
1221
|
-
this.chunkRate = (1 /
|
|
1222
|
-
for (const [
|
|
1221
|
+
this.chunkRate = (1 / l.length).toFixed(5);
|
|
1222
|
+
for (const [h, n] of Object.entries(l)) {
|
|
1223
1223
|
if (!this.canContinue)
|
|
1224
1224
|
break;
|
|
1225
|
-
this.totalProgress = Math.round(Number(
|
|
1226
|
-
const u = Number(
|
|
1227
|
-
await E(this, V, At).call(this,
|
|
1228
|
-
var c, f, O,
|
|
1229
|
-
for (const [
|
|
1225
|
+
this.totalProgress = Math.round(Number(h) / l.length * 100);
|
|
1226
|
+
const u = Number(h) === l.length - 1;
|
|
1227
|
+
await E(this, V, At).call(this, n, async (m) => {
|
|
1228
|
+
var c, f, O, T, _;
|
|
1229
|
+
for (const [R, N] of Object.entries(m)) {
|
|
1230
1230
|
if (!this.canContinue)
|
|
1231
1231
|
return;
|
|
1232
|
-
if (
|
|
1233
|
-
const
|
|
1234
|
-
this.errors[
|
|
1232
|
+
if (N.error()) {
|
|
1233
|
+
const k = (f = (c = N.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, U = (T = (O = N.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1234
|
+
this.errors[R] = k && k.trim() || U && U.trim() || ((_ = N.error()) == null ? void 0 : _.toString()) || "Неизвестная ошибка", s[R] = 0;
|
|
1235
1235
|
continue;
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
s[
|
|
1237
|
+
const y = this.getData(N.data()), L = Array.isArray(y) ? y.length : 0, H = typeof N.total == "function" && N.total() !== void 0 ? N.total() : L;
|
|
1238
|
+
s[R] = H, this.setProgressData({ key: R, value: N, type: "count" });
|
|
1239
1239
|
}
|
|
1240
|
-
await E(this, Z,
|
|
1240
|
+
await E(this, Z, at).call(this, m, !u);
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
|
-
for (const [
|
|
1244
|
-
if (
|
|
1243
|
+
for (const [h, n] of Object.entries(a))
|
|
1244
|
+
if (n && n.length > 0) {
|
|
1245
1245
|
let u = 0;
|
|
1246
|
-
for (const
|
|
1247
|
-
s[
|
|
1248
|
-
s[
|
|
1246
|
+
for (const m of n)
|
|
1247
|
+
s[m] !== void 0 && (u += s[m] || 0), delete s[m];
|
|
1248
|
+
s[h] = u;
|
|
1249
1249
|
}
|
|
1250
1250
|
return Object.entries(this.errors).length && (s.errorsList = this.errors, this.errorLogger()), e && e({ percent: 100 }), Promise.resolve(s);
|
|
1251
1251
|
}
|
|
@@ -1256,29 +1256,29 @@ const j = class j {
|
|
|
1256
1256
|
* @param {{method: string, params?: Object}} request - Описание REST-вызова.
|
|
1257
1257
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1258
1258
|
*/
|
|
1259
|
-
async call({ method:
|
|
1260
|
-
var s,
|
|
1259
|
+
async call({ method: t, params: e = {} }) {
|
|
1260
|
+
var s, i, a, l, A, h, n;
|
|
1261
1261
|
for (; ; ) {
|
|
1262
|
-
const u = await E(this,
|
|
1262
|
+
const u = await E(this, Lt, vt).call(this, t, e);
|
|
1263
1263
|
if (!u) {
|
|
1264
|
-
await E(this,
|
|
1264
|
+
await E(this, Q, st).call(this, this.callLimitPauseMs);
|
|
1265
1265
|
continue;
|
|
1266
1266
|
}
|
|
1267
|
-
const
|
|
1267
|
+
const m = {};
|
|
1268
1268
|
if (u != null && u.answer)
|
|
1269
1269
|
for (const [f, O] of Object.entries(u.answer))
|
|
1270
|
-
f !== "result" && O && (
|
|
1270
|
+
f !== "result" && O && (m[f] = O);
|
|
1271
1271
|
if (u.error()) {
|
|
1272
|
-
const f = ((
|
|
1272
|
+
const f = ((i = (s = u.error()) == null ? void 0 : s.ex) == null ? void 0 : i.error) ?? "";
|
|
1273
1273
|
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(f)) {
|
|
1274
|
-
await E(this,
|
|
1274
|
+
await E(this, Q, st).call(this, this.callLimitPauseMs);
|
|
1275
1275
|
continue;
|
|
1276
1276
|
}
|
|
1277
|
-
const O = ((
|
|
1277
|
+
const O = ((a = u.error()) == null ? void 0 : a.toString()) || ((A = (l = u.error()) == null ? void 0 : l.ex) == null ? void 0 : A.error_description) || ((n = (h = u.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
|
|
1278
1278
|
return {
|
|
1279
1279
|
success: !1,
|
|
1280
1280
|
data: !1,
|
|
1281
|
-
answer:
|
|
1281
|
+
answer: m,
|
|
1282
1282
|
error: O
|
|
1283
1283
|
};
|
|
1284
1284
|
}
|
|
@@ -1286,7 +1286,7 @@ const j = class j {
|
|
|
1286
1286
|
return c != null && c.items && (c = c.items), {
|
|
1287
1287
|
success: !0,
|
|
1288
1288
|
data: c,
|
|
1289
|
-
answer:
|
|
1289
|
+
answer: m,
|
|
1290
1290
|
error: null
|
|
1291
1291
|
};
|
|
1292
1292
|
}
|
|
@@ -1296,18 +1296,18 @@ const j = class j {
|
|
|
1296
1296
|
* Так же переделываем некоторые запросы в нужный вид (Для task-методов)
|
|
1297
1297
|
* @param {Array/Object} request - Массив/объект методов
|
|
1298
1298
|
*/
|
|
1299
|
-
arrayChunk(
|
|
1299
|
+
arrayChunk(t) {
|
|
1300
1300
|
let e = "", s = {};
|
|
1301
|
-
if (Array.isArray(
|
|
1301
|
+
if (Array.isArray(t) ? [e] = t : (e = t.method, s = t.params), (e.includes("list") || e === "user.get" || e === "entity.item.get") && e !== "task.item.list") {
|
|
1302
1302
|
if (!s)
|
|
1303
1303
|
s = e === "entity.item.get" ? { SORT: { ID: "ASC" } } : {
|
|
1304
1304
|
order: { ID: "ASC", id: "ASC" }
|
|
1305
1305
|
};
|
|
1306
1306
|
else {
|
|
1307
1307
|
e === "entity.item.get" ? (s.SORT || (s.SORT = { ID: "ASC" }), Array.isArray(s.select) ? s.select.includes("ID") || s.select.push("ID") : s.select = ["ID"]) : e === "tasks.task.list" ? (s.order || (s.order = {}), s.order.ID = "asc") : e === "user.get" ? (s.sort || (s.sort = "ID"), s.order || (s.order = "ASC")) : s.order = { ID: "ASC", id: "ASC" }, Array.isArray(s.select) && !s.select.includes("ID") && s.select.push("ID");
|
|
1308
|
-
const
|
|
1309
|
-
typeof
|
|
1310
|
-
(s.start === void 0 || s.start !== -1) && ["id", "ID"].includes(
|
|
1308
|
+
const i = e === "user.get" || e === "entity.item.get" ? s.FILTER : s.filter;
|
|
1309
|
+
typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, l]) => {
|
|
1310
|
+
(s.start === void 0 || s.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (s.start = -1);
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
1313
|
e === "crm.type.list" && s.order && delete s.order.ID;
|
|
@@ -1317,8 +1317,8 @@ const j = class j {
|
|
|
1317
1317
|
s = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
1318
1318
|
else {
|
|
1319
1319
|
Array.isArray(s[0]) && (s[0] = {});
|
|
1320
|
-
const [
|
|
1321
|
-
|
|
1320
|
+
const [i, a, l, A] = s;
|
|
1321
|
+
i.ID = "ASC", A[0] !== "" && A.includes("ID") || A.push("ID");
|
|
1322
1322
|
}
|
|
1323
1323
|
return { method: e, params: s };
|
|
1324
1324
|
}
|
|
@@ -1328,46 +1328,46 @@ const j = class j {
|
|
|
1328
1328
|
* @param {Array} query - Тот же массив с методами
|
|
1329
1329
|
* @returns {Object} Объект с результатами запросов
|
|
1330
1330
|
*/
|
|
1331
|
-
async batchChunk(
|
|
1332
|
-
return new Promise((
|
|
1333
|
-
const
|
|
1331
|
+
async batchChunk(t, e, s = !0, i = {}) {
|
|
1332
|
+
return new Promise((a) => {
|
|
1333
|
+
const l = [];
|
|
1334
1334
|
let A;
|
|
1335
|
-
const
|
|
1335
|
+
const h = !!(i != null && i.disablePagination);
|
|
1336
1336
|
(async () => {
|
|
1337
|
-
await E(this, V, At).call(this,
|
|
1338
|
-
var c, f, O,
|
|
1339
|
-
for (const [
|
|
1337
|
+
await E(this, V, At).call(this, t, async (u) => {
|
|
1338
|
+
var c, f, O, T, _;
|
|
1339
|
+
for (const [R, N] of Object.entries(u)) {
|
|
1340
1340
|
if (!this.canContinue)
|
|
1341
1341
|
return;
|
|
1342
|
-
if (
|
|
1343
|
-
const g = (f = (c =
|
|
1344
|
-
this.errors[
|
|
1342
|
+
if (N.error()) {
|
|
1343
|
+
const g = (f = (c = N.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, w = (T = (O = N.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
|
|
1344
|
+
this.errors[R] = g && g.trim() || w && w.trim() || ((_ = N.error()) == null ? void 0 : _.toString()) || "Неизвестная ошибка", A = !0;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
e === "count" ? this.result[
|
|
1348
|
-
const
|
|
1349
|
-
if (!
|
|
1350
|
-
let g =
|
|
1346
|
+
const y = this.getData(N.data()), L = Array.isArray(y) ? y.length : 0, I = typeof N.total == "function" && N.total() !== void 0, H = I ? N.total() : L;
|
|
1347
|
+
e === "count" ? this.result[R] ? this.result[R] += L : this.result[R] = H : this.result[R] = y, this.setProgressData({ key: R, value: N, type: e });
|
|
1348
|
+
const k = t[R], U = Array.isArray(k) ? k[0] : k == null ? void 0 : k.method, M = typeof U == "string" && (U.includes(".list") || U === "user.get" || U === "entity.item.get"), r = e === "count" ? !I && L === this.limit : M ? L === this.limit : H > this.limit && H > L, o = e !== "count" && U === "entity.item.get" && L === this.limit && !r, d = r || o;
|
|
1349
|
+
if (!h && (!this.canContinue || d)) {
|
|
1350
|
+
let g = t[R];
|
|
1351
1351
|
if (Array.isArray(g)) {
|
|
1352
|
-
const [
|
|
1353
|
-
g = [
|
|
1352
|
+
const [w, b = {}] = g;
|
|
1353
|
+
g = [w, b];
|
|
1354
1354
|
} else {
|
|
1355
|
-
const { method:
|
|
1356
|
-
g = [
|
|
1355
|
+
const { method: w, params: b = {} } = g;
|
|
1356
|
+
g = [w, b];
|
|
1357
1357
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1358
|
+
l.push([
|
|
1359
|
+
R,
|
|
1360
1360
|
g,
|
|
1361
|
-
|
|
1362
|
-
{ entityItemGetScan:
|
|
1361
|
+
H,
|
|
1362
|
+
{ entityItemGetScan: o }
|
|
1363
1363
|
]);
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
A > 0 && this.errorLogger();
|
|
1367
|
-
const
|
|
1368
|
-
await E(this, Z,
|
|
1369
|
-
() =>
|
|
1370
|
-
) :
|
|
1367
|
+
const m = l.length > 0 || s;
|
|
1368
|
+
await E(this, Z, at).call(this, u, m), l.length ? await this.batchPayload(l, e, i).then(
|
|
1369
|
+
() => a(this.result)
|
|
1370
|
+
) : a(this.result);
|
|
1371
1371
|
});
|
|
1372
1372
|
})();
|
|
1373
1373
|
});
|
|
@@ -1377,97 +1377,97 @@ const j = class j {
|
|
|
1377
1377
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1378
1378
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1379
1379
|
*/
|
|
1380
|
-
async batchPayload(
|
|
1381
|
-
const
|
|
1382
|
-
let
|
|
1383
|
-
this.result[O][this.result[O].length - 1].ID || (
|
|
1384
|
-
let
|
|
1385
|
-
if (JSON.stringify(
|
|
1380
|
+
async batchPayload(t, e, s = {}) {
|
|
1381
|
+
const i = !!(s != null && s.oneBatch), a = (O, T, _, R) => {
|
|
1382
|
+
let N = "ID";
|
|
1383
|
+
this.result[O][this.result[O].length - 1].ID || (N = "id");
|
|
1384
|
+
let y = `${N}`;
|
|
1385
|
+
if (JSON.stringify(R[1]).toLocaleLowerCase().includes('"id":"desc"') ? y = "<" + y : y = ">" + y, T === 1 || _.length === 0)
|
|
1386
1386
|
return {
|
|
1387
|
-
field:
|
|
1388
|
-
id: this.result[O][this.result[O].length - 1][
|
|
1387
|
+
field: y,
|
|
1388
|
+
id: this.result[O][this.result[O].length - 1][N]
|
|
1389
1389
|
};
|
|
1390
|
-
let
|
|
1391
|
-
const [
|
|
1392
|
-
return (
|
|
1393
|
-
field:
|
|
1394
|
-
id: `$result[${[O,
|
|
1390
|
+
let I = "";
|
|
1391
|
+
const [H, k] = R;
|
|
1392
|
+
return (H === "tasks.task.list" || H === "task.item.list") && (I = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(H) && (I = "[items]"), H === "crm.type.list" && (I = "[types]"), H === "socialnetwork.api.workgroup.list" && (I = "[workgroups]"), {
|
|
1393
|
+
field: y,
|
|
1394
|
+
id: `$result[${[O, T - 1].join("__")}]${I}[49][${N}]`
|
|
1395
1395
|
};
|
|
1396
|
-
},
|
|
1397
|
-
const [
|
|
1398
|
-
let
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1401
|
-
const [
|
|
1402
|
-
return
|
|
1396
|
+
}, l = (O, T) => {
|
|
1397
|
+
const [_, R] = O;
|
|
1398
|
+
let N = JSON.parse(JSON.stringify(R)), y;
|
|
1399
|
+
if (_ === "task.item.list") {
|
|
1400
|
+
N = [...N];
|
|
1401
|
+
const [L, I, H, k] = N;
|
|
1402
|
+
return I[T.field] = T.id, [_, N];
|
|
1403
1403
|
}
|
|
1404
|
-
return ["user.get"].includes(
|
|
1404
|
+
return ["user.get"].includes(_) || N.FILTER ? (N.FILTER || (N.FILTER = {}), y = N.FILTER) : (N.filter || (N.filter = {}), y = N.filter), [
|
|
1405
1405
|
"socialnetwork.api.workgroup.list",
|
|
1406
1406
|
"tasks.task.list"
|
|
1407
|
-
].includes(
|
|
1407
|
+
].includes(_) ? y[">ID"] = T.id : y[T.field] = T.id, [_, { ...N, start: -1 }];
|
|
1408
1408
|
}, A = (O) => {
|
|
1409
|
-
Object.entries(O).forEach(([
|
|
1410
|
-
var
|
|
1411
|
-
const [
|
|
1412
|
-
if (Array.isArray(
|
|
1413
|
-
const
|
|
1414
|
-
this.errors[
|
|
1409
|
+
Object.entries(O).forEach(([T, _]) => {
|
|
1410
|
+
var y, L, I, H, k;
|
|
1411
|
+
const [R] = T.split("__"), N = this.getData(_.data());
|
|
1412
|
+
if (Array.isArray(N) && (e === "count" ? this.result[R] += N.length : this.result[R].push(...N)), _.error()) {
|
|
1413
|
+
const U = (L = (y = _.error()) == null ? void 0 : y.ex) == null ? void 0 : L.error, M = (H = (I = _.error()) == null ? void 0 : I.ex) == null ? void 0 : H.error_description;
|
|
1414
|
+
this.errors[R] = U && U.trim() || M && M.trim() || ((k = _.error()) == null ? void 0 : k.toString()) || "Неизвестная ошибка";
|
|
1415
1415
|
}
|
|
1416
|
-
this.setProgressData({ key:
|
|
1416
|
+
this.setProgressData({ key: R, value: _, type: e });
|
|
1417
1417
|
});
|
|
1418
|
-
},
|
|
1418
|
+
}, h = (O, T) => {
|
|
1419
1419
|
if (!Array.isArray(O) || O.length === 0)
|
|
1420
1420
|
return null;
|
|
1421
|
-
const
|
|
1422
|
-
let
|
|
1423
|
-
|
|
1424
|
-
let
|
|
1425
|
-
return JSON.stringify(
|
|
1426
|
-
},
|
|
1427
|
-
var
|
|
1428
|
-
let
|
|
1429
|
-
for (let
|
|
1430
|
-
const
|
|
1431
|
-
if (!
|
|
1421
|
+
const _ = O[O.length - 1];
|
|
1422
|
+
let R = "ID";
|
|
1423
|
+
_.ID || (R = "id");
|
|
1424
|
+
let N = R;
|
|
1425
|
+
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? N = "<" + N : N = ">" + N, { field: N, id: _[R] };
|
|
1426
|
+
}, n = 1e4, u = async (O, T) => {
|
|
1427
|
+
var R, N;
|
|
1428
|
+
let _ = this.limit;
|
|
1429
|
+
for (let y = 1; this.canContinue && _ === this.limit && y <= n; y++) {
|
|
1430
|
+
const L = this.result[O], I = h(L, T);
|
|
1431
|
+
if (!I)
|
|
1432
1432
|
break;
|
|
1433
|
-
const
|
|
1434
|
-
let
|
|
1435
|
-
await E(this, V, At).call(this, { [
|
|
1436
|
-
|
|
1433
|
+
const H = `${O}__eiscan_${y}`, k = l(T, I);
|
|
1434
|
+
let U = null;
|
|
1435
|
+
await E(this, V, At).call(this, { [H]: k }, async (d) => {
|
|
1436
|
+
U = d, A(d);
|
|
1437
1437
|
});
|
|
1438
|
-
const
|
|
1439
|
-
await E(this, Z,
|
|
1440
|
-
const
|
|
1441
|
-
if ((
|
|
1442
|
-
|
|
1438
|
+
const M = y < n;
|
|
1439
|
+
await E(this, Z, at).call(this, U, M), await this.delay();
|
|
1440
|
+
const r = U == null ? void 0 : U[H];
|
|
1441
|
+
if ((R = r == null ? void 0 : r.error) != null && R.call(r)) {
|
|
1442
|
+
_ = 0;
|
|
1443
1443
|
break;
|
|
1444
1444
|
}
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1445
|
+
const o = this.getData((N = r == null ? void 0 : r.data) == null ? void 0 : N.call(r));
|
|
1446
|
+
_ = Array.isArray(o) ? o.length : 0;
|
|
1447
1447
|
}
|
|
1448
1448
|
};
|
|
1449
|
-
let
|
|
1450
|
-
const f = async (O = !0) =>
|
|
1451
|
-
A(
|
|
1452
|
-
}), c++,
|
|
1453
|
-
for await (const O of
|
|
1449
|
+
let m = [], c = 0;
|
|
1450
|
+
const f = async (O = !0) => m.length ? (await E(this, V, At).call(this, Object.fromEntries(m), async (T) => {
|
|
1451
|
+
A(T), await E(this, Z, at).call(this, T, O);
|
|
1452
|
+
}), c++, m = [], i && c >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1453
|
+
for await (const O of t) {
|
|
1454
1454
|
if (!this.canContinue)
|
|
1455
1455
|
return;
|
|
1456
|
-
const [_,
|
|
1457
|
-
if (
|
|
1456
|
+
const [T, _, R, N = {}] = O;
|
|
1457
|
+
if (N.entityItemGetScan) {
|
|
1458
1458
|
if (await f(!0))
|
|
1459
1459
|
return;
|
|
1460
|
-
if (
|
|
1460
|
+
if (i)
|
|
1461
1461
|
continue;
|
|
1462
|
-
await u(
|
|
1462
|
+
await u(T, _);
|
|
1463
1463
|
continue;
|
|
1464
1464
|
}
|
|
1465
|
-
let
|
|
1466
|
-
for (;
|
|
1467
|
-
const
|
|
1468
|
-
if (
|
|
1465
|
+
let y = 1;
|
|
1466
|
+
for (; R > y * this.limit; ) {
|
|
1467
|
+
const L = [T, y].join("__"), I = a(T, y, m, _);
|
|
1468
|
+
if (m.push([L, l(_, I)]), i && m.length === 49 && await f(!0) || m.length % 50 === 0 && await f(!0))
|
|
1469
1469
|
return;
|
|
1470
|
-
|
|
1470
|
+
y++;
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
await f(!1);
|
|
@@ -1476,127 +1476,127 @@ const j = class j {
|
|
|
1476
1476
|
* Вывод ошибок в консоль в группированном виде
|
|
1477
1477
|
*/
|
|
1478
1478
|
errorLogger() {
|
|
1479
|
-
console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([
|
|
1480
|
-
e && console.log(`[${
|
|
1479
|
+
console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([t, e]) => {
|
|
1480
|
+
e && console.log(`[${t}]`, e.toString());
|
|
1481
1481
|
}), console.groupEnd();
|
|
1482
1482
|
}
|
|
1483
1483
|
};
|
|
1484
|
-
|
|
1485
|
-
const
|
|
1486
|
-
if (
|
|
1484
|
+
yt = new WeakSet(), Jt = function() {
|
|
1485
|
+
const t = this.totalBatchCommands || 0, e = this.batchCommandMethods;
|
|
1486
|
+
if (t < S(j, pt) || !Array.isArray(e) || e.length !== t)
|
|
1487
1487
|
return !1;
|
|
1488
|
-
if (e.filter((
|
|
1488
|
+
if (e.filter((a) => a === "crm.deal.list").length >= S(j, Nt))
|
|
1489
1489
|
return !0;
|
|
1490
|
-
const
|
|
1491
|
-
(
|
|
1490
|
+
const i = e.filter(
|
|
1491
|
+
(a) => typeof a == "string" && a.includes(".list")
|
|
1492
1492
|
).length;
|
|
1493
|
-
return
|
|
1494
|
-
},
|
|
1493
|
+
return i >= S(j, Ot) && i / t >= S(j, _t);
|
|
1494
|
+
}, pt = new WeakMap(), Nt = new WeakMap(), Ot = new WeakMap(), _t = new WeakMap(), it = new WeakSet(), gt = function() {
|
|
1495
1495
|
if (!this.progressCall || !this.progressData)
|
|
1496
1496
|
return;
|
|
1497
|
-
const { percent:
|
|
1498
|
-
E(this,
|
|
1497
|
+
const { percent: t, allCount: e, allTotal: s } = this.progressPercent, i = { percent: t, allCount: e, allTotal: s };
|
|
1498
|
+
E(this, Tt, jt).call(this, i) && (this.progressCall({
|
|
1499
1499
|
data: this.progressData,
|
|
1500
|
-
percent:
|
|
1500
|
+
percent: t,
|
|
1501
1501
|
allCount: e,
|
|
1502
1502
|
allTotal: s
|
|
1503
|
-
}), this.lastProgressSnapshot =
|
|
1504
|
-
},
|
|
1505
|
-
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !==
|
|
1506
|
-
},
|
|
1507
|
-
const
|
|
1503
|
+
}), this.lastProgressSnapshot = i);
|
|
1504
|
+
}, Tt = new WeakSet(), jt = function(t) {
|
|
1505
|
+
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== t.percent || this.lastProgressSnapshot.allCount !== t.allCount || this.lastProgressSnapshot.allTotal !== t.allTotal : !0;
|
|
1506
|
+
}, Et = new WeakSet(), Kt = function() {
|
|
1507
|
+
const t = {
|
|
1508
1508
|
limit: this.timeLimit.limit,
|
|
1509
1509
|
date: this.timeLimit.date,
|
|
1510
1510
|
pauseMs: this.timeLimit.pauseMs
|
|
1511
1511
|
};
|
|
1512
1512
|
for (const e of this.timeLimitListeners)
|
|
1513
1513
|
try {
|
|
1514
|
-
e(
|
|
1514
|
+
e(t);
|
|
1515
1515
|
} catch (s) {
|
|
1516
1516
|
console.warn("Batch timeLimit listener error:", s);
|
|
1517
1517
|
}
|
|
1518
|
-
},
|
|
1519
|
-
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(),
|
|
1520
|
-
}, Z = new WeakSet(),
|
|
1518
|
+
}, Q = new WeakSet(), st = async function(t = this.defaultPauseMs) {
|
|
1519
|
+
this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), t), await new Promise((e) => setTimeout(e, t)), this.setTimeLimitState(!1, void 0);
|
|
1520
|
+
}, Z = new WeakSet(), at = async function(t, e = !0) {
|
|
1521
1521
|
if (!e)
|
|
1522
1522
|
return 0;
|
|
1523
1523
|
let s = 0;
|
|
1524
|
-
if (!
|
|
1524
|
+
if (!t || typeof t != "object")
|
|
1525
1525
|
return 0;
|
|
1526
|
-
for (const
|
|
1527
|
-
if (!(!
|
|
1526
|
+
for (const i of Object.values(t))
|
|
1527
|
+
if (!(!i || typeof i != "object"))
|
|
1528
1528
|
try {
|
|
1529
|
-
if (typeof
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1529
|
+
if (typeof i.time == "function") {
|
|
1530
|
+
const a = i.time();
|
|
1531
|
+
a && typeof a.operating == "number" && (s = Math.max(s, a.operating));
|
|
1532
1532
|
}
|
|
1533
1533
|
} catch {
|
|
1534
1534
|
}
|
|
1535
|
-
s >= this.operatingThreshold && await E(this,
|
|
1536
|
-
}, V = new WeakSet(), At = async function(
|
|
1537
|
-
let s = !1,
|
|
1535
|
+
s >= this.operatingThreshold && await E(this, Q, st).call(this);
|
|
1536
|
+
}, V = new WeakSet(), At = async function(t, e) {
|
|
1537
|
+
let s = !1, i = t;
|
|
1538
1538
|
do
|
|
1539
|
-
s = !1, await this.callBatchWithTimeout(
|
|
1540
|
-
var
|
|
1541
|
-
let
|
|
1539
|
+
s = !1, await this.callBatchWithTimeout(i, async (a) => {
|
|
1540
|
+
var h, n;
|
|
1541
|
+
let l = !1;
|
|
1542
1542
|
const A = /* @__PURE__ */ new Set();
|
|
1543
|
-
for (const [u,
|
|
1544
|
-
if (!(
|
|
1543
|
+
for (const [u, m] of Object.entries(a || {})) {
|
|
1544
|
+
if (!(m != null && m.error) || !m.error())
|
|
1545
1545
|
continue;
|
|
1546
|
-
const c = ((
|
|
1546
|
+
const c = ((n = (h = m.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) ?? "";
|
|
1547
1547
|
if (c === "TIMEOUT") {
|
|
1548
|
-
|
|
1548
|
+
l = !0;
|
|
1549
1549
|
break;
|
|
1550
1550
|
}
|
|
1551
1551
|
["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(c) && A.add(u);
|
|
1552
1552
|
}
|
|
1553
|
-
if (
|
|
1554
|
-
s = !0, await E(this,
|
|
1553
|
+
if (l) {
|
|
1554
|
+
s = !0, await E(this, Q, st).call(this);
|
|
1555
1555
|
return;
|
|
1556
1556
|
}
|
|
1557
1557
|
if (A.size > 0) {
|
|
1558
1558
|
const u = {};
|
|
1559
|
-
for (const [c, f] of Object.entries(
|
|
1559
|
+
for (const [c, f] of Object.entries(a || {}))
|
|
1560
1560
|
A.has(c) || (u[c] = f);
|
|
1561
1561
|
Object.keys(u).length && await e(u);
|
|
1562
|
-
const
|
|
1562
|
+
const m = {};
|
|
1563
1563
|
for (const c of A)
|
|
1564
|
-
|
|
1565
|
-
|
|
1564
|
+
i[c] && (m[c] = i[c]);
|
|
1565
|
+
i = m, Object.keys(i).length && (s = !0, await E(this, Q, st).call(this));
|
|
1566
1566
|
return;
|
|
1567
1567
|
}
|
|
1568
|
-
await e(
|
|
1568
|
+
await e(a);
|
|
1569
1569
|
});
|
|
1570
1570
|
while (s);
|
|
1571
|
-
},
|
|
1571
|
+
}, Lt = new WeakSet(), vt = function(t, e) {
|
|
1572
1572
|
return new Promise((s) => {
|
|
1573
1573
|
if (typeof this.callMethod != "function") {
|
|
1574
1574
|
s(null);
|
|
1575
1575
|
return;
|
|
1576
1576
|
}
|
|
1577
|
-
let
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1577
|
+
let i = !1;
|
|
1578
|
+
const a = setTimeout(() => {
|
|
1579
|
+
i || (i = !0, s(null));
|
|
1580
1580
|
}, this.requestTimeoutMs);
|
|
1581
1581
|
try {
|
|
1582
|
-
this.callMethod(
|
|
1583
|
-
|
|
1582
|
+
this.callMethod(t, e, (l) => {
|
|
1583
|
+
i || (i = !0, clearTimeout(a), s(l));
|
|
1584
1584
|
});
|
|
1585
1585
|
} catch {
|
|
1586
|
-
|
|
1586
|
+
i || (i = !0, clearTimeout(a), s(null));
|
|
1587
1587
|
}
|
|
1588
1588
|
});
|
|
1589
|
-
},
|
|
1590
|
-
this.clearProgressData(), this.progressCall = typeof
|
|
1589
|
+
}, lt = new WeakSet(), Ut = function(t) {
|
|
1590
|
+
this.clearProgressData(), this.progressCall = typeof t == "function" ? t : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
|
|
1591
1591
|
}, /** Не включать вес по командам для совсем маленьких batch. */
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1592
|
+
D(j, pt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1593
|
+
D(j, Nt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1594
|
+
D(j, Ot, 8), D(j, _t, 0.65);
|
|
1595
1595
|
let v = j;
|
|
1596
1596
|
var $;
|
|
1597
|
-
class
|
|
1597
|
+
class zt {
|
|
1598
1598
|
constructor() {
|
|
1599
|
-
|
|
1599
|
+
D(this, $, {});
|
|
1600
1600
|
}
|
|
1601
1601
|
/**
|
|
1602
1602
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1610,10 +1610,10 @@ class Ft {
|
|
|
1610
1610
|
* @param {number} length - Длина генерируемого хеша
|
|
1611
1611
|
* @returns {string}
|
|
1612
1612
|
*/
|
|
1613
|
-
createHash(
|
|
1613
|
+
createHash(t) {
|
|
1614
1614
|
let e = "abcdefghijklmnopqrstuvwxyz0123456789", s = "";
|
|
1615
|
-
|
|
1616
|
-
for (let
|
|
1615
|
+
t = t || 6;
|
|
1616
|
+
for (let i = 0; i < t; i++)
|
|
1617
1617
|
s += e.charAt(Math.floor(Math.random() * e.length));
|
|
1618
1618
|
return s;
|
|
1619
1619
|
}
|
|
@@ -1624,8 +1624,8 @@ class Ft {
|
|
|
1624
1624
|
* @param {number} params.duration - Задержка в миллисекундах (по умолчанию 10)
|
|
1625
1625
|
* @param {Function} params.action - Функция для выполнения
|
|
1626
1626
|
*/
|
|
1627
|
-
actionFilter({ keyTimer:
|
|
1628
|
-
|
|
1627
|
+
actionFilter({ keyTimer: t, duration: e = 10, action: s }) {
|
|
1628
|
+
S(this, $)[t] && (clearTimeout(S(this, $)[t]), S(this, $)[t] = null), s && (S(this, $)[t] = setTimeout(() => {
|
|
1629
1629
|
s();
|
|
1630
1630
|
}, e));
|
|
1631
1631
|
}
|
|
@@ -1634,88 +1634,88 @@ class Ft {
|
|
|
1634
1634
|
* Создает невидимое видео, которое циклически воспроизводится
|
|
1635
1635
|
*/
|
|
1636
1636
|
async noSleep() {
|
|
1637
|
-
let
|
|
1638
|
-
|
|
1639
|
-
|
|
1637
|
+
let t = document.createElement("video");
|
|
1638
|
+
t.classList.add("no-sleep"), t.muted = !0, t.autoplay = !0, t.setAttribute("playsinline", ""), t.addEventListener("loadeddata", () => {
|
|
1639
|
+
t.style.position = "fixed", t.style.left = "-9999px", document.querySelector("body").append(t), t.play().catch((e) => {
|
|
1640
1640
|
console.warn("noSleep: autoplay prevented", e);
|
|
1641
1641
|
});
|
|
1642
|
-
}),
|
|
1642
|
+
}), t.addEventListener("ended", () => {
|
|
1643
1643
|
this.actionFilter({
|
|
1644
1644
|
keyTimer: "no-sleep",
|
|
1645
1645
|
duration: 5e3,
|
|
1646
1646
|
action: () => {
|
|
1647
|
-
|
|
1647
|
+
t.play().catch((e) => {
|
|
1648
1648
|
console.warn("noSleep: replay prevented", e);
|
|
1649
1649
|
});
|
|
1650
1650
|
}
|
|
1651
1651
|
});
|
|
1652
|
-
}),
|
|
1652
|
+
}), t.src = "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAP5tZGF0AAAAAQYAAADlZYiEE28FmH9jNWDBjI+Z/1tIBZsjfhbmcNNUpBFej0U3p+zhaJ3eemJRL2LUMa5tkidy6bp+eatLE3jBIY864TvaAmqEFCgLMTCwVbem1n3myAw9yDXQdR5HfU/8iYf+eneVnRf7Qx9M70XDUuPx1MJX671XJwAE0VAMpnhbcUDx0pTldvUX9KQPhkZNH3eyZHmObkAeyEJ2tl+BEBJIGc90BiqKL60+5EA6fXB6iG5UU/M5KsW8BNAAUw5CbRJIqohNk10fwKbUXwya03rqGkE8+wuYGtEbrVYXb+iOl1mHHVPLYQbIAAcGyAAHAAAFNG1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAAvAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAIldHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAFAAAAA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAAAAAAAAAAAQAAAAABnW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUhtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEIc3RibAAAAKRzdHNkAAAAAAAAAAEAAACUYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAC5hdmNDAU1AC//hABZnTUAL2wUH7ARAAAADAEAAAAQDxQq4AQAFaOrAZXIAAAAQcGFzcAAAAAEAAAABAAAAGHN0dHMAAAAAAAAAAQAAAAEAAAAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAABRzdHN6AAAAAAAAAO4AAAABAAAAFHN0Y28AAAAAAAAAAQAAADAAAAIadHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAvAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAALwAAAAAAAQAAAAABkm1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAArEQAAAgAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAT1taW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAQFzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAAC7gAAAAViBYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAACAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAgAAAAEAAAAUc3RzegAAAAAAAAAEAAAAAgAAABRzdGNvAAAAAAAAAAEAAAEeAAAAGnNncGQBAAAAcm9sbAAAAAIAAAAB//8AAAAcc2JncAAAAAByb2xsAAAAAQAAAAIAAAABAAAAgXVkdGEAAAB5bWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWR0YQAAAAAAAAAAAAAAAAAAAAAfa2V5cwAAAAAAAAABAAAAD21kdGFlbmNvZGVyAAAALWlsc3QAAAAlAAAAAQAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw";
|
|
1653
1653
|
}
|
|
1654
1654
|
/**
|
|
1655
1655
|
* Скачать данные в JSON-файл
|
|
1656
1656
|
* @param {any} data - Данные для сохранения
|
|
1657
1657
|
* @param {string} filename - Имя файла без расширения
|
|
1658
1658
|
*/
|
|
1659
|
-
downloadFileJson(
|
|
1660
|
-
let s = new Blob([JSON.stringify(
|
|
1661
|
-
|
|
1662
|
-
document.body.removeChild(
|
|
1659
|
+
downloadFileJson(t, e) {
|
|
1660
|
+
let s = new Blob([JSON.stringify(t)], { type: "application/json" }), i = URL.createObjectURL(s), a = document.createElement("a");
|
|
1661
|
+
a.style.display = "none", a.href = i, a.download = `${e}.json`, document.body.appendChild(a), a.click(), setTimeout(() => {
|
|
1662
|
+
document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1663
1663
|
}, 200);
|
|
1664
1664
|
}
|
|
1665
1665
|
}
|
|
1666
1666
|
$ = new WeakMap();
|
|
1667
|
-
const
|
|
1668
|
-
var K,
|
|
1669
|
-
class
|
|
1667
|
+
const Bt = new zt();
|
|
1668
|
+
var K, q, tt, nt, F, et, ot, Rt, Qt, ht, Yt, bt, qt, St, Zt, It, Vt;
|
|
1669
|
+
class ce {
|
|
1670
1670
|
constructor() {
|
|
1671
|
-
|
|
1671
|
+
D(this, Rt);
|
|
1672
1672
|
/** Вывод ошибок логера
|
|
1673
1673
|
* @param {'entity'} type - тип ошибки
|
|
1674
1674
|
*/
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1675
|
+
D(this, ht);
|
|
1676
|
+
D(this, bt);
|
|
1677
|
+
D(this, St);
|
|
1678
|
+
D(this, It);
|
|
1679
|
+
D(this, K, "logger");
|
|
1680
|
+
D(this, q, !1);
|
|
1681
|
+
D(this, tt, /* @__PURE__ */ new Map());
|
|
1682
|
+
D(this, nt, {});
|
|
1683
|
+
D(this, F, null);
|
|
1684
|
+
D(this, et, !1);
|
|
1685
|
+
D(this, ot, !1);
|
|
1686
1686
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1687
|
-
|
|
1688
|
-
E(this,
|
|
1687
|
+
C(this, "periodClear", 3);
|
|
1688
|
+
E(this, Rt, Qt).call(this);
|
|
1689
1689
|
}
|
|
1690
1690
|
/** Инициализация логера */
|
|
1691
1691
|
async init() {
|
|
1692
1692
|
try {
|
|
1693
|
-
let
|
|
1693
|
+
let t = new v(BX24.callBatch), { entityList: e } = await t.batch({
|
|
1694
1694
|
entityList: { method: "entity.get" }
|
|
1695
1695
|
});
|
|
1696
1696
|
if (e && Array.isArray(e))
|
|
1697
1697
|
if (e.find(
|
|
1698
|
-
(
|
|
1698
|
+
(i) => i.ENTITY == S(this, K)
|
|
1699
1699
|
))
|
|
1700
|
-
J(this,
|
|
1700
|
+
J(this, q, !0);
|
|
1701
1701
|
else {
|
|
1702
|
-
let { entityAdd:
|
|
1702
|
+
let { entityAdd: i } = await t.batch({
|
|
1703
1703
|
entityAdd: {
|
|
1704
1704
|
method: "entity.add",
|
|
1705
1705
|
params: {
|
|
1706
|
-
ENTITY:
|
|
1707
|
-
NAME:
|
|
1706
|
+
ENTITY: S(this, K),
|
|
1707
|
+
NAME: S(this, K),
|
|
1708
1708
|
ACCESS: { AU: "X" }
|
|
1709
1709
|
}
|
|
1710
1710
|
}
|
|
1711
1711
|
});
|
|
1712
|
-
|
|
1712
|
+
i && J(this, q, !0);
|
|
1713
1713
|
}
|
|
1714
|
-
return E(this,
|
|
1714
|
+
return E(this, St, Zt).call(this).catch((s) => {
|
|
1715
1715
|
console.error("Ошибка при проверке периода очистки:", s);
|
|
1716
|
-
}),
|
|
1717
|
-
} catch (
|
|
1718
|
-
return console.error("Ошибка при инициализации логера:",
|
|
1716
|
+
}), S(this, q);
|
|
1717
|
+
} catch (t) {
|
|
1718
|
+
return console.error("Ошибка при инициализации логера:", t), !1;
|
|
1719
1719
|
}
|
|
1720
1720
|
}
|
|
1721
1721
|
/**
|
|
@@ -1727,21 +1727,21 @@ class ee {
|
|
|
1727
1727
|
* }; }}
|
|
1728
1728
|
* @returns {string|null}
|
|
1729
1729
|
*/
|
|
1730
|
-
start({ type:
|
|
1731
|
-
if (!
|
|
1732
|
-
return E(this,
|
|
1733
|
-
if (!
|
|
1734
|
-
return console.error("Невалидные данные для логирования:", { type:
|
|
1735
|
-
const s =
|
|
1736
|
-
type:
|
|
1730
|
+
start({ type: t, data: e }) {
|
|
1731
|
+
if (!S(this, q))
|
|
1732
|
+
return E(this, ht, Yt).call(this, "entity"), null;
|
|
1733
|
+
if (!t || !e)
|
|
1734
|
+
return console.error("Невалидные данные для логирования:", { type: t, data: e }), null;
|
|
1735
|
+
const s = Bt.hash, i = {
|
|
1736
|
+
type: t,
|
|
1737
1737
|
data: e,
|
|
1738
|
-
userInfo:
|
|
1738
|
+
userInfo: S(this, nt),
|
|
1739
1739
|
errorList: {},
|
|
1740
1740
|
status: "",
|
|
1741
1741
|
answer: null,
|
|
1742
1742
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1743
1743
|
};
|
|
1744
|
-
return
|
|
1744
|
+
return S(this, tt).set(s, i), J(this, ot, !0), s;
|
|
1745
1745
|
}
|
|
1746
1746
|
/**
|
|
1747
1747
|
* @param {{
|
|
@@ -1750,56 +1750,56 @@ class ee {
|
|
|
1750
1750
|
* status: 'success'|'fail'|'fail-runtime',
|
|
1751
1751
|
* answer: { [key]: unknown } }}
|
|
1752
1752
|
*/
|
|
1753
|
-
async stop({ key:
|
|
1754
|
-
var
|
|
1755
|
-
if (!
|
|
1753
|
+
async stop({ key: t, errorList: e, status: s, answer: i }) {
|
|
1754
|
+
var l;
|
|
1755
|
+
if (!S(this, ot))
|
|
1756
1756
|
return;
|
|
1757
|
-
if (!
|
|
1758
|
-
E(this,
|
|
1757
|
+
if (!S(this, q)) {
|
|
1758
|
+
E(this, ht, Yt).call(this, "entity");
|
|
1759
1759
|
return;
|
|
1760
1760
|
}
|
|
1761
|
-
let
|
|
1762
|
-
if (!
|
|
1763
|
-
console.error(`Не найдены данные логирования для ключа: ${
|
|
1761
|
+
let a = S(this, tt).get(t);
|
|
1762
|
+
if (!a) {
|
|
1763
|
+
console.error(`Не найдены данные логирования для ключа: ${t}`);
|
|
1764
1764
|
return;
|
|
1765
1765
|
}
|
|
1766
|
-
e && (
|
|
1766
|
+
e && (a.errorList = e), s && (a.status = s), i && (a.answer = i), await E(this, bt, qt).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && J(this, et, !0), J(this, ot, !1);
|
|
1767
1767
|
}
|
|
1768
1768
|
/**
|
|
1769
1769
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
1770
1770
|
*/
|
|
1771
|
-
async getEntityList(
|
|
1771
|
+
async getEntityList(t) {
|
|
1772
1772
|
var e;
|
|
1773
1773
|
try {
|
|
1774
|
-
if ((e =
|
|
1775
|
-
return
|
|
1776
|
-
let s = new v(BX24.callBatch), { entityList:
|
|
1774
|
+
if ((e = S(this, F)) != null && e.length && !S(this, et))
|
|
1775
|
+
return S(this, F);
|
|
1776
|
+
let s = new v(BX24.callBatch), { entityList: i } = await s.batch(
|
|
1777
1777
|
{
|
|
1778
1778
|
entityList: {
|
|
1779
1779
|
method: "entity.item.get",
|
|
1780
1780
|
params: {
|
|
1781
|
-
ENTITY:
|
|
1781
|
+
ENTITY: S(this, K),
|
|
1782
1782
|
SORT: { ID: "DESC" }
|
|
1783
1783
|
}
|
|
1784
1784
|
}
|
|
1785
1785
|
},
|
|
1786
|
-
|
|
1786
|
+
t
|
|
1787
1787
|
);
|
|
1788
|
-
return !
|
|
1788
|
+
return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
|
|
1789
1789
|
try {
|
|
1790
|
-
const { ID:
|
|
1790
|
+
const { ID: l, DATE_CREATE: A, DETAIL_TEXT: h } = a;
|
|
1791
1791
|
return {
|
|
1792
|
-
...JSON.parse(
|
|
1793
|
-
id:
|
|
1792
|
+
...JSON.parse(h),
|
|
1793
|
+
id: l,
|
|
1794
1794
|
dateCreate: A
|
|
1795
1795
|
};
|
|
1796
|
-
} catch (
|
|
1796
|
+
} catch (l) {
|
|
1797
1797
|
return console.error(
|
|
1798
|
-
`Ошибка парсинга записи ${
|
|
1799
|
-
|
|
1798
|
+
`Ошибка парсинга записи ${a.ID}:`,
|
|
1799
|
+
l
|
|
1800
1800
|
), null;
|
|
1801
1801
|
}
|
|
1802
|
-
}).filter((
|
|
1802
|
+
}).filter((a) => a !== null), J(this, et, !1), J(this, F, i), i);
|
|
1803
1803
|
} catch (s) {
|
|
1804
1804
|
return console.error("Ошибка при получении списка записей:", s), [];
|
|
1805
1805
|
}
|
|
@@ -1807,132 +1807,160 @@ class ee {
|
|
|
1807
1807
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1808
1808
|
async downAllEntityJson() {
|
|
1809
1809
|
try {
|
|
1810
|
-
if (
|
|
1810
|
+
if (S(this, F) || await this.getEntityList(), !S(this, F) || S(this, F).length === 0)
|
|
1811
1811
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1812
|
-
let
|
|
1813
|
-
return
|
|
1814
|
-
|
|
1815
|
-
`sdklogger-entity-data__${
|
|
1812
|
+
let t = dt().format("%Y-%m-%d");
|
|
1813
|
+
return Bt.downloadFileJson(
|
|
1814
|
+
S(this, F),
|
|
1815
|
+
`sdklogger-entity-data__${t}`
|
|
1816
1816
|
), !0;
|
|
1817
|
-
} catch (
|
|
1818
|
-
return console.error("Ошибка при выгрузке данных в JSON:",
|
|
1817
|
+
} catch (t) {
|
|
1818
|
+
return console.error("Ошибка при выгрузке данных в JSON:", t), !1;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
1821
|
}
|
|
1822
|
-
K = new WeakMap(),
|
|
1822
|
+
K = new WeakMap(), q = new WeakMap(), tt = new WeakMap(), nt = new WeakMap(), F = new WeakMap(), et = new WeakMap(), ot = new WeakMap(), Rt = new WeakSet(), Qt = async function() {
|
|
1823
1823
|
try {
|
|
1824
|
-
const
|
|
1824
|
+
const t = new v(BX24.callBatch), e = BX24.isAdmin(), { curUser: s } = await t.batch({
|
|
1825
1825
|
curUser: { method: "user.current" }
|
|
1826
1826
|
});
|
|
1827
1827
|
J(this, nt, { isAdmin: e, curUser: s });
|
|
1828
|
-
} catch (
|
|
1828
|
+
} catch (t) {
|
|
1829
1829
|
console.error(
|
|
1830
1830
|
"Ошибка при получении информации о пользователе:",
|
|
1831
|
-
|
|
1831
|
+
t
|
|
1832
1832
|
), J(this, nt, { isAdmin: !1, curUser: null });
|
|
1833
1833
|
}
|
|
1834
|
-
},
|
|
1835
|
-
|
|
1834
|
+
}, ht = new WeakSet(), Yt = function(t) {
|
|
1835
|
+
t == "entity" && Bt.actionFilter({
|
|
1836
1836
|
keyTimer: "error.logger.entity",
|
|
1837
1837
|
duration: 500,
|
|
1838
1838
|
action: () => {
|
|
1839
1839
|
console.error("Хранилище для логгера не инициализировано");
|
|
1840
1840
|
}
|
|
1841
1841
|
});
|
|
1842
|
-
},
|
|
1842
|
+
}, bt = new WeakSet(), qt = async function() {
|
|
1843
1843
|
try {
|
|
1844
|
-
let
|
|
1845
|
-
for (let [s,
|
|
1846
|
-
if (
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1844
|
+
let t = {}, e = new v(BX24.callBatch);
|
|
1845
|
+
for (let [s, i] of S(this, tt).entries())
|
|
1846
|
+
if (i.status) {
|
|
1847
|
+
const a = JSON.stringify(i);
|
|
1848
|
+
t[s] = {
|
|
1849
1849
|
method: "entity.item.add",
|
|
1850
1850
|
params: {
|
|
1851
|
-
ENTITY:
|
|
1852
|
-
NAME:
|
|
1853
|
-
DETAIL_TEXT:
|
|
1851
|
+
ENTITY: S(this, K),
|
|
1852
|
+
NAME: S(this, K),
|
|
1853
|
+
DETAIL_TEXT: a
|
|
1854
1854
|
}
|
|
1855
1855
|
};
|
|
1856
1856
|
}
|
|
1857
|
-
if (Object.keys(
|
|
1858
|
-
let s = await e.batch(
|
|
1859
|
-
for (let [
|
|
1860
|
-
|
|
1857
|
+
if (Object.keys(t).length) {
|
|
1858
|
+
let s = await e.batch(t), { errors: i } = e;
|
|
1859
|
+
for (let [a, l] of Object.entries({ ...s, ...i }))
|
|
1860
|
+
S(this, tt).delete(a);
|
|
1861
1861
|
return !0;
|
|
1862
1862
|
}
|
|
1863
1863
|
return !1;
|
|
1864
|
-
} catch (
|
|
1865
|
-
return console.error("Ошибка при добавлении записей в хранилище:",
|
|
1864
|
+
} catch (t) {
|
|
1865
|
+
return console.error("Ошибка при добавлении записей в хранилище:", t), !1;
|
|
1866
1866
|
}
|
|
1867
|
-
},
|
|
1867
|
+
}, St = new WeakSet(), Zt = async function() {
|
|
1868
1868
|
try {
|
|
1869
|
-
let
|
|
1869
|
+
let t = new v(BX24.callBatch), { serverTime: e } = await t.batch({
|
|
1870
1870
|
serverTime: { method: "server.time" }
|
|
1871
1871
|
});
|
|
1872
1872
|
if (!e) {
|
|
1873
1873
|
console.error("Не удалось получить время сервера");
|
|
1874
1874
|
return;
|
|
1875
1875
|
}
|
|
1876
|
-
if (
|
|
1876
|
+
if (S(this, F) || await this.getEntityList(), !S(this, F) || S(this, F).length === 0)
|
|
1877
1877
|
return;
|
|
1878
|
-
let s =
|
|
1878
|
+
let s = S(this, F).filter((i) => {
|
|
1879
1879
|
try {
|
|
1880
|
-
let { dateCreate:
|
|
1881
|
-
return
|
|
1882
|
-
|
|
1880
|
+
let { dateCreate: a } = i;
|
|
1881
|
+
return a ? dt(new Date(a)).between(
|
|
1882
|
+
dt(new Date(e)),
|
|
1883
1883
|
"month"
|
|
1884
1884
|
) >= this.periodClear : !1;
|
|
1885
|
-
} catch (
|
|
1886
|
-
return console.error("Ошибка при проверке даты записи:",
|
|
1885
|
+
} catch (a) {
|
|
1886
|
+
return console.error("Ошибка при проверке даты записи:", a), !1;
|
|
1887
1887
|
}
|
|
1888
1888
|
});
|
|
1889
1889
|
s.length > 0 && (console.log(
|
|
1890
1890
|
`Найдено ${s.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1891
|
-
), await E(this,
|
|
1892
|
-
} catch (
|
|
1893
|
-
console.error("Ошибка при проверке периода очистки:",
|
|
1891
|
+
), await E(this, It, Vt).call(this, s));
|
|
1892
|
+
} catch (t) {
|
|
1893
|
+
console.error("Ошибка при проверке периода очистки:", t);
|
|
1894
1894
|
}
|
|
1895
|
-
},
|
|
1895
|
+
}, It = new WeakSet(), Vt = async function(t) {
|
|
1896
1896
|
try {
|
|
1897
|
-
if (!
|
|
1897
|
+
if (!t || t.length === 0)
|
|
1898
1898
|
return !1;
|
|
1899
|
-
let e = new v(BX24.callBatch), s =
|
|
1900
|
-
let { id:
|
|
1899
|
+
let e = new v(BX24.callBatch), s = t.filter((a) => a && a.id).map((a) => {
|
|
1900
|
+
let { id: l } = a;
|
|
1901
1901
|
return {
|
|
1902
1902
|
method: "entity.item.delete",
|
|
1903
1903
|
params: {
|
|
1904
|
-
ENTITY:
|
|
1905
|
-
ID:
|
|
1904
|
+
ENTITY: S(this, K),
|
|
1905
|
+
ID: l
|
|
1906
1906
|
}
|
|
1907
1907
|
};
|
|
1908
1908
|
});
|
|
1909
1909
|
if (s.length === 0)
|
|
1910
1910
|
return !1;
|
|
1911
|
-
const
|
|
1912
|
-
return console.log(`Успешно удалено ${s.length} записей`), J(this, et, !0),
|
|
1911
|
+
const i = await e.batch(s);
|
|
1912
|
+
return console.log(`Успешно удалено ${s.length} записей`), J(this, et, !0), i;
|
|
1913
1913
|
} catch (e) {
|
|
1914
1914
|
return console.error("Ошибка при очистке устаревших записей:", e), !1;
|
|
1915
1915
|
}
|
|
1916
1916
|
};
|
|
1917
|
-
|
|
1918
|
-
|
|
1917
|
+
function Ft(p) {
|
|
1918
|
+
if (!p || typeof p != "string")
|
|
1919
|
+
return "";
|
|
1920
|
+
try {
|
|
1921
|
+
const t = new URL(p);
|
|
1922
|
+
t.search = "", t.hash = "";
|
|
1923
|
+
let e = t.toString();
|
|
1924
|
+
return e.endsWith("/") && t.pathname !== "/" && (e = e.slice(0, -1)), e;
|
|
1925
|
+
} catch {
|
|
1926
|
+
return p.split("?")[0].split("#")[0].replace(/\/$/, "");
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function $t(p) {
|
|
1930
|
+
return !p || typeof p != "string" ? !1 : p.toLowerCase().includes("/marketplace/app");
|
|
1931
|
+
}
|
|
1932
|
+
function le() {
|
|
1933
|
+
var t;
|
|
1934
|
+
if (typeof window > "u" || !((t = window.location) != null && t.href))
|
|
1935
|
+
return "";
|
|
1936
|
+
const p = Ft(window.location.href);
|
|
1937
|
+
return $t(p) ? "" : p;
|
|
1938
|
+
}
|
|
1939
|
+
function Gt(p) {
|
|
1940
|
+
if (!(p != null && p.appConst) || typeof p.appConst != "object")
|
|
1941
|
+
return "";
|
|
1942
|
+
const t = le();
|
|
1943
|
+
return t ? (p.appConst.pathApp = t, t) : Ft(p.appConst.pathApp ?? "");
|
|
1944
|
+
}
|
|
1945
|
+
var rt, ct, Mt, te, Dt, ee, ut, Pt, ft, Wt, kt, re;
|
|
1946
|
+
class ge {
|
|
1919
1947
|
/**
|
|
1920
1948
|
* @param {Object} appConst - Константы приложения
|
|
1921
1949
|
* @param {string} appConst.appName - Название приложения
|
|
1922
1950
|
* @param {string} appConst.pathApp - Путь к приложению
|
|
1923
1951
|
*/
|
|
1924
|
-
constructor(
|
|
1952
|
+
constructor(t) {
|
|
1925
1953
|
/**
|
|
1926
1954
|
* Returns shared Batch instance for all batch operations.
|
|
1927
1955
|
* Keeps a single stateful Batch (including timeLimit) within current BxBoot lifecycle.
|
|
1928
1956
|
*
|
|
1929
1957
|
* @returns {Batch} Shared Batch instance.
|
|
1930
1958
|
*/
|
|
1931
|
-
|
|
1959
|
+
D(this, rt);
|
|
1932
1960
|
/** Запрос данных о приложении */
|
|
1933
|
-
|
|
1961
|
+
D(this, Mt);
|
|
1934
1962
|
/** Запрос данных о текущем пользователе */
|
|
1935
|
-
|
|
1963
|
+
D(this, Dt);
|
|
1936
1964
|
/**
|
|
1937
1965
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1938
1966
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -1942,32 +1970,32 @@ class se {
|
|
|
1942
1970
|
* @param {Array} updateList - Список обновлений для логирования (опционально)
|
|
1943
1971
|
* @returns {Object} Расширенный список ошибок
|
|
1944
1972
|
*/
|
|
1945
|
-
|
|
1973
|
+
D(this, ut);
|
|
1946
1974
|
/**
|
|
1947
1975
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
1948
1976
|
* @private
|
|
1949
1977
|
*/
|
|
1950
|
-
|
|
1978
|
+
D(this, ft);
|
|
1951
1979
|
/**
|
|
1952
1980
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
1953
1981
|
* @private
|
|
1954
1982
|
*/
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1983
|
+
D(this, kt);
|
|
1984
|
+
C(this, "domain", "");
|
|
1985
|
+
C(this, "isAdmin", !1);
|
|
1986
|
+
C(this, "appInfo", null);
|
|
1987
|
+
C(this, "appConst", null);
|
|
1988
|
+
C(this, "userInfo", null);
|
|
1989
|
+
C(this, "placeData", null);
|
|
1990
|
+
C(this, "placeInfo", null);
|
|
1991
|
+
C(this, "logger", !1);
|
|
1992
|
+
C(this, "timeLimit", {
|
|
1965
1993
|
limit: !1,
|
|
1966
1994
|
date: void 0,
|
|
1967
1995
|
pauseMs: void 0
|
|
1968
1996
|
});
|
|
1969
|
-
|
|
1970
|
-
this.appConst =
|
|
1997
|
+
C(this, "batchClient", null);
|
|
1998
|
+
this.appConst = t;
|
|
1971
1999
|
}
|
|
1972
2000
|
/**
|
|
1973
2001
|
* Подписывает внешний код на изменения состояния timeLimit в Batch.
|
|
@@ -1975,8 +2003,8 @@ class se {
|
|
|
1975
2003
|
* @param {(state: {limit: boolean, date?: string, pauseMs?: number}) => void} callback - Обработчик состояния лимита.
|
|
1976
2004
|
* @returns {() => void} Функция отписки.
|
|
1977
2005
|
*/
|
|
1978
|
-
subscribeTimeLimit(
|
|
1979
|
-
return E(this, rt, ct).call(this).subscribeTimeLimit(
|
|
2006
|
+
subscribeTimeLimit(t) {
|
|
2007
|
+
return E(this, rt, ct).call(this).subscribeTimeLimit(t);
|
|
1980
2008
|
}
|
|
1981
2009
|
/**
|
|
1982
2010
|
* Инициализация Bitrix24 SDK
|
|
@@ -1984,10 +2012,10 @@ class se {
|
|
|
1984
2012
|
* @throws {Error} Если BX24 не загружен в течение 30 секунд
|
|
1985
2013
|
*/
|
|
1986
2014
|
init() {
|
|
1987
|
-
return new Promise((
|
|
1988
|
-
let
|
|
2015
|
+
return new Promise((t, e) => {
|
|
2016
|
+
let i = setInterval(() => {
|
|
1989
2017
|
window.BX24 && BX24.init(async () => {
|
|
1990
|
-
console.info("init BX24"), clearInterval(
|
|
2018
|
+
console.info("init BX24"), clearInterval(i), clearTimeout(a), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new ce(), await this.logger.init()) : this.logger = {
|
|
1991
2019
|
start: () => {
|
|
1992
2020
|
},
|
|
1993
2021
|
stop: () => {
|
|
@@ -1995,29 +2023,29 @@ class se {
|
|
|
1995
2023
|
getEntityList: () => {
|
|
1996
2024
|
}
|
|
1997
2025
|
};
|
|
1998
|
-
const [
|
|
1999
|
-
E(this,
|
|
2000
|
-
E(this,
|
|
2026
|
+
const [l, A] = await Promise.all([
|
|
2027
|
+
E(this, Mt, te).call(this),
|
|
2028
|
+
E(this, Dt, ee).call(this)
|
|
2001
2029
|
]);
|
|
2002
|
-
this.appInfo =
|
|
2003
|
-
let
|
|
2030
|
+
this.appInfo = l, this.userInfo = A, Gt(this);
|
|
2031
|
+
let h = new zt();
|
|
2004
2032
|
try {
|
|
2005
|
-
|
|
2006
|
-
} catch (
|
|
2033
|
+
h.noSleep();
|
|
2034
|
+
} catch (n) {
|
|
2007
2035
|
console.warn(
|
|
2008
2036
|
"Failed to initialize noSleep:",
|
|
2009
|
-
|
|
2037
|
+
n
|
|
2010
2038
|
);
|
|
2011
2039
|
}
|
|
2012
|
-
|
|
2040
|
+
t(!0);
|
|
2013
2041
|
});
|
|
2014
2042
|
}, 100);
|
|
2015
|
-
const
|
|
2016
|
-
clearInterval(
|
|
2017
|
-
const
|
|
2043
|
+
const a = setTimeout(() => {
|
|
2044
|
+
clearInterval(i);
|
|
2045
|
+
const l = new Error(
|
|
2018
2046
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
2019
2047
|
);
|
|
2020
|
-
console.error(
|
|
2048
|
+
console.error(l), e(l);
|
|
2021
2049
|
}, 3e4);
|
|
2022
2050
|
});
|
|
2023
2051
|
}
|
|
@@ -2027,23 +2055,23 @@ class se {
|
|
|
2027
2055
|
* @param {any} value - Значение для установки (если не указано, метод вернет текущее значение)
|
|
2028
2056
|
* @returns {any}
|
|
2029
2057
|
*/
|
|
2030
|
-
userOption(
|
|
2058
|
+
userOption(t, e) {
|
|
2031
2059
|
if (typeof BX24 > "u" || !BX24.userOption) {
|
|
2032
2060
|
console.warn(
|
|
2033
2061
|
"BX24.userOption is not available. Make sure BX24 is initialized."
|
|
2034
2062
|
);
|
|
2035
2063
|
return;
|
|
2036
2064
|
}
|
|
2037
|
-
return e !== void 0 ? BX24.userOption.set(
|
|
2065
|
+
return e !== void 0 ? BX24.userOption.set(t, e) : BX24.userOption.get(t);
|
|
2038
2066
|
}
|
|
2039
|
-
appOption(
|
|
2067
|
+
appOption(t, e) {
|
|
2040
2068
|
if (typeof BX24 > "u" || !BX24.appOption) {
|
|
2041
2069
|
console.warn(
|
|
2042
2070
|
"BX24.appOption is not available. Make sure BX24 is initialized."
|
|
2043
2071
|
);
|
|
2044
2072
|
return;
|
|
2045
2073
|
}
|
|
2046
|
-
return e !== void 0 ? BX24.appOption.set(
|
|
2074
|
+
return e !== void 0 ? BX24.appOption.set(t, e) : BX24.appOption.get(t);
|
|
2047
2075
|
}
|
|
2048
2076
|
/**
|
|
2049
2077
|
* @param {{
|
|
@@ -2063,41 +2091,41 @@ class se {
|
|
|
2063
2091
|
* }[]
|
|
2064
2092
|
* }[]
|
|
2065
2093
|
*/
|
|
2066
|
-
async call({ method:
|
|
2067
|
-
let
|
|
2068
|
-
if (s && (
|
|
2094
|
+
async call({ method: t, params: e, updateList: s }) {
|
|
2095
|
+
let i;
|
|
2096
|
+
if (s && (i = this.logger.start({
|
|
2069
2097
|
type: "call",
|
|
2070
|
-
data: { method:
|
|
2098
|
+
data: { method: t, params: e, updateList: s }
|
|
2071
2099
|
})), e || (e = {}), typeof BX24 > "u" || !BX24.callMethod) {
|
|
2072
2100
|
const A = new Error("BX24 is not initialized");
|
|
2073
2101
|
throw console.error(A), A;
|
|
2074
2102
|
}
|
|
2075
|
-
const
|
|
2076
|
-
if (!
|
|
2077
|
-
if (console.error(
|
|
2103
|
+
const l = await E(this, rt, ct).call(this).call({ method: t, params: e });
|
|
2104
|
+
if (!l.success) {
|
|
2105
|
+
if (console.error(l.error), i)
|
|
2078
2106
|
try {
|
|
2079
2107
|
await this.logger.stop({
|
|
2080
|
-
answer:
|
|
2081
|
-
key:
|
|
2108
|
+
answer: l.answer,
|
|
2109
|
+
key: i,
|
|
2082
2110
|
status: "fail",
|
|
2083
|
-
errorList: { 0:
|
|
2111
|
+
errorList: { 0: l.error || "Unknown call error" }
|
|
2084
2112
|
});
|
|
2085
2113
|
} catch (A) {
|
|
2086
2114
|
console.error("Logger error:", A);
|
|
2087
2115
|
}
|
|
2088
2116
|
return !1;
|
|
2089
2117
|
}
|
|
2090
|
-
if (
|
|
2118
|
+
if (i)
|
|
2091
2119
|
try {
|
|
2092
2120
|
await this.logger.stop({
|
|
2093
|
-
answer:
|
|
2094
|
-
key:
|
|
2121
|
+
answer: l.answer,
|
|
2122
|
+
key: i,
|
|
2095
2123
|
status: "success"
|
|
2096
2124
|
});
|
|
2097
2125
|
} catch (A) {
|
|
2098
2126
|
console.error("Logger error:", A);
|
|
2099
2127
|
}
|
|
2100
|
-
return
|
|
2128
|
+
return l.data;
|
|
2101
2129
|
}
|
|
2102
2130
|
/**
|
|
2103
2131
|
* @param commandList - объект/массив команд
|
|
@@ -2118,31 +2146,31 @@ class se {
|
|
|
2118
2146
|
* }[]
|
|
2119
2147
|
* }}
|
|
2120
2148
|
*/
|
|
2121
|
-
async batch(
|
|
2149
|
+
async batch(t, e, { errorCall: s, updateList: i, batchOptions: a } = {}) {
|
|
2122
2150
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2123
|
-
const
|
|
2124
|
-
return console.error(
|
|
2151
|
+
const h = new Error("BX24 is not initialized");
|
|
2152
|
+
return console.error(h), !1;
|
|
2125
2153
|
}
|
|
2126
|
-
const
|
|
2154
|
+
const l = E(this, rt, ct).call(this);
|
|
2127
2155
|
let A;
|
|
2128
|
-
|
|
2156
|
+
i && (A = this.logger.start({
|
|
2129
2157
|
type: "batch",
|
|
2130
|
-
data: { commandList:
|
|
2158
|
+
data: { commandList: t, updateList: i }
|
|
2131
2159
|
}));
|
|
2132
2160
|
try {
|
|
2133
|
-
let
|
|
2134
|
-
|
|
2161
|
+
let h = await l.batch(
|
|
2162
|
+
t,
|
|
2135
2163
|
e,
|
|
2136
|
-
|
|
2164
|
+
a
|
|
2137
2165
|
);
|
|
2138
|
-
const
|
|
2139
|
-
if (Object.keys(
|
|
2140
|
-
if (s && s(
|
|
2166
|
+
const n = E(this, ut, Pt).call(this, l, h, t, i);
|
|
2167
|
+
if (Object.keys(n).length) {
|
|
2168
|
+
if (s && s(n), A)
|
|
2141
2169
|
try {
|
|
2142
2170
|
await this.logger.stop({
|
|
2143
2171
|
key: A,
|
|
2144
2172
|
status: "fail",
|
|
2145
|
-
errorList:
|
|
2173
|
+
errorList: n
|
|
2146
2174
|
});
|
|
2147
2175
|
} catch (u) {
|
|
2148
2176
|
console.error("Logger error:", u);
|
|
@@ -2156,19 +2184,19 @@ class se {
|
|
|
2156
2184
|
} catch (u) {
|
|
2157
2185
|
console.error("Logger error:", u);
|
|
2158
2186
|
}
|
|
2159
|
-
return
|
|
2160
|
-
} catch (
|
|
2187
|
+
return h;
|
|
2188
|
+
} catch (h) {
|
|
2161
2189
|
if (A)
|
|
2162
2190
|
try {
|
|
2163
2191
|
await this.logger.stop({
|
|
2164
2192
|
key: A,
|
|
2165
2193
|
status: "fail-runtime",
|
|
2166
|
-
errorList: { 0:
|
|
2194
|
+
errorList: { 0: h == null ? void 0 : h.toString() }
|
|
2167
2195
|
});
|
|
2168
|
-
} catch (
|
|
2169
|
-
console.error("Logger error:",
|
|
2196
|
+
} catch (n) {
|
|
2197
|
+
console.error("Logger error:", n);
|
|
2170
2198
|
}
|
|
2171
|
-
return console.error(
|
|
2199
|
+
return console.error(h), !1;
|
|
2172
2200
|
}
|
|
2173
2201
|
}
|
|
2174
2202
|
/**
|
|
@@ -2193,105 +2221,105 @@ class se {
|
|
|
2193
2221
|
* }}
|
|
2194
2222
|
* @returns {Promise<Object|false>}
|
|
2195
2223
|
*/
|
|
2196
|
-
async batchTotalCount(
|
|
2224
|
+
async batchTotalCount(t, e, { errorCall: s, updateList: i } = {}) {
|
|
2197
2225
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
2198
2226
|
const A = new Error("BX24 is not initialized");
|
|
2199
2227
|
return console.error(A), !1;
|
|
2200
2228
|
}
|
|
2201
|
-
const
|
|
2202
|
-
let
|
|
2203
|
-
|
|
2229
|
+
const a = E(this, rt, ct).call(this);
|
|
2230
|
+
let l;
|
|
2231
|
+
i && (l = this.logger.start({
|
|
2204
2232
|
type: "batch-total-count",
|
|
2205
|
-
data: { commandList:
|
|
2233
|
+
data: { commandList: t }
|
|
2206
2234
|
}));
|
|
2207
2235
|
try {
|
|
2208
|
-
let A = await
|
|
2209
|
-
|
|
2236
|
+
let A = await a.batchTotalCount(
|
|
2237
|
+
t,
|
|
2210
2238
|
e
|
|
2211
2239
|
);
|
|
2212
|
-
const
|
|
2213
|
-
if (Object.keys(
|
|
2214
|
-
if (s && s(
|
|
2240
|
+
const h = E(this, ut, Pt).call(this, a, A, t, i);
|
|
2241
|
+
if (Object.keys(h).length) {
|
|
2242
|
+
if (s && s(h), l)
|
|
2215
2243
|
try {
|
|
2216
2244
|
await this.logger.stop({
|
|
2217
|
-
key:
|
|
2245
|
+
key: l,
|
|
2218
2246
|
status: "fail",
|
|
2219
|
-
errorList:
|
|
2247
|
+
errorList: h
|
|
2220
2248
|
});
|
|
2221
|
-
} catch (
|
|
2222
|
-
console.error("Logger error:",
|
|
2249
|
+
} catch (n) {
|
|
2250
|
+
console.error("Logger error:", n);
|
|
2223
2251
|
}
|
|
2224
|
-
} else if (
|
|
2252
|
+
} else if (l)
|
|
2225
2253
|
try {
|
|
2226
2254
|
await this.logger.stop({
|
|
2227
|
-
key:
|
|
2255
|
+
key: l,
|
|
2228
2256
|
status: "success"
|
|
2229
2257
|
});
|
|
2230
|
-
} catch (
|
|
2231
|
-
console.error("Logger error:",
|
|
2258
|
+
} catch (n) {
|
|
2259
|
+
console.error("Logger error:", n);
|
|
2232
2260
|
}
|
|
2233
2261
|
return A;
|
|
2234
2262
|
} catch (A) {
|
|
2235
|
-
if (
|
|
2263
|
+
if (l)
|
|
2236
2264
|
try {
|
|
2237
2265
|
await this.logger.stop({
|
|
2238
|
-
key:
|
|
2266
|
+
key: l,
|
|
2239
2267
|
status: "fail-runtime",
|
|
2240
2268
|
errorList: { 0: A == null ? void 0 : A.toString() }
|
|
2241
2269
|
});
|
|
2242
|
-
} catch (
|
|
2243
|
-
console.error("Logger error:",
|
|
2270
|
+
} catch (h) {
|
|
2271
|
+
console.error("Logger error:", h);
|
|
2244
2272
|
}
|
|
2245
2273
|
return console.error(A), !1;
|
|
2246
2274
|
}
|
|
2247
2275
|
}
|
|
2248
2276
|
/** Запрос данных о местах встройки приложения */
|
|
2249
2277
|
async getPlacement() {
|
|
2250
|
-
return await this.call({ method: "placement.get" }).then((
|
|
2278
|
+
return await this.call({ method: "placement.get" }).then((t) => (this.placeData || (this.placeData = t), t));
|
|
2251
2279
|
}
|
|
2252
2280
|
/**
|
|
2253
2281
|
* Встройка приложения в указанные места
|
|
2254
2282
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для встройки
|
|
2255
2283
|
*/
|
|
2256
|
-
async placementBind(
|
|
2257
|
-
var
|
|
2284
|
+
async placementBind(t) {
|
|
2285
|
+
var m;
|
|
2258
2286
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2259
2287
|
return;
|
|
2260
2288
|
const { appName: e, pathApp: s } = this.appConst;
|
|
2261
|
-
let
|
|
2262
|
-
|
|
2289
|
+
let i = E(this, ft, Wt).call(this, t);
|
|
2290
|
+
i = i.filter(
|
|
2263
2291
|
(c) => c.placement !== "PAGE_BACKGROUND_WORKER" && c.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2264
2292
|
);
|
|
2265
|
-
const
|
|
2266
|
-
for (const c of
|
|
2267
|
-
|
|
2268
|
-
if (
|
|
2293
|
+
const a = E(this, kt, re).call(this, s), l = new Set(i.map((c) => c.placement));
|
|
2294
|
+
for (const c of a)
|
|
2295
|
+
l.has(c.placement) || i.push({ placement: c.placement });
|
|
2296
|
+
if (i.length === 0)
|
|
2269
2297
|
return;
|
|
2270
2298
|
let A = e;
|
|
2271
|
-
this.domain === "szdl.bitrix24.ru" && ((
|
|
2272
|
-
const
|
|
2273
|
-
for (let c = 0; c <
|
|
2274
|
-
const f =
|
|
2299
|
+
this.domain === "szdl.bitrix24.ru" && ((m = this.appInfo) != null && m.ID) && (A = `${e}: #${this.appInfo.ID}`);
|
|
2300
|
+
const h = A.replace(" CRM", ""), n = {}, u = [];
|
|
2301
|
+
for (let c = 0; c < i.length; c++) {
|
|
2302
|
+
const f = i[c].placement;
|
|
2275
2303
|
if (this.placeData.find(
|
|
2276
|
-
(
|
|
2304
|
+
(_) => _.placement === f && _.handler === s
|
|
2277
2305
|
))
|
|
2278
2306
|
continue;
|
|
2279
|
-
const
|
|
2280
|
-
(
|
|
2307
|
+
const T = this.placeData.filter(
|
|
2308
|
+
(_) => _.placement === f && _.handler !== s
|
|
2281
2309
|
);
|
|
2282
|
-
for (const
|
|
2310
|
+
for (const _ of T)
|
|
2283
2311
|
u.push({
|
|
2284
2312
|
placement: f,
|
|
2285
|
-
handler:
|
|
2313
|
+
handler: _.handler
|
|
2286
2314
|
});
|
|
2287
|
-
|
|
2315
|
+
n[`bind_${c}`] = {
|
|
2288
2316
|
method: "placement.bind",
|
|
2289
2317
|
params: {
|
|
2290
2318
|
PLACEMENT: f,
|
|
2291
2319
|
HANDLER: s,
|
|
2292
2320
|
LANG_ALL: {
|
|
2293
2321
|
ru: {
|
|
2294
|
-
TITLE: f === "USER_PROFILE_TOOLBAR" ?
|
|
2322
|
+
TITLE: f === "USER_PROFILE_TOOLBAR" ? h : A
|
|
2295
2323
|
}
|
|
2296
2324
|
},
|
|
2297
2325
|
OPTIONS: {
|
|
@@ -2300,7 +2328,7 @@ class se {
|
|
|
2300
2328
|
}
|
|
2301
2329
|
};
|
|
2302
2330
|
}
|
|
2303
|
-
u.length > 0 && await this.placementUnBind(u), Object.keys(
|
|
2331
|
+
u.length > 0 && await this.placementUnBind(u), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((c) => {
|
|
2304
2332
|
console.log("Приложение успешно встроено в", c.params.PLACEMENT);
|
|
2305
2333
|
}));
|
|
2306
2334
|
}
|
|
@@ -2308,24 +2336,24 @@ class se {
|
|
|
2308
2336
|
* Отвязка встройки из указанных мест
|
|
2309
2337
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2310
2338
|
*/
|
|
2311
|
-
async placementUnBind(
|
|
2312
|
-
let e = E(this, ft,
|
|
2339
|
+
async placementUnBind(t) {
|
|
2340
|
+
let e = E(this, ft, Wt).call(this, t);
|
|
2313
2341
|
if (e = e.filter(
|
|
2314
|
-
(
|
|
2342
|
+
(i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
|
|
2315
2343
|
), e.length === 0)
|
|
2316
2344
|
return;
|
|
2317
2345
|
const s = {};
|
|
2318
|
-
for (let
|
|
2319
|
-
const
|
|
2320
|
-
PLACEMENT: e[
|
|
2346
|
+
for (let i = 0; i < e.length; i++) {
|
|
2347
|
+
const a = {
|
|
2348
|
+
PLACEMENT: e[i].placement
|
|
2321
2349
|
};
|
|
2322
|
-
e[
|
|
2350
|
+
e[i].handler && (a.HANDLER = e[i].handler), s[`unbind_${i}`] = {
|
|
2323
2351
|
method: "placement.unbind",
|
|
2324
|
-
params:
|
|
2352
|
+
params: a
|
|
2325
2353
|
};
|
|
2326
2354
|
}
|
|
2327
|
-
await this.batch(s), e.forEach((
|
|
2328
|
-
console.log("Встройка отвязана",
|
|
2355
|
+
await this.batch(s), e.forEach((i) => {
|
|
2356
|
+
console.log("Встройка отвязана", i.placement);
|
|
2329
2357
|
});
|
|
2330
2358
|
}
|
|
2331
2359
|
/** Чат-бот */
|
|
@@ -2334,22 +2362,22 @@ class se {
|
|
|
2334
2362
|
return this.call({
|
|
2335
2363
|
method: "imbot.bot.list",
|
|
2336
2364
|
params: {}
|
|
2337
|
-
}).then((
|
|
2338
|
-
let e = Object.values(
|
|
2365
|
+
}).then((t) => {
|
|
2366
|
+
let e = Object.values(t);
|
|
2339
2367
|
return console.log("chat-bot list:", e), e;
|
|
2340
2368
|
});
|
|
2341
2369
|
}
|
|
2342
2370
|
/* регистрация бота */
|
|
2343
|
-
regBot({ code:
|
|
2344
|
-
const { appName:
|
|
2371
|
+
regBot({ code: t, type: e, name: s }) {
|
|
2372
|
+
const { appName: i, pathApp: a, chatBotLogo: l } = this.appConst, A = this.appInfo.ID;
|
|
2345
2373
|
return this.call({
|
|
2346
2374
|
method: "imbot.register",
|
|
2347
2375
|
params: {
|
|
2348
|
-
CODE:
|
|
2376
|
+
CODE: t ?? this.appInfo.CODE,
|
|
2349
2377
|
// Строковой идентификатор бота, уникальный в рамках вашего приложения (обяз.)
|
|
2350
2378
|
TYPE: e ?? "O",
|
|
2351
2379
|
// Тип бота, B - чат-бот, ответы поступают сразу, H - человек, ответы поступают с задержкой от 2-х до 10 секунд, O - чат-бот для Открытых линий, S - чат-бот с повышенными привилегиями (supervisor)
|
|
2352
|
-
EVENT_HANDLER:
|
|
2380
|
+
EVENT_HANDLER: a,
|
|
2353
2381
|
// Ссылка на обработчик событий, поступивших от сервера - см. Обработчики событий ниже (обяз).
|
|
2354
2382
|
OPENLINE: "Y",
|
|
2355
2383
|
// Включение режима поддержки Открытых линий, можно не указывать, если TYPE = 'O'
|
|
@@ -2357,7 +2385,7 @@ class se {
|
|
|
2357
2385
|
// строковый идентификатор чат-бота, используется только в режиме Вебхуков
|
|
2358
2386
|
PROPERTIES: {
|
|
2359
2387
|
// Личные данные чат-бота (обяз.)
|
|
2360
|
-
NAME: `${s ??
|
|
2388
|
+
NAME: `${s ?? i} - бот #${A}`,
|
|
2361
2389
|
// Имя чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
2362
2390
|
LAST_NAME: "",
|
|
2363
2391
|
// Фамилия чат-бота (обязательное одно из полей NAME или LAST_NAME)
|
|
@@ -2365,7 +2393,7 @@ class se {
|
|
|
2365
2393
|
// Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
|
|
2366
2394
|
EMAIL: "",
|
|
2367
2395
|
// E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
|
|
2368
|
-
PERSONAL_BIRTHDAY:
|
|
2396
|
+
PERSONAL_BIRTHDAY: dt().format("%Y-%m-%d"),
|
|
2369
2397
|
// День рождения в формате YYYY-mm-dd
|
|
2370
2398
|
WORK_POSITION: "Почтальон",
|
|
2371
2399
|
// Занимаемая должность, используется как описание чат-бота
|
|
@@ -2373,24 +2401,24 @@ class se {
|
|
|
2373
2401
|
// Ссылка на сайт
|
|
2374
2402
|
PERSONAL_GENDER: "M",
|
|
2375
2403
|
// Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
|
|
2376
|
-
PERSONAL_PHOTO:
|
|
2404
|
+
PERSONAL_PHOTO: l ?? ""
|
|
2377
2405
|
// Аватар чат-бота - base64
|
|
2378
2406
|
}
|
|
2379
2407
|
}
|
|
2380
|
-
}).then((
|
|
2408
|
+
}).then((h) => (console.log("Чат-бот добавлен", h), h));
|
|
2381
2409
|
}
|
|
2382
2410
|
/* Убрать регистрацию бота */
|
|
2383
|
-
unRegBot(
|
|
2411
|
+
unRegBot(t) {
|
|
2384
2412
|
return this.call({
|
|
2385
2413
|
method: "imbot.unregister",
|
|
2386
2414
|
params: {
|
|
2387
|
-
BOT_ID:
|
|
2415
|
+
BOT_ID: t
|
|
2388
2416
|
}
|
|
2389
2417
|
}).then((e) => (console.log("чат-бот удален", e), e));
|
|
2390
2418
|
}
|
|
2391
2419
|
/* Получение данных логера */
|
|
2392
|
-
getLoggerList(
|
|
2393
|
-
return this.logger.getEntityList(
|
|
2420
|
+
getLoggerList(t) {
|
|
2421
|
+
return this.logger.getEntityList(t);
|
|
2394
2422
|
}
|
|
2395
2423
|
}
|
|
2396
2424
|
rt = new WeakSet(), ct = function() {
|
|
@@ -2398,75 +2426,129 @@ rt = new WeakSet(), ct = function() {
|
|
|
2398
2426
|
callBatch: BX24.callBatch,
|
|
2399
2427
|
callMethod: BX24.callMethod
|
|
2400
2428
|
}), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
|
|
2401
|
-
},
|
|
2429
|
+
}, Mt = new WeakSet(), te = function() {
|
|
2402
2430
|
return this.call({ method: "app.info" });
|
|
2403
|
-
},
|
|
2431
|
+
}, Dt = new WeakSet(), ee = function() {
|
|
2404
2432
|
return this.call({ method: "user.current" });
|
|
2405
|
-
}, ut = new WeakSet(),
|
|
2406
|
-
let
|
|
2407
|
-
if (Object.values(
|
|
2433
|
+
}, ut = new WeakSet(), Pt = function(t, e, s, i) {
|
|
2434
|
+
let a = { ...t.errors };
|
|
2435
|
+
if (Object.values(t.errors).some(
|
|
2408
2436
|
(A) => {
|
|
2409
2437
|
if (typeof A != "string")
|
|
2410
2438
|
return !1;
|
|
2411
|
-
const
|
|
2412
|
-
return
|
|
2439
|
+
const h = A.toUpperCase();
|
|
2440
|
+
return h === "TIMEOUT" || h === "OPERATION_TIME_LIMIT" || h.includes("TIMEOUT") || h.includes("OPERATION_TIME_LIMIT");
|
|
2413
2441
|
}
|
|
2414
|
-
) &&
|
|
2415
|
-
const A = e ? Object.keys(e).filter((
|
|
2442
|
+
) && i) {
|
|
2443
|
+
const A = e ? Object.keys(e).filter((m) => m !== "errorsList") : [], h = new Set(Object.keys(t.errors || {})), n = /* @__PURE__ */ new Set();
|
|
2416
2444
|
if (e) {
|
|
2417
|
-
for (const
|
|
2418
|
-
if (!
|
|
2419
|
-
const c = e[
|
|
2420
|
-
c != null &&
|
|
2445
|
+
for (const m of A)
|
|
2446
|
+
if (!h.has(m)) {
|
|
2447
|
+
const c = e[m];
|
|
2448
|
+
c != null && n.add(m);
|
|
2421
2449
|
}
|
|
2422
2450
|
}
|
|
2423
|
-
const u = Object.values(
|
|
2424
|
-
(
|
|
2425
|
-
if (typeof
|
|
2451
|
+
const u = Object.values(t.errors).find(
|
|
2452
|
+
(m) => {
|
|
2453
|
+
if (typeof m != "string")
|
|
2426
2454
|
return !1;
|
|
2427
|
-
const c =
|
|
2455
|
+
const c = m.toUpperCase();
|
|
2428
2456
|
return c === "TIMEOUT" || c === "OPERATION_TIME_LIMIT" || c.includes("TIMEOUT") || c.includes("OPERATION_TIME_LIMIT");
|
|
2429
2457
|
}
|
|
2430
2458
|
);
|
|
2431
|
-
for (const
|
|
2432
|
-
!
|
|
2459
|
+
for (const m of Object.keys(s))
|
|
2460
|
+
!n.has(m) && !t.errors[m] && (a[m] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
|
|
2433
2461
|
}
|
|
2434
|
-
return
|
|
2435
|
-
}, ft = new WeakSet(),
|
|
2436
|
-
if (!
|
|
2462
|
+
return a;
|
|
2463
|
+
}, ft = new WeakSet(), Wt = function(t) {
|
|
2464
|
+
if (!t)
|
|
2437
2465
|
return [];
|
|
2438
2466
|
let e = [];
|
|
2439
|
-
return Array.isArray(
|
|
2467
|
+
return Array.isArray(t) ? e = t.map(
|
|
2440
2468
|
(s) => typeof s == "string" ? { placement: s } : s
|
|
2441
|
-
) : typeof
|
|
2442
|
-
},
|
|
2443
|
-
return this.placeData ? this.placeData.filter((e) => !(e.placement === "PAGE_BACKGROUND_WORKER" || !e.handler || e.handler.includes(
|
|
2469
|
+
) : typeof t == "string" ? e = [{ placement: t }] : e = [t], e;
|
|
2470
|
+
}, kt = new WeakSet(), re = function(t) {
|
|
2471
|
+
return this.placeData ? this.placeData.filter((e) => !(e.placement === "PAGE_BACKGROUND_WORKER" || !e.handler || e.handler.includes(t))) : [];
|
|
2444
2472
|
};
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2473
|
+
const se = "szdl-utils-kit|";
|
|
2474
|
+
function he() {
|
|
2475
|
+
if (typeof sessionStorage > "u")
|
|
2476
|
+
return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2477
|
+
let p = sessionStorage.getItem("szdl-cross-tab-instance-id");
|
|
2478
|
+
return p || (p = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", p)), p;
|
|
2479
|
+
}
|
|
2480
|
+
function ue() {
|
|
2481
|
+
return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
|
|
2482
|
+
}
|
|
2483
|
+
const Ct = /* @__PURE__ */ new Map();
|
|
2484
|
+
function fe(p = "default") {
|
|
2485
|
+
if (typeof BroadcastChannel > "u")
|
|
2486
|
+
return null;
|
|
2487
|
+
const t = `${se}bc:${p}`;
|
|
2488
|
+
return Ct.has(t) || Ct.set(t, new BroadcastChannel(t)), Ct.get(t);
|
|
2489
|
+
}
|
|
2490
|
+
function Xt(p, t) {
|
|
2491
|
+
const e = fe(p);
|
|
2492
|
+
if (e)
|
|
2493
|
+
try {
|
|
2494
|
+
const s = t && typeof t == "object" && !Array.isArray(t) ? t : { data: t };
|
|
2495
|
+
e.postMessage({
|
|
2496
|
+
...s,
|
|
2497
|
+
tabId: he(),
|
|
2498
|
+
ts: Date.now()
|
|
2499
|
+
});
|
|
2500
|
+
} catch {
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
async function me(p, t, e = {}) {
|
|
2504
|
+
const { ifAvailable: s = !1 } = e, i = typeof p == "string" && p.length > 0 ? p : "default", a = `${se}${i}`;
|
|
2505
|
+
return ue() ? navigator.locks.request(
|
|
2506
|
+
a,
|
|
2507
|
+
{ mode: "exclusive", ifAvailable: !!s },
|
|
2508
|
+
async (l) => {
|
|
2509
|
+
if (s && l == null)
|
|
2510
|
+
return { skipped: !0, coordination: "locks" };
|
|
2511
|
+
Xt(i, { type: "lock-acquired", resource: i });
|
|
2512
|
+
try {
|
|
2513
|
+
return { skipped: !1, result: await t(), coordination: "locks" };
|
|
2514
|
+
} finally {
|
|
2515
|
+
Xt(i, { type: "lock-released", resource: i });
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
) : { skipped: !1, result: await t(), coordination: "none" };
|
|
2519
|
+
}
|
|
2520
|
+
var mt, xt;
|
|
2521
|
+
class ye {
|
|
2522
|
+
constructor(t) {
|
|
2523
|
+
/**
|
|
2524
|
+
* Канонический base URL для placement (без завершающего `/`).
|
|
2525
|
+
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2526
|
+
*/
|
|
2527
|
+
D(this, mt);
|
|
2528
|
+
C(this, "entityName", "tabs");
|
|
2529
|
+
C(this, "maxTabs", 20);
|
|
2530
|
+
C(this, "tabList", []);
|
|
2531
|
+
C(this, "id", 0);
|
|
2532
|
+
C(this, "hasStarted", !1);
|
|
2533
|
+
C(this, "heartbeat");
|
|
2534
|
+
C(this, "runHeartbeat");
|
|
2535
|
+
/** Вкладка считается «мёртвой», если нет обновления lastActive дольше этого (см. refreshTabs). */
|
|
2536
|
+
C(this, "activeMaxPause", 10 * 1e3);
|
|
2537
|
+
C(this, "quickCleanupThreshold", 2 * 60 * 1e3);
|
|
2457
2538
|
// агрессивная очистка при переполнении
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2539
|
+
/** Должен быть заметно меньше activeMaxPause: иначе «живые» вкладки успеют удалиться до следующего тика. */
|
|
2540
|
+
C(this, "pollInterval", 6 * 1e3 + Math.floor(Math.random() * 2e3));
|
|
2541
|
+
// ~6–8 с + размазать одновременные запросы
|
|
2542
|
+
C(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
|
|
2543
|
+
C(this, "continueCondition");
|
|
2544
|
+
C(this, "defaultContinueBackground", () => !0);
|
|
2545
|
+
var l, A, h;
|
|
2546
|
+
if (!t) {
|
|
2465
2547
|
console.error("BackgroundWorker: Нет опций конструктора");
|
|
2466
2548
|
return;
|
|
2467
2549
|
}
|
|
2468
|
-
const { appFunc: e, bx: s, users:
|
|
2469
|
-
this.bx = s, this.appInit = e, this.users =
|
|
2550
|
+
const { appFunc: e, bx: s, users: i, continueBackground: a } = t;
|
|
2551
|
+
this.bx = s, this.appInit = e, this.users = i, Gt(s), this.appPath = E(this, mt, xt).call(this, ((l = s == null ? void 0 : s.appConst) == null ? void 0 : l.pathApp) ?? ""), this.appName = ((A = s == null ? void 0 : s.appConst) == null ? void 0 : A.appName) ?? "", this.appCodeName = ((h = s == null ? void 0 : s.appConst) == null ? void 0 : h.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
|
|
2470
2552
|
}
|
|
2471
2553
|
async init() {
|
|
2472
2554
|
if (!this.appInit) {
|
|
@@ -2498,30 +2580,30 @@ class ie {
|
|
|
2498
2580
|
}
|
|
2499
2581
|
await this.refreshTabs(!0), await this.ensureTabRegistered();
|
|
2500
2582
|
const e = this.selectLeaderId(), s = e && +this.id == +e;
|
|
2501
|
-
await this.updateTabState(s), s && !this.hasStarted &&
|
|
2583
|
+
await this.updateTabState(s), s && !this.hasStarted && await this.runAsLeader();
|
|
2502
2584
|
}
|
|
2503
2585
|
stopTimers() {
|
|
2504
2586
|
this.heartbeat && (clearInterval(this.heartbeat), this.heartbeat = void 0), this.runHeartbeat && (clearInterval(this.runHeartbeat), this.runHeartbeat = void 0);
|
|
2505
2587
|
}
|
|
2506
2588
|
isAppPage() {
|
|
2507
|
-
var
|
|
2508
|
-
if (typeof BX24 > "u" || !((
|
|
2589
|
+
var t;
|
|
2590
|
+
if (typeof BX24 > "u" || !((t = BX24.placement) != null && t.info))
|
|
2509
2591
|
return !1;
|
|
2510
2592
|
try {
|
|
2511
|
-
const e = BX24.placement.info(), s = e == null ? void 0 : e.placement,
|
|
2512
|
-
return !
|
|
2593
|
+
const e = BX24.placement.info(), s = e == null ? void 0 : e.placement, i = (e == null ? void 0 : e.options) || {}, a = (i == null ? void 0 : i.URI) || "", l = s === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", A = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
|
|
2594
|
+
return !l || A;
|
|
2513
2595
|
} catch {
|
|
2514
2596
|
return !1;
|
|
2515
2597
|
}
|
|
2516
2598
|
}
|
|
2517
2599
|
async checkEntity() {
|
|
2518
2600
|
var s;
|
|
2519
|
-
const
|
|
2601
|
+
const t = await this.safeCall(
|
|
2520
2602
|
() => this.bx.call({ method: "entity.get" })
|
|
2521
2603
|
);
|
|
2522
|
-
((s =
|
|
2523
|
-
|
|
2524
|
-
(
|
|
2604
|
+
((s = t == null ? void 0 : t.find) == null ? void 0 : s.call(
|
|
2605
|
+
t,
|
|
2606
|
+
(i) => i.ENTITY === this.entityName
|
|
2525
2607
|
)) || await this.safeCall(
|
|
2526
2608
|
() => this.bx.call({
|
|
2527
2609
|
method: "entity.add",
|
|
@@ -2534,7 +2616,7 @@ class ie {
|
|
|
2534
2616
|
);
|
|
2535
2617
|
}
|
|
2536
2618
|
async getTabs() {
|
|
2537
|
-
const
|
|
2619
|
+
const t = await this.safeCall(
|
|
2538
2620
|
() => {
|
|
2539
2621
|
var e;
|
|
2540
2622
|
return this.bx.call({
|
|
@@ -2547,7 +2629,7 @@ class ie {
|
|
|
2547
2629
|
});
|
|
2548
2630
|
}
|
|
2549
2631
|
);
|
|
2550
|
-
return !Array.isArray(
|
|
2632
|
+
return !Array.isArray(t) || !t.length ? [] : t.map((e) => {
|
|
2551
2633
|
if (!e)
|
|
2552
2634
|
return { id: void 0, data: void 0 };
|
|
2553
2635
|
try {
|
|
@@ -2565,7 +2647,7 @@ class ie {
|
|
|
2565
2647
|
return console.log(
|
|
2566
2648
|
"BackgroundWorker: Достигнут лимит вкладок даже после быстрой очистки, не регистрируемся"
|
|
2567
2649
|
), 0;
|
|
2568
|
-
const
|
|
2650
|
+
const t = {
|
|
2569
2651
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2570
2652
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2571
2653
|
start: !1,
|
|
@@ -2578,20 +2660,20 @@ class ie {
|
|
|
2578
2660
|
params: {
|
|
2579
2661
|
ENTITY: this.entityName,
|
|
2580
2662
|
NAME: (s = this.bx.userInfo) == null ? void 0 : s.ID,
|
|
2581
|
-
DETAIL_TEXT: JSON.stringify(
|
|
2663
|
+
DETAIL_TEXT: JSON.stringify(t)
|
|
2582
2664
|
}
|
|
2583
2665
|
});
|
|
2584
2666
|
}
|
|
2585
2667
|
) || 0;
|
|
2586
2668
|
return this.id = +e || 0, this.id;
|
|
2587
2669
|
}
|
|
2588
|
-
async updateTabState(
|
|
2670
|
+
async updateTabState(t) {
|
|
2589
2671
|
if (!this.id)
|
|
2590
2672
|
return;
|
|
2591
2673
|
const e = {
|
|
2592
2674
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2593
2675
|
createdAt: this.start.toISOString(),
|
|
2594
|
-
start:
|
|
2676
|
+
start: t,
|
|
2595
2677
|
sessionId: this.sessionId
|
|
2596
2678
|
};
|
|
2597
2679
|
await this.safeCall(
|
|
@@ -2609,21 +2691,17 @@ class ie {
|
|
|
2609
2691
|
}
|
|
2610
2692
|
);
|
|
2611
2693
|
}
|
|
2612
|
-
async deleteTabs(
|
|
2613
|
-
if (!
|
|
2694
|
+
async deleteTabs(t = []) {
|
|
2695
|
+
if (!t.length)
|
|
2614
2696
|
return;
|
|
2615
|
-
const e =
|
|
2697
|
+
const e = t.map((s) => ({
|
|
2616
2698
|
method: "entity.item.delete",
|
|
2617
2699
|
params: { ENTITY: this.entityName, ID: s.id }
|
|
2618
2700
|
}));
|
|
2619
2701
|
await this.safeCall(() => this.bx.batch(e));
|
|
2620
2702
|
}
|
|
2621
|
-
getRandomNum() {
|
|
2622
|
-
const r = Math.round(Number(Math.random().toFixed(2)) * 30);
|
|
2623
|
-
return Math.round(Math.random()) ? r : -r;
|
|
2624
|
-
}
|
|
2625
2703
|
async checkPlacementType() {
|
|
2626
|
-
var
|
|
2704
|
+
var t;
|
|
2627
2705
|
try {
|
|
2628
2706
|
const e = await this.safeCall(
|
|
2629
2707
|
() => this.bx.getPlacement()
|
|
@@ -2632,24 +2710,24 @@ class ie {
|
|
|
2632
2710
|
return console.log(
|
|
2633
2711
|
"BackgroundWorker: Не получили список размещений, продолжаем"
|
|
2634
2712
|
), !0;
|
|
2635
|
-
const s = +(((
|
|
2713
|
+
const s = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), i = this.isIndividualPlacement(
|
|
2636
2714
|
typeof window < "u" ? window.location.href : ""
|
|
2637
|
-
),
|
|
2715
|
+
), a = !i;
|
|
2638
2716
|
if (!s)
|
|
2639
2717
|
return !0;
|
|
2640
|
-
let
|
|
2718
|
+
let l = !1;
|
|
2641
2719
|
for (const A of e) {
|
|
2642
2720
|
if (A.placement !== "PAGE_BACKGROUND_WORKER" || !(A.userId || A.handler && A.handler.includes("USER_ID=")))
|
|
2643
2721
|
continue;
|
|
2644
|
-
const
|
|
2645
|
-
if (
|
|
2646
|
-
|
|
2722
|
+
const n = A.userId || (A.handler ? this.extractUserIdFromHandler(A.handler) : null);
|
|
2723
|
+
if (n && +n === s) {
|
|
2724
|
+
l = !0;
|
|
2647
2725
|
break;
|
|
2648
2726
|
}
|
|
2649
2727
|
}
|
|
2650
|
-
return
|
|
2728
|
+
return i ? (console.log(
|
|
2651
2729
|
"BackgroundWorker: Индивидуальная встройка - разрешено"
|
|
2652
|
-
), !0) :
|
|
2730
|
+
), !0) : a && l ? (console.log(
|
|
2653
2731
|
"BackgroundWorker: Есть личная встройка, общую не запускаем"
|
|
2654
2732
|
), !1) : (console.log(
|
|
2655
2733
|
"BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
|
|
@@ -2661,13 +2739,13 @@ class ie {
|
|
|
2661
2739
|
), !0;
|
|
2662
2740
|
}
|
|
2663
2741
|
}
|
|
2664
|
-
isIndividualPlacement(
|
|
2665
|
-
return !
|
|
2742
|
+
isIndividualPlacement(t) {
|
|
2743
|
+
return !t || typeof t != "string" ? !1 : t.includes("USER_ID=");
|
|
2666
2744
|
}
|
|
2667
|
-
extractUserIdFromHandler(
|
|
2668
|
-
if (!
|
|
2745
|
+
extractUserIdFromHandler(t) {
|
|
2746
|
+
if (!t || typeof t != "string")
|
|
2669
2747
|
return null;
|
|
2670
|
-
const e =
|
|
2748
|
+
const e = t.match(/USER_ID=(\d+)/);
|
|
2671
2749
|
return e ? +e[1] : null;
|
|
2672
2750
|
}
|
|
2673
2751
|
async continueBackground() {
|
|
@@ -2676,209 +2754,231 @@ class ie {
|
|
|
2676
2754
|
this.continueCondition(this)
|
|
2677
2755
|
);
|
|
2678
2756
|
return console.log(e ? "BackgroundWorker: Условие продолжения выполнено" : "BackgroundWorker: continueBackground вернул false"), e;
|
|
2679
|
-
} catch (
|
|
2757
|
+
} catch (t) {
|
|
2680
2758
|
return console.error(
|
|
2681
2759
|
"BackgroundWorker: Ошибка в continueCondition",
|
|
2682
|
-
|
|
2760
|
+
t
|
|
2683
2761
|
), !1;
|
|
2684
2762
|
}
|
|
2685
2763
|
}
|
|
2686
|
-
async refreshTabs(
|
|
2687
|
-
const s = [],
|
|
2688
|
-
for (const A of
|
|
2764
|
+
async refreshTabs(t = !1, e = this.activeMaxPause) {
|
|
2765
|
+
const s = [], i = [], a = Date.now(), l = await this.getTabs();
|
|
2766
|
+
for (const A of l) {
|
|
2689
2767
|
if (!(A != null && A.data)) {
|
|
2690
2768
|
s.push(A);
|
|
2691
2769
|
continue;
|
|
2692
2770
|
}
|
|
2693
|
-
if (
|
|
2771
|
+
if (a - new Date(A.data.lastActive || 0).getTime() > e) {
|
|
2694
2772
|
s.push(A);
|
|
2695
2773
|
continue;
|
|
2696
2774
|
}
|
|
2697
|
-
|
|
2775
|
+
i.push(A);
|
|
2698
2776
|
}
|
|
2699
|
-
return
|
|
2777
|
+
return t && s.length && await this.deleteTabs(s), this.tabList = i, i;
|
|
2700
2778
|
}
|
|
2701
2779
|
selectLeaderId() {
|
|
2702
2780
|
var e;
|
|
2703
|
-
return this.tabList.length && +((e = [...this.tabList].sort((s,
|
|
2704
|
-
var A,
|
|
2705
|
-
const
|
|
2706
|
-
((A = s.data) == null ? void 0 : A.createdAt) || ((
|
|
2707
|
-
).getTime(),
|
|
2708
|
-
((
|
|
2781
|
+
return this.tabList.length && +((e = [...this.tabList].sort((s, i) => {
|
|
2782
|
+
var A, h, n, u;
|
|
2783
|
+
const a = new Date(
|
|
2784
|
+
((A = s.data) == null ? void 0 : A.createdAt) || ((h = s.data) == null ? void 0 : h.lastActive) || 0
|
|
2785
|
+
).getTime(), l = new Date(
|
|
2786
|
+
((n = i.data) == null ? void 0 : n.createdAt) || ((u = i.data) == null ? void 0 : u.lastActive) || 0
|
|
2709
2787
|
).getTime();
|
|
2710
|
-
return
|
|
2788
|
+
return a === l ? (+s.id || 0) - (+i.id || 0) : a - l;
|
|
2711
2789
|
})[0]) == null ? void 0 : e.id) || 0;
|
|
2712
2790
|
}
|
|
2713
2791
|
async runAsLeader() {
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2792
|
+
var i, a;
|
|
2793
|
+
const t = String(((a = (i = this.bx) == null ? void 0 : i.userInfo) == null ? void 0 : a.ID) ?? "0"), e = `background-worker:${this.entityName}:${t}`;
|
|
2794
|
+
(await me(
|
|
2795
|
+
e,
|
|
2796
|
+
async () => {
|
|
2797
|
+
this.hasStarted = !0;
|
|
2798
|
+
const l = Math.min(
|
|
2799
|
+
this.activeMaxPause - 1500,
|
|
2800
|
+
Math.max(2500, Math.floor(this.pollInterval / 2))
|
|
2721
2801
|
);
|
|
2802
|
+
this.runHeartbeat = setInterval(
|
|
2803
|
+
() => {
|
|
2804
|
+
this.updateTabState(!0).catch(
|
|
2805
|
+
(A) => console.error(
|
|
2806
|
+
"BackgroundWorker: heartbeat update failed",
|
|
2807
|
+
A
|
|
2808
|
+
)
|
|
2809
|
+
);
|
|
2810
|
+
},
|
|
2811
|
+
l
|
|
2812
|
+
);
|
|
2813
|
+
try {
|
|
2814
|
+
await this.appInit();
|
|
2815
|
+
} catch (A) {
|
|
2816
|
+
console.error("BackgroundWorker: appInit failed", A);
|
|
2817
|
+
}
|
|
2818
|
+
this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
2722
2819
|
},
|
|
2723
|
-
|
|
2820
|
+
{ ifAvailable: !0 }
|
|
2821
|
+
)).skipped && console.log(
|
|
2822
|
+
"BackgroundWorker: runAsLeader пропущен — Web Lock у другой вкладки (тот же фоновый воркер)"
|
|
2724
2823
|
);
|
|
2725
|
-
try {
|
|
2726
|
-
await this.appInit();
|
|
2727
|
-
} catch (r) {
|
|
2728
|
-
console.error("BackgroundWorker: appInit failed", r);
|
|
2729
|
-
}
|
|
2730
|
-
this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
2731
2824
|
}
|
|
2732
2825
|
async setBackgroundWorkerAll() {
|
|
2733
|
-
var
|
|
2734
|
-
if (!((
|
|
2826
|
+
var T, _, R, N;
|
|
2827
|
+
if (!((T = this.bx) != null && T.isAdmin)) {
|
|
2735
2828
|
console.log(
|
|
2736
2829
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2737
2830
|
);
|
|
2738
2831
|
return;
|
|
2739
2832
|
}
|
|
2740
|
-
(_ = this.users) != null && _.length || await this.getEntityData();
|
|
2741
|
-
const
|
|
2833
|
+
(_ = this.users) != null && _.length || await this.getEntityData(), Gt(this.bx);
|
|
2834
|
+
const t = E(this, mt, xt).call(this, ((N = (R = this.bx) == null ? void 0 : R.appConst) == null ? void 0 : N.pathApp) ?? "");
|
|
2835
|
+
if (!t) {
|
|
2836
|
+
console.error(
|
|
2837
|
+
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
2838
|
+
);
|
|
2839
|
+
return;
|
|
2840
|
+
}
|
|
2841
|
+
const e = await this.safeCall(
|
|
2742
2842
|
() => this.bx.getPlacement()
|
|
2743
|
-
),
|
|
2744
|
-
let
|
|
2745
|
-
(
|
|
2746
|
-
if (
|
|
2843
|
+
), s = /* @__PURE__ */ new Map();
|
|
2844
|
+
let i = null;
|
|
2845
|
+
(e || []).forEach((y) => {
|
|
2846
|
+
if (y.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2747
2847
|
return;
|
|
2748
|
-
if (
|
|
2749
|
-
const
|
|
2750
|
-
|
|
2848
|
+
if (y.userId || y.handler && y.handler.includes("USER_ID=")) {
|
|
2849
|
+
const I = y.userId || (y.handler ? this.extractUserIdFromHandler(y.handler) : null);
|
|
2850
|
+
I && s.set(+I, y);
|
|
2751
2851
|
} else
|
|
2752
|
-
|
|
2852
|
+
i = y;
|
|
2753
2853
|
});
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
const
|
|
2757
|
-
return (
|
|
2854
|
+
const a = await this.resolveAdmins(), l = await this.getEligibleUsersForBackgroundWorker(a);
|
|
2855
|
+
l.sort((y, L) => {
|
|
2856
|
+
const I = y.LAST_LOGIN ? new Date(y.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2857
|
+
return (L.LAST_LOGIN ? new Date(L.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
|
|
2758
2858
|
});
|
|
2759
|
-
const
|
|
2760
|
-
const
|
|
2761
|
-
if (!
|
|
2859
|
+
const A = 10, h = l.slice(0, A), n = h.filter((y) => {
|
|
2860
|
+
const L = s.get(+y.ID);
|
|
2861
|
+
if (!L)
|
|
2762
2862
|
return !0;
|
|
2763
|
-
const
|
|
2764
|
-
return
|
|
2765
|
-
}),
|
|
2766
|
-
for (const [
|
|
2767
|
-
const
|
|
2768
|
-
|
|
2863
|
+
const I = `${t}?USER_ID=${y.ID}/`;
|
|
2864
|
+
return L.handler !== I;
|
|
2865
|
+
}), u = [];
|
|
2866
|
+
for (const [y] of s) {
|
|
2867
|
+
const L = +y || 0;
|
|
2868
|
+
l.find((H) => +H.ID === L) || u.push(L);
|
|
2769
2869
|
}
|
|
2770
|
-
for (const
|
|
2771
|
-
const
|
|
2772
|
-
if (!
|
|
2870
|
+
for (const y of h) {
|
|
2871
|
+
const L = s.get(+y.ID);
|
|
2872
|
+
if (!L)
|
|
2773
2873
|
continue;
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2874
|
+
const I = `${t}?USER_ID=${y.ID}/`;
|
|
2875
|
+
L.handler !== I && u.push(+y.ID);
|
|
2776
2876
|
}
|
|
2777
|
-
const
|
|
2778
|
-
for (const
|
|
2779
|
-
|
|
2877
|
+
const m = [];
|
|
2878
|
+
for (const y of u)
|
|
2879
|
+
m.push({
|
|
2780
2880
|
method: "placement.unbind",
|
|
2781
2881
|
params: {
|
|
2782
2882
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2783
|
-
HANDLER: `${
|
|
2883
|
+
HANDLER: `${t}?USER_ID=${y}/`
|
|
2784
2884
|
}
|
|
2785
2885
|
});
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2886
|
+
const c = i && (n.length > 0 || i.handler !== `${t}`);
|
|
2887
|
+
c && m.push({
|
|
2788
2888
|
method: "placement.unbind",
|
|
2789
2889
|
params: {
|
|
2790
2890
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2791
|
-
HANDLER:
|
|
2891
|
+
HANDLER: i.handler || `${t}`
|
|
2792
2892
|
}
|
|
2793
2893
|
});
|
|
2794
|
-
for (const
|
|
2795
|
-
|
|
2894
|
+
for (const y of n)
|
|
2895
|
+
m.push({
|
|
2796
2896
|
method: "placement.bind",
|
|
2797
2897
|
params: {
|
|
2798
2898
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2799
|
-
HANDLER: `${
|
|
2899
|
+
HANDLER: `${t}?USER_ID=${y.ID}/`,
|
|
2800
2900
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2801
2901
|
OPTIONS: {
|
|
2802
|
-
errorHandlerUrl: `${
|
|
2902
|
+
errorHandlerUrl: `${t}?USER_ID=${y.ID}/`
|
|
2803
2903
|
},
|
|
2804
|
-
USER_ID:
|
|
2904
|
+
USER_ID: y.ID
|
|
2805
2905
|
}
|
|
2806
2906
|
});
|
|
2807
|
-
(!
|
|
2907
|
+
(!i || c) && m.push({
|
|
2808
2908
|
method: "placement.bind",
|
|
2809
2909
|
params: {
|
|
2810
2910
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2811
|
-
HANDLER: `${
|
|
2911
|
+
HANDLER: `${t}`,
|
|
2812
2912
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2813
|
-
OPTIONS: { errorHandlerUrl: `${
|
|
2913
|
+
OPTIONS: { errorHandlerUrl: `${t}` }
|
|
2814
2914
|
}
|
|
2815
2915
|
});
|
|
2816
|
-
const
|
|
2817
|
-
(
|
|
2818
|
-
),
|
|
2819
|
-
(
|
|
2916
|
+
const f = m.filter(
|
|
2917
|
+
(y) => y.method === "placement.unbind"
|
|
2918
|
+
), O = m.filter(
|
|
2919
|
+
(y) => y.method === "placement.bind"
|
|
2820
2920
|
);
|
|
2821
|
-
|
|
2921
|
+
f.length && await this.safeCall(
|
|
2822
2922
|
() => this.bx.batch(
|
|
2823
2923
|
Object.fromEntries(
|
|
2824
|
-
|
|
2924
|
+
f.map((y, L) => [`unbind_${L}`, y])
|
|
2825
2925
|
)
|
|
2826
2926
|
)
|
|
2827
|
-
),
|
|
2927
|
+
), O.length && await this.safeCall(
|
|
2828
2928
|
() => this.bx.batch(
|
|
2829
2929
|
Object.fromEntries(
|
|
2830
|
-
|
|
2930
|
+
O.map((y, L) => [`bind_${L}`, y])
|
|
2831
2931
|
)
|
|
2832
2932
|
)
|
|
2833
|
-
),
|
|
2933
|
+
), m.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
2834
2934
|
}
|
|
2835
2935
|
async resolveAdmins() {
|
|
2836
|
-
var
|
|
2936
|
+
var t, e;
|
|
2837
2937
|
try {
|
|
2838
|
-
const s = +(((
|
|
2839
|
-
if (!
|
|
2840
|
-
if (s &&
|
|
2841
|
-
const
|
|
2842
|
-
(
|
|
2938
|
+
const s = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), i = !!((e = this.bx) != null && e.isAdmin), a = await this.getAdminsList() || [];
|
|
2939
|
+
if (!i) {
|
|
2940
|
+
if (s && a.includes(+s)) {
|
|
2941
|
+
const h = a.filter(
|
|
2942
|
+
(n) => +n != +s
|
|
2843
2943
|
);
|
|
2844
|
-
return await this.saveAdminsList(
|
|
2944
|
+
return await this.saveAdminsList(h), h;
|
|
2845
2945
|
}
|
|
2846
|
-
return
|
|
2946
|
+
return a;
|
|
2847
2947
|
}
|
|
2848
|
-
const
|
|
2849
|
-
s &&
|
|
2850
|
-
const A = [...
|
|
2948
|
+
const l = /* @__PURE__ */ new Set([...a || []]);
|
|
2949
|
+
s && l.add(+s);
|
|
2950
|
+
const A = [...l].filter(Boolean);
|
|
2851
2951
|
return await this.saveAdminsList(A), A;
|
|
2852
2952
|
} catch (s) {
|
|
2853
2953
|
return console.error("BackgroundWorker: resolveAdmins error", s), [];
|
|
2854
2954
|
}
|
|
2855
2955
|
}
|
|
2856
|
-
async getEligibleUsersForBackgroundWorker(
|
|
2956
|
+
async getEligibleUsersForBackgroundWorker(t = []) {
|
|
2857
2957
|
const e = (this.users ?? []).filter(
|
|
2858
|
-
(
|
|
2859
|
-
), s =
|
|
2860
|
-
return e.filter((
|
|
2958
|
+
(i) => i.ACTIVE === "Y" || i.ACTIVE === !0
|
|
2959
|
+
), s = t.map((i) => +i || 0).filter(Boolean);
|
|
2960
|
+
return e.filter((i) => s.includes(+i.ID || 0));
|
|
2861
2961
|
}
|
|
2862
|
-
async saveAdminsList(
|
|
2962
|
+
async saveAdminsList(t = []) {
|
|
2863
2963
|
try {
|
|
2864
|
-
BX24.appOption.set("adminsList", JSON.stringify(
|
|
2964
|
+
BX24.appOption.set("adminsList", JSON.stringify(t));
|
|
2865
2965
|
} catch (e) {
|
|
2866
2966
|
console.error("BackgroundWorker: saveAdminsList error", e);
|
|
2867
2967
|
}
|
|
2868
2968
|
}
|
|
2869
2969
|
async getAdminsList() {
|
|
2870
2970
|
try {
|
|
2871
|
-
const
|
|
2971
|
+
const t = BX24.appOption.get("adminsList"), e = t ? JSON.parse(t) : [];
|
|
2872
2972
|
return Array.isArray(e) ? e.map((s) => +s || 0).filter(Boolean) : [];
|
|
2873
|
-
} catch (
|
|
2874
|
-
return console.error("BackgroundWorker: getAdminsList error",
|
|
2973
|
+
} catch (t) {
|
|
2974
|
+
return console.error("BackgroundWorker: getAdminsList error", t), [];
|
|
2875
2975
|
}
|
|
2876
2976
|
}
|
|
2877
2977
|
async getEntityData() {
|
|
2878
|
-
const
|
|
2978
|
+
const t = {
|
|
2879
2979
|
users: { method: "user.get", params: { filter: { ACTIVE: "Y" } } }
|
|
2880
2980
|
}, { users: e } = await this.safeCall(
|
|
2881
|
-
() => this.bx.batch(
|
|
2981
|
+
() => this.bx.batch(t).then((s) => s ? (Array.isArray(s.users) || (s.users = []), s) : { users: [] })
|
|
2882
2982
|
);
|
|
2883
2983
|
this.users = e;
|
|
2884
2984
|
}
|
|
@@ -2887,30 +2987,38 @@ class ie {
|
|
|
2887
2987
|
* (общая и индивидуальные) и что список пользователей подгружен.
|
|
2888
2988
|
*/
|
|
2889
2989
|
async ensureAdminPlacements() {
|
|
2890
|
-
var
|
|
2891
|
-
(
|
|
2990
|
+
var t, e;
|
|
2991
|
+
(t = this.bx) != null && t.isAdmin && ((e = this.users) != null && e.length || await this.getEntityData(), await this.setBackgroundWorkerAll());
|
|
2892
2992
|
}
|
|
2893
|
-
pause(
|
|
2993
|
+
pause(t = 500, e) {
|
|
2894
2994
|
return new Promise((s) => {
|
|
2895
2995
|
setTimeout(() => {
|
|
2896
2996
|
e && e(), s(!0);
|
|
2897
|
-
},
|
|
2997
|
+
}, t);
|
|
2898
2998
|
});
|
|
2899
2999
|
}
|
|
2900
|
-
async safeCall(
|
|
3000
|
+
async safeCall(t) {
|
|
2901
3001
|
try {
|
|
2902
|
-
return await
|
|
3002
|
+
return await t();
|
|
2903
3003
|
} catch (e) {
|
|
2904
3004
|
console.error("BackgroundWorker: safeCall error", e);
|
|
2905
3005
|
return;
|
|
2906
3006
|
}
|
|
2907
3007
|
}
|
|
2908
3008
|
}
|
|
3009
|
+
mt = new WeakSet(), xt = function(t) {
|
|
3010
|
+
if (!t || typeof t != "string")
|
|
3011
|
+
return "";
|
|
3012
|
+
const e = Ft(t).replace(/\/+$/, "");
|
|
3013
|
+
return e ? $t(e) ? (console.error(
|
|
3014
|
+
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3015
|
+
), "") : e : "";
|
|
3016
|
+
};
|
|
2909
3017
|
export {
|
|
2910
|
-
|
|
3018
|
+
ye as BackgroundWorker,
|
|
2911
3019
|
v as Batch,
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
3020
|
+
ge as BxBoot,
|
|
3021
|
+
zt as BxHelper,
|
|
3022
|
+
ce as BxLogger,
|
|
3023
|
+
dt as tempus
|
|
2916
3024
|
};
|