szdl-utils-kit 0.3.23 → 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 +1043 -1023
- package/dist/index.umd.cjs +2 -2
- package/dist/types/background-worker.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
if (!e.has(
|
|
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
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (e.has(
|
|
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
|
-
e instanceof WeakSet ? e.add(
|
|
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(
|
|
17
|
+
var qt = { exports: {} };
|
|
18
|
+
(function(g, e) {
|
|
19
19
|
(function(t) {
|
|
20
|
-
Array.prototype.indexOf || (Array.prototype.indexOf = function(
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
20
|
+
Array.prototype.indexOf || (Array.prototype.indexOf = function(r, o) {
|
|
21
|
+
var m, p;
|
|
22
|
+
for (m = o || 0, p = this.length; m < p; m += 1)
|
|
23
|
+
if (this[m] === r)
|
|
24
|
+
return m;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
|
-
var
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
}, a = function(
|
|
32
|
-
return o !== t ? (
|
|
33
|
-
}, c = function(
|
|
34
|
-
var
|
|
35
|
-
return
|
|
36
|
-
},
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
var s = this, i = function(r, o) {
|
|
28
|
+
for (var m = r.toString(); m.length < o; )
|
|
29
|
+
m = "0" + m;
|
|
30
|
+
return m;
|
|
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
43
|
], C;
|
|
44
|
-
return !isNaN(Number(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
], !isNaN(Number(C[0])) && !isNaN(Number(C[2])) && !isNaN(Number(C[4])) ? (C[1] === "-" && C[3] === "-" && (
|
|
51
|
-
},
|
|
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,69 +209,69 @@ var Jt = { 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(
|
|
273
|
+
parse: function(r) {
|
|
274
|
+
var o = Number(r);
|
|
275
275
|
return { day: isNaN(o) ? t : o };
|
|
276
276
|
},
|
|
277
277
|
minLength: 2,
|
|
@@ -279,11 +279,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
279
279
|
type: "number"
|
|
280
280
|
},
|
|
281
281
|
"%m": {
|
|
282
|
-
format: function(
|
|
283
|
-
return i(
|
|
282
|
+
format: function(r) {
|
|
283
|
+
return i(r.month() || n.MIN_MONTH, 2);
|
|
284
284
|
},
|
|
285
|
-
parse: function(
|
|
286
|
-
var o = Number(
|
|
285
|
+
parse: function(r) {
|
|
286
|
+
var o = Number(r);
|
|
287
287
|
return { month: isNaN(o) ? t : o };
|
|
288
288
|
},
|
|
289
289
|
minLength: 2,
|
|
@@ -291,11 +291,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
291
291
|
type: "number"
|
|
292
292
|
},
|
|
293
293
|
"%Y": {
|
|
294
|
-
format: function(
|
|
295
|
-
return i(
|
|
294
|
+
format: function(r) {
|
|
295
|
+
return i(r.year() || n.MIN_YEAR, 4);
|
|
296
296
|
},
|
|
297
|
-
parse: function(
|
|
298
|
-
var o = Number(
|
|
297
|
+
parse: function(r) {
|
|
298
|
+
var o = Number(r);
|
|
299
299
|
return { year: isNaN(o) ? t : o };
|
|
300
300
|
},
|
|
301
301
|
minLength: 4,
|
|
@@ -303,8 +303,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
303
303
|
type: "number"
|
|
304
304
|
},
|
|
305
305
|
"%w": {
|
|
306
|
-
format: function(
|
|
307
|
-
return
|
|
306
|
+
format: function(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,8 +326,8 @@ 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 =
|
|
329
|
+
format: function(r) {
|
|
330
|
+
var o = r.dayOfWeek();
|
|
331
331
|
return H[o !== t ? o : n.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
@@ -338,12 +338,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
338
338
|
type: "word"
|
|
339
339
|
},
|
|
340
340
|
"%b": {
|
|
341
|
-
format: function(
|
|
342
|
-
var o = n.options("monthFromZero") ?
|
|
341
|
+
format: function(r) {
|
|
342
|
+
var o = n.options("monthFromZero") ? r.month() : r.month() - 1;
|
|
343
343
|
return b[o !== t ? o : n.MIN_MONTH];
|
|
344
344
|
},
|
|
345
|
-
parse: function(
|
|
346
|
-
var o = n.monthNames().indexOf(
|
|
345
|
+
parse: function(r) {
|
|
346
|
+
var o = n.monthNames().indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
|
|
347
347
|
return { month: o !== -1 ? o : t };
|
|
348
348
|
},
|
|
349
349
|
minLength: 1,
|
|
@@ -351,12 +351,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
351
351
|
type: "word"
|
|
352
352
|
},
|
|
353
353
|
"%B": {
|
|
354
|
-
format: function(
|
|
355
|
-
var o = n.options("monthFromZero") ?
|
|
356
|
-
return
|
|
354
|
+
format: function(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(
|
|
358
|
+
parse: function(r) {
|
|
359
|
+
var o = n.monthNames(!0).indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
|
|
360
360
|
return { month: o !== -1 ? o : t };
|
|
361
361
|
},
|
|
362
362
|
minLength: 1,
|
|
@@ -364,11 +364,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
364
364
|
type: "word"
|
|
365
365
|
},
|
|
366
366
|
"%H": {
|
|
367
|
-
format: function(
|
|
368
|
-
return i(
|
|
367
|
+
format: function(r) {
|
|
368
|
+
return i(r.hours() || n.MIN_HOURS, 2);
|
|
369
369
|
},
|
|
370
|
-
parse: function(
|
|
371
|
-
var o = Number(
|
|
370
|
+
parse: function(r) {
|
|
371
|
+
var o = Number(r);
|
|
372
372
|
return { hours: isNaN(o) ? t : o };
|
|
373
373
|
},
|
|
374
374
|
minLength: 2,
|
|
@@ -376,11 +376,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
376
376
|
type: "number"
|
|
377
377
|
},
|
|
378
378
|
"%M": {
|
|
379
|
-
format: function(
|
|
380
|
-
return i(
|
|
379
|
+
format: function(r) {
|
|
380
|
+
return i(r.minutes() || n.MIN_MINUTES, 2);
|
|
381
381
|
},
|
|
382
|
-
parse: function(
|
|
383
|
-
var o = Number(
|
|
382
|
+
parse: function(r) {
|
|
383
|
+
var o = Number(r);
|
|
384
384
|
return { minutes: isNaN(o) ? t : o };
|
|
385
385
|
},
|
|
386
386
|
minLength: 2,
|
|
@@ -388,11 +388,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
388
388
|
type: "number"
|
|
389
389
|
},
|
|
390
390
|
"%S": {
|
|
391
|
-
format: function(
|
|
392
|
-
return i(
|
|
391
|
+
format: function(r) {
|
|
392
|
+
return i(r.seconds() || n.MIN_SECONDS, 2);
|
|
393
393
|
},
|
|
394
|
-
parse: function(
|
|
395
|
-
var o = Number(
|
|
394
|
+
parse: function(r) {
|
|
395
|
+
var o = Number(r);
|
|
396
396
|
return { seconds: isNaN(o) ? t : o };
|
|
397
397
|
},
|
|
398
398
|
minLength: 2,
|
|
@@ -400,26 +400,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
400
400
|
type: "number"
|
|
401
401
|
},
|
|
402
402
|
"%s": {
|
|
403
|
-
format: function(
|
|
404
|
-
return
|
|
403
|
+
format: function(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
|
-
month:
|
|
422
|
-
day:
|
|
421
|
+
month: m,
|
|
422
|
+
day: p
|
|
423
423
|
};
|
|
424
424
|
},
|
|
425
425
|
minLength: 10,
|
|
@@ -427,26 +427,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
427
427
|
type: "string"
|
|
428
428
|
},
|
|
429
429
|
"%D": {
|
|
430
|
-
format: function(
|
|
431
|
-
return i(
|
|
430
|
+
format: function(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
|
-
day:
|
|
438
|
+
day: m
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
442
442
|
maxLength: 10,
|
|
443
443
|
type: "string"
|
|
444
444
|
}
|
|
445
|
-
},
|
|
445
|
+
}, B = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
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,
|
|
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 === t && (o = n.detectFormat(
|
|
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 (P = 0, X = "",
|
|
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 (; P <
|
|
540
|
-
X +=
|
|
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 (; P <
|
|
544
|
-
X +=
|
|
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 (; P <
|
|
548
|
-
X +=
|
|
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 (P <
|
|
552
|
-
return D = a(this,
|
|
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,
|
|
@@ -560,8 +560,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
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,
|
|
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,8 +572,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
572
572
|
}), D;
|
|
573
573
|
W += 1, F += 1;
|
|
574
574
|
}
|
|
575
|
-
for (
|
|
576
|
-
C.hasOwnProperty(
|
|
575
|
+
for (p in C)
|
|
576
|
+
C.hasOwnProperty(p) && R.hasOwnProperty(C[p]) && (Y = R[C[p]].parse(Q[p]), G = {
|
|
577
577
|
year: Y.year !== t ? Y.year : G.year,
|
|
578
578
|
month: Y.month !== t ? Y.month : G.month,
|
|
579
579
|
day: Y.day !== t ? Y.day : G.day,
|
|
@@ -585,35 +585,35 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
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 (
|
|
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
596
|
return H[this._d.getDay()];
|
|
597
|
-
if (
|
|
598
|
-
return
|
|
599
|
-
if (
|
|
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,73 +670,73 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
670
670
|
timestamp: this.timestamp()
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
}, k.fn.format = function(
|
|
674
|
-
for (var o = 0,
|
|
675
|
-
|
|
676
|
-
return
|
|
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
|
+
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
|
|
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
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 (
|
|
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
707
|
if (o === t)
|
|
708
|
-
return
|
|
709
|
-
|
|
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
711
|
return t;
|
|
712
712
|
}, n.noConflict = function() {
|
|
713
|
-
return
|
|
714
|
-
}, n.generate = function(
|
|
715
|
-
var o,
|
|
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
741
|
year: D.year ? -D.year : t,
|
|
742
742
|
month: D.month ? -D.month : t,
|
|
@@ -746,72 +746,72 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
|
|
|
746
746
|
seconds: D.seconds ? -D.seconds : t,
|
|
747
747
|
milliseconds: D.milliseconds ? -D.milliseconds : t
|
|
748
748
|
};
|
|
749
|
-
for (
|
|
750
|
-
W(U[U.length - 1],
|
|
751
|
-
if (
|
|
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
752
|
var P = n(o).dayOfWeek();
|
|
753
|
-
for (
|
|
754
|
-
W(U[U.length - 1],
|
|
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
|
-
for (; o <=
|
|
758
|
-
|
|
759
|
-
if (
|
|
760
|
-
for (C = n(
|
|
757
|
+
for (; o <= m; )
|
|
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
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
768
|
return b;
|
|
769
769
|
}
|
|
770
|
-
}, n.dayNames = function(
|
|
771
|
-
switch (
|
|
770
|
+
}, n.dayNames = function(r) {
|
|
771
|
+
switch (r) {
|
|
772
772
|
case "long":
|
|
773
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
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
|
-
parse:
|
|
789
|
-
minLength:
|
|
788
|
+
parse: m,
|
|
789
|
+
minLength: p,
|
|
790
790
|
maxLength: C,
|
|
791
791
|
type: D
|
|
792
792
|
};
|
|
793
|
-
}, n.unregisterFormat = function(
|
|
794
|
-
delete
|
|
795
|
-
}, n.detectFormat = function(
|
|
796
|
-
var o,
|
|
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(
|
|
800
|
+
}, n.classes = function(r, o) {
|
|
801
801
|
if (o === t)
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
}, n.loadTranslations = function(
|
|
805
|
-
typeof
|
|
806
|
-
|
|
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 = (
|
|
810
|
-
}).call(
|
|
811
|
-
})(
|
|
812
|
-
var
|
|
813
|
-
const
|
|
814
|
-
var
|
|
809
|
+
}, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), l[A] === t && (A = "en"), 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
815
|
const J = class J {
|
|
816
816
|
constructor(e) {
|
|
817
817
|
/**
|
|
@@ -820,25 +820,25 @@ const J = class J {
|
|
|
820
820
|
* формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
|
|
821
821
|
* @returns {boolean}
|
|
822
822
|
*/
|
|
823
|
-
|
|
823
|
+
L(this, Lt);
|
|
824
824
|
/**
|
|
825
825
|
* Одно обновление колбэка прогресса, если снимок изменился.
|
|
826
826
|
* @returns {void}
|
|
827
827
|
*/
|
|
828
|
-
|
|
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
|
-
|
|
835
|
+
L(this, Dt);
|
|
836
836
|
/**
|
|
837
837
|
* Уведомляет подписчиков о текущем состоянии лимита.
|
|
838
838
|
*
|
|
839
839
|
* @returns {void}
|
|
840
840
|
*/
|
|
841
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
866
|
+
L(this, et);
|
|
867
867
|
/**
|
|
868
868
|
* Выполняет BX24.callMethod с таймаутом ожидания ответа.
|
|
869
869
|
*
|
|
@@ -871,13 +871,13 @@ const J = class J {
|
|
|
871
871
|
* @param {Object} params - Параметры REST-метода.
|
|
872
872
|
* @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
|
|
873
873
|
*/
|
|
874
|
-
|
|
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
|
-
|
|
880
|
+
L(this, mt);
|
|
881
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,
|
|
@@ -892,31 +892,31 @@ const J = class J {
|
|
|
892
892
|
if (!this.progressData)
|
|
893
893
|
return { percent: 0, allCount: 0, allTotal: 0 };
|
|
894
894
|
const e = this.totalBatchCommands || 0;
|
|
895
|
-
if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length &&
|
|
896
|
-
let
|
|
897
|
-
for (const
|
|
898
|
-
const
|
|
899
|
-
if (!
|
|
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
|
|
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 t = 0,
|
|
910
|
-
for (const
|
|
911
|
-
const { total: n, count:
|
|
912
|
-
t += n ?? 0,
|
|
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
|
-
t ? a =
|
|
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 t > 0 &&
|
|
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,8 +925,8 @@ const J = class J {
|
|
|
925
925
|
* @param {Object} params.value - Значение ответа от API
|
|
926
926
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
927
927
|
*/
|
|
928
|
-
setProgressData({ key: e, value: t, type:
|
|
929
|
-
var
|
|
928
|
+
setProgressData({ key: e, value: t, type: s }) {
|
|
929
|
+
var l, _;
|
|
930
930
|
if (!this.progressCall)
|
|
931
931
|
return;
|
|
932
932
|
const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
|
|
@@ -938,22 +938,22 @@ const J = class J {
|
|
|
938
938
|
Number.isFinite(E) && (c = E);
|
|
939
939
|
}
|
|
940
940
|
}
|
|
941
|
-
let
|
|
942
|
-
|
|
943
|
-
const
|
|
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
944
|
if (this.progressData[e] = {
|
|
945
|
-
total:
|
|
946
|
-
count: Math.min(
|
|
945
|
+
total: d,
|
|
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));
|
|
@@ -977,8 +977,8 @@ const J = class J {
|
|
|
977
977
|
* @param {number|undefined} pauseMs - Длительность текущей лимит-паузы (мс); при снятии лимита не передаётся.
|
|
978
978
|
* @returns {void}
|
|
979
979
|
*/
|
|
980
|
-
setTimeLimitState(e, t,
|
|
981
|
-
this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof
|
|
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
|
* Подписывает внешний код на изменения состояния лимита.
|
|
@@ -1005,26 +1005,26 @@ const J = class J {
|
|
|
1005
1005
|
* @returns {Array} Массив запросов (может быть один или несколько)
|
|
1006
1006
|
*/
|
|
1007
1007
|
splitLargeFilters(e, t) {
|
|
1008
|
-
const { method:
|
|
1008
|
+
const { method: s, params: i } = t;
|
|
1009
1009
|
if (!i)
|
|
1010
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
1013
|
return [{ key: e, request: t }];
|
|
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] =
|
|
1020
|
-
key:
|
|
1021
|
-
request: { method:
|
|
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
|
+
key: d,
|
|
1021
|
+
request: { method: s, params: A },
|
|
1022
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
1029
|
return [{ key: e, request: t }];
|
|
1030
1030
|
}
|
|
@@ -1035,15 +1035,15 @@ const J = class J {
|
|
|
1035
1035
|
* @returns {Array} Объединенный массив результатов
|
|
1036
1036
|
*/
|
|
1037
1037
|
mergeSplitResults(e, t) {
|
|
1038
|
-
const
|
|
1039
|
-
const n =
|
|
1040
|
-
return n ?
|
|
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
|
* Задержка между запросами
|
|
@@ -1061,25 +1061,25 @@ const J = class J {
|
|
|
1061
1061
|
* @returns {Promise<void>}
|
|
1062
1062
|
*/
|
|
1063
1063
|
callBatchWithTimeout(e, t) {
|
|
1064
|
-
return new Promise((
|
|
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(t(n)),
|
|
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(e).forEach((
|
|
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(t(n)),
|
|
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
1101
|
this.callBatch(e, async (n) => {
|
|
1102
|
-
await
|
|
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,57 +1129,57 @@ const J = class J {
|
|
|
1129
1129
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения.
|
|
1130
1130
|
* @returns {Promise<Object>}
|
|
1131
1131
|
*/
|
|
1132
|
-
async batch(e, t,
|
|
1133
|
-
|
|
1132
|
+
async batch(e, t, s = {}) {
|
|
1133
|
+
O(this, mt, zt).call(this, t);
|
|
1134
1134
|
const i = {}, a = {}, c = {};
|
|
1135
|
-
for (const [
|
|
1136
|
-
const A = this.arrayChunk(
|
|
1135
|
+
for (const [u, d] of Object.entries(e)) {
|
|
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
|
-
(
|
|
1150
|
-
var
|
|
1151
|
-
return String(((
|
|
1149
|
+
(u) => {
|
|
1150
|
+
var d;
|
|
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 [
|
|
1178
|
-
if (
|
|
1179
|
-
const A = this.mergeSplitResults(i,
|
|
1180
|
-
for (const
|
|
1181
|
-
delete i[
|
|
1182
|
-
i[
|
|
1177
|
+
for (const [u, d] of Object.entries(c))
|
|
1178
|
+
if (d && d.length > 0) {
|
|
1179
|
+
const A = this.mergeSplitResults(i, u);
|
|
1180
|
+
for (const l of d)
|
|
1181
|
+
delete i[l];
|
|
1182
|
+
i[u] = A;
|
|
1183
1183
|
}
|
|
1184
1184
|
return Object.entries(this.errors).length && (i.errorsList = this.errors), t && t({ percent: 100 }), Promise.resolve(i);
|
|
1185
1185
|
}
|
|
@@ -1193,61 +1193,61 @@ const J = class J {
|
|
|
1193
1193
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
1194
1194
|
*/
|
|
1195
1195
|
async batchTotalCount(e, t) {
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
for (const [
|
|
1199
|
-
const
|
|
1200
|
-
if (!
|
|
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
|
|
1203
|
-
if (
|
|
1204
|
-
i[
|
|
1202
|
+
const d = this.splitLargeFilters(f, u);
|
|
1203
|
+
if (d.length === 1)
|
|
1204
|
+
i[f] = u;
|
|
1205
1205
|
else {
|
|
1206
|
-
a[
|
|
1207
|
-
for (const A of
|
|
1208
|
-
i[A.key] = A.request, a[
|
|
1206
|
+
a[f] = [];
|
|
1207
|
+
for (const A of d)
|
|
1208
|
+
i[A.key] = A.request, a[f].push(A.key);
|
|
1209
1209
|
}
|
|
1210
1210
|
}
|
|
1211
|
-
const c = [],
|
|
1212
|
-
for (let
|
|
1213
|
-
const n =
|
|
1214
|
-
for (const [
|
|
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
|
+
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 [M,
|
|
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[M] =
|
|
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 b = this.getData(
|
|
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
|
|
1246
|
-
for (const
|
|
1247
|
-
|
|
1248
|
-
|
|
1245
|
+
let u = 0;
|
|
1246
|
+
for (const d of n)
|
|
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-вызов с таймаутом и авто-повтором после лимит-паузы.
|
|
@@ -1257,36 +1257,36 @@ const J = class J {
|
|
|
1257
1257
|
* @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
|
|
1258
1258
|
*/
|
|
1259
1259
|
async call({ method: e, params: t = {} }) {
|
|
1260
|
-
var
|
|
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
|
-
const
|
|
1268
|
-
if (
|
|
1269
|
-
for (const [
|
|
1270
|
-
|
|
1271
|
-
if (
|
|
1272
|
-
const
|
|
1273
|
-
if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(
|
|
1274
|
-
await
|
|
1267
|
+
const d = {};
|
|
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
|
-
answer:
|
|
1282
|
-
error:
|
|
1281
|
+
answer: d,
|
|
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,
|
|
1289
|
-
answer:
|
|
1289
|
+
answer: d,
|
|
1290
1290
|
error: null
|
|
1291
1291
|
};
|
|
1292
1292
|
}
|
|
@@ -1297,30 +1297,30 @@ const J = class J {
|
|
|
1297
1297
|
* @param {Array/Object} request - Массив/объект методов
|
|
1298
1298
|
*/
|
|
1299
1299
|
arrayChunk(e) {
|
|
1300
|
-
let t = "",
|
|
1301
|
-
if (Array.isArray(e) ? [t] = e : (t = e.method,
|
|
1302
|
-
if (!
|
|
1303
|
-
|
|
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
|
-
t === "entity.item.get" ? (
|
|
1308
|
-
const i = t === "user.get" || t === "entity.item.get" ?
|
|
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
|
-
t === "crm.type.list" &&
|
|
1313
|
+
t === "crm.type.list" && s.order && delete s.order.ID;
|
|
1314
1314
|
}
|
|
1315
1315
|
if (t === "task.item.list")
|
|
1316
|
-
if (!
|
|
1317
|
-
|
|
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: t, params:
|
|
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(e, t,
|
|
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 [M,
|
|
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[M] =
|
|
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 b = this.getData(
|
|
1347
|
-
t === "count" ? this.result[M] ? this.result[M] += H : this.result[M] =
|
|
1348
|
-
const
|
|
1349
|
-
if (!
|
|
1350
|
-
let
|
|
1351
|
-
if (Array.isArray(
|
|
1352
|
-
const [C, D = {}] =
|
|
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: C, params: D = {} } =
|
|
1356
|
-
|
|
1355
|
+
const { method: C, params: D = {} } = p;
|
|
1356
|
+
p = [C, D];
|
|
1357
1357
|
}
|
|
1358
1358
|
c.push([
|
|
1359
1359
|
M,
|
|
1360
|
-
|
|
1361
|
-
|
|
1360
|
+
p,
|
|
1361
|
+
S,
|
|
1362
1362
|
{ entityItemGetScan: o }
|
|
1363
1363
|
]);
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
|
-
|
|
1367
|
-
const
|
|
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,100 +1377,100 @@ const J = class J {
|
|
|
1377
1377
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1378
1378
|
* @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
|
|
1379
1379
|
*/
|
|
1380
|
-
async batchPayload(e, t,
|
|
1381
|
-
const i = !!(
|
|
1382
|
-
let
|
|
1383
|
-
this.result[
|
|
1384
|
-
let b = `${
|
|
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
1385
|
if (JSON.stringify(M[1]).toLocaleLowerCase().includes('"id":"desc"') ? b = "<" + b : b = ">" + b, T === 1 || E.length === 0)
|
|
1386
1386
|
return {
|
|
1387
1387
|
field: b,
|
|
1388
|
-
id: this.result[
|
|
1388
|
+
id: this.result[_][this.result[_].length - 1][N]
|
|
1389
1389
|
};
|
|
1390
|
-
let
|
|
1391
|
-
const [
|
|
1392
|
-
return (
|
|
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
1393
|
field: b,
|
|
1394
|
-
id: `$result[${[
|
|
1394
|
+
id: `$result[${[_, T - 1].join("__")}]${y}[49][${N}]`
|
|
1395
1395
|
};
|
|
1396
|
-
}, c = (
|
|
1397
|
-
const [E, M] =
|
|
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 [H,
|
|
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) ? b[">ID"] = T.id : b[T.field] = T.id, [E, { ...
|
|
1408
|
-
},
|
|
1409
|
-
Object.entries(
|
|
1410
|
-
var b, H,
|
|
1411
|
-
const [M] = T.split("__"),
|
|
1412
|
-
if (Array.isArray(
|
|
1413
|
-
const
|
|
1414
|
-
this.errors[M] =
|
|
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
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 =
|
|
1421
|
+
const E = _[_.length - 1];
|
|
1422
1422
|
let M = "ID";
|
|
1423
1423
|
E.ID || (M = "id");
|
|
1424
|
-
let
|
|
1425
|
-
return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ?
|
|
1426
|
-
}, n = 1e4,
|
|
1427
|
-
var M,
|
|
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
1429
|
for (let b = 1; this.canContinue && E === this.limit && b <= n; b++) {
|
|
1430
|
-
const H = this.result[
|
|
1431
|
-
if (!
|
|
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
1438
|
const k = b < n;
|
|
1439
|
-
await
|
|
1440
|
-
const
|
|
1441
|
-
if ((M =
|
|
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
|
-
let
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
}), A++,
|
|
1453
|
-
for await (const
|
|
1449
|
+
let d = [], A = 0;
|
|
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
|
+
}), A++, d = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
|
|
1453
|
+
for await (const _ of e) {
|
|
1454
1454
|
if (!this.canContinue)
|
|
1455
1455
|
return;
|
|
1456
|
-
const [T, E, M,
|
|
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
1465
|
let b = 1;
|
|
1466
1466
|
for (; M > b * this.limit; ) {
|
|
1467
|
-
const H = [T, b].join("__"),
|
|
1468
|
-
if (
|
|
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
|
* Вывод ошибок в консоль в группированном виде
|
|
@@ -1481,29 +1481,29 @@ const J = class J {
|
|
|
1481
1481
|
}), console.groupEnd();
|
|
1482
1482
|
}
|
|
1483
1483
|
};
|
|
1484
|
-
|
|
1484
|
+
Lt = new WeakSet(), ie = function() {
|
|
1485
1485
|
const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
|
|
1486
|
-
if (e <
|
|
1486
|
+
if (e < I(J, Rt) || !Array.isArray(t) || t.length !== e)
|
|
1487
1487
|
return !1;
|
|
1488
|
-
if (t.filter((a) => a === "crm.deal.list").length >=
|
|
1488
|
+
if (t.filter((a) => a === "crm.deal.list").length >= I(J, Mt))
|
|
1489
1489
|
return !0;
|
|
1490
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: e, allCount: t, allTotal:
|
|
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
1500
|
percent: e,
|
|
1501
1501
|
allCount: t,
|
|
1502
|
-
allTotal:
|
|
1502
|
+
allTotal: s
|
|
1503
1503
|
}), this.lastProgressSnapshot = i);
|
|
1504
|
-
},
|
|
1504
|
+
}, Dt = new WeakSet(), ne = function(e) {
|
|
1505
1505
|
return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== e.percent || this.lastProgressSnapshot.allCount !== e.allCount || this.lastProgressSnapshot.allTotal !== e.allTotal : !0;
|
|
1506
|
-
},
|
|
1506
|
+
}, kt = new WeakSet(), ae = function() {
|
|
1507
1507
|
const e = {
|
|
1508
1508
|
limit: this.timeLimit.limit,
|
|
1509
1509
|
date: this.timeLimit.date,
|
|
@@ -1512,15 +1512,15 @@ Et = new WeakSet(), ee = function() {
|
|
|
1512
1512
|
for (const t of this.timeLimitListeners)
|
|
1513
1513
|
try {
|
|
1514
1514
|
t(e);
|
|
1515
|
-
} catch (
|
|
1516
|
-
console.warn("Batch timeLimit listener error:",
|
|
1515
|
+
} catch (s) {
|
|
1516
|
+
console.warn("Batch timeLimit listener error:", s);
|
|
1517
1517
|
}
|
|
1518
|
-
}, Z = new WeakSet(),
|
|
1518
|
+
}, Z = new WeakSet(), at = async function(e = this.defaultPauseMs) {
|
|
1519
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(),
|
|
1520
|
+
}, tt = new WeakSet(), ut = async function(e, t = !0) {
|
|
1521
1521
|
if (!t)
|
|
1522
1522
|
return 0;
|
|
1523
|
-
let
|
|
1523
|
+
let s = 0;
|
|
1524
1524
|
if (!e || typeof e != "object")
|
|
1525
1525
|
return 0;
|
|
1526
1526
|
for (const i of Object.values(e))
|
|
@@ -1528,75 +1528,75 @@ Et = new WeakSet(), ee = function() {
|
|
|
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
|
-
}, et = new WeakSet(),
|
|
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 [
|
|
1544
|
-
if (!(
|
|
1542
|
+
const h = /* @__PURE__ */ new Set();
|
|
1543
|
+
for (const [u, d] of Object.entries(a || {})) {
|
|
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(
|
|
1562
|
-
const
|
|
1563
|
-
for (const A of
|
|
1564
|
-
i[A] && (
|
|
1565
|
-
i =
|
|
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
|
+
const d = {};
|
|
1563
|
+
for (const A of h)
|
|
1564
|
+
i[A] && (d[A] = i[A]);
|
|
1565
|
+
i = d, Object.keys(i).length && (s = !0, await O(this, Z, at).call(this));
|
|
1566
1566
|
return;
|
|
1567
1567
|
}
|
|
1568
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
1582
|
this.callMethod(e, t, (c) => {
|
|
1583
|
-
i || (i = !0, clearTimeout(a),
|
|
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
|
-
},
|
|
1589
|
+
}, mt = new WeakSet(), zt = function(e) {
|
|
1590
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
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1592
|
+
L(J, Rt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
|
|
1593
|
+
L(J, Mt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
|
|
1594
|
+
L(J, St, 8), L(J, It, 0.65);
|
|
1595
1595
|
let K = J;
|
|
1596
|
-
var
|
|
1597
|
-
class
|
|
1596
|
+
var rt;
|
|
1597
|
+
class Ae {
|
|
1598
1598
|
constructor() {
|
|
1599
|
-
|
|
1599
|
+
L(this, rt, {});
|
|
1600
1600
|
}
|
|
1601
1601
|
/**
|
|
1602
1602
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1611,11 +1611,11 @@ class ne {
|
|
|
1611
1611
|
* @returns {string}
|
|
1612
1612
|
*/
|
|
1613
1613
|
createHash(e) {
|
|
1614
|
-
let t = "abcdefghijklmnopqrstuvwxyz0123456789",
|
|
1614
|
+
let t = "abcdefghijklmnopqrstuvwxyz0123456789", s = "";
|
|
1615
1615
|
e = e || 6;
|
|
1616
1616
|
for (let i = 0; i < e; i++)
|
|
1617
|
-
|
|
1618
|
-
return
|
|
1617
|
+
s += t.charAt(Math.floor(Math.random() * t.length));
|
|
1618
|
+
return s;
|
|
1619
1619
|
}
|
|
1620
1620
|
/**
|
|
1621
1621
|
* Фильтр часто запускаемых действий (debounce)
|
|
@@ -1624,9 +1624,9 @@ class ne {
|
|
|
1624
1624
|
* @param {number} params.duration - Задержка в миллисекундах (по умолчанию 10)
|
|
1625
1625
|
* @param {Function} params.action - Функция для выполнения
|
|
1626
1626
|
*/
|
|
1627
|
-
actionFilter({ keyTimer: e, duration: t = 10, action:
|
|
1628
|
-
|
|
1629
|
-
|
|
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
1630
|
}, t));
|
|
1631
1631
|
}
|
|
1632
1632
|
/**
|
|
@@ -1657,37 +1657,37 @@ class ne {
|
|
|
1657
1657
|
* @param {string} filename - Имя файла без расширения
|
|
1658
1658
|
*/
|
|
1659
1659
|
downloadFileJson(e, t) {
|
|
1660
|
-
let
|
|
1660
|
+
let s = new Blob([JSON.stringify(e)], { type: "application/json" }), i = URL.createObjectURL(s), a = document.createElement("a");
|
|
1661
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 j, z,
|
|
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
|
-
|
|
1672
|
+
L(this, Bt);
|
|
1673
1673
|
/** Вывод ошибок логера
|
|
1674
1674
|
* @param {'entity'} type - тип ошибки
|
|
1675
1675
|
*/
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
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
|
+
L(this, st, /* @__PURE__ */ new Map());
|
|
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() {
|
|
@@ -1697,7 +1697,7 @@ class be {
|
|
|
1697
1697
|
});
|
|
1698
1698
|
if (t && Array.isArray(t))
|
|
1699
1699
|
if (t.find(
|
|
1700
|
-
(i) => i.ENTITY ==
|
|
1700
|
+
(i) => i.ENTITY == I(this, j)
|
|
1701
1701
|
))
|
|
1702
1702
|
x(this, z, !0);
|
|
1703
1703
|
else {
|
|
@@ -1705,15 +1705,15 @@ class be {
|
|
|
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
1714
|
i && x(this, z, !0);
|
|
1715
1715
|
}
|
|
1716
|
-
return
|
|
1716
|
+
return I(this, z);
|
|
1717
1717
|
} catch (e) {
|
|
1718
1718
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1719
1719
|
}
|
|
@@ -1735,11 +1735,11 @@ class be {
|
|
|
1735
1735
|
* @returns {string|null}
|
|
1736
1736
|
*/
|
|
1737
1737
|
start({ type: e, data: t }) {
|
|
1738
|
-
if (!
|
|
1739
|
-
return
|
|
1738
|
+
if (!I(this, z))
|
|
1739
|
+
return O(this, pt, Qt).call(this, "entity"), null;
|
|
1740
1740
|
if (!e || !t)
|
|
1741
1741
|
return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
|
|
1742
|
-
const
|
|
1742
|
+
const s = jt.hash, i = {
|
|
1743
1743
|
type: e,
|
|
1744
1744
|
data: t,
|
|
1745
1745
|
userInfo: null,
|
|
@@ -1748,7 +1748,7 @@ class be {
|
|
|
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,20 +1757,20 @@ class be {
|
|
|
1757
1757
|
* status: 'success'|'fail'|'fail-runtime',
|
|
1758
1758
|
* answer: { [key]: unknown } }}
|
|
1759
1759
|
*/
|
|
1760
|
-
async stop({ key: e, errorList: t, status:
|
|
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
1770
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1771
1771
|
return;
|
|
1772
1772
|
}
|
|
1773
|
-
t && (a.errorList = t),
|
|
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 - коллбэк
|
|
@@ -1778,14 +1778,14 @@ class be {
|
|
|
1778
1778
|
async getEntityList(e) {
|
|
1779
1779
|
var t;
|
|
1780
1780
|
try {
|
|
1781
|
-
if ((t =
|
|
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
|
}
|
|
@@ -1794,11 +1794,11 @@ class be {
|
|
|
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(
|
|
@@ -1807,8 +1807,8 @@ class be {
|
|
|
1807
1807
|
), null;
|
|
1808
1808
|
}
|
|
1809
1809
|
}).filter((a) => a !== null), x(this, it, !1), x(this, v, i), i);
|
|
1810
|
-
} catch (
|
|
1811
|
-
return console.error("Ошибка при получении списка записей:",
|
|
1810
|
+
} catch (s) {
|
|
1811
|
+
return console.error("Ошибка при получении списка записей:", s), [];
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
1814
|
/**
|
|
@@ -1816,16 +1816,16 @@ class be {
|
|
|
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 e =
|
|
1827
|
-
return
|
|
1828
|
-
|
|
1826
|
+
let e = Tt().format("%Y-%m-%d");
|
|
1827
|
+
return jt.downloadFileJson(
|
|
1828
|
+
I(this, v),
|
|
1829
1829
|
`sdklogger-entity-data__${e}`
|
|
1830
1830
|
), !0;
|
|
1831
1831
|
} catch (e) {
|
|
@@ -1833,57 +1833,57 @@ class be {
|
|
|
1833
1833
|
}
|
|
1834
1834
|
}
|
|
1835
1835
|
}
|
|
1836
|
-
j = new WeakMap(), z = new WeakMap(),
|
|
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 e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser:
|
|
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,
|
|
1843
|
+
x(this, ct, { isAdmin: t, curUser: s });
|
|
1844
1844
|
} catch (e) {
|
|
1845
1845
|
console.error(
|
|
1846
1846
|
"Ошибка при получении информации о пользователе:",
|
|
1847
1847
|
e
|
|
1848
|
-
), x(this,
|
|
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
|
-
e == "entity" &&
|
|
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
1863
|
let e = {}, t = new K(BX24.callBatch);
|
|
1864
|
-
for (let [
|
|
1864
|
+
for (let [s, i] of I(this, st).entries())
|
|
1865
1865
|
if (i.status) {
|
|
1866
1866
|
const a = JSON.stringify(i);
|
|
1867
|
-
e[
|
|
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
1876
|
if (Object.keys(e).length) {
|
|
1877
|
-
let
|
|
1878
|
-
for (let [a, c] of Object.entries({ ...
|
|
1879
|
-
|
|
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
1883
|
} catch (e) {
|
|
1884
1884
|
return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
|
|
1885
1885
|
}
|
|
1886
|
-
},
|
|
1886
|
+
}, Ht = new WeakSet(), he = async function() {
|
|
1887
1887
|
try {
|
|
1888
1888
|
let e = new K(BX24.callBatch), { serverTime: t } = await e.batch({
|
|
1889
1889
|
serverTime: { method: "server.time" }
|
|
@@ -1892,77 +1892,77 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
|
|
|
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
|
|
1908
|
+
s.length > 0 && (console.log(
|
|
1909
|
+
`Найдено ${s.length} записей для очистки (старше ${this.periodClear} месяцев)`
|
|
1910
|
+
), await O(this, Ut, ue).call(this, s));
|
|
1911
1911
|
} catch (e) {
|
|
1912
1912
|
console.error("Ошибка при проверке периода очистки:", e);
|
|
1913
1913
|
}
|
|
1914
|
-
},
|
|
1914
|
+
}, Ut = new WeakSet(), ue = async function(e) {
|
|
1915
1915
|
try {
|
|
1916
1916
|
if (!e || e.length === 0)
|
|
1917
1917
|
return !1;
|
|
1918
|
-
let t = new K(BX24.callBatch),
|
|
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 t.batch(
|
|
1931
|
-
return console.log(`Успешно удалено ${
|
|
1930
|
+
const i = await t.batch(s);
|
|
1931
|
+
return console.log(`Успешно удалено ${s.length} записей`), x(this, it, !0), i;
|
|
1932
1932
|
} catch (t) {
|
|
1933
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 e = new URL(
|
|
1940
|
+
const e = new URL(g);
|
|
1941
1941
|
e.search = "", e.hash = "";
|
|
1942
1942
|
let t = e.toString();
|
|
1943
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
|
|
1951
|
+
function Ie() {
|
|
1952
1952
|
var e;
|
|
1953
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 e =
|
|
1962
|
-
return e ? (
|
|
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 - Название приложения
|
|
@@ -1975,24 +1975,24 @@ class we {
|
|
|
1975
1975
|
*
|
|
1976
1976
|
* @returns {Batch} Shared Batch instance.
|
|
1977
1977
|
*/
|
|
1978
|
-
|
|
1979
|
-
|
|
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
|
-
|
|
1985
|
+
L(this, yt);
|
|
1986
1986
|
/**
|
|
1987
1987
|
* @returns {boolean}
|
|
1988
1988
|
*/
|
|
1989
|
-
|
|
1989
|
+
L(this, Gt);
|
|
1990
1990
|
/** Запрос данных о приложении */
|
|
1991
|
-
|
|
1991
|
+
L(this, Yt);
|
|
1992
1992
|
/** Запрос данных о текущем пользователе */
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1993
|
+
L(this, Wt);
|
|
1994
|
+
L(this, $);
|
|
1995
|
+
L(this, Nt);
|
|
1996
1996
|
/**
|
|
1997
1997
|
* Расширяет errorList для случаев TIMEOUT и LIMIT
|
|
1998
1998
|
* Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
|
|
@@ -2002,31 +2002,31 @@ class we {
|
|
|
2002
2002
|
* @param {Array} updateList - Список обновлений для логирования (опционально)
|
|
2003
2003
|
* @returns {Object} Расширенный список ошибок
|
|
2004
2004
|
*/
|
|
2005
|
-
|
|
2005
|
+
L(this, xt);
|
|
2006
2006
|
/**
|
|
2007
2007
|
* Нормализует входные данные в массив объектов {placement, handler?}
|
|
2008
2008
|
* @private
|
|
2009
2009
|
*/
|
|
2010
|
-
|
|
2010
|
+
L(this, Ot);
|
|
2011
2011
|
/**
|
|
2012
2012
|
* Находит встройки с устаревшим handler (не содержащим текущий pathApp)
|
|
2013
2013
|
* @private
|
|
2014
2014
|
*/
|
|
2015
|
-
|
|
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
|
-
|
|
2029
|
+
w(this, "batchClient", null);
|
|
2030
2030
|
this.appConst = e;
|
|
2031
2031
|
}
|
|
2032
2032
|
/**
|
|
@@ -2036,7 +2036,7 @@ class we {
|
|
|
2036
2036
|
* @returns {() => void} Функция отписки.
|
|
2037
2037
|
*/
|
|
2038
2038
|
subscribeTimeLimit(e) {
|
|
2039
|
-
return
|
|
2039
|
+
return O(this, ht, bt).call(this).subscribeTimeLimit(e);
|
|
2040
2040
|
}
|
|
2041
2041
|
/**
|
|
2042
2042
|
* Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
|
|
@@ -2060,22 +2060,22 @@ class we {
|
|
|
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
|
}
|
|
@@ -2126,20 +2126,20 @@ class we {
|
|
|
2126
2126
|
* }[]
|
|
2127
2127
|
* }[]
|
|
2128
2128
|
*/
|
|
2129
|
-
async call({ method: e, params: t, updateList:
|
|
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: e, params: t, updateList:
|
|
2133
|
+
data: { method: e, params: t, updateList: s }
|
|
2134
2134
|
})), t || (t = {}), typeof BX24 > "u" || !BX24.callMethod) {
|
|
2135
|
-
const
|
|
2136
|
-
throw console.error(
|
|
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 we {
|
|
|
2164
2164
|
* }[]
|
|
2165
2165
|
* }}
|
|
2166
2166
|
*/
|
|
2167
|
-
async batch(e, t, { errorCall:
|
|
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
2174
|
commandList: e,
|
|
2175
2175
|
progressCall: t,
|
|
2176
|
-
errorCall:
|
|
2176
|
+
errorCall: s,
|
|
2177
2177
|
updateList: i,
|
|
2178
2178
|
batchOptions: a
|
|
2179
2179
|
});
|
|
@@ -2200,16 +2200,16 @@ class we {
|
|
|
2200
2200
|
* }}
|
|
2201
2201
|
* @returns {Promise<Object|false>}
|
|
2202
2202
|
*/
|
|
2203
|
-
async batchTotalCount(e, t, { errorCall:
|
|
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
2210
|
commandList: e,
|
|
2211
2211
|
progressCall: t,
|
|
2212
|
-
errorCall:
|
|
2212
|
+
errorCall: s,
|
|
2213
2213
|
updateList: i
|
|
2214
2214
|
});
|
|
2215
2215
|
}
|
|
@@ -2226,54 +2226,54 @@ class we {
|
|
|
2226
2226
|
var A;
|
|
2227
2227
|
if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
|
|
2228
2228
|
return;
|
|
2229
|
-
const { appName: t, pathApp:
|
|
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
|
-
|
|
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
|
-
(b) => b.handler ===
|
|
2247
|
+
(b) => b.handler === s
|
|
2248
2248
|
))
|
|
2249
2249
|
continue;
|
|
2250
|
-
const
|
|
2251
|
-
(b) => b.handler !==
|
|
2250
|
+
const N = E.filter(
|
|
2251
|
+
(b) => b.handler !== s
|
|
2252
2252
|
);
|
|
2253
|
-
for (const b of
|
|
2254
|
-
|
|
2255
|
-
placement:
|
|
2253
|
+
for (const b of N)
|
|
2254
|
+
u.push({
|
|
2255
|
+
placement: _,
|
|
2256
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
|
/**
|
|
@@ -2281,22 +2281,22 @@ class we {
|
|
|
2281
2281
|
* @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
|
|
2282
2282
|
*/
|
|
2283
2283
|
async placementUnBind(e) {
|
|
2284
|
-
let t =
|
|
2284
|
+
let t = O(this, Ot, te).call(this, e);
|
|
2285
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
|
|
2289
|
+
const s = {};
|
|
2290
2290
|
for (let i = 0; i < t.length; i++) {
|
|
2291
2291
|
const a = {
|
|
2292
2292
|
PLACEMENT: t[i].placement
|
|
2293
2293
|
};
|
|
2294
|
-
t[i].handler && (a.HANDLER = t[i].handler),
|
|
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
|
}
|
|
@@ -2310,8 +2310,8 @@ class we {
|
|
|
2310
2310
|
return console.log("chat-bot list:", t), t;
|
|
2311
2311
|
}
|
|
2312
2312
|
/* регистрация бота */
|
|
2313
|
-
async regBot({ code: e, type: t, name:
|
|
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
2317
|
CODE: e ?? this.appInfo.CODE,
|
|
@@ -2326,7 +2326,7 @@ class we {
|
|
|
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 we {
|
|
|
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,7 +2347,7 @@ class we {
|
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
2349
|
});
|
|
2350
|
-
return console.log("Чат-бот добавлен",
|
|
2350
|
+
return console.log("Чат-бот добавлен", f), f;
|
|
2351
2351
|
}
|
|
2352
2352
|
/* Убрать регистрацию бота */
|
|
2353
2353
|
async unRegBot(e) {
|
|
@@ -2364,12 +2364,12 @@ class we {
|
|
|
2364
2364
|
return this.logger.getEntityList(e);
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
2367
|
-
|
|
2367
|
+
ht = new WeakSet(), bt = function() {
|
|
2368
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,133 +2378,133 @@ lt = new WeakSet(), Tt = function() {
|
|
|
2378
2378
|
getEntityList: () => {
|
|
2379
2379
|
}
|
|
2380
2380
|
};
|
|
2381
|
-
},
|
|
2382
|
-
this.logger ? (this.logger = new
|
|
2383
|
-
},
|
|
2384
|
-
var
|
|
2385
|
-
const e = (
|
|
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
2386
|
return e === "PAGE_BACKGROUND_WORKER" || t === "PAGE_BACKGROUND_WORKER";
|
|
2387
|
-
},
|
|
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
|
-
}, $ = new WeakSet(),
|
|
2391
|
+
}, $ = new WeakSet(), ot = async function(e, t) {
|
|
2392
2392
|
if (e)
|
|
2393
2393
|
try {
|
|
2394
2394
|
await this.logger.stop({
|
|
2395
2395
|
key: e,
|
|
2396
2396
|
...t
|
|
2397
2397
|
});
|
|
2398
|
-
} catch (
|
|
2399
|
-
console.error("Logger error:",
|
|
2398
|
+
} catch (s) {
|
|
2399
|
+
console.error("Logger error:", s);
|
|
2400
2400
|
}
|
|
2401
|
-
},
|
|
2401
|
+
}, Nt = new WeakSet(), $t = async function({
|
|
2402
2402
|
mode: e,
|
|
2403
2403
|
commandList: t,
|
|
2404
|
-
progressCall:
|
|
2404
|
+
progressCall: s,
|
|
2405
2405
|
errorCall: i,
|
|
2406
2406
|
updateList: a,
|
|
2407
2407
|
batchOptions: c
|
|
2408
2408
|
}) {
|
|
2409
|
-
const
|
|
2409
|
+
const h = O(this, ht, bt).call(this), f = a ? this.logger.start({
|
|
2410
2410
|
type: e,
|
|
2411
2411
|
data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
|
|
2412
2412
|
}) : void 0;
|
|
2413
2413
|
try {
|
|
2414
|
-
const n = e === "batch" ? await
|
|
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
|
-
},
|
|
2425
|
+
}, xt = new WeakSet(), ye = function(e, t, s, i) {
|
|
2426
2426
|
let a = { ...e.errors };
|
|
2427
2427
|
if (Object.values(e.errors).some(
|
|
2428
|
-
(
|
|
2429
|
-
if (typeof
|
|
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
|
|
2435
|
+
const h = t ? Object.keys(t).filter((d) => d !== "errorsList") : [], f = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
|
|
2436
2436
|
if (t) {
|
|
2437
|
-
for (const
|
|
2438
|
-
if (!
|
|
2439
|
-
const A = t[
|
|
2440
|
-
A != null && n.add(
|
|
2437
|
+
for (const d of h)
|
|
2438
|
+
if (!f.has(d)) {
|
|
2439
|
+
const A = t[d];
|
|
2440
|
+
A != null && n.add(d);
|
|
2441
2441
|
}
|
|
2442
2442
|
}
|
|
2443
|
-
const
|
|
2444
|
-
(
|
|
2445
|
-
if (typeof
|
|
2443
|
+
const u = Object.values(e.errors).find(
|
|
2444
|
+
(d) => {
|
|
2445
|
+
if (typeof d != "string")
|
|
2446
2446
|
return !1;
|
|
2447
|
-
const A =
|
|
2447
|
+
const A = d.toUpperCase();
|
|
2448
2448
|
return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
|
|
2449
2449
|
}
|
|
2450
2450
|
);
|
|
2451
|
-
for (const
|
|
2452
|
-
!n.has(
|
|
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
|
-
},
|
|
2455
|
+
}, Ot = new WeakSet(), te = function(e) {
|
|
2456
2456
|
if (!e)
|
|
2457
2457
|
return [];
|
|
2458
2458
|
let t = [];
|
|
2459
2459
|
return Array.isArray(e) ? t = e.map(
|
|
2460
|
-
(
|
|
2460
|
+
(s) => typeof s == "string" ? { placement: s } : s
|
|
2461
2461
|
) : typeof e == "string" ? t = [{ placement: e }] : t = [e], t;
|
|
2462
|
-
},
|
|
2462
|
+
}, Ft = new WeakSet(), Ne = function(e) {
|
|
2463
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 e = `${
|
|
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 t =
|
|
2482
|
+
function se(g, e) {
|
|
2483
|
+
const t = we(g);
|
|
2484
2484
|
if (t)
|
|
2485
2485
|
try {
|
|
2486
|
-
const
|
|
2486
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : { data: e };
|
|
2487
2487
|
t.postMessage({
|
|
2488
|
-
...
|
|
2489
|
-
tabId:
|
|
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
2505
|
return { skipped: !1, result: await e(), coordination: "locks" };
|
|
2506
2506
|
} finally {
|
|
2507
|
-
|
|
2507
|
+
se(i, { type: "lock-released", resource: i });
|
|
2508
2508
|
}
|
|
2509
2509
|
}
|
|
2510
2510
|
) : { skipped: !1, result: await e(), coordination: "none" };
|
|
@@ -2525,11 +2525,16 @@ const q = {
|
|
|
2525
2525
|
/** Heartbeat лидера во время appInit; null — вычислить из poll/activeMaxPause. */
|
|
2526
2526
|
leaderHeartbeatMs: null
|
|
2527
2527
|
};
|
|
2528
|
-
function
|
|
2529
|
-
|
|
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 };
|
|
2530
2535
|
for (const t of Object.keys(q)) {
|
|
2531
2536
|
if (t === "leaderHeartbeatMs") {
|
|
2532
|
-
const i =
|
|
2537
|
+
const i = g == null ? void 0 : g.leaderHeartbeatMs;
|
|
2533
2538
|
if (i == null) {
|
|
2534
2539
|
e.leaderHeartbeatMs = null;
|
|
2535
2540
|
continue;
|
|
@@ -2538,45 +2543,58 @@ function De(y = {}) {
|
|
|
2538
2543
|
e.leaderHeartbeatMs = Number.isFinite(a) && a >= 0 ? a : null;
|
|
2539
2544
|
continue;
|
|
2540
2545
|
}
|
|
2541
|
-
const
|
|
2542
|
-
e[t] = Number.isFinite(
|
|
2546
|
+
const s = Number(e[t]);
|
|
2547
|
+
e[t] = Number.isFinite(s) && s >= 0 ? s : q[t];
|
|
2543
2548
|
}
|
|
2544
2549
|
return e;
|
|
2545
2550
|
}
|
|
2546
|
-
var
|
|
2547
|
-
class
|
|
2551
|
+
var vt, _e, _t, ee, nt, dt, Xt, Te;
|
|
2552
|
+
class Ge {
|
|
2548
2553
|
constructor(e) {
|
|
2549
|
-
|
|
2554
|
+
L(this, vt);
|
|
2550
2555
|
/**
|
|
2551
2556
|
* Канонический base URL для placement (без завершающего `/`).
|
|
2552
2557
|
* Пустая строка — не биндить (некорректный или marketplace URL).
|
|
2553
2558
|
*/
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
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;
|
|
2574
2585
|
if (!e) {
|
|
2575
2586
|
console.error("BackgroundWorker: Нет опций конструктора");
|
|
2576
2587
|
return;
|
|
2577
2588
|
}
|
|
2578
|
-
const {
|
|
2579
|
-
|
|
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;
|
|
2580
2598
|
}
|
|
2581
2599
|
async init() {
|
|
2582
2600
|
if (!this.appInit) {
|
|
@@ -2609,8 +2627,8 @@ class Be {
|
|
|
2609
2627
|
return;
|
|
2610
2628
|
}
|
|
2611
2629
|
await this.refreshTabs(!0), await this.ensureTabRegistered();
|
|
2612
|
-
const t = this.selectLeaderId(),
|
|
2613
|
-
await this.updateTabState(
|
|
2630
|
+
const t = this.selectLeaderId(), s = t && +this.id == +t;
|
|
2631
|
+
await this.updateTabState(s), s && !this.hasStarted && await this.runAsLeader();
|
|
2614
2632
|
}
|
|
2615
2633
|
stopTimers() {
|
|
2616
2634
|
this.heartbeat && (clearInterval(this.heartbeat), this.heartbeat = void 0), this.runHeartbeat && (clearInterval(this.runHeartbeat), this.runHeartbeat = void 0);
|
|
@@ -2620,18 +2638,18 @@ class Be {
|
|
|
2620
2638
|
if (typeof BX24 > "u" || !((e = BX24.placement) != null && e.info))
|
|
2621
2639
|
return !1;
|
|
2622
2640
|
try {
|
|
2623
|
-
const t = BX24.placement.info(),
|
|
2624
|
-
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;
|
|
2625
2643
|
} catch {
|
|
2626
2644
|
return !1;
|
|
2627
2645
|
}
|
|
2628
2646
|
}
|
|
2629
2647
|
async checkEntity() {
|
|
2630
|
-
var
|
|
2648
|
+
var s;
|
|
2631
2649
|
const e = await this.safeCall(
|
|
2632
2650
|
() => this.bx.call({ method: "entity.get" })
|
|
2633
2651
|
);
|
|
2634
|
-
((
|
|
2652
|
+
((s = e == null ? void 0 : e.find) == null ? void 0 : s.call(
|
|
2635
2653
|
e,
|
|
2636
2654
|
(i) => i.ENTITY === this.entityName
|
|
2637
2655
|
)) || await this.safeCall(
|
|
@@ -2646,31 +2664,29 @@ class Be {
|
|
|
2646
2664
|
);
|
|
2647
2665
|
}
|
|
2648
2666
|
async getTabs() {
|
|
2649
|
-
const e = await this.safeCall(
|
|
2650
|
-
() => {
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
}
|
|
2659
|
-
});
|
|
2660
|
-
}
|
|
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
|
+
})
|
|
2661
2676
|
);
|
|
2662
|
-
return !Array.isArray(
|
|
2663
|
-
if (!
|
|
2677
|
+
return !Array.isArray(t) || !t.length ? [] : t.map((s) => {
|
|
2678
|
+
if (!s)
|
|
2664
2679
|
return { id: void 0, data: void 0 };
|
|
2665
2680
|
try {
|
|
2666
|
-
const
|
|
2667
|
-
return { id: +
|
|
2668
|
-
} catch (
|
|
2669
|
-
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 };
|
|
2670
2685
|
}
|
|
2671
2686
|
});
|
|
2672
2687
|
}
|
|
2673
2688
|
async ensureTabRegistered() {
|
|
2689
|
+
var s, i;
|
|
2674
2690
|
if (this.id)
|
|
2675
2691
|
return +this.id || 0;
|
|
2676
2692
|
if (this.tabList.length >= this.maxTabs && await this.refreshTabs(!0, this.quickCleanupThreshold), this.tabList.length >= this.maxTabs)
|
|
@@ -2681,52 +2697,49 @@ class Be {
|
|
|
2681
2697
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2682
2698
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2683
2699
|
start: !1,
|
|
2684
|
-
sessionId: this.sessionId
|
|
2700
|
+
sessionId: this.sessionId,
|
|
2701
|
+
userId: (i = (s = this.bx) == null ? void 0 : s.userInfo) == null ? void 0 : i.ID
|
|
2685
2702
|
}, t = await this.safeCall(
|
|
2686
|
-
() => {
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
}
|
|
2695
|
-
});
|
|
2696
|
-
}
|
|
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
|
+
})
|
|
2697
2711
|
) || 0;
|
|
2698
2712
|
return this.id = +t || 0, this.id;
|
|
2699
2713
|
}
|
|
2700
2714
|
async updateTabState(e) {
|
|
2715
|
+
var s, i;
|
|
2701
2716
|
if (!this.id)
|
|
2702
2717
|
return;
|
|
2703
2718
|
const t = {
|
|
2704
2719
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2705
2720
|
createdAt: this.start.toISOString(),
|
|
2706
2721
|
start: e,
|
|
2707
|
-
sessionId: this.sessionId
|
|
2722
|
+
sessionId: this.sessionId,
|
|
2723
|
+
userId: (i = (s = this.bx) == null ? void 0 : s.userInfo) == null ? void 0 : i.ID
|
|
2708
2724
|
};
|
|
2709
2725
|
await this.safeCall(
|
|
2710
|
-
() => {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
}
|
|
2720
|
-
});
|
|
2721
|
-
}
|
|
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
|
+
})
|
|
2722
2735
|
);
|
|
2723
2736
|
}
|
|
2724
2737
|
async deleteTabs(e = []) {
|
|
2725
2738
|
if (!e.length)
|
|
2726
2739
|
return;
|
|
2727
|
-
const t = e.map((
|
|
2740
|
+
const t = e.map((s) => ({
|
|
2728
2741
|
method: "entity.item.delete",
|
|
2729
|
-
params: { ENTITY: this.entityName, ID:
|
|
2742
|
+
params: { ENTITY: this.entityName, ID: s.id }
|
|
2730
2743
|
}));
|
|
2731
2744
|
await this.safeCall(() => this.bx.batch(t));
|
|
2732
2745
|
}
|
|
@@ -2735,10 +2748,10 @@ class Be {
|
|
|
2735
2748
|
try {
|
|
2736
2749
|
if (!((e = this.bx) != null && e.isAdmin))
|
|
2737
2750
|
return !0;
|
|
2738
|
-
const
|
|
2751
|
+
const s = await this.safeCall(
|
|
2739
2752
|
() => this.bx.getPlacement()
|
|
2740
2753
|
);
|
|
2741
|
-
if (!
|
|
2754
|
+
if (!s || !Array.isArray(s))
|
|
2742
2755
|
return console.log(
|
|
2743
2756
|
"BackgroundWorker: Не получили список размещений, продолжаем"
|
|
2744
2757
|
), !0;
|
|
@@ -2747,27 +2760,27 @@ class Be {
|
|
|
2747
2760
|
), c = !a;
|
|
2748
2761
|
if (!i)
|
|
2749
2762
|
return !0;
|
|
2750
|
-
let
|
|
2751
|
-
for (const
|
|
2752
|
-
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=")))
|
|
2753
2766
|
continue;
|
|
2754
|
-
const
|
|
2755
|
-
if (
|
|
2756
|
-
|
|
2767
|
+
const u = f.userId || (f.handler ? this.extractUserIdFromHandler(f.handler) : null);
|
|
2768
|
+
if (u && +u === i) {
|
|
2769
|
+
h = !0;
|
|
2757
2770
|
break;
|
|
2758
2771
|
}
|
|
2759
2772
|
}
|
|
2760
2773
|
return a ? (console.log(
|
|
2761
2774
|
"BackgroundWorker: Индивидуальная встройка - разрешено"
|
|
2762
|
-
), !0) : c &&
|
|
2775
|
+
), !0) : c && h ? (console.log(
|
|
2763
2776
|
"BackgroundWorker: Есть личная встройка, общую не запускаем"
|
|
2764
2777
|
), !1) : (console.log(
|
|
2765
2778
|
"BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
|
|
2766
2779
|
), !0);
|
|
2767
|
-
} catch (
|
|
2780
|
+
} catch (s) {
|
|
2768
2781
|
return console.error(
|
|
2769
2782
|
"BackgroundWorker: Ошибка при проверке типа встройки",
|
|
2770
|
-
|
|
2783
|
+
s
|
|
2771
2784
|
), !0;
|
|
2772
2785
|
}
|
|
2773
2786
|
}
|
|
@@ -2794,30 +2807,30 @@ class Be {
|
|
|
2794
2807
|
}
|
|
2795
2808
|
}
|
|
2796
2809
|
async refreshTabs(e = !1, t = this.activeMaxPause) {
|
|
2797
|
-
const
|
|
2798
|
-
for (const
|
|
2799
|
-
if (!(
|
|
2800
|
-
|
|
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);
|
|
2801
2814
|
continue;
|
|
2802
2815
|
}
|
|
2803
|
-
if (a - new Date(
|
|
2804
|
-
|
|
2816
|
+
if (a - new Date(h.data.lastActive || 0).getTime() > t) {
|
|
2817
|
+
s.push(h);
|
|
2805
2818
|
continue;
|
|
2806
2819
|
}
|
|
2807
|
-
i.push(
|
|
2820
|
+
i.push(h);
|
|
2808
2821
|
}
|
|
2809
|
-
return e &&
|
|
2822
|
+
return e && s.length && await this.deleteTabs(s), this.tabList = i, i;
|
|
2810
2823
|
}
|
|
2811
2824
|
selectLeaderId() {
|
|
2812
2825
|
var t;
|
|
2813
|
-
return this.tabList.length && +((t = [...this.tabList].sort((
|
|
2814
|
-
var
|
|
2826
|
+
return this.tabList.length && +((t = [...this.tabList].sort((s, i) => {
|
|
2827
|
+
var h, f, n, u;
|
|
2815
2828
|
const a = new Date(
|
|
2816
|
-
((
|
|
2829
|
+
((h = s.data) == null ? void 0 : h.createdAt) || ((f = s.data) == null ? void 0 : f.lastActive) || 0
|
|
2817
2830
|
).getTime(), c = new Date(
|
|
2818
|
-
((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
|
|
2819
2832
|
).getTime();
|
|
2820
|
-
return a === c ? (+
|
|
2833
|
+
return a === c ? (+s.id || 0) - (+i.id || 0) : a - c;
|
|
2821
2834
|
})[0]) == null ? void 0 : t.id) || 0;
|
|
2822
2835
|
}
|
|
2823
2836
|
async confirmLeaderAfterLock() {
|
|
@@ -2826,10 +2839,9 @@ class Be {
|
|
|
2826
2839
|
return !!(e && +this.id == +e);
|
|
2827
2840
|
}
|
|
2828
2841
|
async runAsLeader() {
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
t,
|
|
2842
|
+
const e = O(this, Xt, Te).call(this);
|
|
2843
|
+
(await Be(
|
|
2844
|
+
e,
|
|
2833
2845
|
async () => {
|
|
2834
2846
|
if (await this.updateTabState(!0), console.log(
|
|
2835
2847
|
`BackgroundWorker: захват лидерства, пауза ${this.leaderConfirmDelay} мс перед запуском`
|
|
@@ -2840,25 +2852,25 @@ class Be {
|
|
|
2840
2852
|
return;
|
|
2841
2853
|
}
|
|
2842
2854
|
this.hasStarted = !0;
|
|
2843
|
-
const
|
|
2855
|
+
const i = this.leaderHeartbeatMs ?? Math.min(
|
|
2844
2856
|
this.activeMaxPause - 1500,
|
|
2845
2857
|
Math.max(2500, Math.floor(this.pollInterval / 2))
|
|
2846
2858
|
);
|
|
2847
2859
|
this.runHeartbeat = setInterval(
|
|
2848
2860
|
() => {
|
|
2849
2861
|
this.updateTabState(!0).catch(
|
|
2850
|
-
(
|
|
2862
|
+
(a) => console.error(
|
|
2851
2863
|
"BackgroundWorker: heartbeat update failed",
|
|
2852
|
-
|
|
2864
|
+
a
|
|
2853
2865
|
)
|
|
2854
2866
|
);
|
|
2855
2867
|
},
|
|
2856
|
-
|
|
2868
|
+
i
|
|
2857
2869
|
);
|
|
2858
2870
|
try {
|
|
2859
2871
|
await this.appInit();
|
|
2860
|
-
} catch (
|
|
2861
|
-
console.error("BackgroundWorker: appInit failed",
|
|
2872
|
+
} catch (a) {
|
|
2873
|
+
console.error("BackgroundWorker: appInit failed", a);
|
|
2862
2874
|
}
|
|
2863
2875
|
this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
2864
2876
|
},
|
|
@@ -2868,15 +2880,15 @@ class Be {
|
|
|
2868
2880
|
);
|
|
2869
2881
|
}
|
|
2870
2882
|
async setBackgroundWorkerAll() {
|
|
2871
|
-
var M,
|
|
2883
|
+
var M, N, b, H;
|
|
2872
2884
|
if (!((M = this.bx) != null && M.isAdmin)) {
|
|
2873
2885
|
console.log(
|
|
2874
2886
|
"BackgroundWorker: setBackgroundWorkerAll доступен только админам"
|
|
2875
2887
|
);
|
|
2876
2888
|
return;
|
|
2877
2889
|
}
|
|
2878
|
-
(
|
|
2879
|
-
const e =
|
|
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) ?? "");
|
|
2880
2892
|
if (!e) {
|
|
2881
2893
|
console.error(
|
|
2882
2894
|
"BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
|
|
@@ -2885,77 +2897,80 @@ class Be {
|
|
|
2885
2897
|
}
|
|
2886
2898
|
const t = await this.safeCall(
|
|
2887
2899
|
() => this.bx.getPlacement()
|
|
2888
|
-
),
|
|
2900
|
+
), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2889
2901
|
let a = null;
|
|
2890
|
-
(t || []).forEach((
|
|
2891
|
-
if (
|
|
2902
|
+
(t || []).forEach((y) => {
|
|
2903
|
+
if (y.placement !== "PAGE_BACKGROUND_WORKER")
|
|
2892
2904
|
return;
|
|
2893
|
-
if (
|
|
2894
|
-
const
|
|
2895
|
-
if (
|
|
2896
|
-
const
|
|
2897
|
-
|
|
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);
|
|
2898
2910
|
}
|
|
2899
2911
|
} else
|
|
2900
|
-
a =
|
|
2912
|
+
a = y;
|
|
2901
2913
|
});
|
|
2902
|
-
const c = await this.resolveAdmins(),
|
|
2903
|
-
|
|
2904
|
-
const
|
|
2905
|
-
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;
|
|
2906
2918
|
});
|
|
2907
|
-
const
|
|
2908
|
-
const
|
|
2909
|
-
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)
|
|
2910
2922
|
return !0;
|
|
2911
|
-
const
|
|
2912
|
-
return
|
|
2913
|
-
}),
|
|
2914
|
-
|
|
2915
|
-
const
|
|
2916
|
-
|
|
2923
|
+
const R = `${e}?USER_ID=${y.ID}/`;
|
|
2924
|
+
return S.handler !== R;
|
|
2925
|
+
}), d = [];
|
|
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);
|
|
2917
2932
|
}
|
|
2918
|
-
for (const
|
|
2919
|
-
const
|
|
2920
|
-
if (!
|
|
2933
|
+
for (const y of n) {
|
|
2934
|
+
const S = s.get(+y.ID);
|
|
2935
|
+
if (!S)
|
|
2921
2936
|
continue;
|
|
2922
|
-
const
|
|
2923
|
-
|
|
2937
|
+
const R = `${e}?USER_ID=${y.ID}/`;
|
|
2938
|
+
S.handler !== R && d.push(+y.ID);
|
|
2924
2939
|
}
|
|
2925
|
-
const A = [],
|
|
2926
|
-
for (const
|
|
2927
|
-
const
|
|
2928
|
-
for (const
|
|
2929
|
-
|
|
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({
|
|
2930
2945
|
method: "placement.unbind",
|
|
2931
2946
|
params: {
|
|
2932
2947
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2933
|
-
HANDLER:
|
|
2948
|
+
HANDLER: R.handler
|
|
2934
2949
|
}
|
|
2935
2950
|
});
|
|
2936
2951
|
}
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2952
|
+
const _ = a && (u.length > 0 || a.handler !== `${e}`);
|
|
2953
|
+
_ && A.push({
|
|
2939
2954
|
method: "placement.unbind",
|
|
2940
2955
|
params: {
|
|
2941
2956
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2942
2957
|
HANDLER: a.handler || `${e}`
|
|
2943
2958
|
}
|
|
2944
2959
|
});
|
|
2945
|
-
for (const
|
|
2960
|
+
for (const y of u)
|
|
2946
2961
|
A.push({
|
|
2947
2962
|
method: "placement.bind",
|
|
2948
2963
|
params: {
|
|
2949
2964
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2950
|
-
HANDLER: `${e}?USER_ID=${
|
|
2965
|
+
HANDLER: `${e}?USER_ID=${y.ID}/`,
|
|
2951
2966
|
LANG_ALL: { ru: { TITLE: this.appName } },
|
|
2952
2967
|
OPTIONS: {
|
|
2953
|
-
errorHandlerUrl: `${e}?USER_ID=${
|
|
2968
|
+
errorHandlerUrl: `${e}?USER_ID=${y.ID}/`
|
|
2954
2969
|
},
|
|
2955
|
-
USER_ID:
|
|
2970
|
+
USER_ID: y.ID
|
|
2956
2971
|
}
|
|
2957
2972
|
});
|
|
2958
|
-
(!a ||
|
|
2973
|
+
(!a || _) && A.push({
|
|
2959
2974
|
method: "placement.bind",
|
|
2960
2975
|
params: {
|
|
2961
2976
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
@@ -2965,20 +2980,20 @@ class Be {
|
|
|
2965
2980
|
}
|
|
2966
2981
|
});
|
|
2967
2982
|
const T = A.filter(
|
|
2968
|
-
(
|
|
2983
|
+
(y) => y.method === "placement.unbind"
|
|
2969
2984
|
), E = A.filter(
|
|
2970
|
-
(
|
|
2985
|
+
(y) => y.method === "placement.bind"
|
|
2971
2986
|
);
|
|
2972
2987
|
T.length && await this.safeCall(
|
|
2973
2988
|
() => this.bx.batch(
|
|
2974
2989
|
Object.fromEntries(
|
|
2975
|
-
T.map((
|
|
2990
|
+
T.map((y, S) => [`unbind_${S}`, y])
|
|
2976
2991
|
)
|
|
2977
2992
|
)
|
|
2978
2993
|
), E.length && await this.safeCall(
|
|
2979
2994
|
() => this.bx.batch(
|
|
2980
2995
|
Object.fromEntries(
|
|
2981
|
-
E.map((
|
|
2996
|
+
E.map((y, S) => [`bind_${S}`, y])
|
|
2982
2997
|
)
|
|
2983
2998
|
)
|
|
2984
2999
|
), A.length || console.log("setBackgroundWorkerAll: Нет операций");
|
|
@@ -2986,29 +3001,29 @@ class Be {
|
|
|
2986
3001
|
async resolveAdmins() {
|
|
2987
3002
|
var e, t;
|
|
2988
3003
|
try {
|
|
2989
|
-
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() || [];
|
|
2990
3005
|
if (!i) {
|
|
2991
|
-
if (
|
|
2992
|
-
const
|
|
2993
|
-
(n) => +n != +
|
|
3006
|
+
if (s && a.includes(+s)) {
|
|
3007
|
+
const f = a.filter(
|
|
3008
|
+
(n) => +n != +s
|
|
2994
3009
|
);
|
|
2995
|
-
return await this.saveAdminsList(
|
|
3010
|
+
return await this.saveAdminsList(f), f;
|
|
2996
3011
|
}
|
|
2997
3012
|
return a;
|
|
2998
3013
|
}
|
|
2999
3014
|
const c = /* @__PURE__ */ new Set([...a || []]);
|
|
3000
|
-
|
|
3001
|
-
const
|
|
3002
|
-
return await this.saveAdminsList(
|
|
3003
|
-
} catch (
|
|
3004
|
-
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), [];
|
|
3005
3020
|
}
|
|
3006
3021
|
}
|
|
3007
3022
|
async getEligibleUsersForBackgroundWorker(e = []) {
|
|
3008
3023
|
const t = (this.users ?? []).filter(
|
|
3009
3024
|
(i) => i.ACTIVE === "Y" || i.ACTIVE === !0
|
|
3010
|
-
),
|
|
3011
|
-
return t.filter((i) =>
|
|
3025
|
+
), s = e.map((i) => +i || 0).filter(Boolean);
|
|
3026
|
+
return t.filter((i) => s.includes(+i.ID || 0));
|
|
3012
3027
|
}
|
|
3013
3028
|
async saveAdminsList(e = []) {
|
|
3014
3029
|
try {
|
|
@@ -3020,7 +3035,7 @@ class Be {
|
|
|
3020
3035
|
async getAdminsList() {
|
|
3021
3036
|
try {
|
|
3022
3037
|
const e = BX24.appOption.get("adminsList"), t = e ? JSON.parse(e) : [];
|
|
3023
|
-
return Array.isArray(t) ? t.map((
|
|
3038
|
+
return Array.isArray(t) ? t.map((s) => +s || 0).filter(Boolean) : [];
|
|
3024
3039
|
} catch (e) {
|
|
3025
3040
|
return console.error("BackgroundWorker: getAdminsList error", e), [];
|
|
3026
3041
|
}
|
|
@@ -3029,7 +3044,7 @@ class Be {
|
|
|
3029
3044
|
const e = {
|
|
3030
3045
|
users: { method: "user.get", params: { filter: { ACTIVE: "Y" } } }
|
|
3031
3046
|
}, { users: t } = await this.safeCall(
|
|
3032
|
-
() => this.bx.batch(e).then((
|
|
3047
|
+
() => this.bx.batch(e).then((s) => s ? (Array.isArray(s.users) || (s.users = []), s) : { users: [] })
|
|
3033
3048
|
);
|
|
3034
3049
|
this.users = t;
|
|
3035
3050
|
}
|
|
@@ -3042,9 +3057,9 @@ class Be {
|
|
|
3042
3057
|
(e = this.bx) != null && e.isAdmin && ((t = this.users) != null && t.length || await this.getEntityData(), await this.setBackgroundWorkerAll());
|
|
3043
3058
|
}
|
|
3044
3059
|
pause(e = 500, t) {
|
|
3045
|
-
return new Promise((
|
|
3060
|
+
return new Promise((s) => {
|
|
3046
3061
|
setTimeout(() => {
|
|
3047
|
-
t && t(),
|
|
3062
|
+
t && t(), s(!0);
|
|
3048
3063
|
}, e);
|
|
3049
3064
|
});
|
|
3050
3065
|
}
|
|
@@ -3057,28 +3072,33 @@ class Be {
|
|
|
3057
3072
|
}
|
|
3058
3073
|
}
|
|
3059
3074
|
}
|
|
3060
|
-
|
|
3061
|
-
const t =
|
|
3075
|
+
vt = new WeakSet(), _e = function(e) {
|
|
3076
|
+
const t = He(e);
|
|
3062
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;
|
|
3063
|
-
const
|
|
3064
|
-
t.activeMaxPauseMs <
|
|
3065
|
-
`BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${
|
|
3078
|
+
const s = t.pollIntervalMs + t.pollIntervalJitterMs + t.leaderConfirmDelayMs;
|
|
3079
|
+
t.activeMaxPauseMs < s && console.warn(
|
|
3080
|
+
`BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${s}) — «живые» вкладки могут удаляться раньше следующего тика`
|
|
3066
3081
|
);
|
|
3067
|
-
},
|
|
3082
|
+
}, _t = new WeakSet(), ee = function(e) {
|
|
3068
3083
|
if (!e || typeof e != "string")
|
|
3069
3084
|
return "";
|
|
3070
|
-
const t =
|
|
3071
|
-
return t ?
|
|
3085
|
+
const t = re(e).replace(/\/+$/, "");
|
|
3086
|
+
return t ? fe(t) ? (console.error(
|
|
3072
3087
|
"BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
|
|
3073
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)}`;
|
|
3074
3094
|
};
|
|
3075
3095
|
export {
|
|
3076
|
-
|
|
3096
|
+
Ge as BackgroundWorker,
|
|
3077
3097
|
K as Batch,
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3098
|
+
Pe as BxBoot,
|
|
3099
|
+
Ae as BxHelper,
|
|
3100
|
+
Se as BxLogger,
|
|
3081
3101
|
q as DEFAULT_BACKGROUND_WORKER_TIMING,
|
|
3082
|
-
|
|
3083
|
-
|
|
3102
|
+
He as resolveBackgroundWorkerTiming,
|
|
3103
|
+
Tt as tempus
|
|
3084
3104
|
};
|