@hmcts/ccd-case-ui-toolkit 6.19.0-RetryCaseRetrievals.1 → 6.19.0-RetryCaseRetrievals.2

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.
Files changed (24) hide show
  1. package/bundles/hmcts-ccd-case-ui-toolkit.umd.js +91 -79
  2. package/bundles/hmcts-ccd-case-ui-toolkit.umd.js.map +1 -1
  3. package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js +1 -1
  4. package/bundles/hmcts-ccd-case-ui-toolkit.umd.min.js.map +1 -1
  5. package/esm2015/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.js +12 -1
  6. package/esm2015/lib/shared/components/case-editor/services/cases.service.js +7 -9
  7. package/esm2015/lib/shared/services/index.js +2 -1
  8. package/esm2015/lib/shared/services/utils/retry/index.js +2 -0
  9. package/esm2015/lib/shared/services/utils/retry/retry-util.service.js +73 -0
  10. package/fesm2015/hmcts-ccd-case-ui-toolkit.js +87 -76
  11. package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
  12. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts +1 -0
  13. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  14. package/lib/shared/components/case-editor/services/cases.service.d.ts +3 -4
  15. package/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
  16. package/lib/shared/services/index.d.ts +1 -0
  17. package/lib/shared/services/index.d.ts.map +1 -1
  18. package/lib/shared/services/utils/retry/index.d.ts +2 -0
  19. package/lib/shared/services/utils/retry/index.d.ts.map +1 -0
  20. package/lib/shared/services/utils/{rxjs-utils.service.d.ts → retry/retry-util.service.d.ts} +4 -4
  21. package/lib/shared/services/utils/retry/retry-util.service.d.ts.map +1 -0
  22. package/package.json +1 -1
  23. package/esm2015/lib/shared/services/utils/rxjs-utils.service.js +0 -73
  24. package/lib/shared/services/utils/rxjs-utils.service.d.ts.map +0 -1
@@ -8086,6 +8086,80 @@
8086
8086
  }], null, null);
8087
8087
  })();
8088
8088
 
8089
+ var RetryUtil = /** @class */ (function () {
8090
+ function RetryUtil() {
8091
+ this.artificialDelayOn = true;
8092
+ this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 3;
8093
+ }
8094
+ RetryUtil.prototype.switchArtificialDelays = function (status) {
8095
+ this.artificialDelayOn = status;
8096
+ this.artificialDelayPeriod = Math.random() > 0.5 ? 60 : 2;
8097
+ };
8098
+ RetryUtil.prototype.switchOnArtificialDelays = function () {
8099
+ this.switchArtificialDelays(true);
8100
+ };
8101
+ RetryUtil.prototype.switchOffArtificialDelays = function () {
8102
+ this.switchArtificialDelays(false);
8103
+ };
8104
+ RetryUtil.prototype.getArtificialDelayTime = function () {
8105
+ return this.artificialDelayOn ? this.artificialDelayPeriod : 0;
8106
+ };
8107
+ RetryUtil.prototype.pipeTimeoutMechanismOn = function (in$, environment, timeoutPeriods) {
8108
+ this.switchOnArtificialDelays();
8109
+ var out$ = in$;
8110
+ if (environment === 'aat') {
8111
+ out$ = this.pipeArtificialDelayOn(out$);
8112
+ }
8113
+ out$ = this.pipeTimeOutControlOn(out$, timeoutPeriods);
8114
+ out$ = this.pipeRetryMechanismOn(out$);
8115
+ return out$;
8116
+ };
8117
+ RetryUtil.prototype.pipeTimeOutControlOn = function (in$, timeoutPeriods) {
8118
+ var timeOutAfterSeconds = timeoutPeriods[0];
8119
+ var out$ = in$.pipe(operators.timeout(timeOutAfterSeconds * 1000));
8120
+ return out$;
8121
+ };
8122
+ RetryUtil.prototype.pipeRetryMechanismOn = function (in$) {
8123
+ var _this = this;
8124
+ var retryStrategy = function (errors) {
8125
+ return errors.pipe(operators.mergeMap(function (error, i) {
8126
+ console.error("Mapping error " + (error === null || error === void 0 ? void 0 : error.name) + ", " + i);
8127
+ console.error(error);
8128
+ if ((error === null || error === void 0 ? void 0 : error.name) === 'TimeoutError' && i === 0) {
8129
+ _this.switchOffArtificialDelays();
8130
+ console.info('Will retry, after a timeout error.');
8131
+ }
8132
+ else {
8133
+ console.error('Will NOT retry.');
8134
+ rxjs.throwError(error);
8135
+ }
8136
+ return rxjs.timer(0);
8137
+ }), operators.finalize(function () { return console.log('We are done!'); }));
8138
+ };
8139
+ var out$ = in$.pipe(operators.retryWhen(retryStrategy));
8140
+ return out$;
8141
+ };
8142
+ RetryUtil.prototype.pipeArtificialDelayOn = function (in$) {
8143
+ var _this = this;
8144
+ var out$ = in$.pipe(operators.tap(function () {
8145
+ console.log("Artificially delaying for " + _this.getArtificialDelayTime() + " seconds..");
8146
+ }));
8147
+ out$ = out$.pipe(operators.delayWhen(function () { return rxjs.timer(_this.getArtificialDelayTime() * 1000); }));
8148
+ out$ = out$.pipe(operators.tap(function () {
8149
+ console.log("Artificially delayed for " + _this.getArtificialDelayTime() + " seconds..");
8150
+ }));
8151
+ return out$;
8152
+ };
8153
+ return RetryUtil;
8154
+ }());
8155
+ RetryUtil.ɵfac = function RetryUtil_Factory(t) { return new (t || RetryUtil)(); };
8156
+ RetryUtil.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: RetryUtil, factory: RetryUtil.ɵfac });
8157
+ (function () {
8158
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(RetryUtil, [{
8159
+ type: i0.Injectable
8160
+ }], null, null);
8161
+ })();
8162
+
8089
8163
  var WindowService = /** @class */ (function () {
8090
8164
  function WindowService() {
8091
8165
  }
@@ -8636,82 +8710,8 @@
8636
8710
  }], null, null);
8637
8711
  })();
8638
8712
 
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
-
8713
8713
  var CasesService = /** @class */ (function () {
8714
- function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService, rxjsUtils) {
8714
+ function CasesService(http, appConfig, orderService, errorService, wizardPageFieldToCaseFieldMapper, loadingService, sessionStorageService, retryUtil) {
8715
8715
  this.http = http;
8716
8716
  this.appConfig = appConfig;
8717
8717
  this.orderService = orderService;
@@ -8719,7 +8719,7 @@
8719
8719
  this.wizardPageFieldToCaseFieldMapper = wizardPageFieldToCaseFieldMapper;
8720
8720
  this.loadingService = loadingService;
8721
8721
  this.sessionStorageService = sessionStorageService;
8722
- this.rxjsUtils = rxjsUtils;
8722
+ this.retryUtil = retryUtil;
8723
8723
  this.get = this.getCaseView;
8724
8724
  }
8725
8725
  CasesService.updateChallengedAccessRequestAttributes = function (httpClient, caseId, attributesToUpdate) {
@@ -8754,7 +8754,7 @@
8754
8754
  .set('Content-Type', 'application/json');
8755
8755
  var loadingToken = this.loadingService.register();
8756
8756
  var http$ = this.http.get(url, { headers: headers, observe: 'body' });
8757
- this.rxjsUtils.pipeTimeoutMechanismOn(http$, this.appConfig.getEnvironment(), this.appConfig.getCaseRetrievalTimeouts());
8757
+ this.retryUtil.pipeTimeoutMechanismOn(http$, this.appConfig.getEnvironment(), this.appConfig.getCaseRetrievalTimeouts());
8758
8758
  http$ = this.pipeErrorProcessor(http$);
8759
8759
  http$ = http$.pipe(operators.finalize(function () { return _this.finalizeGetCaseViewWith(caseId, loadingToken); }));
8760
8760
  return http$;
@@ -8965,12 +8965,12 @@
8965
8965
  CasesService.V2_MEDIATYPE_CREATE_EVENT = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-event.v2+json;charset=UTF-8';
8966
8966
  CasesService.V2_MEDIATYPE_CREATE_CASE = 'application/vnd.uk.gov.hmcts.ccd-data-store-api.create-case.v2+json;charset=UTF-8';
8967
8967
  CasesService.PUI_CASE_MANAGER = 'pui-case-manager';
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)); };
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(RetryUtil)); };
8969
8969
  CasesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CasesService, factory: CasesService.ɵfac });
8970
8970
  (function () {
8971
8971
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CasesService, [{
8972
8972
  type: i0.Injectable
8973
- }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }, { type: RxjsUtils }]; }, null);
8973
+ }], function () { return [{ type: HttpService }, { type: AbstractAppConfig }, { type: OrderService }, { type: HttpErrorService }, { type: WizardPageFieldToCaseFieldMapper }, { type: LoadingService }, { type: SessionStorageService }, { type: RetryUtil }]; }, null);
8974
8974
  })();
8975
8975
 
8976
8976
  var EventTriggerService = /** @class */ (function () {
@@ -11176,6 +11176,10 @@
11176
11176
  _this.handleError(error);
11177
11177
  });
11178
11178
  CaseEditPageComponent.scrollToTop();
11179
+ // Remove all JudicialUser FormControls with the ID suffix "_judicialUserControl" because these are not
11180
+ // intended to be present in the Case Event data (they are added only for value selection and validation
11181
+ // purposes)
11182
+ this.removeAllJudicialUserFormControls(this.currentPage, this.editForm);
11179
11183
  }
11180
11184
  CaseEditPageComponent.setFocusToTop();
11181
11185
  };
@@ -11447,6 +11451,13 @@
11447
11451
  submit: this.caseEdit.submit,
11448
11452
  });
11449
11453
  };
11454
+ CaseEditPageComponent.prototype.removeAllJudicialUserFormControls = function (page, editForm) {
11455
+ page.case_fields.forEach(function (caseField) {
11456
+ if (FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser'])) {
11457
+ editForm.controls['data'].removeControl(caseField.id + "_judicialUserControl");
11458
+ }
11459
+ });
11460
+ };
11450
11461
  return CaseEditPageComponent;
11451
11462
  }());
11452
11463
  CaseEditPageComponent.RESUMED_FORM_DISCARD = 'RESUMED_FORM_DISCARD';
@@ -37687,6 +37698,7 @@
37687
37698
  exports.ReadYesNoFieldComponent = ReadYesNoFieldComponent;
37688
37699
  exports.RemoveDialogComponent = RemoveDialogComponent;
37689
37700
  exports.RequestOptionsBuilder = RequestOptionsBuilder;
37701
+ exports.RetryUtil = RetryUtil;
37690
37702
  exports.RouterHelperService = RouterHelperService;
37691
37703
  exports.SaveOrDiscardDialogComponent = SaveOrDiscardDialogComponent;
37692
37704
  exports.SearchFiltersComponent = SearchFiltersComponent;