ngx-vector-components 6.57.0 → 6.58.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [6.58.0] (25/11/2026)
4
+
5
+ ### Feat
6
+
7
+ - Added the permission `ENABLED_CHANGE_LOT_CADENCE_MASSIVELY` to `ProfileModuleActionType`, for changing the cadence of several lots at once (`profile.model.ts`)
8
+
9
+ ## [6.57.1] (25/11/2026)
10
+
11
+ ### Fix
12
+
13
+ - `HttpInterceptorProvider`: when the token refresh fails (or there is no refresh token stored), the requests that were waiting in the refresh queue now receive the error too, instead of waiting forever with the screen stuck. The queue subject is replaced before being errored, so the next 401 starts with a clean queue (`http-interceptor.ts`)
14
+ - `HttpInterceptorProvider`: the global spinner now turns off after a 401, whether the refresh succeeds or fails; previously the request stayed in the active list and the spinner never went off (`http-interceptor.ts`)
15
+ - `HttpInterceptorProvider`: each request now releases only its own spinner slot, once. Previously the slot was looked up by the response URL and removed by the request URL; when they differed, `splice(-1, 1)` removed another request's slot and the spinner could turn off too early (`http-interceptor.ts`)
16
+ - Added `http-interceptor.spec.ts` covering the 401 path: queued requests fail with the refresh, and the spinner turns off on refresh success and failure
17
+
3
18
  ## [6.57.0] (23/11/2026)
4
19
 
5
20
  ### Feat
@@ -63,7 +63,7 @@ import { Tabs, TabsModule as TabsModule$1 } from 'primeng/tabs';
63
63
  import { DateTime } from 'luxon';
64
64
  import * as i1$5 from '@angular/common/http';
65
65
  import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http';
66
- import { switchMap, map, tap, debounceTime, catchError, filter, take } from 'rxjs/operators';
66
+ import { switchMap, map, tap, debounceTime, catchError, finalize, filter, take } from 'rxjs/operators';
67
67
  import * as i1$7 from '@angular/platform-browser';
68
68
  import * as i1$8 from 'primeng/drawer';
69
69
  import { DrawerModule as DrawerModule$1 } from 'primeng/drawer';
@@ -1585,6 +1585,7 @@ var ProfileModuleActionType;
1585
1585
  ProfileModuleActionType["EDIT_LOTDAILYCADENCES"] = "Edit LotDailyCadences";
1586
1586
  ProfileModuleActionType["USE_LOTCADENCE_PERCENTAGE"] = "Use LotCadence Percentage";
1587
1587
  ProfileModuleActionType["USE_LOTCADENCE_VEHICLE"] = "Use LotCadence Vehicle";
1588
+ ProfileModuleActionType["ENABLED_CHANGE_LOT_CADENCE_MASSIVELY"] = "Enabled Change LotCadence Massively";
1588
1589
  ProfileModuleActionType["PERMISSION_N2_CHANGE_FREIGHT"] = "Permission N2 Change Freight";
1589
1590
  ProfileModuleActionType["PERMISSION_N3_CHANGE_FREIGHT"] = "Permission N3 Change Freight";
1590
1591
  ProfileModuleActionType["PERMISSION_N4_CHANGE_FREIGHT"] = "Permission N4 Change Freight";
@@ -7699,17 +7700,33 @@ class HttpInterceptorProvider {
7699
7700
  request = this.addClientHeaders(request);
7700
7701
  }
7701
7702
  const noSpinnerHeader = request.headers.get('no-spinner');
7702
- if (!noSpinnerHeader && !request.url.startsWith('/assets/')) {
7703
+ const tracksSpinner = !noSpinnerHeader && !request.url.startsWith('/assets/');
7704
+ const spinnerKey = this.getUrlWithoutParams(request.url);
7705
+ if (tracksSpinner) {
7703
7706
  this.loadingService.loading$.next(true);
7704
- this.activeRequests.push(this.getUrlWithoutParams(request.url));
7705
- }
7707
+ this.activeRequests.push(spinnerKey);
7708
+ }
7709
+ // Cada requisicao solta a sua vaga uma vez so. Depois do refresh o retry passa de novo
7710
+ // pelo `tap`, e sem esta trava a segunda soltura tiraria a vaga de outra requisicao com
7711
+ // a mesma URL -- o que e comum aqui, porque a mesma chamada sai repetida.
7712
+ let released = !tracksSpinner;
7713
+ const release = () => {
7714
+ if (released) {
7715
+ return;
7716
+ }
7717
+ released = true;
7718
+ this.releaseRequest(spinnerKey);
7719
+ };
7706
7720
  return next.handle(request).pipe(catchError((response) => {
7707
7721
  if (response.error?.messages?.length) {
7708
7722
  this.errorMessageService.genericModalErrorMessage$.next(response.error.messages[response.error.messages.length - 1]);
7709
7723
  }
7710
7724
  if (!this.isRefreshTokenRequest(request.url)) {
7711
7725
  if (response.status === 401) {
7712
- return this.handle401Error(request, next);
7726
+ // A volta acontecia aqui, antes da limpeza la embaixo: a requisicao ficava para
7727
+ // sempre no activeRequests e o spinner nunca apagava. O `finalize` solta a vaga
7728
+ // tanto se o retry der certo quanto se a renovacao falhar.
7729
+ return this.handle401Error(request, next).pipe(finalize(release));
7713
7730
  }
7714
7731
  if (response.status === 403) {
7715
7732
  this.errorMessageService.genericModalErrorMessage$.next('Usuário sem privilégios para realizar essa ação');
@@ -7722,21 +7739,11 @@ class HttpInterceptorProvider {
7722
7739
  }
7723
7740
  }
7724
7741
  }
7725
- if (this.activeRequests.includes(this.getUrlWithoutParams(response.url))) {
7726
- this.activeRequests.splice(this.activeRequests.findIndex((item) => item === this.getUrlWithoutParams(request.url)), 1);
7727
- if (!this.activeRequests.length) {
7728
- this.loadingService.loading$.next(false);
7729
- }
7730
- }
7742
+ release();
7731
7743
  return throwError(() => response);
7732
7744
  }), tap((response) => {
7733
7745
  if (response instanceof HttpResponse) {
7734
- if (this.activeRequests.includes(this.getUrlWithoutParams(response.url))) {
7735
- this.activeRequests.splice(this.activeRequests.findIndex((item) => item === this.getUrlWithoutParams(request.url)), 1);
7736
- if (!this.activeRequests.length) {
7737
- this.loadingService.loading$.next(false);
7738
- }
7739
- }
7746
+ release();
7740
7747
  if (Object(response.body).hasOwnProperty('statusCode') &&
7741
7748
  response.body.statusCode === 400 &&
7742
7749
  response.body.messages?.length) {
@@ -7745,6 +7752,41 @@ class HttpInterceptorProvider {
7745
7752
  }
7746
7753
  }));
7747
7754
  }
7755
+ /**
7756
+ * Tira uma vaga da URL do contador do spinner e apaga o spinner na ultima.
7757
+ *
7758
+ * A busca da vaga usa a MESMA chave que entrou na fila. Antes o `includes` olhava a URL
7759
+ * da resposta e o `findIndex` a da requisicao: quando as duas diferiam, o `findIndex`
7760
+ * devolvia -1 e o `splice(-1, 1)` apagava a ultima vaga da lista, que era de outra
7761
+ * requisicao.
7762
+ */
7763
+ releaseRequest(key) {
7764
+ const index = this.activeRequests.indexOf(key);
7765
+ if (index === -1) {
7766
+ return;
7767
+ }
7768
+ this.activeRequests.splice(index, 1);
7769
+ if (!this.activeRequests.length) {
7770
+ this.loadingService.loading$.next(false);
7771
+ }
7772
+ }
7773
+ /**
7774
+ * Derruba quem ficou esperando o refresh terminar.
7775
+ *
7776
+ * Quando o refresh falhava, so quem disparou a renovacao recebia o erro. As requisicoes
7777
+ * que entraram na fila do `refreshTokenSubject` esperavam um token que nunca chegava:
7778
+ * sem `next`, sem `error` e sem `complete`, a inscricao ficava pendurada para sempre e
7779
+ * com ela a tela.
7780
+ *
7781
+ * O subject e trocado antes de receber o erro porque um BehaviorSubject que errou fica
7782
+ * morto: qualquer inscricao nova erra na hora. Assim a fila atual cai e o proximo 401
7783
+ * comeca com uma fila limpa.
7784
+ */
7785
+ failQueuedRequests(error) {
7786
+ const queue = this.refreshTokenSubject;
7787
+ this.refreshTokenSubject = new BehaviorSubject(null);
7788
+ queue.error(error);
7789
+ }
7748
7790
  isRefreshTokenRequest(url) {
7749
7791
  return url.includes('connect/token');
7750
7792
  }
@@ -7842,24 +7884,25 @@ class HttpInterceptorProvider {
7842
7884
  this.isRefreshing = true;
7843
7885
  this.refreshTokenSubject.next(null);
7844
7886
  const refreshToken = this.storageService.getRefreshToken();
7845
- if (refreshToken) {
7846
- return this.authService.getTokenByRefreshToken(refreshToken).pipe(switchMap((token) => {
7847
- this.isRefreshing = false;
7848
- this.refreshTokenSubject.next(this.storageService.getToken());
7849
- return next.handle(this.addTokenIfPresent(request));
7850
- }), catchError((err) => {
7851
- this.isRefreshing = false;
7852
- this.authService.logout();
7853
- return throwError(() => err);
7854
- }));
7855
- }
7856
- else {
7887
+ if (!refreshToken) {
7857
7888
  this.isRefreshing = false;
7889
+ const missingRefreshToken = new Error('Sessao expirada: nao ha refresh token guardado');
7890
+ this.failQueuedRequests(missingRefreshToken);
7858
7891
  this.authService.logout();
7859
- return throwError(() => new Error());
7892
+ return throwError(() => missingRefreshToken);
7860
7893
  }
7894
+ return this.authService.getTokenByRefreshToken(refreshToken).pipe(switchMap(() => {
7895
+ this.isRefreshing = false;
7896
+ this.refreshTokenSubject.next(this.storageService.getToken());
7897
+ return next.handle(this.addTokenIfPresent(request));
7898
+ }), catchError((err) => {
7899
+ this.isRefreshing = false;
7900
+ this.failQueuedRequests(err);
7901
+ this.authService.logout();
7902
+ return throwError(() => err);
7903
+ }));
7861
7904
  }
7862
- return this.refreshTokenSubject.pipe(filter((token) => token !== null), take(1), switchMap((token) => next.handle(this.addTokenIfPresent(request))));
7905
+ return this.refreshTokenSubject.pipe(filter((token) => token !== null), take(1), switchMap(() => next.handle(this.addTokenIfPresent(request))));
7863
7906
  }
7864
7907
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HttpInterceptorProvider, deps: [{ token: StorageService }, { token: ErrorMessageService }, { token: LoadingService }, { token: AuthService }, { token: i2$2.MessageService }, { token: ENVIRONMENT }, { token: APP_NAME, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
7865
7908
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HttpInterceptorProvider }); }