@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.
@@ -13263,7 +13263,7 @@ var require_common_errors_pt = __commonJS({
13263
13263
  "errorHandler.common-error.permission-denied": "Voc\xEA n\xE3o tem as permiss\xF5es necess\xE1rias. Solicite acesso ao propriet\xE1rio.",
13264
13264
  "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.",
13265
13265
  "errorHandler.common-error.technicalIssue-unmappedError": "Houve um problema t\xE9cnico no nosso sistema. Tente novamente ou atualize.",
13266
- "errorHandler.common-error.unauthenticated": "Voc\xEA est\xE1 desconectado. Fa\xE7a login novamente para continuar.",
13266
+ "errorHandler.common-error.unauthenticated": "Sua conta est\xE1 desconectada. Fa\xE7a login novamente para continuar.",
13267
13267
  "errorHandler.common-error.networkError": "Houve um problema na conex\xE3o com sua rede. Verifique sua conex\xE3o e tente novamente.",
13268
13268
  "errorHandler.common-error.technicalIssue": "Houve um problema t\xE9cnico no nosso sistema. Tente novamente ou atualize.",
13269
13269
  "errorHandler.common-error.captchaRequired": "Para continuar, confirme que voc\xEA \xE9 humano.",
@@ -16743,7 +16743,7 @@ function reportErrorBi(errorHandler, params) {
16743
16743
  errorMessage,
16744
16744
  exceptionMessage,
16745
16745
  httpError,
16746
- error
16746
+ errorHandlerState
16747
16747
  } = errorAccessor;
16748
16748
  const config = httpError == null ? void 0 : httpError.config;
16749
16749
  biLogger.report(withoutDefaults(httpClientErrorSrc176Evid404)({
@@ -16761,11 +16761,11 @@ function reportErrorBi(errorHandler, params) {
16761
16761
  request_id: httpError == null ? void 0 : httpError.requestId,
16762
16762
  hasInternetConnection: onlineManager.onLine,
16763
16763
  pageUrl: webWindow == null || (_webWindow$location = webWindow.location) == null ? void 0 : _webWindow$location.href,
16764
- session_id: error == null ? void 0 : error._errorHandlerSessionId,
16764
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId,
16765
16765
  serverUrl: (config == null ? void 0 : config.url) || (requestOptions == null ? void 0 : requestOptions.url),
16766
16766
  method: (config == null ? void 0 : config.method) || (requestOptions == null ? void 0 : requestOptions.method) || "unknown",
16767
- entity_fqdn: config == null ? void 0 : config.entityFqdn,
16768
- method_fqn: config == null ? void 0 : config.methodFqn,
16767
+ entity_fqdn: (config == null ? void 0 : config.entityFqdn) || (requestOptions == null ? void 0 : requestOptions.entityFqdn),
16768
+ method_fqn: (config == null ? void 0 : config.methodFqn) || (requestOptions == null ? void 0 : requestOptions.methodFqn),
16769
16769
  server_artifactid: config == null ? void 0 : config.artifactId
16770
16770
  }));
16771
16771
  }
@@ -16965,10 +16965,12 @@ function createBiLoggerWithDefaults(params) {
16965
16965
  // ../../node_modules/@wix/error-handler/dist/esm/state/ErrorAccessor.js
16966
16966
  var import_defineProperty2 = __toESM(require_defineProperty());
16967
16967
 
16968
- // ../../node_modules/@wix/error-handler/dist/esm/util/httpErrorDecoders.js
16968
+ // ../../node_modules/@wix/error-handler/dist/esm/util/isObject.js
16969
16969
  function isObject2(thing) {
16970
16970
  return thing != null;
16971
16971
  }
16972
+
16973
+ // ../../node_modules/@wix/error-handler/dist/esm/util/httpErrorDecoders.js
16972
16974
  function isHttpError(err) {
16973
16975
  return isObject2(err) && err.response != null;
16974
16976
  }
@@ -16986,7 +16988,7 @@ function isObject3(thing) {
16986
16988
  function isSdkError(err) {
16987
16989
  return isObject3(err) && err.status != null;
16988
16990
  }
16989
- function toMinimalHttpError(err) {
16991
+ function sdkErrorToMinimalHttpError(err) {
16990
16992
  return {
16991
16993
  response: {
16992
16994
  data: {
@@ -16998,6 +17000,19 @@ function toMinimalHttpError(err) {
16998
17000
  };
16999
17001
  }
17000
17002
 
17003
+ // ../../node_modules/@wix/error-handler/dist/esm/util/responseErrorDecoders.js
17004
+ function responseToMinimalHttpError(err) {
17005
+ var _err$_errorHandlerSta;
17006
+ const data = (_err$_errorHandlerSta = err._errorHandlerState) == null ? void 0 : _err$_errorHandlerSta.responseData;
17007
+ return {
17008
+ response: {
17009
+ data,
17010
+ status: err.status
17011
+ },
17012
+ requestId: err.headers.get("X-Wix-Request-Id")
17013
+ };
17014
+ }
17015
+
17001
17016
  // ../../node_modules/@wix/error-handler/dist/esm/state/ErrorAccessor.js
17002
17017
  var ErrorAccessor = class {
17003
17018
  constructor(params) {
@@ -17008,7 +17023,10 @@ var ErrorAccessor = class {
17008
17023
  this.inputError = params.error;
17009
17024
  }
17010
17025
  get error() {
17011
- return this._error ??= this.inputError instanceof Error ? this.inputError : null;
17026
+ const {
17027
+ inputError
17028
+ } = this;
17029
+ return this._error ??= typeof Response !== "undefined" && inputError instanceof Response ? inputError : inputError instanceof Error ? inputError : null;
17012
17030
  }
17013
17031
  /**
17014
17032
  * The message of the JS error, for example: `Network Error`
@@ -17024,7 +17042,16 @@ var ErrorAccessor = class {
17024
17042
  const {
17025
17043
  inputError
17026
17044
  } = this;
17027
- return this._httpError ??= isHttpError(inputError) ? inputError : isSdkError(inputError) ? toMinimalHttpError(inputError) : null;
17045
+ return this._httpError ??= isHttpError(inputError) ? inputError : typeof Response !== "undefined" && inputError instanceof Response ? responseToMinimalHttpError(inputError) : isSdkError(inputError) ? sdkErrorToMinimalHttpError(inputError) : null;
17046
+ }
17047
+ get errorHandlerState() {
17048
+ const {
17049
+ error
17050
+ } = this;
17051
+ if (!error) {
17052
+ return null;
17053
+ }
17054
+ return error._errorHandlerState ??= {};
17028
17055
  }
17029
17056
  /**
17030
17057
  * errno symbolic name** like `ENETUNREACH`, Not http status code
@@ -17150,16 +17177,18 @@ var TranslationsState = class {
17150
17177
  disableAutoInit: true
17151
17178
  });
17152
17179
  this._initPromise = new Promise(async (resolve) => {
17180
+ var _this$i18n$on, _this$i18n2;
17153
17181
  let failedLoading = false;
17154
17182
  const onFailedLoading = (lng, _ns, err) => {
17183
+ var _this$i18n$off, _this$i18n;
17155
17184
  if (lng !== "en") {
17156
17185
  return;
17157
17186
  }
17158
- this.i18n.off("failedLoading", onFailedLoading);
17187
+ (_this$i18n$off = (_this$i18n = this.i18n).off) == null || _this$i18n$off.call(_this$i18n, "failedLoading", onFailedLoading);
17159
17188
  failedLoading = true;
17160
17189
  resolve(err);
17161
17190
  };
17162
- this.i18n.on("failedLoading", onFailedLoading);
17191
+ (_this$i18n$on = (_this$i18n2 = this.i18n).on) == null || _this$i18n$on.call(_this$i18n2, "failedLoading", onFailedLoading);
17163
17192
  try {
17164
17193
  await this.i18n.init();
17165
17194
  if (failedLoading) {
@@ -17191,7 +17220,7 @@ function reportErrorResolutionBi(errorHandler, params) {
17191
17220
  biLogger
17192
17221
  } = errorHandler;
17193
17222
  const {
17194
- error,
17223
+ errorHandlerState,
17195
17224
  applicationError
17196
17225
  } = errorAccessor;
17197
17226
  const code = applicationError == null ? void 0 : applicationError.code;
@@ -17199,7 +17228,7 @@ function reportErrorResolutionBi(errorHandler, params) {
17199
17228
  biLogger.report(withoutDefaults(httpClientErrorMappingSrc176Evid100)({
17200
17229
  error_opt_out: applicationErrorMapping === false,
17201
17230
  is_override_error: String(errorCodesMap != null),
17202
- session_id: error == null ? void 0 : error._errorHandlerSessionId
17231
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId
17203
17232
  }));
17204
17233
  }
17205
17234
 
@@ -17264,13 +17293,13 @@ function reportGetResolvedErrorBi(errorHandler, params) {
17264
17293
  translations
17265
17294
  } = errorHandler;
17266
17295
  const {
17267
- error
17296
+ errorHandlerState
17268
17297
  } = errorAccessor;
17269
17298
  const {
17270
17299
  consumerResolvedError
17271
17300
  } = errorResolution ?? {};
17272
17301
  biLogger.report(withoutDefaults(getResolvedErrorSrc176Evid101)({
17273
- session_id: error == null ? void 0 : error._errorHandlerSessionId,
17302
+ session_id: errorHandlerState == null ? void 0 : errorHandlerState.sessionId,
17274
17303
  translated_message: message,
17275
17304
  action_text: action == null ? void 0 : action.text,
17276
17305
  is_consumer_resolved_error: consumerResolvedError != null,
@@ -17281,7 +17310,7 @@ function reportGetResolvedErrorBi(errorHandler, params) {
17281
17310
 
17282
17311
  // ../../node_modules/@wix/error-handler/dist/esm/error-handler/reportShowErrorBi.js
17283
17312
  function reportShowErrorBi(errorHandler, params) {
17284
- var _errorAccessor$error;
17313
+ var _errorAccessor$errorH;
17285
17314
  const {
17286
17315
  message,
17287
17316
  action,
@@ -17292,7 +17321,7 @@ function reportShowErrorBi(errorHandler, params) {
17292
17321
  translations
17293
17322
  } = errorHandler;
17294
17323
  biLogger.report(withoutDefaults(showErrorSrc176Evid102)({
17295
- session_id: (_errorAccessor$error = errorAccessor.error) == null ? void 0 : _errorAccessor$error._errorHandlerSessionId,
17324
+ session_id: (_errorAccessor$errorH = errorAccessor.errorHandlerState) == null ? void 0 : _errorAccessor$errorH.sessionId,
17296
17325
  displayed_message: message,
17297
17326
  displayed_action: action == null ? void 0 : action.text,
17298
17327
  action_was_provided: String((action == null ? void 0 : action.onClick) != null),
@@ -17352,9 +17381,9 @@ function reportErrorRetryBi(errorHandler, params) {
17352
17381
  errorAccessor
17353
17382
  } = params;
17354
17383
  const {
17355
- error
17384
+ errorHandlerState
17356
17385
  } = errorAccessor;
17357
- const sessionId = error == null ? void 0 : error._errorHandlerSessionId;
17386
+ const sessionId = errorHandlerState == null ? void 0 : errorHandlerState.sessionId;
17358
17387
  if (!sessionId) {
17359
17388
  return;
17360
17389
  }
@@ -17367,12 +17396,19 @@ function reportErrorRetryBi(errorHandler, params) {
17367
17396
  var import_defineProperty5 = __toESM(require_defineProperty());
17368
17397
  var ErrorHandlerV2 = class {
17369
17398
  constructor(_errorHandler) {
17399
+ var _this = this;
17370
17400
  (0, import_defineProperty5.default)(this, "errorHandler", void 0);
17371
- (0, import_defineProperty5.default)(this, "withErrorHandler", async (fn, errorCodesMap) => {
17372
- return this.errorHandler.withErrorHandler(fn, {
17401
+ (0, import_defineProperty5.default)(this, "withErrorHandler", async function(fn, errorCodesMap, options) {
17402
+ if (options === void 0) {
17403
+ options = {};
17404
+ }
17405
+ const {
17406
+ errorHandler
17407
+ } = _this;
17408
+ const ops = {
17373
17409
  errorCodesMap: {
17374
17410
  validationError: errorCodesMap,
17375
- statusCodeError: errorCodesMap,
17411
+ statusCodeError: options.statusCodesOverrides,
17376
17412
  applicationError: Object.entries(errorCodesMap).reduce((acc, _ref) => {
17377
17413
  let [key, value] = _ref;
17378
17414
  if (value) {
@@ -17380,9 +17416,23 @@ var ErrorHandlerV2 = class {
17380
17416
  }
17381
17417
  return acc;
17382
17418
  }, {}),
17383
- serverError: errorCodesMap.serverError
17419
+ serverError: options.serverErrorOverride
17384
17420
  }
17385
- });
17421
+ };
17422
+ const response = await errorHandler.withErrorHandler(fn, ops);
17423
+ if (typeof Response !== "undefined" && response instanceof Response) {
17424
+ const errorAccessor = new ErrorAccessor({
17425
+ error: response
17426
+ });
17427
+ errorHandler._setErrorHandlerErrorCodesMap(errorAccessor, ops);
17428
+ const {
17429
+ errorHandlerState
17430
+ } = errorAccessor;
17431
+ if (!response.ok && errorHandlerState) {
17432
+ errorHandlerState.responseData = await response.json().catch(() => null);
17433
+ }
17434
+ }
17435
+ return response;
17386
17436
  });
17387
17437
  (0, import_defineProperty5.default)(this, "getResolvedError", (error) => {
17388
17438
  const {
@@ -17397,10 +17447,10 @@ var ErrorHandlerV2 = class {
17397
17447
  });
17398
17448
  const {
17399
17449
  httpError,
17400
- error: e
17450
+ errorHandlerState
17401
17451
  } = errorAccessor;
17402
17452
  const errorResolution = errorHandler._resolveError(errorAccessor);
17403
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
17453
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
17404
17454
  const message = (resolvedError == null ? void 0 : resolvedError.message) ?? fallbackMessage;
17405
17455
  const action = resolvedError == null ? void 0 : resolvedError.action;
17406
17456
  const requestId = (resolvedError == null ? void 0 : resolvedError.requestId) ?? (httpError == null ? void 0 : httpError.requestId);
@@ -17429,7 +17479,16 @@ var ErrorHandlerV2 = class {
17429
17479
  this.errorHandler.reportRetryAttempt(error);
17430
17480
  });
17431
17481
  (0, import_defineProperty5.default)(this, "handleError", (error, options) => {
17432
- this.errorHandler.handleError(error, options);
17482
+ const {
17483
+ errorHandler
17484
+ } = this;
17485
+ if (typeof Response !== "undefined" && error instanceof Response) {
17486
+ if (!error.ok) {
17487
+ errorHandler.handleError(error, options);
17488
+ }
17489
+ } else {
17490
+ errorHandler.handleError(error, options);
17491
+ }
17433
17492
  });
17434
17493
  this.errorHandler = _errorHandler;
17435
17494
  }
@@ -17488,7 +17547,10 @@ var ErrorHandler = class {
17488
17547
  try {
17489
17548
  return await fn();
17490
17549
  } catch (error) {
17491
- this._setErrorHandlerErrorCodesMap(error, options);
17550
+ const errorAccessor = new ErrorAccessor({
17551
+ error
17552
+ });
17553
+ this._setErrorHandlerErrorCodesMap(errorAccessor, options);
17492
17554
  if (process.env.NODE_ENV === "test" && !this._skipWaitTranslations) {
17493
17555
  await this.commonErrorsMapState.getInitPromise();
17494
17556
  }
@@ -17507,10 +17569,10 @@ var ErrorHandler = class {
17507
17569
  applicationError,
17508
17570
  validationError,
17509
17571
  httpError,
17510
- error: e
17572
+ errorHandlerState
17511
17573
  } = errorAccessor;
17512
17574
  const errorResolution = this._resolveError(errorAccessor);
17513
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
17575
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
17514
17576
  const message = (resolvedError == null ? void 0 : resolvedError.message) ?? fallbackMessage;
17515
17577
  reportGetResolvedErrorBi(this, {
17516
17578
  message,
@@ -17562,10 +17624,10 @@ var ErrorHandler = class {
17562
17624
  error
17563
17625
  });
17564
17626
  const {
17565
- error: e
17627
+ errorHandlerState
17566
17628
  } = errorAccessor;
17567
17629
  this._resolveError(errorAccessor);
17568
- const resolvedError = e == null ? void 0 : e._errorHandlerResolvedError;
17630
+ const resolvedError = errorHandlerState == null ? void 0 : errorHandlerState.resolvedError;
17569
17631
  const showErrorProps = {
17570
17632
  ...resolvedError,
17571
17633
  ...props
@@ -17611,43 +17673,40 @@ var ErrorHandler = class {
17611
17673
  }
17612
17674
  _setErrorHandlerSessionId(errorAccessor) {
17613
17675
  const {
17614
- error
17676
+ errorHandlerState
17615
17677
  } = errorAccessor;
17616
- if (!error) {
17678
+ if (!errorHandlerState) {
17617
17679
  return;
17618
17680
  }
17619
- error._errorHandlerSessionId = v4_default();
17681
+ errorHandlerState.sessionId = v4_default();
17620
17682
  }
17621
17683
  _setErrorHandlerResolvedError(errorAccessor, errorResolution) {
17622
17684
  const {
17623
- error
17685
+ errorHandlerState
17624
17686
  } = errorAccessor;
17625
- if (!error) {
17687
+ if (!errorHandlerState) {
17626
17688
  return;
17627
17689
  }
17628
- error._errorHandlerResolvedError = errorResolution.errorToShow;
17690
+ errorHandlerState.resolvedError = errorResolution.errorToShow;
17629
17691
  }
17630
- _setErrorHandlerErrorCodesMap(error, options) {
17692
+ _setErrorHandlerErrorCodesMap(errorAccessor, options) {
17631
17693
  if (options === void 0) {
17632
17694
  options = {};
17633
17695
  }
17634
17696
  const {
17635
17697
  errorCodesMap
17636
17698
  } = options;
17637
- const errorAccessor = new ErrorAccessor({
17638
- error
17639
- });
17640
17699
  reportErrorResolutionBi(this, {
17641
17700
  errorAccessor,
17642
17701
  errorCodesMap
17643
17702
  });
17644
17703
  const {
17645
- error: e
17704
+ errorHandlerState
17646
17705
  } = errorAccessor;
17647
- if (!e) {
17706
+ if (!errorHandlerState) {
17648
17707
  return;
17649
17708
  }
17650
- e._errorHandlerErrorCodesMap = errorCodesMap;
17709
+ errorHandlerState.errorCodesMap = errorCodesMap;
17651
17710
  }
17652
17711
  _isErrorHandlerDisabled() {
17653
17712
  const {
@@ -17656,14 +17715,14 @@ var ErrorHandler = class {
17656
17715
  return experiments != null && !experiments.enabled("specs.os.EnableErrorHandlerInEditor");
17657
17716
  }
17658
17717
  _resolveError(errorAccessor, options) {
17659
- var _errorAccessor$error;
17718
+ var _errorAccessor$errorH;
17660
17719
  if (options === void 0) {
17661
17720
  options = {};
17662
17721
  }
17663
17722
  if (this._isErrorHandlerDisabled()) {
17664
17723
  return;
17665
17724
  }
17666
- const errorCodesMap = options.errorCodesMap ?? ((_errorAccessor$error = errorAccessor.error) == null ? void 0 : _errorAccessor$error._errorHandlerErrorCodesMap);
17725
+ const errorCodesMap = options.errorCodesMap ?? ((_errorAccessor$errorH = errorAccessor.errorHandlerState) == null ? void 0 : _errorAccessor$errorH.errorCodesMap);
17667
17726
  const errorResolution = createErrorResolution(this, {
17668
17727
  errorAccessor,
17669
17728
  errorCodesMap