@hmcts/ccd-case-ui-toolkit 6.18.3-hotfix-EUI-8738 → 6.19.0-RetryCaseRetrievals.1

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.
@@ -2022,6 +2022,18 @@
2022
2022
  AbstractAppConfig.prototype.getLocationRefApiUrl = function () {
2023
2023
  return undefined;
2024
2024
  };
2025
+ AbstractAppConfig.prototype.getEnvironment = function () {
2026
+ var _a, _b, _c, _d;
2027
+ if ((_a = this.getActivityUrl()) === null || _a === void 0 ? void 0 : _a.includes('.aat.'))
2028
+ return 'aat';
2029
+ else if ((_b = this.getActivityUrl()) === null || _b === void 0 ? void 0 : _b.includes('.preview.'))
2030
+ return 'preview';
2031
+ else if ((_c = this.getActivityUrl()) === null || _c === void 0 ? void 0 : _c.includes('.demo.'))
2032
+ return 'demo';
2033
+ else if ((_d = this.getActivityUrl()) === null || _d === void 0 ? void 0 : _d.includes('.ithc.'))
2034
+ return 'ithc';
2035
+ return 'prod';
2036
+ };
2025
2037
  AbstractAppConfig.prototype.getCamRoleAssignmentsApiUrl = function () {
2026
2038
  return undefined;
2027
2039
  };
@@ -8624,8 +8636,82 @@
8624
8636
  }], null, null);
8625
8637
  })();
8626
8638
 
8639
+ var RxjsUtils = /** @class */ (function () {
8640
+ function RxjsUtils() {
8641
+ this.artificialDelayOn = true;
8642
+ this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 3;
8643
+ }
8644
+ RxjsUtils.prototype.switchArtificialDelays = function (status) {
8645
+ this.artificialDelayOn = status;
8646
+ this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 2;
8647
+ };
8648
+ RxjsUtils.prototype.switchOnArtificialDelays = function () {
8649
+ this.switchArtificialDelays(true);
8650
+ };
8651
+ RxjsUtils.prototype.switchOffArtificialDelays = function () {
8652
+ this.switchArtificialDelays(false);
8653
+ };
8654
+ RxjsUtils.prototype.getArtificialDelayTime = function () {
8655
+ return this.artificialDelayOn ? this.artificialDelayPeriod : 0;
8656
+ };
8657
+ RxjsUtils.prototype.pipeTimeoutMechanismOn = function (in$, environment, timeoutPeriods) {
8658
+ this.switchOnArtificialDelays();
8659
+ var out$ = in$;
8660
+ if (environment === 'aat') {
8661
+ out$ = this.pipeArtificialDelayOn(out$);
8662
+ }
8663
+ out$ = this.pipeTimeOutControlOn(out$, timeoutPeriods);
8664
+ out$ = this.pipeRetryMechanismOn(out$);
8665
+ return out$;
8666
+ };
8667
+ RxjsUtils.prototype.pipeTimeOutControlOn = function (in$, timeoutPeriods) {
8668
+ var timeOutAfterSeconds = timeoutPeriods[0];
8669
+ var out$ = in$.pipe(operators.timeout(timeOutAfterSeconds * 1000));
8670
+ return out$;
8671
+ };
8672
+ RxjsUtils.prototype.pipeRetryMechanismOn = function (in$) {
8673
+ var _this = this;
8674
+ var retryStrategy = function (errors) {
8675
+ return errors.pipe(operators.mergeMap(function (error, i) {
8676
+ console.error("Mapping error " + (error === null || error === void 0 ? void 0 : error.name) + ", " + i);
8677
+ console.error(error);
8678
+ if ((error === null || error === void 0 ? void 0 : error.name) === 'TimeoutError' && i === 0) {
8679
+ _this.switchOffArtificialDelays();
8680
+ console.info('Will retry, after a timeout error.');
8681
+ }
8682
+ else {
8683
+ console.error('Will NOT retry.');
8684
+ rxjs.throwError(error);
8685
+ }
8686
+ return rxjs.timer(0);
8687
+ }), operators.finalize(function () { return console.log('We are done!'); }));
8688
+ };
8689
+ var out$ = in$.pipe(operators.retryWhen(retryStrategy));
8690
+ return out$;
8691
+ };
8692
+ RxjsUtils.prototype.pipeArtificialDelayOn = function (in$) {
8693
+ var _this = this;
8694
+ var out$ = in$.pipe(operators.tap(function () {
8695
+ console.log("Artificially delaying for " + _this.getArtificialDelayTime() + " seconds..");
8696
+ }));
8697
+ out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(_this.getArtificialDelayTime() * 1000); }));
8698
+ out$ = out$.pipe(operators.tap(function () {
8699
+ console.log("Artificially delayed for " + _this.getArtificialDelayTime() + " seconds..");
8700
+ }));
8701
+ return out$;
8702
+ };
8703
+ return RxjsUtils;
8704
+ }());
8705
+ RxjsUtils.ɵfac = function RxjsUtils_Factory(t) { return new (t || RxjsUtils)(); };
8706
+ RxjsUtils.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: RxjsUtils, factory: RxjsUtils.ɵfac });
8707
+ (function () {
8708
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(RxjsUtils, [{
8709
+ type: i0.Injectable
8710
+ }], null, null);
8711
+ })();
8712
+
8627
8713
  var CasesService = /** @class */ (function () {
8628
- function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService) {
8714
+ function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService, rxjsUtils) {
8629
8715
  this.http = http;
8630
8716
  this.appConfig = appConfig;
8631
8717
  this.orderService = orderService;
@@ -8633,6 +8719,7 @@
8633
8719
  this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
8634
8720
  this.loadingService = loadingService;
8635
8721
  this.sessionStorageService = sessionStorageService;
8722
+ this.rxjsUtils = rxjsUtils;
8636
8723
  this.get = this.getCaseView;
8637
8724
  }
8638
8725
  CasesService.updateChallengedAccessRequestAttributes = function (httpClient, caseId, attributesToUpdate) {
@@ -8666,14 +8753,21 @@
8666
8753
  .set('Accept', CasesService.V2_MEDIATYPE_CASE_VIEW)
8667
8754
  .set('Content-Type', 'application/json');
8668
8755
  var loadingToken = this.loadingService.register();
8669
- return this.http
8670
- .get(url, { headers: headers, observe: 'body' })
8671
- .pipe(operators.catchError(function (error) {
8672
- console.error('Error while getting case view with getCaseViewV2!');
8756
+ var http$ = this.http.get(url, { headers: headers, observe: 'body' });
8757
+ this.rxjsUtils.pipeTimeoutMechanismOn(http$, this.appConfig.getEnvironment(), this.appConfig.getCaseRetrievalTimeouts());
8758
+ http$ = this.pipeErrorProcessor(http$);
8759
+ http$ = http$.pipe(operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
8760
+ return http$;
8761
+ };
8762
+ CasesService.prototype.pipeErrorProcessor = function (in$) {
8763
+ var _this = this;
8764
+ var out$$ = in$.pipe(operators.catchError(function (error) {
8765
+ console.error("Error while getting case view with getCaseViewV2! Error type: '" + typeof error + ", Error name: '" + (error === null || error === void 0 ? void 0 : error.name) + "'");
8673
8766
  console.error(error);
8674
8767
  _this.errorService.setError(error);
8675
8768
  return rxjs.throwError(error);
8676
- }), operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
8769
+ }));
8770
+ return out$$;
8677
8771
  };
8678
8772
  CasesService.prototype.syncWait = function (seconds) {
8679
8773
  var end = Date.now() + seconds * 1000;
@@ -8871,12 +8965,12 @@
8871
8965
  CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
8872
8966
  CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
8873
8967
  CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
8874
- CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService)); };
8968
+ CasesService.ɵfac = function CasesService_Factory(t) { return new (t || CasesService)(i0__namespace.ɵɵinject(HttpService), i0__namespace.ɵɵinject(AbstractAppConfig), i0__namespace.ɵɵinject(OrderService), i0__namespace.ɵɵinject(HttpErrorService), i0__namespace.ɵɵinject(WizardPageFieldToCaseFieldMapper), i0__namespace.ɵɵinject(LoadingService), i0__namespace.ɵɵinject(SessionStorageService), i0__namespace.ɵɵinject(RxjsUtils)); };
8875
8969
  CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
8876
8970
  (function () {
8877
8971
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
8878
8972
  type: i0.Injectable
8879
- }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }]; }, null);
8973
+ }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }, { type: RxjsUtils }]; }, null);
8880
8974
  })();
8881
8975
 
8882
8976
  var EventTriggerService = /** @class */ (function () {
@@ -11082,10 +11176,6 @@
11082
11176
  _this.handleError(error);
11083
11177
  });
11084
11178
  CaseEditPageComponent.scrollToTop();
11085
- // Remove all JudicialUser FormControls with the ID suffix "_judicialUserControl" because these are not
11086
- // intended to be present in the Case Event data (they are added only for value selection and validation
11087
- // purposes)
11088
- this.removeAllJudicialUserFormControls(this.currentPage, this.editForm);
11089
11179
  }
11090
11180
  CaseEditPageComponent.setFocusToTop();
11091
11181
  };
@@ -11357,13 +11447,6 @@
11357
11447
  submit: this.caseEdit.submit,
11358
11448
  });
11359
11449
  };
11360
- CaseEditPageComponent.prototype.removeAllJudicialUserFormControls = function (page, editForm) {
11361
- page.case_fields.forEach(function (caseField) {
11362
- if (FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser'])) {
11363
- editForm.controls['data'].removeControl(caseField.id + "_judicialUserControl");
11364
- }
11365
- });
11366
- };
11367
11450
  return CaseEditPageComponent;
11368
11451
  }());
11369
11452
  CaseEditPageComponent.RESUMED_FORM_DISCARD = 'RESUMED_FORM_DISCARD';