@bitrix24/b24jssdk 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.cjs +460 -190
- package/dist/commonjs/index.cjs.map +1 -1
- package/dist/commonjs/index.d.cts +139 -71
- package/dist/commonjs/index.d.mts +139 -71
- package/dist/commonjs/index.d.ts +139 -71
- package/dist/esm/index.d.mts +139 -71
- package/dist/esm/index.d.ts +139 -71
- package/dist/esm/index.mjs +458 -191
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +625 -532
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +24 -18
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +72 -76
package/dist/umd/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.1
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.2.1
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
@@ -491,6 +491,24 @@
|
|
|
491
491
|
}
|
|
492
492
|
const Type = new TypeManager();
|
|
493
493
|
|
|
494
|
+
function pick$1(data, keys) {
|
|
495
|
+
const result = {};
|
|
496
|
+
for (const key of keys) {
|
|
497
|
+
result[key] = data[key];
|
|
498
|
+
}
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
function omit(data, keys) {
|
|
502
|
+
const result = { ...data };
|
|
503
|
+
for (const key of keys) {
|
|
504
|
+
delete result[key];
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
function isArrayOfArray(item) {
|
|
509
|
+
return Array.isArray(item[0]);
|
|
510
|
+
}
|
|
511
|
+
|
|
494
512
|
// these aren't really private, but nor are they really useful to document
|
|
495
513
|
|
|
496
514
|
/**
|
|
@@ -885,12 +903,13 @@
|
|
|
885
903
|
}
|
|
886
904
|
}
|
|
887
905
|
|
|
888
|
-
|
|
889
|
-
function makeDTF(
|
|
890
|
-
|
|
891
|
-
|
|
906
|
+
const dtfCache = new Map();
|
|
907
|
+
function makeDTF(zoneName) {
|
|
908
|
+
let dtf = dtfCache.get(zoneName);
|
|
909
|
+
if (dtf === undefined) {
|
|
910
|
+
dtf = new Intl.DateTimeFormat("en-US", {
|
|
892
911
|
hour12: false,
|
|
893
|
-
timeZone:
|
|
912
|
+
timeZone: zoneName,
|
|
894
913
|
year: "numeric",
|
|
895
914
|
month: "2-digit",
|
|
896
915
|
day: "2-digit",
|
|
@@ -899,8 +918,9 @@
|
|
|
899
918
|
second: "2-digit",
|
|
900
919
|
era: "short",
|
|
901
920
|
});
|
|
921
|
+
dtfCache.set(zoneName, dtf);
|
|
902
922
|
}
|
|
903
|
-
return
|
|
923
|
+
return dtf;
|
|
904
924
|
}
|
|
905
925
|
|
|
906
926
|
const typeToPos = {
|
|
@@ -936,7 +956,7 @@
|
|
|
936
956
|
return filled;
|
|
937
957
|
}
|
|
938
958
|
|
|
939
|
-
|
|
959
|
+
const ianaZoneCache = new Map();
|
|
940
960
|
/**
|
|
941
961
|
* A zone identified by an IANA identifier, like America/New_York
|
|
942
962
|
* @implements {Zone}
|
|
@@ -947,10 +967,11 @@
|
|
|
947
967
|
* @return {IANAZone}
|
|
948
968
|
*/
|
|
949
969
|
static create(name) {
|
|
950
|
-
|
|
951
|
-
|
|
970
|
+
let zone = ianaZoneCache.get(name);
|
|
971
|
+
if (zone === undefined) {
|
|
972
|
+
ianaZoneCache.set(name, (zone = new IANAZone(name)));
|
|
952
973
|
}
|
|
953
|
-
return
|
|
974
|
+
return zone;
|
|
954
975
|
}
|
|
955
976
|
|
|
956
977
|
/**
|
|
@@ -958,8 +979,8 @@
|
|
|
958
979
|
* @return {void}
|
|
959
980
|
*/
|
|
960
981
|
static resetCache() {
|
|
961
|
-
ianaZoneCache
|
|
962
|
-
dtfCache
|
|
982
|
+
ianaZoneCache.clear();
|
|
983
|
+
dtfCache.clear();
|
|
963
984
|
}
|
|
964
985
|
|
|
965
986
|
/**
|
|
@@ -1062,6 +1083,7 @@
|
|
|
1062
1083
|
* @return {number}
|
|
1063
1084
|
*/
|
|
1064
1085
|
offset(ts) {
|
|
1086
|
+
if (!this.valid) return NaN;
|
|
1065
1087
|
const date = new Date(ts);
|
|
1066
1088
|
|
|
1067
1089
|
if (isNaN(date)) return NaN;
|
|
@@ -1127,36 +1149,36 @@
|
|
|
1127
1149
|
return dtf;
|
|
1128
1150
|
}
|
|
1129
1151
|
|
|
1130
|
-
|
|
1152
|
+
const intlDTCache = new Map();
|
|
1131
1153
|
function getCachedDTF(locString, opts = {}) {
|
|
1132
1154
|
const key = JSON.stringify([locString, opts]);
|
|
1133
|
-
let dtf = intlDTCache
|
|
1134
|
-
if (
|
|
1155
|
+
let dtf = intlDTCache.get(key);
|
|
1156
|
+
if (dtf === undefined) {
|
|
1135
1157
|
dtf = new Intl.DateTimeFormat(locString, opts);
|
|
1136
|
-
intlDTCache
|
|
1158
|
+
intlDTCache.set(key, dtf);
|
|
1137
1159
|
}
|
|
1138
1160
|
return dtf;
|
|
1139
1161
|
}
|
|
1140
1162
|
|
|
1141
|
-
|
|
1163
|
+
const intlNumCache = new Map();
|
|
1142
1164
|
function getCachedINF(locString, opts = {}) {
|
|
1143
1165
|
const key = JSON.stringify([locString, opts]);
|
|
1144
|
-
let inf = intlNumCache
|
|
1145
|
-
if (
|
|
1166
|
+
let inf = intlNumCache.get(key);
|
|
1167
|
+
if (inf === undefined) {
|
|
1146
1168
|
inf = new Intl.NumberFormat(locString, opts);
|
|
1147
|
-
intlNumCache
|
|
1169
|
+
intlNumCache.set(key, inf);
|
|
1148
1170
|
}
|
|
1149
1171
|
return inf;
|
|
1150
1172
|
}
|
|
1151
1173
|
|
|
1152
|
-
|
|
1174
|
+
const intlRelCache = new Map();
|
|
1153
1175
|
function getCachedRTF(locString, opts = {}) {
|
|
1154
1176
|
const { base, ...cacheKeyOpts } = opts; // exclude `base` from the options
|
|
1155
1177
|
const key = JSON.stringify([locString, cacheKeyOpts]);
|
|
1156
|
-
let inf = intlRelCache
|
|
1157
|
-
if (
|
|
1178
|
+
let inf = intlRelCache.get(key);
|
|
1179
|
+
if (inf === undefined) {
|
|
1158
1180
|
inf = new Intl.RelativeTimeFormat(locString, opts);
|
|
1159
|
-
intlRelCache
|
|
1181
|
+
intlRelCache.set(key, inf);
|
|
1160
1182
|
}
|
|
1161
1183
|
return inf;
|
|
1162
1184
|
}
|
|
@@ -1171,14 +1193,28 @@
|
|
|
1171
1193
|
}
|
|
1172
1194
|
}
|
|
1173
1195
|
|
|
1174
|
-
|
|
1196
|
+
const intlResolvedOptionsCache = new Map();
|
|
1197
|
+
function getCachedIntResolvedOptions(locString) {
|
|
1198
|
+
let opts = intlResolvedOptionsCache.get(locString);
|
|
1199
|
+
if (opts === undefined) {
|
|
1200
|
+
opts = new Intl.DateTimeFormat(locString).resolvedOptions();
|
|
1201
|
+
intlResolvedOptionsCache.set(locString, opts);
|
|
1202
|
+
}
|
|
1203
|
+
return opts;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
const weekInfoCache = new Map();
|
|
1175
1207
|
function getCachedWeekInfo(locString) {
|
|
1176
|
-
let data = weekInfoCache
|
|
1208
|
+
let data = weekInfoCache.get(locString);
|
|
1177
1209
|
if (!data) {
|
|
1178
1210
|
const locale = new Intl.Locale(locString);
|
|
1179
1211
|
// browsers currently implement this as a property, but spec says it should be a getter function
|
|
1180
1212
|
data = "getWeekInfo" in locale ? locale.getWeekInfo() : locale.weekInfo;
|
|
1181
|
-
|
|
1213
|
+
// minimalDays was removed from WeekInfo: https://github.com/tc39/proposal-intl-locale-info/issues/86
|
|
1214
|
+
if (!("minimalDays" in data)) {
|
|
1215
|
+
data = { ...fallbackWeekSettings, ...data };
|
|
1216
|
+
}
|
|
1217
|
+
weekInfoCache.set(locString, data);
|
|
1182
1218
|
}
|
|
1183
1219
|
return data;
|
|
1184
1220
|
}
|
|
@@ -1277,7 +1313,7 @@
|
|
|
1277
1313
|
loc.numberingSystem === "latn" ||
|
|
1278
1314
|
!loc.locale ||
|
|
1279
1315
|
loc.locale.startsWith("en") ||
|
|
1280
|
-
|
|
1316
|
+
getCachedIntResolvedOptions(loc.locale).numberingSystem === "latn"
|
|
1281
1317
|
);
|
|
1282
1318
|
}
|
|
1283
1319
|
}
|
|
@@ -1436,7 +1472,6 @@
|
|
|
1436
1472
|
/**
|
|
1437
1473
|
* @private
|
|
1438
1474
|
*/
|
|
1439
|
-
|
|
1440
1475
|
class Locale {
|
|
1441
1476
|
static fromOpts(opts) {
|
|
1442
1477
|
return Locale.create(
|
|
@@ -1460,9 +1495,11 @@
|
|
|
1460
1495
|
|
|
1461
1496
|
static resetCache() {
|
|
1462
1497
|
sysLocaleCache = null;
|
|
1463
|
-
intlDTCache
|
|
1464
|
-
intlNumCache
|
|
1465
|
-
intlRelCache
|
|
1498
|
+
intlDTCache.clear();
|
|
1499
|
+
intlNumCache.clear();
|
|
1500
|
+
intlRelCache.clear();
|
|
1501
|
+
intlResolvedOptionsCache.clear();
|
|
1502
|
+
weekInfoCache.clear();
|
|
1466
1503
|
}
|
|
1467
1504
|
|
|
1468
1505
|
static fromObject({ locale, numberingSystem, outputCalendar, weekSettings } = {}) {
|
|
@@ -1616,7 +1653,7 @@
|
|
|
1616
1653
|
return (
|
|
1617
1654
|
this.locale === "en" ||
|
|
1618
1655
|
this.locale.toLowerCase() === "en-us" ||
|
|
1619
|
-
|
|
1656
|
+
getCachedIntResolvedOptions(this.intl).locale.startsWith("en-us")
|
|
1620
1657
|
);
|
|
1621
1658
|
}
|
|
1622
1659
|
|
|
@@ -1955,22 +1992,26 @@
|
|
|
1955
1992
|
}
|
|
1956
1993
|
|
|
1957
1994
|
// cache of {numberingSystem: {append: regex}}
|
|
1958
|
-
|
|
1995
|
+
const digitRegexCache = new Map();
|
|
1959
1996
|
function resetDigitRegexCache() {
|
|
1960
|
-
digitRegexCache
|
|
1997
|
+
digitRegexCache.clear();
|
|
1961
1998
|
}
|
|
1962
1999
|
|
|
1963
2000
|
function digitRegex({ numberingSystem }, append = "") {
|
|
1964
2001
|
const ns = numberingSystem || "latn";
|
|
1965
2002
|
|
|
1966
|
-
|
|
1967
|
-
|
|
2003
|
+
let appendCache = digitRegexCache.get(ns);
|
|
2004
|
+
if (appendCache === undefined) {
|
|
2005
|
+
appendCache = new Map();
|
|
2006
|
+
digitRegexCache.set(ns, appendCache);
|
|
1968
2007
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
2008
|
+
let regex = appendCache.get(append);
|
|
2009
|
+
if (regex === undefined) {
|
|
2010
|
+
regex = new RegExp(`${numberingSystems[ns]}${append}`);
|
|
2011
|
+
appendCache.set(append, regex);
|
|
1971
2012
|
}
|
|
1972
2013
|
|
|
1973
|
-
return
|
|
2014
|
+
return regex;
|
|
1974
2015
|
}
|
|
1975
2016
|
|
|
1976
2017
|
let now = () => Date.now(),
|
|
@@ -4722,6 +4763,14 @@
|
|
|
4722
4763
|
return this.isValid ? this.e : null;
|
|
4723
4764
|
}
|
|
4724
4765
|
|
|
4766
|
+
/**
|
|
4767
|
+
* Returns the last DateTime included in the interval (since end is not part of the interval)
|
|
4768
|
+
* @type {DateTime}
|
|
4769
|
+
*/
|
|
4770
|
+
get lastDateTime() {
|
|
4771
|
+
return this.isValid ? (this.e ? this.e.minus(1) : null) : null;
|
|
4772
|
+
}
|
|
4773
|
+
|
|
4725
4774
|
/**
|
|
4726
4775
|
* Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
|
|
4727
4776
|
* @type {boolean}
|
|
@@ -4986,8 +5035,11 @@
|
|
|
4986
5035
|
}
|
|
4987
5036
|
|
|
4988
5037
|
/**
|
|
4989
|
-
* Merge an array of Intervals into
|
|
5038
|
+
* Merge an array of Intervals into an equivalent minimal set of Intervals.
|
|
4990
5039
|
* Combines overlapping and adjacent Intervals.
|
|
5040
|
+
* The resulting array will contain the Intervals in ascending order, that is, starting with the earliest Interval
|
|
5041
|
+
* and ending with the latest.
|
|
5042
|
+
*
|
|
4991
5043
|
* @param {Array} intervals
|
|
4992
5044
|
* @return {Array}
|
|
4993
5045
|
*/
|
|
@@ -6310,15 +6362,27 @@
|
|
|
6310
6362
|
// This is safe for quickDT (used by local() and utc()) because we don't fill in
|
|
6311
6363
|
// higher-order units from tsNow (as we do in fromObject, this requires that
|
|
6312
6364
|
// offset is calculated from tsNow).
|
|
6365
|
+
/**
|
|
6366
|
+
* @param {Zone} zone
|
|
6367
|
+
* @return {number}
|
|
6368
|
+
*/
|
|
6313
6369
|
function guessOffsetForZone(zone) {
|
|
6314
|
-
if (
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
}
|
|
6370
|
+
if (zoneOffsetTs === undefined) {
|
|
6371
|
+
zoneOffsetTs = Settings.now();
|
|
6372
|
+
}
|
|
6318
6373
|
|
|
6319
|
-
|
|
6374
|
+
// Do not cache anything but IANA zones, because it is not safe to do so.
|
|
6375
|
+
// Guessing an offset which is not present in the zone can cause wrong results from fixOffset
|
|
6376
|
+
if (zone.type !== "iana") {
|
|
6377
|
+
return zone.offset(zoneOffsetTs);
|
|
6378
|
+
}
|
|
6379
|
+
const zoneName = zone.name;
|
|
6380
|
+
let offsetGuess = zoneOffsetGuessCache.get(zoneName);
|
|
6381
|
+
if (offsetGuess === undefined) {
|
|
6382
|
+
offsetGuess = zone.offset(zoneOffsetTs);
|
|
6383
|
+
zoneOffsetGuessCache.set(zoneName, offsetGuess);
|
|
6320
6384
|
}
|
|
6321
|
-
return
|
|
6385
|
+
return offsetGuess;
|
|
6322
6386
|
}
|
|
6323
6387
|
|
|
6324
6388
|
// this is a dumbed down version of fromObject() that runs about 60% faster
|
|
@@ -6408,7 +6472,7 @@
|
|
|
6408
6472
|
* This optimizes quickDT via guessOffsetForZone to avoid repeated calls of
|
|
6409
6473
|
* zone.offset().
|
|
6410
6474
|
*/
|
|
6411
|
-
|
|
6475
|
+
const zoneOffsetGuessCache = new Map();
|
|
6412
6476
|
|
|
6413
6477
|
/**
|
|
6414
6478
|
* A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
|
|
@@ -6612,7 +6676,7 @@
|
|
|
6612
6676
|
throw new InvalidArgumentError(
|
|
6613
6677
|
`fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
|
|
6614
6678
|
);
|
|
6615
|
-
} else if (milliseconds < -
|
|
6679
|
+
} else if (milliseconds < -864e13 || milliseconds > MAX_DATE) {
|
|
6616
6680
|
// this isn't perfect because we can still end up out of range because of additional shifting, but it's a start
|
|
6617
6681
|
return DateTime.invalid("Timestamp out of range");
|
|
6618
6682
|
} else {
|
|
@@ -6973,7 +7037,7 @@
|
|
|
6973
7037
|
|
|
6974
7038
|
static resetCache() {
|
|
6975
7039
|
zoneOffsetTs = undefined;
|
|
6976
|
-
zoneOffsetGuessCache
|
|
7040
|
+
zoneOffsetGuessCache.clear();
|
|
6977
7041
|
}
|
|
6978
7042
|
|
|
6979
7043
|
// INFO
|
|
@@ -7742,7 +7806,7 @@
|
|
|
7742
7806
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|
7743
7807
|
* @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
|
|
7744
7808
|
* @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
|
|
7745
|
-
* @return {string}
|
|
7809
|
+
* @return {string|null}
|
|
7746
7810
|
*/
|
|
7747
7811
|
toISO({
|
|
7748
7812
|
format = "extended",
|
|
@@ -7769,7 +7833,7 @@
|
|
|
7769
7833
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
7770
7834
|
* @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
|
|
7771
7835
|
* @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
|
|
7772
|
-
* @return {string}
|
|
7836
|
+
* @return {string|null}
|
|
7773
7837
|
*/
|
|
7774
7838
|
toISODate({ format = "extended" } = {}) {
|
|
7775
7839
|
if (!this.isValid) {
|
|
@@ -7854,7 +7918,7 @@
|
|
|
7854
7918
|
/**
|
|
7855
7919
|
* Returns a string representation of this DateTime appropriate for use in SQL Date
|
|
7856
7920
|
* @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
|
|
7857
|
-
* @return {string}
|
|
7921
|
+
* @return {string|null}
|
|
7858
7922
|
*/
|
|
7859
7923
|
toSQLDate() {
|
|
7860
7924
|
if (!this.isValid) {
|
|
@@ -7949,7 +8013,7 @@
|
|
|
7949
8013
|
}
|
|
7950
8014
|
|
|
7951
8015
|
/**
|
|
7952
|
-
* Returns the epoch seconds of this DateTime.
|
|
8016
|
+
* Returns the epoch seconds (including milliseconds in the fractional part) of this DateTime.
|
|
7953
8017
|
* @return {number}
|
|
7954
8018
|
*/
|
|
7955
8019
|
toSeconds() {
|
|
@@ -8056,7 +8120,7 @@
|
|
|
8056
8120
|
/**
|
|
8057
8121
|
* Return an Interval spanning between this DateTime and another DateTime
|
|
8058
8122
|
* @param {DateTime} otherDateTime - the other end point of the Interval
|
|
8059
|
-
* @return {Interval}
|
|
8123
|
+
* @return {Interval|DateTime}
|
|
8060
8124
|
*/
|
|
8061
8125
|
until(otherDateTime) {
|
|
8062
8126
|
return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
|
|
@@ -8649,7 +8713,6 @@
|
|
|
8649
8713
|
return str;
|
|
8650
8714
|
}
|
|
8651
8715
|
const matches = str.match(
|
|
8652
|
-
// eslint-disable-next-line
|
|
8653
8716
|
/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g
|
|
8654
8717
|
);
|
|
8655
8718
|
if (!matches) {
|
|
@@ -9018,75 +9081,42 @@
|
|
|
9018
9081
|
})(RpcMethod || {});
|
|
9019
9082
|
|
|
9020
9083
|
class Result {
|
|
9021
|
-
|
|
9084
|
+
_errors;
|
|
9022
9085
|
_data;
|
|
9023
|
-
constructor() {
|
|
9024
|
-
this.
|
|
9025
|
-
this._data = null;
|
|
9086
|
+
constructor(data) {
|
|
9087
|
+
this._errors = /* @__PURE__ */ new Map();
|
|
9088
|
+
this._data = data ?? null;
|
|
9026
9089
|
}
|
|
9027
|
-
/**
|
|
9028
|
-
* Getter for the `isSuccess` property.
|
|
9029
|
-
* Checks if the `_errorCollection` is empty to determine success.
|
|
9030
|
-
*
|
|
9031
|
-
* @returns Whether the operation resulted in success (no errors).
|
|
9032
|
-
*/
|
|
9033
9090
|
get isSuccess() {
|
|
9034
|
-
return this.
|
|
9091
|
+
return this._errors.size === 0;
|
|
9092
|
+
}
|
|
9093
|
+
get errors() {
|
|
9094
|
+
return this._errors;
|
|
9035
9095
|
}
|
|
9036
|
-
/**
|
|
9037
|
-
* Sets the data associated with the result.
|
|
9038
|
-
*
|
|
9039
|
-
* @param data The data to be stored in the result.
|
|
9040
|
-
* @returns The current Result object for chaining methods.
|
|
9041
|
-
*/
|
|
9042
9096
|
setData(data) {
|
|
9043
9097
|
this._data = data;
|
|
9044
9098
|
return this;
|
|
9045
9099
|
}
|
|
9046
|
-
/**
|
|
9047
|
-
* Retrieves the data associated with the result.
|
|
9048
|
-
*
|
|
9049
|
-
* @returns The data stored in the result, if any.
|
|
9050
|
-
*/
|
|
9051
9100
|
getData() {
|
|
9052
9101
|
return this._data;
|
|
9053
9102
|
}
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
* @returns The current Result object for chaining methods.
|
|
9059
|
-
*/
|
|
9060
|
-
addError(error) {
|
|
9061
|
-
if (error instanceof Error) {
|
|
9062
|
-
this._errorCollection.add(error);
|
|
9063
|
-
} else {
|
|
9064
|
-
this._errorCollection.add(new Error(error.toString()));
|
|
9065
|
-
}
|
|
9103
|
+
addError(error, key) {
|
|
9104
|
+
const errorKey = key ?? Text.getUuidRfc4122();
|
|
9105
|
+
const errorObj = typeof error === "string" ? new Error(error) : error;
|
|
9106
|
+
this._errors.set(errorKey, errorObj);
|
|
9066
9107
|
return this;
|
|
9067
9108
|
}
|
|
9068
|
-
/**
|
|
9069
|
-
* Adds multiple errors to the result in a single call.
|
|
9070
|
-
*
|
|
9071
|
-
* @param errors An array of errors or strings that will be converted to errors.
|
|
9072
|
-
* @returns The current Result object for chaining methods.
|
|
9073
|
-
*/
|
|
9074
9109
|
addErrors(errors) {
|
|
9075
9110
|
for (const error of errors) {
|
|
9076
|
-
|
|
9077
|
-
this._errorCollection.add(error);
|
|
9078
|
-
} else {
|
|
9079
|
-
this._errorCollection.add(new Error(error.toString()));
|
|
9080
|
-
}
|
|
9111
|
+
this.addError(error);
|
|
9081
9112
|
}
|
|
9082
9113
|
return this;
|
|
9083
9114
|
}
|
|
9084
|
-
/**
|
|
9085
|
-
* Retrieves an iterator for the errors collected in the result.
|
|
9086
|
-
* @returns An iterator over the stored Error objects.
|
|
9087
|
-
*/
|
|
9088
9115
|
getErrors() {
|
|
9089
|
-
return this.
|
|
9116
|
+
return this._errors.values();
|
|
9117
|
+
}
|
|
9118
|
+
hasError(key) {
|
|
9119
|
+
return this._errors.has(key);
|
|
9090
9120
|
}
|
|
9091
9121
|
/**
|
|
9092
9122
|
* Retrieves an array of error messages from the collected errors.
|
|
@@ -9095,7 +9125,7 @@
|
|
|
9095
9125
|
* contains the message of a corresponding error object.
|
|
9096
9126
|
*/
|
|
9097
9127
|
getErrorMessages() {
|
|
9098
|
-
return
|
|
9128
|
+
return Array.from(this._errors.values(), (e) => e.message);
|
|
9099
9129
|
}
|
|
9100
9130
|
/**
|
|
9101
9131
|
* Converts the Result object to a string.
|
|
@@ -9103,36 +9133,168 @@
|
|
|
9103
9133
|
* @returns {string} Returns a string representation of the result operation
|
|
9104
9134
|
*/
|
|
9105
9135
|
toString() {
|
|
9106
|
-
|
|
9107
|
-
|
|
9136
|
+
const status = this.isSuccess ? "success" : "failure";
|
|
9137
|
+
const data = this.safeStringify(this._data);
|
|
9138
|
+
return this.isSuccess ? `Result(${status}): ${data}` : `Result(${status}): ${data}
|
|
9139
|
+
Errors: ${this.getErrorMessages().join(", ")}`;
|
|
9140
|
+
}
|
|
9141
|
+
safeStringify(data) {
|
|
9142
|
+
try {
|
|
9143
|
+
return JSON.stringify(data, this.replacer, 2);
|
|
9144
|
+
} catch {
|
|
9145
|
+
return "[Unable to serialize data]";
|
|
9108
9146
|
}
|
|
9109
|
-
|
|
9147
|
+
}
|
|
9148
|
+
replacer(_, value) {
|
|
9149
|
+
if (value instanceof Error) {
|
|
9150
|
+
return {
|
|
9151
|
+
name: value.name,
|
|
9152
|
+
message: value.message,
|
|
9153
|
+
stack: value.stack
|
|
9154
|
+
};
|
|
9155
|
+
}
|
|
9156
|
+
return value;
|
|
9157
|
+
}
|
|
9158
|
+
// Static constructors
|
|
9159
|
+
static ok(data) {
|
|
9160
|
+
return new Result(data);
|
|
9161
|
+
}
|
|
9162
|
+
static fail(error, key) {
|
|
9163
|
+
return new Result().addError(error, key);
|
|
9110
9164
|
}
|
|
9111
9165
|
}
|
|
9112
9166
|
|
|
9113
9167
|
class AjaxError extends Error {
|
|
9114
|
-
|
|
9168
|
+
code;
|
|
9115
9169
|
_status;
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9170
|
+
requestInfo;
|
|
9171
|
+
timestamp;
|
|
9172
|
+
originalError;
|
|
9173
|
+
// override cause: null | Error
|
|
9174
|
+
// private _status: number
|
|
9175
|
+
// private _answerError: AnswerError
|
|
9176
|
+
constructor(details) {
|
|
9177
|
+
const message = AjaxError.formatErrorMessage(details);
|
|
9119
9178
|
super(message);
|
|
9120
|
-
this.
|
|
9121
|
-
this.
|
|
9122
|
-
this._status =
|
|
9123
|
-
this.
|
|
9124
|
-
|
|
9179
|
+
this.name = "AjaxError";
|
|
9180
|
+
this.code = details.code;
|
|
9181
|
+
this._status = details.status;
|
|
9182
|
+
this.requestInfo = details.requestInfo;
|
|
9183
|
+
this.originalError = details.originalError;
|
|
9184
|
+
this.timestamp = /* @__PURE__ */ new Date();
|
|
9185
|
+
this.cleanErrorStack();
|
|
9186
|
+
}
|
|
9187
|
+
// constructor(params: AjaxErrorParams) {
|
|
9188
|
+
// const message = `${ params.answerError.error }${
|
|
9189
|
+
// params.answerError.errorDescription
|
|
9190
|
+
// ? ': ' + params.answerError.errorDescription
|
|
9191
|
+
// : ''
|
|
9192
|
+
// }`
|
|
9193
|
+
//
|
|
9194
|
+
// super(message)
|
|
9195
|
+
// this.cause = params.cause || null
|
|
9196
|
+
// this.name = this.constructor.name
|
|
9197
|
+
//
|
|
9198
|
+
// this._status = params.status
|
|
9199
|
+
// this._answerError = params.answerError
|
|
9200
|
+
// }
|
|
9201
|
+
/**
|
|
9202
|
+
* @deprecated
|
|
9203
|
+
*/
|
|
9125
9204
|
get answerError() {
|
|
9126
|
-
return
|
|
9205
|
+
return {
|
|
9206
|
+
error: this.message,
|
|
9207
|
+
errorDescription: ""
|
|
9208
|
+
};
|
|
9127
9209
|
}
|
|
9128
9210
|
get status() {
|
|
9129
9211
|
return this._status;
|
|
9130
9212
|
}
|
|
9213
|
+
/**
|
|
9214
|
+
* @deprecated
|
|
9215
|
+
*/
|
|
9131
9216
|
set status(status) {
|
|
9132
9217
|
this._status = status;
|
|
9133
9218
|
}
|
|
9219
|
+
/**
|
|
9220
|
+
* Creates AjaxError from HTTP response
|
|
9221
|
+
*/
|
|
9222
|
+
static fromResponse(response) {
|
|
9223
|
+
return new AjaxError({
|
|
9224
|
+
code: response.data?.error || "unknown_error",
|
|
9225
|
+
description: response.data?.error_description,
|
|
9226
|
+
status: response.status,
|
|
9227
|
+
requestInfo: {
|
|
9228
|
+
method: response.config?.method?.toUpperCase(),
|
|
9229
|
+
url: response.config?.url,
|
|
9230
|
+
params: response.config?.params
|
|
9231
|
+
}
|
|
9232
|
+
});
|
|
9233
|
+
}
|
|
9234
|
+
/**
|
|
9235
|
+
* Creates AjaxError from exception
|
|
9236
|
+
*/
|
|
9237
|
+
static fromException(error, context) {
|
|
9238
|
+
if (error instanceof AjaxError) return error;
|
|
9239
|
+
return new AjaxError({
|
|
9240
|
+
code: context?.code || "internal_error",
|
|
9241
|
+
status: context?.status || 500,
|
|
9242
|
+
description: error instanceof Error ? error.message : String(error),
|
|
9243
|
+
requestInfo: context?.requestInfo,
|
|
9244
|
+
originalError: error
|
|
9245
|
+
});
|
|
9246
|
+
}
|
|
9247
|
+
/**
|
|
9248
|
+
* Serializes error for logging and debugging
|
|
9249
|
+
*/
|
|
9250
|
+
toJSON() {
|
|
9251
|
+
return {
|
|
9252
|
+
name: this.name,
|
|
9253
|
+
code: this.code,
|
|
9254
|
+
message: this.message,
|
|
9255
|
+
status: this._status,
|
|
9256
|
+
timestamp: this.timestamp.toISOString(),
|
|
9257
|
+
requestInfo: this.requestInfo,
|
|
9258
|
+
stack: this.stack
|
|
9259
|
+
};
|
|
9260
|
+
}
|
|
9261
|
+
// override toString(): string {
|
|
9262
|
+
// return `${ this.answerError.error }${
|
|
9263
|
+
// this.answerError.errorDescription
|
|
9264
|
+
// ? ': ' + this.answerError.errorDescription
|
|
9265
|
+
// : ''
|
|
9266
|
+
// } (${ this.status })`
|
|
9267
|
+
// }
|
|
9268
|
+
/**
|
|
9269
|
+
* Formats error information for human-readable output
|
|
9270
|
+
*/
|
|
9134
9271
|
toString() {
|
|
9135
|
-
|
|
9272
|
+
let output = `[${this.name}] ${this.code} (${this._status}): ${this.message}`;
|
|
9273
|
+
if (this.requestInfo) {
|
|
9274
|
+
output += `
|
|
9275
|
+
Request: ${this.requestInfo.method} ${this.requestInfo.url}`;
|
|
9276
|
+
}
|
|
9277
|
+
if (this.stack) {
|
|
9278
|
+
output += `
|
|
9279
|
+
Stack trace:
|
|
9280
|
+
${this.stack}`;
|
|
9281
|
+
}
|
|
9282
|
+
return output;
|
|
9283
|
+
}
|
|
9284
|
+
static formatErrorMessage(details) {
|
|
9285
|
+
const parts = [details.code];
|
|
9286
|
+
if (details.description) {
|
|
9287
|
+
parts.push(`- ${details.description}`);
|
|
9288
|
+
}
|
|
9289
|
+
if (details.requestInfo?.method && details.requestInfo.url) {
|
|
9290
|
+
parts.push(`(on ${details.requestInfo.method} ${details.requestInfo.url})`);
|
|
9291
|
+
}
|
|
9292
|
+
return parts.join(" ");
|
|
9293
|
+
}
|
|
9294
|
+
cleanErrorStack() {
|
|
9295
|
+
if (typeof this.stack === "string") {
|
|
9296
|
+
this.stack = this.stack.split("\n").filter((line) => !line.includes("AjaxError.constructor")).join("\n");
|
|
9297
|
+
}
|
|
9136
9298
|
}
|
|
9137
9299
|
}
|
|
9138
9300
|
|
|
@@ -9140,31 +9302,48 @@
|
|
|
9140
9302
|
_status;
|
|
9141
9303
|
_query;
|
|
9142
9304
|
_data;
|
|
9143
|
-
constructor(
|
|
9305
|
+
constructor(options) {
|
|
9144
9306
|
super();
|
|
9145
|
-
this._data = answer;
|
|
9146
|
-
this._query = structuredClone(query);
|
|
9147
|
-
this._status = status;
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9307
|
+
this._data = Object.freeze(options.answer);
|
|
9308
|
+
this._query = Object.freeze(structuredClone(options.query));
|
|
9309
|
+
this._status = options.status;
|
|
9310
|
+
this.#processErrors();
|
|
9311
|
+
}
|
|
9312
|
+
#processErrors() {
|
|
9313
|
+
const { error } = this._data;
|
|
9314
|
+
if (!error) return;
|
|
9315
|
+
const errorParams = this.#normalizeError(error);
|
|
9316
|
+
this.addError(this.#createAjaxError(errorParams), "base-error");
|
|
9317
|
+
}
|
|
9318
|
+
#normalizeError(error) {
|
|
9319
|
+
return typeof error === "string" ? { code: error, description: this._data.error_description || "" } : { code: error.error, description: error.error_description || "" };
|
|
9320
|
+
}
|
|
9321
|
+
#createAjaxError(params) {
|
|
9322
|
+
return new AjaxError({
|
|
9323
|
+
code: String(this._status),
|
|
9324
|
+
description: params.description,
|
|
9325
|
+
status: this._status,
|
|
9326
|
+
requestInfo: {
|
|
9327
|
+
method: this._query.method,
|
|
9328
|
+
// url: '?',
|
|
9329
|
+
params: this._query.params
|
|
9330
|
+
}
|
|
9331
|
+
// request:
|
|
9332
|
+
});
|
|
9165
9333
|
}
|
|
9166
9334
|
getData() {
|
|
9167
|
-
return
|
|
9335
|
+
return Object.freeze({
|
|
9336
|
+
result: this._data.result,
|
|
9337
|
+
next: this._data.next,
|
|
9338
|
+
total: this._data.total,
|
|
9339
|
+
time: this._data.time
|
|
9340
|
+
});
|
|
9341
|
+
}
|
|
9342
|
+
/**
|
|
9343
|
+
* Alias for isMore
|
|
9344
|
+
*/
|
|
9345
|
+
hasMore() {
|
|
9346
|
+
return this.isMore();
|
|
9168
9347
|
}
|
|
9169
9348
|
isMore() {
|
|
9170
9349
|
return Type.isNumber(this._data?.next);
|
|
@@ -9178,16 +9357,35 @@
|
|
|
9178
9357
|
getQuery() {
|
|
9179
9358
|
return this._query;
|
|
9180
9359
|
}
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9360
|
+
/**
|
|
9361
|
+
* Alias for getNext
|
|
9362
|
+
* @param http
|
|
9363
|
+
*/
|
|
9364
|
+
async fetchNext(http) {
|
|
9365
|
+
const data = await this.getNext(http);
|
|
9366
|
+
if (data === false) {
|
|
9367
|
+
return null;
|
|
9189
9368
|
}
|
|
9190
|
-
return
|
|
9369
|
+
return data;
|
|
9370
|
+
}
|
|
9371
|
+
async getNext(http) {
|
|
9372
|
+
if (!this.isMore() || !this.isSuccess) return false;
|
|
9373
|
+
const nextPageQuery = this.#buildNextPageQuery();
|
|
9374
|
+
return http.call(
|
|
9375
|
+
nextPageQuery.method,
|
|
9376
|
+
nextPageQuery.params,
|
|
9377
|
+
nextPageQuery.start
|
|
9378
|
+
);
|
|
9379
|
+
}
|
|
9380
|
+
#buildNextPageQuery() {
|
|
9381
|
+
return {
|
|
9382
|
+
...this._query,
|
|
9383
|
+
start: Text.toInteger(this._data.next)
|
|
9384
|
+
};
|
|
9385
|
+
}
|
|
9386
|
+
// Immutable API
|
|
9387
|
+
setData() {
|
|
9388
|
+
throw new ReferenceError("AjaxResult does not allow data modification");
|
|
9191
9389
|
}
|
|
9192
9390
|
}
|
|
9193
9391
|
|
|
@@ -9842,7 +10040,7 @@
|
|
|
9842
10040
|
*
|
|
9843
10041
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
9844
10042
|
*/
|
|
9845
|
-
const isRegExp
|
|
10043
|
+
const isRegExp = kindOfTest('RegExp');
|
|
9846
10044
|
|
|
9847
10045
|
const reduceDescriptors = (obj, reducer) => {
|
|
9848
10046
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -9909,26 +10107,6 @@
|
|
|
9909
10107
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
9910
10108
|
};
|
|
9911
10109
|
|
|
9912
|
-
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
9913
|
-
|
|
9914
|
-
const DIGIT = '0123456789';
|
|
9915
|
-
|
|
9916
|
-
const ALPHABET = {
|
|
9917
|
-
DIGIT,
|
|
9918
|
-
ALPHA,
|
|
9919
|
-
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
9920
|
-
};
|
|
9921
|
-
|
|
9922
|
-
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
9923
|
-
let str = '';
|
|
9924
|
-
const {length} = alphabet;
|
|
9925
|
-
while (size--) {
|
|
9926
|
-
str += alphabet[Math.random() * length|0];
|
|
9927
|
-
}
|
|
9928
|
-
|
|
9929
|
-
return str;
|
|
9930
|
-
};
|
|
9931
|
-
|
|
9932
10110
|
/**
|
|
9933
10111
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
9934
10112
|
*
|
|
@@ -10025,7 +10203,7 @@
|
|
|
10025
10203
|
isDate,
|
|
10026
10204
|
isFile,
|
|
10027
10205
|
isBlob,
|
|
10028
|
-
isRegExp
|
|
10206
|
+
isRegExp,
|
|
10029
10207
|
isFunction,
|
|
10030
10208
|
isStream,
|
|
10031
10209
|
isURLSearchParams,
|
|
@@ -10056,8 +10234,6 @@
|
|
|
10056
10234
|
findKey,
|
|
10057
10235
|
global: _global,
|
|
10058
10236
|
isContextDefined,
|
|
10059
|
-
ALPHABET,
|
|
10060
|
-
generateString,
|
|
10061
10237
|
isSpecCompliantForm,
|
|
10062
10238
|
toJSONObject,
|
|
10063
10239
|
isAsyncFn,
|
|
@@ -10454,7 +10630,7 @@
|
|
|
10454
10630
|
*
|
|
10455
10631
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
10456
10632
|
* @param {object} [params] The params to be appended
|
|
10457
|
-
* @param {?object} options
|
|
10633
|
+
* @param {?(object|Function)} options
|
|
10458
10634
|
*
|
|
10459
10635
|
* @returns {string} The formatted url
|
|
10460
10636
|
*/
|
|
@@ -10466,6 +10642,12 @@
|
|
|
10466
10642
|
|
|
10467
10643
|
const _encode = options && options.encode || encode$1;
|
|
10468
10644
|
|
|
10645
|
+
if (utils$1.isFunction(options)) {
|
|
10646
|
+
options = {
|
|
10647
|
+
serialize: options
|
|
10648
|
+
};
|
|
10649
|
+
}
|
|
10650
|
+
|
|
10469
10651
|
const serializeFn = options && options.serialize;
|
|
10470
10652
|
|
|
10471
10653
|
let serializedParams;
|
|
@@ -10761,7 +10943,7 @@
|
|
|
10761
10943
|
}
|
|
10762
10944
|
}
|
|
10763
10945
|
|
|
10764
|
-
return (
|
|
10946
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
10765
10947
|
}
|
|
10766
10948
|
|
|
10767
10949
|
const defaults$2 = {
|
|
@@ -11448,68 +11630,18 @@
|
|
|
11448
11630
|
|
|
11449
11631
|
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
11450
11632
|
|
|
11451
|
-
const isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
11452
|
-
|
|
11453
|
-
// Standard browser envs have full support of the APIs needed to test
|
|
11454
|
-
// whether the request URL is of the same origin as current location.
|
|
11455
|
-
(function standardBrowserEnv() {
|
|
11456
|
-
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
|
11457
|
-
const urlParsingNode = document.createElement('a');
|
|
11458
|
-
let originURL;
|
|
11633
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
|
11634
|
+
url = new URL(url, platform.origin);
|
|
11459
11635
|
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
if (msie) {
|
|
11470
|
-
// IE needs attribute set twice to normalize properties
|
|
11471
|
-
urlParsingNode.setAttribute('href', href);
|
|
11472
|
-
href = urlParsingNode.href;
|
|
11473
|
-
}
|
|
11474
|
-
|
|
11475
|
-
urlParsingNode.setAttribute('href', href);
|
|
11476
|
-
|
|
11477
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
11478
|
-
return {
|
|
11479
|
-
href: urlParsingNode.href,
|
|
11480
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
11481
|
-
host: urlParsingNode.host,
|
|
11482
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
11483
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
11484
|
-
hostname: urlParsingNode.hostname,
|
|
11485
|
-
port: urlParsingNode.port,
|
|
11486
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
11487
|
-
urlParsingNode.pathname :
|
|
11488
|
-
'/' + urlParsingNode.pathname
|
|
11489
|
-
};
|
|
11490
|
-
}
|
|
11491
|
-
|
|
11492
|
-
originURL = resolveURL(window.location.href);
|
|
11493
|
-
|
|
11494
|
-
/**
|
|
11495
|
-
* Determine if a URL shares the same origin as the current location
|
|
11496
|
-
*
|
|
11497
|
-
* @param {String} requestURL The URL to test
|
|
11498
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
11499
|
-
*/
|
|
11500
|
-
return function isURLSameOrigin(requestURL) {
|
|
11501
|
-
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
11502
|
-
return (parsed.protocol === originURL.protocol &&
|
|
11503
|
-
parsed.host === originURL.host);
|
|
11504
|
-
};
|
|
11505
|
-
})() :
|
|
11506
|
-
|
|
11507
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
11508
|
-
(function nonStandardBrowserEnv() {
|
|
11509
|
-
return function isURLSameOrigin() {
|
|
11510
|
-
return true;
|
|
11511
|
-
};
|
|
11512
|
-
})();
|
|
11636
|
+
return (
|
|
11637
|
+
origin.protocol === url.protocol &&
|
|
11638
|
+
origin.host === url.host &&
|
|
11639
|
+
(isMSIE || origin.port === url.port)
|
|
11640
|
+
);
|
|
11641
|
+
})(
|
|
11642
|
+
new URL(platform.origin),
|
|
11643
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
11644
|
+
) : () => true;
|
|
11513
11645
|
|
|
11514
11646
|
const cookies = platform.hasStandardBrowserEnv ?
|
|
11515
11647
|
|
|
@@ -11588,8 +11720,9 @@
|
|
|
11588
11720
|
*
|
|
11589
11721
|
* @returns {string} The combined full path
|
|
11590
11722
|
*/
|
|
11591
|
-
function buildFullPath(baseURL, requestedURL) {
|
|
11592
|
-
|
|
11723
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
11724
|
+
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
11725
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
11593
11726
|
return combineURLs(baseURL, requestedURL);
|
|
11594
11727
|
}
|
|
11595
11728
|
return requestedURL;
|
|
@@ -11611,7 +11744,7 @@
|
|
|
11611
11744
|
config2 = config2 || {};
|
|
11612
11745
|
const config = {};
|
|
11613
11746
|
|
|
11614
|
-
function getMergedValue(target, source, caseless) {
|
|
11747
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
11615
11748
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
11616
11749
|
return utils$1.merge.call({caseless}, target, source);
|
|
11617
11750
|
} else if (utils$1.isPlainObject(source)) {
|
|
@@ -11623,11 +11756,11 @@
|
|
|
11623
11756
|
}
|
|
11624
11757
|
|
|
11625
11758
|
// eslint-disable-next-line consistent-return
|
|
11626
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
11759
|
+
function mergeDeepProperties(a, b, prop , caseless) {
|
|
11627
11760
|
if (!utils$1.isUndefined(b)) {
|
|
11628
|
-
return getMergedValue(a, b, caseless);
|
|
11761
|
+
return getMergedValue(a, b, prop , caseless);
|
|
11629
11762
|
} else if (!utils$1.isUndefined(a)) {
|
|
11630
|
-
return getMergedValue(undefined, a, caseless);
|
|
11763
|
+
return getMergedValue(undefined, a, prop , caseless);
|
|
11631
11764
|
}
|
|
11632
11765
|
}
|
|
11633
11766
|
|
|
@@ -11685,7 +11818,7 @@
|
|
|
11685
11818
|
socketPath: defaultToConfig2,
|
|
11686
11819
|
responseEncoding: defaultToConfig2,
|
|
11687
11820
|
validateStatus: mergeDirectKeys,
|
|
11688
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
11821
|
+
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
11689
11822
|
};
|
|
11690
11823
|
|
|
11691
11824
|
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
@@ -11704,7 +11837,7 @@
|
|
|
11704
11837
|
|
|
11705
11838
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
11706
11839
|
|
|
11707
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
11840
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
11708
11841
|
|
|
11709
11842
|
// HTTP basic authentication
|
|
11710
11843
|
if (auth) {
|
|
@@ -12427,7 +12560,7 @@
|
|
|
12427
12560
|
});
|
|
12428
12561
|
}
|
|
12429
12562
|
|
|
12430
|
-
const VERSION$1 = "1.
|
|
12563
|
+
const VERSION$1 = "1.8.4";
|
|
12431
12564
|
|
|
12432
12565
|
const validators$1 = {};
|
|
12433
12566
|
|
|
@@ -12478,6 +12611,14 @@
|
|
|
12478
12611
|
};
|
|
12479
12612
|
};
|
|
12480
12613
|
|
|
12614
|
+
validators$1.spelling = function spelling(correctSpelling) {
|
|
12615
|
+
return (value, opt) => {
|
|
12616
|
+
// eslint-disable-next-line no-console
|
|
12617
|
+
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
12618
|
+
return true;
|
|
12619
|
+
}
|
|
12620
|
+
};
|
|
12621
|
+
|
|
12481
12622
|
/**
|
|
12482
12623
|
* Assert object's properties type
|
|
12483
12624
|
*
|
|
@@ -12547,9 +12688,9 @@
|
|
|
12547
12688
|
return await this._request(configOrUrl, config);
|
|
12548
12689
|
} catch (err) {
|
|
12549
12690
|
if (err instanceof Error) {
|
|
12550
|
-
let dummy;
|
|
12691
|
+
let dummy = {};
|
|
12551
12692
|
|
|
12552
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy
|
|
12693
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
12553
12694
|
|
|
12554
12695
|
// slice off the Error: ... line
|
|
12555
12696
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
@@ -12604,6 +12745,18 @@
|
|
|
12604
12745
|
}
|
|
12605
12746
|
}
|
|
12606
12747
|
|
|
12748
|
+
// Set config.allowAbsoluteUrls
|
|
12749
|
+
if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|
12750
|
+
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
12751
|
+
} else {
|
|
12752
|
+
config.allowAbsoluteUrls = true;
|
|
12753
|
+
}
|
|
12754
|
+
|
|
12755
|
+
validator.assertOptions(config, {
|
|
12756
|
+
baseUrl: validators.spelling('baseURL'),
|
|
12757
|
+
withXsrfToken: validators.spelling('withXSRFToken')
|
|
12758
|
+
}, true);
|
|
12759
|
+
|
|
12607
12760
|
// Set config.method
|
|
12608
12761
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
12609
12762
|
|
|
@@ -12694,7 +12847,7 @@
|
|
|
12694
12847
|
|
|
12695
12848
|
getUri(config) {
|
|
12696
12849
|
config = mergeConfig$1(this.defaults, config);
|
|
12697
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
12850
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
12698
12851
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
12699
12852
|
}
|
|
12700
12853
|
};
|
|
@@ -13079,7 +13232,7 @@
|
|
|
13079
13232
|
|
|
13080
13233
|
const formats = Format.RFC3986;
|
|
13081
13234
|
|
|
13082
|
-
const has$
|
|
13235
|
+
const has$1 = Object.prototype.hasOwnProperty;
|
|
13083
13236
|
const isArray$2 = Array.isArray;
|
|
13084
13237
|
|
|
13085
13238
|
const hexTable = (function () {
|
|
@@ -13133,7 +13286,7 @@
|
|
|
13133
13286
|
} else if (target && typeof target === 'object') {
|
|
13134
13287
|
if (
|
|
13135
13288
|
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
13136
|
-
!has$
|
|
13289
|
+
!has$1.call(Object.prototype, source)
|
|
13137
13290
|
) {
|
|
13138
13291
|
target[source] = true;
|
|
13139
13292
|
}
|
|
@@ -13155,7 +13308,7 @@
|
|
|
13155
13308
|
|
|
13156
13309
|
if (isArray$2(target) && isArray$2(source)) {
|
|
13157
13310
|
source.forEach(function (item, i) {
|
|
13158
|
-
if (has$
|
|
13311
|
+
if (has$1.call(target, i)) {
|
|
13159
13312
|
const targetItem = target[i];
|
|
13160
13313
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
13161
13314
|
target[i] = merge(targetItem, item, options);
|
|
@@ -13172,7 +13325,7 @@
|
|
|
13172
13325
|
return Object.keys(source).reduce(function (acc, key) {
|
|
13173
13326
|
const value = source[key];
|
|
13174
13327
|
|
|
13175
|
-
if (has$
|
|
13328
|
+
if (has$1.call(acc, key)) {
|
|
13176
13329
|
acc[key] = merge(acc[key], value, options);
|
|
13177
13330
|
} else {
|
|
13178
13331
|
acc[key] = value;
|
|
@@ -13296,10 +13449,6 @@
|
|
|
13296
13449
|
return value
|
|
13297
13450
|
};
|
|
13298
13451
|
|
|
13299
|
-
const isRegExp = function isRegExp(obj) {
|
|
13300
|
-
return Object.prototype.toString.call(obj) === '[object RegExp]'
|
|
13301
|
-
};
|
|
13302
|
-
|
|
13303
13452
|
const isBuffer = function isBuffer(obj) {
|
|
13304
13453
|
if (!obj || typeof obj !== 'object') {
|
|
13305
13454
|
return false
|
|
@@ -13323,8 +13472,6 @@
|
|
|
13323
13472
|
return fn(val)
|
|
13324
13473
|
};
|
|
13325
13474
|
|
|
13326
|
-
const has$1 = Object.prototype.hasOwnProperty;
|
|
13327
|
-
|
|
13328
13475
|
const arrayPrefixGenerators = {
|
|
13329
13476
|
brackets: function brackets(prefix) {
|
|
13330
13477
|
return prefix + '[]'
|
|
@@ -13407,7 +13554,7 @@
|
|
|
13407
13554
|
let tmpSc = sideChannel;
|
|
13408
13555
|
let step = 0;
|
|
13409
13556
|
let findFlag = false;
|
|
13410
|
-
while ((tmpSc = tmpSc.get(sentinel)) !== void
|
|
13557
|
+
while ((tmpSc = tmpSc.get(sentinel)) !== void 0 && !findFlag) {
|
|
13411
13558
|
// Where object last appeared in the ref tree
|
|
13412
13559
|
const pos = tmpSc.get(object);
|
|
13413
13560
|
step += 1;
|
|
@@ -13472,7 +13619,7 @@
|
|
|
13472
13619
|
if (encodeValuesOnly && encoder) {
|
|
13473
13620
|
obj = maybeMap(obj, encoder);
|
|
13474
13621
|
}
|
|
13475
|
-
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void
|
|
13622
|
+
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void 0 }];
|
|
13476
13623
|
} else if (isArray$1(filter)) {
|
|
13477
13624
|
objKeys = filter;
|
|
13478
13625
|
} else {
|
|
@@ -13536,108 +13683,14 @@
|
|
|
13536
13683
|
};
|
|
13537
13684
|
|
|
13538
13685
|
const normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
13539
|
-
|
|
13686
|
+
{
|
|
13540
13687
|
return defaults$1
|
|
13541
13688
|
}
|
|
13542
|
-
|
|
13543
|
-
if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
|
|
13544
|
-
throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided')
|
|
13545
|
-
}
|
|
13546
|
-
|
|
13547
|
-
if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
|
|
13548
|
-
throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided')
|
|
13549
|
-
}
|
|
13550
|
-
|
|
13551
|
-
if (
|
|
13552
|
-
opts.encoder !== null &&
|
|
13553
|
-
typeof opts.encoder !== 'undefined' &&
|
|
13554
|
-
typeof opts.encoder !== 'function'
|
|
13555
|
-
) {
|
|
13556
|
-
throw new TypeError('Encoder has to be a function.')
|
|
13557
|
-
}
|
|
13558
|
-
|
|
13559
|
-
const charset = opts.charset || defaults$1.charset;
|
|
13560
|
-
if (
|
|
13561
|
-
typeof opts.charset !== 'undefined' &&
|
|
13562
|
-
opts.charset !== 'utf-8' &&
|
|
13563
|
-
opts.charset !== 'iso-8859-1'
|
|
13564
|
-
) {
|
|
13565
|
-
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined')
|
|
13566
|
-
}
|
|
13567
|
-
|
|
13568
|
-
let format = formats;
|
|
13569
|
-
if (typeof opts.format !== 'undefined') {
|
|
13570
|
-
if (!has$1.call(formatters, opts.format)) {
|
|
13571
|
-
throw new TypeError('Unknown format option provided.')
|
|
13572
|
-
}
|
|
13573
|
-
format = opts.format;
|
|
13574
|
-
}
|
|
13575
|
-
const formatter = formatters[format];
|
|
13576
|
-
|
|
13577
|
-
let filter = defaults$1.filter;
|
|
13578
|
-
if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
|
|
13579
|
-
filter = opts.filter;
|
|
13580
|
-
}
|
|
13581
|
-
|
|
13582
|
-
let arrayFormat;
|
|
13583
|
-
if (opts.arrayFormat in arrayPrefixGenerators) {
|
|
13584
|
-
arrayFormat = opts.arrayFormat;
|
|
13585
|
-
} else if ('indices' in opts) {
|
|
13586
|
-
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
|
13587
|
-
} else {
|
|
13588
|
-
arrayFormat = defaults$1.arrayFormat;
|
|
13589
|
-
}
|
|
13590
|
-
|
|
13591
|
-
if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
|
|
13592
|
-
throw new TypeError('`commaRoundTrip` must be a boolean, or absent')
|
|
13593
|
-
}
|
|
13594
|
-
|
|
13595
|
-
const allowDots =
|
|
13596
|
-
typeof opts.allowDots === 'undefined'
|
|
13597
|
-
? opts.encodeDotInKeys === true
|
|
13598
|
-
? true
|
|
13599
|
-
: defaults$1.allowDots
|
|
13600
|
-
: !!opts.allowDots;
|
|
13601
|
-
|
|
13602
|
-
return {
|
|
13603
|
-
addQueryPrefix:
|
|
13604
|
-
typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
|
|
13605
|
-
allowDots: allowDots,
|
|
13606
|
-
allowEmptyArrays:
|
|
13607
|
-
typeof opts.allowEmptyArrays === 'boolean'
|
|
13608
|
-
? !!opts.allowEmptyArrays
|
|
13609
|
-
: defaults$1.allowEmptyArrays,
|
|
13610
|
-
arrayFormat: arrayFormat,
|
|
13611
|
-
charset: charset,
|
|
13612
|
-
charsetSentinel:
|
|
13613
|
-
typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
|
|
13614
|
-
commaRoundTrip: opts.commaRoundTrip,
|
|
13615
|
-
delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter,
|
|
13616
|
-
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode,
|
|
13617
|
-
encodeDotInKeys:
|
|
13618
|
-
typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults$1.encodeDotInKeys,
|
|
13619
|
-
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder,
|
|
13620
|
-
encodeValuesOnly:
|
|
13621
|
-
typeof opts.encodeValuesOnly === 'boolean'
|
|
13622
|
-
? opts.encodeValuesOnly
|
|
13623
|
-
: defaults$1.encodeValuesOnly,
|
|
13624
|
-
filter: filter,
|
|
13625
|
-
format: format,
|
|
13626
|
-
formatter: formatter,
|
|
13627
|
-
serializeDate:
|
|
13628
|
-
typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate,
|
|
13629
|
-
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls,
|
|
13630
|
-
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
|
13631
|
-
strictNullHandling:
|
|
13632
|
-
typeof opts.strictNullHandling === 'boolean'
|
|
13633
|
-
? opts.strictNullHandling
|
|
13634
|
-
: defaults$1.strictNullHandling,
|
|
13635
|
-
}
|
|
13636
13689
|
};
|
|
13637
13690
|
|
|
13638
13691
|
function stringify(object, opts) {
|
|
13639
13692
|
let obj = object;
|
|
13640
|
-
const options = normalizeStringifyOptions(
|
|
13693
|
+
const options = normalizeStringifyOptions();
|
|
13641
13694
|
|
|
13642
13695
|
let objKeys;
|
|
13643
13696
|
let filter;
|
|
@@ -13920,91 +13973,13 @@
|
|
|
13920
13973
|
};
|
|
13921
13974
|
|
|
13922
13975
|
const normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
13923
|
-
|
|
13976
|
+
{
|
|
13924
13977
|
return defaults
|
|
13925
13978
|
}
|
|
13926
|
-
|
|
13927
|
-
if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
|
|
13928
|
-
throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided')
|
|
13929
|
-
}
|
|
13930
|
-
|
|
13931
|
-
if (typeof opts.decodeDotInKeys !== 'undefined' && typeof opts.decodeDotInKeys !== 'boolean') {
|
|
13932
|
-
throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided')
|
|
13933
|
-
}
|
|
13934
|
-
|
|
13935
|
-
if (
|
|
13936
|
-
opts.decoder !== null &&
|
|
13937
|
-
typeof opts.decoder !== 'undefined' &&
|
|
13938
|
-
typeof opts.decoder !== 'function'
|
|
13939
|
-
) {
|
|
13940
|
-
throw new TypeError('Decoder has to be a function.')
|
|
13941
|
-
}
|
|
13942
|
-
|
|
13943
|
-
if (
|
|
13944
|
-
typeof opts.charset !== 'undefined' &&
|
|
13945
|
-
opts.charset !== 'utf-8' &&
|
|
13946
|
-
opts.charset !== 'iso-8859-1'
|
|
13947
|
-
) {
|
|
13948
|
-
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined')
|
|
13949
|
-
}
|
|
13950
|
-
const charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
|
13951
|
-
|
|
13952
|
-
const duplicates = typeof opts.duplicates === 'undefined' ? defaults.duplicates : opts.duplicates;
|
|
13953
|
-
|
|
13954
|
-
if (duplicates !== 'combine' && duplicates !== 'first' && duplicates !== 'last') {
|
|
13955
|
-
throw new TypeError('The duplicates option must be either combine, first, or last')
|
|
13956
|
-
}
|
|
13957
|
-
|
|
13958
|
-
const allowDots =
|
|
13959
|
-
typeof opts.allowDots === 'undefined'
|
|
13960
|
-
? opts.decodeDotInKeys === true
|
|
13961
|
-
? true
|
|
13962
|
-
: defaults.allowDots
|
|
13963
|
-
: !!opts.allowDots;
|
|
13964
|
-
|
|
13965
|
-
return {
|
|
13966
|
-
allowDots: allowDots,
|
|
13967
|
-
allowEmptyArrays:
|
|
13968
|
-
typeof opts.allowEmptyArrays === 'boolean'
|
|
13969
|
-
? !!opts.allowEmptyArrays
|
|
13970
|
-
: defaults.allowEmptyArrays,
|
|
13971
|
-
allowPrototypes:
|
|
13972
|
-
typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
|
13973
|
-
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
|
|
13974
|
-
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
|
13975
|
-
charset: charset,
|
|
13976
|
-
charsetSentinel:
|
|
13977
|
-
typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
13978
|
-
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
|
13979
|
-
decodeDotInKeys:
|
|
13980
|
-
typeof opts.decodeDotInKeys === 'boolean' ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
|
|
13981
|
-
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
|
13982
|
-
delimiter:
|
|
13983
|
-
typeof opts.delimiter === 'string' || isRegExp(opts.delimiter)
|
|
13984
|
-
? opts.delimiter
|
|
13985
|
-
: defaults.delimiter,
|
|
13986
|
-
// eslint-disable-next-line no-implicit-coercion, no-extra-parens
|
|
13987
|
-
depth: typeof opts.depth === 'number' || opts.depth === false ? +opts.depth : defaults.depth,
|
|
13988
|
-
duplicates: duplicates,
|
|
13989
|
-
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
|
13990
|
-
interpretNumericEntities:
|
|
13991
|
-
typeof opts.interpretNumericEntities === 'boolean'
|
|
13992
|
-
? opts.interpretNumericEntities
|
|
13993
|
-
: defaults.interpretNumericEntities,
|
|
13994
|
-
parameterLimit:
|
|
13995
|
-
typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
|
13996
|
-
parseArrays: opts.parseArrays !== false,
|
|
13997
|
-
plainObjects:
|
|
13998
|
-
typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
|
13999
|
-
strictNullHandling:
|
|
14000
|
-
typeof opts.strictNullHandling === 'boolean'
|
|
14001
|
-
? opts.strictNullHandling
|
|
14002
|
-
: defaults.strictNullHandling,
|
|
14003
|
-
}
|
|
14004
13979
|
};
|
|
14005
13980
|
|
|
14006
13981
|
function parse(str, opts) {
|
|
14007
|
-
const options = normalizeParseOptions(
|
|
13982
|
+
const options = normalizeParseOptions();
|
|
14008
13983
|
|
|
14009
13984
|
if (str === '' || str === null || typeof str === 'undefined') {
|
|
14010
13985
|
return options.plainObjects ? Object.create(null) : {}
|
|
@@ -14100,33 +14075,37 @@
|
|
|
14100
14075
|
// endregion ////
|
|
14101
14076
|
// region Actions Call ////
|
|
14102
14077
|
async batch(calls, isHaltOnError = true) {
|
|
14103
|
-
|
|
14104
|
-
|
|
14078
|
+
if (Array.isArray(calls)) {
|
|
14079
|
+
return this.#batchAsArray(
|
|
14080
|
+
calls,
|
|
14081
|
+
isHaltOnError
|
|
14082
|
+
);
|
|
14083
|
+
}
|
|
14084
|
+
return this.#batchAsObject(
|
|
14085
|
+
calls,
|
|
14086
|
+
isHaltOnError
|
|
14087
|
+
);
|
|
14088
|
+
}
|
|
14089
|
+
async #batchAsObject(calls, isHaltOnError = true) {
|
|
14090
|
+
const cmd = {};
|
|
14105
14091
|
let cnt = 0;
|
|
14106
14092
|
const processRow = (row, index) => {
|
|
14107
14093
|
let method = null;
|
|
14108
14094
|
let params = null;
|
|
14109
|
-
if (
|
|
14110
|
-
method = row
|
|
14111
|
-
params = row
|
|
14112
|
-
} else if (row.
|
|
14113
|
-
method = row
|
|
14114
|
-
params = row
|
|
14095
|
+
if (row.method) {
|
|
14096
|
+
method = row.method ?? null;
|
|
14097
|
+
params = row?.params ?? null;
|
|
14098
|
+
} else if (Array.isArray(row) && row.length > 0) {
|
|
14099
|
+
method = row[0] ?? null;
|
|
14100
|
+
params = row[1] ?? null;
|
|
14115
14101
|
}
|
|
14116
14102
|
if (method) {
|
|
14117
14103
|
cnt++;
|
|
14118
|
-
|
|
14119
|
-
if (isArrayMode || Array.isArray(cmd)) {
|
|
14120
|
-
cmd.push(data);
|
|
14121
|
-
} else {
|
|
14122
|
-
cmd[index] = data;
|
|
14123
|
-
}
|
|
14104
|
+
cmd[index] = method + "?" + stringify(params);
|
|
14124
14105
|
}
|
|
14125
14106
|
};
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
} else {
|
|
14129
|
-
for (const [index, item] of Object.entries(calls)) processRow(item, index);
|
|
14107
|
+
for (const [index, row] of Object.entries(calls)) {
|
|
14108
|
+
processRow(row, index);
|
|
14130
14109
|
}
|
|
14131
14110
|
if (cnt < 1) {
|
|
14132
14111
|
return Promise.resolve(new Result());
|
|
@@ -14136,7 +14115,7 @@
|
|
|
14136
14115
|
cmd
|
|
14137
14116
|
}).then((response) => {
|
|
14138
14117
|
const responseResult = response.getData().result;
|
|
14139
|
-
const results =
|
|
14118
|
+
const results = {};
|
|
14140
14119
|
const processResponse = (row, index) => {
|
|
14141
14120
|
if (
|
|
14142
14121
|
// @ts-ignore
|
|
@@ -14144,8 +14123,8 @@
|
|
|
14144
14123
|
typeof responseResult.result_error[index] !== "undefined"
|
|
14145
14124
|
) {
|
|
14146
14125
|
const q = row.split("?");
|
|
14147
|
-
|
|
14148
|
-
{
|
|
14126
|
+
results[index] = new AjaxResult({
|
|
14127
|
+
answer: {
|
|
14149
14128
|
// @ts-ignore
|
|
14150
14129
|
result: Type.isUndefined(responseResult.result[index]) ? (
|
|
14151
14130
|
// @ts-ignore
|
|
@@ -14159,67 +14138,154 @@
|
|
|
14159
14138
|
// @ts-ignore
|
|
14160
14139
|
total: responseResult.result_total[index],
|
|
14161
14140
|
// @ts-ignore
|
|
14162
|
-
next: responseResult.result_next[index]
|
|
14141
|
+
next: responseResult.result_next[index],
|
|
14142
|
+
// @todo test this ////
|
|
14143
|
+
// @ts-ignore
|
|
14144
|
+
time: responseResult.result_time[index]
|
|
14163
14145
|
},
|
|
14164
|
-
{
|
|
14146
|
+
query: {
|
|
14165
14147
|
method: q[0] || "",
|
|
14166
14148
|
params: parse(q[1] || ""),
|
|
14167
14149
|
start: 0
|
|
14168
14150
|
},
|
|
14169
|
-
response.getStatus()
|
|
14170
|
-
);
|
|
14171
|
-
if (isArrayMode || Array.isArray(results)) {
|
|
14172
|
-
results.push(data);
|
|
14173
|
-
} else {
|
|
14174
|
-
results[index] = data;
|
|
14175
|
-
}
|
|
14151
|
+
status: response.getStatus()
|
|
14152
|
+
});
|
|
14176
14153
|
}
|
|
14177
14154
|
};
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
} else {
|
|
14181
|
-
for (const [index, item] of Object.entries(cmd))
|
|
14182
|
-
processResponse(item, index);
|
|
14155
|
+
for (const [index, row] of Object.entries(cmd)) {
|
|
14156
|
+
processResponse(row, index);
|
|
14183
14157
|
}
|
|
14184
|
-
|
|
14158
|
+
const dataResult = {};
|
|
14185
14159
|
const initError = (result2) => {
|
|
14160
|
+
if (result2.hasError("base-error")) {
|
|
14161
|
+
return result2.errors.get("base-error");
|
|
14162
|
+
}
|
|
14186
14163
|
return new AjaxError({
|
|
14164
|
+
code: "0",
|
|
14165
|
+
description: result2.getErrorMessages().join("; "),
|
|
14187
14166
|
status: 0,
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14167
|
+
requestInfo: {
|
|
14168
|
+
method: result2.getQuery().method,
|
|
14169
|
+
params: result2.getQuery().params
|
|
14191
14170
|
},
|
|
14192
|
-
|
|
14171
|
+
originalError: result2.getErrors().next().value
|
|
14193
14172
|
});
|
|
14194
14173
|
};
|
|
14195
14174
|
const result = new Result();
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
continue;
|
|
14204
|
-
}
|
|
14205
|
-
return Promise.reject(error);
|
|
14175
|
+
for (const key of Object.keys(results)) {
|
|
14176
|
+
const data = results[key];
|
|
14177
|
+
if (data.getStatus() !== 200 || !data.isSuccess) {
|
|
14178
|
+
const error = initError(data);
|
|
14179
|
+
if (!isHaltOnError && !data.isSuccess) {
|
|
14180
|
+
result.addError(error, key);
|
|
14181
|
+
continue;
|
|
14206
14182
|
}
|
|
14207
|
-
|
|
14183
|
+
return Promise.reject(error);
|
|
14208
14184
|
}
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14185
|
+
dataResult[key] = data.getData().result;
|
|
14186
|
+
}
|
|
14187
|
+
result.setData(dataResult);
|
|
14188
|
+
return Promise.resolve(result);
|
|
14189
|
+
});
|
|
14190
|
+
}
|
|
14191
|
+
async #batchAsArray(calls, isHaltOnError = true) {
|
|
14192
|
+
const cmd = [];
|
|
14193
|
+
let cnt = 0;
|
|
14194
|
+
const processRow = (row) => {
|
|
14195
|
+
let method = null;
|
|
14196
|
+
let params = null;
|
|
14197
|
+
if (row.method) {
|
|
14198
|
+
method = row.method ?? null;
|
|
14199
|
+
params = row?.params ?? null;
|
|
14200
|
+
} else if (Array.isArray(row) && row.length > 0) {
|
|
14201
|
+
method = row[0] ?? null;
|
|
14202
|
+
params = row[1] ?? null;
|
|
14203
|
+
}
|
|
14204
|
+
if (method) {
|
|
14205
|
+
cnt++;
|
|
14206
|
+
const data = method + "?" + stringify(params);
|
|
14207
|
+
cmd.push(data);
|
|
14208
|
+
}
|
|
14209
|
+
};
|
|
14210
|
+
for (const [_, row] of calls.entries()) {
|
|
14211
|
+
processRow(row);
|
|
14212
|
+
}
|
|
14213
|
+
if (cnt < 1) {
|
|
14214
|
+
return Promise.resolve(new Result());
|
|
14215
|
+
}
|
|
14216
|
+
return this.call("batch", {
|
|
14217
|
+
halt: isHaltOnError ? 1 : 0,
|
|
14218
|
+
cmd
|
|
14219
|
+
}).then((response) => {
|
|
14220
|
+
const responseResult = response.getData().result;
|
|
14221
|
+
const results = [];
|
|
14222
|
+
const processResponse = (row, index) => {
|
|
14223
|
+
if (
|
|
14224
|
+
// @ts-ignore
|
|
14225
|
+
typeof responseResult.result[index] !== "undefined" || // @ts-ignore
|
|
14226
|
+
typeof responseResult.result_error[index] !== "undefined"
|
|
14227
|
+
) {
|
|
14228
|
+
const q = row.split("?");
|
|
14229
|
+
const data = new AjaxResult({
|
|
14230
|
+
answer: {
|
|
14231
|
+
// @ts-ignore
|
|
14232
|
+
result: Type.isUndefined(responseResult.result[index]) ? (
|
|
14233
|
+
// @ts-ignore
|
|
14234
|
+
{}
|
|
14235
|
+
) : (
|
|
14236
|
+
// @ts-ignore
|
|
14237
|
+
responseResult.result[index]
|
|
14238
|
+
),
|
|
14239
|
+
// @ts-ignore
|
|
14240
|
+
error: responseResult?.result_error[index] || void 0,
|
|
14241
|
+
// @ts-ignore
|
|
14242
|
+
total: responseResult.result_total[index],
|
|
14243
|
+
// @ts-ignore
|
|
14244
|
+
next: responseResult.result_next[index],
|
|
14245
|
+
// @todo test this ////
|
|
14246
|
+
// @ts-ignore
|
|
14247
|
+
time: responseResult.result_time[index]
|
|
14248
|
+
},
|
|
14249
|
+
query: {
|
|
14250
|
+
method: q[0] || "",
|
|
14251
|
+
params: parse(q[1] || ""),
|
|
14252
|
+
start: 0
|
|
14253
|
+
},
|
|
14254
|
+
status: response.getStatus()
|
|
14255
|
+
});
|
|
14256
|
+
results.push(data);
|
|
14257
|
+
}
|
|
14258
|
+
};
|
|
14259
|
+
for (const [index, row] of cmd.entries()) {
|
|
14260
|
+
processResponse(row, index);
|
|
14261
|
+
}
|
|
14262
|
+
const dataResult = [];
|
|
14263
|
+
const initError = (result2) => {
|
|
14264
|
+
if (result2.hasError("base-error")) {
|
|
14265
|
+
return result2.errors.get("base-error");
|
|
14266
|
+
}
|
|
14267
|
+
return new AjaxError({
|
|
14268
|
+
code: "0",
|
|
14269
|
+
description: result2.getErrorMessages().join("; "),
|
|
14270
|
+
status: 0,
|
|
14271
|
+
requestInfo: {
|
|
14272
|
+
method: result2.getQuery().method,
|
|
14273
|
+
params: result2.getQuery().params
|
|
14274
|
+
},
|
|
14275
|
+
originalError: result2.getErrors().next().value
|
|
14276
|
+
});
|
|
14277
|
+
};
|
|
14278
|
+
const result = new Result();
|
|
14279
|
+
for (const data of results) {
|
|
14280
|
+
if (data.getStatus() !== 200 || !data.isSuccess) {
|
|
14281
|
+
const error = initError(data);
|
|
14282
|
+
if (!isHaltOnError && !data.isSuccess) {
|
|
14283
|
+
result.addError(error);
|
|
14284
|
+
continue;
|
|
14220
14285
|
}
|
|
14221
|
-
|
|
14286
|
+
return Promise.reject(error);
|
|
14222
14287
|
}
|
|
14288
|
+
dataResult.push(data.getData().result);
|
|
14223
14289
|
}
|
|
14224
14290
|
result.setData(dataResult);
|
|
14225
14291
|
return Promise.resolve(result);
|
|
@@ -14267,9 +14333,14 @@
|
|
|
14267
14333
|
};
|
|
14268
14334
|
}
|
|
14269
14335
|
const problemError = new AjaxError({
|
|
14336
|
+
code: String(answerError.error),
|
|
14337
|
+
description: answerError.errorDescription,
|
|
14270
14338
|
status: error_.response?.status || 0,
|
|
14271
|
-
|
|
14272
|
-
|
|
14339
|
+
requestInfo: {
|
|
14340
|
+
method,
|
|
14341
|
+
params
|
|
14342
|
+
},
|
|
14343
|
+
originalError: error_
|
|
14273
14344
|
});
|
|
14274
14345
|
if (problemError.status === 401 && ["expired_token", "invalid_token"].includes(
|
|
14275
14346
|
problemError.answerError.error
|
|
@@ -14303,9 +14374,14 @@
|
|
|
14303
14374
|
};
|
|
14304
14375
|
}
|
|
14305
14376
|
const problemError2 = new AjaxError({
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14377
|
+
code: String(answerError2.error),
|
|
14378
|
+
description: answerError2.errorDescription,
|
|
14379
|
+
status: error_.response?.status || 0,
|
|
14380
|
+
requestInfo: {
|
|
14381
|
+
method,
|
|
14382
|
+
params
|
|
14383
|
+
},
|
|
14384
|
+
originalError: error__
|
|
14309
14385
|
});
|
|
14310
14386
|
return Promise.reject(problemError2);
|
|
14311
14387
|
}
|
|
@@ -14314,15 +14390,15 @@
|
|
|
14314
14390
|
return Promise.reject(problemError);
|
|
14315
14391
|
}
|
|
14316
14392
|
).then((response) => {
|
|
14317
|
-
const result = new AjaxResult(
|
|
14318
|
-
response.payload,
|
|
14319
|
-
{
|
|
14393
|
+
const result = new AjaxResult({
|
|
14394
|
+
answer: response.payload,
|
|
14395
|
+
query: {
|
|
14320
14396
|
method,
|
|
14321
14397
|
params,
|
|
14322
14398
|
start
|
|
14323
14399
|
},
|
|
14324
|
-
response.status
|
|
14325
|
-
);
|
|
14400
|
+
status: response.status
|
|
14401
|
+
});
|
|
14326
14402
|
return Promise.resolve(result);
|
|
14327
14403
|
});
|
|
14328
14404
|
}
|
|
@@ -14343,7 +14419,7 @@
|
|
|
14343
14419
|
result.logTag = this.#logTag;
|
|
14344
14420
|
}
|
|
14345
14421
|
result[this.#requestIdGenerator.getQueryStringParameterName()] = this.#requestIdGenerator.getRequestId();
|
|
14346
|
-
result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.1
|
|
14422
|
+
result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.2.1";
|
|
14347
14423
|
if (!!result.data && !!result.data.start) {
|
|
14348
14424
|
delete result.data.start;
|
|
14349
14425
|
}
|
|
@@ -15505,11 +15581,13 @@
|
|
|
15505
15581
|
class MessageManager {
|
|
15506
15582
|
#appFrame;
|
|
15507
15583
|
#callbackPromises;
|
|
15584
|
+
#callbackSingletone;
|
|
15508
15585
|
_logger = null;
|
|
15509
15586
|
runCallbackHandler;
|
|
15510
15587
|
constructor(appFrame) {
|
|
15511
15588
|
this.#appFrame = appFrame;
|
|
15512
15589
|
this.#callbackPromises = /* @__PURE__ */ new Map();
|
|
15590
|
+
this.#callbackSingletone = /* @__PURE__ */ new Map();
|
|
15513
15591
|
this.runCallbackHandler = this._runCallback.bind(this);
|
|
15514
15592
|
}
|
|
15515
15593
|
setLogger(logger) {
|
|
@@ -15559,17 +15637,22 @@
|
|
|
15559
15637
|
timeoutId: null
|
|
15560
15638
|
};
|
|
15561
15639
|
const keyPromise = this.#setCallbackPromise(promiseHandler);
|
|
15640
|
+
const paramsSend = omit(params || {}, ["callBack", "isSafely", "safelyTime"]);
|
|
15641
|
+
const { callBack } = params || {};
|
|
15642
|
+
if (callBack) {
|
|
15643
|
+
this.#callbackSingletone.set(keyPromise, callBack);
|
|
15644
|
+
}
|
|
15562
15645
|
if (command.toString().includes(":")) {
|
|
15563
15646
|
cmd = {
|
|
15564
15647
|
method: command.toString(),
|
|
15565
|
-
params:
|
|
15648
|
+
params: paramsSend ?? "",
|
|
15566
15649
|
callback: keyPromise,
|
|
15567
15650
|
appSid: this.#appFrame.getAppSid()
|
|
15568
15651
|
};
|
|
15569
15652
|
} else {
|
|
15570
15653
|
cmd = command.toString();
|
|
15571
15654
|
const listParams = [
|
|
15572
|
-
params ? JSON.stringify(
|
|
15655
|
+
params ? JSON.stringify(paramsSend) : null,
|
|
15573
15656
|
keyPromise,
|
|
15574
15657
|
this.#appFrame.getAppSid()
|
|
15575
15658
|
];
|
|
@@ -15624,6 +15707,11 @@
|
|
|
15624
15707
|
}
|
|
15625
15708
|
this.#callbackPromises.delete(cmd.id);
|
|
15626
15709
|
promise.resolve(cmd.args);
|
|
15710
|
+
} else if (this.#callbackSingletone.has(cmd.id)) {
|
|
15711
|
+
const callBack = this.#callbackSingletone.get(cmd.id);
|
|
15712
|
+
if (callBack) {
|
|
15713
|
+
callBack.apply(globalThis, [cmd.args]);
|
|
15714
|
+
}
|
|
15627
15715
|
}
|
|
15628
15716
|
}
|
|
15629
15717
|
}
|
|
@@ -16350,15 +16438,17 @@
|
|
|
16350
16438
|
/**
|
|
16351
16439
|
* Set Up the Interface Event Handler
|
|
16352
16440
|
* @param {string} eventName
|
|
16441
|
+
* @param {(...args: any[]) => void} callBack
|
|
16353
16442
|
* @return {Promise<any>}
|
|
16354
16443
|
*
|
|
16355
16444
|
* @link https://apidocs.bitrix24.com/api-reference/widgets/ui-interaction/bx24-placement-bind-event.html
|
|
16356
16445
|
*/
|
|
16357
|
-
async bindEvent(eventName) {
|
|
16446
|
+
async bindEvent(eventName, callBack) {
|
|
16358
16447
|
return this.#messageManager.send(
|
|
16359
|
-
MessageCommands.
|
|
16448
|
+
MessageCommands.placementBindEvent,
|
|
16360
16449
|
{
|
|
16361
16450
|
event: eventName,
|
|
16451
|
+
callBack,
|
|
16362
16452
|
isSafely: true
|
|
16363
16453
|
}
|
|
16364
16454
|
);
|
|
@@ -24315,7 +24405,7 @@
|
|
|
24315
24405
|
}
|
|
24316
24406
|
if (message.extra.server_time_unix) {
|
|
24317
24407
|
message.extra.server_time_ago = (Date.now() - message.extra.server_time_unix * 1e3) / 1e3 - (this._config?.server.timeShift || 0);
|
|
24318
|
-
message.extra.server_time_ago =
|
|
24408
|
+
message.extra.server_time_ago = Math.max(message.extra.server_time_ago, 0);
|
|
24319
24409
|
}
|
|
24320
24410
|
this.logMessage(message);
|
|
24321
24411
|
try {
|
|
@@ -25381,7 +25471,7 @@ Data string: ${pullEvent}
|
|
|
25381
25471
|
}
|
|
25382
25472
|
trimDuplicates() {
|
|
25383
25473
|
if (this._session.lastMessageIds.length > MAX_IDS_TO_STORE) {
|
|
25384
|
-
this._session.lastMessageIds = this._session.lastMessageIds.slice(-
|
|
25474
|
+
this._session.lastMessageIds = this._session.lastMessageIds.slice(-10);
|
|
25385
25475
|
}
|
|
25386
25476
|
}
|
|
25387
25477
|
// endregion ////
|
|
@@ -25459,19 +25549,19 @@ Data string: ${pullEvent}
|
|
|
25459
25549
|
* @deprecated
|
|
25460
25550
|
*/
|
|
25461
25551
|
/*/
|
|
25462
|
-
|
|
25463
|
-
|
|
25464
|
-
|
|
25552
|
+
getRestClientOptions()
|
|
25553
|
+
{
|
|
25554
|
+
let result = {};
|
|
25465
25555
|
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25473
|
-
|
|
25474
|
-
|
|
25556
|
+
if (this.guestMode && this.guestUserId !== 0)
|
|
25557
|
+
{
|
|
25558
|
+
result.queryParams = {
|
|
25559
|
+
pull_guest_id: this.guestUserId
|
|
25560
|
+
}
|
|
25561
|
+
}
|
|
25562
|
+
return result;
|
|
25563
|
+
}
|
|
25564
|
+
//*/
|
|
25475
25565
|
// endregion ////
|
|
25476
25566
|
}
|
|
25477
25567
|
|
|
@@ -26037,6 +26127,9 @@ Data string: ${pullEvent}
|
|
|
26037
26127
|
exports.TypeOption = TypeOption;
|
|
26038
26128
|
exports.TypeSpecificUrl = TypeSpecificUrl;
|
|
26039
26129
|
exports.initializeB24Frame = initializeB24Frame;
|
|
26130
|
+
exports.isArrayOfArray = isArrayOfArray;
|
|
26131
|
+
exports.omit = omit;
|
|
26132
|
+
exports.pick = pick$1;
|
|
26040
26133
|
exports.useB24Helper = useB24Helper;
|
|
26041
26134
|
exports.useFormatter = useFormatter;
|
|
26042
26135
|
|