intelica-library-components 1.1.144 → 1.1.146

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,11 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, inject, signal, Pipe, Component, TemplateRef, ContentChild, Input, Directive, EventEmitter, ContentChildren, Output, HostListener, forwardRef, ViewChild, PLATFORM_ID, Inject, DestroyRef, output, input, effect, Optional, Host, InjectionToken } from '@angular/core';
3
- import { getCookie, setCookie, Cookies } from 'typescript-cookie';
3
+ import { getCookie, setCookie } from 'typescript-cookie';
4
4
  import * as i1$4 from '@angular/common/http';
5
5
  import { HttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http';
6
- import { BehaviorSubject, catchError, throwError, from, switchMap, Subject, Subscription, tap as tap$1, of, map, fromEvent, startWith, distinctUntilChanged, shareReplay, firstValueFrom } from 'rxjs';
6
+ import { BehaviorSubject, catchError, throwError, Subject, Subscription, tap as tap$1, of, map, fromEvent, startWith, distinctUntilChanged, shareReplay, firstValueFrom } from 'rxjs';
7
7
  import Swal from 'sweetalert2';
8
- import { Guid } from 'guid-typescript';
9
8
  import { tap, catchError as catchError$1 } from 'rxjs/operators';
10
9
  import * as i1 from '@angular/common';
11
10
  import { DatePipe, CommonModule, isPlatformBrowser, NgClass } from '@angular/common';
@@ -53,6 +52,7 @@ import { SkeletonModule } from 'primeng/skeleton';
53
52
  import * as i1$3 from 'primeng/confirmdialog';
54
53
  import { ConfirmDialogModule } from 'primeng/confirmdialog';
55
54
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
55
+ import { Guid } from 'guid-typescript';
56
56
  import { ActivatedRoute, RouterLink } from '@angular/router';
57
57
  import { Breadcrumb } from 'primeng/breadcrumb';
58
58
  import * as XLSX from 'xlsx';
@@ -514,207 +514,6 @@ const ErrorInterceptor = (req, next) => {
514
514
  }
515
515
  };
516
516
 
517
- class IntelicaSessionService {
518
- configService = inject(ConfigService);
519
- prefix = "itl.session.";
520
- sessionIdKey = "itl.session.__sessionId";
521
- pageRoot = "";
522
- sessionId = null;
523
- constructor() {
524
- this.ensureSessionId();
525
- this.cleanupForeignSessions();
526
- }
527
- /**
528
- * Actualiza el pageRoot actual, es necesario matricularlo en el app.component
529
- */
530
- setPageRoot(pageRoot) {
531
- this.pageRoot = pageRoot;
532
- }
533
- /**
534
- * Retorna la key de usuario con scope si necesitas reutilizarla manualmente.
535
- */
536
- getUserKey(key) {
537
- return this.buildScopedKey(key, "user");
538
- }
539
- ensureSessionId() {
540
- if (this.sessionId)
541
- return this.sessionId;
542
- const stored = localStorage.getItem(this.sessionIdKey);
543
- if (stored) {
544
- this.sessionId = stored;
545
- return stored;
546
- }
547
- const id = this.createGuid();
548
- this.sessionId = id;
549
- localStorage.setItem(this.sessionIdKey, id);
550
- return id;
551
- }
552
- createGuid() {
553
- return Guid.create().toString();
554
- }
555
- buildScopedKey(key, scope = "user-profile") {
556
- const parts = [];
557
- if (this.pageRoot)
558
- parts.push(this.pageRoot);
559
- parts.push(key);
560
- const userId = this.configService.SessionInformation?.businessUserID;
561
- const profileId = this.configService.SessionInformation?.businessUserProfile;
562
- if (scope === "user" || scope === "user-profile") {
563
- if (userId)
564
- parts.push(`user:${userId}`);
565
- }
566
- if (scope === "profile" || scope === "user-profile") {
567
- if (profileId)
568
- parts.push(`profile:${profileId}`);
569
- }
570
- return parts.join("|");
571
- }
572
- set(key, value, scope = "user-profile") {
573
- this.ensureSessionId();
574
- const storageKey = this.buildScopedKey(key, scope);
575
- const envelope = {
576
- sessionId: this.sessionId,
577
- updatedAt: Date.now(),
578
- value,
579
- };
580
- localStorage.setItem(this.prefix + storageKey, JSON.stringify(envelope));
581
- }
582
- get(key, scope = "user-profile") {
583
- const storageKey = this.buildScopedKey(key, scope);
584
- const raw = localStorage.getItem(this.prefix + storageKey);
585
- if (!raw)
586
- return null;
587
- try {
588
- const env = JSON.parse(raw);
589
- if (!this.sessionId || env.sessionId !== this.sessionId)
590
- return null;
591
- return env.value;
592
- }
593
- catch {
594
- return null;
595
- }
596
- }
597
- /**
598
- * Limpia todo lo que haya en localStorage para este servicio (todas las sesiones).
599
- * Úsalo al iniciar sesión/cerrar sesión para evitar acumulación.
600
- */
601
- clearAll() {
602
- Object.keys(localStorage)
603
- .filter(k => k.startsWith(this.prefix))
604
- .forEach(k => localStorage.removeItem(k));
605
- localStorage.removeItem(this.sessionIdKey);
606
- this.sessionId = null;
607
- }
608
- /**
609
- * Limpia los valores de la sesión actual para el pageRoot vigente.
610
- */
611
- clearCurrentPageRoot() {
612
- if (!this.pageRoot)
613
- return;
614
- this.clearPageRoot(this.pageRoot);
615
- }
616
- clearPageRoot(pageRoot) {
617
- const prefix = `${this.prefix}${pageRoot}|`;
618
- Object.keys(localStorage)
619
- .filter(k => k.startsWith(prefix))
620
- .forEach(k => {
621
- const raw = localStorage.getItem(k);
622
- if (!raw)
623
- return;
624
- const env = this.tryParseEnvelope(raw);
625
- if (!env || env.sessionId !== this.sessionId)
626
- return;
627
- localStorage.removeItem(k);
628
- });
629
- }
630
- cleanupForeignSessions() {
631
- if (!this.sessionId)
632
- return;
633
- Object.keys(localStorage)
634
- .filter(k => k.startsWith(this.prefix))
635
- .forEach(k => {
636
- const raw = localStorage.getItem(k);
637
- if (!raw)
638
- return;
639
- const env = this.tryParseEnvelope(raw);
640
- if (!env)
641
- return;
642
- if (env.sessionId !== this.sessionId) {
643
- localStorage.removeItem(k);
644
- }
645
- });
646
- }
647
- tryParseEnvelope(raw) {
648
- try {
649
- return JSON.parse(raw);
650
- }
651
- catch {
652
- return null;
653
- }
654
- }
655
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
656
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, providedIn: "root" });
657
- }
658
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, decorators: [{
659
- type: Injectable,
660
- args: [{
661
- providedIn: "root",
662
- }]
663
- }], ctorParameters: () => [] });
664
-
665
- const RefreshTokenInterceptor = (req, next) => {
666
- const skip = req.headers.has("Skip-Interceptor");
667
- if (skip) {
668
- const cleanReq = req.clone({
669
- headers: req.headers.delete("Skip-Interceptor"),
670
- });
671
- return next(cleanReq);
672
- }
673
- const configService = inject(ConfigService);
674
- const httpClient = inject(HttpClient);
675
- const commonFeatureFlagService = inject(GlobalFeatureFlagService);
676
- const intelicaSessionService = inject(IntelicaSessionService);
677
- const cookieAttributesGeneral = GetCookieAttributes(configService.environment?.environment ?? "");
678
- let _request = req.clone();
679
- let authenticationLocation = `${configService.environment?.authenticationWeb}?callback=${window.location.href}&clientID=${configService.environment?.clientID}`;
680
- let path = `${configService.environment?.authenticationPath ?? ""}/Authenticate/ignore/auth/token/validate`;
681
- var authenticationClientID = configService.environment?.clientID ?? "";
682
- let validateTokenQuery = {
683
- token: getCookie("token") ?? "",
684
- refreshToken: getCookie("refreshToken") ?? "",
685
- ip: req.url,
686
- clientID: configService.environment?.clientID ?? "",
687
- pageRoot: commonFeatureFlagService.GetPageRoot(),
688
- controller: "",
689
- httpVerb: "GET",
690
- businessUserClientGroupID: getCookie("businessUserClientGroupID") ?? "",
691
- access: authenticationClientID == "" ? "" : getCookie(authenticationClientID) ?? "",
692
- };
693
- if (!req.url.includes("ValidateToken") && !req.url.includes("environment.json") && !req.url.includes("auth/token/validate"))
694
- return from(httpClient.post(path, validateTokenQuery)).pipe(switchMap((response) => {
695
- if (response.expired) {
696
- intelicaSessionService.clearAll();
697
- Cookies.remove("token", cookieAttributesGeneral);
698
- Cookies.remove("refreshToken", cookieAttributesGeneral);
699
- Cookies.remove("data", cookieAttributesGeneral);
700
- Cookies.remove("businessUserClientGroupID", cookieAttributesGeneral);
701
- Cookies.remove("defaultClientID", cookieAttributesGeneral);
702
- Cookies.remove("defaultClientGroupID", cookieAttributesGeneral);
703
- Cookies.remove(authenticationClientID, cookieAttributesGeneral);
704
- window.location.href = authenticationLocation;
705
- return next(_request);
706
- }
707
- if (response.unauthorized) {
708
- window.location.href = window.location.origin;
709
- }
710
- if (response.newToken != "")
711
- setCookie("token", response.newToken, cookieAttributesGeneral);
712
- return next(_request);
713
- }));
714
- else
715
- return next(_request);
716
- };
717
-
718
517
  const ResponseHeadersInterceptor = (req, next) => {
719
518
  return next(req).pipe(tap(event => {
720
519
  if (event instanceof HttpResponse) {
@@ -8259,6 +8058,154 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.23", ngImpo
8259
8058
  args: [{ providedIn: "root" }]
8260
8059
  }] });
8261
8060
 
8061
+ class IntelicaSessionService {
8062
+ configService = inject(ConfigService);
8063
+ prefix = "itl.session.";
8064
+ sessionIdKey = "itl.session.__sessionId";
8065
+ pageRoot = "";
8066
+ sessionId = null;
8067
+ constructor() {
8068
+ this.ensureSessionId();
8069
+ this.cleanupForeignSessions();
8070
+ }
8071
+ /**
8072
+ * Actualiza el pageRoot actual, es necesario matricularlo en el app.component
8073
+ */
8074
+ setPageRoot(pageRoot) {
8075
+ this.pageRoot = pageRoot;
8076
+ }
8077
+ /**
8078
+ * Retorna la key de usuario con scope si necesitas reutilizarla manualmente.
8079
+ */
8080
+ getUserKey(key) {
8081
+ return this.buildScopedKey(key, "user");
8082
+ }
8083
+ ensureSessionId() {
8084
+ if (this.sessionId)
8085
+ return this.sessionId;
8086
+ const stored = localStorage.getItem(this.sessionIdKey);
8087
+ if (stored) {
8088
+ this.sessionId = stored;
8089
+ return stored;
8090
+ }
8091
+ const id = this.createGuid();
8092
+ this.sessionId = id;
8093
+ localStorage.setItem(this.sessionIdKey, id);
8094
+ return id;
8095
+ }
8096
+ createGuid() {
8097
+ return Guid.create().toString();
8098
+ }
8099
+ buildScopedKey(key, scope = "user-profile") {
8100
+ const parts = [];
8101
+ if (this.pageRoot)
8102
+ parts.push(this.pageRoot);
8103
+ parts.push(key);
8104
+ const userId = this.configService.SessionInformation?.businessUserID;
8105
+ const profileId = this.configService.SessionInformation?.businessUserProfile;
8106
+ if (scope === "user" || scope === "user-profile") {
8107
+ if (userId)
8108
+ parts.push(`user:${userId}`);
8109
+ }
8110
+ if (scope === "profile" || scope === "user-profile") {
8111
+ if (profileId)
8112
+ parts.push(`profile:${profileId}`);
8113
+ }
8114
+ return parts.join("|");
8115
+ }
8116
+ set(key, value, scope = "user-profile") {
8117
+ this.ensureSessionId();
8118
+ const storageKey = this.buildScopedKey(key, scope);
8119
+ const envelope = {
8120
+ sessionId: this.sessionId,
8121
+ updatedAt: Date.now(),
8122
+ value,
8123
+ };
8124
+ localStorage.setItem(this.prefix + storageKey, JSON.stringify(envelope));
8125
+ }
8126
+ get(key, scope = "user-profile") {
8127
+ const storageKey = this.buildScopedKey(key, scope);
8128
+ const raw = localStorage.getItem(this.prefix + storageKey);
8129
+ if (!raw)
8130
+ return null;
8131
+ try {
8132
+ const env = JSON.parse(raw);
8133
+ if (!this.sessionId || env.sessionId !== this.sessionId)
8134
+ return null;
8135
+ return env.value;
8136
+ }
8137
+ catch {
8138
+ return null;
8139
+ }
8140
+ }
8141
+ /**
8142
+ * Limpia todo lo que haya en localStorage para este servicio (todas las sesiones).
8143
+ * Úsalo al iniciar sesión/cerrar sesión para evitar acumulación.
8144
+ */
8145
+ clearAll() {
8146
+ Object.keys(localStorage)
8147
+ .filter(k => k.startsWith(this.prefix))
8148
+ .forEach(k => localStorage.removeItem(k));
8149
+ localStorage.removeItem(this.sessionIdKey);
8150
+ this.sessionId = null;
8151
+ }
8152
+ /**
8153
+ * Limpia los valores de la sesión actual para el pageRoot vigente.
8154
+ */
8155
+ clearCurrentPageRoot() {
8156
+ if (!this.pageRoot)
8157
+ return;
8158
+ this.clearPageRoot(this.pageRoot);
8159
+ }
8160
+ clearPageRoot(pageRoot) {
8161
+ const prefix = `${this.prefix}${pageRoot}|`;
8162
+ Object.keys(localStorage)
8163
+ .filter(k => k.startsWith(prefix))
8164
+ .forEach(k => {
8165
+ const raw = localStorage.getItem(k);
8166
+ if (!raw)
8167
+ return;
8168
+ const env = this.tryParseEnvelope(raw);
8169
+ if (!env || env.sessionId !== this.sessionId)
8170
+ return;
8171
+ localStorage.removeItem(k);
8172
+ });
8173
+ }
8174
+ cleanupForeignSessions() {
8175
+ if (!this.sessionId)
8176
+ return;
8177
+ Object.keys(localStorage)
8178
+ .filter(k => k.startsWith(this.prefix))
8179
+ .forEach(k => {
8180
+ const raw = localStorage.getItem(k);
8181
+ if (!raw)
8182
+ return;
8183
+ const env = this.tryParseEnvelope(raw);
8184
+ if (!env)
8185
+ return;
8186
+ if (env.sessionId !== this.sessionId) {
8187
+ localStorage.removeItem(k);
8188
+ }
8189
+ });
8190
+ }
8191
+ tryParseEnvelope(raw) {
8192
+ try {
8193
+ return JSON.parse(raw);
8194
+ }
8195
+ catch {
8196
+ return null;
8197
+ }
8198
+ }
8199
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8200
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, providedIn: "root" });
8201
+ }
8202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.23", ngImport: i0, type: IntelicaSessionService, decorators: [{
8203
+ type: Injectable,
8204
+ args: [{
8205
+ providedIn: "root",
8206
+ }]
8207
+ }], ctorParameters: () => [] });
8208
+
8262
8209
  class GlobalMenuService {
8263
8210
  ConfigService = inject(ConfigService);
8264
8211
  _isMenuVisible = signal(true, ...(ngDevMode ? [{ debugName: "_isMenuVisible" }] : []));
@@ -9144,5 +9091,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.23", ngImpo
9144
9091
  * Generated bundle index. Do not edit.
9145
9092
  */
9146
9093
 
9147
- export { ALERT_DEFAULTS, ALERT_ICON_OVERRIDES, ALERT_ICON_PATHS, ALERT_TYPE_CONFIG, ActionDirective, ActionsMenuComponent, AddFavoritesComponent, AlertButtonMode, AlertService, AlertType, BreadCrumbComponent, ButtonSplitComponent, CheckboxFilterDirective, ClientContextSelector, Color, ColumnComponent, ColumnGroupComponent, CompareByField, ConfigService, CookieAttributesGeneral, DATEPICKER_BUTTON_TYPES, DataDirective, DateFilterDirective, DateModeOptions, DatepickerComponent, DynamicInputValidation, EchartComponent, EchartService, ElementService, EmailInputValidation, ErrorInterceptor, FeatureFlagService, FilterChipsComponent, FiltersComponent, FormatAmountPipe, GetCookieAttributes, GlobalFavoriteService, GlobalFeatureFlagService, GlobalMenuService, GlobalTermService, GoogleTaskManagerService, HtmlToExcelService, InitializeConfigService, InputValidation, IntelicaAlertComponent, IntelicaCellCheckboxDirective, IntelicaSessionService, ItemSplitDirective, LanguageService, MatrixColumnComponent, MatrixColumnGroupComponent, MatrixTableComponent, ModalDialogComponent, MultiSelectComponent, NotificationJobService, NotificationOrchestratorService, NotificationService, NotificationSignalRService, OrderConstants, PageInformation, PageRootChildGuard, PaginatorComponent, Patterns, PopoverComponent, ProfileService, RecordPerPageComponent, RefreshTokenInterceptor, RequestCacheService, ResponseHeadersInterceptor, RowResumenComponent, RowResumenTreeComponent, SearchComponent, SelectDetailFilterDirective, SelectFilterDirective, SetsesioninformationComponent, Shared, SharedService, SkeletonChartComponent, SkeletonComponent, SkeletonService, SkeletonTableComponent, SortingComponent, SpinnerComponent, SpinnerService, SweetAlertService, TableComponent, TableFetchComponent, TableSortOrder, TemplateDirective, TemplateMenuComponent, TermPipe, TermService, TextAreaFilterDirective, TextFilterDirective, TextRangeFilterDirective, TitleComponent, TreeColumnComponent, TreeColumnGroupComponent, TreeTableComponent, TruncatePipe, decryptData, encryptData, getColor };
9094
+ export { ALERT_DEFAULTS, ALERT_ICON_OVERRIDES, ALERT_ICON_PATHS, ALERT_TYPE_CONFIG, ActionDirective, ActionsMenuComponent, AddFavoritesComponent, AlertButtonMode, AlertService, AlertType, BreadCrumbComponent, ButtonSplitComponent, CheckboxFilterDirective, ClientContextSelector, Color, ColumnComponent, ColumnGroupComponent, CompareByField, ConfigService, CookieAttributesGeneral, DATEPICKER_BUTTON_TYPES, DataDirective, DateFilterDirective, DateModeOptions, DatepickerComponent, DynamicInputValidation, EchartComponent, EchartService, ElementService, EmailInputValidation, ErrorInterceptor, FeatureFlagService, FilterChipsComponent, FiltersComponent, FormatAmountPipe, GetCookieAttributes, GlobalFavoriteService, GlobalFeatureFlagService, GlobalMenuService, GlobalTermService, GoogleTaskManagerService, HtmlToExcelService, InitializeConfigService, InputValidation, IntelicaAlertComponent, IntelicaCellCheckboxDirective, IntelicaSessionService, ItemSplitDirective, LanguageService, MatrixColumnComponent, MatrixColumnGroupComponent, MatrixTableComponent, ModalDialogComponent, MultiSelectComponent, NotificationJobService, NotificationOrchestratorService, NotificationService, NotificationSignalRService, OrderConstants, PageInformation, PageRootChildGuard, PaginatorComponent, Patterns, PopoverComponent, ProfileService, RecordPerPageComponent, RequestCacheService, ResponseHeadersInterceptor, RowResumenComponent, RowResumenTreeComponent, SearchComponent, SelectDetailFilterDirective, SelectFilterDirective, SetsesioninformationComponent, Shared, SharedService, SkeletonChartComponent, SkeletonComponent, SkeletonService, SkeletonTableComponent, SortingComponent, SpinnerComponent, SpinnerService, SweetAlertService, TableComponent, TableFetchComponent, TableSortOrder, TemplateDirective, TemplateMenuComponent, TermPipe, TermService, TextAreaFilterDirective, TextFilterDirective, TextRangeFilterDirective, TitleComponent, TreeColumnComponent, TreeColumnGroupComponent, TreeTableComponent, TruncatePipe, decryptData, encryptData, getColor };
9148
9095
  //# sourceMappingURL=intelica-library-components.mjs.map