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