@esfaenza/httpservice 19.2.10 → 19.2.12
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/esfaenza-httpservice.mjs +152 -51
- package/fesm2022/esfaenza-httpservice.mjs.map +1 -1
- package/index.d.ts +588 -3
- package/package.json +2 -6
- package/lib/config/HttpServiceExtensions.d.ts +0 -65
- package/lib/config/HttpServiceModuleConfig.d.ts +0 -25
- package/lib/config/IHttpServiceExtensions.d.ts +0 -61
- package/lib/httpservice.module.d.ts +0 -9
- package/lib/httpservice.service.d.ts +0 -379
- package/lib/models/CacheInfos.d.ts +0 -8
- package/lib/models/Download.d.ts +0 -5
- package/lib/tokens.d.ts +0 -21
- package/public-api.d.ts +0 -7
|
@@ -3,10 +3,9 @@ import { InjectionToken, Injectable, Optional, Inject, NgModule } from '@angular
|
|
|
3
3
|
import * as i3 from '@angular/common/http';
|
|
4
4
|
import { HttpEventType, HttpHeaders, HttpErrorResponse, HttpParams } from '@angular/common/http';
|
|
5
5
|
import { first, concatMap, delay, finalize, map, catchError, scan } from 'rxjs/operators';
|
|
6
|
-
import { Subject, forkJoin,
|
|
6
|
+
import { Subject, forkJoin, of, from, throwError, Observable } from 'rxjs';
|
|
7
7
|
import * as i2 from '@esfaenza/localizations';
|
|
8
8
|
import * as i4 from '@esfaenza/preferences';
|
|
9
|
-
import * as i5 from '@esfaenza/extensions';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Dizionario di invalidazioni delle chiamate HTTP
|
|
@@ -106,10 +105,10 @@ class HttpServiceExtensions {
|
|
|
106
105
|
handleException(status, text) {
|
|
107
106
|
console.error("ESHttpError " + status + " " + text);
|
|
108
107
|
}
|
|
109
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
110
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
108
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpServiceExtensions, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
109
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpServiceExtensions, providedIn: 'root' }); }
|
|
111
110
|
}
|
|
112
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpServiceExtensions, decorators: [{
|
|
113
112
|
type: Injectable,
|
|
114
113
|
args: [{ providedIn: 'root' }]
|
|
115
114
|
}] });
|
|
@@ -133,7 +132,7 @@ class HTTPService {
|
|
|
133
132
|
/**
|
|
134
133
|
* @ignore
|
|
135
134
|
*/
|
|
136
|
-
constructor(EXTENSION_CLASS, HTTP_INVALIDATION, CLIENT_CACHE_DURATION_S, CACHE_BY_USER, HTTP_DEBUG_MODE, bc, http, localStorage
|
|
135
|
+
constructor(EXTENSION_CLASS, HTTP_INVALIDATION, CLIENT_CACHE_DURATION_S, CACHE_BY_USER, HTTP_DEBUG_MODE, bc, http, localStorage) {
|
|
137
136
|
this.EXTENSION_CLASS = EXTENSION_CLASS;
|
|
138
137
|
this.HTTP_INVALIDATION = HTTP_INVALIDATION;
|
|
139
138
|
this.CLIENT_CACHE_DURATION_S = CLIENT_CACHE_DURATION_S;
|
|
@@ -142,8 +141,6 @@ class HTTPService {
|
|
|
142
141
|
this.bc = bc;
|
|
143
142
|
this.http = http;
|
|
144
143
|
this.localStorage = localStorage;
|
|
145
|
-
this.hash = hash;
|
|
146
|
-
this.utisExts = utisExts;
|
|
147
144
|
/** Cache dello stato delle chiamate HTTP attualmente effettuate. Ogni chiamata è rappresentata da un GUID e lo status assume valore **false** solo sugli errori */
|
|
148
145
|
this.callStatus = {};
|
|
149
146
|
/** Nome della cache in cui vengono storicizzate le informazioni sulle risposte delle chiamate sotto forma di dictionary */
|
|
@@ -169,6 +166,17 @@ class HTTPService {
|
|
|
169
166
|
this.GET_Trans_BeginTrans = "/api/Trans/BeginTrans";
|
|
170
167
|
this.GET_Trans_CheckExecution = "/api/Trans/CheckExecution";
|
|
171
168
|
this.GET_Trans_EndTrans = "/api/Trans/EndTrans";
|
|
169
|
+
/*****************************************************************************************************************************************
|
|
170
|
+
***************************************************** ROBA PER HASHING ******************************************************************
|
|
171
|
+
*****************************************************************************************************************************************/
|
|
172
|
+
/**
|
|
173
|
+
* Blacklist dei tipi da ignorare quando si effettua l'hashing degli oggetti
|
|
174
|
+
*/
|
|
175
|
+
this.objBlacklist = {
|
|
176
|
+
"NgForm": true, "ElementRef": true, "ExtensionsService": true, "ToastrService": true, "LocaleService": true, "AppState": true, "Router": true,
|
|
177
|
+
"ActivatedRoute": true, "HTTPService": true, "Location": true, "CanvasComponent": true, "ModalDirective": true, "ChangeDetectorRef": true,
|
|
178
|
+
"DateService": true, "EventEmitter": true, "ViewRef_": true, "Subscriber": true, "ItemLocalization": true
|
|
179
|
+
};
|
|
172
180
|
this.ExtensionsImpl = this.EXTENSION_CLASS || new HttpServiceExtensions();
|
|
173
181
|
}
|
|
174
182
|
setAppConfig(myconfig) {
|
|
@@ -191,12 +199,16 @@ class HTTPService {
|
|
|
191
199
|
localStorage.removeItem(this.localStorageHttpCacheKey);
|
|
192
200
|
lsTimed = lsTimed ? JSON.parse(lsTimed) : {};
|
|
193
201
|
lsUntimed = lsUntimed ? JSON.parse(lsUntimed) : {};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
if (this.localStorage)
|
|
203
|
+
await forkJoin([
|
|
204
|
+
this.localStorage.setItem(this.localStorageHttpTimedCacheKey, lsTimed),
|
|
205
|
+
this.localStorage.setItem(this.localStorageHttpCacheKey, lsUntimed)
|
|
206
|
+
]).toPromise();
|
|
198
207
|
this.log(this.loc("Converted old storage system to new one"));
|
|
199
208
|
}
|
|
209
|
+
getlocaleObservable() {
|
|
210
|
+
return this.bc ? this.bc.Locale.pipe(first()) : of("it-IT");
|
|
211
|
+
}
|
|
200
212
|
/**
|
|
201
213
|
* Esecuzione di una GET HTTP con eventualmente la gestione della cache qualora la chiamata termini con la convenzione "#cache"
|
|
202
214
|
*
|
|
@@ -212,7 +224,7 @@ class HTTPService {
|
|
|
212
224
|
get(url, params = null, transaction = "", succesfulResultMandatory = true, errorCallback = null) {
|
|
213
225
|
return forkJoin({
|
|
214
226
|
myGuid: from([this.defaultStartCall(url)]),
|
|
215
|
-
locale: this.
|
|
227
|
+
locale: this.getlocaleObservable()
|
|
216
228
|
}).pipe(concatMap((ret) => {
|
|
217
229
|
let cachedInfos = this.tryGetCacheInformations(url, params);
|
|
218
230
|
if (cachedInfos.cache && cachedInfos.cacheItem) {
|
|
@@ -223,7 +235,8 @@ class HTTPService {
|
|
|
223
235
|
return httpCall.pipe(map((res) => {
|
|
224
236
|
let responseItem = res;
|
|
225
237
|
if (cachedInfos.cache) {
|
|
226
|
-
|
|
238
|
+
let toCache = JSON.parse(JSON.stringify(responseItem));
|
|
239
|
+
this.cacheResponse(toCache, cachedInfos);
|
|
227
240
|
this.log(this.loc("Cached result for") + " " + url);
|
|
228
241
|
}
|
|
229
242
|
return responseItem;
|
|
@@ -252,7 +265,7 @@ class HTTPService {
|
|
|
252
265
|
getRaw(url, params = null, type = "arraybuffer", transaction = "", succesfulResultMandatory = true, errorCallback = null) {
|
|
253
266
|
return forkJoin({
|
|
254
267
|
myGuid: from([this.defaultStartCall(url)]),
|
|
255
|
-
locale: this.
|
|
268
|
+
locale: this.getlocaleObservable()
|
|
256
269
|
}).pipe(concatMap((ret) => {
|
|
257
270
|
let cachedInfos = this.tryGetCacheInformations(url, params);
|
|
258
271
|
if (cachedInfos.cache && cachedInfos.cacheItem) {
|
|
@@ -288,7 +301,7 @@ class HTTPService {
|
|
|
288
301
|
post(url, bodyData, params = null, transaction = "", succesfulResultMandatory = true) {
|
|
289
302
|
return forkJoin({
|
|
290
303
|
myGuid: from([this.defaultStartCall(url)]),
|
|
291
|
-
locale: this.
|
|
304
|
+
locale: this.getlocaleObservable()
|
|
292
305
|
}).pipe(concatMap((ret) => {
|
|
293
306
|
// Se è una ricerca, shallow copy e rimuovo gli "items" per evitare di farli andare su e giù al backend
|
|
294
307
|
if (!!bodyData?.items && !!bodyData?.page) {
|
|
@@ -315,7 +328,7 @@ class HTTPService {
|
|
|
315
328
|
delete(url, params = null, transaction = "", succesfulResultMandatory = true) {
|
|
316
329
|
return forkJoin({
|
|
317
330
|
myGuid: from([this.defaultStartCall(url)]),
|
|
318
|
-
locale: this.
|
|
331
|
+
locale: this.getlocaleObservable()
|
|
319
332
|
}).pipe(concatMap((ret) => {
|
|
320
333
|
var httpCall = this.http.delete(url, { headers: this.getHeaders(ret.locale, transaction), params: params });
|
|
321
334
|
return httpCall.pipe(catchError((err, caught) => {
|
|
@@ -338,7 +351,7 @@ class HTTPService {
|
|
|
338
351
|
put(url, bodyData, params = null, transaction = "", succesfulResultMandatory = true) {
|
|
339
352
|
return forkJoin({
|
|
340
353
|
myGuid: from([this.defaultStartCall(url)]),
|
|
341
|
-
locale: this.
|
|
354
|
+
locale: this.getlocaleObservable()
|
|
342
355
|
}).pipe(concatMap((ret) => {
|
|
343
356
|
var httpCall = this.http.put(url, bodyData, { headers: this.getHeaders(ret.locale, transaction), params: params });
|
|
344
357
|
return httpCall.pipe(catchError((err, caught) => {
|
|
@@ -360,7 +373,7 @@ class HTTPService {
|
|
|
360
373
|
postwithFiles(url, bodyData, fileArrayOrFile, params = null, succesfulResultMandatory = true, onError) {
|
|
361
374
|
return forkJoin({
|
|
362
375
|
myGuid: from([this.defaultStartCall(url)]),
|
|
363
|
-
locale: this.
|
|
376
|
+
locale: this.getlocaleObservable()
|
|
364
377
|
}).pipe(concatMap((ret) => {
|
|
365
378
|
var formData = this.getFilesFormData(fileArrayOrFile);
|
|
366
379
|
formData.append("body", JSON.stringify(bodyData));
|
|
@@ -386,7 +399,7 @@ class HTTPService {
|
|
|
386
399
|
*/
|
|
387
400
|
async postGetFile(url, bodyData, filename, getFileCallback, afterGetFile = null, handleError = true, pars) {
|
|
388
401
|
let myGuid = this.defaultStartCall(url);
|
|
389
|
-
let locale = await this.
|
|
402
|
+
let locale = await this.getlocaleObservable().toPromise();
|
|
390
403
|
this.http.post(url, bodyData, { params: pars, headers: this.getHeaders(locale), observe: 'response', responseType: "blob" }).pipe(catchError((err, caught) => {
|
|
391
404
|
if (afterGetFile && !handleError)
|
|
392
405
|
afterGetFile();
|
|
@@ -414,7 +427,7 @@ class HTTPService {
|
|
|
414
427
|
*/
|
|
415
428
|
async getFile(url, params = null, filename, getFileCallback, afterGetFile = null, handleError = true) {
|
|
416
429
|
let myGuid = this.defaultStartCall(url);
|
|
417
|
-
let locale = await this.
|
|
430
|
+
let locale = await this.getlocaleObservable().toPromise();
|
|
418
431
|
this.http.get(url, { params: params, headers: this.getHeaders(locale), observe: 'response', responseType: "blob" }).pipe(catchError((err, caught) => {
|
|
419
432
|
if (afterGetFile && !handleError)
|
|
420
433
|
afterGetFile();
|
|
@@ -457,7 +470,7 @@ class HTTPService {
|
|
|
457
470
|
getFileWithProgress(url, params = null, getFileCallback) {
|
|
458
471
|
return forkJoin({
|
|
459
472
|
myGuid: from([this.defaultStartCall(url)]),
|
|
460
|
-
locale: this.
|
|
473
|
+
locale: this.getlocaleObservable()
|
|
461
474
|
}).pipe(concatMap((ret) => {
|
|
462
475
|
return this.http.get(url, { responseType: 'blob', headers: this.getHeaders(ret.locale), params: params, observe: 'events', reportProgress: true })
|
|
463
476
|
.pipe(scan((previous, event) => {
|
|
@@ -512,7 +525,7 @@ class HTTPService {
|
|
|
512
525
|
checkCacheInvalidation(url) {
|
|
513
526
|
if (!this.CacheInitialized)
|
|
514
527
|
return;
|
|
515
|
-
let cache = this.localStorage
|
|
528
|
+
let cache = (this.localStorage?.getLocalItem)?.(this.localStorageHttpCacheKey);
|
|
516
529
|
let tmp = /#cache(:?-(\d+))/gi.exec(url);
|
|
517
530
|
let cacheTime = tmp ? tmp[2] : null;
|
|
518
531
|
let normalizedUrl_tmp = url.replace("#cache" + (cacheTime ? "-" + cacheTime : ""), "");
|
|
@@ -534,7 +547,7 @@ class HTTPService {
|
|
|
534
547
|
this.log(this.loc("Invlalidating cache element") + " " + k);
|
|
535
548
|
delete cache[k];
|
|
536
549
|
}
|
|
537
|
-
this.localStorage
|
|
550
|
+
this.localStorage?.setItem?.(this.localStorageHttpCacheKey, cache);
|
|
538
551
|
}
|
|
539
552
|
/**
|
|
540
553
|
* Finalizzazione di una chiamata
|
|
@@ -572,11 +585,11 @@ class HTTPService {
|
|
|
572
585
|
if ((this.PersistTimedCacheASAP || this.PersistUntimedCacheASAP) && Object.keys(this.callStatus).length == 0 && this.CacheInitialized) {
|
|
573
586
|
var toCall = [];
|
|
574
587
|
let tmpKey = "";
|
|
575
|
-
if (this.PersistTimedCacheASAP) {
|
|
588
|
+
if (this.PersistTimedCacheASAP && this.localStorage) {
|
|
576
589
|
tmpKey = this.localStorageHttpTimedCacheKey;
|
|
577
590
|
toCall.push(this.localStorage.setItem(tmpKey, this.localStorage.getLocalItem(tmpKey)));
|
|
578
591
|
}
|
|
579
|
-
if (this.PersistUntimedCacheASAP) {
|
|
592
|
+
if (this.PersistUntimedCacheASAP && this.localStorage) {
|
|
580
593
|
tmpKey = this.localStorageHttpCacheKey;
|
|
581
594
|
toCall.push(this.localStorage.setItem(tmpKey, this.localStorage.getLocalItem(tmpKey)));
|
|
582
595
|
}
|
|
@@ -694,7 +707,7 @@ class HTTPService {
|
|
|
694
707
|
this.ExtensionsImpl.handleBlockingException(res.status, finalError);
|
|
695
708
|
return;
|
|
696
709
|
case 0:
|
|
697
|
-
finalError = `Generic connection error while calling '[${guid}] - ${this.callStatus[guid].url}' at ${
|
|
710
|
+
finalError = `Generic connection error while calling '[${guid}] - ${this.callStatus[guid].url}' at ${new Date().toISOString()}. Response: ${JSON.stringify(res)}`;
|
|
698
711
|
}
|
|
699
712
|
}
|
|
700
713
|
this.ExtensionsImpl.handleException(finalStatus, finalError);
|
|
@@ -786,9 +799,9 @@ class HTTPService {
|
|
|
786
799
|
this.resetHttpUntimedCacheStorage();
|
|
787
800
|
cachingKey = this.makeCacheKey(url, params);
|
|
788
801
|
let cacheKey = cacheTime ? this.localStorageHttpTimedCacheKey : this.localStorageHttpCacheKey;
|
|
789
|
-
let cacheLs = this.localStorage
|
|
802
|
+
let cacheLs = this.localStorage?.getLocalItem?.(cacheKey);
|
|
790
803
|
let cache = cacheLs ? cacheLs : {};
|
|
791
|
-
if (cache && cache[cachingKey] && !this.timedCacheItemExpired(cache[cachingKey])) {
|
|
804
|
+
if (cache && cache[cachingKey] && !this.timedCacheItemExpired(cache[cachingKey].__expire)) {
|
|
792
805
|
// Se gestisco il tempo esatto della cache prima di restituire l'oggetto cachato lo ripulisco
|
|
793
806
|
// dalle proprietà interne che gli ho aggiunto per controllarne la scadenza
|
|
794
807
|
if (cacheTime)
|
|
@@ -797,7 +810,8 @@ class HTTPService {
|
|
|
797
810
|
}
|
|
798
811
|
}
|
|
799
812
|
// Per assicurarmi che il rifeirmento degli oggetti sia diverso utilizzo il deepClone
|
|
800
|
-
|
|
813
|
+
let toCache = JSON.parse(JSON.stringify(item));
|
|
814
|
+
return new CacheInfos(url, useCaching && this.CacheInitialized, cachingKey, cacheTime, toCache);
|
|
801
815
|
}
|
|
802
816
|
/**
|
|
803
817
|
* Inserisce un oggetto nella cache appropriata in base alle informazioni contenute nel parametro **cacheInfos**
|
|
@@ -807,12 +821,15 @@ class HTTPService {
|
|
|
807
821
|
*/
|
|
808
822
|
cacheResponse(item, cacheInfos) {
|
|
809
823
|
let cacheKey = cacheInfos.cacheTime ? this.localStorageHttpTimedCacheKey : this.localStorageHttpCacheKey;
|
|
810
|
-
let cacheLs = this.localStorage
|
|
824
|
+
let cacheLs = this.localStorage?.getLocalItem?.(cacheKey);
|
|
811
825
|
let cache = cacheLs ? cacheLs : {};
|
|
812
826
|
cache[cacheInfos.cacheKey] = item;
|
|
813
|
-
if (cacheInfos.cacheTime)
|
|
814
|
-
|
|
815
|
-
|
|
827
|
+
if (cacheInfos.cacheTime) {
|
|
828
|
+
let date = new Date();
|
|
829
|
+
date.setSeconds(date.getSeconds() + parseInt(cacheInfos.cacheTime));
|
|
830
|
+
cache[cacheInfos.cacheKey].__expire = date;
|
|
831
|
+
}
|
|
832
|
+
this.localStorage?.setLocalItem?.(cacheKey, cache);
|
|
816
833
|
}
|
|
817
834
|
/**
|
|
818
835
|
* Controlla se la cache per le chiamate senza expire time è scaduta
|
|
@@ -821,7 +838,7 @@ class HTTPService {
|
|
|
821
838
|
*/
|
|
822
839
|
untimedCacheExpired() {
|
|
823
840
|
let expire = JSON.parse(localStorage.getItem(this.localStorageHttpCacheExpireKey));
|
|
824
|
-
return !expire || expire &&
|
|
841
|
+
return !expire || (expire && this.timedCacheItemExpired(expire));
|
|
825
842
|
}
|
|
826
843
|
/**
|
|
827
844
|
* Controlla se la cache per una chiamata che ha un tempo di vita ben definito è scaduta o meno
|
|
@@ -830,23 +847,25 @@ class HTTPService {
|
|
|
830
847
|
*
|
|
831
848
|
* @returns {boolean} **true** se la cache è scaduta e dev'essere ripulita, **false** altrimenti
|
|
832
849
|
*/
|
|
833
|
-
timedCacheItemExpired(
|
|
834
|
-
return
|
|
850
|
+
timedCacheItemExpired(dtCheck) {
|
|
851
|
+
return new Date(dtCheck) < new Date();
|
|
835
852
|
}
|
|
836
853
|
/**
|
|
837
854
|
* Ripulisce la cache e imposta la prossima scadenza ad adesso + **CLIENT_CACHE_DURATION_S** (token valorizzato in fase di configurazione dalla proprietà **clientCacheDurationS** della classe **HttpServiceModuleConfig**)
|
|
838
855
|
*/
|
|
839
856
|
async resetHttpUntimedCacheStorage() {
|
|
840
|
-
if (!this.CacheInitialized)
|
|
857
|
+
if (!this.CacheInitialized || !this.localStorage)
|
|
841
858
|
return;
|
|
842
859
|
await this.localStorage.setItem(this.localStorageHttpCacheKey, {}).toPromise();
|
|
843
|
-
|
|
860
|
+
let date = new Date();
|
|
861
|
+
date.setSeconds(date.getSeconds() + (this.CLIENT_CACHE_DURATION_S ?? 3600));
|
|
862
|
+
localStorage.setItem(this.localStorageHttpCacheExpireKey, JSON.stringify(date));
|
|
844
863
|
}
|
|
845
864
|
/**
|
|
846
865
|
* Ripulisce la cache delle chiamate con un tempo di expire definito
|
|
847
866
|
*/
|
|
848
867
|
async resetHttpTimedCacheStorage() {
|
|
849
|
-
if (!this.CacheInitialized)
|
|
868
|
+
if (!this.CacheInitialized || !this.localStorage)
|
|
850
869
|
return;
|
|
851
870
|
await this.localStorage.setItem(this.localStorageHttpTimedCacheKey, {}).toPromise();
|
|
852
871
|
}
|
|
@@ -901,17 +920,22 @@ class HTTPService {
|
|
|
901
920
|
getAll(view, api, pars, transaction) {
|
|
902
921
|
if (!view.selection.all)
|
|
903
922
|
return of(view.selection.items);
|
|
904
|
-
var jsonView =
|
|
923
|
+
var jsonView = JSON.parse(JSON.stringify(view));
|
|
905
924
|
jsonView.page = 1;
|
|
906
925
|
jsonView.itemsperpageoverride = 999999;
|
|
907
926
|
return this.post(api, jsonView, pars, transaction).pipe(map(res => {
|
|
908
927
|
let items = res.items;
|
|
909
|
-
items.forEach(t => t.hash = this.
|
|
928
|
+
items.forEach(t => t.hash = this.hashObject(t));
|
|
910
929
|
if (res.selection.exclusions?.length > 0)
|
|
911
|
-
items = items.filter((t) => !res.selection.exclusions.find((e) => this.
|
|
930
|
+
items = items.filter((t) => !res.selection.exclusions.find((e) => this.hashObject(e) == t.hash));
|
|
912
931
|
return items;
|
|
913
932
|
}));
|
|
914
933
|
}
|
|
934
|
+
hashObject(o, level = 0) {
|
|
935
|
+
var strDef = this.stringify(o, level);
|
|
936
|
+
var hash = this.simpleHash(strDef);
|
|
937
|
+
return hash;
|
|
938
|
+
}
|
|
915
939
|
beginTransaction(executionKey, secondsTimeout) {
|
|
916
940
|
this.log("beginTransaction call received: " + executionKey);
|
|
917
941
|
var pars = new HttpParams().set("executionKey", executionKey);
|
|
@@ -928,10 +952,77 @@ class HTTPService {
|
|
|
928
952
|
let pars = new HttpParams().set("idtrans", transactionKey).set("success", transactionResult.toString());
|
|
929
953
|
return this.get(this.GET_Trans_EndTrans, pars);
|
|
930
954
|
}
|
|
931
|
-
|
|
932
|
-
|
|
955
|
+
/**
|
|
956
|
+
* Hash più semplice e più veloce dell'md5, ma meno sicuro
|
|
957
|
+
*
|
|
958
|
+
* Vedi https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
|
959
|
+
*
|
|
960
|
+
* @param {string} str Stringa di cui calcolare l'hash
|
|
961
|
+
*/
|
|
962
|
+
simpleHash(str, seed = 0) {
|
|
963
|
+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
964
|
+
for (let i = 0, ch; i < str.length; i++) {
|
|
965
|
+
ch = str.charCodeAt(i);
|
|
966
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
967
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
968
|
+
}
|
|
969
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
970
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
971
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString();
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Genera una stringa che identifica univocamente l'oggetto in questione
|
|
975
|
+
*
|
|
976
|
+
* @param {any} o Oggetto di cui calcolare la stringa univoca
|
|
977
|
+
* @param {number} level Livello di ricorsione nel caso venga effettuato l'hash di un oggetto che contiene altri oggetti
|
|
978
|
+
* @param {boolean} navigateFullDepth Indica se navigare l'oggetto per l'intera lunghezza. In caso contrario si ferma al secondo livello
|
|
979
|
+
*/
|
|
980
|
+
stringify(o, level) {
|
|
981
|
+
var i, r;
|
|
982
|
+
if (o === null)
|
|
983
|
+
return "n";
|
|
984
|
+
if (o === true)
|
|
985
|
+
return "t";
|
|
986
|
+
if (o === false)
|
|
987
|
+
return "f";
|
|
988
|
+
if (o instanceof Date)
|
|
989
|
+
return 'd:' + o.valueOf().toString();
|
|
990
|
+
i = typeof o;
|
|
991
|
+
if (i === "string")
|
|
992
|
+
return "s:" + o;
|
|
993
|
+
if (i === "number")
|
|
994
|
+
return "n:" + o;
|
|
995
|
+
if (o instanceof Function)
|
|
996
|
+
return "m:" + o.toString();
|
|
997
|
+
if (o instanceof Array) {
|
|
998
|
+
r = [];
|
|
999
|
+
for (i = 0; i < o.length; i++) {
|
|
1000
|
+
let res = this.stringify(o[i], level);
|
|
1001
|
+
if (res)
|
|
1002
|
+
r.push(res);
|
|
1003
|
+
}
|
|
1004
|
+
return r.length > 0 ? "a:" + r.join(";") : "";
|
|
1005
|
+
}
|
|
1006
|
+
r = [];
|
|
1007
|
+
//Se è oggetto, escludo tutti quelli di sistema/inutili
|
|
1008
|
+
if (o) {
|
|
1009
|
+
var name = o.__proto__.constructor.name;
|
|
1010
|
+
if (!this.objBlacklist[name]) {
|
|
1011
|
+
for (i in o) {
|
|
1012
|
+
if (o.hasOwnProperty(i) && (level <= 2)) {
|
|
1013
|
+
let res = this.stringify(o[i], level + 1);
|
|
1014
|
+
if (res)
|
|
1015
|
+
r.push(i + ":" + res);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
return r.length > 0 ? "o:" + r.join(";") : "";
|
|
1021
|
+
}
|
|
1022
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HTTPService, deps: [{ token: HttpServiceExtensions }, { token: HTTP_INVALIDATION, optional: true }, { token: CLIENT_CACHE_DURATION_S, optional: true }, { token: CACHE_BY_USER, optional: true }, { token: HTTP_DEBUG_MODE, optional: true }, { token: i2.BaseLocalization, optional: true }, { token: i3.HttpClient }, { token: i4.CacheService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1023
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HTTPService, providedIn: 'root' }); }
|
|
933
1024
|
}
|
|
934
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1025
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HTTPService, decorators: [{
|
|
935
1026
|
type: Injectable,
|
|
936
1027
|
args: [{ providedIn: 'root' }]
|
|
937
1028
|
}], ctorParameters: () => [{ type: HttpServiceExtensions }, { type: undefined, decorators: [{
|
|
@@ -940,15 +1031,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
940
1031
|
type: Inject,
|
|
941
1032
|
args: [HTTP_INVALIDATION]
|
|
942
1033
|
}] }, { type: undefined, decorators: [{
|
|
1034
|
+
type: Optional
|
|
1035
|
+
}, {
|
|
943
1036
|
type: Inject,
|
|
944
1037
|
args: [CLIENT_CACHE_DURATION_S]
|
|
945
1038
|
}] }, { type: undefined, decorators: [{
|
|
1039
|
+
type: Optional
|
|
1040
|
+
}, {
|
|
946
1041
|
type: Inject,
|
|
947
1042
|
args: [CACHE_BY_USER]
|
|
948
1043
|
}] }, { type: undefined, decorators: [{
|
|
1044
|
+
type: Optional
|
|
1045
|
+
}, {
|
|
949
1046
|
type: Inject,
|
|
950
1047
|
args: [HTTP_DEBUG_MODE]
|
|
951
|
-
}] }, { type: i2.BaseLocalization
|
|
1048
|
+
}] }, { type: i2.BaseLocalization, decorators: [{
|
|
1049
|
+
type: Optional
|
|
1050
|
+
}] }, { type: i3.HttpClient }, { type: i4.CacheService, decorators: [{
|
|
1051
|
+
type: Optional
|
|
1052
|
+
}] }] });
|
|
952
1053
|
|
|
953
1054
|
class HttpserviceModule {
|
|
954
1055
|
static forRoot(config) {
|
|
@@ -962,11 +1063,11 @@ class HttpserviceModule {
|
|
|
962
1063
|
]
|
|
963
1064
|
};
|
|
964
1065
|
}
|
|
965
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
966
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
967
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1066
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpserviceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1067
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.2", ngImport: i0, type: HttpserviceModule }); }
|
|
1068
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpserviceModule }); }
|
|
968
1069
|
}
|
|
969
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1070
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: HttpserviceModule, decorators: [{
|
|
970
1071
|
type: NgModule
|
|
971
1072
|
}] });
|
|
972
1073
|
|