@arsedizioni/ars-utils 22.0.54 → 22.0.56
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-clipper.common.mjs +96 -102
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs +218 -220
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs.map +1 -1
- package/package.json +1 -1
- package/types/arsedizioni-ars-utils-clipper.common.d.ts +18 -33
- package/types/arsedizioni-ars-utils-clipper.ui.d.ts +1 -1
- package/types/arsedizioni-ars-utils-evolution.common.d.ts +19 -28
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { HttpClient, HttpHeaders
|
|
1
|
+
import { HttpErrorResponse, HttpClient, HttpHeaders } from '@angular/common/http';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, signal, Service, DestroyRef
|
|
3
|
+
import { inject, signal, Service, DestroyRef } from '@angular/core';
|
|
4
4
|
import { BroadcastService, SystemUtils } from '@arsedizioni/ars-utils/core';
|
|
5
|
-
import {
|
|
5
|
+
import { catchError, throwError, EMPTY, of } from 'rxjs';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
-
import { catchError, map, finalize } from 'rxjs/operators';
|
|
7
|
+
import { catchError as catchError$1, map, finalize } from 'rxjs/operators';
|
|
8
8
|
|
|
9
9
|
const EvolutionMessages = {
|
|
10
10
|
// Error
|
|
@@ -483,6 +483,94 @@ var ERPPlace;
|
|
|
483
483
|
class EvolutionComplianceContextInfo {
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
+
/** Minimum milliseconds between consecutive error broadcasts (debounce guard). */
|
|
487
|
+
const ERROR_DEBOUNCE_MS = 5000;
|
|
488
|
+
/**
|
|
489
|
+
* Builds the Evolution auth HTTP interceptor.
|
|
490
|
+
*
|
|
491
|
+
* Takes its two inputs — the Evolution base URI and the service flags — directly
|
|
492
|
+
* as arguments (captured in the closure), so it never injects EvolutionService:
|
|
493
|
+
* registering it does not pull the full Evolution service into the eager bundle.
|
|
494
|
+
*
|
|
495
|
+
* Register it with `withInterceptors`:
|
|
496
|
+
* @example
|
|
497
|
+
* provideHttpClient(withInterceptors([
|
|
498
|
+
* evolutionAuthInterceptor(environment.evolutionServiceUri,
|
|
499
|
+
* EvolutionServiceFlags.DisplayConnectionStateMessages | EvolutionServiceFlags.Embedded),
|
|
500
|
+
* ]))
|
|
501
|
+
*
|
|
502
|
+
* @param serviceUri - Base URI of the Evolution service; only requests starting with it are handled.
|
|
503
|
+
* @param flags - Service flags (e.g. NotifySystemErrors). Defaults to None.
|
|
504
|
+
* @returns An `HttpInterceptorFn` ready to register.
|
|
505
|
+
*/
|
|
506
|
+
function evolutionAuthInterceptor(serviceUri, flags = EvolutionServiceFlags.None) {
|
|
507
|
+
// Debounce state, persisted across requests via the factory closure.
|
|
508
|
+
let lastErrorTime = -1;
|
|
509
|
+
/**
|
|
510
|
+
* Broadcasts a user-friendly message for an Evolution HTTP error, debounced.
|
|
511
|
+
* @param error - The raw error value thrown by the HTTP layer.
|
|
512
|
+
* @param broadcastService - The broadcast service for the current request.
|
|
513
|
+
* @returns void
|
|
514
|
+
*/
|
|
515
|
+
function handleError(error, broadcastService) {
|
|
516
|
+
if (!(error instanceof HttpErrorResponse))
|
|
517
|
+
return;
|
|
518
|
+
// Only reject errors that explicitly belong to a different service; a missing
|
|
519
|
+
// url (network failure on an Evolution request) is allowed through.
|
|
520
|
+
if (error.url && !error.url.startsWith(serviceUri))
|
|
521
|
+
return;
|
|
522
|
+
const errorStatus = error.status;
|
|
523
|
+
const shouldNotify = errorStatus === 0 ||
|
|
524
|
+
(errorStatus > 0 && errorStatus < 500) ||
|
|
525
|
+
(flags & EvolutionServiceFlags.NotifySystemErrors) > 0;
|
|
526
|
+
if (!shouldNotify)
|
|
527
|
+
return;
|
|
528
|
+
const now = Date.now();
|
|
529
|
+
if (now - lastErrorTime <= ERROR_DEBOUNCE_MS)
|
|
530
|
+
return;
|
|
531
|
+
lastErrorTime = now;
|
|
532
|
+
let message;
|
|
533
|
+
switch (errorStatus) {
|
|
534
|
+
case 0:
|
|
535
|
+
message = "In questo momento Evolution non è disponibile. Riprova tra qualche minuto.";
|
|
536
|
+
break;
|
|
537
|
+
case 403:
|
|
538
|
+
message = "Non hai i permessi necessari per eseguire l'operazione richiesta.";
|
|
539
|
+
break;
|
|
540
|
+
default:
|
|
541
|
+
message = (error.error?.['message'] ??
|
|
542
|
+
error.message ??
|
|
543
|
+
"Impossibile eseguire l'operazione richiesta.").replaceAll('\r\n', '</p><p>');
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
broadcastService.sendMessage(EvolutionMessages.ERROR, {
|
|
547
|
+
invalidateSession: errorStatus === 405 || errorStatus === 410,
|
|
548
|
+
message,
|
|
549
|
+
title: "Errore in Evolution",
|
|
550
|
+
errorStatus,
|
|
551
|
+
service: serviceUri
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
// The interceptor itself. Runs in an injection context, so `inject()` works.
|
|
555
|
+
return (request, next) => {
|
|
556
|
+
if (!serviceUri || !request.url.startsWith(serviceUri)) {
|
|
557
|
+
return next(request);
|
|
558
|
+
}
|
|
559
|
+
const broadcastService = inject(BroadcastService);
|
|
560
|
+
const authenticatedRequest = request.clone({
|
|
561
|
+
withCredentials: true,
|
|
562
|
+
setHeaders: {
|
|
563
|
+
'ngsw-bypass': 'ngsw-bypass',
|
|
564
|
+
'X-Client-Id': sessionStorage.getItem('evolution_client_id') ?? ''
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
return next(authenticatedRequest).pipe(catchError((error) => {
|
|
568
|
+
handleError(error, broadcastService);
|
|
569
|
+
return throwError(() => error);
|
|
570
|
+
}));
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
|
|
486
574
|
/**
|
|
487
575
|
* @internal
|
|
488
576
|
* Private state container for the Evolution session.
|
|
@@ -626,126 +714,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
626
714
|
type: Service
|
|
627
715
|
}] });
|
|
628
716
|
|
|
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
717
|
/**
|
|
750
718
|
* Authentication service for the Evolution module: login / logout / MFA,
|
|
751
719
|
* session bootstrap, connectivity ping and the broadcast handler.
|
|
@@ -889,7 +857,7 @@ class LoginService {
|
|
|
889
857
|
ping() {
|
|
890
858
|
this.httpClient
|
|
891
859
|
.get(this.core.serviceUri + '/ping?nocache=' + SystemUtils.generateUUID())
|
|
892
|
-
.pipe(catchError(() => EMPTY))
|
|
860
|
+
.pipe(catchError$1(() => EMPTY))
|
|
893
861
|
.subscribe();
|
|
894
862
|
}
|
|
895
863
|
/**
|
|
@@ -960,7 +928,7 @@ class LoginService {
|
|
|
960
928
|
? new HttpHeaders().set('Authorization', oauthAccessToken)
|
|
961
929
|
: new HttpHeaders()
|
|
962
930
|
})
|
|
963
|
-
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
931
|
+
.pipe(catchError$1(err => throwError(() => err)), map((r) => {
|
|
964
932
|
if (r.success) {
|
|
965
933
|
this.core.setAuthMeta(oauth, remember);
|
|
966
934
|
if (!oauth && r.value?.requiresMfa) {
|
|
@@ -992,7 +960,7 @@ class LoginService {
|
|
|
992
960
|
confirmIdentity(code) {
|
|
993
961
|
return this.httpClient
|
|
994
962
|
.post(this.core.serviceUri + '/login/confirm/' + code, {})
|
|
995
|
-
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
963
|
+
.pipe(catchError$1(err => throwError(() => err)), map((r) => {
|
|
996
964
|
if (r.success) {
|
|
997
965
|
this.completeLogin(r.value);
|
|
998
966
|
}
|
|
@@ -1010,7 +978,7 @@ class LoginService {
|
|
|
1010
978
|
.pipe(finalize(() => {
|
|
1011
979
|
this.core.clear();
|
|
1012
980
|
localStorage.removeItem('evolution_context');
|
|
1013
|
-
}), catchError(() => of({ success: false, value: undefined, message: undefined })));
|
|
981
|
+
}), catchError$1(() => of({ success: false, value: undefined, message: undefined })));
|
|
1014
982
|
}
|
|
1015
983
|
/**
|
|
1016
984
|
* Switches the active session to a different user account while retaining credentials.
|
|
@@ -1020,7 +988,7 @@ class LoginService {
|
|
|
1020
988
|
loginSwitch(id) {
|
|
1021
989
|
return this.httpClient
|
|
1022
990
|
.post(this.core.serviceUri + '/login/switch', { userId: id })
|
|
1023
|
-
.pipe(catchError(err => throwError(() => err)), map((r) => {
|
|
991
|
+
.pipe(catchError$1(err => throwError(() => err)), map((r) => {
|
|
1024
992
|
if (r.success) {
|
|
1025
993
|
this.completeLogin(r.value);
|
|
1026
994
|
}
|
|
@@ -1034,6 +1002,126 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
1034
1002
|
type: Service
|
|
1035
1003
|
}] });
|
|
1036
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Compliance endpoints: taxonomy & groups, context, registers, laws and
|
|
1007
|
+
* activities (the `Context` / `Registers` / `Laws` / `Activities` sections,
|
|
1008
|
+
* plus the general taxonomy/groups lookups). Pure HTTP; injects the private
|
|
1009
|
+
* {@link CoreService} only to read the back-end URI.
|
|
1010
|
+
*/
|
|
1011
|
+
class ComplianceService {
|
|
1012
|
+
constructor() {
|
|
1013
|
+
this.httpClient = inject(HttpClient);
|
|
1014
|
+
this.core = inject(CoreService);
|
|
1015
|
+
}
|
|
1016
|
+
// ── Taxonomy & groups ───────────────────────────────────────────────────────
|
|
1017
|
+
/**
|
|
1018
|
+
* Retrieves the taxonomy tree from the back end.
|
|
1019
|
+
* @returns An observable that emits `ApiResult<FolderTree>`.
|
|
1020
|
+
*/
|
|
1021
|
+
getTaxonomy() {
|
|
1022
|
+
return this.httpClient.get(this.core.serviceUri + '/taxonomy');
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Retrieves the compliance groups for a register.
|
|
1026
|
+
* @param group - Group index to retrieve (default: `1`).
|
|
1027
|
+
* @param register - Optional register ID to scope the query.
|
|
1028
|
+
* @returns An observable that emits `ApiResult<string[]>`.
|
|
1029
|
+
*/
|
|
1030
|
+
getGroups(group = 1, register) {
|
|
1031
|
+
const path = register
|
|
1032
|
+
? `/compliance/groups/?group=${group}®ister=${register}`
|
|
1033
|
+
: `/compliance/groups/?group=${group}`;
|
|
1034
|
+
return this.httpClient.get(this.core.serviceUri + path);
|
|
1035
|
+
}
|
|
1036
|
+
// ── Context ──────────────────────────────────────────────────────────────────
|
|
1037
|
+
/**
|
|
1038
|
+
* Sends a context-change request to the back end.
|
|
1039
|
+
* @param params - The context model describing the desired switch.
|
|
1040
|
+
* @returns An observable that emits `ApiResult<EvolutionChangeContextResultModel>`.
|
|
1041
|
+
*/
|
|
1042
|
+
changeContext(params) {
|
|
1043
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/context', params);
|
|
1044
|
+
}
|
|
1045
|
+
// ── Registers ────────────────────────────────────────────────────────────────
|
|
1046
|
+
/**
|
|
1047
|
+
* Retrieves a single compliance register by ID.
|
|
1048
|
+
* @param id - The register ID.
|
|
1049
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceRegister>`.
|
|
1050
|
+
*/
|
|
1051
|
+
getRegister(id) {
|
|
1052
|
+
return this.httpClient.get(this.core.serviceUri + '/compliance/registers/' + id);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Collects register profiles matching the given query parameters.
|
|
1056
|
+
* @param params - Query parameters defining the filter criteria.
|
|
1057
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceRegisterProfile[]>`.
|
|
1058
|
+
*/
|
|
1059
|
+
collectRegisterProfiles(params) {
|
|
1060
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/registers/profiles/collect', params);
|
|
1061
|
+
}
|
|
1062
|
+
// ── Laws ─────────────────────────────────────────────────────────────────────
|
|
1063
|
+
/**
|
|
1064
|
+
* Adds one or more compliance laws.
|
|
1065
|
+
* @param params - The laws to add.
|
|
1066
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceLaw[]>`.
|
|
1067
|
+
*/
|
|
1068
|
+
addLaws(params) {
|
|
1069
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/laws/add', params);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Exports compliance laws in the format expected by the server.
|
|
1073
|
+
* @param params - Export parameters (model shape is server-defined).
|
|
1074
|
+
* @returns An observable that emits the binary blob response.
|
|
1075
|
+
*/
|
|
1076
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1077
|
+
exportLaws(params) {
|
|
1078
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/laws/export', params, { responseType: 'blob' });
|
|
1079
|
+
}
|
|
1080
|
+
// ── Activities ─────────────────────────────────────────────────────────────────
|
|
1081
|
+
/**
|
|
1082
|
+
* Adds one or more compliance activities.
|
|
1083
|
+
* @param params - The activities to add.
|
|
1084
|
+
* @returns An observable that emits `ApiResult<EvolutionComplianceActivity>`.
|
|
1085
|
+
*/
|
|
1086
|
+
addActivities(params) {
|
|
1087
|
+
return this.httpClient.post(this.core.serviceUri + '/compliance/activities/add', params);
|
|
1088
|
+
}
|
|
1089
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
1090
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService }); }
|
|
1091
|
+
}
|
|
1092
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ComplianceService, decorators: [{
|
|
1093
|
+
type: Service
|
|
1094
|
+
}] });
|
|
1095
|
+
|
|
1096
|
+
/** Account endpoints (the `Links` section): user links management. */
|
|
1097
|
+
class AccountService {
|
|
1098
|
+
constructor() {
|
|
1099
|
+
this.httpClient = inject(HttpClient);
|
|
1100
|
+
this.core = inject(CoreService);
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Persists a user link on the server.
|
|
1104
|
+
* @param item - The user link to save.
|
|
1105
|
+
* @returns An observable that emits `ApiResult<boolean>`.
|
|
1106
|
+
*/
|
|
1107
|
+
saveLink(item) {
|
|
1108
|
+
return this.httpClient.post(this.core.serviceUri + '/account/links/save', item);
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Deletes a user link from the server.
|
|
1112
|
+
* @param item - The user link to delete.
|
|
1113
|
+
* @returns An observable that emits `ApiResult<boolean>`.
|
|
1114
|
+
*/
|
|
1115
|
+
deleteLink(item) {
|
|
1116
|
+
return this.httpClient.post(this.core.serviceUri + '/account/links/delete', item);
|
|
1117
|
+
}
|
|
1118
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AccountService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
1119
|
+
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.1", ngImport: i0, type: AccountService }); }
|
|
1120
|
+
}
|
|
1121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AccountService, decorators: [{
|
|
1122
|
+
type: Service
|
|
1123
|
+
}] });
|
|
1124
|
+
|
|
1037
1125
|
/**
|
|
1038
1126
|
* Public entry point for the Evolution compliance module.
|
|
1039
1127
|
*
|
|
@@ -1101,96 +1189,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
1101
1189
|
type: Service
|
|
1102
1190
|
}] });
|
|
1103
1191
|
|
|
1104
|
-
/** Minimum milliseconds between consecutive error broadcasts (debounce guard). */
|
|
1105
|
-
const ERROR_DEBOUNCE_MS = 5000;
|
|
1106
|
-
/**
|
|
1107
|
-
* HTTP interceptor that attaches Evolution authentication headers to every request
|
|
1108
|
-
* targeting the Evolution service, and broadcasts user-friendly error messages
|
|
1109
|
-
* when the server returns an error response.
|
|
1110
|
-
*/
|
|
1111
|
-
class EvolutionAuthInterceptor {
|
|
1112
|
-
constructor() {
|
|
1113
|
-
this.evolutionService = inject(EvolutionService);
|
|
1114
|
-
this.broadcastService = inject(BroadcastService);
|
|
1115
|
-
this.lastErrorTime = -1;
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
* Intercepts every outgoing HTTP request.
|
|
1119
|
-
* When the request targets the Evolution service URI, attaches credentials and
|
|
1120
|
-
* a client-ID header, then pipes the response through an error handler.
|
|
1121
|
-
* @param request - The outgoing HTTP request.
|
|
1122
|
-
* @param next - The next handler in the interceptor chain.
|
|
1123
|
-
* @returns An observable of the HTTP event stream.
|
|
1124
|
-
*/
|
|
1125
|
-
intercept(request, next) {
|
|
1126
|
-
const serviceUri = this.evolutionService.serviceUri ?? '';
|
|
1127
|
-
if (!serviceUri || !request.url.startsWith(serviceUri)) {
|
|
1128
|
-
return next.handle(request);
|
|
1129
|
-
}
|
|
1130
|
-
const authenticatedRequest = request.clone({
|
|
1131
|
-
withCredentials: true,
|
|
1132
|
-
setHeaders: {
|
|
1133
|
-
'ngsw-bypass': 'ngsw-bypass',
|
|
1134
|
-
'X-Client-Id': sessionStorage.getItem('evolution_client_id') ?? ''
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
return next.handle(authenticatedRequest).pipe(catchError$1((error) => {
|
|
1138
|
-
this.handleError(error);
|
|
1139
|
-
return throwError(() => error);
|
|
1140
|
-
}));
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Processes an HTTP error, broadcasting a user-friendly message when appropriate.
|
|
1144
|
-
* Errors are debounced: only one message is sent per `ERROR_DEBOUNCE_MS` window.
|
|
1145
|
-
* @param error - The raw error value thrown by the HTTP layer.
|
|
1146
|
-
*/
|
|
1147
|
-
handleError(error) {
|
|
1148
|
-
if (!(error instanceof HttpErrorResponse))
|
|
1149
|
-
return;
|
|
1150
|
-
const serviceUri = this.evolutionService.serviceUri ?? '';
|
|
1151
|
-
// Only reject errors that explicitly belong to a different service; a missing
|
|
1152
|
-
// url (network failure on an Evolution request) is allowed through.
|
|
1153
|
-
if (error.url && !error.url.startsWith(serviceUri))
|
|
1154
|
-
return;
|
|
1155
|
-
const errorStatus = error.status;
|
|
1156
|
-
const shouldNotify = errorStatus === 0 ||
|
|
1157
|
-
(errorStatus > 0 && errorStatus < 500) ||
|
|
1158
|
-
(this.evolutionService.flags & EvolutionServiceFlags.NotifySystemErrors) > 0;
|
|
1159
|
-
if (!shouldNotify)
|
|
1160
|
-
return;
|
|
1161
|
-
const now = Date.now();
|
|
1162
|
-
if (now - this.lastErrorTime <= ERROR_DEBOUNCE_MS)
|
|
1163
|
-
return;
|
|
1164
|
-
this.lastErrorTime = now;
|
|
1165
|
-
let message;
|
|
1166
|
-
switch (errorStatus) {
|
|
1167
|
-
case 0:
|
|
1168
|
-
message = "In questo momento Evolution non è disponibile. Riprova tra qualche minuto.";
|
|
1169
|
-
break;
|
|
1170
|
-
case 403:
|
|
1171
|
-
message = "Non hai i permessi necessari per eseguire l'operazione richiesta.";
|
|
1172
|
-
break;
|
|
1173
|
-
default:
|
|
1174
|
-
message = (error.error?.['message'] ??
|
|
1175
|
-
error.message ??
|
|
1176
|
-
"Impossibile eseguire l'operazione richiesta.").replaceAll('\r\n', '</p><p>');
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
this.broadcastService.sendMessage(EvolutionMessages.ERROR, {
|
|
1180
|
-
invalidateSession: errorStatus === 405 || errorStatus === 410,
|
|
1181
|
-
message,
|
|
1182
|
-
title: "Errore in Evolution",
|
|
1183
|
-
errorStatus,
|
|
1184
|
-
service: this.evolutionService.serviceUri
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EvolutionAuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1188
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EvolutionAuthInterceptor }); }
|
|
1189
|
-
}
|
|
1190
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: EvolutionAuthInterceptor, decorators: [{
|
|
1191
|
-
type: Injectable
|
|
1192
|
-
}] });
|
|
1193
|
-
|
|
1194
1192
|
// Public barrel for the Evolution services.
|
|
1195
1193
|
//
|
|
1196
1194
|
// CoreService is intentionally NOT exported: it is private/internal and must
|
|
@@ -1206,5 +1204,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
1206
1204
|
* Generated bundle index. Do not edit.
|
|
1207
1205
|
*/
|
|
1208
1206
|
|
|
1209
|
-
export { AccountService, ComplianceService, ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType,
|
|
1207
|
+
export { AccountService, ComplianceService, ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags, LoginService, evolutionAuthInterceptor };
|
|
1210
1208
|
//# sourceMappingURL=arsedizioni-ars-utils-evolution.common.mjs.map
|