szdl-utils-kit 0.3.4 → 0.3.6
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 -3
- package/dist/index.js +755 -683
- package/dist/index.umd.cjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
var _t = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var S = (
|
|
4
|
-
if (!e.has(
|
|
5
|
-
throw TypeError("Cannot " +
|
|
2
|
+
var pt = (N, e, r) => e in N ? _t(N, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : N[e] = r;
|
|
3
|
+
var S = (N, e, r) => (pt(N, typeof e != "symbol" ? e + "" : e, r), r), at = (N, e, r) => {
|
|
4
|
+
if (!e.has(N))
|
|
5
|
+
throw TypeError("Cannot " + r);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (e.has(
|
|
7
|
+
var p = (N, e, r) => (at(N, e, "read from private field"), r ? r.call(N) : e.get(N)), w = (N, e, r) => {
|
|
8
|
+
if (e.has(N))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
e instanceof WeakSet ? e.add(
|
|
11
|
-
},
|
|
12
|
-
var X = (
|
|
13
|
-
var
|
|
14
|
-
function Et(
|
|
15
|
-
return
|
|
10
|
+
e instanceof WeakSet ? e.add(N) : e.set(N, r);
|
|
11
|
+
}, F = (N, e, r, i) => (at(N, e, "write to private field"), i ? i.call(N, r) : e.set(N, r), r);
|
|
12
|
+
var X = (N, e, r) => (at(N, e, "access private method"), r);
|
|
13
|
+
var yt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
14
|
+
function Et(N) {
|
|
15
|
+
return N && N.__esModule && Object.prototype.hasOwnProperty.call(N, "default") ? N.default : N;
|
|
16
16
|
}
|
|
17
17
|
var lt = { exports: {} };
|
|
18
|
-
(function(
|
|
19
|
-
(function(
|
|
18
|
+
(function(N, e) {
|
|
19
|
+
(function(r) {
|
|
20
20
|
Array.prototype.indexOf || (Array.prototype.indexOf = function(t, n) {
|
|
21
|
-
var
|
|
22
|
-
for (
|
|
23
|
-
if (this[
|
|
24
|
-
return
|
|
21
|
+
var c, f;
|
|
22
|
+
for (c = n || 0, f = this.length; c < f; c += 1)
|
|
23
|
+
if (this[c] === t)
|
|
24
|
+
return c;
|
|
25
25
|
return -1;
|
|
26
26
|
});
|
|
27
27
|
var i = this, A = function(t, n) {
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
},
|
|
32
|
-
return n !==
|
|
28
|
+
for (var c = t.toString(); c.length < n; )
|
|
29
|
+
c = "0" + c;
|
|
30
|
+
return c;
|
|
31
|
+
}, o = function(t, n) {
|
|
32
|
+
return n !== r ? (t.year(n.year() || n.year), t.month(n.month() || n.month), t.day(n.day() || n.day), t.hours(n.hours() || n.hours), t.minutes(n.minutes() || n.minutes), t.seconds(n.seconds() || n.seconds), t.milliseconds(n.milliseconds() || n.milliseconds), t) : r;
|
|
33
33
|
}, h = function(t, n) {
|
|
34
|
-
var
|
|
35
|
-
return
|
|
34
|
+
var c, f = "";
|
|
35
|
+
return c = t.slice(n, n + 1), c !== "" && !isNaN(Number(c)) && (f += "%H"), c = t.charAt(n + 2), c !== "" && c === ":" && (f += c), c = t.slice(n + 3, n + 4), c !== "" && !isNaN(Number(c)) && (f += "%M"), c = t.charAt(n + 5), c !== "" && c === ":" && (f += c), c = t.slice(n + 6, n + 7), c !== "" && !isNaN(Number(c)) && (f += "%S"), f;
|
|
36
36
|
}, m = function(t, n) {
|
|
37
|
-
var
|
|
37
|
+
var c, f = [
|
|
38
38
|
t.slice(n, n + 1),
|
|
39
39
|
t.charAt(n + 2),
|
|
40
40
|
t.slice(n + 3, n + 4),
|
|
41
41
|
t.charAt(n + 5),
|
|
42
42
|
t.slice(n + 6, n + 9)
|
|
43
|
-
],
|
|
44
|
-
return !isNaN(Number(
|
|
43
|
+
], L;
|
|
44
|
+
return !isNaN(Number(f[0])) && !isNaN(Number(f[2])) && !isNaN(Number(f[4])) ? (f[1] === "." && f[3] === "." ? c = "%d.%m.%Y" : f[1] === "-" && f[3] === "-" ? c = "%m-%d-%Y" : f[1] === "/" && f[3] === "/" && (c = "%m/%d/%Y"), c) : (L = [
|
|
45
45
|
t.slice(n, n + 3),
|
|
46
46
|
t.charAt(n + 4),
|
|
47
47
|
t.slice(n + 5, n + 6),
|
|
48
48
|
t.charAt(n + 7),
|
|
49
49
|
t.slice(n + 8, n + 9)
|
|
50
|
-
], !isNaN(Number(
|
|
51
|
-
},
|
|
50
|
+
], !isNaN(Number(L[0])) && !isNaN(Number(L[2])) && !isNaN(Number(L[4])) ? (L[1] === "-" && L[3] === "-" && (c = "%Y-%m-%d"), c) : "");
|
|
51
|
+
}, l = i.tempus, s, d, g = i.navigator || {}, a = "en", u = {
|
|
52
52
|
en: {
|
|
53
53
|
JANUARY_SHORT: "Jan",
|
|
54
54
|
FEBRUARY_SHORT: "Feb",
|
|
@@ -209,70 +209,70 @@ var lt = { exports: {} };
|
|
|
209
209
|
FRIDAY_LONG: "Freitag",
|
|
210
210
|
SATURDAY_LONG: "Samstag"
|
|
211
211
|
}
|
|
212
|
-
},
|
|
212
|
+
}, y = function() {
|
|
213
213
|
return [
|
|
214
|
-
u[
|
|
215
|
-
u[
|
|
216
|
-
u[
|
|
217
|
-
u[
|
|
218
|
-
u[
|
|
219
|
-
u[
|
|
220
|
-
u[
|
|
221
|
-
u[
|
|
222
|
-
u[
|
|
223
|
-
u[
|
|
224
|
-
u[
|
|
225
|
-
u[
|
|
214
|
+
u[a].JANUARY_LONG,
|
|
215
|
+
u[a].FEBRUARY_LONG,
|
|
216
|
+
u[a].MARCH_LONG,
|
|
217
|
+
u[a].APRIL_LONG,
|
|
218
|
+
u[a].MAY_LONG,
|
|
219
|
+
u[a].JUNE_LONG,
|
|
220
|
+
u[a].JULY_LONG,
|
|
221
|
+
u[a].AUGUST_LONG,
|
|
222
|
+
u[a].SEPTEMBER_LONG,
|
|
223
|
+
u[a].OCTOBER_LONG,
|
|
224
|
+
u[a].NOVEMBER_LONG,
|
|
225
|
+
u[a].DECEMBER_LONG
|
|
226
226
|
];
|
|
227
|
-
},
|
|
227
|
+
}, O = function() {
|
|
228
228
|
return [
|
|
229
|
-
u[
|
|
230
|
-
u[
|
|
231
|
-
u[
|
|
232
|
-
u[
|
|
233
|
-
u[
|
|
234
|
-
u[
|
|
235
|
-
u[
|
|
236
|
-
u[
|
|
237
|
-
u[
|
|
238
|
-
u[
|
|
239
|
-
u[
|
|
240
|
-
u[
|
|
229
|
+
u[a].JANUARY_SHORT,
|
|
230
|
+
u[a].FEBRUARY_SHORT,
|
|
231
|
+
u[a].MARCH_SHORT,
|
|
232
|
+
u[a].APRIL_SHORT,
|
|
233
|
+
u[a].MAY_SHORT,
|
|
234
|
+
u[a].JUNE_SHORT,
|
|
235
|
+
u[a].JULY_SHORT,
|
|
236
|
+
u[a].AUGUST_SHORT,
|
|
237
|
+
u[a].SEPTEMBER_SHORT,
|
|
238
|
+
u[a].OCTOBER_SHORT,
|
|
239
|
+
u[a].NOVEMBER_SHORT,
|
|
240
|
+
u[a].DECEMBER_SHORT
|
|
241
241
|
];
|
|
242
|
-
},
|
|
242
|
+
}, R = function() {
|
|
243
243
|
return [
|
|
244
|
-
u[
|
|
245
|
-
u[
|
|
246
|
-
u[
|
|
247
|
-
u[
|
|
248
|
-
u[
|
|
249
|
-
u[
|
|
250
|
-
u[
|
|
244
|
+
u[a].SUNDAY_LONG,
|
|
245
|
+
u[a].MONDAY_LONG,
|
|
246
|
+
u[a].TUESDAY_LONG,
|
|
247
|
+
u[a].WEDNESDAY_LONG,
|
|
248
|
+
u[a].THURSDAY_LONG,
|
|
249
|
+
u[a].FRIDAY_LONG,
|
|
250
|
+
u[a].SATURDAY_LONG
|
|
251
251
|
];
|
|
252
|
-
},
|
|
252
|
+
}, G = function() {
|
|
253
253
|
return [
|
|
254
|
-
u[
|
|
255
|
-
u[
|
|
256
|
-
u[
|
|
257
|
-
u[
|
|
258
|
-
u[
|
|
259
|
-
u[
|
|
260
|
-
u[
|
|
254
|
+
u[a].SUNDAY_SHORT,
|
|
255
|
+
u[a].MONDAY_SHORT,
|
|
256
|
+
u[a].TUESDAY_SHORT,
|
|
257
|
+
u[a].WEDNESDAY_SHORT,
|
|
258
|
+
u[a].THURSDAY_SHORT,
|
|
259
|
+
u[a].FRIDAY_SHORT,
|
|
260
|
+
u[a].SATURDAY_SHORT
|
|
261
261
|
];
|
|
262
|
-
},
|
|
263
|
-
var
|
|
264
|
-
i.XMLHttpRequest ?
|
|
265
|
-
|
|
266
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(
|
|
267
|
-
},
|
|
268
|
-
},
|
|
262
|
+
}, P, H, I, M, q = function(t, n, c) {
|
|
263
|
+
var f;
|
|
264
|
+
i.XMLHttpRequest ? f = new XMLHttpRequest() : f = new ActiveXObject("Microsoft.XMLHTTP"), f.onreadystatechange = function() {
|
|
265
|
+
f.readyState === 4 && (f.status === 200 ? n && (i.JSON === r ? alert(`Please, include json2 into your project if you want use old browsers!
|
|
266
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(f.responseText))) : c && c(f));
|
|
267
|
+
}, f.open("GET", t, !1), f.send();
|
|
268
|
+
}, B = {
|
|
269
269
|
"%d": {
|
|
270
270
|
format: function(t) {
|
|
271
|
-
return A(t.day() ||
|
|
271
|
+
return A(t.day() || s.MIN_DAY, 2);
|
|
272
272
|
},
|
|
273
273
|
parse: function(t) {
|
|
274
274
|
var n = Number(t);
|
|
275
|
-
return { day: isNaN(n) ?
|
|
275
|
+
return { day: isNaN(n) ? r : n };
|
|
276
276
|
},
|
|
277
277
|
minLength: 2,
|
|
278
278
|
maxLength: 2,
|
|
@@ -280,11 +280,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
280
280
|
},
|
|
281
281
|
"%m": {
|
|
282
282
|
format: function(t) {
|
|
283
|
-
return A(t.month() ||
|
|
283
|
+
return A(t.month() || s.MIN_MONTH, 2);
|
|
284
284
|
},
|
|
285
285
|
parse: function(t) {
|
|
286
286
|
var n = Number(t);
|
|
287
|
-
return { month: isNaN(n) ?
|
|
287
|
+
return { month: isNaN(n) ? r : n };
|
|
288
288
|
},
|
|
289
289
|
minLength: 2,
|
|
290
290
|
maxLength: 2,
|
|
@@ -292,11 +292,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
292
292
|
},
|
|
293
293
|
"%Y": {
|
|
294
294
|
format: function(t) {
|
|
295
|
-
return A(t.year() ||
|
|
295
|
+
return A(t.year() || s.MIN_YEAR, 4);
|
|
296
296
|
},
|
|
297
297
|
parse: function(t) {
|
|
298
298
|
var n = Number(t);
|
|
299
|
-
return { year: isNaN(n) ?
|
|
299
|
+
return { year: isNaN(n) ? r : n };
|
|
300
300
|
},
|
|
301
301
|
minLength: 4,
|
|
302
302
|
maxLength: 4,
|
|
@@ -304,7 +304,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
304
304
|
},
|
|
305
305
|
"%w": {
|
|
306
306
|
format: function(t) {
|
|
307
|
-
return t.dayOfWeek() ||
|
|
307
|
+
return t.dayOfWeek() || s.MIN_DAY_OF_WEEK;
|
|
308
308
|
},
|
|
309
309
|
parse: function() {
|
|
310
310
|
return {};
|
|
@@ -316,7 +316,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
316
316
|
"%a": {
|
|
317
317
|
format: function(t) {
|
|
318
318
|
var n = t.dayOfWeek();
|
|
319
|
-
return M[n !==
|
|
319
|
+
return M[n !== r ? n : s.MIN_DAY_OF_WEEK];
|
|
320
320
|
},
|
|
321
321
|
parse: function() {
|
|
322
322
|
return {};
|
|
@@ -328,7 +328,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
328
328
|
"%A": {
|
|
329
329
|
format: function(t) {
|
|
330
330
|
var n = t.dayOfWeek();
|
|
331
|
-
return
|
|
331
|
+
return I[n !== r ? n : s.MIN_DAY_OF_WEEK];
|
|
332
332
|
},
|
|
333
333
|
parse: function() {
|
|
334
334
|
return {};
|
|
@@ -339,12 +339,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
339
339
|
},
|
|
340
340
|
"%b": {
|
|
341
341
|
format: function(t) {
|
|
342
|
-
var n =
|
|
343
|
-
return
|
|
342
|
+
var n = s.options("monthFromZero") ? t.month() : t.month() - 1;
|
|
343
|
+
return H[n !== r ? n : s.MIN_MONTH];
|
|
344
344
|
},
|
|
345
345
|
parse: function(t) {
|
|
346
|
-
var n =
|
|
347
|
-
return { month: n !== -1 ? n :
|
|
346
|
+
var n = s.monthNames().indexOf(t) + (s.options("monthFromZero") ? 0 : 1);
|
|
347
|
+
return { month: n !== -1 ? n : r };
|
|
348
348
|
},
|
|
349
349
|
minLength: 1,
|
|
350
350
|
maxLength: 999,
|
|
@@ -352,12 +352,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
352
352
|
},
|
|
353
353
|
"%B": {
|
|
354
354
|
format: function(t) {
|
|
355
|
-
var n =
|
|
356
|
-
return
|
|
355
|
+
var n = s.options("monthFromZero") ? t.month() : t.month() - 1;
|
|
356
|
+
return P[n !== r ? n : s.MIN_MONTH];
|
|
357
357
|
},
|
|
358
358
|
parse: function(t) {
|
|
359
|
-
var n =
|
|
360
|
-
return { month: n !== -1 ? n :
|
|
359
|
+
var n = s.monthNames(!0).indexOf(t) + (s.options("monthFromZero") ? 0 : 1);
|
|
360
|
+
return { month: n !== -1 ? n : r };
|
|
361
361
|
},
|
|
362
362
|
minLength: 1,
|
|
363
363
|
maxLength: 999,
|
|
@@ -365,11 +365,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
365
365
|
},
|
|
366
366
|
"%H": {
|
|
367
367
|
format: function(t) {
|
|
368
|
-
return A(t.hours() ||
|
|
368
|
+
return A(t.hours() || s.MIN_HOURS, 2);
|
|
369
369
|
},
|
|
370
370
|
parse: function(t) {
|
|
371
371
|
var n = Number(t);
|
|
372
|
-
return { hours: isNaN(n) ?
|
|
372
|
+
return { hours: isNaN(n) ? r : n };
|
|
373
373
|
},
|
|
374
374
|
minLength: 2,
|
|
375
375
|
maxLength: 2,
|
|
@@ -377,11 +377,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
377
377
|
},
|
|
378
378
|
"%M": {
|
|
379
379
|
format: function(t) {
|
|
380
|
-
return A(t.minutes() ||
|
|
380
|
+
return A(t.minutes() || s.MIN_MINUTES, 2);
|
|
381
381
|
},
|
|
382
382
|
parse: function(t) {
|
|
383
383
|
var n = Number(t);
|
|
384
|
-
return { minutes: isNaN(n) ?
|
|
384
|
+
return { minutes: isNaN(n) ? r : n };
|
|
385
385
|
},
|
|
386
386
|
minLength: 2,
|
|
387
387
|
maxLength: 2,
|
|
@@ -389,11 +389,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
389
389
|
},
|
|
390
390
|
"%S": {
|
|
391
391
|
format: function(t) {
|
|
392
|
-
return A(t.seconds() ||
|
|
392
|
+
return A(t.seconds() || s.MIN_SECONDS, 2);
|
|
393
393
|
},
|
|
394
394
|
parse: function(t) {
|
|
395
395
|
var n = Number(t);
|
|
396
|
-
return { seconds: isNaN(n) ?
|
|
396
|
+
return { seconds: isNaN(n) ? r : n };
|
|
397
397
|
},
|
|
398
398
|
minLength: 2,
|
|
399
399
|
maxLength: 2,
|
|
@@ -404,7 +404,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
404
404
|
return t.timestamp();
|
|
405
405
|
},
|
|
406
406
|
parse: function(t) {
|
|
407
|
-
return isNaN(Number(t)) ? {} :
|
|
407
|
+
return isNaN(Number(t)) ? {} : s(Number(t)).get();
|
|
408
408
|
},
|
|
409
409
|
minLength: 1,
|
|
410
410
|
maxLength: 20,
|
|
@@ -412,14 +412,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
412
412
|
},
|
|
413
413
|
"%F": {
|
|
414
414
|
format: function(t) {
|
|
415
|
-
return A(t.year() ||
|
|
415
|
+
return A(t.year() || s.MIN_YEAR, 4) + "-" + A(t.month() || s.MIN_MONTH, 2) + "-" + A(t.day() || s.MIN_DAY, 2);
|
|
416
416
|
},
|
|
417
417
|
parse: function(t) {
|
|
418
|
-
var n = Number(t.slice(0, 4)),
|
|
418
|
+
var n = Number(t.slice(0, 4)), c = Number(t.slice(5, 7)), f = Number(t.slice(8, 10));
|
|
419
419
|
return {
|
|
420
420
|
year: n,
|
|
421
|
-
month:
|
|
422
|
-
day:
|
|
421
|
+
month: c,
|
|
422
|
+
day: f
|
|
423
423
|
};
|
|
424
424
|
},
|
|
425
425
|
minLength: 10,
|
|
@@ -428,14 +428,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
428
428
|
},
|
|
429
429
|
"%D": {
|
|
430
430
|
format: function(t) {
|
|
431
|
-
return A(t.month() ||
|
|
431
|
+
return A(t.month() || s.MIN_MONTH, 2) + "/" + A(t.day() || s.MIN_DAY, 2) + "/" + A(t.year() || s.MIN_YEAR, 4);
|
|
432
432
|
},
|
|
433
433
|
parse: function(t) {
|
|
434
|
-
var n = Number(t.slice(0, 2)),
|
|
434
|
+
var n = Number(t.slice(0, 2)), c = Number(t.slice(3, 5)), f = Number(t.slice(6, 10));
|
|
435
435
|
return {
|
|
436
|
-
year:
|
|
436
|
+
year: f,
|
|
437
437
|
month: n,
|
|
438
|
-
day:
|
|
438
|
+
day: c
|
|
439
439
|
};
|
|
440
440
|
},
|
|
441
441
|
minLength: 10,
|
|
@@ -445,8 +445,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
445
445
|
}, tt = {
|
|
446
446
|
useMilliseconds: !1,
|
|
447
447
|
monthFromZero: !1
|
|
448
|
-
},
|
|
449
|
-
|
|
448
|
+
}, E;
|
|
449
|
+
E = function(t, n, c) {
|
|
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`) : n(JSON.pars
|
|
|
455
455
|
minutes: !1,
|
|
456
456
|
seconds: !1,
|
|
457
457
|
milliseconds: !1
|
|
458
|
-
}, t !==
|
|
459
|
-
},
|
|
460
|
-
var t = this.month(), n =
|
|
461
|
-
return this.leapYear() && t === (
|
|
462
|
-
},
|
|
458
|
+
}, t !== r && this.set(t, n, c), this;
|
|
459
|
+
}, E.fn = E.prototype, E.fn.dayCount = function() {
|
|
460
|
+
var t = this.month(), n = s.MAX_DAY_IN_MONTHS[t - (s.options("monthFromZero") ? 0 : 1)];
|
|
461
|
+
return this.leapYear() && t === (s.options("monthFromZero") ? 1 : 2) && (n += 1), n;
|
|
462
|
+
}, E.fn.year = function(t) {
|
|
463
463
|
if (arguments.length !== 0)
|
|
464
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
464
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_YEAR && Number(t) <= s.MAX_YEAR ? (this._d.setFullYear(Number(t)), this._i.year = !1) : this._i.year = Number(t) : (this._d.setFullYear(s.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
|
+
}, E.fn.month = function(t) {
|
|
469
469
|
if (arguments.length !== 0)
|
|
470
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
470
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MONTH && Number(t) <= s.MAX_MONTH ? (this._d.setMonth(s.options("monthFromZero") ? Number(t) : Number(t) - 1), this._i.month = !1) : this._i.month = Number(t) : (this._d.setMonth(s.options("monthFromZero") ? s.MIN_MONTH : s.MIN_MONTH - 1), this._i.month = !1);
|
|
471
471
|
else
|
|
472
|
-
return this._i.month === !1 ?
|
|
472
|
+
return this._i.month === !1 ? s.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
|
|
473
473
|
return this;
|
|
474
|
-
},
|
|
474
|
+
}, E.fn.day = function(t) {
|
|
475
475
|
if (arguments.length !== 0)
|
|
476
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
476
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_DAY && Number(t) <= this.dayCount() ? (this._d.setDate(Number(t)), this._i.day = !1) : this._i.day = Number(t) : (this._d.setDate(s.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
|
+
}, E.fn.hours = function(t) {
|
|
481
481
|
if (arguments.length !== 0)
|
|
482
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
482
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_HOURS && Number(t) <= s.MAX_HOURS ? (this._d.setHours(Number(t)), this._i.hours = !1) : this._i.hours = Number(t) : (this._d.setHours(s.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
|
+
}, E.fn.minutes = function(t) {
|
|
487
487
|
if (arguments.length !== 0)
|
|
488
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
488
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MINUTES && Number(t) <= s.MAX_MINUTES ? (this._d.setMinutes(Number(t)), this._i.minutes = !1) : this._i.minutes = Number(t) : (this._d.setMinutes(s.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
|
+
}, E.fn.seconds = function(t) {
|
|
493
493
|
if (arguments.length !== 0)
|
|
494
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
494
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_SECONDS && Number(t) <= s.MAX_SECONDS ? (this._d.setSeconds(Number(t)), this._i.seconds = !1) : this._i.seconds = Number(t) : (this._d.setSeconds(s.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
|
+
}, E.fn.milliseconds = function(t) {
|
|
499
499
|
if (arguments.length !== 0)
|
|
500
|
-
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >=
|
|
500
|
+
(typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= s.MIN_MILLISECONDS && Number(t) <= s.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(t)), this._i.milliseconds = !1) : this._i.milliseconds = Number(t) : (this._d.setMilliseconds(s.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 t = new Date(this.year(), 0, 1), n =
|
|
504
|
+
}, E.fn.week = function() {
|
|
505
|
+
var t = new Date(this.year(), 0, 1), n = s(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
|
|
506
506
|
return Math.ceil(((n - t.getTime()) / 864e5 + t.getDay() + 1) / 7);
|
|
507
|
-
},
|
|
507
|
+
}, E.fn.set = function(t, n, c) {
|
|
508
508
|
if (this._i = {
|
|
509
509
|
year: !1,
|
|
510
510
|
month: !1,
|
|
@@ -513,16 +513,16 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
513
513
|
minutes: !1,
|
|
514
514
|
seconds: !1,
|
|
515
515
|
milliseconds: !1
|
|
516
|
-
}, t ===
|
|
516
|
+
}, t === r)
|
|
517
517
|
return this._d = /* @__PURE__ */ new Date(), this;
|
|
518
518
|
if (t instanceof Date)
|
|
519
519
|
return this._d = t, this;
|
|
520
520
|
if (typeof t == "number")
|
|
521
|
-
return this._d = new Date(t * (
|
|
522
|
-
if (typeof t == "object" && (t instanceof Array ? (this.day(
|
|
523
|
-
var
|
|
524
|
-
if (t ===
|
|
525
|
-
return
|
|
521
|
+
return this._d = new Date(t * (s.options("useMilliseconds") ? 1 : 1e3)), this;
|
|
522
|
+
if (typeof t == "object" && (t instanceof Array ? (this.day(s.MIN_DAY), this.year(t[0]), this.month(t[1]), this.day(t[2]), this.hours(t[3]), this.minutes(t[4]), this.seconds(t[5]), this.milliseconds(t[6])) : (this.day(s.MIN_DAY), this.year(t.year), this.month(t.month), this.day(t.day), this.hours(t.hours), this.minutes(t.minutes), this.seconds(t.seconds), this.milliseconds(t.milliseconds))), typeof t == "string") {
|
|
523
|
+
var f, L = [], _, T, J = [], Y = 0, U = 0, b, W, D = {}, k;
|
|
524
|
+
if (t === r)
|
|
525
|
+
return _ = o(this, c), _ === r && (this._i = {
|
|
526
526
|
year: -1,
|
|
527
527
|
month: -1,
|
|
528
528
|
day: -1,
|
|
@@ -530,26 +530,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
530
530
|
minutes: -1,
|
|
531
531
|
seconds: -1,
|
|
532
532
|
milliseconds: -1
|
|
533
|
-
}),
|
|
534
|
-
for (n ===
|
|
535
|
-
if (n.charAt(
|
|
536
|
-
if (
|
|
537
|
-
switch (
|
|
533
|
+
}), _;
|
|
534
|
+
for (n === r && (n = s.detectFormat(t)); Y < n.length; ) {
|
|
535
|
+
if (n.charAt(Y) === "%") {
|
|
536
|
+
if (T = n.charAt(Y) + n.charAt(Y + 1), B[T] !== r) {
|
|
537
|
+
switch (b = 0, W = "", B[T].type) {
|
|
538
538
|
case "number":
|
|
539
|
-
for (;
|
|
540
|
-
|
|
539
|
+
for (; b < B[T].maxLength && U + b < t.length && !isNaN(Number(t.charAt(U + b))); )
|
|
540
|
+
W += t.charAt(U + b), b += 1;
|
|
541
541
|
break;
|
|
542
542
|
case "word":
|
|
543
|
-
for (;
|
|
544
|
-
|
|
543
|
+
for (; b < B[T].maxLength && U + b < t.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(U + b)); )
|
|
544
|
+
W += t.charAt(U + b), b += 1;
|
|
545
545
|
break;
|
|
546
546
|
case "string":
|
|
547
|
-
for (;
|
|
548
|
-
|
|
547
|
+
for (; b < B[T].maxLength && U + b < t.length; )
|
|
548
|
+
W += t.charAt(U + b), b += 1;
|
|
549
549
|
break;
|
|
550
550
|
}
|
|
551
|
-
if (
|
|
552
|
-
return
|
|
551
|
+
if (b < B[T].minLength)
|
|
552
|
+
return _ = o(this, c), _ === r && (this._i = {
|
|
553
553
|
year: -1,
|
|
554
554
|
month: -1,
|
|
555
555
|
day: -1,
|
|
@@ -557,11 +557,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
557
557
|
minutes: -1,
|
|
558
558
|
seconds: -1,
|
|
559
559
|
milliseconds: -1
|
|
560
|
-
}),
|
|
561
|
-
|
|
560
|
+
}), _;
|
|
561
|
+
L.push(T), J.push(W), b -= 1, U += b, Y += 1;
|
|
562
562
|
}
|
|
563
|
-
} else if (t.charAt(
|
|
564
|
-
return
|
|
563
|
+
} else if (t.charAt(U) !== n.charAt(Y))
|
|
564
|
+
return _ = o(this, c), _ === r && (this._i = {
|
|
565
565
|
year: -1,
|
|
566
566
|
month: -1,
|
|
567
567
|
day: -1,
|
|
@@ -569,34 +569,34 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
569
569
|
minutes: -1,
|
|
570
570
|
seconds: -1,
|
|
571
571
|
milliseconds: -1
|
|
572
|
-
}),
|
|
573
|
-
|
|
572
|
+
}), _;
|
|
573
|
+
Y += 1, U += 1;
|
|
574
574
|
}
|
|
575
|
-
for (
|
|
576
|
-
|
|
577
|
-
year:
|
|
578
|
-
month:
|
|
579
|
-
day:
|
|
580
|
-
hours:
|
|
581
|
-
minutes:
|
|
582
|
-
seconds:
|
|
575
|
+
for (f in L)
|
|
576
|
+
L.hasOwnProperty(f) && B.hasOwnProperty(L[f]) && (k = B[L[f]].parse(J[f]), D = {
|
|
577
|
+
year: k.year !== r ? k.year : D.year,
|
|
578
|
+
month: k.month !== r ? k.month : D.month,
|
|
579
|
+
day: k.day !== r ? k.day : D.day,
|
|
580
|
+
hours: k.hours !== r ? k.hours : D.hours,
|
|
581
|
+
minutes: k.minutes !== r ? k.minutes : D.minutes,
|
|
582
|
+
seconds: k.seconds !== r ? k.seconds : D.seconds
|
|
583
583
|
});
|
|
584
|
-
this.day(
|
|
584
|
+
this.day(s.MIN_DAY), this.year(D.year), this.month(D.month), this.day(D.day), this.hours(D.hours), this.minutes(D.minutes), this.seconds(D.seconds), this.milliseconds(D.milliseconds);
|
|
585
585
|
}
|
|
586
586
|
return this;
|
|
587
|
-
},
|
|
587
|
+
}, E.fn.leapYear = function() {
|
|
588
588
|
var t = this.year();
|
|
589
589
|
return t % 4 === 0 ? t % 100 === 0 ? t % 400 === 0 : !0 : !1;
|
|
590
|
-
},
|
|
591
|
-
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (
|
|
592
|
-
},
|
|
593
|
-
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (
|
|
594
|
-
},
|
|
590
|
+
}, E.fn.timestamp = function(t) {
|
|
591
|
+
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (s.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : s.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
|
|
592
|
+
}, E.fn.utc = function(t) {
|
|
593
|
+
return arguments.length !== 0 ? (this._d = new Date(Number(t) * (s.options("useMilliseconds") ? 1 : 1e3)), this) : s.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
|
|
594
|
+
}, E.fn.dayOfWeek = function(t) {
|
|
595
595
|
if (t === "long")
|
|
596
|
-
return
|
|
596
|
+
return I[this._d.getDay()];
|
|
597
597
|
if (t === "short")
|
|
598
598
|
return M[this._d.getDay()];
|
|
599
|
-
if (t ===
|
|
599
|
+
if (t === r)
|
|
600
600
|
return this._d.getDay();
|
|
601
601
|
if (t === 0 || t === "Sunday")
|
|
602
602
|
return this.calc({ day: -this.dayOfWeek() });
|
|
@@ -612,7 +612,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
612
612
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
|
|
613
613
|
if (t === 6 || t === "Saturday")
|
|
614
614
|
return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
|
|
615
|
-
},
|
|
615
|
+
}, E.fn.timezone = function(t) {
|
|
616
616
|
switch (t) {
|
|
617
617
|
case "hours":
|
|
618
618
|
return Math.floor(this._d.getTimezoneOffset() / 60);
|
|
@@ -621,12 +621,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
621
621
|
default:
|
|
622
622
|
return this._d.getTimezoneOffset() * 60;
|
|
623
623
|
}
|
|
624
|
-
},
|
|
624
|
+
}, E.fn.get = function(t) {
|
|
625
625
|
switch (t) {
|
|
626
626
|
case "Date":
|
|
627
627
|
return new Date(
|
|
628
628
|
this.year(),
|
|
629
|
-
this.month() - (
|
|
629
|
+
this.month() - (s.options("monthFromZero") ? 0 : 1),
|
|
630
630
|
this.day(),
|
|
631
631
|
this.hours(),
|
|
632
632
|
this.minutes(),
|
|
@@ -636,7 +636,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
636
636
|
case "DateUTC":
|
|
637
637
|
return new Date(Date.UTC(
|
|
638
638
|
this.year(),
|
|
639
|
-
this.month() - (
|
|
639
|
+
this.month() - (s.options("monthFromZero") ? 0 : 1),
|
|
640
640
|
this.day(),
|
|
641
641
|
this.hours(),
|
|
642
642
|
this.minutes(),
|
|
@@ -670,144 +670,144 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
|
|
|
670
670
|
timestamp: this.timestamp()
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
},
|
|
674
|
-
for (var n = 0,
|
|
675
|
-
t.charAt(n) === "%" ? (
|
|
676
|
-
return
|
|
677
|
-
},
|
|
673
|
+
}, E.fn.format = function(t) {
|
|
674
|
+
for (var n = 0, c = "", f; n < t.length; )
|
|
675
|
+
t.charAt(n) === "%" ? (f = t.charAt(n) + t.charAt(n + 1), B[f] !== r ? (c += B[f].format(this), n += 1) : c += "%") : c += t.charAt(n), n += 1;
|
|
676
|
+
return c;
|
|
677
|
+
}, E.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
|
+
}, E.fn.errors = function() {
|
|
680
680
|
return this._i;
|
|
681
|
-
},
|
|
682
|
-
var
|
|
681
|
+
}, E.fn.between = function(t, n) {
|
|
682
|
+
var c = this.timestamp(), f = t.timestamp();
|
|
683
683
|
switch (n) {
|
|
684
684
|
case "year":
|
|
685
|
-
return Math.floor((
|
|
685
|
+
return Math.floor((f - c) / 31556952);
|
|
686
686
|
case "month":
|
|
687
|
-
return Math.floor((
|
|
687
|
+
return Math.floor((f - c) / 2629746);
|
|
688
688
|
case "day":
|
|
689
|
-
return Math.floor((
|
|
689
|
+
return Math.floor((f - c) / 86400);
|
|
690
690
|
case "hours":
|
|
691
|
-
return Math.floor((
|
|
691
|
+
return Math.floor((f - c) / 3600);
|
|
692
692
|
case "minutes":
|
|
693
|
-
return Math.floor((
|
|
693
|
+
return Math.floor((f - c) / 60);
|
|
694
694
|
case "seconds":
|
|
695
|
-
return
|
|
695
|
+
return f - c;
|
|
696
696
|
default:
|
|
697
|
-
return
|
|
697
|
+
return r;
|
|
698
698
|
}
|
|
699
|
-
},
|
|
700
|
-
return t.year !==
|
|
701
|
-
},
|
|
702
|
-
return new
|
|
703
|
-
},
|
|
704
|
-
if (t ===
|
|
699
|
+
}, E.fn.calc = function(t) {
|
|
700
|
+
return t.year !== r && this._d.setFullYear(this._d.getFullYear() + t.year), t.month !== r && this._d.setMonth(this._d.getMonth() + t.month), t.day !== r && this._d.setDate(this._d.getDate() + t.day), t.hours !== r && this._d.setHours(this._d.getHours() + t.hours), t.minutes !== r && this._d.setMinutes(this._d.getMinutes() + t.minutes), t.seconds !== r && this._d.setSeconds(this._d.getSeconds() + t.seconds), t.milliseconds !== r && this._d.setMilliseconds(this._d.getMilliseconds() + t.milliseconds), this;
|
|
701
|
+
}, s = function(t, n, c) {
|
|
702
|
+
return new E(t, n, c);
|
|
703
|
+
}, s.MIN_YEAR = 1e3, s.MAX_YEAR = 3e3, s.MIN_MONTH = 1, s.MAX_MONTH = 12, s.MIN_DAY = 1, s.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], s.MIN_DAY_OF_WEEK = 0, s.MAX_DAY_OF_WEEK = 6, s.MIN_HOURS = 0, s.MAX_HOURS = 23, s.MIN_MINUTES = 0, s.MAX_MINUTES = 59, s.MIN_SECONDS = 0, s.MAX_SECONDS = 59, s.MIN_MILLISECONDS = 0, s.MAX_MILLISECONDS = 999, s.VERSION = "0.2.18", s.options = function(t, n) {
|
|
704
|
+
if (t === r)
|
|
705
705
|
return tt;
|
|
706
706
|
if (tt.hasOwnProperty(t)) {
|
|
707
|
-
if (n ===
|
|
707
|
+
if (n === r)
|
|
708
708
|
return tt[t];
|
|
709
|
-
tt[t] = n, t === "monthFromZero" && (
|
|
709
|
+
tt[t] = n, t === "monthFromZero" && (s.MIN_MONTH = n ? 0 : 1, s.MAX_MONTH = n ? 11 : 12);
|
|
710
710
|
}
|
|
711
|
-
return
|
|
712
|
-
},
|
|
713
|
-
return i.tempus =
|
|
714
|
-
},
|
|
715
|
-
var n,
|
|
716
|
-
if (typeof t.dateFrom != "number" && (t.dateFrom instanceof
|
|
711
|
+
return r;
|
|
712
|
+
}, s.noConflict = function() {
|
|
713
|
+
return i.tempus = l, s;
|
|
714
|
+
}, s.generate = function(t) {
|
|
715
|
+
var n, c, f, L, _, T, J, Y;
|
|
716
|
+
if (typeof t.dateFrom != "number" && (t.dateFrom instanceof E ? n = t.dateFrom.utc() : n = s(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof E ? c = t.dateTo.utc() : c = s(t.dateTo, t.formatTo !== r ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? _ = {
|
|
717
717
|
year: 0,
|
|
718
718
|
month: 0,
|
|
719
719
|
day: 0,
|
|
720
720
|
hours: 0,
|
|
721
721
|
minutes: 0,
|
|
722
722
|
seconds: t.period
|
|
723
|
-
} : typeof t.period == "string" ?
|
|
723
|
+
} : typeof t.period == "string" ? _ = {
|
|
724
724
|
year: t.period === "year" ? 1 : 0,
|
|
725
725
|
month: t.period === "month" ? 1 : 0,
|
|
726
726
|
day: t.period === "day" ? 1 : 0,
|
|
727
727
|
hours: t.period === "hours" ? 1 : 0,
|
|
728
728
|
minutes: t.period === "minutes" ? 1 : 0,
|
|
729
729
|
seconds: t.period === "seconds" ? 1 : 0
|
|
730
|
-
} : typeof t.period == "object" && (
|
|
731
|
-
year: t.period.year !==
|
|
732
|
-
month: t.period.month !==
|
|
733
|
-
day: t.period.day !==
|
|
734
|
-
hours: t.period.hours !==
|
|
735
|
-
minutes: t.period.minutes !==
|
|
736
|
-
seconds: t.period.seconds !==
|
|
737
|
-
}), t.groupBy ===
|
|
738
|
-
return t.asObject === !0 ? t.format !==
|
|
739
|
-
}, t.groupBy !==
|
|
740
|
-
var
|
|
741
|
-
year:
|
|
742
|
-
month:
|
|
743
|
-
day:
|
|
744
|
-
hours:
|
|
745
|
-
minutes:
|
|
746
|
-
seconds:
|
|
747
|
-
milliseconds:
|
|
730
|
+
} : typeof t.period == "object" && (_ = {
|
|
731
|
+
year: t.period.year !== r ? t.period.year : 0,
|
|
732
|
+
month: t.period.month !== r ? t.period.month : 0,
|
|
733
|
+
day: t.period.day !== r ? t.period.day : 0,
|
|
734
|
+
hours: t.period.hours !== r ? t.period.hours : 0,
|
|
735
|
+
minutes: t.period.minutes !== r ? t.period.minutes : 0,
|
|
736
|
+
seconds: t.period.seconds !== r ? t.period.seconds : 0
|
|
737
|
+
}), t.groupBy === r ? T = t.asObject === !0 ? {} : [] : (T = [], T.push([]), J = s(n).get()[t.groupBy]), Y = function(W, D, k) {
|
|
738
|
+
return t.asObject === !0 ? t.format !== r ? W[s(D).format(t.format)] = {} : W[s(D).format("%F %H:%M:%S")] = {} : t.format !== r ? W.push(k ? null : s(D).format(t.format)) : W.push(k ? null : s(D)), W;
|
|
739
|
+
}, t.groupBy !== r && t.fillNulls) {
|
|
740
|
+
var U = {
|
|
741
|
+
year: _.year ? -_.year : r,
|
|
742
|
+
month: _.month ? -_.month : r,
|
|
743
|
+
day: _.day ? -_.day : r,
|
|
744
|
+
hours: _.hours ? -_.hours : r,
|
|
745
|
+
minutes: _.minutes ? -_.minutes : r,
|
|
746
|
+
seconds: _.seconds ? -_.seconds : r,
|
|
747
|
+
milliseconds: _.milliseconds ? -_.milliseconds : r
|
|
748
748
|
};
|
|
749
|
-
for (
|
|
750
|
-
|
|
749
|
+
for (f = s(n).calc(U).utc(); s(f).get()[t.groupBy] === J; )
|
|
750
|
+
Y(T[T.length - 1], f, !0), f = s(f).calc(U).utc();
|
|
751
751
|
if (t.groupBy === "week") {
|
|
752
|
-
var
|
|
753
|
-
for (
|
|
754
|
-
|
|
752
|
+
var b = s(n).dayOfWeek();
|
|
753
|
+
for (f = s(n).dayOfWeek(0).utc(); T[0].length < b && f < n; )
|
|
754
|
+
Y(T[T.length - 1], f, !0), f = s(f).calc(_).utc();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
for (; n <=
|
|
758
|
-
t.groupBy ===
|
|
759
|
-
if (t.groupBy !==
|
|
760
|
-
for (
|
|
761
|
-
|
|
762
|
-
return
|
|
763
|
-
},
|
|
757
|
+
for (; n <= c; )
|
|
758
|
+
t.groupBy === r ? Y(T, n) : s(n).get()[t.groupBy] === J ? Y(T[T.length - 1], n) : (T.push([]), Y(T[T.length - 1], n), J = s(n).get()[t.groupBy]), n = s(n).calc(_).utc();
|
|
759
|
+
if (t.groupBy !== r && t.fillNulls)
|
|
760
|
+
for (L = s(c).calc(_).utc(); s(L).get()[t.groupBy] === J; )
|
|
761
|
+
Y(T[T.length - 1], L, !0), L = s(L).calc(_).utc();
|
|
762
|
+
return T;
|
|
763
|
+
}, s.monthNames = function(t) {
|
|
764
764
|
switch (t) {
|
|
765
765
|
case "long":
|
|
766
|
-
return
|
|
766
|
+
return P;
|
|
767
767
|
default:
|
|
768
|
-
return
|
|
768
|
+
return H;
|
|
769
769
|
}
|
|
770
|
-
},
|
|
770
|
+
}, s.dayNames = function(t) {
|
|
771
771
|
switch (t) {
|
|
772
772
|
case "long":
|
|
773
|
-
return
|
|
773
|
+
return I;
|
|
774
774
|
default:
|
|
775
775
|
return M;
|
|
776
776
|
}
|
|
777
|
-
},
|
|
778
|
-
if (t !==
|
|
779
|
-
|
|
777
|
+
}, s.lang = function(t) {
|
|
778
|
+
if (t !== r)
|
|
779
|
+
a = t, u[a] === r && (a = "en"), P = y(), H = O(), I = R(), M = G();
|
|
780
780
|
else
|
|
781
|
-
return
|
|
782
|
-
return
|
|
783
|
-
},
|
|
781
|
+
return a;
|
|
782
|
+
return r;
|
|
783
|
+
}, s.availableLangs = function() {
|
|
784
784
|
return Object.keys(u);
|
|
785
|
-
},
|
|
786
|
-
|
|
785
|
+
}, s.registerFormat = function(t, n, c, f, L, _) {
|
|
786
|
+
B[t] = {
|
|
787
787
|
format: n,
|
|
788
|
-
parse:
|
|
789
|
-
minLength:
|
|
790
|
-
maxLength:
|
|
791
|
-
type:
|
|
788
|
+
parse: c,
|
|
789
|
+
minLength: f,
|
|
790
|
+
maxLength: L,
|
|
791
|
+
type: _
|
|
792
792
|
};
|
|
793
|
-
},
|
|
794
|
-
delete
|
|
795
|
-
},
|
|
796
|
-
var n,
|
|
797
|
-
return n = m(t, 0), n !== "" && (
|
|
793
|
+
}, s.unregisterFormat = function(t) {
|
|
794
|
+
delete B[t];
|
|
795
|
+
}, s.detectFormat = function(t) {
|
|
796
|
+
var n, c, f;
|
|
797
|
+
return n = m(t, 0), n !== "" && (f = 10), c = t.charAt(f), (c === "T" || c === " ") && (n += c, f += 1), n += h(t, f), n;
|
|
798
798
|
}, d = {
|
|
799
|
-
TempusDate:
|
|
800
|
-
},
|
|
801
|
-
if (n ===
|
|
799
|
+
TempusDate: E
|
|
800
|
+
}, s.classes = function(t, n) {
|
|
801
|
+
if (n === r)
|
|
802
802
|
return d[t];
|
|
803
803
|
d[t] = n;
|
|
804
|
-
},
|
|
804
|
+
}, s.loadTranslations = function(t) {
|
|
805
805
|
typeof t == "object" ? u = t : typeof t == "string" && q(t, function(n) {
|
|
806
806
|
u = n;
|
|
807
807
|
}, function(n) {
|
|
808
808
|
});
|
|
809
|
-
},
|
|
810
|
-
}).call(
|
|
809
|
+
}, a = (g.language || g.systemLanguage || g.userLanguage || "en").substr(0, 2).toLowerCase(), u[a] === r && (a = "en"), P = y(), H = O(), I = R(), M = G(), N.exports && (e = N.exports = s), e.tempus = s;
|
|
810
|
+
}).call(yt);
|
|
811
811
|
})(lt, lt.exports);
|
|
812
812
|
var Tt = lt.exports;
|
|
813
813
|
const et = /* @__PURE__ */ Et(Tt);
|
|
@@ -831,11 +831,11 @@ class j {
|
|
|
831
831
|
let e = 0;
|
|
832
832
|
if (!this.progressData)
|
|
833
833
|
return { percent: Math.round(e), allCount: 0, allTotal: 0 };
|
|
834
|
-
let
|
|
834
|
+
let r = 0, i = 0;
|
|
835
835
|
return Object.values(this.progressData).forEach((A) => {
|
|
836
|
-
const { total:
|
|
837
|
-
|
|
838
|
-
}),
|
|
836
|
+
const { total: o, count: h } = A;
|
|
837
|
+
r += o ?? 0, i += h ?? 0;
|
|
838
|
+
}), r ? e = i / r * 100 * this.chunkRate + this.totalProgress : i === 0 && r === 0 ? e = 100 * this.chunkRate + this.totalProgress : e = 100, { percent: Math.round(e), allCount: i, allTotal: r };
|
|
839
839
|
}
|
|
840
840
|
/**
|
|
841
841
|
* Обновление данных прогресса выполнения
|
|
@@ -844,19 +844,19 @@ class j {
|
|
|
844
844
|
* @param {Object} params.value - Значение ответа от API
|
|
845
845
|
* @param {string} params.type - Тип обработки ('count' или undefined)
|
|
846
846
|
*/
|
|
847
|
-
setProgressData({ key: e, value:
|
|
848
|
-
const A = this.getData(
|
|
849
|
-
let h =
|
|
850
|
-
i === "count" && (h =
|
|
847
|
+
setProgressData({ key: e, value: r, type: i }) {
|
|
848
|
+
const A = this.getData(r.data()), o = Array.isArray(A) ? A.length : 0;
|
|
849
|
+
let h = r.total() || o;
|
|
850
|
+
i === "count" && (h = o);
|
|
851
851
|
let m = 1;
|
|
852
|
-
A && (m =
|
|
853
|
-
const { percent:
|
|
852
|
+
A && (m = o), this.progressCall && (this.progressData || (this.progressData = {}), this.progressData[e] && this.progressData[e].count && (m += this.progressData[e].count), this.progressData[e] ? this.progressData[e].count = m : this.progressData[e] = { total: h, count: m }, this.progressTimer || (this.progressTimer = setInterval(() => {
|
|
853
|
+
const { percent: l, allCount: s, allTotal: d } = this.progressPercent;
|
|
854
854
|
(this.oldPercent === "no" || this.oldPercent < this.progressPercent.percent) && (this.progressCall({
|
|
855
855
|
data: this.progressData,
|
|
856
|
-
percent:
|
|
857
|
-
allCount:
|
|
856
|
+
percent: l,
|
|
857
|
+
allCount: s,
|
|
858
858
|
allTotal: d
|
|
859
|
-
}), this.oldPercent = this.progressPercent.percent),
|
|
859
|
+
}), this.oldPercent = this.progressPercent.percent), l >= 100 && this.clearProgressData();
|
|
860
860
|
}, this.progressDelay)));
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
@@ -883,26 +883,26 @@ class j {
|
|
|
883
883
|
* @param {Function} progressCall - Функция получающая данные выполнения батча
|
|
884
884
|
* @returns {Promise}
|
|
885
885
|
*/
|
|
886
|
-
async batch(e,
|
|
887
|
-
this.progressTimer && this.clearProgressData(),
|
|
886
|
+
async batch(e, r, i) {
|
|
887
|
+
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
888
888
|
const A = {};
|
|
889
889
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
890
|
-
let
|
|
891
|
-
for (const [m,
|
|
890
|
+
let o = {}, h = 0;
|
|
891
|
+
for (const [m, l] of Object.entries(e)) {
|
|
892
892
|
if (!this.canContinue)
|
|
893
893
|
break;
|
|
894
|
-
const
|
|
895
|
-
if (!
|
|
894
|
+
const s = this.arrayChunk(l);
|
|
895
|
+
if (!s) {
|
|
896
896
|
h++;
|
|
897
897
|
continue;
|
|
898
898
|
}
|
|
899
|
-
|
|
900
|
-
A[d] =
|
|
899
|
+
o[m] = s, (Object.keys(o).length >= 50 || h + 1 === Object.keys(e).length) && (await this.batchChunk(o), Object.entries(this.result).forEach(([d, g]) => {
|
|
900
|
+
A[d] = g;
|
|
901
901
|
}), this.totalProgress = Math.round(
|
|
902
902
|
h / Object.keys(e).length * 100
|
|
903
|
-
),
|
|
903
|
+
), o = {}), h++;
|
|
904
904
|
}
|
|
905
|
-
return Object.entries(this.errors).length && (A.errorsList = this.errors),
|
|
905
|
+
return Object.entries(this.errors).length && (A.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(A);
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
908
908
|
* Аналогично this.batch, но возвращает количество элементов
|
|
@@ -914,26 +914,26 @@ class j {
|
|
|
914
914
|
* @param {Function} limitCall - Callback при превышении лимитов
|
|
915
915
|
* @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
|
|
916
916
|
*/
|
|
917
|
-
async batchTotalCount(e,
|
|
918
|
-
this.progressTimer && this.clearProgressData(),
|
|
917
|
+
async batchTotalCount(e, r, i) {
|
|
918
|
+
this.progressTimer && this.clearProgressData(), r && (this.progressCall = r), i && (this.limitCall = i), this.canContinue = !0, this.result = {}, this.errors = {};
|
|
919
919
|
const A = {};
|
|
920
920
|
this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
|
|
921
|
-
let
|
|
922
|
-
for (const [m,
|
|
921
|
+
let o = {}, h = 0;
|
|
922
|
+
for (const [m, l] of Object.entries(e)) {
|
|
923
923
|
if (!this.canContinue)
|
|
924
924
|
break;
|
|
925
|
-
const
|
|
926
|
-
if (!
|
|
925
|
+
const s = this.arrayChunk(l);
|
|
926
|
+
if (!s) {
|
|
927
927
|
h++;
|
|
928
928
|
continue;
|
|
929
929
|
}
|
|
930
|
-
|
|
931
|
-
A[d] =
|
|
930
|
+
o[m] = s, (Object.keys(o).length >= 50 || h + 1 === Object.keys(e).length) && (await this.batchChunk(o, "count"), Object.entries(this.result).forEach(([d, g]) => {
|
|
931
|
+
A[d] = g;
|
|
932
932
|
}), this.totalProgress = Math.round(
|
|
933
933
|
h / Object.keys(e).length * 100
|
|
934
|
-
),
|
|
934
|
+
), o = {}), h++;
|
|
935
935
|
}
|
|
936
|
-
return Object.entries(this.errors).length && (A.errorsList = this.errors),
|
|
936
|
+
return Object.entries(this.errors).length && (A.errorsList = this.errors), r && r({ percent: 100 }), Promise.resolve(A);
|
|
937
937
|
}
|
|
938
938
|
/** Валидация запросов
|
|
939
939
|
* Чтобы не перегружать Битрикс сервера запросами с start - добавляем нужные поля в параметры
|
|
@@ -941,32 +941,32 @@ class j {
|
|
|
941
941
|
* @param {Array/Object} request - Массив/объект методов
|
|
942
942
|
*/
|
|
943
943
|
arrayChunk(e) {
|
|
944
|
-
let
|
|
945
|
-
if (Array.isArray(e) ? [
|
|
944
|
+
let r = "", i = {};
|
|
945
|
+
if (Array.isArray(e) ? [r] = e : (r = e.method, i = e.params), this.skipList.has(r))
|
|
946
946
|
return !1;
|
|
947
|
-
if ((
|
|
947
|
+
if ((r.includes("list") || r === "user.get") && r !== "task.item.list") {
|
|
948
948
|
if (!i)
|
|
949
949
|
i = {
|
|
950
950
|
order: { ID: "ASC", id: "ASC" }
|
|
951
951
|
};
|
|
952
952
|
else {
|
|
953
|
-
|
|
954
|
-
const A =
|
|
955
|
-
typeof A == "object" && A !== null && !Array.isArray(A) && Object.entries(A).forEach(([
|
|
956
|
-
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(
|
|
953
|
+
r === "tasks.task.list" ? (i.order || (i.order = {}), i.order.ID = "asc") : r === "user.get" ? (i.sort || (i.sort = "ID"), i.order || (i.order = "ASC")) : i.order = { ID: "ASC", id: "ASC" }, Array.isArray(i.select) && !i.select.includes("ID") && i.select.push("ID");
|
|
954
|
+
const A = r === "user.get" ? i.FILTER : i.filter;
|
|
955
|
+
typeof A == "object" && A !== null && !Array.isArray(A) && Object.entries(A).forEach(([o, h]) => {
|
|
956
|
+
(i.start === void 0 || i.start !== -1) && ["id", "ID"].includes(o) && (typeof h == "string" || Array.isArray(h) && h.length <= 50) && (i.start = -1);
|
|
957
957
|
});
|
|
958
958
|
}
|
|
959
|
-
|
|
959
|
+
r === "crm.type.list" && i.order && delete i.order.ID;
|
|
960
960
|
}
|
|
961
|
-
if (
|
|
961
|
+
if (r === "task.item.list")
|
|
962
962
|
if (!i)
|
|
963
963
|
i = [{ ID: "ASC" }, [""], [""], ["ID"]];
|
|
964
964
|
else {
|
|
965
965
|
Array.isArray(i[0]) && (i[0] = {});
|
|
966
|
-
const [A,
|
|
966
|
+
const [A, o, h, m] = i;
|
|
967
967
|
A.ID = "ASC", m[0] !== "" && m.includes("ID") || m.push("ID");
|
|
968
968
|
}
|
|
969
|
-
return { method:
|
|
969
|
+
return { method: r, params: i };
|
|
970
970
|
}
|
|
971
971
|
/** Выполняет первичный запрос с массивом методов
|
|
972
972
|
* При наличии более 50 элементов в нем, подготоваливаем данные и передаем в this.batchPayload
|
|
@@ -974,43 +974,43 @@ class j {
|
|
|
974
974
|
* @param {Array} query - Тот же массив с методами
|
|
975
975
|
* @returns {Object} Объект с результатами запросов
|
|
976
976
|
*/
|
|
977
|
-
async batchChunk(e,
|
|
977
|
+
async batchChunk(e, r) {
|
|
978
978
|
return new Promise((i) => {
|
|
979
979
|
const A = [];
|
|
980
|
-
let
|
|
980
|
+
let o;
|
|
981
981
|
this.callBatch(e, async (h) => {
|
|
982
|
-
var m,
|
|
983
|
-
for (const [
|
|
982
|
+
var m, l, s, d, g, a, u;
|
|
983
|
+
for (const [y, O] of Object.entries(h)) {
|
|
984
984
|
if (!this.canContinue)
|
|
985
985
|
return;
|
|
986
|
-
if (
|
|
987
|
-
switch (this.errors[
|
|
986
|
+
if (O.error())
|
|
987
|
+
switch (this.errors[y] = ((l = (m = O.error()) == null ? void 0 : m.ex) == null ? void 0 : l.error) ?? ((d = (s = O.error()) == null ? void 0 : s.ex) == null ? void 0 : d.error_description) ?? ((g = O.error()) == null ? void 0 : g.toString()) ?? "Неизвестная ошибка", o = !0, ((u = (a = O.error()) == null ? void 0 : a.ex) == null ? void 0 : u.error) ?? "") {
|
|
988
988
|
case "OPERATION_TIME_LIMIT":
|
|
989
|
-
this.skipList.add(e[
|
|
989
|
+
this.skipList.add(e[y].method), this.limitCall && this.limitCall(y);
|
|
990
990
|
break;
|
|
991
991
|
case "QUERY_LIMIT_EXCEEDED":
|
|
992
992
|
this.canContinue = !1;
|
|
993
993
|
break;
|
|
994
994
|
case "ACCESS_DENIED":
|
|
995
|
-
this.skipList.add(e[
|
|
995
|
+
this.skipList.add(e[y].method);
|
|
996
996
|
break;
|
|
997
997
|
}
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
const
|
|
1001
|
-
if (!this.canContinue ||
|
|
1002
|
-
let M = e[
|
|
998
|
+
const R = this.getData(O.data()), G = Array.isArray(R) ? R.length : 0, P = typeof O.total == "function" && O.total() !== void 0, H = P ? O.total() : G;
|
|
999
|
+
r === "count" ? this.result[y] ? this.result[y] += G : this.result[y] = H : this.result[y] = R, this.setProgressData({ key: y, value: O, type: r });
|
|
1000
|
+
const I = r === "count" ? !P && G === this.limit : H > this.limit && H > G;
|
|
1001
|
+
if (!this.canContinue || I) {
|
|
1002
|
+
let M = e[y];
|
|
1003
1003
|
if (Array.isArray(M)) {
|
|
1004
|
-
const [q,
|
|
1005
|
-
M = [q,
|
|
1004
|
+
const [q, B = {}] = M;
|
|
1005
|
+
M = [q, B];
|
|
1006
1006
|
} else {
|
|
1007
|
-
const { method: q, params:
|
|
1008
|
-
M = [q,
|
|
1007
|
+
const { method: q, params: B = {} } = M;
|
|
1008
|
+
M = [q, B];
|
|
1009
1009
|
}
|
|
1010
|
-
A.push([
|
|
1010
|
+
A.push([y, M, H]);
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
|
|
1013
|
+
o > 0 && this.errorLogger(), A.length ? await this.batchPayload(A, r).then(
|
|
1014
1014
|
() => i(this.result)
|
|
1015
1015
|
) : i(this.result);
|
|
1016
1016
|
});
|
|
@@ -1020,47 +1020,47 @@ class j {
|
|
|
1020
1020
|
* @param {Array} payloadList - Массив с подмассивами списочных методов
|
|
1021
1021
|
* @param {String} type - Тип обработки результатов ('count' или undefined)
|
|
1022
1022
|
*/
|
|
1023
|
-
async batchPayload(e,
|
|
1024
|
-
const i = /* @__PURE__ */ new Map(), A = (
|
|
1025
|
-
let
|
|
1026
|
-
this.result[
|
|
1027
|
-
let u = `${
|
|
1028
|
-
if (JSON.stringify(
|
|
1023
|
+
async batchPayload(e, r) {
|
|
1024
|
+
const i = /* @__PURE__ */ new Map(), A = (l, s, d, g) => {
|
|
1025
|
+
let a = "ID";
|
|
1026
|
+
this.result[l][this.result[l].length - 1].ID || (a = "id");
|
|
1027
|
+
let u = `${a}`;
|
|
1028
|
+
if (JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"') ? u = "<" + u : u = ">" + u, s === 1 || d.length === 0)
|
|
1029
1029
|
return {
|
|
1030
1030
|
field: u,
|
|
1031
|
-
id: this.result[
|
|
1031
|
+
id: this.result[l][this.result[l].length - 1][a]
|
|
1032
1032
|
};
|
|
1033
|
-
let
|
|
1034
|
-
const [
|
|
1035
|
-
return (
|
|
1033
|
+
let O = "";
|
|
1034
|
+
const [R, G] = g;
|
|
1035
|
+
return (R === "tasks.task.list" || R === "task.item.list") && (O = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(R) && (O = "[items]"), R === "crm.type.list" && (O = "[types]"), R === "socialnetwork.api.workgroup.list" && (O = "[workgroups]"), {
|
|
1036
1036
|
field: u,
|
|
1037
|
-
id: `$result[${[
|
|
1037
|
+
id: `$result[${[l, s - 1].join("__")}]${O}[49][${a}]`
|
|
1038
1038
|
};
|
|
1039
|
-
},
|
|
1040
|
-
const [d,
|
|
1041
|
-
let
|
|
1039
|
+
}, o = (l, s) => {
|
|
1040
|
+
const [d, g] = l;
|
|
1041
|
+
let a = JSON.parse(JSON.stringify(g)), u;
|
|
1042
1042
|
if (d === "task.item.list") {
|
|
1043
|
-
|
|
1044
|
-
const [
|
|
1045
|
-
return
|
|
1043
|
+
a = [...a];
|
|
1044
|
+
const [y, O, R, G] = a;
|
|
1045
|
+
return O[s.field] = s.id, [d, a];
|
|
1046
1046
|
}
|
|
1047
|
-
return ["user.get"].includes(d) ||
|
|
1047
|
+
return ["user.get"].includes(d) || a.FILTER ? (a.FILTER || (a.FILTER = {}), u = a.FILTER) : (a.filter || (a.filter = {}), u = a.filter), [
|
|
1048
1048
|
"socialnetwork.api.workgroup.list",
|
|
1049
1049
|
"tasks.task.list"
|
|
1050
|
-
].includes(d) ? u[">ID"] =
|
|
1051
|
-
}, h = (
|
|
1052
|
-
Object.entries(
|
|
1053
|
-
var u,
|
|
1054
|
-
const [
|
|
1055
|
-
if (Array.isArray(
|
|
1056
|
-
this.errors[
|
|
1057
|
-
const
|
|
1058
|
-
if (
|
|
1059
|
-
this.limitCall && this.limitCall(
|
|
1060
|
-
const M = i.get(
|
|
1061
|
-
switch (
|
|
1050
|
+
].includes(d) ? u[">ID"] = s.id : u[s.field] = s.id, [d, { ...a, start: -1 }];
|
|
1051
|
+
}, h = (l) => {
|
|
1052
|
+
Object.entries(l).forEach(([s, d]) => {
|
|
1053
|
+
var u, y, O, R, G, P, H;
|
|
1054
|
+
const [g] = s.split("__"), a = this.getData(d.data());
|
|
1055
|
+
if (Array.isArray(a) && (r === "count" ? this.result[g] += a.length : this.result[g].push(...a)), d.error()) {
|
|
1056
|
+
this.errors[g] = ((y = (u = d.error()) == null ? void 0 : u.ex) == null ? void 0 : y.error) ?? ((R = (O = d.error()) == null ? void 0 : O.ex) == null ? void 0 : R.error_description) ?? ((G = d.error()) == null ? void 0 : G.toString()) ?? "Неизвестная ошибка";
|
|
1057
|
+
const I = ((H = (P = d.error()) == null ? void 0 : P.ex) == null ? void 0 : H.error) ?? "";
|
|
1058
|
+
if (I === "OPERATION_TIME_LIMIT") {
|
|
1059
|
+
this.limitCall && this.limitCall(g);
|
|
1060
|
+
const M = i.get(g);
|
|
1061
|
+
switch (I) {
|
|
1062
1062
|
case "OPERATION_TIME_LIMIT":
|
|
1063
|
-
M && (this.skipList.add(M), this.limitCall && this.limitCall(
|
|
1063
|
+
M && (this.skipList.add(M), this.limitCall && this.limitCall(g));
|
|
1064
1064
|
break;
|
|
1065
1065
|
case "QUERY_LIMIT_EXCEEDED":
|
|
1066
1066
|
this.canContinue = !1;
|
|
@@ -1071,32 +1071,32 @@ class j {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
-
this.setProgressData({ key:
|
|
1074
|
+
this.setProgressData({ key: g, value: d, type: r });
|
|
1075
1075
|
});
|
|
1076
1076
|
};
|
|
1077
1077
|
let m = [];
|
|
1078
|
-
for await (const [
|
|
1078
|
+
for await (const [l, s, d] of e) {
|
|
1079
1079
|
if (!this.canContinue)
|
|
1080
1080
|
return;
|
|
1081
|
-
const [
|
|
1082
|
-
if (i.set(
|
|
1081
|
+
const [g] = s;
|
|
1082
|
+
if (i.set(l, g), this.skipList.has(g))
|
|
1083
1083
|
continue;
|
|
1084
|
-
let
|
|
1085
|
-
for (; d >
|
|
1086
|
-
const u = [
|
|
1087
|
-
m.push([u,
|
|
1088
|
-
(
|
|
1084
|
+
let a = 1;
|
|
1085
|
+
for (; d > a * 50 && !this.skipList.has(g); ) {
|
|
1086
|
+
const u = [l, a].join("__"), y = A(l, a, m, s);
|
|
1087
|
+
m.push([u, o(s, y)]), m.length % 50 === 0 && (await new Promise(
|
|
1088
|
+
(O) => this.callBatch(
|
|
1089
1089
|
Object.fromEntries(m),
|
|
1090
|
-
(
|
|
1091
|
-
h(
|
|
1090
|
+
(R) => {
|
|
1091
|
+
h(R), O();
|
|
1092
1092
|
}
|
|
1093
1093
|
)
|
|
1094
|
-
), m = [], await this.delay()),
|
|
1094
|
+
), m = [], await this.delay()), a++;
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
m.length && (await new Promise(
|
|
1098
|
-
(
|
|
1099
|
-
h(
|
|
1098
|
+
(l) => this.callBatch(Object.fromEntries(m), (s) => {
|
|
1099
|
+
h(s), l();
|
|
1100
1100
|
})
|
|
1101
1101
|
), await this.delay());
|
|
1102
1102
|
}
|
|
@@ -1104,15 +1104,15 @@ class j {
|
|
|
1104
1104
|
* Вывод ошибок в консоль в группированном виде
|
|
1105
1105
|
*/
|
|
1106
1106
|
errorLogger() {
|
|
1107
|
-
console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([e,
|
|
1108
|
-
|
|
1107
|
+
console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([e, r]) => {
|
|
1108
|
+
r && console.log(`[${e}]`, r.toString());
|
|
1109
1109
|
}), console.groupEnd();
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
1112
|
var v;
|
|
1113
1113
|
class ut {
|
|
1114
1114
|
constructor() {
|
|
1115
|
-
|
|
1115
|
+
w(this, v, {});
|
|
1116
1116
|
}
|
|
1117
1117
|
/**
|
|
1118
1118
|
* Получить случайный хеш-код длиной 8 символов
|
|
@@ -1127,10 +1127,10 @@ class ut {
|
|
|
1127
1127
|
* @returns {string}
|
|
1128
1128
|
*/
|
|
1129
1129
|
createHash(e) {
|
|
1130
|
-
let
|
|
1130
|
+
let r = "abcdefghijklmnopqrstuvwxyz0123456789", i = "";
|
|
1131
1131
|
e = e || 6;
|
|
1132
1132
|
for (let A = 0; A < e; A++)
|
|
1133
|
-
i +=
|
|
1133
|
+
i += r.charAt(Math.floor(Math.random() * r.length));
|
|
1134
1134
|
return i;
|
|
1135
1135
|
}
|
|
1136
1136
|
/**
|
|
@@ -1140,10 +1140,10 @@ class ut {
|
|
|
1140
1140
|
* @param {number} params.duration - Задержка в миллисекундах (по умолчанию 10)
|
|
1141
1141
|
* @param {Function} params.action - Функция для выполнения
|
|
1142
1142
|
*/
|
|
1143
|
-
actionFilter({ keyTimer: e, duration:
|
|
1144
|
-
|
|
1143
|
+
actionFilter({ keyTimer: e, duration: r = 10, action: i }) {
|
|
1144
|
+
p(this, v)[e] && (clearTimeout(p(this, v)[e]), p(this, v)[e] = null), i && (p(this, v)[e] = setTimeout(() => {
|
|
1145
1145
|
i();
|
|
1146
|
-
},
|
|
1146
|
+
}, r));
|
|
1147
1147
|
}
|
|
1148
1148
|
/**
|
|
1149
1149
|
* Включение режима NO-SLEEP для предотвращения засыпания устройства
|
|
@@ -1152,16 +1152,16 @@ class ut {
|
|
|
1152
1152
|
async noSleep() {
|
|
1153
1153
|
let e = document.createElement("video");
|
|
1154
1154
|
e.classList.add("no-sleep"), e.muted = !0, e.autoplay = !0, e.setAttribute("playsinline", ""), e.addEventListener("loadeddata", () => {
|
|
1155
|
-
e.style.position = "fixed", e.style.left = "-9999px", document.querySelector("body").append(e), e.play().catch((
|
|
1156
|
-
console.warn("noSleep: autoplay prevented",
|
|
1155
|
+
e.style.position = "fixed", e.style.left = "-9999px", document.querySelector("body").append(e), e.play().catch((r) => {
|
|
1156
|
+
console.warn("noSleep: autoplay prevented", r);
|
|
1157
1157
|
});
|
|
1158
1158
|
}), e.addEventListener("ended", () => {
|
|
1159
1159
|
this.actionFilter({
|
|
1160
1160
|
keyTimer: "no-sleep",
|
|
1161
1161
|
duration: 5e3,
|
|
1162
1162
|
action: () => {
|
|
1163
|
-
e.play().catch((
|
|
1164
|
-
console.warn("noSleep: replay prevented",
|
|
1163
|
+
e.play().catch((r) => {
|
|
1164
|
+
console.warn("noSleep: replay prevented", r);
|
|
1165
1165
|
});
|
|
1166
1166
|
}
|
|
1167
1167
|
});
|
|
@@ -1172,64 +1172,64 @@ class ut {
|
|
|
1172
1172
|
* @param {any} data - Данные для сохранения
|
|
1173
1173
|
* @param {string} filename - Имя файла без расширения
|
|
1174
1174
|
*/
|
|
1175
|
-
downloadFileJson(e,
|
|
1176
|
-
let i = new Blob([JSON.stringify(e)], { type: "application/json" }), A = URL.createObjectURL(i),
|
|
1177
|
-
|
|
1178
|
-
document.body.removeChild(
|
|
1175
|
+
downloadFileJson(e, r) {
|
|
1176
|
+
let i = new Blob([JSON.stringify(e)], { type: "application/json" }), A = URL.createObjectURL(i), o = document.createElement("a");
|
|
1177
|
+
o.style.display = "none", o.href = A, o.download = `${r}.json`, document.body.appendChild(o), o.click(), setTimeout(() => {
|
|
1178
|
+
document.body.removeChild(o), URL.revokeObjectURL(A);
|
|
1179
1179
|
}, 200);
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
1182
|
v = new WeakMap();
|
|
1183
1183
|
const ht = new ut();
|
|
1184
|
-
var x, Q, Z, z,
|
|
1184
|
+
var x, Q, Z, z, C, V, K, rt, ft, $, ct, st, mt, it, dt, nt, gt;
|
|
1185
1185
|
class Rt {
|
|
1186
1186
|
constructor() {
|
|
1187
|
-
|
|
1187
|
+
w(this, rt);
|
|
1188
1188
|
/** Вывод ошибок логера
|
|
1189
1189
|
* @param {'entity'} type - тип ошибки
|
|
1190
1190
|
*/
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1191
|
+
w(this, $);
|
|
1192
|
+
w(this, st);
|
|
1193
|
+
w(this, it);
|
|
1194
|
+
w(this, nt);
|
|
1195
|
+
w(this, x, "logger");
|
|
1196
|
+
w(this, Q, !1);
|
|
1197
|
+
w(this, Z, /* @__PURE__ */ new Map());
|
|
1198
|
+
w(this, z, {});
|
|
1199
|
+
w(this, C, null);
|
|
1200
|
+
w(this, V, !1);
|
|
1201
|
+
w(this, K, !1);
|
|
1202
1202
|
/** Очистка хранилища элементов старше 'N' месяцев */
|
|
1203
1203
|
S(this, "periodClear", 3);
|
|
1204
|
-
X(this,
|
|
1204
|
+
X(this, rt, ft).call(this);
|
|
1205
1205
|
}
|
|
1206
1206
|
/** Инициализация логера */
|
|
1207
1207
|
async init() {
|
|
1208
1208
|
try {
|
|
1209
|
-
let e = new j(BX24.callBatch), { entityList:
|
|
1209
|
+
let e = new j(BX24.callBatch), { entityList: r } = await e.batch({
|
|
1210
1210
|
entityList: { method: "entity.get" }
|
|
1211
1211
|
});
|
|
1212
|
-
if (
|
|
1213
|
-
if (
|
|
1214
|
-
(A) => A.ENTITY ==
|
|
1212
|
+
if (r && Array.isArray(r))
|
|
1213
|
+
if (r.find(
|
|
1214
|
+
(A) => A.ENTITY == p(this, x)
|
|
1215
1215
|
))
|
|
1216
|
-
|
|
1216
|
+
F(this, Q, !0);
|
|
1217
1217
|
else {
|
|
1218
1218
|
let { entityAdd: A } = await e.batch({
|
|
1219
1219
|
entityAdd: {
|
|
1220
1220
|
method: "entity.add",
|
|
1221
1221
|
params: {
|
|
1222
|
-
ENTITY:
|
|
1223
|
-
NAME:
|
|
1222
|
+
ENTITY: p(this, x),
|
|
1223
|
+
NAME: p(this, x),
|
|
1224
1224
|
ACCESS: { AU: "X" }
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
1227
|
});
|
|
1228
|
-
A &&
|
|
1228
|
+
A && F(this, Q, !0);
|
|
1229
1229
|
}
|
|
1230
1230
|
return X(this, it, dt).call(this).catch((i) => {
|
|
1231
1231
|
console.error("Ошибка при проверке периода очистки:", i);
|
|
1232
|
-
}),
|
|
1232
|
+
}), p(this, Q);
|
|
1233
1233
|
} catch (e) {
|
|
1234
1234
|
return console.error("Ошибка при инициализации логера:", e), !1;
|
|
1235
1235
|
}
|
|
@@ -1243,21 +1243,21 @@ class Rt {
|
|
|
1243
1243
|
* }; }}
|
|
1244
1244
|
* @returns {string|null}
|
|
1245
1245
|
*/
|
|
1246
|
-
start({ type: e, data:
|
|
1247
|
-
if (!
|
|
1246
|
+
start({ type: e, data: r }) {
|
|
1247
|
+
if (!p(this, Q))
|
|
1248
1248
|
return X(this, $, ct).call(this, "entity"), null;
|
|
1249
|
-
if (!e || !
|
|
1250
|
-
return console.error("Невалидные данные для логирования:", { type: e, data:
|
|
1249
|
+
if (!e || !r)
|
|
1250
|
+
return console.error("Невалидные данные для логирования:", { type: e, data: r }), null;
|
|
1251
1251
|
const i = ht.hash, A = {
|
|
1252
1252
|
type: e,
|
|
1253
|
-
data:
|
|
1254
|
-
userInfo:
|
|
1253
|
+
data: r,
|
|
1254
|
+
userInfo: p(this, z),
|
|
1255
1255
|
errorList: {},
|
|
1256
1256
|
status: "",
|
|
1257
1257
|
answer: null,
|
|
1258
1258
|
date: (/* @__PURE__ */ new Date()).getTime()
|
|
1259
1259
|
};
|
|
1260
|
-
return
|
|
1260
|
+
return p(this, Z).set(i, A), F(this, K, !0), i;
|
|
1261
1261
|
}
|
|
1262
1262
|
/**
|
|
1263
1263
|
* @param {{
|
|
@@ -1266,56 +1266,56 @@ class Rt {
|
|
|
1266
1266
|
* status: 'success'|'fail'|'fail-runtime',
|
|
1267
1267
|
* answer: { [key]: unknown } }}
|
|
1268
1268
|
*/
|
|
1269
|
-
async stop({ key: e, errorList:
|
|
1269
|
+
async stop({ key: e, errorList: r, status: i, answer: A }) {
|
|
1270
1270
|
var h;
|
|
1271
|
-
if (!
|
|
1271
|
+
if (!p(this, K))
|
|
1272
1272
|
return;
|
|
1273
|
-
if (!
|
|
1273
|
+
if (!p(this, Q)) {
|
|
1274
1274
|
X(this, $, ct).call(this, "entity");
|
|
1275
1275
|
return;
|
|
1276
1276
|
}
|
|
1277
|
-
let
|
|
1278
|
-
if (!
|
|
1277
|
+
let o = p(this, Z).get(e);
|
|
1278
|
+
if (!o) {
|
|
1279
1279
|
console.error(`Не найдены данные логирования для ключа: ${e}`);
|
|
1280
1280
|
return;
|
|
1281
1281
|
}
|
|
1282
|
-
|
|
1282
|
+
r && (o.errorList = r), i && (o.status = i), A && (o.answer = A), await X(this, st, mt).call(this), (h = o == null ? void 0 : o.data) != null && h.updateList && F(this, V, !0), F(this, K, !1);
|
|
1283
1283
|
}
|
|
1284
1284
|
/**
|
|
1285
1285
|
* @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
|
|
1286
1286
|
*/
|
|
1287
1287
|
async getEntityList(e) {
|
|
1288
|
-
var
|
|
1288
|
+
var r;
|
|
1289
1289
|
try {
|
|
1290
|
-
if ((
|
|
1291
|
-
return
|
|
1290
|
+
if ((r = p(this, C)) != null && r.length && !p(this, V))
|
|
1291
|
+
return p(this, C);
|
|
1292
1292
|
let i = new j(BX24.callBatch), { entityList: A } = await i.batch(
|
|
1293
1293
|
{
|
|
1294
1294
|
entityList: {
|
|
1295
1295
|
method: "entity.item.get",
|
|
1296
1296
|
params: {
|
|
1297
|
-
ENTITY:
|
|
1297
|
+
ENTITY: p(this, x),
|
|
1298
1298
|
SORT: { ID: "DESC" }
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
},
|
|
1302
1302
|
e
|
|
1303
1303
|
);
|
|
1304
|
-
return !A || !Array.isArray(A) ? (console.warn("Получен невалидный список записей"), []) : (A = A.map((
|
|
1304
|
+
return !A || !Array.isArray(A) ? (console.warn("Получен невалидный список записей"), []) : (A = A.map((o) => {
|
|
1305
1305
|
try {
|
|
1306
|
-
const { ID: h, DATE_CREATE: m, DETAIL_TEXT:
|
|
1306
|
+
const { ID: h, DATE_CREATE: m, DETAIL_TEXT: l } = o;
|
|
1307
1307
|
return {
|
|
1308
|
-
...JSON.parse(
|
|
1308
|
+
...JSON.parse(l),
|
|
1309
1309
|
id: h,
|
|
1310
1310
|
dateCreate: m
|
|
1311
1311
|
};
|
|
1312
1312
|
} catch (h) {
|
|
1313
1313
|
return console.error(
|
|
1314
|
-
`Ошибка парсинга записи ${
|
|
1314
|
+
`Ошибка парсинга записи ${o.ID}:`,
|
|
1315
1315
|
h
|
|
1316
1316
|
), null;
|
|
1317
1317
|
}
|
|
1318
|
-
}).filter((
|
|
1318
|
+
}).filter((o) => o !== null), F(this, V, !1), F(this, C, A), A);
|
|
1319
1319
|
} catch (i) {
|
|
1320
1320
|
return console.error("Ошибка при получении списка записей:", i), [];
|
|
1321
1321
|
}
|
|
@@ -1323,11 +1323,11 @@ class Rt {
|
|
|
1323
1323
|
/** Выгрузка всех данных из хранилища в JSON-файл */
|
|
1324
1324
|
async downAllEntityJson() {
|
|
1325
1325
|
try {
|
|
1326
|
-
if (
|
|
1326
|
+
if (p(this, C) || await this.getEntityList(), !p(this, C) || p(this, C).length === 0)
|
|
1327
1327
|
return console.warn("Нет данных для выгрузки"), !1;
|
|
1328
1328
|
let e = et().format("%Y-%m-%d");
|
|
1329
1329
|
return ht.downloadFileJson(
|
|
1330
|
-
|
|
1330
|
+
p(this, C),
|
|
1331
1331
|
`sdklogger-entity-data__${e}`
|
|
1332
1332
|
), !0;
|
|
1333
1333
|
} catch (e) {
|
|
@@ -1335,17 +1335,17 @@ class Rt {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
|
-
x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(),
|
|
1338
|
+
x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), C = new WeakMap(), V = new WeakMap(), K = new WeakMap(), rt = new WeakSet(), ft = async function() {
|
|
1339
1339
|
try {
|
|
1340
|
-
const e = new j(BX24.callBatch),
|
|
1340
|
+
const e = new j(BX24.callBatch), r = BX24.isAdmin(), { curUser: i } = await e.batch({
|
|
1341
1341
|
curUser: { method: "user.current" }
|
|
1342
1342
|
});
|
|
1343
|
-
|
|
1343
|
+
F(this, z, { isAdmin: r, curUser: i });
|
|
1344
1344
|
} catch (e) {
|
|
1345
1345
|
console.error(
|
|
1346
1346
|
"Ошибка при получении информации о пользователе:",
|
|
1347
1347
|
e
|
|
1348
|
-
),
|
|
1348
|
+
), F(this, z, { isAdmin: !1, curUser: null });
|
|
1349
1349
|
}
|
|
1350
1350
|
}, $ = new WeakSet(), ct = function(e) {
|
|
1351
1351
|
e == "entity" && ht.actionFilter({
|
|
@@ -1355,25 +1355,25 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), w =
|
|
|
1355
1355
|
console.error("Хранилище для логгера не инициализировано");
|
|
1356
1356
|
}
|
|
1357
1357
|
});
|
|
1358
|
-
},
|
|
1358
|
+
}, st = new WeakSet(), mt = async function() {
|
|
1359
1359
|
try {
|
|
1360
|
-
let e = {},
|
|
1361
|
-
for (let [i, A] of
|
|
1360
|
+
let e = {}, r = new j(BX24.callBatch);
|
|
1361
|
+
for (let [i, A] of p(this, Z).entries())
|
|
1362
1362
|
if (A.status) {
|
|
1363
|
-
const
|
|
1363
|
+
const o = JSON.stringify(A);
|
|
1364
1364
|
e[i] = {
|
|
1365
1365
|
method: "entity.item.add",
|
|
1366
1366
|
params: {
|
|
1367
|
-
ENTITY:
|
|
1368
|
-
NAME:
|
|
1369
|
-
DETAIL_TEXT:
|
|
1367
|
+
ENTITY: p(this, x),
|
|
1368
|
+
NAME: p(this, x),
|
|
1369
|
+
DETAIL_TEXT: o
|
|
1370
1370
|
}
|
|
1371
1371
|
};
|
|
1372
1372
|
}
|
|
1373
1373
|
if (Object.keys(e).length) {
|
|
1374
|
-
let i = await
|
|
1375
|
-
for (let [
|
|
1376
|
-
|
|
1374
|
+
let i = await r.batch(e), { errors: A } = r;
|
|
1375
|
+
for (let [o, h] of Object.entries({ ...i, ...A }))
|
|
1376
|
+
p(this, Z).delete(o);
|
|
1377
1377
|
return !0;
|
|
1378
1378
|
}
|
|
1379
1379
|
return !1;
|
|
@@ -1382,24 +1382,24 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), w =
|
|
|
1382
1382
|
}
|
|
1383
1383
|
}, it = new WeakSet(), dt = async function() {
|
|
1384
1384
|
try {
|
|
1385
|
-
let e = new j(BX24.callBatch), { serverTime:
|
|
1385
|
+
let e = new j(BX24.callBatch), { serverTime: r } = await e.batch({
|
|
1386
1386
|
serverTime: { method: "server.time" }
|
|
1387
1387
|
});
|
|
1388
|
-
if (!
|
|
1388
|
+
if (!r) {
|
|
1389
1389
|
console.error("Не удалось получить время сервера");
|
|
1390
1390
|
return;
|
|
1391
1391
|
}
|
|
1392
|
-
if (
|
|
1392
|
+
if (p(this, C) || await this.getEntityList(), !p(this, C) || p(this, C).length === 0)
|
|
1393
1393
|
return;
|
|
1394
|
-
let i =
|
|
1394
|
+
let i = p(this, C).filter((A) => {
|
|
1395
1395
|
try {
|
|
1396
|
-
let { dateCreate:
|
|
1397
|
-
return
|
|
1398
|
-
et(new Date(
|
|
1396
|
+
let { dateCreate: o } = A;
|
|
1397
|
+
return o ? et(new Date(o)).between(
|
|
1398
|
+
et(new Date(r)),
|
|
1399
1399
|
"month"
|
|
1400
1400
|
) >= this.periodClear : !1;
|
|
1401
|
-
} catch (
|
|
1402
|
-
return console.error("Ошибка при проверке даты записи:",
|
|
1401
|
+
} catch (o) {
|
|
1402
|
+
return console.error("Ошибка при проверке даты записи:", o), !1;
|
|
1403
1403
|
}
|
|
1404
1404
|
});
|
|
1405
1405
|
i.length > 0 && (console.log(
|
|
@@ -1412,26 +1412,26 @@ x = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), w =
|
|
|
1412
1412
|
try {
|
|
1413
1413
|
if (!e || e.length === 0)
|
|
1414
1414
|
return !1;
|
|
1415
|
-
let
|
|
1416
|
-
let { id: h } =
|
|
1415
|
+
let r = new j(BX24.callBatch), i = e.filter((o) => o && o.id).map((o) => {
|
|
1416
|
+
let { id: h } = o;
|
|
1417
1417
|
return {
|
|
1418
1418
|
method: "entity.item.delete",
|
|
1419
1419
|
params: {
|
|
1420
|
-
ENTITY:
|
|
1420
|
+
ENTITY: p(this, x),
|
|
1421
1421
|
ID: h
|
|
1422
1422
|
}
|
|
1423
1423
|
};
|
|
1424
1424
|
});
|
|
1425
1425
|
if (i.length === 0)
|
|
1426
1426
|
return !1;
|
|
1427
|
-
const A = await
|
|
1428
|
-
return console.log(`Успешно удалено ${i.length} записей`),
|
|
1429
|
-
} catch (
|
|
1430
|
-
return console.error("Ошибка при очистке устаревших записей:",
|
|
1427
|
+
const A = await r.batch(i);
|
|
1428
|
+
return console.log(`Успешно удалено ${i.length} записей`), F(this, V, !0), A;
|
|
1429
|
+
} catch (r) {
|
|
1430
|
+
return console.error("Ошибка при очистке устаревших записей:", r), !1;
|
|
1431
1431
|
}
|
|
1432
1432
|
};
|
|
1433
|
-
var At, Nt,
|
|
1434
|
-
class
|
|
1433
|
+
var At, Nt, ot, Ot;
|
|
1434
|
+
class bt {
|
|
1435
1435
|
/**
|
|
1436
1436
|
* @param {Object} appConst - Константы приложения
|
|
1437
1437
|
* @param {string} appConst.appName - Название приложения
|
|
@@ -1439,9 +1439,9 @@ class St {
|
|
|
1439
1439
|
*/
|
|
1440
1440
|
constructor(e) {
|
|
1441
1441
|
/** Запрос данных о приложении */
|
|
1442
|
-
|
|
1442
|
+
w(this, At);
|
|
1443
1443
|
/** Запрос данных о текущем пользователе */
|
|
1444
|
-
|
|
1444
|
+
w(this, ot);
|
|
1445
1445
|
S(this, "domain", "");
|
|
1446
1446
|
S(this, "isAdmin", !1);
|
|
1447
1447
|
S(this, "appInfo", null);
|
|
@@ -1458,10 +1458,10 @@ class St {
|
|
|
1458
1458
|
* @throws {Error} Если BX24 не загружен в течение 30 секунд
|
|
1459
1459
|
*/
|
|
1460
1460
|
init() {
|
|
1461
|
-
return new Promise((e,
|
|
1461
|
+
return new Promise((e, r) => {
|
|
1462
1462
|
let A = setInterval(() => {
|
|
1463
1463
|
window.BX24 && BX24.init(async () => {
|
|
1464
|
-
console.info("init BX24"), clearInterval(A), clearTimeout(
|
|
1464
|
+
console.info("init BX24"), clearInterval(A), clearTimeout(o), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new Rt(), await this.logger.init()) : this.logger = {
|
|
1465
1465
|
start: () => {
|
|
1466
1466
|
},
|
|
1467
1467
|
stop: () => {
|
|
@@ -1471,27 +1471,27 @@ class St {
|
|
|
1471
1471
|
};
|
|
1472
1472
|
const [h, m] = await Promise.all([
|
|
1473
1473
|
X(this, At, Nt).call(this),
|
|
1474
|
-
X(this,
|
|
1474
|
+
X(this, ot, Ot).call(this)
|
|
1475
1475
|
]);
|
|
1476
1476
|
this.appInfo = h, this.userInfo = m;
|
|
1477
|
-
let
|
|
1477
|
+
let l = new ut();
|
|
1478
1478
|
try {
|
|
1479
|
-
|
|
1480
|
-
} catch (
|
|
1479
|
+
l.noSleep();
|
|
1480
|
+
} catch (s) {
|
|
1481
1481
|
console.warn(
|
|
1482
1482
|
"Failed to initialize noSleep:",
|
|
1483
|
-
|
|
1483
|
+
s
|
|
1484
1484
|
);
|
|
1485
1485
|
}
|
|
1486
1486
|
e(!0);
|
|
1487
1487
|
});
|
|
1488
1488
|
}, 100);
|
|
1489
|
-
const
|
|
1489
|
+
const o = setTimeout(() => {
|
|
1490
1490
|
clearInterval(A);
|
|
1491
1491
|
const h = new Error(
|
|
1492
1492
|
"BX24 initialization timeout: BX24 object not found within 30 seconds"
|
|
1493
1493
|
);
|
|
1494
|
-
console.error(h),
|
|
1494
|
+
console.error(h), r(h);
|
|
1495
1495
|
}, 3e4);
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
@@ -1501,23 +1501,23 @@ class St {
|
|
|
1501
1501
|
* @param {any} value - Значение для установки (если не указано, метод вернет текущее значение)
|
|
1502
1502
|
* @returns {any}
|
|
1503
1503
|
*/
|
|
1504
|
-
userOption(e,
|
|
1504
|
+
userOption(e, r) {
|
|
1505
1505
|
if (typeof BX24 > "u" || !BX24.userOption) {
|
|
1506
1506
|
console.warn(
|
|
1507
1507
|
"BX24.userOption is not available. Make sure BX24 is initialized."
|
|
1508
1508
|
);
|
|
1509
1509
|
return;
|
|
1510
1510
|
}
|
|
1511
|
-
return
|
|
1511
|
+
return r !== void 0 ? BX24.userOption.set(e, r) : BX24.userOption.get(e);
|
|
1512
1512
|
}
|
|
1513
|
-
appOption(e,
|
|
1513
|
+
appOption(e, r) {
|
|
1514
1514
|
if (typeof BX24 > "u" || !BX24.appOption) {
|
|
1515
1515
|
console.warn(
|
|
1516
1516
|
"BX24.appOption is not available. Make sure BX24 is initialized."
|
|
1517
1517
|
);
|
|
1518
1518
|
return;
|
|
1519
1519
|
}
|
|
1520
|
-
return
|
|
1520
|
+
return r !== void 0 ? BX24.appOption.set(e, r) : BX24.appOption.get(e);
|
|
1521
1521
|
}
|
|
1522
1522
|
/**
|
|
1523
1523
|
* @param {{
|
|
@@ -1537,37 +1537,48 @@ class St {
|
|
|
1537
1537
|
* }[]
|
|
1538
1538
|
* }[]
|
|
1539
1539
|
*/
|
|
1540
|
-
async call({ method: e, params:
|
|
1540
|
+
async call({ method: e, params: r, updateList: i }) {
|
|
1541
1541
|
let A;
|
|
1542
|
-
|
|
1542
|
+
if (i && (A = this.logger.start({
|
|
1543
1543
|
type: "call",
|
|
1544
|
-
data: { method: e, params:
|
|
1545
|
-
}),
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
let f = {};
|
|
1544
|
+
data: { method: e, params: r, updateList: i }
|
|
1545
|
+
})), r || (r = {}), typeof BX24 > "u" || !BX24.callMethod) {
|
|
1546
|
+
const o = new Error("BX24 is not initialized");
|
|
1547
|
+
throw console.error(o), o;
|
|
1548
|
+
}
|
|
1549
|
+
return new Promise((o, h) => {
|
|
1550
|
+
BX24.callMethod(e, r, async (m) => {
|
|
1551
|
+
let l = {};
|
|
1553
1552
|
if (m != null && m.answer)
|
|
1554
|
-
for (let [
|
|
1555
|
-
|
|
1553
|
+
for (let [s, d] of Object.entries(m.answer))
|
|
1554
|
+
s !== "result" && d && (l[s] = d);
|
|
1556
1555
|
if (m.error()) {
|
|
1557
|
-
let
|
|
1558
|
-
console.error(
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1556
|
+
let s = m.error();
|
|
1557
|
+
if (console.error(s), A)
|
|
1558
|
+
try {
|
|
1559
|
+
await this.logger.stop({
|
|
1560
|
+
answer: l,
|
|
1561
|
+
key: A,
|
|
1562
|
+
status: "fail",
|
|
1563
|
+
errorList: { 0: s.toString() }
|
|
1564
|
+
});
|
|
1565
|
+
} catch (d) {
|
|
1566
|
+
console.error("Logger error:", d);
|
|
1567
|
+
}
|
|
1568
|
+
o(!1);
|
|
1564
1569
|
} else {
|
|
1565
|
-
let
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1570
|
+
let s = m.data();
|
|
1571
|
+
if (s != null && s.items && (s = s.items), A)
|
|
1572
|
+
try {
|
|
1573
|
+
await this.logger.stop({
|
|
1574
|
+
answer: l,
|
|
1575
|
+
key: A,
|
|
1576
|
+
status: "success"
|
|
1577
|
+
});
|
|
1578
|
+
} catch (d) {
|
|
1579
|
+
console.error("Logger error:", d);
|
|
1580
|
+
}
|
|
1581
|
+
o(s);
|
|
1571
1582
|
}
|
|
1572
1583
|
});
|
|
1573
1584
|
});
|
|
@@ -1591,81 +1602,131 @@ class St {
|
|
|
1591
1602
|
* }[]
|
|
1592
1603
|
* }}
|
|
1593
1604
|
*/
|
|
1594
|
-
async batch(e,
|
|
1605
|
+
async batch(e, r, { errorCall: i, limitCommandSerial: A, updateList: o, limitCall: h } = {}) {
|
|
1595
1606
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1596
|
-
const
|
|
1597
|
-
return console.error(
|
|
1607
|
+
const s = new Error("BX24 is not initialized");
|
|
1608
|
+
return console.error(s), !1;
|
|
1598
1609
|
}
|
|
1599
|
-
let m = new j(BX24.callBatch),
|
|
1600
|
-
|
|
1610
|
+
let m = new j(BX24.callBatch), l;
|
|
1611
|
+
o && (l = this.logger.start({
|
|
1601
1612
|
type: "batch",
|
|
1602
|
-
data: { commandList: e, updateList:
|
|
1613
|
+
data: { commandList: e, updateList: o }
|
|
1603
1614
|
})), A && console.warn(
|
|
1604
1615
|
"limitCommandSerial is deprecated and not used in current Batch implementation"
|
|
1605
1616
|
);
|
|
1606
1617
|
try {
|
|
1607
|
-
let
|
|
1618
|
+
let s = await m.batch(
|
|
1608
1619
|
e,
|
|
1609
|
-
|
|
1620
|
+
r,
|
|
1610
1621
|
h
|
|
1611
1622
|
);
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1623
|
+
if (Object.keys(m.errors).length) {
|
|
1624
|
+
if (i && i(m.errors), l)
|
|
1625
|
+
try {
|
|
1626
|
+
await this.logger.stop({
|
|
1627
|
+
key: l,
|
|
1628
|
+
status: "fail",
|
|
1629
|
+
errorList: m.errors
|
|
1630
|
+
});
|
|
1631
|
+
} catch (d) {
|
|
1632
|
+
console.error("Logger error:", d);
|
|
1633
|
+
}
|
|
1634
|
+
} else if (l)
|
|
1635
|
+
try {
|
|
1636
|
+
await this.logger.stop({
|
|
1637
|
+
key: l,
|
|
1638
|
+
status: "success"
|
|
1639
|
+
});
|
|
1640
|
+
} catch (d) {
|
|
1641
|
+
console.error("Logger error:", d);
|
|
1642
|
+
}
|
|
1643
|
+
return s;
|
|
1644
|
+
} catch (s) {
|
|
1645
|
+
if (l)
|
|
1646
|
+
try {
|
|
1647
|
+
await this.logger.stop({
|
|
1648
|
+
key: l,
|
|
1649
|
+
status: "fail-runtime",
|
|
1650
|
+
errorList: { 0: s == null ? void 0 : s.toString() }
|
|
1651
|
+
});
|
|
1652
|
+
} catch (d) {
|
|
1653
|
+
console.error("Logger error:", d);
|
|
1654
|
+
}
|
|
1655
|
+
return console.error(s), !1;
|
|
1626
1656
|
}
|
|
1627
1657
|
}
|
|
1628
1658
|
/**
|
|
1629
1659
|
* Получить количество элементов для списочных методов
|
|
1630
1660
|
* @param {Object} commandList - объект/массив команд
|
|
1631
1661
|
* @param {Function} progressCall - callback(data), в data приходят данные о загрузке данных
|
|
1662
|
+
* @param {{
|
|
1663
|
+
* updateList: {
|
|
1664
|
+
* method: string,
|
|
1665
|
+
* name: string,
|
|
1666
|
+
* list: {
|
|
1667
|
+
* id: string | number,
|
|
1668
|
+
* fields: {
|
|
1669
|
+
* [key: string]: {
|
|
1670
|
+
* oldValue: string | number | string[] | number[],
|
|
1671
|
+
* newValue: string | number | string[] | number[],
|
|
1672
|
+
* }
|
|
1673
|
+
* }
|
|
1674
|
+
* }[]
|
|
1675
|
+
* }[],
|
|
1676
|
+
* errorCall: Function,
|
|
1677
|
+
* limitCall: Function
|
|
1678
|
+
* }}
|
|
1632
1679
|
* @returns {Promise<Object|false>}
|
|
1633
1680
|
*/
|
|
1634
|
-
async batchTotalCount(e,
|
|
1681
|
+
async batchTotalCount(e, r, { errorCall: i, updateList: A, limitCall: o } = {}) {
|
|
1635
1682
|
if (typeof BX24 > "u" || !BX24.callBatch) {
|
|
1636
|
-
const
|
|
1637
|
-
return console.error(
|
|
1683
|
+
const l = new Error("BX24 is not initialized");
|
|
1684
|
+
return console.error(l), !1;
|
|
1638
1685
|
}
|
|
1639
|
-
let
|
|
1686
|
+
let h = new j(BX24.callBatch), m;
|
|
1687
|
+
A && (m = this.logger.start({
|
|
1640
1688
|
type: "batch-total-count",
|
|
1641
1689
|
data: { commandList: e }
|
|
1642
|
-
});
|
|
1690
|
+
}));
|
|
1643
1691
|
try {
|
|
1644
|
-
let
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1692
|
+
let l = await h.batchTotalCount(
|
|
1693
|
+
e,
|
|
1694
|
+
r,
|
|
1695
|
+
o
|
|
1696
|
+
);
|
|
1697
|
+
if (Object.keys(h.errors).length) {
|
|
1698
|
+
if (i && i(h.errors), m)
|
|
1699
|
+
try {
|
|
1700
|
+
await this.logger.stop({
|
|
1701
|
+
key: m,
|
|
1702
|
+
status: "fail",
|
|
1703
|
+
errorList: h.errors
|
|
1704
|
+
});
|
|
1705
|
+
} catch (s) {
|
|
1706
|
+
console.error("Logger error:", s);
|
|
1707
|
+
}
|
|
1708
|
+
} else if (m)
|
|
1709
|
+
try {
|
|
1710
|
+
await this.logger.stop({
|
|
1648
1711
|
key: m,
|
|
1649
|
-
|
|
1650
|
-
})
|
|
1651
|
-
)
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
errorList: [a.toString()]
|
|
1668
|
-
}), console.error(a), !1;
|
|
1712
|
+
status: "success"
|
|
1713
|
+
});
|
|
1714
|
+
} catch (s) {
|
|
1715
|
+
console.error("Logger error:", s);
|
|
1716
|
+
}
|
|
1717
|
+
return l;
|
|
1718
|
+
} catch (l) {
|
|
1719
|
+
if (m)
|
|
1720
|
+
try {
|
|
1721
|
+
await this.logger.stop({
|
|
1722
|
+
key: m,
|
|
1723
|
+
status: "fail-runtime",
|
|
1724
|
+
errorList: { 0: l == null ? void 0 : l.toString() }
|
|
1725
|
+
});
|
|
1726
|
+
} catch (s) {
|
|
1727
|
+
console.error("Logger error:", s);
|
|
1728
|
+
}
|
|
1729
|
+
return console.error(l), !1;
|
|
1669
1730
|
}
|
|
1670
1731
|
}
|
|
1671
1732
|
/** Запрос данных о местах встройки приложения */
|
|
@@ -1673,69 +1734,87 @@ class St {
|
|
|
1673
1734
|
return await this.call({ method: "placement.get" }).then((e) => (this.placeData || (this.placeData = e), e));
|
|
1674
1735
|
}
|
|
1675
1736
|
/** Встройка приложения в place */
|
|
1676
|
-
async placementBind(e,
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
e.map((f) => this.placementBind(f, s))
|
|
1680
|
-
);
|
|
1737
|
+
async placementBind(e, r = !0) {
|
|
1738
|
+
var d;
|
|
1739
|
+
if (!this.isAdmin)
|
|
1681
1740
|
return;
|
|
1682
|
-
|
|
1683
|
-
|
|
1741
|
+
r && await this.placementCheck();
|
|
1742
|
+
let i = [];
|
|
1743
|
+
if (Array.isArray(e) ? i = e.map((g) => typeof g == "string" ? { placement: g } : g) : typeof e == "string" ? i = [{ placement: e }] : i = [e], this.placeData = await this.getPlacement(), !this.placeData)
|
|
1684
1744
|
return;
|
|
1685
|
-
const { appName:
|
|
1686
|
-
let
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
},
|
|
1698
|
-
OPTIONS: {
|
|
1699
|
-
errorHandlerUrl: a
|
|
1745
|
+
const { appName: A, pathApp: o } = this.appConst;
|
|
1746
|
+
let h = A;
|
|
1747
|
+
this.domain === "szdl.bitrix24.ru" && ((d = this.appInfo) != null && d.ID) && (h = `${A}: #${this.appInfo.ID}`);
|
|
1748
|
+
const m = h.replace(" CRM", ""), l = {}, s = [];
|
|
1749
|
+
for (let g = 0; g < i.length; g++) {
|
|
1750
|
+
const a = i[g], u = a.placement, y = a.userId;
|
|
1751
|
+
let O = o, R = u;
|
|
1752
|
+
if (u === "PAGE_BACKGROUND_WORKER") {
|
|
1753
|
+
if (!y) {
|
|
1754
|
+
console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${u}`);
|
|
1755
|
+
continue;
|
|
1700
1756
|
}
|
|
1757
|
+
O = `${o}?USER_ID=${y}/`;
|
|
1701
1758
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
await Promise.all(
|
|
1709
|
-
e.map((a) => this.placementUnBind(a, s))
|
|
1759
|
+
if (u === "PAGE_BACKGROUND_WORKER_ALL" && (R = "PAGE_BACKGROUND_WORKER"), this.placeData.find(
|
|
1760
|
+
(I) => I.placement === R && I.handler === O
|
|
1761
|
+
))
|
|
1762
|
+
continue;
|
|
1763
|
+
let P = this.placeData.find(
|
|
1764
|
+
(I) => I.placement === R && I.handler !== O
|
|
1710
1765
|
);
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const { appName: i, pathApp: A } = this.appConst;
|
|
1716
|
-
s || (e === "PAGE_BACKGROUND_WORKER" ? s = `${A}?USER_ID=${this.userInfo.ID}/` : s = A), await this.call({
|
|
1717
|
-
method: "placement.unbind",
|
|
1718
|
-
params: {
|
|
1719
|
-
PLACEMENT: e,
|
|
1720
|
-
HANDLER: s,
|
|
1766
|
+
P && s.push({ placement: R, handler: P.handler });
|
|
1767
|
+
const H = {
|
|
1768
|
+
PLACEMENT: R,
|
|
1769
|
+
HANDLER: O,
|
|
1721
1770
|
LANG_ALL: {
|
|
1722
1771
|
ru: {
|
|
1723
|
-
TITLE:
|
|
1772
|
+
TITLE: R === "USER_PROFILE_TOOLBAR" ? m : h
|
|
1724
1773
|
}
|
|
1725
1774
|
},
|
|
1726
1775
|
OPTIONS: {
|
|
1727
|
-
errorHandlerUrl:
|
|
1776
|
+
errorHandlerUrl: O
|
|
1728
1777
|
}
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1778
|
+
};
|
|
1779
|
+
u === "PAGE_BACKGROUND_WORKER" && y && (H.USER_ID = y), l[`bind_${g}`] = {
|
|
1780
|
+
method: "placement.bind",
|
|
1781
|
+
params: H
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
s.length > 0 && await this.placementUnBind(s), Object.keys(l).length > 0 && await this.batch(l), Object.keys(l).length > 0 && (this.placeData = await this.getPlacement(), Object.values(l).forEach((g) => {
|
|
1785
|
+
console.log("Приложение успешно встроено в", g.params.PLACEMENT);
|
|
1786
|
+
}));
|
|
1787
|
+
}
|
|
1788
|
+
/* Отвязка встройки из place */
|
|
1789
|
+
async placementUnBind(e) {
|
|
1790
|
+
let r = [];
|
|
1791
|
+
Array.isArray(e) ? r = e.map((A) => typeof A == "string" ? { placement: A } : A) : typeof e == "string" ? r = [{ placement: e }] : r = [e];
|
|
1792
|
+
const i = {};
|
|
1793
|
+
for (let A = 0; A < r.length; A++) {
|
|
1794
|
+
const o = r[A], h = o.placement, m = o.handler, l = {
|
|
1795
|
+
PLACEMENT: h
|
|
1796
|
+
};
|
|
1797
|
+
m && (l.HANDLER = m), i[`unbind_${A}`] = {
|
|
1798
|
+
method: "placement.unbind",
|
|
1799
|
+
params: l
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
Object.keys(i).length > 0 && (await this.batch(i), r.forEach((A) => {
|
|
1803
|
+
console.log("Встройка отвязана", A.placement);
|
|
1804
|
+
}));
|
|
1731
1805
|
}
|
|
1732
1806
|
/** Удаляем фоновые обработчики прошлых версий и создаем новые */
|
|
1733
1807
|
async placementCheck() {
|
|
1734
1808
|
if (this.placeData = await this.getPlacement(), !this.placeData)
|
|
1735
1809
|
return;
|
|
1736
|
-
const { pathApp: e } = this.appConst;
|
|
1737
|
-
for (const
|
|
1738
|
-
|
|
1810
|
+
const { pathApp: e } = this.appConst, r = [], i = [];
|
|
1811
|
+
for (const A of this.placeData) {
|
|
1812
|
+
if (!A.handler || A.handler.includes(e))
|
|
1813
|
+
continue;
|
|
1814
|
+
const { placement: o, handler: h, userId: m } = A;
|
|
1815
|
+
r.push({ placement: o, handler: h }), i.push({ placement: o, userId: m });
|
|
1816
|
+
}
|
|
1817
|
+
r.length > 0 && await this.placementUnBind(r), i.length > 0 && await this.placementBind(i, !1);
|
|
1739
1818
|
}
|
|
1740
1819
|
/** Чат-бот */
|
|
1741
1820
|
/* получение списка ботов */
|
|
@@ -1744,21 +1823,21 @@ class St {
|
|
|
1744
1823
|
method: "imbot.bot.list",
|
|
1745
1824
|
params: {}
|
|
1746
1825
|
}).then((e) => {
|
|
1747
|
-
let
|
|
1748
|
-
return console.log("chat-bot list:",
|
|
1826
|
+
let r = Object.values(e);
|
|
1827
|
+
return console.log("chat-bot list:", r), r;
|
|
1749
1828
|
});
|
|
1750
1829
|
}
|
|
1751
1830
|
/* регистрация бота */
|
|
1752
|
-
regBot({ code: e, type:
|
|
1753
|
-
const { appName: A, pathApp:
|
|
1831
|
+
regBot({ code: e, type: r, name: i }) {
|
|
1832
|
+
const { appName: A, pathApp: o, chatBotLogo: h } = this.appConst, m = this.appInfo.ID;
|
|
1754
1833
|
return this.call({
|
|
1755
1834
|
method: "imbot.register",
|
|
1756
1835
|
params: {
|
|
1757
1836
|
CODE: e ?? this.appInfo.CODE,
|
|
1758
1837
|
// Строковой идентификатор бота, уникальный в рамках вашего приложения (обяз.)
|
|
1759
|
-
TYPE:
|
|
1838
|
+
TYPE: r ?? "O",
|
|
1760
1839
|
// Тип бота, B - чат-бот, ответы поступают сразу, H - человек, ответы поступают с задержкой от 2-х до 10 секунд, O - чат-бот для Открытых линий, S - чат-бот с повышенными привилегиями (supervisor)
|
|
1761
|
-
EVENT_HANDLER:
|
|
1840
|
+
EVENT_HANDLER: o,
|
|
1762
1841
|
// Ссылка на обработчик событий, поступивших от сервера - см. Обработчики событий ниже (обяз).
|
|
1763
1842
|
OPENLINE: "Y",
|
|
1764
1843
|
// Включение режима поддержки Открытых линий, можно не указывать, если TYPE = 'O'
|
|
@@ -1786,7 +1865,7 @@ class St {
|
|
|
1786
1865
|
// Аватар чат-бота - base64
|
|
1787
1866
|
}
|
|
1788
1867
|
}
|
|
1789
|
-
}).then((
|
|
1868
|
+
}).then((l) => (console.log("Чат-бот добавлен", l), l));
|
|
1790
1869
|
}
|
|
1791
1870
|
/* Убрать регистрацию бота */
|
|
1792
1871
|
unRegBot(e) {
|
|
@@ -1795,7 +1874,7 @@ class St {
|
|
|
1795
1874
|
params: {
|
|
1796
1875
|
BOT_ID: e
|
|
1797
1876
|
}
|
|
1798
|
-
}).then((
|
|
1877
|
+
}).then((r) => (console.log("чат-бот удален", r), r));
|
|
1799
1878
|
}
|
|
1800
1879
|
/* Получение данных логера */
|
|
1801
1880
|
getLoggerList(e) {
|
|
@@ -1804,10 +1883,10 @@ class St {
|
|
|
1804
1883
|
}
|
|
1805
1884
|
At = new WeakSet(), Nt = function() {
|
|
1806
1885
|
return this.call({ method: "app.info" });
|
|
1807
|
-
},
|
|
1886
|
+
}, ot = new WeakSet(), Ot = function() {
|
|
1808
1887
|
return this.call({ method: "user.current" });
|
|
1809
1888
|
};
|
|
1810
|
-
class
|
|
1889
|
+
class St {
|
|
1811
1890
|
constructor(e) {
|
|
1812
1891
|
S(this, "entityName", "tabs");
|
|
1813
1892
|
S(this, "maxTabs", 5);
|
|
@@ -1823,8 +1902,8 @@ class bt {
|
|
|
1823
1902
|
console.error("В бек-воркер не переданы настройки, отмена вызова"), console.log("BackgroundWorker: Отмена конструктора - отсутствуют опции");
|
|
1824
1903
|
return;
|
|
1825
1904
|
}
|
|
1826
|
-
const { appFunc:
|
|
1827
|
-
this.bx = i, this.appPath = i.appConst.pathApp ?? "", this.appName = i.appConst.appName ?? "", this.appInit =
|
|
1905
|
+
const { appFunc: r, bx: i, users: A, continueBackground: o } = e;
|
|
1906
|
+
this.bx = i, this.appPath = i.appConst.pathApp ?? "", this.appName = i.appConst.appName ?? "", this.appInit = r, this.users = A, this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof o == "function" ? o : this.defaultContinueBackground;
|
|
1828
1907
|
}
|
|
1829
1908
|
async init() {
|
|
1830
1909
|
if (!this.appInit) {
|
|
@@ -1858,13 +1937,13 @@ class bt {
|
|
|
1858
1937
|
});
|
|
1859
1938
|
}
|
|
1860
1939
|
async getTabs() {
|
|
1861
|
-
var
|
|
1940
|
+
var r;
|
|
1862
1941
|
const e = await this.bx.call({
|
|
1863
1942
|
method: "entity.item.get",
|
|
1864
1943
|
params: {
|
|
1865
1944
|
ENTITY: this.entityName,
|
|
1866
1945
|
FILTER: {
|
|
1867
|
-
NAME: (
|
|
1946
|
+
NAME: (r = this.bx.userInfo) == null ? void 0 : r.ID
|
|
1868
1947
|
},
|
|
1869
1948
|
SORT: {
|
|
1870
1949
|
DATE_CREATE: "DESC"
|
|
@@ -1882,7 +1961,7 @@ class bt {
|
|
|
1882
1961
|
}) : [];
|
|
1883
1962
|
}
|
|
1884
1963
|
async addTab() {
|
|
1885
|
-
var
|
|
1964
|
+
var r;
|
|
1886
1965
|
const e = {
|
|
1887
1966
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1888
1967
|
duration: (/* @__PURE__ */ new Date()).getTime() - this.start.getTime(),
|
|
@@ -1892,14 +1971,14 @@ class bt {
|
|
|
1892
1971
|
method: "entity.item.add",
|
|
1893
1972
|
params: {
|
|
1894
1973
|
ENTITY: this.entityName,
|
|
1895
|
-
NAME: (
|
|
1974
|
+
NAME: (r = this.bx.userInfo) == null ? void 0 : r.ID,
|
|
1896
1975
|
DETAIL_TEXT: JSON.stringify(e)
|
|
1897
1976
|
}
|
|
1898
1977
|
}) || 0;
|
|
1899
1978
|
}
|
|
1900
1979
|
async updateTab(e) {
|
|
1901
1980
|
var i;
|
|
1902
|
-
const
|
|
1981
|
+
const r = {
|
|
1903
1982
|
lastActive: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1904
1983
|
duration: (/* @__PURE__ */ new Date()).getTime() - this.start.getTime(),
|
|
1905
1984
|
start: e
|
|
@@ -1910,18 +1989,18 @@ class bt {
|
|
|
1910
1989
|
ENTITY: this.entityName,
|
|
1911
1990
|
ID: this.id,
|
|
1912
1991
|
NAME: (i = this.bx.userInfo) == null ? void 0 : i.ID,
|
|
1913
|
-
DETAIL_TEXT: JSON.stringify(
|
|
1992
|
+
DETAIL_TEXT: JSON.stringify(r)
|
|
1914
1993
|
}
|
|
1915
1994
|
});
|
|
1916
1995
|
}
|
|
1917
1996
|
async deleteTabs(e = []) {
|
|
1918
1997
|
if (!e.length)
|
|
1919
1998
|
return;
|
|
1920
|
-
const
|
|
1999
|
+
const r = e.map((i) => ({
|
|
1921
2000
|
method: "entity.item.delete",
|
|
1922
2001
|
params: { ENTITY: this.entityName, ID: i.id }
|
|
1923
2002
|
}));
|
|
1924
|
-
|
|
2003
|
+
r.length && await this.bx.batch(r);
|
|
1925
2004
|
}
|
|
1926
2005
|
getRandomNum() {
|
|
1927
2006
|
const e = Math.round(Number(Math.random().toFixed(2)) * 30);
|
|
@@ -1929,22 +2008,22 @@ class bt {
|
|
|
1929
2008
|
}
|
|
1930
2009
|
async continueBackground() {
|
|
1931
2010
|
try {
|
|
1932
|
-
const
|
|
1933
|
-
return console.log(
|
|
2011
|
+
const r = !!await Promise.resolve(this.continueCondition(this));
|
|
2012
|
+
return console.log(r ? "BackgroundWorker: Условие продолжения выполнено" : "BackgroundWorker: Отмена continueBackground - внешнее условие вернуло false"), r;
|
|
1934
2013
|
} catch (e) {
|
|
1935
2014
|
return console.error("BackgroundWorker: Ошибка при выполнении условия продолжения", e), console.log("BackgroundWorker: Отмена continueBackground - исключение в условии запуска"), !1;
|
|
1936
2015
|
}
|
|
1937
2016
|
}
|
|
1938
2017
|
async getFilteredTabList() {
|
|
1939
|
-
const e = [],
|
|
2018
|
+
const e = [], r = [], i = await this.getTabs();
|
|
1940
2019
|
for (const A of i) {
|
|
1941
2020
|
if (!(A != null && A.data)) {
|
|
1942
2021
|
e.push(A);
|
|
1943
2022
|
continue;
|
|
1944
2023
|
}
|
|
1945
|
-
(/* @__PURE__ */ new Date()).getTime() - new Date(A.data.lastActive).getTime() > this.activeMaxPause ? e.push(A) :
|
|
2024
|
+
(/* @__PURE__ */ new Date()).getTime() - new Date(A.data.lastActive).getTime() > this.activeMaxPause ? e.push(A) : r.push(A);
|
|
1946
2025
|
}
|
|
1947
|
-
return await this.deleteTabs(e),
|
|
2026
|
+
return await this.deleteTabs(e), r;
|
|
1948
2027
|
}
|
|
1949
2028
|
async backgroundPolling() {
|
|
1950
2029
|
if (!await this.continueBackground()) {
|
|
@@ -1959,14 +2038,14 @@ class bt {
|
|
|
1959
2038
|
e && (await this.pause(Math.round(Number(Math.random().toFixed(2)) * 1e4)), this.tabList = await this.getFilteredTabList(), e = this.checkOtherTabs(), e && await this.startBackground());
|
|
1960
2039
|
}
|
|
1961
2040
|
checkOtherTabs() {
|
|
1962
|
-
var A,
|
|
1963
|
-
let e = !1,
|
|
2041
|
+
var A, o;
|
|
2042
|
+
let e = !1, r = (/* @__PURE__ */ new Date()).getTime() - new Date(this.start).getTime();
|
|
1964
2043
|
for (const h of this.tabList)
|
|
1965
|
-
if (+h.id !== this.id && ((A = h.data) != null && A.start && (e = !0), ((
|
|
1966
|
-
|
|
2044
|
+
if (+h.id !== this.id && ((A = h.data) != null && A.start && (e = !0), ((o = h.data) == null ? void 0 : o.duration) > r)) {
|
|
2045
|
+
r = !1;
|
|
1967
2046
|
break;
|
|
1968
2047
|
}
|
|
1969
|
-
const i = !e && !!
|
|
2048
|
+
const i = !e && !!r;
|
|
1970
2049
|
return this.updateTab(i).catch((h) => {
|
|
1971
2050
|
console.error("BackgroundWorker: updateTab failed", h);
|
|
1972
2051
|
}), console.log(`BackgroundWorker: Проверка вкладок - можно запускать приложение? ${i}`), i;
|
|
@@ -1979,22 +2058,22 @@ class bt {
|
|
|
1979
2058
|
}, this.activeMinPause), await this.appInit(), this.interval && (clearInterval(this.interval), this.interval = void 0), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
|
|
1980
2059
|
}
|
|
1981
2060
|
async setBackgroundWorkerAll() {
|
|
1982
|
-
var d,
|
|
2061
|
+
var d, g;
|
|
1983
2062
|
if (!((d = this.bx) != null && d.isAdmin)) {
|
|
1984
2063
|
console.log("BackgroundWorker: Отмена setBackgroundWorkerAll - пользователь не админ");
|
|
1985
2064
|
return;
|
|
1986
2065
|
}
|
|
1987
|
-
(
|
|
1988
|
-
const e = await this.bx.getPlacement(),
|
|
2066
|
+
(g = this.users) != null && g.length || await this.getEntityData();
|
|
2067
|
+
const e = await this.bx.getPlacement(), r = /* @__PURE__ */ new Map();
|
|
1989
2068
|
let i = null;
|
|
1990
|
-
e.forEach((
|
|
1991
|
-
|
|
1992
|
-
}), console.log(`setBackgroundWorkerAll: Найдено ${
|
|
1993
|
-
const A = await this.
|
|
1994
|
-
|
|
1995
|
-
const
|
|
1996
|
-
return (u.LAST_LOGIN ? new Date(u.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) -
|
|
1997
|
-
}), console.log(`setBackgroundWorkerAll: Найдено ${
|
|
2069
|
+
e.forEach((a) => {
|
|
2070
|
+
a.placement === "PAGE_BACKGROUND_WORKER" && (a.userId ? r.set(+a.userId, a) : i = a);
|
|
2071
|
+
}), console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i ? 1 : 0} общих привязок PAGE_BACKGROUND_WORKER`);
|
|
2072
|
+
const A = await this.updateAdminsList(), o = await this.getEligibleUsersForBackgroundWorker(A);
|
|
2073
|
+
o.sort((a, u) => {
|
|
2074
|
+
const y = a.LAST_LOGIN ? new Date(a.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
|
|
2075
|
+
return (u.LAST_LOGIN ? new Date(u.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - y;
|
|
2076
|
+
}), console.log(`setBackgroundWorkerAll: Найдено ${o.length} подходящих пользователей (админы и руководители)`);
|
|
1998
2077
|
const h = [];
|
|
1999
2078
|
!i && this.appPath && (h.push({
|
|
2000
2079
|
method: "placement.bind",
|
|
@@ -2011,32 +2090,32 @@ class bt {
|
|
|
2011
2090
|
}
|
|
2012
2091
|
}
|
|
2013
2092
|
}), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера"));
|
|
2014
|
-
const m = 10,
|
|
2015
|
-
for (const [
|
|
2016
|
-
|
|
2017
|
-
for (const
|
|
2093
|
+
const m = 10, l = o.slice(0, m), s = [];
|
|
2094
|
+
for (const [a] of r)
|
|
2095
|
+
o.find((y) => +y.ID === a) || s.push(a);
|
|
2096
|
+
for (const a of s)
|
|
2018
2097
|
this.appPath && (h.push({
|
|
2019
2098
|
method: "placement.unbind",
|
|
2020
2099
|
params: {
|
|
2021
2100
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2022
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2101
|
+
HANDLER: `${this.appPath}?USER_ID=${a}/`
|
|
2023
2102
|
}
|
|
2024
|
-
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${
|
|
2025
|
-
for (const
|
|
2026
|
-
|
|
2103
|
+
}), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${a}`));
|
|
2104
|
+
for (const a of l)
|
|
2105
|
+
r.has(+a.ID) || !this.appPath || h.push({
|
|
2027
2106
|
method: "placement.bind",
|
|
2028
2107
|
params: {
|
|
2029
2108
|
PLACEMENT: "PAGE_BACKGROUND_WORKER",
|
|
2030
|
-
HANDLER: `${this.appPath}?USER_ID=${
|
|
2109
|
+
HANDLER: `${this.appPath}?USER_ID=${a.ID}/`,
|
|
2031
2110
|
LANG_ALL: {
|
|
2032
2111
|
ru: {
|
|
2033
2112
|
TITLE: this.appName
|
|
2034
2113
|
}
|
|
2035
2114
|
},
|
|
2036
2115
|
OPTIONS: {
|
|
2037
|
-
errorHandlerUrl: `${this.appPath}?USER_ID=${
|
|
2116
|
+
errorHandlerUrl: `${this.appPath}?USER_ID=${a.ID}/`
|
|
2038
2117
|
},
|
|
2039
|
-
USER_ID:
|
|
2118
|
+
USER_ID: a.ID
|
|
2040
2119
|
}
|
|
2041
2120
|
});
|
|
2042
2121
|
h.length ? (console.log(`setBackgroundWorkerAll: Выполняем ${h.length} операций через batch`), await this.bx.batch(h), console.log("setBackgroundWorkerAll: Все операции batch выполнены успешно")) : console.log("setBackgroundWorkerAll: Нет операций для выполнения");
|
|
@@ -2048,22 +2127,15 @@ class bt {
|
|
|
2048
2127
|
});
|
|
2049
2128
|
}
|
|
2050
2129
|
async updateAdminsList() {
|
|
2051
|
-
var e,
|
|
2130
|
+
var e, r, i;
|
|
2052
2131
|
try {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
}
|
|
2061
|
-
const h = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2062
|
-
(s = this.bx) != null && s.isAdmin && h && !a.includes(h) && (a.push(h), console.log(`updateAdminsList: Добавлен новый админ ${h}`)), !((i = this.bx) != null && i.isAdmin) && h && a.includes(h) && (a = a.filter((r) => r !== h), console.log(`updateAdminsList: Удален из списка админов пользователь ${h} (больше не админ)`));
|
|
2063
|
-
const m = new Set(
|
|
2064
|
-
(this.users ?? []).filter((r) => r.ACTIVE === "Y" || r.ACTIVE === !0).map((r) => +r.ID)
|
|
2065
|
-
), f = a.filter((r) => m.has(r));
|
|
2066
|
-
return f.length !== a.length && (console.log(`updateAdminsList: Удалено ${a.length - f.length} неактивных админов`), a = f), BX24.appOption.set("adminsList", JSON.stringify(a)), console.log(`BackgroundWorker: Список админов обновлен: ${a.length} админов`), a;
|
|
2132
|
+
let A = await this.getAdminsList();
|
|
2133
|
+
const o = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
|
|
2134
|
+
(r = this.bx) != null && r.isAdmin && o && !A.includes(o) && (A.push(o), console.log(`updateAdminsList: Добавлен новый админ ${o}`)), !((i = this.bx) != null && i.isAdmin) && o && A.includes(o) && (A = A.filter((l) => l !== o), console.log(`updateAdminsList: Удален из списка админов пользователь ${o} (больше не админ)`));
|
|
2135
|
+
const h = new Set(
|
|
2136
|
+
(this.users ?? []).filter((l) => l.ACTIVE === "Y" || l.ACTIVE === !0).map((l) => +l.ID)
|
|
2137
|
+
), m = A.filter((l) => h.has(l));
|
|
2138
|
+
return m.length !== A.length && (console.log(`updateAdminsList: Удалено ${A.length - m.length} неактивных админов`), A = m), BX24.appOption.set("adminsList", JSON.stringify(A)), console.log(`BackgroundWorker: Список админов обновлен: ${A.length} админов`), A;
|
|
2067
2139
|
} catch (A) {
|
|
2068
2140
|
return console.error("BackgroundWorker: Ошибка при обновлении списка админов:", A), [];
|
|
2069
2141
|
}
|
|
@@ -2079,21 +2151,21 @@ class bt {
|
|
|
2079
2151
|
async getEntityData() {
|
|
2080
2152
|
const e = {
|
|
2081
2153
|
users: { method: "user.get", params: { filter: { ACTIVE: "Y" } } }
|
|
2082
|
-
}, { users:
|
|
2083
|
-
this.users =
|
|
2154
|
+
}, { users: r } = await this.bx.batch(e).then((i) => i ? (Array.isArray(i.users) || (i.users = []), i) : { users: [] });
|
|
2155
|
+
this.users = r;
|
|
2084
2156
|
}
|
|
2085
|
-
pause(e = 500,
|
|
2157
|
+
pause(e = 500, r) {
|
|
2086
2158
|
return new Promise((i) => {
|
|
2087
2159
|
setTimeout(() => {
|
|
2088
|
-
|
|
2160
|
+
r && r(), i(!0);
|
|
2089
2161
|
}, e);
|
|
2090
2162
|
});
|
|
2091
2163
|
}
|
|
2092
2164
|
}
|
|
2093
2165
|
export {
|
|
2094
|
-
|
|
2166
|
+
St as BackgroundWorker,
|
|
2095
2167
|
j as Batch,
|
|
2096
|
-
|
|
2168
|
+
bt as BxBoot,
|
|
2097
2169
|
ut as BxHelper,
|
|
2098
2170
|
Rt as BxLogger,
|
|
2099
2171
|
et as tempus
|