@esfaenza/httpservice 13.1.3 → 13.1.7
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/esm2020/lib/httpservice.service.loc.mjs +7 -2
- package/esm2020/lib/httpservice.service.mjs +86 -39
- package/esm2020/lib/models/CacheInfos.mjs +10 -0
- package/fesm2015/esfaenza-httpservice.mjs +114 -45
- package/fesm2015/esfaenza-httpservice.mjs.map +1 -1
- package/fesm2020/esfaenza-httpservice.mjs +100 -39
- package/fesm2020/esfaenza-httpservice.mjs.map +1 -1
- package/lib/httpservice.service.d.ts +24 -21
- package/lib/httpservice.service.loc.d.ts +20 -0
- package/lib/models/CacheInfos.d.ts +8 -0
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class CacheInfos {
|
|
2
|
+
constructor(finalUrl, cache, cacheKey, cacheTime, cacheItem) {
|
|
3
|
+
this.finalUrl = finalUrl;
|
|
4
|
+
this.cache = cache;
|
|
5
|
+
this.cacheKey = cacheKey;
|
|
6
|
+
this.cacheTime = cacheTime;
|
|
7
|
+
this.cacheItem = cacheItem;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGVJbmZvcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2h0dHBzZXJ2aWNlL3NyYy9saWIvbW9kZWxzL0NhY2hlSW5mb3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxPQUFPLFVBQVU7SUFDbkIsWUFBbUIsUUFBZ0IsRUFBUyxLQUFjLEVBQVMsUUFBZ0IsRUFBUyxTQUFpQixFQUFTLFNBQWM7UUFBakgsYUFBUSxHQUFSLFFBQVEsQ0FBUTtRQUFTLFVBQUssR0FBTCxLQUFLLENBQVM7UUFBUyxhQUFRLEdBQVIsUUFBUSxDQUFRO1FBQVMsY0FBUyxHQUFULFNBQVMsQ0FBUTtRQUFTLGNBQVMsR0FBVCxTQUFTLENBQUs7SUFBSSxDQUFDO0NBQzVJIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIENhY2hlSW5mb3Mge1xyXG4gICAgY29uc3RydWN0b3IocHVibGljIGZpbmFsVXJsOiBzdHJpbmcsIHB1YmxpYyBjYWNoZTogYm9vbGVhbiwgcHVibGljIGNhY2hlS2V5OiBzdHJpbmcsIHB1YmxpYyBjYWNoZVRpbWU6IHN0cmluZywgcHVibGljIGNhY2hlSXRlbTogYW55KSB7IH1cclxufSJdfQ==
|
|
@@ -4,7 +4,8 @@ import { HttpEventType, HttpHeaders, HttpErrorResponse } from '@angular/common/h
|
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
5
|
import { InjectionToken, Injectable, Inject, Optional, NgModule } from '@angular/core';
|
|
6
6
|
import { delay, finalize, map, catchError, scan } from 'rxjs/operators';
|
|
7
|
-
import { of, throwError, Observable } from 'rxjs';
|
|
7
|
+
import { forkJoin, of, throwError, Observable } from 'rxjs';
|
|
8
|
+
import * as i3 from '@esfaenza/preferences';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Dizionario di invalidazioni delle chiamate HTTP
|
|
@@ -134,9 +135,24 @@ const Loc = {
|
|
|
134
135
|
"Redirecting to Login, ignoring HTTP error on call": { "en-US": "Redirecting to Login, ignoring HTTP error on call", "it-IT": "Redireziono al login ignorando errori sulla chiamata", },
|
|
135
136
|
"Already Handling an error, ignoring HTTP error on call": { "en-US": "Already Handling an error, ignoring HTTP error on call", "it-IT": "sto già gestendo un errore, ignoro quello corrente per la chiamata HTTP", },
|
|
136
137
|
"Error 444 on call": { "en-US": "Error 444 on call", "it-IT": "Errore 444 su chiamata" },
|
|
137
|
-
"Resource not found": { "en-US": "Resource not found", "it-IT": "Risorsa non trovata" }
|
|
138
|
+
"Resource not found": { "en-US": "Resource not found", "it-IT": "Risorsa non trovata" },
|
|
139
|
+
"Converted old storage system to new one": { "en-US": "Converted old storage system to new one", "it-IT": "Convertito il vecchio sistema di storicizzazione al nuovo" },
|
|
140
|
+
"Marking cache to be persisted as soon as possible": { "en-US": "Marking cache to be persisted as soon as possible", "it-IT": "Marco cache da persistere il prima possibile" },
|
|
141
|
+
"No more HTTP calls to be executed, entering idle state and persisting modified caches": { "en-US": "No more HTTP calls to be executed, entering idle state and persisting modified caches", "it-IT": "Nessun'altra chiamata HTTP dev'essere eseguita, entro in stato IDLE e persisto le cache modificate" },
|
|
142
|
+
"Caches succesfully persisted": { "en-US": "Caches succesfully persisted", "it-IT": "Le cache sono state persistite con successo" },
|
|
143
|
+
"Errors persisting modified caches": { "en-US": "Errors persisting modified caches", "it-IT": "Errori nella persistizione delle cache (esiste persistizione? boh...)" },
|
|
138
144
|
};
|
|
139
145
|
|
|
146
|
+
class CacheInfos {
|
|
147
|
+
constructor(finalUrl, cache, cacheKey, cacheTime, cacheItem) {
|
|
148
|
+
this.finalUrl = finalUrl;
|
|
149
|
+
this.cache = cache;
|
|
150
|
+
this.cacheKey = cacheKey;
|
|
151
|
+
this.cacheTime = cacheTime;
|
|
152
|
+
this.cacheItem = cacheItem;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
140
156
|
/**
|
|
141
157
|
* Servizio utilizzato per effettuare qualsiasi tipo di chiamata HTTP dall'applicazione, gestisce errori e cache delle risposte nativamente e ne può essere
|
|
142
158
|
* esteso/modificato il comportamento implementando la classe di "hook" **IHttpServiceExtensions** e registrandola nel provider della classe **HttpServiceExtensions**
|
|
@@ -145,7 +161,7 @@ class HTTPService {
|
|
|
145
161
|
/**
|
|
146
162
|
* @ignore
|
|
147
163
|
*/
|
|
148
|
-
constructor(BACKEND_URL, EXTENSION_CLASS, HTTP_INVALIDATION, LOCALE, APP_NAME, CLIENT_CACHE_DURATION_S, CACHE_BY_USER, DEBUG_MODE, http) {
|
|
164
|
+
constructor(BACKEND_URL, EXTENSION_CLASS, HTTP_INVALIDATION, LOCALE, APP_NAME, CLIENT_CACHE_DURATION_S, CACHE_BY_USER, DEBUG_MODE, http, localStorage) {
|
|
149
165
|
var _a, _b;
|
|
150
166
|
this.BACKEND_URL = BACKEND_URL;
|
|
151
167
|
this.EXTENSION_CLASS = EXTENSION_CLASS;
|
|
@@ -156,34 +172,51 @@ class HTTPService {
|
|
|
156
172
|
this.CACHE_BY_USER = CACHE_BY_USER;
|
|
157
173
|
this.DEBUG_MODE = DEBUG_MODE;
|
|
158
174
|
this.http = http;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
*/
|
|
175
|
+
this.localStorage = localStorage;
|
|
176
|
+
/** Cache dello stato delle chiamate HTTP attualmente effettuate. Ogni chiamata è rappresentata da un GUID e lo status assume valore **false** solo sugli errori */
|
|
162
177
|
this.callStatus = {};
|
|
163
|
-
/**
|
|
164
|
-
* Nome della cache in cui vengono storicizzate le informazioni sulle risposte delle chiamate sotto forma di dictionary
|
|
165
|
-
*/
|
|
178
|
+
/** Nome della cache in cui vengono storicizzate le informazioni sulle risposte delle chiamate sotto forma di dictionary */
|
|
166
179
|
this.localStorageHttpCacheKey = null;
|
|
167
|
-
/**
|
|
168
|
-
* Nome della cache in cui vengono storicizzate le informazioni sulle risposte delle chiamate sotto forma di dictionary, solo per le chiamate con un tempo definito di caching
|
|
169
|
-
*/
|
|
180
|
+
/** Nome della cache in cui vengono storicizzate le informazioni sulle risposte delle chiamate sotto forma di dictionary, solo per le chiamate con un tempo definito di caching */
|
|
170
181
|
this.localStorageHttpTimedCacheKey = null;
|
|
171
|
-
/**
|
|
172
|
-
* Nome della cache in cui vengono storicizzate le informazioni sullo scadere della cache stessa
|
|
173
|
-
*/
|
|
182
|
+
/** Nome della cache in cui vengono storicizzate le informazioni sullo scadere della cache stessa */
|
|
174
183
|
this.localStorageHttpCacheExpireKey = null;
|
|
175
|
-
/**
|
|
176
|
-
* Identità collegata al token di autenticazione da usare, richiesta al programma che utilizza la libreria attraverso l'hook **retrieveIdentity** della **HttpServiceExtensions**
|
|
177
|
-
*/
|
|
184
|
+
/** Identità collegata al token di autenticazione da usare, richiesta al programma che utilizza la libreria attraverso l'hook **retrieveIdentity** della **HttpServiceExtensions** */
|
|
178
185
|
this.me = null;
|
|
186
|
+
/** Indica che la cache a tempo dev'essere persistita il prima possibile */
|
|
187
|
+
this.PersistTimedCacheASAP = false;
|
|
188
|
+
/** Indica che la cache senza limiti di tempo dev'essere persistita il prima possibile */
|
|
189
|
+
this.PersistUntimedCacheASAP = false;
|
|
179
190
|
this.ExtensionsImpl = this.EXTENSION_CLASS || new HttpServiceExtensions();
|
|
180
191
|
this.me = this.ExtensionsImpl.retrieveIdentity();
|
|
181
192
|
this.localStorageHttpCacheKey = ((_a = this.APP_NAME) !== null && _a !== void 0 ? _a : "APP").replace(/\s/g, '_') + "_HttpCache";
|
|
182
193
|
this.localStorageHttpTimedCacheKey = ((_b = this.APP_NAME) !== null && _b !== void 0 ? _b : "APP").replace(/\s/g, '_') + "_HttpTimedCache";
|
|
183
194
|
this.localStorageHttpCacheExpireKey = this.localStorageHttpCacheKey + "_Expire";
|
|
195
|
+
this.adjustOldStorageSystem();
|
|
184
196
|
if (this.untimedCacheExpired())
|
|
185
197
|
this.resetHttpUntimedCacheStorage();
|
|
186
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Se vedo che ci sono elementi salvati nel localStorage provo a toglierli e a risalvarli via preference.
|
|
201
|
+
* Nel caso migliore li sposto dal localStorage al DB di preference, nel caso peggiore li tolgo e li risalvo nel localStorage
|
|
202
|
+
*/
|
|
203
|
+
adjustOldStorageSystem() {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
var lsTimed = localStorage.getItem(this.localStorageHttpTimedCacheKey);
|
|
206
|
+
var lsUntimed = localStorage.getItem(this.localStorageHttpCacheKey);
|
|
207
|
+
if (!lsTimed && !lsUntimed)
|
|
208
|
+
return;
|
|
209
|
+
localStorage.removeItem(this.localStorageHttpTimedCacheKey);
|
|
210
|
+
localStorage.removeItem(this.localStorageHttpCacheKey);
|
|
211
|
+
lsTimed = lsTimed ? JSON.parse(lsTimed) : {};
|
|
212
|
+
lsUntimed = lsUntimed ? JSON.parse(lsUntimed) : {};
|
|
213
|
+
yield forkJoin([
|
|
214
|
+
this.localStorage.setItem(this.localStorageHttpTimedCacheKey, lsTimed),
|
|
215
|
+
this.localStorage.setItem(this.localStorageHttpCacheKey, lsUntimed)
|
|
216
|
+
]).toPromise();
|
|
217
|
+
this.log(this.loc("Converted old storage system to new one"));
|
|
218
|
+
});
|
|
219
|
+
}
|
|
187
220
|
/**
|
|
188
221
|
* Esecuzione di una GET HTTP con eventualmente la gestione della cache qualora la chiamata termini con la convenzione "#cache"
|
|
189
222
|
*
|
|
@@ -215,7 +248,7 @@ class HTTPService {
|
|
|
215
248
|
if (errorCallback)
|
|
216
249
|
errorCallback();
|
|
217
250
|
return !succesfulResultMandatory ? throwError(err) : this.registerErrorAndReturnEmptyObservable(err, myGuid);
|
|
218
|
-
}), finalize(() => { this.tryFinalizeByGuid(myGuid); }));
|
|
251
|
+
}), finalize(() => { this.tryFinalizeByGuid(myGuid, cachedInfos); }));
|
|
219
252
|
}
|
|
220
253
|
/**
|
|
221
254
|
* Esecuzione di una GET HTTP con eventualmente la gestione della cache qualora la chiamata termini con la convenzione "#cache"
|
|
@@ -250,7 +283,7 @@ class HTTPService {
|
|
|
250
283
|
if (errorCallback)
|
|
251
284
|
errorCallback();
|
|
252
285
|
return !succesfulResultMandatory ? throwError(err) : this.registerErrorAndReturnEmptyObservable(err, myGuid);
|
|
253
|
-
}), finalize(() => { this.tryFinalizeByGuid(myGuid); }));
|
|
286
|
+
}), finalize(() => { this.tryFinalizeByGuid(myGuid, cachedInfos); }));
|
|
254
287
|
}
|
|
255
288
|
/**
|
|
256
289
|
* Esecuzione di una POST HTTP
|
|
@@ -465,7 +498,7 @@ class HTTPService {
|
|
|
465
498
|
* @param {string} url URL per cui controllare se ci sono chiamate in cache da invalidare
|
|
466
499
|
*/
|
|
467
500
|
checkCacheInvalidation(url) {
|
|
468
|
-
let cache =
|
|
501
|
+
let cache = this.localStorage.getLocalItem(this.localStorageHttpCacheKey);
|
|
469
502
|
let tmp = /#cache(:?-(\d+))/gi.exec(url);
|
|
470
503
|
let cacheTime = tmp ? tmp[2] : null;
|
|
471
504
|
let normalizedUrl = url.replace("#cache" + (cacheTime ? "-" + cacheTime : ""), "").replace(this.BACKEND_URL, "");
|
|
@@ -486,21 +519,53 @@ class HTTPService {
|
|
|
486
519
|
this.log(this.loc("Invlalidating cache element") + " " + k);
|
|
487
520
|
delete cache[k];
|
|
488
521
|
}
|
|
489
|
-
localStorage.setItem(this.localStorageHttpCacheKey,
|
|
522
|
+
this.localStorage.setItem(this.localStorageHttpCacheKey, cache);
|
|
490
523
|
}
|
|
491
524
|
/**
|
|
492
525
|
* Finalizzazione di una chiamata
|
|
493
526
|
*
|
|
494
527
|
* @param {string} guid GUID collegato alla chiamata appena terminata
|
|
528
|
+
* @param {boolean} persistCacheIfIdle Effettua il persist della cache HTTP solo se non ci sono altre chiamate in corso, per evitare
|
|
529
|
+
* che mi cambi sotto l'oggetto di cache mentre sto salvando le informazioni
|
|
495
530
|
*/
|
|
496
|
-
tryFinalizeByGuid(guid) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
this.ExtensionsImpl.
|
|
502
|
-
|
|
503
|
-
|
|
531
|
+
tryFinalizeByGuid(guid, cacheInfos) {
|
|
532
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
533
|
+
this.log(this.loc("Finalizing call") + " " + guid + " " + this.loc("with status") + ": " + (this.callStatus[guid] ? this.loc('Success') : this.loc('Failure')));
|
|
534
|
+
//Alla prima chiamata buona, significa che almeno il login ce l'ho. Posso mettermi in modalità redirectInProgress false
|
|
535
|
+
//e riiniziare a valutare errori di javashit
|
|
536
|
+
if (this.callStatus[guid] && this.ExtensionsImpl.readRedirectionStatus())
|
|
537
|
+
this.ExtensionsImpl.writeRedirectionStatus(false);
|
|
538
|
+
//In ogni caso questa posso rimuoverla
|
|
539
|
+
delete this.callStatus[guid];
|
|
540
|
+
// Se vengo da una chiamata che ha aggiornato la cache a timer o globale marco il fatto che quella cache dev'essere aggiornata
|
|
541
|
+
if (cacheInfos && cacheInfos.cache) {
|
|
542
|
+
this.PersistTimedCacheASAP = this.PersistTimedCacheASAP || !!cacheInfos.cacheTime;
|
|
543
|
+
this.PersistUntimedCacheASAP = this.PersistTimedCacheASAP || !cacheInfos.cacheTime;
|
|
544
|
+
this.log(this.loc("Marking cache to be persisted as soon as possible"));
|
|
545
|
+
}
|
|
546
|
+
// Se una delle due cache devono essere aggiornate e non ho nessuna chiamata in corso effettuo l'aggiornamento in base a quale delle due va aggiornata
|
|
547
|
+
// Alla fine di tutto marco come fatto
|
|
548
|
+
if ((this.PersistTimedCacheASAP || this.PersistUntimedCacheASAP) && Object.keys(this.callStatus).length == 0) {
|
|
549
|
+
var toCall = [];
|
|
550
|
+
let tmpKey = "";
|
|
551
|
+
if (this.PersistTimedCacheASAP) {
|
|
552
|
+
tmpKey = this.localStorageHttpTimedCacheKey;
|
|
553
|
+
toCall.push(this.localStorage.setItem(tmpKey, this.localStorage.getLocalItem(tmpKey)));
|
|
554
|
+
}
|
|
555
|
+
if (this.PersistUntimedCacheASAP) {
|
|
556
|
+
tmpKey = this.localStorageHttpCacheKey;
|
|
557
|
+
toCall.push(this.localStorage.setItem(tmpKey, this.localStorage.getLocalItem(tmpKey)));
|
|
558
|
+
}
|
|
559
|
+
this.log(this.loc("No more HTTP calls to be executed, entering idle state and persisting modified caches..."));
|
|
560
|
+
var ret = yield forkJoin(toCall).toPromise();
|
|
561
|
+
if (ret)
|
|
562
|
+
this.log(this.loc("Caches succesfully persisted"));
|
|
563
|
+
else
|
|
564
|
+
this.log(this.loc("Errors persisting modified caches"));
|
|
565
|
+
this.PersistTimedCacheASAP = false;
|
|
566
|
+
this.PersistUntimedCacheASAP = false;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
504
569
|
}
|
|
505
570
|
/**
|
|
506
571
|
* Helper che dato un unico File o una lista di File crea un oggetto FormData che può essere inviato comodamente
|
|
@@ -687,7 +752,7 @@ class HTTPService {
|
|
|
687
752
|
* @param {string} url URL su cui effettuare la chiamata
|
|
688
753
|
* @param {HttpParams} params Parametri della chiamata (nulli in caso di POST)
|
|
689
754
|
*
|
|
690
|
-
* @returns {
|
|
755
|
+
* @returns {CacheInfos} Oggetto contenente le informazioni sulla cache per l'oggetto specificato
|
|
691
756
|
*/
|
|
692
757
|
tryGetCacheInformations(url, params) {
|
|
693
758
|
let cachingKey = null, cacheTime = null, cache = null, item = null;
|
|
@@ -700,8 +765,8 @@ class HTTPService {
|
|
|
700
765
|
this.resetHttpUntimedCacheStorage();
|
|
701
766
|
cachingKey = this.makeCacheKey(url, params);
|
|
702
767
|
let cacheKey = cacheTime ? this.localStorageHttpTimedCacheKey : this.localStorageHttpCacheKey;
|
|
703
|
-
let cacheLs = localStorage.
|
|
704
|
-
let cache = cacheLs ?
|
|
768
|
+
let cacheLs = this.localStorage.getLocalItem(cacheKey);
|
|
769
|
+
let cache = cacheLs ? cacheLs : {};
|
|
705
770
|
if (cache && cache[cachingKey] && !this.timedCacheItemExpired(cache[cachingKey])) {
|
|
706
771
|
// Se gestisco il tempo esatto della cache prima di restituire l'oggetto cachato lo ripulisco
|
|
707
772
|
// dalle proprietà interne che gli ho aggiunto per controllarne la scadenza
|
|
@@ -710,22 +775,22 @@ class HTTPService {
|
|
|
710
775
|
item = cache[cachingKey];
|
|
711
776
|
}
|
|
712
777
|
}
|
|
713
|
-
return
|
|
778
|
+
return new CacheInfos(url, useCaching, cachingKey, cacheTime, item);
|
|
714
779
|
}
|
|
715
780
|
/**
|
|
716
781
|
* Inserisce un oggetto nella cache appropriata in base alle informazioni contenute nel parametro **cacheInfos**
|
|
717
782
|
*
|
|
718
783
|
* @param {T} item Oggetto da inserire nella cache
|
|
719
|
-
* @param {
|
|
784
|
+
* @param {CacheInfos} cacheInfos Informazioni sulla cache recuperate da una chiamata precedente a **tryGetCacheInformations**
|
|
720
785
|
*/
|
|
721
786
|
cacheResponse(item, cacheInfos) {
|
|
722
787
|
let cacheKey = cacheInfos.cacheTime ? this.localStorageHttpTimedCacheKey : this.localStorageHttpCacheKey;
|
|
723
|
-
let cacheLs = localStorage.
|
|
724
|
-
let cache = cacheLs ?
|
|
788
|
+
let cacheLs = this.localStorage.getLocalItem(cacheKey);
|
|
789
|
+
let cache = cacheLs ? cacheLs : {};
|
|
725
790
|
cache[cacheInfos.cacheKey] = item;
|
|
726
791
|
if (cacheInfos.cacheTime)
|
|
727
792
|
cache[cacheInfos.cacheKey].__expire = dayjs().add(cacheInfos.cacheTime, "seconds");
|
|
728
|
-
localStorage.
|
|
793
|
+
this.localStorage.setLocalItem(cacheKey, cache);
|
|
729
794
|
}
|
|
730
795
|
/**
|
|
731
796
|
* Controlla se la cache per le chiamate senza expire time è scaduta
|
|
@@ -751,14 +816,18 @@ class HTTPService {
|
|
|
751
816
|
*/
|
|
752
817
|
resetHttpUntimedCacheStorage() {
|
|
753
818
|
var _a;
|
|
754
|
-
|
|
755
|
-
|
|
819
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
820
|
+
yield this.localStorage.setItem(this.localStorageHttpCacheKey, {}).toPromise();
|
|
821
|
+
localStorage.setItem(this.localStorageHttpCacheExpireKey, JSON.stringify(dayjs().add((_a = this.CLIENT_CACHE_DURATION_S) !== null && _a !== void 0 ? _a : 3600, "second")));
|
|
822
|
+
});
|
|
756
823
|
}
|
|
757
824
|
/**
|
|
758
825
|
* Ripulisce la cache delle chiamate con un tempo di expire definito
|
|
759
826
|
*/
|
|
760
827
|
resetHttpTimedCacheStorage() {
|
|
761
|
-
|
|
828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
829
|
+
yield this.localStorage.setItem(this.localStorageHttpTimedCacheKey, {}).toPromise();
|
|
830
|
+
});
|
|
762
831
|
}
|
|
763
832
|
/**
|
|
764
833
|
* Genera una chiave per la cache delle chiamate in base ad URL e Parametri HTTP
|
|
@@ -770,8 +839,8 @@ class HTTPService {
|
|
|
770
839
|
*/
|
|
771
840
|
makeCacheKey(url, params) {
|
|
772
841
|
let authKeyPart = (this.me ? this.me.Idtenant : "") + (this.me && this.CACHE_BY_USER ? this.me.IdUser : "");
|
|
773
|
-
let paramsKeyPart = params && params.keys().length > 0 ? params.keys().reduce((prev, next) => prev + next + '=' + params.get(next), "") : "";
|
|
774
|
-
return authKeyPart + url + paramsKeyPart;
|
|
842
|
+
let paramsKeyPart = params && params.keys().length > 0 ? params.keys().reduce((prev, next) => prev + "," + next + '=' + params.get(next), "") : "";
|
|
843
|
+
return authKeyPart + "_" + url.substring(url.indexOf("api") + 4) + "?" + paramsKeyPart;
|
|
775
844
|
}
|
|
776
845
|
/**
|
|
777
846
|
* Generazione GUID
|
|
@@ -808,7 +877,7 @@ class HTTPService {
|
|
|
808
877
|
return Loc[message][this.LOCALE];
|
|
809
878
|
}
|
|
810
879
|
}
|
|
811
|
-
HTTPService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: HTTPService, deps: [{ token: BACKEND_URL }, { token: HttpServiceExtensions }, { token: HTTP_INVALIDATION, optional: true }, { token: HTTP_LOCALE, optional: true }, { token: APP_NAME, optional: true }, { token: CLIENT_CACHE_DURATION_S, optional: true }, { token: CACHE_BY_USER, optional: true }, { token: DEBUG_MODE, optional: true }, { token: i2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
880
|
+
HTTPService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: HTTPService, deps: [{ token: BACKEND_URL }, { token: HttpServiceExtensions }, { token: HTTP_INVALIDATION, optional: true }, { token: HTTP_LOCALE, optional: true }, { token: APP_NAME, optional: true }, { token: CLIENT_CACHE_DURATION_S, optional: true }, { token: CACHE_BY_USER, optional: true }, { token: DEBUG_MODE, optional: true }, { token: i2.HttpClient }, { token: i3.PreferencesService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
812
881
|
HTTPService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: HTTPService });
|
|
813
882
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: HTTPService, decorators: [{
|
|
814
883
|
type: Injectable
|
|
@@ -846,7 +915,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
846
915
|
}, {
|
|
847
916
|
type: Inject,
|
|
848
917
|
args: [DEBUG_MODE]
|
|
849
|
-
}] }, { type: i2.HttpClient }];
|
|
918
|
+
}] }, { type: i2.HttpClient }, { type: i3.PreferencesService }];
|
|
850
919
|
} });
|
|
851
920
|
|
|
852
921
|
class HttpserviceModule {
|