@esfaenza/httpservice 11.2.46 → 11.2.47

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.
@@ -557,25 +557,27 @@
557
557
  if (transaction === void 0) { transaction = ""; }
558
558
  if (succesfulResultMandatory === void 0) { succesfulResultMandatory = true; }
559
559
  if (errorCallback === void 0) { errorCallback = null; }
560
- var myGuid = this.defaultStartCall(url);
561
- var cachedInfos = this.tryGetCacheInformations(url, params);
562
- if (cachedInfos.cache && cachedInfos.cacheItem) {
563
- this.log(this.loc("Result for") + " " + url + " " + this.loc("retrieved from cache"));
564
- return rxjs.of(cachedInfos.cacheItem).pipe(operators.delay(0), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
565
- }
566
- var httpCall = this.http.get(cachedInfos.finalUrl, { headers: this.getHeaders(transaction), params: params });
567
- return httpCall.pipe(operators.map(function (res) {
568
- var responseItem = res;
569
- if (cachedInfos.cache) {
570
- _this.cacheResponse(_this.utisExts.deepClone(responseItem), cachedInfos);
571
- _this.log(_this.loc("Cached result for") + " " + url);
560
+ // TODO provare e testare
561
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
562
+ var cachedInfos = _this.tryGetCacheInformations(url, params);
563
+ if (cachedInfos.cache && cachedInfos.cacheItem) {
564
+ _this.log(_this.loc("Result for") + " " + url + " " + _this.loc("retrieved from cache"));
565
+ return rxjs.of(cachedInfos.cacheItem).pipe(operators.delay(0), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
572
566
  }
573
- return responseItem;
574
- }), operators.catchError(function (err, caught) {
575
- if (errorCallback)
576
- errorCallback();
577
- return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
578
- }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid, cachedInfos); }));
567
+ var httpCall = _this.http.get(cachedInfos.finalUrl, { headers: _this.getHeaders(transaction), params: params });
568
+ return httpCall.pipe(operators.map(function (res) {
569
+ var responseItem = res;
570
+ if (cachedInfos.cache) {
571
+ _this.cacheResponse(_this.utisExts.deepClone(responseItem), cachedInfos);
572
+ _this.log(_this.loc("Cached result for") + " " + url);
573
+ }
574
+ return responseItem;
575
+ }), operators.catchError(function (err, caught) {
576
+ if (errorCallback)
577
+ errorCallback();
578
+ return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
579
+ }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid, cachedInfos); }));
580
+ }));
579
581
  };
580
582
  /**
581
583
  * Esecuzione di una GET HTTP con eventualmente la gestione della cache qualora la chiamata termini con la convenzione "#cache"
@@ -599,24 +601,25 @@
599
601
  if (transaction === void 0) { transaction = ""; }
600
602
  if (succesfulResultMandatory === void 0) { succesfulResultMandatory = true; }
601
603
  if (errorCallback === void 0) { errorCallback = null; }
602
- var myGuid = this.defaultStartCall(url);
603
- var cachedInfos = this.tryGetCacheInformations(url, params);
604
- if (cachedInfos.cache && cachedInfos.cacheItem) {
605
- this.log(this.loc("Result for") + " " + url + " " + this.loc("retrieved from cache"));
606
- return rxjs.of(cachedInfos.cacheItem).pipe(operators.delay(0), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
607
- }
608
- var httpCall = this.http.get(cachedInfos.finalUrl, { responseType: type, headers: this.getHeaders(transaction), params: params });
609
- return httpCall.pipe(operators.map(function (blob) {
610
- if (cachedInfos.cache) {
611
- _this.cacheResponse(blob, cachedInfos);
612
- _this.log(_this.loc("Cached result for") + " " + url);
604
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
605
+ var cachedInfos = _this.tryGetCacheInformations(url, params);
606
+ if (cachedInfos.cache && cachedInfos.cacheItem) {
607
+ _this.log(_this.loc("Result for") + " " + url + " " + _this.loc("retrieved from cache"));
608
+ return rxjs.of(cachedInfos.cacheItem).pipe(operators.delay(0), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
613
609
  }
614
- return blob;
615
- }), operators.catchError(function (err, caught) {
616
- if (errorCallback)
617
- errorCallback();
618
- return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
619
- }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid, cachedInfos); }));
610
+ var httpCall = _this.http.get(cachedInfos.finalUrl, { responseType: type, headers: _this.getHeaders(transaction), params: params });
611
+ return httpCall.pipe(operators.map(function (blob) {
612
+ if (cachedInfos.cache) {
613
+ _this.cacheResponse(blob, cachedInfos);
614
+ _this.log(_this.loc("Cached result for") + " " + url);
615
+ }
616
+ return blob;
617
+ }), operators.catchError(function (err, caught) {
618
+ if (errorCallback)
619
+ errorCallback();
620
+ return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
621
+ }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid, cachedInfos); }));
622
+ }));
620
623
  };
621
624
  /**
622
625
  * Esecuzione di una POST HTTP
@@ -635,14 +638,12 @@
635
638
  if (params === void 0) { params = null; }
636
639
  if (transaction === void 0) { transaction = ""; }
637
640
  if (succesfulResultMandatory === void 0) { succesfulResultMandatory = true; }
638
- var myGuid = this.defaultStartCall(url);
639
- var httpCall = this.http.post(url, bodyData, { headers: this.getHeaders(transaction), params: params });
640
- return httpCall.pipe(operators.map(function (res) {
641
- var responseItem = res;
642
- return responseItem;
643
- }), operators.catchError(function (err, caught) {
644
- return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
645
- }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
641
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
642
+ var httpCall = _this.http.post(url, bodyData, { headers: _this.getHeaders(transaction), params: params });
643
+ return httpCall.pipe(operators.catchError(function (err, caught) {
644
+ return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
645
+ }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
646
+ }));
646
647
  };
647
648
  /**
648
649
  * Esecuzione di una DELETE HTTP
@@ -660,14 +661,12 @@
660
661
  if (params === void 0) { params = null; }
661
662
  if (transaction === void 0) { transaction = ""; }
662
663
  if (succesfulResultMandatory === void 0) { succesfulResultMandatory = true; }
663
- var myGuid = this.defaultStartCall(url);
664
- var httpCall = this.http.delete(url, { headers: this.getHeaders(transaction), params: params });
665
- return httpCall.pipe(operators.map(function (res) {
666
- var responseItem = res;
667
- return responseItem;
668
- }), operators.catchError(function (err, caught) {
669
- return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
670
- }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
664
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
665
+ var httpCall = _this.http.delete(url, { headers: _this.getHeaders(transaction), params: params });
666
+ return httpCall.pipe(operators.catchError(function (err, caught) {
667
+ return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
668
+ }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
669
+ }));
671
670
  };
672
671
  /**
673
672
  * Esecuzione di una PUT HTTP
@@ -686,14 +685,12 @@
686
685
  if (params === void 0) { params = null; }
687
686
  if (transaction === void 0) { transaction = ""; }
688
687
  if (succesfulResultMandatory === void 0) { succesfulResultMandatory = true; }
689
- var myGuid = this.defaultStartCall(url);
690
- var httpCall = this.http.put(url, bodyData, { headers: this.getHeaders(transaction), params: params });
691
- return httpCall.pipe(operators.map(function (res) {
692
- var responseItem = res;
693
- return responseItem;
694
- }), operators.catchError(function (err, caught) {
695
- return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
696
- }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
688
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
689
+ var httpCall = _this.http.put(url, bodyData, { headers: _this.getHeaders(transaction), params: params });
690
+ return httpCall.pipe(operators.catchError(function (err, caught) {
691
+ return !succesfulResultMandatory ? rxjs.throwError(err) : _this.registerErrorAndReturnEmptyObservable(err, myGuid);
692
+ }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
693
+ }));
697
694
  };
698
695
  /**
699
696
  * Esecuzione di una POST HTTP
@@ -708,11 +705,12 @@
708
705
  */
709
706
  HTTPService.prototype.postwithFiles = function (url, bodyData, fileArrayOrFile) {
710
707
  var _this = this;
711
- var myGuid = this.defaultStartCall(url);
712
- var formData = this.getFilesFormData(fileArrayOrFile);
713
- formData.append("body", JSON.stringify(bodyData));
714
- var httpCall = this.http.post(url, formData, { headers: this.getHeaders(null, true, null, null) });
715
- return httpCall.pipe(operators.catchError(function (err, caught) { return _this.registerErrorAndReturnEmptyObservable(err, myGuid); }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
708
+ return rxjs.from(this.defaultStartCall(url)).pipe(operators.concatMap(function (myGuid) {
709
+ var formData = _this.getFilesFormData(fileArrayOrFile);
710
+ formData.append("body", JSON.stringify(bodyData));
711
+ var httpCall = _this.http.post(url, formData, { headers: _this.getHeaders(null, true, null, null) });
712
+ return httpCall.pipe(operators.catchError(function (err, caught) { return _this.registerErrorAndReturnEmptyObservable(err, myGuid); }), operators.finalize(function () { _this.tryFinalizeByGuid(myGuid); }));
713
+ }));
716
714
  };
717
715
  /**
718
716
  * Esecuzione di una POST HTTP