ngx-smz-ui 16.2.39 → 16.2.41

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.
@@ -20079,13 +20079,16 @@ __decorate([
20079
20079
  ], ApplicationSelectors, "logInfo", null);
20080
20080
 
20081
20081
  class DiagnosticsService extends BaseApiService {
20082
- constructor(http) {
20082
+ constructor(http, store) {
20083
20083
  super();
20084
20084
  this.http = http;
20085
+ this.store = store;
20085
20086
  this.logSubject = new Subject();
20086
20087
  const config = GlobalInjector.config;
20087
20088
  this.logSubscription = this.logSubject.pipe(throttleTime(config.rbkUtils.diagnostics.throttleTime), // 5 segundos, ajuste conforme necessário
20088
- switchMap(data => this.actualLogCall(data))).subscribe();
20089
+ switchMap(data => this.actualLogCall(data))).subscribe(() => {
20090
+ this.store.dispatch(new ToastActions.Error('O relatório do erro foi enviado ao servidor.', 'Occorreu um erro não tratado.'));
20091
+ });
20089
20092
  }
20090
20093
  log(data) {
20091
20094
  this.logSubject.next(data);
@@ -20136,12 +20139,12 @@ class DiagnosticsService extends BaseApiService {
20136
20139
  return log;
20137
20140
  }
20138
20141
  }
20139
- DiagnosticsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DiagnosticsService, deps: [{ token: i1$5.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
20142
+ DiagnosticsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DiagnosticsService, deps: [{ token: i1$5.HttpClient }, { token: i1$3.Store }], target: i0.ɵɵFactoryTarget.Injectable });
20140
20143
  DiagnosticsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DiagnosticsService, providedIn: 'root' });
20141
20144
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DiagnosticsService, decorators: [{
20142
20145
  type: Injectable,
20143
20146
  args: [{ providedIn: 'root' }]
20144
- }], ctorParameters: function () { return [{ type: i1$5.HttpClient }]; } });
20147
+ }], ctorParameters: function () { return [{ type: i1$5.HttpClient }, { type: i1$3.Store }]; } });
20145
20148
 
20146
20149
  class AuthHandler {
20147
20150
  constructor(authService, store, diagnosticsService) {
@@ -20192,7 +20195,9 @@ class AuthHandler {
20192
20195
  console.log('[AuthHandler:refreshToken] Could not refresh the access token due to API error', error);
20193
20196
  if (GlobalInjector.config.debugMode)
20194
20197
  console.groupEnd();
20195
- this.store.dispatch(new AuthenticationActions.Logout(GlobalInjector.config.rbkUtils.authentication.login.route));
20198
+ setTimeout(() => {
20199
+ this.store.dispatch(new AuthenticationActions.Logout(GlobalInjector.config.rbkUtils.authentication.login.route));
20200
+ }, 500);
20196
20201
  return throwError('Não foi possível revalidar suas credenciais, redirecionando para a tela de login.');
20197
20202
  }));
20198
20203
  }
@@ -20539,10 +20544,16 @@ class CachedRouteReuseStrategy {
20539
20544
  }
20540
20545
 
20541
20546
  class GlobalErrorHandler {
20542
- constructor(injector) {
20543
- this.injector = injector;
20547
+ constructor() {
20548
+ this.logSubject = new Subject();
20549
+ const config = GlobalInjector.config;
20550
+ this.logSubscription = this.logSubject.pipe(throttleTime(config.rbkUtils.diagnostics.throttleTime), switchMap(data => this.actualHandleError(data))).subscribe();
20544
20551
  }
20545
20552
  handleError(error) {
20553
+ this.logSubject.next(error);
20554
+ }
20555
+ actualHandleError(error) {
20556
+ var _a;
20546
20557
  const config = GlobalInjector.config;
20547
20558
  const isDiagnosticsEnabled = config.rbkUtils.diagnostics.url != null;
20548
20559
  if (error.status != null) {
@@ -20553,19 +20564,26 @@ class GlobalErrorHandler {
20553
20564
  }
20554
20565
  else {
20555
20566
  // Erro de Javascript
20556
- if (isDiagnosticsEnabled) {
20557
- const handleJsErrorWithRedirect = config.rbkUtils.errorsConfig.handleJsErrorWithRedirect;
20558
- if (handleJsErrorWithRedirect) {
20559
- this.handleJavascriptError(error);
20560
- }
20561
- else {
20562
- this.submitDiagnostic(error);
20567
+ const javascriptErrorHandlingType = (_a = config.rbkUtils.errorsConfig.javascriptErrors) === null || _a === void 0 ? void 0 : _a.errorHandlingType;
20568
+ if (javascriptErrorHandlingType != null && javascriptErrorHandlingType != 'none') {
20569
+ this.handleJavascriptError(error);
20570
+ }
20571
+ else {
20572
+ if (isDiagnosticsEnabled) {
20573
+ {
20574
+ this.submitDiagnostic(error);
20575
+ }
20563
20576
  }
20564
20577
  }
20565
20578
  }
20566
20579
  console.error('Error caught by Global Error Interceptor: ', error);
20580
+ return of();
20567
20581
  }
20568
20582
  handleJavascriptError(error) {
20583
+ var _a;
20584
+ const config = GlobalInjector.config;
20585
+ const isDiagnosticsEnabled = config.rbkUtils.diagnostics.url != null;
20586
+ const javascriptErrorHandlingType = (_a = config.rbkUtils.errorsConfig.javascriptErrors) === null || _a === void 0 ? void 0 : _a.errorHandlingType;
20569
20587
  const messages = [];
20570
20588
  const message = error.message ? error.message : error.toString();
20571
20589
  if (message.includes(`'localStorage' property from 'Window'`)) {
@@ -20583,12 +20601,25 @@ class GlobalErrorHandler {
20583
20601
  setTimeout(() => {
20584
20602
  store.dispatch(new Navigate(['diagnostics-data-collect', { exceptionMessage: message, stackTrace: error.stack, messages }]));
20585
20603
  }, 0);
20604
+ return;
20586
20605
  }
20587
- else {
20588
- const config = GlobalInjector.config;
20589
- store.dispatch(new Navigate([config.rbkUtils.errorsConfig.page.route]));
20606
+ if (isDiagnosticsEnabled) {
20590
20607
  this.submitDiagnostic(error);
20591
20608
  }
20609
+ switch (javascriptErrorHandlingType) {
20610
+ case 'redirect':
20611
+ if (username != null) {
20612
+ setTimeout(() => {
20613
+ store.dispatch(new Navigate([config.rbkUtils.errorsConfig.page.route]));
20614
+ }, 0);
20615
+ }
20616
+ break;
20617
+ case 'toast':
20618
+ store.dispatch(new ToastActions.Error('Caso o erro persista, entre em contato com o administrador do sistema.', 'Occorreu um erro.'));
20619
+ break;
20620
+ default:
20621
+ break;
20622
+ }
20592
20623
  }
20593
20624
  submitDiagnostic(error) {
20594
20625
  const diagnosticsService = GlobalInjector.instance.get(DiagnosticsService);
@@ -20600,11 +20631,11 @@ class GlobalErrorHandler {
20600
20631
  diagnosticsService.log(diagnosticData);
20601
20632
  }
20602
20633
  }
20603
- GlobalErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
20634
+ GlobalErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GlobalErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
20604
20635
  GlobalErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GlobalErrorHandler });
20605
20636
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: GlobalErrorHandler, decorators: [{
20606
20637
  type: Injectable
20607
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
20638
+ }], ctorParameters: function () { return []; } });
20608
20639
 
20609
20640
  class NgxRbkUtilsModule {
20610
20641
  constructor(router) {
@@ -44181,7 +44212,9 @@ class SmzUiBuilder extends SmzBuilderUtilities {
44181
44212
  navigationHistory: true
44182
44213
  },
44183
44214
  callback: null,
44184
- handleJsErrorWithRedirect: false
44215
+ javascriptErrors: {
44216
+ errorHandlingType: 'none',
44217
+ }
44185
44218
  },
44186
44219
  authorization: {
44187
44220
  navigationMenu: null,
@@ -44232,8 +44265,8 @@ class SmzUiBuilder extends SmzBuilderUtilities {
44232
44265
  this._state.rbkUtils.diagnostics.throttleTime = throttleTime;
44233
44266
  return this.that;
44234
44267
  }
44235
- handleJsErrorWithRedirect() {
44236
- this._state.rbkUtils.errorsConfig.handleJsErrorWithRedirect = true;
44268
+ setJavascriptErrorBehavior(errorHandlingType) {
44269
+ this._state.rbkUtils.errorsConfig.javascriptErrors.errorHandlingType = errorHandlingType;
44237
44270
  return this.that;
44238
44271
  }
44239
44272
  disableUiDefinitions() {