@wix/bex-utils 2.58.0 → 2.60.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.
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.25.0](https://github.com/wix-private/cairo/compare/@wix/bex-bundled-mini-essentials@2.24.0...@wix/bex-bundled-mini-essentials@2.25.0) (2025-08-05)
7
+
8
+ **Note:** Version bump only for package @wix/bex-bundled-mini-essentials
9
+
6
10
  # [2.24.0](https://github.com/wix-private/cairo/compare/@wix/bex-bundled-mini-essentials@2.22.0...@wix/bex-bundled-mini-essentials@2.24.0) (2025-08-04)
7
11
 
8
12
  **Note:** Version bump only for package @wix/bex-bundled-mini-essentials
@@ -5530,7 +5530,7 @@ var require_common_errors_pt = __commonJS({
5530
5530
  "errorHandler.common-error.permission-denied": "Voc\xEA n\xE3o tem as permiss\xF5es necess\xE1rias. Solicite acesso ao propriet\xE1rio.",
5531
5531
  "errorHandler.requestID.tooltip.description": "Se voc\xEA for reportar esse erro ao Apoio ao Cliente, compartilhe esse ID de solicita\xE7\xE3o para que eles possam investigar.",
5532
5532
  "errorHandler.common-error.technicalIssue-unmappedError": "Houve um problema t\xE9cnico no nosso sistema. Tente novamente ou atualize.",
5533
- "errorHandler.common-error.unauthenticated": "Voc\xEA est\xE1 desconectado. Fa\xE7a login novamente para continuar.",
5533
+ "errorHandler.common-error.unauthenticated": "Sua conta est\xE1 desconectada. Fa\xE7a login novamente para continuar.",
5534
5534
  "errorHandler.common-error.networkError": "Houve um problema na conex\xE3o com sua rede. Verifique sua conex\xE3o e tente novamente.",
5535
5535
  "errorHandler.common-error.technicalIssue": "Houve um problema t\xE9cnico no nosso sistema. Tente novamente ou atualize.",
5536
5536
  "errorHandler.common-error.captchaRequired": "Para continuar, confirme que voc\xEA \xE9 humano.",
@@ -8849,7 +8849,7 @@ function reportErrorBi(errorHandler, params) {
8849
8849
  errorMessage,
8850
8850
  exceptionMessage,
8851
8851
  httpError,
8852
- error
8852
+ errorHandlerState
8853
8853
  } = errorAccessor;
8854
8854
  const config = httpError == null ? void 0 : httpError.config;
8855
8855
  biLogger.report(withoutDefaults(httpClientErrorSrc176Evid404)({
@@ -8867,11 +8867,11 @@ function reportErrorBi(errorHandler, params) {
8867
8867
  request_id: httpError == null ? void 0 : httpError.requestId,
8868
8868
  hasInternetConnection: onlineManager.onLine,
8869
8869
  pageUrl: webWindow == null || (_webWindow$location = webWindow.location) == null ? void 0 : _webWindow$location.href,
8870
- session_id: error == null ? void 0 : error._errorHandlerSessionId,
8870
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId,
8871
8871
  serverUrl: (config == null ? void 0 : config.url) || (requestOptions == null ? void 0 : requestOptions.url),
8872
8872
  method: (config == null ? void 0 : config.method) || (requestOptions == null ? void 0 : requestOptions.method) || "unknown",
8873
- entity_fqdn: config == null ? void 0 : config.entityFqdn,
8874
- method_fqn: config == null ? void 0 : config.methodFqn,
8873
+ entity_fqdn: (config == null ? void 0 : config.entityFqdn) || (requestOptions == null ? void 0 : requestOptions.entityFqdn),
8874
+ method_fqn: (config == null ? void 0 : config.methodFqn) || (requestOptions == null ? void 0 : requestOptions.methodFqn),
8875
8875
  server_artifactid: config == null ? void 0 : config.artifactId
8876
8876
  }));
8877
8877
  }
@@ -9071,10 +9071,12 @@ function createBiLoggerWithDefaults(params) {
9071
9071
  // ../../node_modules/@wix/error-handler/dist/esm/state/ErrorAccessor.js
9072
9072
  var import_defineProperty2 = __toESM(require_defineProperty());
9073
9073
 
9074
- // ../../node_modules/@wix/error-handler/dist/esm/util/httpErrorDecoders.js
9074
+ // ../../node_modules/@wix/error-handler/dist/esm/util/isObject.js
9075
9075
  function isObject(thing) {
9076
9076
  return thing != null;
9077
9077
  }
9078
+
9079
+ // ../../node_modules/@wix/error-handler/dist/esm/util/httpErrorDecoders.js
9078
9080
  function isHttpError(err) {
9079
9081
  return isObject(err) && err.response != null;
9080
9082
  }
@@ -9092,7 +9094,7 @@ function isObject2(thing) {
9092
9094
  function isSdkError(err) {
9093
9095
  return isObject2(err) && err.status != null;
9094
9096
  }
9095
- function toMinimalHttpError(err) {
9097
+ function sdkErrorToMinimalHttpError(err) {
9096
9098
  return {
9097
9099
  response: {
9098
9100
  data: {
@@ -9104,6 +9106,19 @@ function toMinimalHttpError(err) {
9104
9106
  };
9105
9107
  }
9106
9108
 
9109
+ // ../../node_modules/@wix/error-handler/dist/esm/util/responseErrorDecoders.js
9110
+ function responseToMinimalHttpError(err) {
9111
+ var _err$_errorHandlerSta;
9112
+ const data = (_err$_errorHandlerSta = err._errorHandlerState) == null ? void 0 : _err$_errorHandlerSta.responseData;
9113
+ return {
9114
+ response: {
9115
+ data,
9116
+ status: err.status
9117
+ },
9118
+ requestId: err.headers.get("X-Wix-Request-Id")
9119
+ };
9120
+ }
9121
+
9107
9122
  // ../../node_modules/@wix/error-handler/dist/esm/state/ErrorAccessor.js
9108
9123
  var ErrorAccessor = class {
9109
9124
  constructor(params) {
@@ -9114,7 +9129,10 @@ var ErrorAccessor = class {
9114
9129
  this.inputError = params.error;
9115
9130
  }
9116
9131
  get error() {
9117
- return this._error ??= this.inputError instanceof Error ? this.inputError : null;
9132
+ const {
9133
+ inputError
9134
+ } = this;
9135
+ return this._error ??= typeof Response !== "undefined" && inputError instanceof Response ? inputError : inputError instanceof Error ? inputError : null;
9118
9136
  }
9119
9137
  /**
9120
9138
  * The message of the JS error, for example: `Network Error`
@@ -9130,7 +9148,16 @@ var ErrorAccessor = class {
9130
9148
  const {
9131
9149
  inputError
9132
9150
  } = this;
9133
- return this._httpError ??= isHttpError(inputError) ? inputError : isSdkError(inputError) ? toMinimalHttpError(inputError) : null;
9151
+ return this._httpError ??= isHttpError(inputError) ? inputError : typeof Response !== "undefined" && inputError instanceof Response ? responseToMinimalHttpError(inputError) : isSdkError(inputError) ? sdkErrorToMinimalHttpError(inputError) : null;
9152
+ }
9153
+ get errorHandlerState() {
9154
+ const {
9155
+ error
9156
+ } = this;
9157
+ if (!error) {
9158
+ return null;
9159
+ }
9160
+ return error._errorHandlerState ??= {};
9134
9161
  }
9135
9162
  /**
9136
9163
  * errno symbolic name** like `ENETUNREACH`, Not http status code
@@ -9256,16 +9283,18 @@ var TranslationsState = class {
9256
9283
  disableAutoInit: true
9257
9284
  });
9258
9285
  this._initPromise = new Promise(async (resolve) => {
9286
+ var _this$i18n$on, _this$i18n2;
9259
9287
  let failedLoading = false;
9260
9288
  const onFailedLoading = (lng, _ns, err) => {
9289
+ var _this$i18n$off, _this$i18n;
9261
9290
  if (lng !== "en") {
9262
9291
  return;
9263
9292
  }
9264
- this.i18n.off("failedLoading", onFailedLoading);
9293
+ (_this$i18n$off = (_this$i18n = this.i18n).off) == null || _this$i18n$off.call(_this$i18n, "failedLoading", onFailedLoading);
9265
9294
  failedLoading = true;
9266
9295
  resolve(err);
9267
9296
  };
9268
- this.i18n.on("failedLoading", onFailedLoading);
9297
+ (_this$i18n$on = (_this$i18n2 = this.i18n).on) == null || _this$i18n$on.call(_this$i18n2, "failedLoading", onFailedLoading);
9269
9298
  try {
9270
9299
  await this.i18n.init();
9271
9300
  if (failedLoading) {
@@ -9297,7 +9326,7 @@ function reportErrorResolutionBi(errorHandler, params) {
9297
9326
  biLogger
9298
9327
  } = errorHandler;
9299
9328
  const {
9300
- error,
9329
+ errorHandlerState,
9301
9330
  applicationError
9302
9331
  } = errorAccessor;
9303
9332
  const code = applicationError == null ? void 0 : applicationError.code;
@@ -9305,7 +9334,7 @@ function reportErrorResolutionBi(errorHandler, params) {
9305
9334
  biLogger.report(withoutDefaults(httpClientErrorMappingSrc176Evid100)({
9306
9335
  error_opt_out: applicationErrorMapping === false,
9307
9336
  is_override_error: String(errorCodesMap != null),
9308
- session_id: error == null ? void 0 : error._errorHandlerSessionId
9337
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId
9309
9338
  }));
9310
9339
  }
9311
9340
 
@@ -9370,13 +9399,13 @@ function reportGetResolvedErrorBi(errorHandler, params) {
9370
9399
  translations
9371
9400
  } = errorHandler;
9372
9401
  const {
9373
- error
9402
+ errorHandlerState
9374
9403
  } = errorAccessor;
9375
9404
  const {
9376
9405
  consumerResolvedError
9377
9406
  } = errorResolution ?? {};
9378
9407
  biLogger.report(withoutDefaults(getResolvedErrorSrc176Evid101)({
9379
- session_id: error == null ? void 0 : error._errorHandlerSessionId,
9408
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId,
9380
9409
  translated_message: message,
9381
9410
  action_text: action == null ? void 0 : action.text,
9382
9411
  is_consumer_resolved_error: consumerResolvedError != null,
@@ -9387,7 +9416,7 @@ function reportGetResolvedErrorBi(errorHandler, params) {
9387
9416
 
9388
9417
  // ../../node_modules/@wix/error-handler/dist/esm/error-handler/reportShowErrorBi.js
9389
9418
  function reportShowErrorBi(errorHandler, params) {
9390
- var _errorAccessor$error;
9419
+ var _errorAccessor$errorH;
9391
9420
  const {
9392
9421
  message,
9393
9422
  action,
@@ -9398,7 +9427,7 @@ function reportShowErrorBi(errorHandler, params) {
9398
9427
  translations
9399
9428
  } = errorHandler;
9400
9429
  biLogger.report(withoutDefaults(showErrorSrc176Evid102)({
9401
- session_id: (_errorAccessor$error = errorAccessor.error) == null ? void 0 : _errorAccessor$error._errorHandlerSessionId,
9430
+ session_id: (_errorAccessor$errorH = errorAccessor.errorHandlerState) == null ? void 0 : _errorAccessor$errorH.sessionId,
9402
9431
  displayed_message: message,
9403
9432
  displayed_action: action == null ? void 0 : action.text,
9404
9433
  action_was_provided: String((action == null ? void 0 : action.onClick) != null),
@@ -9458,9 +9487,9 @@ function reportErrorRetryBi(errorHandler, params) {
9458
9487
  errorAccessor
9459
9488
  } = params;
9460
9489
  const {
9461
- error
9490
+ errorHandlerState
9462
9491
  } = errorAccessor;
9463
- const sessionId = error == null ? void 0 : error._errorHandlerSessionId;
9492
+ const sessionId = errorHandlerState == null ? void 0 : errorHandlerState.sessionId;
9464
9493
  if (!sessionId) {
9465
9494
  return;
9466
9495
  }
@@ -9473,12 +9502,19 @@ function reportErrorRetryBi(errorHandler, params) {
9473
9502
  var import_defineProperty5 = __toESM(require_defineProperty());
9474
9503
  var ErrorHandlerV2 = class {
9475
9504
  constructor(_errorHandler) {
9505
+ var _this = this;
9476
9506
  (0, import_defineProperty5.default)(this, "errorHandler", void 0);
9477
- (0, import_defineProperty5.default)(this, "withErrorHandler", async (fn, errorCodesMap) => {
9478
- return this.errorHandler.withErrorHandler(fn, {
9507
+ (0, import_defineProperty5.default)(this, "withErrorHandler", async function(fn, errorCodesMap, options) {
9508
+ if (options === void 0) {
9509
+ options = {};
9510
+ }
9511
+ const {
9512
+ errorHandler
9513
+ } = _this;
9514
+ const ops = {
9479
9515
  errorCodesMap: {
9480
9516
  validationError: errorCodesMap,
9481
- statusCodeError: errorCodesMap,
9517
+ statusCodeError: options.statusCodesOverrides,
9482
9518
  applicationError: Object.entries(errorCodesMap).reduce((acc, _ref) => {
9483
9519
  let [key, value] = _ref;
9484
9520
  if (value) {
@@ -9486,9 +9522,23 @@ var ErrorHandlerV2 = class {
9486
9522
  }
9487
9523
  return acc;
9488
9524
  }, {}),
9489
- serverError: errorCodesMap.serverError
9525
+ serverError: options.serverErrorOverride
9490
9526
  }
9491
- });
9527
+ };
9528
+ const response = await errorHandler.withErrorHandler(fn, ops);
9529
+ if (typeof Response !== "undefined" && response instanceof Response) {
9530
+ const errorAccessor = new ErrorAccessor({
9531
+ error: response
9532
+ });
9533
+ errorHandler._setErrorHandlerErrorCodesMap(errorAccessor, ops);
9534
+ const {
9535
+ errorHandlerState
9536
+ } = errorAccessor;
9537
+ if (!response.ok && errorHandlerState) {
9538
+ errorHandlerState.responseData = await response.json().catch(() => null);
9539
+ }
9540
+ }
9541
+ return response;
9492
9542
  });
9493
9543
  (0, import_defineProperty5.default)(this, "getResolvedError", (error) => {
9494
9544
  const {
@@ -9503,10 +9553,10 @@ var ErrorHandlerV2 = class {
9503
9553
  });
9504
9554
  const {
9505
9555
  httpError,
9506
- error: e
9556
+ errorHandlerState
9507
9557
  } = errorAccessor;
9508
9558
  const errorResolution = errorHandler._resolveError(errorAccessor);
9509
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
9559
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
9510
9560
  const message = (resolvedError == null ? void 0 : resolvedError.message) ?? fallbackMessage;
9511
9561
  const action = resolvedError == null ? void 0 : resolvedError.action;
9512
9562
  const requestId = (resolvedError == null ? void 0 : resolvedError.requestId) ?? (httpError == null ? void 0 : httpError.requestId);
@@ -9535,7 +9585,16 @@ var ErrorHandlerV2 = class {
9535
9585
  this.errorHandler.reportRetryAttempt(error);
9536
9586
  });
9537
9587
  (0, import_defineProperty5.default)(this, "handleError", (error, options) => {
9538
- this.errorHandler.handleError(error, options);
9588
+ const {
9589
+ errorHandler
9590
+ } = this;
9591
+ if (typeof Response !== "undefined" && error instanceof Response) {
9592
+ if (!error.ok) {
9593
+ errorHandler.handleError(error, options);
9594
+ }
9595
+ } else {
9596
+ errorHandler.handleError(error, options);
9597
+ }
9539
9598
  });
9540
9599
  this.errorHandler = _errorHandler;
9541
9600
  }
@@ -9594,7 +9653,10 @@ var ErrorHandler = class {
9594
9653
  try {
9595
9654
  return await fn();
9596
9655
  } catch (error) {
9597
- this._setErrorHandlerErrorCodesMap(error, options);
9656
+ const errorAccessor = new ErrorAccessor({
9657
+ error
9658
+ });
9659
+ this._setErrorHandlerErrorCodesMap(errorAccessor, options);
9598
9660
  if (process.env.NODE_ENV === "test" && !this._skipWaitTranslations) {
9599
9661
  await this.commonErrorsMapState.getInitPromise();
9600
9662
  }
@@ -9613,10 +9675,10 @@ var ErrorHandler = class {
9613
9675
  applicationError,
9614
9676
  validationError,
9615
9677
  httpError,
9616
- error: e
9678
+ errorHandlerState
9617
9679
  } = errorAccessor;
9618
9680
  const errorResolution = this._resolveError(errorAccessor);
9619
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
9681
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
9620
9682
  const message = (resolvedError == null ? void 0 : resolvedError.message) ?? fallbackMessage;
9621
9683
  reportGetResolvedErrorBi(this, {
9622
9684
  message,
@@ -9668,10 +9730,10 @@ var ErrorHandler = class {
9668
9730
  error
9669
9731
  });
9670
9732
  const {
9671
- error: e
9733
+ errorHandlerState
9672
9734
  } = errorAccessor;
9673
9735
  this._resolveError(errorAccessor);
9674
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
9736
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
9675
9737
  const showErrorProps = {
9676
9738
  ...resolvedError,
9677
9739
  ...props
@@ -9717,43 +9779,40 @@ var ErrorHandler = class {
9717
9779
  }
9718
9780
  _setErrorHandlerSessionId(errorAccessor) {
9719
9781
  const {
9720
- error
9782
+ errorHandlerState
9721
9783
  } = errorAccessor;
9722
- if (!error) {
9784
+ if (!errorHandlerState) {
9723
9785
  return;
9724
9786
  }
9725
- error._errorHandlerSessionId = v4_default();
9787
+ errorHandlerState.sessionId = v4_default();
9726
9788
  }
9727
9789
  _setErrorHandlerResolvedError(errorAccessor, errorResolution) {
9728
9790
  const {
9729
- error
9791
+ errorHandlerState
9730
9792
  } = errorAccessor;
9731
- if (!error) {
9793
+ if (!errorHandlerState) {
9732
9794
  return;
9733
9795
  }
9734
- error._errorHandlerResolvedError = errorResolution.errorToShow;
9796
+ errorHandlerState.resolvedError = errorResolution.errorToShow;
9735
9797
  }
9736
- _setErrorHandlerErrorCodesMap(error, options) {
9798
+ _setErrorHandlerErrorCodesMap(errorAccessor, options) {
9737
9799
  if (options === void 0) {
9738
9800
  options = {};
9739
9801
  }
9740
9802
  const {
9741
9803
  errorCodesMap
9742
9804
  } = options;
9743
- const errorAccessor = new ErrorAccessor({
9744
- error
9745
- });
9746
9805
  reportErrorResolutionBi(this, {
9747
9806
  errorAccessor,
9748
9807
  errorCodesMap
9749
9808
  });
9750
9809
  const {
9751
- error: e
9810
+ errorHandlerState
9752
9811
  } = errorAccessor;
9753
- if (!e) {
9812
+ if (!errorHandlerState) {
9754
9813
  return;
9755
9814
  }
9756
- e._errorHandlerErrorCodesMap = errorCodesMap;
9815
+ errorHandlerState.errorCodesMap = errorCodesMap;
9757
9816
  }
9758
9817
  _isErrorHandlerDisabled() {
9759
9818
  const {
@@ -9762,14 +9821,14 @@ var ErrorHandler = class {
9762
9821
  return experiments != null && !experiments.enabled("specs.os.EnableErrorHandlerInEditor");
9763
9822
  }
9764
9823
  _resolveError(errorAccessor, options) {
9765
- var _errorAccessor$error;
9824
+ var _errorAccessor$errorH;
9766
9825
  if (options === void 0) {
9767
9826
  options = {};
9768
9827
  }
9769
9828
  if (this._isErrorHandlerDisabled()) {
9770
9829
  return;
9771
9830
  }
9772
- const errorCodesMap = options.errorCodesMap ?? ((_errorAccessor$error = errorAccessor.error) == null ? void 0 : _errorAccessor$error._errorHandlerErrorCodesMap);
9831
+ const errorCodesMap = options.errorCodesMap ?? ((_errorAccessor$errorH = errorAccessor.errorHandlerState) == null ? void 0 : _errorAccessor$errorH.errorCodesMap);
9773
9832
  const errorResolution = createErrorResolution(this, {
9774
9833
  errorAccessor,
9775
9834
  errorCodesMap