@bitrix24/b24jssdk 0.1.4 → 0.1.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.
@@ -579,6 +579,12 @@ type TypeHttp = {
579
579
  getRestrictionManagerParams(): TypeRestrictionManagerParams;
580
580
  setLogTag(logTag?: string): void;
581
581
  clearLogTag(): void;
582
+ /**
583
+ * On|Off warning about client-side query execution
584
+ * @param {boolean} value
585
+ * @param {string} message
586
+ */
587
+ setClientSideWarning(value: boolean, message: string): void;
582
588
  };
583
589
  interface IRequestIdGenerator {
584
590
  getRequestId(): string;
@@ -1613,6 +1619,10 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
1613
1619
  constructor(b24HookParams: B24HookParams);
1614
1620
  setLogger(logger: LoggerBrowser): void;
1615
1621
  get auth(): AuthActions;
1622
+ /**
1623
+ * Disables warning about client-side query execution
1624
+ */
1625
+ offClientSideWarning(): void;
1616
1626
  /**
1617
1627
  * Get the account address BX24 ( https://name.bitrix24.com )
1618
1628
  */
@@ -579,6 +579,12 @@ type TypeHttp = {
579
579
  getRestrictionManagerParams(): TypeRestrictionManagerParams;
580
580
  setLogTag(logTag?: string): void;
581
581
  clearLogTag(): void;
582
+ /**
583
+ * On|Off warning about client-side query execution
584
+ * @param {boolean} value
585
+ * @param {string} message
586
+ */
587
+ setClientSideWarning(value: boolean, message: string): void;
582
588
  };
583
589
  interface IRequestIdGenerator {
584
590
  getRequestId(): string;
@@ -1613,6 +1619,10 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
1613
1619
  constructor(b24HookParams: B24HookParams);
1614
1620
  setLogger(logger: LoggerBrowser): void;
1615
1621
  get auth(): AuthActions;
1622
+ /**
1623
+ * Disables warning about client-side query execution
1624
+ */
1625
+ offClientSideWarning(): void;
1616
1626
  /**
1617
1627
  * Get the account address BX24 ( https://name.bitrix24.com )
1618
1628
  */
@@ -579,6 +579,12 @@ type TypeHttp = {
579
579
  getRestrictionManagerParams(): TypeRestrictionManagerParams;
580
580
  setLogTag(logTag?: string): void;
581
581
  clearLogTag(): void;
582
+ /**
583
+ * On|Off warning about client-side query execution
584
+ * @param {boolean} value
585
+ * @param {string} message
586
+ */
587
+ setClientSideWarning(value: boolean, message: string): void;
582
588
  };
583
589
  interface IRequestIdGenerator {
584
590
  getRequestId(): string;
@@ -1613,6 +1619,10 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
1613
1619
  constructor(b24HookParams: B24HookParams);
1614
1620
  setLogger(logger: LoggerBrowser): void;
1615
1621
  get auth(): AuthActions;
1622
+ /**
1623
+ * Disables warning about client-side query execution
1624
+ */
1625
+ offClientSideWarning(): void;
1616
1626
  /**
1617
1627
  * Get the account address BX24 ( https://name.bitrix24.com )
1618
1628
  */
@@ -579,6 +579,12 @@ type TypeHttp = {
579
579
  getRestrictionManagerParams(): TypeRestrictionManagerParams;
580
580
  setLogTag(logTag?: string): void;
581
581
  clearLogTag(): void;
582
+ /**
583
+ * On|Off warning about client-side query execution
584
+ * @param {boolean} value
585
+ * @param {string} message
586
+ */
587
+ setClientSideWarning(value: boolean, message: string): void;
582
588
  };
583
589
  interface IRequestIdGenerator {
584
590
  getRequestId(): string;
@@ -1613,6 +1619,10 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
1613
1619
  constructor(b24HookParams: B24HookParams);
1614
1620
  setLogger(logger: LoggerBrowser): void;
1615
1621
  get auth(): AuthActions;
1622
+ /**
1623
+ * Disables warning about client-side query execution
1624
+ */
1625
+ offClientSideWarning(): void;
1616
1626
  /**
1617
1627
  * Get the account address BX24 ( https://name.bitrix24.com )
1618
1628
  */
@@ -579,6 +579,12 @@ type TypeHttp = {
579
579
  getRestrictionManagerParams(): TypeRestrictionManagerParams;
580
580
  setLogTag(logTag?: string): void;
581
581
  clearLogTag(): void;
582
+ /**
583
+ * On|Off warning about client-side query execution
584
+ * @param {boolean} value
585
+ * @param {string} message
586
+ */
587
+ setClientSideWarning(value: boolean, message: string): void;
582
588
  };
583
589
  interface IRequestIdGenerator {
584
590
  getRequestId(): string;
@@ -1613,6 +1619,10 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
1613
1619
  constructor(b24HookParams: B24HookParams);
1614
1620
  setLogger(logger: LoggerBrowser): void;
1615
1621
  get auth(): AuthActions;
1622
+ /**
1623
+ * Disables warning about client-side query execution
1624
+ */
1625
+ offClientSideWarning(): void;
1616
1626
  /**
1617
1627
  * Get the account address BX24 ( https://name.bitrix24.com )
1618
1628
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @version @bitrix24/b24jssdk v0.1.4
2
+ * @version @bitrix24/b24jssdk v0.1.5
3
3
  * @copyright (c) 2024 Bitrix24
4
4
  * @licence MIT
5
5
  * @links https://github.com/bitrix24/b24jssdk - GitHub
@@ -1324,7 +1324,10 @@ class Http {
1324
1324
  #restrictionManager;
1325
1325
  #requestIdGenerator;
1326
1326
  _logger = null;
1327
+ _loggerSystem = null;
1327
1328
  #logTag = "";
1329
+ #isClientSideWarning = false;
1330
+ #clientSideWarningMessage = "";
1328
1331
  constructor(baseURL, authActions, options) {
1329
1332
  this.#clientAxios = axios.create({
1330
1333
  baseURL,
@@ -1334,6 +1337,7 @@ class Http {
1334
1337
  this.#restrictionManager = new RestrictionManager();
1335
1338
  this.#requestIdGenerator = new DefaultRequestIdGenerator();
1336
1339
  }
1340
+ // region Logger ////
1337
1341
  setLogger(logger) {
1338
1342
  this._logger = logger;
1339
1343
  this.#restrictionManager.setLogger(this.getLogger());
@@ -1352,18 +1356,38 @@ class Http {
1352
1356
  }
1353
1357
  return this._logger;
1354
1358
  }
1359
+ getSystemLogger() {
1360
+ if (null === this._loggerSystem) {
1361
+ this._loggerSystem = LoggerBrowser.build(`SystemLogger`);
1362
+ this._loggerSystem.setConfig({
1363
+ [LoggerType.desktop]: false,
1364
+ [LoggerType.log]: false,
1365
+ [LoggerType.info]: true,
1366
+ [LoggerType.warn]: true,
1367
+ [LoggerType.error]: true,
1368
+ [LoggerType.trace]: false
1369
+ });
1370
+ }
1371
+ return this._loggerSystem;
1372
+ }
1373
+ // endregion ////
1374
+ // region RestrictionManager ////
1355
1375
  setRestrictionManagerParams(params) {
1356
1376
  this.#restrictionManager.params = params;
1357
1377
  }
1358
1378
  getRestrictionManagerParams() {
1359
1379
  return this.#restrictionManager.params;
1360
1380
  }
1381
+ // endregion ////
1382
+ // region LogTag ////
1361
1383
  setLogTag(logTag) {
1362
1384
  this.#logTag = logTag;
1363
1385
  }
1364
1386
  clearLogTag() {
1365
1387
  this.#logTag = "";
1366
1388
  }
1389
+ // endregion ////
1390
+ // region Actions Call ////
1367
1391
  async batch(calls, isHaltOnError = true) {
1368
1392
  const isArrayMode = Array.isArray(calls);
1369
1393
  const cmd = isArrayMode ? [] : {};
@@ -1505,6 +1529,9 @@ class Http {
1505
1529
  authData = await this.#authActions.refreshAuth();
1506
1530
  }
1507
1531
  await this.#restrictionManager.check();
1532
+ if (this.#isClientSideWarning && !this.isServerSide() && Type.isStringFilled(this.#clientSideWarningMessage)) {
1533
+ this.getSystemLogger().warn(this.#clientSideWarningMessage);
1534
+ }
1508
1535
  return this.#clientAxios.post(
1509
1536
  this.#prepareMethod(method),
1510
1537
  this.#prepareParams(authData, params, start)
@@ -1588,6 +1615,8 @@ class Http {
1588
1615
  return Promise.resolve(result);
1589
1616
  });
1590
1617
  }
1618
+ // endregion ////
1619
+ // region Prepare ////
1591
1620
  /**
1592
1621
  * Processes function parameters and adds authorization
1593
1622
  *
@@ -1603,7 +1632,7 @@ class Http {
1603
1632
  result.logTag = this.#logTag;
1604
1633
  }
1605
1634
  result[this.#requestIdGenerator.getQueryStringParameterName()] = this.#requestIdGenerator.getRequestId();
1606
- result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.1.4";
1635
+ result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.1.5";
1607
1636
  if (!!result.data && !!result.data.start) {
1608
1637
  delete result.data.start;
1609
1638
  }
@@ -1622,6 +1651,24 @@ class Http {
1622
1651
  #prepareMethod(method) {
1623
1652
  return `${encodeURIComponent(method)}.json`;
1624
1653
  }
1654
+ /**
1655
+ * @inheritDoc
1656
+ */
1657
+ setClientSideWarning(value, message) {
1658
+ this.#isClientSideWarning = value;
1659
+ this.#clientSideWarningMessage = message;
1660
+ }
1661
+ // endregion ////
1662
+ // region Tools ////
1663
+ /**
1664
+ * Tests whether the code is executed on the client side
1665
+ * @return {boolean}
1666
+ * @protected
1667
+ */
1668
+ isServerSide() {
1669
+ return Type.isUndefined(window);
1670
+ }
1671
+ // endregion ////
1625
1672
  }
1626
1673
 
1627
1674
  class AbstractB24 {
@@ -2676,6 +2723,10 @@ class B24Hook extends AbstractB24 {
2676
2723
  this.#authHookManager,
2677
2724
  this._getHttpOptions()
2678
2725
  );
2726
+ this._http.setClientSideWarning(
2727
+ true,
2728
+ "It is not safe to use hook requests on the client side"
2729
+ );
2679
2730
  this._isInit = true;
2680
2731
  }
2681
2732
  setLogger(logger) {
@@ -2686,6 +2737,12 @@ class B24Hook extends AbstractB24 {
2686
2737
  return this.#authHookManager;
2687
2738
  }
2688
2739
  // region Core ////
2740
+ /**
2741
+ * Disables warning about client-side query execution
2742
+ */
2743
+ offClientSideWarning() {
2744
+ this.getHttpClient().setClientSideWarning(false, "");
2745
+ }
2689
2746
  // endregion ////
2690
2747
  // region Get ////
2691
2748
  /**