@hmcts/ccd-case-ui-toolkit 6.18.4-EXUI-433-pass-all-fields-rc2 → 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 (29) hide show
  1. package/bundles/hmcts-ccd-case-ui-toolkit.umd.js +116 -11
  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/app.config.js +13 -1
  6. package/esm2015/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.js +12 -1
  7. package/esm2015/lib/shared/components/case-editor/case-edit-submit/case-edit-submit.component.js +2 -3
  8. package/esm2015/lib/shared/components/case-editor/services/cases.service.js +17 -10
  9. package/esm2015/lib/shared/pipes/complex/ccd-read-fields-filter.pipe.js +2 -2
  10. package/esm2015/lib/shared/services/index.js +2 -1
  11. package/esm2015/lib/shared/services/utils/retry/index.js +2 -0
  12. package/esm2015/lib/shared/services/utils/retry/retry-util.service.js +73 -0
  13. package/fesm2015/hmcts-ccd-case-ui-toolkit.js +111 -13
  14. package/fesm2015/hmcts-ccd-case-ui-toolkit.js.map +1 -1
  15. package/lib/app.config.d.ts +3 -0
  16. package/lib/app.config.d.ts.map +1 -1
  17. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts +1 -0
  18. package/lib/shared/components/case-editor/case-edit-page/case-edit-page.component.d.ts.map +1 -1
  19. package/lib/shared/components/case-editor/case-edit-submit/case-edit-submit.component.d.ts +0 -1
  20. package/lib/shared/components/case-editor/case-edit-submit/case-edit-submit.component.d.ts.map +1 -1
  21. package/lib/shared/components/case-editor/services/cases.service.d.ts +4 -2
  22. package/lib/shared/components/case-editor/services/cases.service.d.ts.map +1 -1
  23. package/lib/shared/services/index.d.ts +1 -0
  24. package/lib/shared/services/index.d.ts.map +1 -1
  25. package/lib/shared/services/utils/retry/index.d.ts +2 -0
  26. package/lib/shared/services/utils/retry/index.d.ts.map +1 -0
  27. package/lib/shared/services/utils/retry/retry-util.service.d.ts +17 -0
  28. package/lib/shared/services/utils/retry/retry-util.service.d.ts.map +1 -0
  29. package/package.json +1 -1
@@ -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
  };
@@ -8074,6 +8086,80 @@
8074
8086
  }], null, null);
8075
8087
  })();
8076
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
+
8077
8163
  var WindowService = /** @class */ (function () {
8078
8164
  function WindowService() {
8079
8165
  }
@@ -8625,7 +8711,7 @@
8625
8711
  })();
8626
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, retryUtil) {
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.retryUtil = retryUtil;
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.retryUtil.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(RetryUtil)); };
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: RetryUtil }]; }, null);
8880
8974
  })();
8881
8975
 
8882
8976
  var EventTriggerService = /** @class */ (function () {
@@ -11082,6 +11176,10 @@
11082
11176
  _this.handleError(error);
11083
11177
  });
11084
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);
11085
11183
  }
11086
11184
  CaseEditPageComponent.setFocusToTop();
11087
11185
  };
@@ -11353,6 +11451,13 @@
11353
11451
  submit: this.caseEdit.submit,
11354
11452
  });
11355
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
+ };
11356
11461
  return CaseEditPageComponent;
11357
11462
  }());
11358
11463
  CaseEditPageComponent.RESUMED_FORM_DISCARD = 'RESUMED_FORM_DISCARD';
@@ -26311,7 +26416,7 @@
26311
26416
  var checkConditionalShowAgainst = values;
26312
26417
  var formGroupAvailable = false;
26313
26418
  if (formGroup) {
26314
- checkConditionalShowAgainst = formGroup.value ? formGroup.value : formGroup;
26419
+ checkConditionalShowAgainst = formGroup.value;
26315
26420
  formGroupAvailable = true;
26316
26421
  }
26317
26422
  return fields
@@ -27317,7 +27422,7 @@
27317
27422
  var page_r13 = i0__namespace.ɵɵnextContext().$implicit;
27318
27423
  var ctx_r14 = i0__namespace.ɵɵnextContext(3);
27319
27424
  i0__namespace.ɵɵadvance(1);
27320
- i0__namespace.ɵɵproperty("ngForOf", i0__namespace.ɵɵpipeBind1(2, 1, i0__namespace.ɵɵpipeBindV(3, 3, i0__namespace.ɵɵpureFunction2(12, _c0$f, i0__namespace.ɵɵpipeBind2(4, 9, page_r13, ctx_r14.editForm), ctx_r14.allFieldsValues))));
27425
+ i0__namespace.ɵɵproperty("ngForOf", i0__namespace.ɵɵpipeBind1(2, 1, i0__namespace.ɵɵpipeBindV(3, 3, i0__namespace.ɵɵpureFunction2(12, _c0$f, i0__namespace.ɵɵpipeBind2(4, 9, page_r13, ctx_r14.editForm), ctx_r14.editForm.controls["data"]))));
27321
27426
  }
27322
27427
  }
27323
27428
  function CaseEditSubmitComponent_div_0_ng_container_11_ng_container_7_Template(rf, ctx) {
@@ -27585,7 +27690,6 @@
27585
27690
  this.caseEdit.isLinkedCasesSubmission =
27586
27691
  this.eventTrigger.case_fields.some(function (caseField) { return FieldsUtils.isCaseFieldOfType(caseField, ['ComponentLauncher']); });
27587
27692
  this.pageTitle = this.caseEdit.isCaseFlagSubmission ? 'Review flag details' : 'Check your answers';
27588
- this.allFieldsValues = this.editForm.getRawValue().data;
27589
27693
  };
27590
27694
  CaseEditSubmitComponent.prototype.ngOnDestroy = function () {
27591
27695
  /* istanbul ignore else */
@@ -37594,6 +37698,7 @@
37594
37698
  exports.ReadYesNoFieldComponent = ReadYesNoFieldComponent;
37595
37699
  exports.RemoveDialogComponent = RemoveDialogComponent;
37596
37700
  exports.RequestOptionsBuilder = RequestOptionsBuilder;
37701
+ exports.RetryUtil = RetryUtil;
37597
37702
  exports.RouterHelperService = RouterHelperService;
37598
37703
  exports.SaveOrDiscardDialogComponent = SaveOrDiscardDialogComponent;
37599
37704
  exports.SearchFiltersComponent = SearchFiltersComponent;