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