@bitrix24/b24jssdk 0.2.2 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @version @bitrix24/b24jssdk v0.2.2
2
+ * @version @bitrix24/b24jssdk v0.3.0
3
3
  * @copyright (c) 2025 Bitrix24
4
4
  * @licence MIT
5
5
  * @links https://github.com/bitrix24/b24jssdk - GitHub
@@ -1513,13 +1513,17 @@ class RestrictionManager {
1513
1513
 
1514
1514
  const DEFAULT_REQUEST_ID_HEADER_FIELD_NAME = "X-Request-ID";
1515
1515
  const DEFAULT_QUERY_STRING_PARAMETER_NAME = "bx24_request_id";
1516
- const DEFAULT_QUERY_STRING_SDK_PARAMETER_NAME = "bx24_sdk_ver";
1516
+ const DEFAULT_QUERY_STRING_SDK_VER_PARAMETER_NAME = "bx24_sdk_ver";
1517
+ const DEFAULT_QUERY_STRING_SDK_TYPE_PARAMETER_NAME = "bx24_sdk_type";
1517
1518
  class DefaultRequestIdGenerator {
1518
1519
  getQueryStringParameterName() {
1519
1520
  return DEFAULT_QUERY_STRING_PARAMETER_NAME;
1520
1521
  }
1521
1522
  getQueryStringSdkParameterName() {
1522
- return DEFAULT_QUERY_STRING_SDK_PARAMETER_NAME;
1523
+ return DEFAULT_QUERY_STRING_SDK_VER_PARAMETER_NAME;
1524
+ }
1525
+ getQueryStringSdkTypeParameterName() {
1526
+ return DEFAULT_QUERY_STRING_SDK_TYPE_PARAMETER_NAME;
1523
1527
  }
1524
1528
  generate() {
1525
1529
  return Text.getUuidRfc4122();
@@ -1544,7 +1548,7 @@ class Http {
1544
1548
  #clientSideWarningMessage = "";
1545
1549
  constructor(baseURL, authActions, options) {
1546
1550
  const defaultHeaders = {
1547
- // 'X-Sdk': 'b24-js-sdk-v-0.2.2'
1551
+ // 'X-Sdk': 'b24-js-sdk-v-0.3.0'
1548
1552
  };
1549
1553
  this.#clientAxios = axios.create({
1550
1554
  baseURL,
@@ -1953,8 +1957,6 @@ class Http {
1953
1957
  if (this.#logTag.length > 0) {
1954
1958
  result.logTag = this.#logTag;
1955
1959
  }
1956
- result[this.#requestIdGenerator.getQueryStringParameterName()] = this.#requestIdGenerator.getRequestId();
1957
- result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.2.2";
1958
1960
  if (!!result.data && !!result.data.start) {
1959
1961
  delete result.data.start;
1960
1962
  }
@@ -1971,7 +1973,13 @@ class Http {
1971
1973
  * @private
1972
1974
  */
1973
1975
  #prepareMethod(method) {
1974
- return `${encodeURIComponent(method)}.json`;
1976
+ const baseUrl = `${encodeURIComponent(method)}.json`;
1977
+ const queryParams = new URLSearchParams({
1978
+ [this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
1979
+ [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.3.0",
1980
+ [this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
1981
+ });
1982
+ return `${baseUrl}?${queryParams.toString()}`;
1975
1983
  }
1976
1984
  /**
1977
1985
  * @inheritDoc
@@ -3172,22 +3180,28 @@ class MessageManager {
3172
3180
  timeoutId: null
3173
3181
  };
3174
3182
  const keyPromise = this.#setCallbackPromise(promiseHandler);
3175
- const paramsSend = omit(params || {}, ["callBack", "isSafely", "safelyTime"]);
3176
- const { callBack } = params || {};
3183
+ let paramsSend = null;
3184
+ const optionsSend = omit(params || {}, ["singleOption", "callBack", "isSafely", "safelyTime"]);
3185
+ const { callBack, singleOption } = params || {};
3177
3186
  if (callBack) {
3178
3187
  this.#callbackSingletone.set(keyPromise, callBack);
3179
3188
  }
3189
+ if (singleOption) {
3190
+ paramsSend = singleOption;
3191
+ } else if (Object.keys(optionsSend).length > 0) {
3192
+ paramsSend = { ...optionsSend };
3193
+ }
3180
3194
  if (command.toString().includes(":")) {
3181
3195
  cmd = {
3182
3196
  method: command.toString(),
3183
- params: paramsSend ?? "",
3197
+ params: paramsSend || "",
3184
3198
  callback: keyPromise,
3185
3199
  appSid: this.#appFrame.getAppSid()
3186
3200
  };
3187
3201
  } else {
3188
3202
  cmd = command.toString();
3189
3203
  const listParams = [
3190
- params ? JSON.stringify(paramsSend) : null,
3204
+ paramsSend ? JSON.stringify(paramsSend) : "",
3191
3205
  keyPromise,
3192
3206
  this.#appFrame.getAppSid()
3193
3207
  ];
@@ -4005,6 +4019,30 @@ class PlacementManager {
4005
4019
  }
4006
4020
  );
4007
4021
  }
4022
+ /**
4023
+ * Set Up the Interface Event Handler
4024
+ * @param {string} command
4025
+ * @param {null | string | Record<string, any>} parameters
4026
+ * @param {(...args: any[]) => void} callBack
4027
+ *
4028
+ * @return {Promise<any>}
4029
+ */
4030
+ async callCustomBind(command, parameters = null, callBack) {
4031
+ let options = {};
4032
+ if (Type.isString(parameters)) {
4033
+ options["singleOption"] = parameters;
4034
+ } else if (Type.isObjectLike(parameters)) {
4035
+ options = { ...parameters };
4036
+ }
4037
+ return this.#messageManager.send(
4038
+ command,
4039
+ {
4040
+ ...options,
4041
+ callBack,
4042
+ isSafely: true
4043
+ }
4044
+ );
4045
+ }
4008
4046
  }
4009
4047
 
4010
4048
  class B24Frame extends AbstractB24 {