kwikid-forms 0.6.34 → 0.6.36

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.
@@ -1014,7 +1014,7 @@
1014
1014
  return field;
1015
1015
  };
1016
1016
  var setApiTimerMessage = function (field, timer) {
1017
- if (timer === void 0) { timer = undefined; }
1017
+ if (timer === void 0) { timer = {}; }
1018
1018
  if (kwikidToolkit.checkObjectKeyExists(field, "api")) {
1019
1019
  field["api"]["timer"] = timer;
1020
1020
  }
@@ -1318,21 +1318,26 @@
1318
1318
  };
1319
1319
  var getMinDate = function (field) {
1320
1320
  if (kwikidToolkit.checkObjectKeyExists(field, "min")) {
1321
+ /**
1322
+ * This is to handler old version of config.
1323
+ * Please don't add "min" at field level, add it insider field.properties only.
1324
+ */
1321
1325
  return convertFormFieldTypeDateToKwikUIFormat(field["min"]);
1322
1326
  }
1323
1327
  else {
1324
- return new cdk.TuiDay(0, 0, 1); // Year - 0000, Month - 0 (0 Indexing), Day - 1
1328
+ return {};
1325
1329
  }
1326
1330
  };
1327
1331
  var getMaxDate = function (field) {
1328
1332
  if (kwikidToolkit.checkObjectKeyExists(field, "max")) {
1333
+ /**
1334
+ * This is to handler old version of config.
1335
+ * Please don't add "max" at field level, add it insider field.properties only.
1336
+ */
1329
1337
  return convertFormFieldTypeDateToKwikUIFormat(field["max"]);
1330
1338
  }
1331
1339
  else {
1332
- return new cdk.TuiDay(new Date().getFullYear(), // Year - 9999
1333
- new Date().getMonth(), // Month - 11 (0 Indexing)
1334
- new Date().getDate() // Day - 31
1335
- );
1340
+ return {};
1336
1341
  }
1337
1342
  };
1338
1343
  var updateLanguage = function (object, language) {
@@ -3286,26 +3291,20 @@
3286
3291
  // Function to verify the signature
3287
3292
  KwikIDFormViewApiService.prototype.verifySignature = function (data, header, url, isVerifySignature) {
3288
3293
  return new Promise(function (resolve, reject) {
3289
- // Log the function call for verification
3290
- console.log("Verify Signature: Function Called For", url, header);
3291
3294
  // Check if the signature is disabled
3292
3295
  if (!isVerifySignature) {
3293
- console.log("Verify Signature: Authentication Disabled");
3294
3296
  resolve(true);
3295
3297
  }
3296
3298
  // Check if data is invalid
3297
3299
  else if (!data) {
3298
- console.log("Verify Signature: Data Not Available");
3299
3300
  resolve(true);
3300
3301
  }
3301
3302
  // Check if the signature is missing in headers when authentication is not skipped
3302
3303
  else if (isVerifySignature && header && !(header === null || header === void 0 ? void 0 : header.sig)) {
3303
- console.log("Verify Signature Failure: Signature Not Present in Headers");
3304
3304
  reject(false);
3305
3305
  }
3306
3306
  // Verify the signature when public key and header with signature are present and authentication is not skipped
3307
3307
  else if (isVerifySignature && header && (header === null || header === void 0 ? void 0 : header.sig)) {
3308
- console.log("Verify Signature: Signature Present in Headers");
3309
3308
  // Extract the signature and decode it
3310
3309
  var signature = header.sig.split(".")[0];
3311
3310
  var rawSignature = atob(signature);
@@ -3320,30 +3319,22 @@
3320
3319
  var dateCheck = dateValue < parseInt(exp);
3321
3320
  // Check if the signature matches the data
3322
3321
  var res = signature === data;
3323
- console.log("Verify Signature: Matching", signature, data);
3324
- console.log("Verify Signature: Time", dateValue, parseInt(exp), parseInt(exp) - dateValue);
3325
- console.log("Verify Signature: Date", new Date(dateValue), new Date(parseInt(exp)));
3326
- console.log("Verify Signature: Signature Converted to Required Format");
3327
3322
  // Resolve the promise if the signature is valid and the date check passes
3328
3323
  if (res && dateCheck) {
3329
- console.log("Verify Signature Success");
3330
3324
  resolve(res);
3331
3325
  }
3332
3326
  else {
3333
3327
  // Reject the promise if the signature is invalid or the date check fails
3334
- console.log("Verify Signature Failure: Signature did not match");
3335
3328
  reject(res);
3336
3329
  }
3337
3330
  }
3338
3331
  else {
3339
3332
  // Reject the promise if the signature is not in the required format
3340
- console.log("Verify Signature Failure: Signature Not Converted to Required Format");
3341
3333
  reject(false);
3342
3334
  }
3343
3335
  }
3344
3336
  else {
3345
3337
  // Resolve the promise if the signature is missing in headers
3346
- console.log("Verify Signature Failure: Signature Not Present in Headers");
3347
3338
  resolve(true);
3348
3339
  }
3349
3340
  });
@@ -3380,7 +3371,6 @@
3380
3371
  case 1:
3381
3372
  decryptedResponse = _c.sent();
3382
3373
  data = JSON.parse(decryptedResponse);
3383
- console.log("Decrypted Response", data);
3384
3374
  res.data = data;
3385
3375
  _c.label = 2;
3386
3376
  case 2:
@@ -3408,7 +3398,6 @@
3408
3398
  case 1:
3409
3399
  decryptedResponse = _c.sent();
3410
3400
  data = JSON.parse(decryptedResponse);
3411
- console.log("Decrypted Response", data);
3412
3401
  err.response.data = data;
3413
3402
  _c.label = 2;
3414
3403
  case 2:
@@ -3454,7 +3443,6 @@
3454
3443
  case 1:
3455
3444
  decryptedResponse = _c.sent();
3456
3445
  data = JSON.parse(decryptedResponse);
3457
- console.log("Decrypted Response", data);
3458
3446
  res.data = data;
3459
3447
  _c.label = 2;
3460
3448
  case 2:
@@ -3482,7 +3470,6 @@
3482
3470
  case 1:
3483
3471
  decryptedResponse = _c.sent();
3484
3472
  data = JSON.parse(decryptedResponse);
3485
- console.log("Decrypted Response", data);
3486
3473
  err.response.data = data;
3487
3474
  _c.label = 2;
3488
3475
  case 2:
@@ -5044,7 +5031,7 @@
5044
5031
  if (field_1.isFormElement &&
5045
5032
  kwikidToolkit.checkObjectKeyExists(field_1, "validation") &&
5046
5033
  field_1.validation.triggers.includes("ON_CHANGE")) {
5047
- var validations_1 = new kwikidToolkit.Validation({
5034
+ var ruleEngine_1 = new kwikidToolkit.RuleEngine({
5048
5035
  FIELD_CONFIG: field_1,
5049
5036
  FORM_FIELDS: this.formFields,
5050
5037
  FORM_DATA: this.formData,
@@ -5055,7 +5042,7 @@
5055
5042
  (function () { return __awaiter(_this, void 0, void 0, function () {
5056
5043
  return __generator(this, function (_15) {
5057
5044
  switch (_15.label) {
5058
- case 0: return [4 /*yield*/, validations_1.validate(field_1.validation)];
5045
+ case 0: return [4 /*yield*/, ruleEngine_1.run(field_1.validation)];
5059
5046
  case 1:
5060
5047
  _15.sent();
5061
5048
  return [2 /*return*/];
@@ -5110,7 +5097,7 @@
5110
5097
  if (field_1.isFormElement &&
5111
5098
  kwikidToolkit.checkObjectKeyExists(field_1, "validation") &&
5112
5099
  field_1.validation.triggers.includes("ON_CHANGE")) {
5113
- var validations_2 = new kwikidToolkit.Validation({
5100
+ var ruleEngine_2 = new kwikidToolkit.RuleEngine({
5114
5101
  FIELD_CONFIG: field_1,
5115
5102
  FORM_FIELDS: this.formFields,
5116
5103
  FORM_DATA: this.formData,
@@ -5121,7 +5108,7 @@
5121
5108
  (function () { return __awaiter(_this, void 0, void 0, function () {
5122
5109
  return __generator(this, function (_15) {
5123
5110
  switch (_15.label) {
5124
- case 0: return [4 /*yield*/, validations_2.validate(field_1.validation)];
5111
+ case 0: return [4 /*yield*/, ruleEngine_2.run(field_1.validation)];
5125
5112
  case 1:
5126
5113
  _15.sent();
5127
5114
  return [2 /*return*/];
@@ -5196,7 +5183,7 @@
5196
5183
  if (field_1.isFormElement &&
5197
5184
  kwikidToolkit.checkObjectKeyExists(field_1, "validation") &&
5198
5185
  field_1.validation.triggers.includes("ON_CHANGE")) {
5199
- var validations_3 = new kwikidToolkit.Validation({
5186
+ var ruleEngine_3 = new kwikidToolkit.RuleEngine({
5200
5187
  FIELD_CONFIG: field_1,
5201
5188
  FORM_FIELDS: this.formFields,
5202
5189
  FORM_DATA: this.formData,
@@ -5207,7 +5194,7 @@
5207
5194
  (function () { return __awaiter(_this, void 0, void 0, function () {
5208
5195
  return __generator(this, function (_15) {
5209
5196
  switch (_15.label) {
5210
- case 0: return [4 /*yield*/, validations_3.validate(field_1.validation)];
5197
+ case 0: return [4 /*yield*/, ruleEngine_3.run(field_1.validation)];
5211
5198
  case 1:
5212
5199
  _15.sent();
5213
5200
  return [2 /*return*/];
@@ -5286,7 +5273,7 @@
5286
5273
  if (kwikidToolkit.checkObjectKeyExists(field_2, "validation")) {
5287
5274
  if (kwikidToolkit.checkObjectKeyExists(field_2.validation, "triggers") &&
5288
5275
  field_2.validation.triggers.includes("ON_RESPONSE")) {
5289
- var validations_4 = new kwikidToolkit.Validation({
5276
+ var ruleEngine_4 = new kwikidToolkit.RuleEngine({
5290
5277
  FIELD_CONFIG: field_2,
5291
5278
  FORM_FIELDS: this.formFields,
5292
5279
  FORM_DATA: this.formData,
@@ -5297,7 +5284,7 @@
5297
5284
  (function () { return __awaiter(_this, void 0, void 0, function () {
5298
5285
  return __generator(this, function (_15) {
5299
5286
  switch (_15.label) {
5300
- case 0: return [4 /*yield*/, validations_4.validate(field_2.validation)];
5287
+ case 0: return [4 /*yield*/, ruleEngine_4.run(field_2.validation)];
5301
5288
  case 1:
5302
5289
  _15.sent();
5303
5290
  return [2 /*return*/];
@@ -5338,7 +5325,7 @@
5338
5325
  };
5339
5326
  KwikIDFormViewComponent.prototype.initFormConfig = function (formConfig) {
5340
5327
  return __awaiter(this, void 0, void 0, function () {
5341
- var _15, _16, preTask, task, e_1_1, _17, _loop_1, this_1, _18, _19, field, _20, _21, field, validations, e_2_1;
5328
+ var _15, _16, preTask, task, e_1_1, _17, _loop_1, this_1, _18, _19, field, _20, _21, field, ruleEngine, e_2_1;
5342
5329
  var e_1, _22, e_3, _23, e_2, _24;
5343
5330
  var _this = this;
5344
5331
  return __generator(this, function (_25) {
@@ -5493,7 +5480,7 @@
5493
5480
  if (!field.isFormElement) return [3 /*break*/, 16];
5494
5481
  if (!kwikidToolkit.checkObjectKeyExists(field, "validation")) return [3 /*break*/, 15];
5495
5482
  if (!field.validation.triggers.includes("ON_INIT")) return [3 /*break*/, 15];
5496
- validations = new kwikidToolkit.Validation({
5483
+ ruleEngine = new kwikidToolkit.RuleEngine({
5497
5484
  FIELD_CONFIG: field,
5498
5485
  FORM_FIELDS: this.formFields,
5499
5486
  FORM_DATA: this.formData,
@@ -5501,7 +5488,7 @@
5501
5488
  PREVIOUS_FORM_DATA: this.previousFormData,
5502
5489
  ALL_FORMS_DATA: this.allFormsData
5503
5490
  }, this.takeAction.bind(this));
5504
- return [4 /*yield*/, validations.validate(field.validation)];
5491
+ return [4 /*yield*/, ruleEngine.run(field.validation)];
5505
5492
  case 14:
5506
5493
  _25.sent();
5507
5494
  _25.label = 15;
@@ -5988,7 +5975,7 @@
5988
5975
  /** CameraType = CAPTURE */
5989
5976
  KwikIDFormViewComponent.prototype.setCameraMedia = function (media) {
5990
5977
  return __awaiter(this, void 0, void 0, function () {
5991
- var field, validations_5;
5978
+ var field, ruleEngine_5;
5992
5979
  var _15;
5993
5980
  var _this = this;
5994
5981
  return __generator(this, function (_16) {
@@ -6023,7 +6010,7 @@
6023
6010
  if (field.isFormElement &&
6024
6011
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
6025
6012
  field.validation.triggers.includes("ON_CHANGE")) {
6026
- validations_5 = new kwikidToolkit.Validation({
6013
+ ruleEngine_5 = new kwikidToolkit.RuleEngine({
6027
6014
  FIELD_CONFIG: field,
6028
6015
  FORM_FIELDS: this.formFields,
6029
6016
  FORM_DATA: this.formData,
@@ -6034,7 +6021,7 @@
6034
6021
  (function () { return __awaiter(_this, void 0, void 0, function () {
6035
6022
  return __generator(this, function (_15) {
6036
6023
  switch (_15.label) {
6037
- case 0: return [4 /*yield*/, validations_5.validate(field.validation)];
6024
+ case 0: return [4 /*yield*/, ruleEngine_5.run(field.validation)];
6038
6025
  case 1:
6039
6026
  _15.sent();
6040
6027
  return [2 /*return*/];
@@ -6200,7 +6187,7 @@
6200
6187
  if (field.isFormElement &&
6201
6188
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
6202
6189
  field.validation.triggers.includes("ON_CHANGE")) {
6203
- var validations_6 = new kwikidToolkit.Validation({
6190
+ var ruleEngine_6 = new kwikidToolkit.RuleEngine({
6204
6191
  FIELD_CONFIG: field,
6205
6192
  FORM_FIELDS: this.formFields,
6206
6193
  FORM_DATA: this.formData,
@@ -6211,7 +6198,7 @@
6211
6198
  (function () { return __awaiter(_this, void 0, void 0, function () {
6212
6199
  return __generator(this, function (_15) {
6213
6200
  switch (_15.label) {
6214
- case 0: return [4 /*yield*/, validations_6.validate(field.validation)];
6201
+ case 0: return [4 /*yield*/, ruleEngine_6.run(field.validation)];
6215
6202
  case 1:
6216
6203
  _15.sent();
6217
6204
  return [2 /*return*/];
@@ -6406,7 +6393,7 @@
6406
6393
  };
6407
6394
  KwikIDFormViewComponent.prototype.handleOnClickLiveLocation = function (e) {
6408
6395
  return __awaiter(this, void 0, void 0, function () {
6409
- var field, validations_7;
6396
+ var field, ruleEngine_7;
6410
6397
  var _15;
6411
6398
  var _this = this;
6412
6399
  return __generator(this, function (_16) {
@@ -6448,7 +6435,7 @@
6448
6435
  if (field.isFormElement &&
6449
6436
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
6450
6437
  field.validation.triggers.includes("ON_CHANGE")) {
6451
- validations_7 = new kwikidToolkit.Validation({
6438
+ ruleEngine_7 = new kwikidToolkit.RuleEngine({
6452
6439
  FIELD_CONFIG: field,
6453
6440
  FORM_FIELDS: this.formFields,
6454
6441
  FORM_DATA: this.formData,
@@ -6459,7 +6446,7 @@
6459
6446
  (function () { return __awaiter(_this, void 0, void 0, function () {
6460
6447
  return __generator(this, function (_15) {
6461
6448
  switch (_15.label) {
6462
- case 0: return [4 /*yield*/, validations_7.validate(field.validation)];
6449
+ case 0: return [4 /*yield*/, ruleEngine_7.run(field.validation)];
6463
6450
  case 1:
6464
6451
  _15.sent();
6465
6452
  return [2 /*return*/];
@@ -6494,7 +6481,7 @@
6494
6481
  if (field.isFormElement &&
6495
6482
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
6496
6483
  field.validation.triggers.includes("ON_CHANGE")) {
6497
- var validations_8 = new kwikidToolkit.Validation({
6484
+ var ruleEngine_8 = new kwikidToolkit.RuleEngine({
6498
6485
  FIELD_CONFIG: field,
6499
6486
  FORM_FIELDS: this.formFields,
6500
6487
  FORM_DATA: this.formData,
@@ -6505,7 +6492,7 @@
6505
6492
  (function () { return __awaiter(_this, void 0, void 0, function () {
6506
6493
  return __generator(this, function (_15) {
6507
6494
  switch (_15.label) {
6508
- case 0: return [4 /*yield*/, validations_8.validate(field.validation)];
6495
+ case 0: return [4 /*yield*/, ruleEngine_8.run(field.validation)];
6509
6496
  case 1:
6510
6497
  _15.sent();
6511
6498
  return [2 /*return*/];
@@ -6912,7 +6899,7 @@
6912
6899
  };
6913
6900
  KwikIDFormViewComponent.prototype.handleOnClickSaveForm = function (e) {
6914
6901
  return __awaiter(this, void 0, void 0, function () {
6915
- var controls, firstFieldWithError, controls_1, controls_1_1, control, field, _15, _16, field, validations, e_13_1, formData, _17, _18, field, extendedFormData, _19, _20, postTask, task, e_14_1;
6902
+ var controls, firstFieldWithError, controls_1, controls_1_1, control, field, _15, _16, field, ruleEngine, e_13_1, formData, _17, _18, field, extendedFormData, _19, _20, postTask, task, e_14_1;
6916
6903
  var e_15, _21, e_13, _22, e_16, _23, e_14, _24;
6917
6904
  var _this = this;
6918
6905
  return __generator(this, function (_25) {
@@ -6969,7 +6956,7 @@
6969
6956
  !field.hidden &&
6970
6957
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
6971
6958
  field.validation.triggers.includes("ON_SAVE"))) return [3 /*break*/, 4];
6972
- validations = new kwikidToolkit.Validation({
6959
+ ruleEngine = new kwikidToolkit.RuleEngine({
6973
6960
  FIELD_CONFIG: field,
6974
6961
  FORM_FIELDS: this.formFields,
6975
6962
  FORM_DATA: this.formData,
@@ -6977,7 +6964,7 @@
6977
6964
  PREVIOUS_FORM_DATA: this.previousFormData,
6978
6965
  ALL_FORMS_DATA: this.allFormsData
6979
6966
  }, this.takeAction.bind(this));
6980
- return [4 /*yield*/, validations.validate(field.validation)];
6967
+ return [4 /*yield*/, ruleEngine.run(field.validation)];
6981
6968
  case 3:
6982
6969
  _25.sent();
6983
6970
  if (!field.validation.is_valid) {
@@ -7455,7 +7442,7 @@
7455
7442
  };
7456
7443
  KwikIDFormViewComponent.prototype.fieldApiTimerMessageHide = function (fieldKey) {
7457
7444
  return __awaiter(this, void 0, void 0, function () {
7458
- var field, fieldIndex, validations_9;
7445
+ var field, fieldIndex, ruleEngine_9;
7459
7446
  var _this = this;
7460
7447
  return __generator(this, function (_15) {
7461
7448
  field = getFormFieldByKey(this.formFields, fieldKey);
@@ -7466,7 +7453,7 @@
7466
7453
  if (field.isFormElement &&
7467
7454
  kwikidToolkit.checkObjectKeyExists(field, "validation") &&
7468
7455
  field.validation.triggers.includes("ON_API_TIMER_STOP")) {
7469
- validations_9 = new kwikidToolkit.Validation({
7456
+ ruleEngine_9 = new kwikidToolkit.RuleEngine({
7470
7457
  FIELD_CONFIG: field,
7471
7458
  FORM_FIELDS: this.formFields,
7472
7459
  FORM_DATA: this.formData,
@@ -7477,7 +7464,7 @@
7477
7464
  (function () { return __awaiter(_this, void 0, void 0, function () {
7478
7465
  return __generator(this, function (_15) {
7479
7466
  switch (_15.label) {
7480
- case 0: return [4 /*yield*/, validations_9.validate(field.validation)];
7467
+ case 0: return [4 /*yield*/, ruleEngine_9.run(field.validation)];
7481
7468
  case 1:
7482
7469
  _15.sent();
7483
7470
  return [2 /*return*/];