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