@yuuvis/client-core 2.0.0 → 2.0.2

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,7 +1,7 @@
1
1
  import * as i1 from '@ngx-translate/core';
2
2
  import { TranslateService, TranslateLoader, MissingTranslationHandler, TranslateModule } from '@ngx-translate/core';
3
3
  export { TranslateDirective, TranslateLoader, TranslateModule, TranslatePipe, TranslateService } from '@ngx-translate/core';
4
- import { HttpErrorResponse, HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpEventType, HTTP_INTERCEPTORS } from '@angular/common/http';
4
+ import { HttpErrorResponse, HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpEventType, provideHttpClient, withInterceptors } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
6
6
  import { inject, Injectable, InjectionToken, Inject, Pipe, importProvidersFrom, provideAppInitializer } from '@angular/core';
7
7
  import { tap, finalize, shareReplay, catchError, map, switchMap, first, filter, scan, delay } from 'rxjs/operators';
@@ -4987,64 +4987,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImpo
4987
4987
  /**
4988
4988
  * Prevent app from running into 401 issues related to gateway timeouts.
4989
4989
  */
4990
- class AuthInterceptor {
4991
- /**
4992
- * @ignore
4993
- */
4994
- #userService = inject(UserService);
4995
- #auth = inject(AuthService);
4996
- #backend = inject(BackendService);
4997
- // readonly #oauthService = inject(OAuthService);
4998
- intercept(request, next) {
4999
- return next.handle(request).pipe(tap({
5000
- next: (event) => {
5001
- if (event instanceof HttpResponse) {
5002
- // do stuff with response if you want
5003
- }
5004
- },
5005
- error: (error) => {
5006
- if (error instanceof HttpErrorResponse || error.isHttpErrorResponse) {
5007
- if (error.status === 401) {
5008
- this.#auth.logout();
5009
- this.#userService.logout();
5010
- }
4990
+ function AuthInterceptorFnc(req, next) {
4991
+ const userService = inject(UserService);
4992
+ const auth = inject(AuthService);
4993
+ return next(req).pipe(tap({
4994
+ next: (event) => {
4995
+ if (event instanceof HttpResponse) {
4996
+ // do stuff with response if you want
4997
+ }
4998
+ },
4999
+ error: (error) => {
5000
+ if (error instanceof HttpErrorResponse || error.isHttpErrorResponse) {
5001
+ if (error.status === 401) {
5002
+ auth.logout();
5003
+ userService.logout();
5011
5004
  }
5012
5005
  }
5013
- }));
5014
- }
5015
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: AuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5016
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: AuthInterceptor, providedIn: 'root' }); }
5006
+ }
5007
+ }));
5017
5008
  }
5018
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: AuthInterceptor, decorators: [{
5019
- type: Injectable,
5020
- args: [{
5021
- providedIn: 'root'
5022
- }]
5023
- }] });
5024
5009
 
5025
5010
  /**
5026
5011
  * Http Offline interceptor trys to serving offline content for method/url
5027
5012
  */
5028
- class OfflineInterceptor {
5029
- constructor(connectionService) {
5030
- this.connectionService = connectionService;
5031
- this.offline = false;
5032
- this.connectionService.connection$.subscribe((connectionState) => {
5033
- this.offline = !connectionState.isOnline;
5034
- });
5035
- }
5036
- intercept(request, next) {
5037
- return next.handle(request);
5038
- }
5039
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: OfflineInterceptor, deps: [{ token: ConnectionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
5040
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: OfflineInterceptor, providedIn: 'root' }); }
5013
+ function OfflineInterceptorFnc(req, next) {
5014
+ return next(req);
5041
5015
  }
5042
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: OfflineInterceptor, decorators: [{
5043
- type: Injectable,
5044
- args: [{
5045
- providedIn: 'root'
5046
- }]
5047
- }], ctorParameters: () => [{ type: ConnectionService }] });
5048
5016
 
5049
5017
  /**
5050
5018
  * Handles missing translations
@@ -5185,9 +5153,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImpo
5185
5153
  const provideYuvClientCore = (options = { translations: [] }) => {
5186
5154
  return [
5187
5155
  importProvidersFrom(TranslateModule.forRoot()),
5156
+ provideHttpClient(withInterceptors([AuthInterceptorFnc, OfflineInterceptorFnc])),
5188
5157
  { provide: Logger, useClass: LoggerConsoleService },
5189
- { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
5190
- { provide: HTTP_INTERCEPTORS, useClass: OfflineInterceptor, multi: true },
5191
5158
  { provide: CORE_CONFIG, useClass: CoreConfig, deps: [CUSTOM_CONFIG] },
5192
5159
  provideAppInitializer(init_moduleFnc),
5193
5160
  /**