@arsedizioni/ars-utils 22.0.48 → 22.0.50
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/fesm2022/arsedizioni-ars-utils-evolution.common.mjs +384 -193
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-support.common.mjs +157 -32
- package/fesm2022/arsedizioni-ars-utils-support.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-support.ui.mjs +5 -5
- package/fesm2022/arsedizioni-ars-utils-support.ui.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-ui.mjs +17 -4
- package/fesm2022/arsedizioni-ars-utils-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/arsedizioni-ars-utils-clipper.ui.d.ts +1 -1
- package/types/arsedizioni-ars-utils-evolution.common.d.ts +142 -65
- package/types/arsedizioni-ars-utils-support.common.d.ts +58 -11
- package/types/arsedizioni-ars-utils-ui.d.ts +15 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject,
|
|
3
|
+
import { inject, signal, Service, DestroyRef, Injectable } from '@angular/core';
|
|
4
4
|
import { BroadcastService, SystemUtils } from '@arsedizioni/ars-utils/core';
|
|
5
5
|
import { EMPTY, throwError, of, catchError as catchError$1 } from 'rxjs';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -484,16 +484,20 @@ class EvolutionComplianceContextInfo {
|
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
487
|
+
* @internal
|
|
488
|
+
* Private state container for the Evolution session.
|
|
489
|
+
*
|
|
490
|
+
* Intentionally NOT exported from the barrel: it must never be injected by
|
|
491
|
+
* application code. Its state and pure mutations are re-published through
|
|
492
|
+
* {@link EvolutionService} (and partly {@link LoginService}). The feature
|
|
493
|
+
* services inject it ONLY to read {@link serviceUri}.
|
|
494
|
+
*
|
|
495
|
+
* Owns the back-end URI, feature flags, persisted login info and the session
|
|
496
|
+
* signals. No HTTP, no auth orchestration.
|
|
490
497
|
*/
|
|
491
|
-
class
|
|
498
|
+
class CoreService {
|
|
492
499
|
constructor() {
|
|
493
|
-
this.httpClient = inject(HttpClient);
|
|
494
500
|
this.broadcastService = inject(BroadcastService);
|
|
495
|
-
this.destroyRef = inject(DestroyRef);
|
|
496
|
-
this.broadcastInitialized = false;
|
|
497
501
|
this._flags = EvolutionServiceFlags.None;
|
|
498
502
|
this._loggedIn = signal(false, /* @ts-ignore */
|
|
499
503
|
...(ngDevMode ? [{ debugName: "_loggedIn" }] : /* istanbul ignore next */ []));
|
|
@@ -503,17 +507,40 @@ class EvolutionService {
|
|
|
503
507
|
this.loggingIn = signal(false, /* @ts-ignore */
|
|
504
508
|
...(ngDevMode ? [{ debugName: "loggingIn" }] : /* istanbul ignore next */ []));
|
|
505
509
|
}
|
|
506
|
-
/**
|
|
510
|
+
/**
|
|
511
|
+
* Gets the base URI of the Evolution back-end service.
|
|
512
|
+
* @returns The configured service URI, or undefined before initialize().
|
|
513
|
+
*/
|
|
507
514
|
get serviceUri() {
|
|
508
515
|
return this._serviceUri;
|
|
509
516
|
}
|
|
510
|
-
/**
|
|
517
|
+
/**
|
|
518
|
+
* Sets the base URI of the Evolution back-end service.
|
|
519
|
+
* @param uri - The base URL.
|
|
520
|
+
* @returns void
|
|
521
|
+
*/
|
|
522
|
+
setServiceUri(uri) {
|
|
523
|
+
this._serviceUri = uri;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Gets the active feature flags.
|
|
527
|
+
* @returns The active {@link EvolutionServiceFlags} bitmask.
|
|
528
|
+
*/
|
|
511
529
|
get flags() {
|
|
512
530
|
return this._flags;
|
|
513
531
|
}
|
|
514
532
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
533
|
+
* Sets the active feature flags.
|
|
534
|
+
* @param flags - The flags bitmask to apply.
|
|
535
|
+
* @returns void
|
|
536
|
+
*/
|
|
537
|
+
setFlags(flags) {
|
|
538
|
+
this._flags = flags;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Gets the current login info, hydrating it from `localStorage` on first
|
|
542
|
+
* access when no in-memory value is available.
|
|
543
|
+
* @returns The current {@link EvolutionLoginInfo}, or undefined.
|
|
517
544
|
*/
|
|
518
545
|
get loginInfo() {
|
|
519
546
|
if (!this._loginInfo) {
|
|
@@ -527,11 +554,263 @@ class EvolutionService {
|
|
|
527
554
|
}
|
|
528
555
|
return this._loginInfo;
|
|
529
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Sets the logged-in state.
|
|
559
|
+
* @param value - The new logged-in value.
|
|
560
|
+
* @returns void
|
|
561
|
+
*/
|
|
562
|
+
setLoggedIn(value) {
|
|
563
|
+
this._loggedIn.set(value);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Records the OAuth provider / remember flag on the login info, creating the
|
|
567
|
+
* container if needed.
|
|
568
|
+
* @param oauth - The OAuth provider type, if any.
|
|
569
|
+
* @param remember - Whether the session should persist across restarts.
|
|
570
|
+
* @returns void
|
|
571
|
+
*/
|
|
572
|
+
setAuthMeta(oauth, remember) {
|
|
573
|
+
if (!this._loginInfo) {
|
|
574
|
+
this._loginInfo = { context: undefined };
|
|
575
|
+
}
|
|
576
|
+
this._loginInfo.oauth = oauth;
|
|
577
|
+
this._loginInfo.remember = remember;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Persists the current login info to `localStorage`.
|
|
581
|
+
* @returns void
|
|
582
|
+
*/
|
|
583
|
+
storeContext() {
|
|
584
|
+
localStorage.setItem('evolution_context', JSON.stringify(this._loginInfo));
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Merges a login result into the stored login info and persists it.
|
|
588
|
+
* @param result - The login result returned by the login endpoint.
|
|
589
|
+
* @returns void
|
|
590
|
+
*/
|
|
591
|
+
updateContext(result) {
|
|
592
|
+
if (!this._loginInfo) {
|
|
593
|
+
this._loginInfo = { context: undefined };
|
|
594
|
+
}
|
|
595
|
+
this._loginInfo.context = result.context;
|
|
596
|
+
this.storeContext();
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Resets the in-memory login state and broadcasts a logout-completed event.
|
|
600
|
+
* Does NOT touch storage; call {@link clear} for a full cleanup.
|
|
601
|
+
* @returns void
|
|
602
|
+
*/
|
|
603
|
+
reset() {
|
|
604
|
+
this._loginInfo = undefined;
|
|
605
|
+
this._loggedIn.set(false);
|
|
606
|
+
this.broadcastService.sendMessage(EvolutionMessages.LOGOUT_COMPLETED);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Removes Evolution session data from `sessionStorage` and calls {@link reset}.
|
|
610
|
+
* @param clearOAuthToken - When true, also removes the stored OAuth2 access token.
|
|
611
|
+
* @returns void
|
|
612
|
+
*/
|
|
613
|
+
clear(clearOAuthToken = false) {
|
|
614
|
+
sessionStorage.removeItem('evolution_auth');
|
|
615
|
+
sessionStorage.removeItem('evolution_refresh');
|
|
616
|
+
sessionStorage.removeItem('evolution_oauth');
|
|
617
|
+
if (clearOAuthToken) {
|
|
618
|
+
sessionStorage.removeItem('evolution_oauth_token');
|
|
619
|
+
}
|
|
620
|
+
this.reset();
|
|
621
|
+
}
|
|
622
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CoreService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
623
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: CoreService }); }
|
|
624
|
+
}
|
|
625
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: CoreService, decorators: [{
|
|
626
|
+
type: Service
|
|
627
|
+
}] });
|
|
628
|
+
|
|
629
|
+
/** Account endpoints (the `Links` section): user links management. */
|
|
630
|
+
class AccountService {
|
|
631
|
+
constructor() {
|
|
632
|
+
this.httpClient = inject(HttpClient);
|
|
633
|
+
this.core = inject(CoreService);
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Persists a user link on the server.
|
|
637
|
+
* @param item - The user link to save.
|
|
638
|
+
* @returns An observable that emits `ApiResult<boolean>`.
|
|
639
|
+
*/
|
|
640
|
+
saveLink(item) {
|
|
641
|
+
return this.httpClient.post(this.core.serviceUri + '/account/links/save', item);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Deletes a user link from the server.
|
|
645
|
+
* @param item - The user link to delete.
|
|
646
|
+
* @returns An observable that emits `ApiResult<boolean>`.
|
|
647
|
+
*/
|
|
648
|
+
deleteLink(item) {
|
|
649
|
+
return this.httpClient.post(this.core.serviceUri + '/account/links/delete', item);
|
|
650
|
+
}
|
|
651
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AccountService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
652
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: AccountService }); }
|
|
653
|
+
}
|
|
654
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AccountService, decorators: [{
|
|
655
|
+
type: Service
|
|
656
|
+
}] });
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Compliance endpoints: taxonomy & groups, context, registers, laws and
|
|
660
|
+
* activities (the `Context` / `Registers` / `Laws` / `Activities` sections,
|
|
661
|
+
* plus the general taxonomy/groups lookups). Pure HTTP; injects the private
|
|
662
|
+
* {@link CoreService} only to read the back-end URI.
|
|
663
|
+
*/
|
|
664
|
+
class ComplianceService {
|
|
665
|
+
constructor() {
|
|
666
|
+
this.httpClient = inject(HttpClient);
|
|
667
|
+
this.core = inject(CoreService);
|
|
668
|
+
}
|
|
669
|
+
// ── Taxonomy & groups ───────────────────────────────────────────────────────
|
|
670
|
+
/**
|
|
671
|
+
* Retrieves the taxonomy tree from the back end.
|
|
672
|
+
* @returns An observable that emits `ApiResult<FolderTree>`.
|
|
673
|
+
*/
|
|
674
|
+
getTaxonomy() {
|
|
675
|
+
return this.httpClient.get(this.core.serviceUri + '/taxonomy');
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Retrieves the compliance groups for a register.
|
|
679
|
+
* @param group - Group index to retrieve (default: `1`).
|
|
680
|
+
* @param register - Optional register ID to scope the query.
|
|
681
|
+
* @returns An observable that emits `ApiResult<string[]>`.
|
|
682
|
+
*/
|
|
683
|
+
getGroups(group = 1, register) {
|
|
684
|
+
const path = register
|
|
685
|
+
? `/compliance/groups/?group=${group}®ister=${register}`
|
|
686
|
+
: `/compliance/groups/?group=${group}`;
|
|
687
|
+
return this.httpClient.get(this.core.serviceUri + path);
|
|
688
|
+
}
|
|
689
|
+
// ── Context ──────────────────────────────────────────────────────────────────
|
|
690
|
+
/**
|
|
691
|
+
* Sends a context-change request to the back end.
|
|
692
|
+
* @param params - The context model describing the desired switch.
|
|
693
|
+
* @returns An observable that emits `ApiResult<EvolutionChangeContextResultModel>`.
|
|
694
|
+
*/
|
|
695
|
+
changeContext(params) {
|
|
696
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/context', params);
|
|
697
|
+
}
|
|
698
|
+
// ── Registers ────────────────────────────────────────────────────────────────
|
|
699
|
+
/**
|
|
700
|
+
* Retrieves a single compliance register by ID.
|
|
701
|
+
* @param id - The register ID.
|
|
702
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceRegister>`.
|
|
703
|
+
*/
|
|
704
|
+
getRegister(id) {
|
|
705
|
+
return this.httpClient.get(this.core.serviceUri + '/compliance/registers/' + id);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Collects register profiles matching the given query parameters.
|
|
709
|
+
* @param params - Query parameters defining the filter criteria.
|
|
710
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceRegisterProfile[]>`.
|
|
711
|
+
*/
|
|
712
|
+
collectRegisterProfiles(params) {
|
|
713
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/registers/profiles/collect', params);
|
|
714
|
+
}
|
|
715
|
+
// ── Laws ─────────────────────────────────────────────────────────────────────
|
|
716
|
+
/**
|
|
717
|
+
* Adds one or more compliance laws.
|
|
718
|
+
* @param params - The laws to add.
|
|
719
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceLaw[]>`.
|
|
720
|
+
*/
|
|
721
|
+
addLaws(params) {
|
|
722
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/laws/add', params);
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Exports compliance laws in the format expected by the server.
|
|
726
|
+
* @param params - Export parameters (model shape is server-defined).
|
|
727
|
+
* @returns An observable that emits the binary blob response.
|
|
728
|
+
*/
|
|
729
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
730
|
+
exportLaws(params) {
|
|
731
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/laws/export', params, { responseType: 'blob' });
|
|
732
|
+
}
|
|
733
|
+
// ── Activities ─────────────────────────────────────────────────────────────────
|
|
734
|
+
/**
|
|
735
|
+
* Adds one or more compliance activities.
|
|
736
|
+
* @param params - The activities to add.
|
|
737
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceActivity>`.
|
|
738
|
+
*/
|
|
739
|
+
addActivities(params) {
|
|
740
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/activities/add', params);
|
|
741
|
+
}
|
|
742
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
743
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService }); }
|
|
744
|
+
}
|
|
745
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService, decorators: [{
|
|
746
|
+
type: Service
|
|
747
|
+
}] });
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Authentication service for the Evolution module: login / logout / MFA,
|
|
751
|
+
* session bootstrap, connectivity ping and the broadcast handler.
|
|
752
|
+
* All session state lives in the private {@link CoreService}; this service
|
|
753
|
+
* orchestrates the HTTP flows and re-publishes the parts of core that
|
|
754
|
+
* consumers need.
|
|
755
|
+
*/
|
|
756
|
+
class LoginService {
|
|
757
|
+
constructor() {
|
|
758
|
+
this.httpClient = inject(HttpClient);
|
|
759
|
+
this.broadcastService = inject(BroadcastService);
|
|
760
|
+
this.destroyRef = inject(DestroyRef);
|
|
761
|
+
this.core = inject(CoreService);
|
|
762
|
+
this.broadcastInitialized = false;
|
|
763
|
+
}
|
|
764
|
+
// ── Re-published core state (CoreService stays private) ─────────────────────
|
|
765
|
+
/**
|
|
766
|
+
* Gets the base URI of the Evolution back-end service.
|
|
767
|
+
* @returns The configured service URI, or undefined before initialize().
|
|
768
|
+
*/
|
|
769
|
+
get serviceUri() { return this.core.serviceUri; }
|
|
770
|
+
/**
|
|
771
|
+
* Gets the active feature flags.
|
|
772
|
+
* @returns The active {@link EvolutionServiceFlags} bitmask.
|
|
773
|
+
*/
|
|
774
|
+
get flags() { return this.core.flags; }
|
|
775
|
+
/**
|
|
776
|
+
* Gets the current login info.
|
|
777
|
+
* @returns The current {@link EvolutionLoginInfo}, or undefined.
|
|
778
|
+
*/
|
|
779
|
+
get loginInfo() { return this.core.loginInfo; }
|
|
780
|
+
/** `true` when the user has an active (non-temporary) session. */
|
|
781
|
+
get loggedIn() { return this.core.loggedIn; }
|
|
782
|
+
/** `true` while a login request is in flight. */
|
|
783
|
+
get loggingIn() { return this.core.loggingIn; }
|
|
784
|
+
// ── Re-published core operations ────────────────────────────────────────────
|
|
785
|
+
/**
|
|
786
|
+
* Persists the current login info to `localStorage` (delegates to core).
|
|
787
|
+
* @returns void
|
|
788
|
+
*/
|
|
789
|
+
storeContext() { this.core.storeContext(); }
|
|
790
|
+
/**
|
|
791
|
+
* Merges a login result into the stored login info (delegates to core).
|
|
792
|
+
* @param result - The login result returned by the login endpoint.
|
|
793
|
+
* @returns void
|
|
794
|
+
*/
|
|
795
|
+
updateContext(result) { this.core.updateContext(result); }
|
|
796
|
+
/**
|
|
797
|
+
* Resets the in-memory login state and broadcasts logout-completed (delegates to core).
|
|
798
|
+
* @returns void
|
|
799
|
+
*/
|
|
800
|
+
reset() { this.core.reset(); }
|
|
801
|
+
/**
|
|
802
|
+
* Removes Evolution session data and resets the state (delegates to core).
|
|
803
|
+
* @param clearOAuthToken - When true, also removes the stored OAuth2 access token.
|
|
804
|
+
* @returns void
|
|
805
|
+
*/
|
|
806
|
+
clear(clearOAuthToken = false) { this.core.clear(clearOAuthToken); }
|
|
807
|
+
// ── Lifecycle ───────────────────────────────────────────────────────────────
|
|
530
808
|
/**
|
|
531
809
|
* Initialises the service with the back-end URI and optional feature flags.
|
|
532
810
|
* Must be called once during application bootstrap before any other method.
|
|
533
|
-
* @param serviceUri - Base URL of the Evolution service
|
|
534
|
-
* @param flags
|
|
811
|
+
* @param serviceUri - Base URL of the Evolution service.
|
|
812
|
+
* @param flags - Bitmask of `EvolutionServiceFlags` (default: `None`).
|
|
813
|
+
* @returns void
|
|
535
814
|
*/
|
|
536
815
|
initialize(serviceUri, flags = EvolutionServiceFlags.None) {
|
|
537
816
|
// Create a unique per-tab client ID if not already set
|
|
@@ -540,8 +819,8 @@ class EvolutionService {
|
|
|
540
819
|
? 'embedded'
|
|
541
820
|
: SystemUtils.generateUUID());
|
|
542
821
|
}
|
|
543
|
-
this.
|
|
544
|
-
this.
|
|
822
|
+
this.core.setServiceUri(serviceUri);
|
|
823
|
+
this.core.setFlags(flags);
|
|
545
824
|
// Subscribe to broadcast messages (only once)
|
|
546
825
|
if (!this.broadcastInitialized) {
|
|
547
826
|
this.broadcastInitialized = true;
|
|
@@ -553,14 +832,15 @@ class EvolutionService {
|
|
|
553
832
|
});
|
|
554
833
|
}
|
|
555
834
|
// If a session is already active (e.g. after an F5 page refresh), notify consumers
|
|
556
|
-
if (this.loggedIn()) {
|
|
557
|
-
this.loggingIn.set(false);
|
|
835
|
+
if (this.core.loggedIn()) {
|
|
836
|
+
this.core.loggingIn.set(false);
|
|
558
837
|
this.broadcastService.sendMessage(EvolutionMessages.LOGIN_COMPLETED);
|
|
559
838
|
}
|
|
560
839
|
}
|
|
561
840
|
/**
|
|
562
841
|
* Dispatches an incoming broadcast message to the appropriate handler.
|
|
563
842
|
* @param message - The message received from the broadcast channel.
|
|
843
|
+
* @returns void
|
|
564
844
|
*/
|
|
565
845
|
handleBroadcastMessage(message) {
|
|
566
846
|
if (message.id === EvolutionMessages.LOGIN_CHANGED) {
|
|
@@ -568,13 +848,13 @@ class EvolutionService {
|
|
|
568
848
|
this.login(undefined, undefined, true, data?.['oauth'], data?.['oauthAccessToken']).subscribe({
|
|
569
849
|
next: r => {
|
|
570
850
|
if (!r.success) {
|
|
571
|
-
if ((this.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
851
|
+
if ((this.core.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
572
852
|
this.broadcastService.sendMessage(EvolutionMessages.ERROR, { message: "Le credenziali di accesso sono cambiate o non sono più valide. Esegui un nuovo accesso." });
|
|
573
853
|
}
|
|
574
854
|
this.broadcastService.sendMessage(EvolutionMessages.LOGIN_FAILED);
|
|
575
855
|
}
|
|
576
856
|
else {
|
|
577
|
-
if ((this.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
857
|
+
if ((this.core.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
578
858
|
this.broadcastService.sendMessage(EvolutionMessages.SUCCESS_TOAST, { message: 'Connesso a Evolution', icon: 'power', duration: 1500 });
|
|
579
859
|
}
|
|
580
860
|
}
|
|
@@ -583,7 +863,7 @@ class EvolutionService {
|
|
|
583
863
|
});
|
|
584
864
|
}
|
|
585
865
|
else if (message.id === EvolutionMessages.LOGOUT) {
|
|
586
|
-
if (this.loggedIn()) {
|
|
866
|
+
if (this.core.loggedIn()) {
|
|
587
867
|
this.logout().subscribe(r => {
|
|
588
868
|
if (!r.success) {
|
|
589
869
|
if (r.message) {
|
|
@@ -591,46 +871,29 @@ class EvolutionService {
|
|
|
591
871
|
}
|
|
592
872
|
}
|
|
593
873
|
else {
|
|
594
|
-
if ((this.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
874
|
+
if ((this.core.flags & EvolutionServiceFlags.DisplayConnectionStateMessages) > 0) {
|
|
595
875
|
this.broadcastService.sendMessage(EvolutionMessages.SUCCESS_TOAST, { message: 'Disconnesso da Evolution', icon: 'power_off', duration: 1500 });
|
|
596
876
|
}
|
|
597
877
|
}
|
|
598
878
|
});
|
|
599
879
|
}
|
|
600
880
|
else {
|
|
601
|
-
this.clear();
|
|
881
|
+
this.core.clear();
|
|
602
882
|
}
|
|
603
883
|
}
|
|
604
884
|
}
|
|
605
885
|
/**
|
|
606
886
|
* Sends a one-shot ping to the back end to verify connectivity.
|
|
887
|
+
* @returns void
|
|
607
888
|
*/
|
|
608
889
|
ping() {
|
|
609
890
|
this.httpClient
|
|
610
|
-
.get(this.
|
|
891
|
+
.get(this.core.serviceUri + '/ping?nocache=' + SystemUtils.generateUUID())
|
|
611
892
|
.pipe(catchError(() => EMPTY))
|
|
612
893
|
.subscribe();
|
|
613
894
|
}
|
|
614
|
-
/**
|
|
615
|
-
* Persists the current login info to `localStorage`.
|
|
616
|
-
*/
|
|
617
|
-
storeContext() {
|
|
618
|
-
localStorage.setItem('evolution_context', JSON.stringify(this._loginInfo));
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Merges a login result into the stored login info and persists it.
|
|
622
|
-
* @param result - The `EvolutionLoginResult` returned by the login endpoint.
|
|
623
|
-
*/
|
|
624
|
-
updateContext(result) {
|
|
625
|
-
if (!this._loginInfo) {
|
|
626
|
-
this._loginInfo = { context: undefined };
|
|
627
|
-
}
|
|
628
|
-
this._loginInfo.context = result.context;
|
|
629
|
-
this.storeContext();
|
|
630
|
-
}
|
|
631
895
|
/**
|
|
632
896
|
* Performs an automatic login using the credentials already stored in the session.
|
|
633
|
-
* Shows a busy indicator and handles success/failure dialogs.
|
|
634
897
|
* @param onSuccess - Optional callback invoked after a successful login.
|
|
635
898
|
* @returns `true` (always) — the result is handled via the subscription callbacks.
|
|
636
899
|
*/
|
|
@@ -655,6 +918,7 @@ class EvolutionService {
|
|
|
655
918
|
/**
|
|
656
919
|
* Performs an automatic logout, notifying the user when the session ends.
|
|
657
920
|
* @param onSuccess - Optional callback invoked after the logout completes.
|
|
921
|
+
* @returns void
|
|
658
922
|
*/
|
|
659
923
|
autoLogout(onSuccess) {
|
|
660
924
|
this.logout().subscribe({
|
|
@@ -676,18 +940,17 @@ class EvolutionService {
|
|
|
676
940
|
});
|
|
677
941
|
}
|
|
678
942
|
/**
|
|
679
|
-
* Authenticates the user against the Evolution back end.
|
|
680
|
-
*
|
|
681
|
-
* @param
|
|
682
|
-
* @param
|
|
683
|
-
* @param
|
|
684
|
-
* @param oauth - OAuth2 provider type, when using federated login.
|
|
943
|
+
* Authenticates the user against the Evolution back end (credential or OAuth2).
|
|
944
|
+
* @param email - User e-mail (credential login only; omit for OAuth2).
|
|
945
|
+
* @param password - User password (credential login only; omit for OAuth2).
|
|
946
|
+
* @param remember - Whether to persist the session across browser restarts.
|
|
947
|
+
* @param oauth - OAuth2 provider type, when using federated login.
|
|
685
948
|
* @param oauthAccessToken - Bearer token from the OAuth2 provider.
|
|
686
949
|
* @returns An observable that emits the `ApiResult<EvolutionLoginResult>`.
|
|
687
950
|
*/
|
|
688
951
|
login(email, password, remember, oauth, oauthAccessToken = sessionStorage.getItem('evolution_oauth_token') ?? undefined) {
|
|
689
952
|
return this.httpClient
|
|
690
|
-
.post(this.
|
|
953
|
+
.post(this.core.serviceUri + '/login2', {
|
|
691
954
|
user: oauth ? null : email,
|
|
692
955
|
password: oauth ? null : password,
|
|
693
956
|
remember,
|
|
@@ -699,11 +962,7 @@ class EvolutionService {
|
|
|
699
962
|
})
|
|
700
963
|
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
701
964
|
if (r.success) {
|
|
702
|
-
|
|
703
|
-
this._loginInfo = { context: undefined };
|
|
704
|
-
}
|
|
705
|
-
this._loginInfo.oauth = oauth;
|
|
706
|
-
this._loginInfo.remember = remember;
|
|
965
|
+
this.core.setAuthMeta(oauth, remember);
|
|
707
966
|
if (!oauth && r.value?.requiresMfa) {
|
|
708
967
|
this.broadcastService.sendMessage(EvolutionMessages.LOGIN_PENDING, {});
|
|
709
968
|
}
|
|
@@ -717,11 +976,12 @@ class EvolutionService {
|
|
|
717
976
|
/**
|
|
718
977
|
* Finalises a successful login by updating the stored context and notifying consumers.
|
|
719
978
|
* @param result - The login result payload from the server.
|
|
979
|
+
* @returns void
|
|
720
980
|
*/
|
|
721
981
|
completeLogin(result) {
|
|
722
|
-
this.updateContext(result);
|
|
723
|
-
this.
|
|
724
|
-
this.loggingIn.set(false);
|
|
982
|
+
this.core.updateContext(result);
|
|
983
|
+
this.core.setLoggedIn(!result.context?.isTemporary);
|
|
984
|
+
this.core.loggingIn.set(false);
|
|
725
985
|
this.broadcastService.sendMessage(EvolutionMessages.LOGIN_COMPLETED);
|
|
726
986
|
}
|
|
727
987
|
/**
|
|
@@ -731,7 +991,7 @@ class EvolutionService {
|
|
|
731
991
|
*/
|
|
732
992
|
confirmIdentity(code) {
|
|
733
993
|
return this.httpClient
|
|
734
|
-
.post(this.
|
|
994
|
+
.post(this.core.serviceUri + '/login/confirm/' + code, {})
|
|
735
995
|
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
736
996
|
if (r.success) {
|
|
737
997
|
this.completeLogin(r.value);
|
|
@@ -746,9 +1006,9 @@ class EvolutionService {
|
|
|
746
1006
|
*/
|
|
747
1007
|
logout(forget = false) {
|
|
748
1008
|
return this.httpClient
|
|
749
|
-
.post(this.
|
|
1009
|
+
.post(this.core.serviceUri + '/logout/?forget=' + forget, {})
|
|
750
1010
|
.pipe(finalize(() => {
|
|
751
|
-
this.clear();
|
|
1011
|
+
this.core.clear();
|
|
752
1012
|
localStorage.removeItem('evolution_context');
|
|
753
1013
|
}), catchError(() => of({ success: false, value: undefined, message: undefined })));
|
|
754
1014
|
}
|
|
@@ -759,7 +1019,7 @@ class EvolutionService {
|
|
|
759
1019
|
*/
|
|
760
1020
|
loginSwitch(id) {
|
|
761
1021
|
return this.httpClient
|
|
762
|
-
.post(this.
|
|
1022
|
+
.post(this.core.serviceUri + '/login/switch', { userId: id })
|
|
763
1023
|
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
764
1024
|
if (r.success) {
|
|
765
1025
|
this.completeLogin(r.value);
|
|
@@ -767,149 +1027,73 @@ class EvolutionService {
|
|
|
767
1027
|
return r;
|
|
768
1028
|
}));
|
|
769
1029
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
* Recursive helper for `toNodes`.
|
|
802
|
-
* @param folders - The nodes to process at the current depth level.
|
|
803
|
-
* @param parent - The parent node, or `undefined` at the root level.
|
|
804
|
-
* @returns An array of `INode` objects with nested `children`.
|
|
805
|
-
*/
|
|
806
|
-
_toNodes(folders, parent) {
|
|
807
|
-
const nodes = [];
|
|
808
|
-
for (const n of folders) {
|
|
809
|
-
const node = {
|
|
810
|
-
id: n.id,
|
|
811
|
-
name: n.name,
|
|
812
|
-
count: n.count,
|
|
813
|
-
parent,
|
|
814
|
-
children: undefined,
|
|
815
|
-
bag: n,
|
|
816
|
-
};
|
|
817
|
-
node.children = n.children && n.children.length > 0
|
|
818
|
-
? this._toNodes(n.children, node)
|
|
819
|
-
: [];
|
|
820
|
-
nodes.push(node);
|
|
821
|
-
}
|
|
822
|
-
return nodes;
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Retrieves the taxonomy tree from the back end.
|
|
826
|
-
* @returns An observable that emits `ApiResult<FolderTree>`.
|
|
827
|
-
*/
|
|
828
|
-
getTaxonomy() {
|
|
829
|
-
return this.httpClient.get(this._serviceUri + '/taxonomy');
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Retrieves the compliance groups for a register.
|
|
833
|
-
* @param group - Group index to retrieve (default: `1`).
|
|
834
|
-
* @param register - Optional register ID to scope the query.
|
|
835
|
-
* @returns An observable that emits `ApiResult<string[]>`.
|
|
836
|
-
*/
|
|
837
|
-
getGroups(group = 1, register) {
|
|
838
|
-
const path = register
|
|
839
|
-
? `/compliance/groups/?group=${group}®ister=${register}`
|
|
840
|
-
: `/compliance/groups/?group=${group}`;
|
|
841
|
-
return this.httpClient.get(this._serviceUri + path);
|
|
842
|
-
}
|
|
843
|
-
// ── Context ────────────────────────────────────────────────────────────────
|
|
844
|
-
/**
|
|
845
|
-
* Sends a context-change request to the back end.
|
|
846
|
-
* @param params - The context model describing the desired switch.
|
|
847
|
-
* @returns An observable that emits `ApiResult<EvolutionChangeContextResultModel>`.
|
|
848
|
-
*/
|
|
849
|
-
changeContext(params) {
|
|
850
|
-
return this.httpClient.post(this._serviceUri + '/compliance/context', params);
|
|
851
|
-
}
|
|
852
|
-
// ── Registers ──────────────────────────────────────────────────────────────
|
|
853
|
-
/**
|
|
854
|
-
* Retrieves a single compliance register by ID.
|
|
855
|
-
* @param id - The register ID.
|
|
856
|
-
* @returns An observable that emits `ApiResult<EvolutionComplianceRegister>`.
|
|
857
|
-
*/
|
|
858
|
-
getRegister(id) {
|
|
859
|
-
return this.httpClient.get(this._serviceUri + '/compliance/registers/' + id);
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Collects register profiles matching the given query parameters.
|
|
863
|
-
* @param params - Query parameters defining the filter criteria.
|
|
864
|
-
* @returns An observable that emits `ApiResult<EvolutionComplianceRegisterProfile[]>`.
|
|
865
|
-
*/
|
|
866
|
-
collectRegisterProfiles(params) {
|
|
867
|
-
return this.httpClient.post(this._serviceUri + '/compliance/registers/profiles/collect', params);
|
|
1030
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LoginService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
1031
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: LoginService }); }
|
|
1032
|
+
}
|
|
1033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LoginService, decorators: [{
|
|
1034
|
+
type: Service
|
|
1035
|
+
}] });
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Public entry point for the Evolution compliance module.
|
|
1039
|
+
*
|
|
1040
|
+
* The private {@link CoreService} is never exposed; its state and operations
|
|
1041
|
+
* are re-published here. All endpoint operations are reached through the
|
|
1042
|
+
* namespaced sub-services:
|
|
1043
|
+
* - `evolution.session` — authentication / session lifecycle
|
|
1044
|
+
* - `evolution.compliance` — taxonomy, context, registers, laws, activities
|
|
1045
|
+
* - `evolution.account` — user links
|
|
1046
|
+
*
|
|
1047
|
+
* The facade itself exposes ONLY the re-published core state/operations plus
|
|
1048
|
+
* `initialize` and `ping` — it intentionally does NOT flatten the sub-service
|
|
1049
|
+
* methods (use the namespaces for those).
|
|
1050
|
+
*/
|
|
1051
|
+
class EvolutionService {
|
|
1052
|
+
constructor() {
|
|
1053
|
+
/** Private: never exposed to consumers. */
|
|
1054
|
+
this.core = inject(CoreService);
|
|
1055
|
+
/** Authentication / session lifecycle sub-service. */
|
|
1056
|
+
this.session = inject(LoginService);
|
|
1057
|
+
/** Compliance endpoints: taxonomy, groups, context, registers, laws, activities. */
|
|
1058
|
+
this.compliance = inject(ComplianceService);
|
|
1059
|
+
/** Account endpoints: user links management. */
|
|
1060
|
+
this.account = inject(AccountService);
|
|
868
1061
|
}
|
|
869
|
-
// ──
|
|
1062
|
+
// ── Re-published core state ─────────────────────────────────────────────────
|
|
870
1063
|
/**
|
|
871
|
-
*
|
|
872
|
-
* @
|
|
873
|
-
* @returns An observable that emits `ApiResult<EvolutionComplianceLaw[]>`.
|
|
1064
|
+
* Gets the base URI of the Evolution back-end service.
|
|
1065
|
+
* @returns The configured service URI, or undefined before initialize().
|
|
874
1066
|
*/
|
|
875
|
-
|
|
876
|
-
return this.httpClient.post(this._serviceUri + '/compliance/laws/add', params);
|
|
877
|
-
}
|
|
878
|
-
// ── Activities ─────────────────────────────────────────────────────────────
|
|
1067
|
+
get serviceUri() { return this.core.serviceUri; }
|
|
879
1068
|
/**
|
|
880
|
-
*
|
|
881
|
-
* @
|
|
882
|
-
* @returns An observable that emits `ApiResult<EvolutionComplianceActivity>`.
|
|
1069
|
+
* Gets the active feature flags.
|
|
1070
|
+
* @returns The active {@link EvolutionServiceFlags} bitmask.
|
|
883
1071
|
*/
|
|
884
|
-
|
|
885
|
-
return this.httpClient.post(this._serviceUri + '/compliance/activities/add', params);
|
|
886
|
-
}
|
|
1072
|
+
get flags() { return this.core.flags; }
|
|
887
1073
|
/**
|
|
888
|
-
*
|
|
889
|
-
* @
|
|
890
|
-
* @returns An observable that emits the binary blob response.
|
|
1074
|
+
* Gets the current login info.
|
|
1075
|
+
* @returns The current {@link EvolutionLoginInfo}, or undefined.
|
|
891
1076
|
*/
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1077
|
+
get loginInfo() { return this.core.loginInfo; }
|
|
1078
|
+
/** `true` when the user has an active (non-temporary) session. */
|
|
1079
|
+
get loggedIn() { return this.core.loggedIn; }
|
|
1080
|
+
/** `true` while a login request is in flight. */
|
|
1081
|
+
get loggingIn() { return this.core.loggingIn; }
|
|
1082
|
+
// ── Lifecycle (the only flattened sub-service methods) ──────────────────────
|
|
897
1083
|
/**
|
|
898
|
-
*
|
|
899
|
-
* @param
|
|
900
|
-
* @
|
|
1084
|
+
* Initialises the service with the back-end URI and optional feature flags.
|
|
1085
|
+
* @param serviceUri - Base URL of the Evolution service.
|
|
1086
|
+
* @param flags - Bitmask of `EvolutionServiceFlags` (default: `None`).
|
|
1087
|
+
* @returns void
|
|
901
1088
|
*/
|
|
902
|
-
|
|
903
|
-
|
|
1089
|
+
initialize(serviceUri, flags = EvolutionServiceFlags.None) {
|
|
1090
|
+
this.session.initialize(serviceUri, flags);
|
|
904
1091
|
}
|
|
905
1092
|
/**
|
|
906
|
-
*
|
|
907
|
-
* @
|
|
908
|
-
* @returns An observable that emits `ApiResult<boolean>`.
|
|
1093
|
+
* Sends a one-shot ping to the back end to verify connectivity.
|
|
1094
|
+
* @returns void
|
|
909
1095
|
*/
|
|
910
|
-
|
|
911
|
-
return this.httpClient.post(this._serviceUri + '/account/links/delete', item);
|
|
912
|
-
}
|
|
1096
|
+
ping() { this.session.ping(); }
|
|
913
1097
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EvolutionService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
914
1098
|
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: EvolutionService }); }
|
|
915
1099
|
}
|
|
@@ -1007,6 +1191,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
1007
1191
|
type: Injectable
|
|
1008
1192
|
}] });
|
|
1009
1193
|
|
|
1194
|
+
// Public barrel for the Evolution services.
|
|
1195
|
+
//
|
|
1196
|
+
// CoreService is intentionally NOT exported: it is private/internal and must
|
|
1197
|
+
// never be injected directly. Consumers use EvolutionService (the full facade,
|
|
1198
|
+
// with both namespaced sub-services and the backward-compatible flat methods)
|
|
1199
|
+
// or, in size-sensitive code, the specific sub-service they need.
|
|
1200
|
+
|
|
1010
1201
|
/*
|
|
1011
1202
|
* Public API Surface of ars-utils
|
|
1012
1203
|
*/
|
|
@@ -1015,5 +1206,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
1015
1206
|
* Generated bundle index. Do not edit.
|
|
1016
1207
|
*/
|
|
1017
1208
|
|
|
1018
|
-
export { ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EvolutionAuthInterceptor, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags };
|
|
1209
|
+
export { AccountService, ComplianceService, ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EvolutionAuthInterceptor, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags, LoginService };
|
|
1019
1210
|
//# sourceMappingURL=arsedizioni-ars-utils-evolution.common.mjs.map
|