@bitrix24/b24jssdk 0.4.4 → 0.4.5
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/esm/index.d.mts +47 -37
- package/dist/esm/index.d.ts +47 -37
- package/dist/esm/index.mjs +42 -40
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +48 -42
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +14 -14
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.4.
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.4.5
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
@@ -169,7 +169,7 @@ var DataType = /* @__PURE__ */ ((DataType2) => {
|
|
|
169
169
|
return DataType2;
|
|
170
170
|
})(DataType || {});
|
|
171
171
|
|
|
172
|
-
const
|
|
172
|
+
const OBJECT_CONSTRUCTOR_STRING = Function.prototype.toString.call(Object);
|
|
173
173
|
class TypeManager {
|
|
174
174
|
getTag(value) {
|
|
175
175
|
return Object.prototype.toString.call(value);
|
|
@@ -182,10 +182,7 @@ class TypeManager {
|
|
|
182
182
|
* @memo get from pull.client.Utils
|
|
183
183
|
*/
|
|
184
184
|
isString(value) {
|
|
185
|
-
return value === ""
|
|
186
|
-
// eslint-disable-next-line unicorn/no-nested-ternary
|
|
187
|
-
value ? typeof value === "string" || value instanceof String : false
|
|
188
|
-
);
|
|
185
|
+
return typeof value === "string" || value instanceof String;
|
|
189
186
|
}
|
|
190
187
|
/**
|
|
191
188
|
* Returns true if a value is not an empty string
|
|
@@ -202,14 +199,19 @@ class TypeManager {
|
|
|
202
199
|
*
|
|
203
200
|
* @memo get from pull.client.Utils
|
|
204
201
|
*/
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
205
203
|
isFunction(value) {
|
|
206
|
-
return value === null ? false :
|
|
204
|
+
return value === null ? false : (
|
|
205
|
+
// eslint-disable-next-line unicorn/no-instanceof-builtins
|
|
206
|
+
typeof value === "function" || value instanceof Function
|
|
207
|
+
);
|
|
207
208
|
}
|
|
208
209
|
/**
|
|
209
210
|
* Checks that value is an object
|
|
210
211
|
* @param value
|
|
211
212
|
* @return {boolean}
|
|
212
213
|
*/
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
213
215
|
isObject(value) {
|
|
214
216
|
return !!value && (typeof value === "object" || typeof value === "function");
|
|
215
217
|
}
|
|
@@ -235,7 +237,7 @@ class TypeManager {
|
|
|
235
237
|
return true;
|
|
236
238
|
}
|
|
237
239
|
const ctor = proto.hasOwnProperty("constructor") && proto.constructor;
|
|
238
|
-
return typeof ctor === "function" && Function.prototype.toString.call(ctor) ===
|
|
240
|
+
return typeof ctor === "function" && Function.prototype.toString.call(ctor) === OBJECT_CONSTRUCTOR_STRING;
|
|
239
241
|
}
|
|
240
242
|
isJsonRpcRequest(value) {
|
|
241
243
|
return typeof value === "object" && value && "jsonrpc" in value && this.isStringFilled(value.jsonrpc) && "method" in value && this.isStringFilled(value.method);
|
|
@@ -257,7 +259,7 @@ class TypeManager {
|
|
|
257
259
|
* @return {boolean}
|
|
258
260
|
*/
|
|
259
261
|
isNumber(value) {
|
|
260
|
-
return
|
|
262
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
261
263
|
}
|
|
262
264
|
/**
|
|
263
265
|
* Checks that value is integer
|
|
@@ -265,7 +267,7 @@ class TypeManager {
|
|
|
265
267
|
* @return {boolean}
|
|
266
268
|
*/
|
|
267
269
|
isInteger(value) {
|
|
268
|
-
return
|
|
270
|
+
return Number.isInteger(value);
|
|
269
271
|
}
|
|
270
272
|
/**
|
|
271
273
|
* Checks that value is float
|
|
@@ -313,7 +315,7 @@ class TypeManager {
|
|
|
313
315
|
* @return {boolean}
|
|
314
316
|
*/
|
|
315
317
|
isDate(value) {
|
|
316
|
-
return
|
|
318
|
+
return value instanceof Date;
|
|
317
319
|
}
|
|
318
320
|
/**
|
|
319
321
|
* Checks that is a DOM node
|
|
@@ -442,12 +444,15 @@ class TypeManager {
|
|
|
442
444
|
* @return {boolean}
|
|
443
445
|
*/
|
|
444
446
|
isFormData(value) {
|
|
445
|
-
|
|
447
|
+
if (typeof FormData !== "undefined" && value instanceof FormData) {
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
return this.isObjectLike(value) && this.getTag(value) === "[object FormData]";
|
|
446
451
|
}
|
|
447
452
|
clone(obj, bCopyObj = true) {
|
|
448
453
|
let _obj, i, l;
|
|
449
|
-
if (obj
|
|
450
|
-
return
|
|
454
|
+
if (this.isNil(obj) || typeof obj !== "object") {
|
|
455
|
+
return obj;
|
|
451
456
|
}
|
|
452
457
|
if (this.isDomNode(obj)) {
|
|
453
458
|
_obj = obj.cloneNode(bCopyObj);
|
|
@@ -1678,7 +1683,7 @@ class Http {
|
|
|
1678
1683
|
#clientSideWarningMessage = "";
|
|
1679
1684
|
constructor(baseURL, authActions, options) {
|
|
1680
1685
|
const defaultHeaders = {
|
|
1681
|
-
// 'X-Sdk': 'b24-js-sdk-v-0.4.
|
|
1686
|
+
// 'X-Sdk': 'b24-js-sdk-v-0.4.5'
|
|
1682
1687
|
};
|
|
1683
1688
|
this.#clientAxios = axios.create({
|
|
1684
1689
|
baseURL,
|
|
@@ -1743,19 +1748,21 @@ class Http {
|
|
|
1743
1748
|
}
|
|
1744
1749
|
// endregion ////
|
|
1745
1750
|
// region Actions Call ////
|
|
1746
|
-
async batch(calls, isHaltOnError = true) {
|
|
1751
|
+
async batch(calls, isHaltOnError = true, returnAjaxResult = false) {
|
|
1747
1752
|
if (Array.isArray(calls)) {
|
|
1748
1753
|
return this.#batchAsArray(
|
|
1749
1754
|
calls,
|
|
1750
|
-
isHaltOnError
|
|
1755
|
+
isHaltOnError,
|
|
1756
|
+
returnAjaxResult
|
|
1751
1757
|
);
|
|
1752
1758
|
}
|
|
1753
1759
|
return this.#batchAsObject(
|
|
1754
1760
|
calls,
|
|
1755
|
-
isHaltOnError
|
|
1761
|
+
isHaltOnError,
|
|
1762
|
+
returnAjaxResult
|
|
1756
1763
|
);
|
|
1757
1764
|
}
|
|
1758
|
-
async #batchAsObject(calls, isHaltOnError = true) {
|
|
1765
|
+
async #batchAsObject(calls, isHaltOnError = true, returnAjaxResult = false) {
|
|
1759
1766
|
const cmd = {};
|
|
1760
1767
|
let cnt = 0;
|
|
1761
1768
|
const processRow = (row, index) => {
|
|
@@ -1851,13 +1858,13 @@ class Http {
|
|
|
1851
1858
|
}
|
|
1852
1859
|
return Promise.reject(error);
|
|
1853
1860
|
}
|
|
1854
|
-
dataResult[key] = data.getData().result;
|
|
1861
|
+
dataResult[key] = returnAjaxResult ? data : data.getData().result;
|
|
1855
1862
|
}
|
|
1856
1863
|
result.setData(dataResult);
|
|
1857
1864
|
return Promise.resolve(result);
|
|
1858
1865
|
});
|
|
1859
1866
|
}
|
|
1860
|
-
async #batchAsArray(calls, isHaltOnError = true) {
|
|
1867
|
+
async #batchAsArray(calls, isHaltOnError = true, returnAjaxResult = false) {
|
|
1861
1868
|
const cmd = [];
|
|
1862
1869
|
let cnt = 0;
|
|
1863
1870
|
const processRow = (row) => {
|
|
@@ -1954,7 +1961,7 @@ class Http {
|
|
|
1954
1961
|
}
|
|
1955
1962
|
return Promise.reject(error);
|
|
1956
1963
|
}
|
|
1957
|
-
dataResult.push(data.getData().result);
|
|
1964
|
+
dataResult.push(returnAjaxResult ? data : data.getData().result);
|
|
1958
1965
|
}
|
|
1959
1966
|
result.setData(dataResult);
|
|
1960
1967
|
return Promise.resolve(result);
|
|
@@ -2106,7 +2113,7 @@ class Http {
|
|
|
2106
2113
|
const baseUrl = `${encodeURIComponent(method)}.json`;
|
|
2107
2114
|
const queryParams = new URLSearchParams({
|
|
2108
2115
|
[this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
|
|
2109
|
-
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.
|
|
2116
|
+
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.5",
|
|
2110
2117
|
[this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
|
|
2111
2118
|
});
|
|
2112
2119
|
return `${baseUrl}?${queryParams.toString()}`;
|
|
@@ -2254,8 +2261,8 @@ class AbstractB24 {
|
|
|
2254
2261
|
/**
|
|
2255
2262
|
* @inheritDoc
|
|
2256
2263
|
*/
|
|
2257
|
-
async callBatch(calls, isHaltOnError = true) {
|
|
2258
|
-
return this.getHttpClient().batch(calls, isHaltOnError);
|
|
2264
|
+
async callBatch(calls, isHaltOnError = true, returnAjaxResult = false) {
|
|
2265
|
+
return this.getHttpClient().batch(calls, isHaltOnError, returnAjaxResult);
|
|
2259
2266
|
}
|
|
2260
2267
|
chunkArray(array, chunkSize = 50) {
|
|
2261
2268
|
const result = [];
|
|
@@ -2607,7 +2614,7 @@ class FormatterIban {
|
|
|
2607
2614
|
* @returns {boolean} true if the passed IBAN is valid, false otherwise
|
|
2608
2615
|
*/
|
|
2609
2616
|
isValid(iban) {
|
|
2610
|
-
if (!
|
|
2617
|
+
if (!Type.isString(iban)) {
|
|
2611
2618
|
return false;
|
|
2612
2619
|
}
|
|
2613
2620
|
iban = this.electronicFormat(iban);
|
|
@@ -2682,7 +2689,7 @@ class FormatterIban {
|
|
|
2682
2689
|
* @param bban the BBAN to check the validity of
|
|
2683
2690
|
*/
|
|
2684
2691
|
isValidBBAN(countryCode, bban) {
|
|
2685
|
-
if (!
|
|
2692
|
+
if (!Type.isString(bban)) {
|
|
2686
2693
|
return false;
|
|
2687
2694
|
}
|
|
2688
2695
|
if (!this._countries.has(countryCode)) {
|
|
@@ -2692,11 +2699,6 @@ class FormatterIban {
|
|
|
2692
2699
|
return !!countryStructure && countryStructure.isValidBBAN(this.electronicFormat(bban));
|
|
2693
2700
|
}
|
|
2694
2701
|
// endregion ////
|
|
2695
|
-
// region Tools ////
|
|
2696
|
-
_isString(value) {
|
|
2697
|
-
return typeof value == "string" || value instanceof String;
|
|
2698
|
-
}
|
|
2699
|
-
// endregion ////
|
|
2700
2702
|
}
|
|
2701
2703
|
|
|
2702
2704
|
const useFormatter = () => {
|
|
@@ -11857,8 +11859,8 @@ class PullClient {
|
|
|
11857
11859
|
if (!skipReconnectToLastSession && this._storage) {
|
|
11858
11860
|
oldSession = this._storage.get(LS_SESSION, null);
|
|
11859
11861
|
}
|
|
11860
|
-
if (Type.isPlainObject(oldSession) && oldSession.hasOwnProperty("ttl") && oldSession
|
|
11861
|
-
this._session.mid = oldSession
|
|
11862
|
+
if (Type.isPlainObject(oldSession) && oldSession.hasOwnProperty("ttl") && oldSession["ttl"] >= now) {
|
|
11863
|
+
this._session.mid = oldSession["mid"];
|
|
11862
11864
|
}
|
|
11863
11865
|
this._starting = true;
|
|
11864
11866
|
return this._startingPromise = new Promise((resolve, reject) => {
|
|
@@ -12681,22 +12683,22 @@ class PullClient {
|
|
|
12681
12683
|
if (!Type.isPlainObject(config)) {
|
|
12682
12684
|
return false;
|
|
12683
12685
|
}
|
|
12684
|
-
if (Number(config
|
|
12686
|
+
if (Number(config["server"].config_timestamp) !== this._configTimestamp) {
|
|
12685
12687
|
return false;
|
|
12686
12688
|
}
|
|
12687
12689
|
const now = /* @__PURE__ */ new Date();
|
|
12688
|
-
if (Type.isNumber(config
|
|
12690
|
+
if (Type.isNumber(config["exp"]) && config["exp"] > 0 && config["exp"] < now.getTime() / 1e3) {
|
|
12689
12691
|
return false;
|
|
12690
12692
|
}
|
|
12691
|
-
const channelCount = Object.keys(config
|
|
12693
|
+
const channelCount = Object.keys(config["channels"]).length;
|
|
12692
12694
|
if (channelCount === 0) {
|
|
12693
12695
|
return false;
|
|
12694
12696
|
}
|
|
12695
|
-
for (const channelType in config
|
|
12696
|
-
if (!config
|
|
12697
|
+
for (const channelType in config["channels"]) {
|
|
12698
|
+
if (!config["channels"].hasOwnProperty(channelType)) {
|
|
12697
12699
|
continue;
|
|
12698
12700
|
}
|
|
12699
|
-
const channel = config
|
|
12701
|
+
const channel = config["channels"][channelType];
|
|
12700
12702
|
const channelEnd = new Date(channel.end);
|
|
12701
12703
|
if (channelEnd < now) {
|
|
12702
12704
|
return false;
|