kwikid-forms 0.6.46 → 0.6.48

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.
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __awaiter } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
3
  import { EventEmitter, Component, Input, Output, ChangeDetectionStrategy, Pipe, Inject, ViewChild, ViewChildren, HostListener, NgModule } from '@angular/core';
4
- import { checkObjectKeyExists, setValueToObjectPath, isEmptyValue, getObjectDeepCopy, logMethod, isNotEmptyValue, setMissingKeyValue, isObject, mergeObjects, checkObjectPathExists, getObjectValueFromPath, getObjectFromLocalStorage, encryptWithAES, decryptWithAES, Rule, Condition, Action, Source, hasWhitespacesOnly, PATTERNS, RuleEngine, mergeObjectsDeep, ESourceKey, replaceString, isUndefined, isNull, isEmptyString } from 'kwikid-toolkit';
4
+ import { checkObjectKeyExists, setValueToObjectPath, isEmptyValue, getObjectDeepCopy, logMethod, isNotEmptyValue, setMissingKeyValue, isObject, mergeObjects, checkObjectPathExists, getObjectValueFromPath, getObjectFromLocalStorage, encryptWithAES, decryptWithAES, Rule, Condition, Action, Source, hasWhitespacesOnly, PATTERNS, RuleEngine, mergeObjectsDeep, ESourceKey, isNotEmptyString, removeKeyFromObjectPath, replaceString, isUndefined, isNull, isEmptyString } from 'kwikid-toolkit';
5
5
  import * as i3 from 'kwikui';
6
6
  import { KwikUIModule, KwikUIPipeModule, KwikUIInputEmailModule } from 'kwikui';
7
7
  import * as i3$1 from '@angular/forms';
@@ -2614,6 +2614,7 @@ var ELogEventType$2;
2614
2614
 
2615
2615
  var EActionKey;
2616
2616
  (function (EActionKey) {
2617
+ EActionKey["REMOVE_KEY_FROM_OBJECT_PATH"] = "REMOVE_KEY_FROM_OBJECT_PATH";
2617
2618
  EActionKey["SET_VALUE"] = "SET_VALUE";
2618
2619
  EActionKey["SET_FIELD_DEFAULT_VALUE"] = "SET_FIELD_DEFAULT_VALUE";
2619
2620
  EActionKey["SET_API_STATUS"] = "SET_API_STATUS";
@@ -2780,10 +2781,12 @@ class KwikIDFormViewApiService {
2780
2781
  }
2781
2782
  // Function to preprocess header data
2782
2783
  preProcessHeader(headerData, isVerifySignature) {
2783
- if (!headerData)
2784
+ if (!headerData) {
2784
2785
  headerData = {};
2785
- if (!headerData.headers)
2786
+ }
2787
+ if (!headerData.headers) {
2786
2788
  headerData.headers = {};
2789
+ }
2787
2790
  // Generate a unique identifier if signature verification is required
2788
2791
  if (isVerifySignature) {
2789
2792
  headerData.headers.xrid = v4();
@@ -4890,7 +4893,7 @@ class KwikIDFormViewComponent {
4890
4893
  * This is a api upload mocking method. Set's to loading at first at point when API is called and then changes the status to random status after 2 seconds of delay showing a mocked response from API.
4891
4894
  */
4892
4895
  uploadFile(field, file) {
4893
- var _a, _b, _c, _d, _e, _f;
4896
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4894
4897
  return __awaiter(this, void 0, void 0, function* () {
4895
4898
  switch (field.type) {
4896
4899
  case EFieldType.FILE:
@@ -4988,12 +4991,18 @@ class KwikIDFormViewComponent {
4988
4991
  watermarkPayload.data.push(watermarkSource);
4989
4992
  }
4990
4993
  }
4991
- const imageUploadPayload = Object.assign(Object.assign(Object.assign({ image: file }, ((ocrPayload === null || ocrPayload === void 0 ? void 0 : ocrPayload.isEnabled) && {
4994
+ let livelinessPayload = {};
4995
+ if (isNotEmptyValue((_h = (_g = field === null || field === void 0 ? void 0 : field.properties) === null || _g === void 0 ? void 0 : _g.features) === null || _h === void 0 ? void 0 : _h.liveliness)) {
4996
+ livelinessPayload = field.properties.features.liveliness;
4997
+ }
4998
+ const imageUploadPayload = Object.assign(Object.assign(Object.assign(Object.assign({ image: file }, ((ocrPayload === null || ocrPayload === void 0 ? void 0 : ocrPayload.isEnabled) && {
4992
4999
  ocr: ocrPayload
4993
5000
  })), ((facematchPayload === null || facematchPayload === void 0 ? void 0 : facematchPayload.isEnabled) && {
4994
5001
  facematch: facematchPayload
4995
5002
  })), ((watermarkPayload === null || watermarkPayload === void 0 ? void 0 : watermarkPayload.isEnabled) && {
4996
5003
  watermark: watermarkPayload
5004
+ })), ((livelinessPayload === null || livelinessPayload === void 0 ? void 0 : livelinessPayload.isEnabled) && {
5005
+ liveliness: livelinessPayload
4997
5006
  }));
4998
5007
  this.triggerLogs(ELogEventType$1.FORM__API_REQUEST_UPLOAD_IMAGE, {
4999
5008
  field_key: field.key,
@@ -5340,7 +5349,7 @@ class KwikIDFormViewComponent {
5340
5349
  });
5341
5350
  }
5342
5351
  executeApiCall(api, object) {
5343
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
5352
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
5344
5353
  return __awaiter(this, void 0, void 0, function* () {
5345
5354
  const apis = new Apis(object, this.takeAction.bind(this));
5346
5355
  api = yield apis.setUrl();
@@ -5383,7 +5392,7 @@ class KwikIDFormViewComponent {
5383
5392
  apiCallResponse = executedApiCall.data;
5384
5393
  apiCallResponseStatusCode = executedApiCall.status;
5385
5394
  }
5386
- catch (_13) {
5395
+ catch (_11) {
5387
5396
  // Handle any errors
5388
5397
  apiCallResponse = {};
5389
5398
  apiCallResponseStatusCode =
@@ -5409,7 +5418,7 @@ class KwikIDFormViewComponent {
5409
5418
  apiCallResponse = executedApiCall.data;
5410
5419
  apiCallResponseStatusCode = executedApiCall.status;
5411
5420
  }
5412
- catch (_14) {
5421
+ catch (_12) {
5413
5422
  // Handle any errors
5414
5423
  apiCallResponse = {};
5415
5424
  apiCallResponseStatusCode =
@@ -5419,13 +5428,13 @@ class KwikIDFormViewComponent {
5419
5428
  }
5420
5429
  api.response = setValueToObjectPath(api.response, "value", apiCallResponse);
5421
5430
  api.response = setValueToObjectPath(api.response, "status", apiCallResponseStatusCode);
5422
- this.triggerLogs(ELogEventType$1.FORM__API_RESPONSE, Object.assign(Object.assign({ form_api_key: (_y = api === null || api === void 0 ? void 0 : api.apiKey) !== null && _y !== void 0 ? _y : "", form_api_response_encrypted: (_0 = (_z = api === null || api === void 0 ? void 0 : api.response) === null || _z === void 0 ? void 0 : _z.isSecure) !== null && _0 !== void 0 ? _0 : false }, (((_2 = !((_1 = api === null || api === void 0 ? void 0 : api.response) === null || _1 === void 0 ? void 0 : _1.isSecure)) !== null && _2 !== void 0 ? _2 : false) && {
5431
+ this.triggerLogs(ELogEventType$1.FORM__API_RESPONSE, Object.assign(Object.assign({ form_api_key: (_y = api === null || api === void 0 ? void 0 : api.apiKey) !== null && _y !== void 0 ? _y : "", form_api_response_encrypted: (_0 = (_z = api === null || api === void 0 ? void 0 : api.response) === null || _z === void 0 ? void 0 : _z.isSecure) !== null && _0 !== void 0 ? _0 : false }, (!((_1 = api === null || api === void 0 ? void 0 : api.response) === null || _1 === void 0 ? void 0 : _1.isSecure) && {
5423
5432
  form_api_response_body: apiCallResponse !== null && apiCallResponse !== void 0 ? apiCallResponse : {}
5424
5433
  })), { form_api_status_code: apiCallResponseStatusCode }));
5425
5434
  }
5426
5435
  else {
5427
- this.triggerLogs(ELogEventType$1.FORM__API_REQUEST_INVALID, Object.assign({ form_api_key: (_3 = api === null || api === void 0 ? void 0 : api.apiKey) !== null && _3 !== void 0 ? _3 : "", form_api_request_encrypted: (_6 = (_5 = (_4 = api === null || api === void 0 ? void 0 : api.request) === null || _4 === void 0 ? void 0 : _4.body) === null || _5 === void 0 ? void 0 : _5.isSecure) !== null && _6 !== void 0 ? _6 : false }, (((_9 = !((_8 = (_7 = api === null || api === void 0 ? void 0 : api.request) === null || _7 === void 0 ? void 0 : _7.body) === null || _8 === void 0 ? void 0 : _8.isSecure)) !== null && _9 !== void 0 ? _9 : false) && {
5428
- form_api_request_body: (_12 = (_11 = (_10 = api === null || api === void 0 ? void 0 : api.request) === null || _10 === void 0 ? void 0 : _10.body) === null || _11 === void 0 ? void 0 : _11.value) !== null && _12 !== void 0 ? _12 : {}
5436
+ this.triggerLogs(ELogEventType$1.FORM__API_REQUEST_INVALID, Object.assign({ form_api_key: (_2 = api === null || api === void 0 ? void 0 : api.apiKey) !== null && _2 !== void 0 ? _2 : "", form_api_request_encrypted: (_5 = (_4 = (_3 = api === null || api === void 0 ? void 0 : api.request) === null || _3 === void 0 ? void 0 : _3.body) === null || _4 === void 0 ? void 0 : _4.isSecure) !== null && _5 !== void 0 ? _5 : false }, (!((_7 = (_6 = api === null || api === void 0 ? void 0 : api.request) === null || _6 === void 0 ? void 0 : _6.body) === null || _7 === void 0 ? void 0 : _7.isSecure) && {
5437
+ form_api_request_body: (_10 = (_9 = (_8 = api === null || api === void 0 ? void 0 : api.request) === null || _8 === void 0 ? void 0 : _8.body) === null || _9 === void 0 ? void 0 : _9.value) !== null && _10 !== void 0 ? _10 : {}
5429
5438
  })));
5430
5439
  }
5431
5440
  return api;
@@ -6018,6 +6027,28 @@ class KwikIDFormViewComponent {
6018
6027
  });
6019
6028
  });
6020
6029
  }
6030
+ removeKeyFromObjectPath(action, object) {
6031
+ var _a, _b, _c, _d;
6032
+ return __awaiter(this, void 0, void 0, function* () {
6033
+ const source = new Source(object);
6034
+ const sourceValue = action.props.source;
6035
+ const objectKey = (_b = (_a = sourceValue === null || sourceValue === void 0 ? void 0 : sourceValue.props) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.key;
6036
+ const objectPath = (_d = (_c = sourceValue === null || sourceValue === void 0 ? void 0 : sourceValue.props) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.path;
6037
+ if (sourceValue.key === ESourceKey.OBJECT &&
6038
+ isNotEmptyString(objectKey) &&
6039
+ isNotEmptyString(objectPath)) {
6040
+ if (checkObjectKeyExists(source._object, objectKey)) {
6041
+ source._object[objectKey] = removeKeyFromObjectPath(source._object[objectKey], objectPath);
6042
+ }
6043
+ }
6044
+ object.FIELD_CONFIG = source._object.FIELD_CONFIG;
6045
+ this.formData = source._object.FORM_DATA;
6046
+ this.patchFormGroup(this.formData);
6047
+ this.allFormsData = source._object.ALL_FORMS_DATA;
6048
+ this.previousFormData = source._object.PREVIOUS_FORM_DATA;
6049
+ this.extraData = source._object.EXTRA_DATA;
6050
+ });
6051
+ }
6021
6052
  setValue(action, object) {
6022
6053
  return __awaiter(this, void 0, void 0, function* () {
6023
6054
  const source = new Source(object);
@@ -6220,8 +6251,9 @@ class KwikIDFormViewComponent {
6220
6251
  const field = getFormFieldByKey(this.formFields, action.props.fieldKey);
6221
6252
  let multipleApiCallResponses = {};
6222
6253
  field.api.endpoints.forEach((api) => {
6223
- if (checkObjectKeyExists(api.response, "value"))
6254
+ if (checkObjectKeyExists(api.response, "value")) {
6224
6255
  multipleApiCallResponses = setValueToObjectPath(multipleApiCallResponses, `${api.apiKey}`, api.response.value);
6256
+ }
6225
6257
  });
6226
6258
  this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: multipleApiCallResponses });
6227
6259
  this.patchFormGroup(this.formData);
@@ -6273,8 +6305,9 @@ class KwikIDFormViewComponent {
6273
6305
  const multipleApiConfig = this.formConfig.apis[action.props.formApiKey];
6274
6306
  let multipleApiCallResponses = {};
6275
6307
  multipleApiConfig.endpoints.forEach((api) => {
6276
- if (checkObjectKeyExists(api.response, "value"))
6308
+ if (checkObjectKeyExists(api.response, "value")) {
6277
6309
  multipleApiCallResponses = setValueToObjectPath(multipleApiCallResponses, `${api.apiKey}`, api.response.value);
6310
+ }
6278
6311
  });
6279
6312
  this.taskData = Object.assign(Object.assign({}, this.taskData), { [action.props.formApiKey]: multipleApiCallResponses });
6280
6313
  this.waitingForChanges = false;
@@ -6601,6 +6634,9 @@ class KwikIDFormViewComponent {
6601
6634
  case EActionKey.FIELD_API_TIMER_MESSAGE_HIDE:
6602
6635
  yield this.fieldApiTimerMessageHide(action.props.fieldKey);
6603
6636
  break;
6637
+ case EActionKey.REMOVE_KEY_FROM_OBJECT_PATH:
6638
+ yield this.removeKeyFromObjectPath(action, object);
6639
+ break;
6604
6640
  case EActionKey.SET_VALUE:
6605
6641
  yield this.setValue(action, object);
6606
6642
  break;
@@ -6920,6 +6956,9 @@ __decorate([
6920
6956
  __decorate([
6921
6957
  logMethod
6922
6958
  ], KwikIDFormViewComponent.prototype, "fieldMessageHide", null);
6959
+ __decorate([
6960
+ logMethod
6961
+ ], KwikIDFormViewComponent.prototype, "removeKeyFromObjectPath", null);
6923
6962
  __decorate([
6924
6963
  logMethod
6925
6964
  ], KwikIDFormViewComponent.prototype, "setValue", null);
@@ -7083,7 +7122,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
7083
7122
  type: Output
7084
7123
  }], onClickViewForms: [{
7085
7124
  type: Output
7086
- }], resetCamera: [], ngOnInit: [], ngOnChanges: [], ngOnDestroy: [], triggerLogs: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleRemovedFile: [], handleViewButtonClick: [], handleGetKeyValueFile: [], handleOnClickGetRemovedMediaFile: [], handleOnClickInputCamera: [], setCameraMedia: [], handleGetCameraMedia: [], handleOnClickSaveCameraMedia: [], handleOnClickCameraBack: [], handleOnClickCameraClose: [], updateFiles: [], uploadFile: [], handleOnClickFormFieldButton: [], handleOnLocationPermission: [], handleOnClickLiveLocation: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleFieldApiCall: [], handleApiCall: [], executeApiCall: [], isValidRequestHeadersAndBody: [], handleOnClickApiCall: [], handleOnClickGoBack: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], handleOnApiTimerStop: [], handleOnScrollToField: [], toggleErrorNotification: [], togglePermissionErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldGroupReset: [], fieldHideApiLoader: [], fieldShowApiLoader: [], setHtml: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setValue: [], setFieldDefaultValue: [], setApiStatus: [], setApiHeaderValue: [], setApiHeaderValidity: [], setApiBodyValue: [], setApiBodyValidity: [], setFieldValidity: [], setDropdownOptions: [], apiCall: [], fieldApiCall: [], fieldMultipleApiCalls: [], fieldMultipleApiCallsEnd: [], taskApiCall: [], taskMultipleApiCalls: [], taskMultipleApiCallsEnd: [], dialogShow: [], dialogHide: [], redirectToUrl: [], patchFieldControlValue: [], setFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], showPreview: [], showErrorPreview: [], showPopupForm: [], alertShow: [], takeActionOnFieldGroup: [], takeAction: [] } });
7125
+ }], resetCamera: [], ngOnInit: [], ngOnChanges: [], ngOnDestroy: [], triggerLogs: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleRemovedFile: [], handleViewButtonClick: [], handleGetKeyValueFile: [], handleOnClickGetRemovedMediaFile: [], handleOnClickInputCamera: [], setCameraMedia: [], handleGetCameraMedia: [], handleOnClickSaveCameraMedia: [], handleOnClickCameraBack: [], handleOnClickCameraClose: [], updateFiles: [], uploadFile: [], handleOnClickFormFieldButton: [], handleOnLocationPermission: [], handleOnClickLiveLocation: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleFieldApiCall: [], handleApiCall: [], executeApiCall: [], isValidRequestHeadersAndBody: [], handleOnClickApiCall: [], handleOnClickGoBack: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], handleOnApiTimerStop: [], handleOnScrollToField: [], toggleErrorNotification: [], togglePermissionErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldGroupReset: [], fieldHideApiLoader: [], fieldShowApiLoader: [], setHtml: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], removeKeyFromObjectPath: [], setValue: [], setFieldDefaultValue: [], setApiStatus: [], setApiHeaderValue: [], setApiHeaderValidity: [], setApiBodyValue: [], setApiBodyValidity: [], setFieldValidity: [], setDropdownOptions: [], apiCall: [], fieldApiCall: [], fieldMultipleApiCalls: [], fieldMultipleApiCallsEnd: [], taskApiCall: [], taskMultipleApiCalls: [], taskMultipleApiCallsEnd: [], dialogShow: [], dialogHide: [], redirectToUrl: [], patchFieldControlValue: [], setFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], showPreview: [], showErrorPreview: [], showPopupForm: [], alertShow: [], takeActionOnFieldGroup: [], takeAction: [] } });
7087
7126
 
7088
7127
  /* eslint-disable no-unused-vars */
7089
7128
  var EFormType;
@@ -7670,6 +7709,22 @@ class KwikIDFormsRendererComponent {
7670
7709
  form = setValueToObjectPath(form, "status", "completed");
7671
7710
  form = setValueToObjectPath(form, "disabled", false);
7672
7711
  }
7712
+ else if (checkObjectKeyExists(form, "dependentOn")) {
7713
+ const isDependent = form.dependentOn.every((r) => formsListCompleted.includes(r));
7714
+ if (isDependent) {
7715
+ form = setValueToObjectPath(form, "status", "editable");
7716
+ form = setValueToObjectPath(form, "disabled", false);
7717
+ }
7718
+ else {
7719
+ form = setValueToObjectPath(form, "status", "locked");
7720
+ form = setValueToObjectPath(form, "disabled", true);
7721
+ }
7722
+ }
7723
+ else {
7724
+ form = setValueToObjectPath(form, "dependentOn", []);
7725
+ form = setValueToObjectPath(form, "status", "editable");
7726
+ form = setValueToObjectPath(form, "disabled", false);
7727
+ }
7673
7728
  }
7674
7729
  }
7675
7730
  }
@@ -8348,8 +8403,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
8348
8403
 
8349
8404
  class JsonFormatPipe {
8350
8405
  transform(value) {
8351
- if (!value)
8406
+ if (!value) {
8352
8407
  return "";
8408
+ }
8353
8409
  // Trim spaces from start and end, then JSON.stringify with indentation for formatting
8354
8410
  return JSON.stringify(value, null, 2).trim();
8355
8411
  }