kwikid-forms 0.2.10 → 0.2.11

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.
@@ -1642,6 +1642,26 @@
1642
1642
  failed: "API Failed"
1643
1643
  });
1644
1644
  }
1645
+ if (!kwikidToolkit.checkObjectKeyExists(field.api, "request") &&
1646
+ !kwikidToolkit.checkObjectKeyExists(field.api, "entrypoint")) {
1647
+ // Set entrypoint as First endpoint.
1648
+ var entrypoint = {
1649
+ triggers: ["ON_API_CALL"],
1650
+ rules: [],
1651
+ actions: [
1652
+ {
1653
+ id: "1",
1654
+ key: "API_CALL",
1655
+ condition: "true",
1656
+ props: {
1657
+ fieldKey: field.key,
1658
+ apiKey: field.api.endpoints[0].apiKey
1659
+ }
1660
+ }
1661
+ ]
1662
+ };
1663
+ field = kwikidToolkit.setMissingKeyValue(field.api, "entrypoint", entrypoint);
1664
+ }
1645
1665
  return field;
1646
1666
  };
1647
1667
  var formatFieldTypeOtp = function (field) {
@@ -2112,6 +2132,8 @@
2112
2132
  EActionKey["FIELD_GROUP_ENABLE"] = "FIELD_GROUP_ENABLE";
2113
2133
  EActionKey["FIELD_GROUP_DISABLE"] = "FIELD_GROUP_DISABLE";
2114
2134
  EActionKey["SET_DROPDOWN_OPTIONS"] = "SET_DROPDOWN_OPTIONS";
2135
+ EActionKey["API_CALL"] = "API_CALL";
2136
+ EActionKey["API_CALL_END"] = "API_CALL_END";
2115
2137
  })(EActionKey || (EActionKey = {}));
2116
2138
 
2117
2139
  var EApiStatusType;
@@ -2121,6 +2143,11 @@
2121
2143
  EApiStatusType["SUCCESS"] = "success";
2122
2144
  EApiStatusType["FAILED"] = "failed";
2123
2145
  })(EApiStatusType || (EApiStatusType = {}));
2146
+ var EApiRequestUrlType;
2147
+ (function (EApiRequestUrlType) {
2148
+ EApiRequestUrlType["MOCK"] = "MOCK";
2149
+ EApiRequestUrlType["CALCULATED"] = "CALCULATED";
2150
+ })(EApiRequestUrlType || (EApiRequestUrlType = {}));
2124
2151
 
2125
2152
  var EMessageType;
2126
2153
  (function (EMessageType) {
@@ -2474,10 +2501,8 @@
2474
2501
  function Apis(object, takeAction) {
2475
2502
  this._object = object;
2476
2503
  this._takeAction = takeAction;
2477
- this._api = this._object.FIELD_CONFIG.api;
2478
- this._request = this._object.FIELD_CONFIG.api.request;
2479
- this._response = this._object.FIELD_CONFIG.api.response;
2480
- this._status = this._object.FIELD_CONFIG.api.status;
2504
+ this._request = this._object.API_CONFIG.request;
2505
+ this._response = this._object.API_CONFIG.response;
2481
2506
  }
2482
2507
  Object.defineProperty(Apis.prototype, "object", {
2483
2508
  get: function () {
@@ -2489,6 +2514,28 @@
2489
2514
  enumerable: false,
2490
2515
  configurable: true
2491
2516
  });
2517
+ Apis.prototype.setUrl = function () {
2518
+ return __awaiter(this, void 0, void 0, function () {
2519
+ var source, url;
2520
+ return __generator(this, function (_e) {
2521
+ switch (_e.label) {
2522
+ case 0:
2523
+ if (!(this._request.url.hasOwnProperty("type") &&
2524
+ this._request.url.type === EApiRequestUrlType.CALCULATED)) return [3 /*break*/, 2];
2525
+ source = new kwikidToolkit.Source(this._object);
2526
+ return [4 /*yield*/, source.getValueFromSource(this._request.url.props.value.source)];
2527
+ case 1:
2528
+ url = _e.sent();
2529
+ this._request.url = kwikidToolkit.setValueToObjectPath(this._request.url, "value", url);
2530
+ return [3 /*break*/, 3];
2531
+ case 2:
2532
+ this._request.url = kwikidToolkit.setValueToObjectPath({}, "value", this._request.url);
2533
+ _e.label = 3;
2534
+ case 3: return [2 /*return*/, this._object.API_CONFIG];
2535
+ }
2536
+ });
2537
+ });
2538
+ };
2492
2539
  Apis.prototype.setRequestBody = function () {
2493
2540
  var _a, _b, _c, _d;
2494
2541
  return __awaiter(this, void 0, void 0, function () {
@@ -2497,6 +2544,8 @@
2497
2544
  return __generator(this, function (_h) {
2498
2545
  switch (_h.label) {
2499
2546
  case 0:
2547
+ if (!kwikidToolkit.checkObjectKeyExists(this._request, "body")) return [3 /*break*/, 25];
2548
+ if (!kwikidToolkit.checkObjectKeyExists(this._request.headers, "params")) return [3 /*break*/, 23];
2500
2549
  params = this._request.body.params;
2501
2550
  paramIndex = 0;
2502
2551
  _h.label = 1;
@@ -2520,7 +2569,7 @@
2520
2569
  sources_2 = new kwikidToolkit.Source(this._object);
2521
2570
  value = sources_2.getValueFromSource(source);
2522
2571
  // Set the Value of current source.
2523
- this._object.FIELD_CONFIG = kwikidToolkit.setValueToObjectPath(this._object.FIELD_CONFIG, "api.request.body.params[" + paramIndex + "].sources[" + sourceIndex + "].value", value);
2572
+ this._object.API_CONFIG = kwikidToolkit.setValueToObjectPath(this._object.API_CONFIG, "request.body.params[" + paramIndex + "].sources[" + sourceIndex + "].value", value);
2524
2573
  validation = source.validation;
2525
2574
  triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
2526
2575
  rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
@@ -2589,7 +2638,11 @@
2589
2638
  }
2590
2639
  finally { if (e_3) throw e_3.error; }
2591
2640
  return [7 /*endfinally*/];
2592
- case 22: return [2 /*return*/, this._object.FIELD_CONFIG];
2641
+ case 22: return [2 /*return*/, this._object.API_CONFIG];
2642
+ case 23: return [2 /*return*/, this._object.API_CONFIG];
2643
+ case 24: return [3 /*break*/, 26];
2644
+ case 25: return [2 /*return*/, this._object.API_CONFIG];
2645
+ case 26: return [2 /*return*/];
2593
2646
  }
2594
2647
  });
2595
2648
  });
@@ -2602,6 +2655,8 @@
2602
2655
  return __generator(this, function (_f) {
2603
2656
  switch (_f.label) {
2604
2657
  case 0:
2658
+ if (!kwikidToolkit.checkObjectKeyExists(this._request, "body")) return [3 /*break*/, 11];
2659
+ if (!kwikidToolkit.checkObjectKeyExists(this._request.body, "validation")) return [3 /*break*/, 9];
2605
2660
  body = this._request.body;
2606
2661
  validation = body.validation;
2607
2662
  triggers = validation.triggers;
@@ -2637,7 +2692,11 @@
2637
2692
  }
2638
2693
  finally { if (e_4) throw e_4.error; }
2639
2694
  return [7 /*endfinally*/];
2640
- case 8: return [2 /*return*/, this._object.FIELD_CONFIG];
2695
+ case 8: return [2 /*return*/, this._object.API_CONFIG];
2696
+ case 9: return [2 /*return*/, this._object.API_CONFIG];
2697
+ case 10: return [3 /*break*/, 12];
2698
+ case 11: return [2 /*return*/, this._object.API_CONFIG];
2699
+ case 12: return [2 /*return*/];
2641
2700
  }
2642
2701
  });
2643
2702
  });
@@ -2675,7 +2734,7 @@
2675
2734
  sources_4 = new kwikidToolkit.Source(this._object);
2676
2735
  value = sources_4.getValueFromSource(source);
2677
2736
  // Set the Value of current source.
2678
- this._object.FIELD_CONFIG = kwikidToolkit.setValueToObjectPath(this._object.FIELD_CONFIG, "api.request.headers.params[" + paramIndex + "].sources[" + sourceIndex + "].value", value);
2737
+ this._object.API_CONFIG = kwikidToolkit.setValueToObjectPath(this._object.API_CONFIG, "request.headers.params[" + paramIndex + "].sources[" + sourceIndex + "].value", value);
2679
2738
  validation = source.validation;
2680
2739
  triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
2681
2740
  rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
@@ -2744,10 +2803,10 @@
2744
2803
  }
2745
2804
  finally { if (e_7) throw e_7.error; }
2746
2805
  return [7 /*endfinally*/];
2747
- case 22: return [2 /*return*/, this._object.FIELD_CONFIG];
2748
- case 23: return [2 /*return*/, this._object.FIELD_CONFIG];
2806
+ case 22: return [2 /*return*/, this._object.API_CONFIG];
2807
+ case 23: return [2 /*return*/, this._object.API_CONFIG];
2749
2808
  case 24: return [3 /*break*/, 26];
2750
- case 25: return [2 /*return*/, this._object.FIELD_CONFIG];
2809
+ case 25: return [2 /*return*/, this._object.API_CONFIG];
2751
2810
  case 26: return [2 /*return*/];
2752
2811
  }
2753
2812
  });
@@ -2798,10 +2857,10 @@
2798
2857
  }
2799
2858
  finally { if (e_8) throw e_8.error; }
2800
2859
  return [7 /*endfinally*/];
2801
- case 8: return [2 /*return*/, this._object.FIELD_CONFIG];
2802
- case 9: return [2 /*return*/, this._object.FIELD_CONFIG];
2860
+ case 8: return [2 /*return*/, this._object.API_CONFIG];
2861
+ case 9: return [2 /*return*/, this._object.API_CONFIG];
2803
2862
  case 10: return [3 /*break*/, 12];
2804
- case 11: return [2 /*return*/, this._object.FIELD_CONFIG];
2863
+ case 11: return [2 /*return*/, this._object.API_CONFIG];
2805
2864
  case 12: return [2 /*return*/];
2806
2865
  }
2807
2866
  });
@@ -2814,6 +2873,7 @@
2814
2873
  return __generator(this, function (_f) {
2815
2874
  switch (_f.label) {
2816
2875
  case 0:
2876
+ if (!kwikidToolkit.checkObjectKeyExists(this._response, "validation")) return [3 /*break*/, 8];
2817
2877
  validation = this._response.validation;
2818
2878
  triggers = validation.triggers;
2819
2879
  rules = validation.rules;
@@ -2848,13 +2908,61 @@
2848
2908
  }
2849
2909
  finally { if (e_9) throw e_9.error; }
2850
2910
  return [7 /*endfinally*/];
2851
- case 8: return [2 /*return*/, this._object.FIELD_CONFIG];
2911
+ case 8: return [2 /*return*/, this._object.API_CONFIG];
2912
+ }
2913
+ });
2914
+ });
2915
+ };
2916
+ Apis.prototype.callNextApi = function (validation) {
2917
+ var _a;
2918
+ return __awaiter(this, void 0, void 0, function () {
2919
+ var rules, actions, rulesMapping, actions_11, actions_11_1, action, conditionSuccess, actions_12, e_10_1;
2920
+ var e_10, _e;
2921
+ return __generator(this, function (_f) {
2922
+ switch (_f.label) {
2923
+ case 0:
2924
+ rules = validation.rules;
2925
+ actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
2926
+ rulesMapping = new kwikidToolkit.Rule(rules, this._object).mapping();
2927
+ _f.label = 1;
2928
+ case 1:
2929
+ _f.trys.push([1, 6, 7, 8]);
2930
+ actions_11 = __values(actions), actions_11_1 = actions_11.next();
2931
+ _f.label = 2;
2932
+ case 2:
2933
+ if (!!actions_11_1.done) return [3 /*break*/, 5];
2934
+ action = actions_11_1.value;
2935
+ conditionSuccess = new kwikidToolkit.Condition(action.condition, rulesMapping).evaluate();
2936
+ if (!conditionSuccess) return [3 /*break*/, 4];
2937
+ actions_12 = new kwikidToolkit.Action(action, rulesMapping, this._object, this._takeAction);
2938
+ return [4 /*yield*/, actions_12.execute()];
2939
+ case 3:
2940
+ _f.sent();
2941
+ _f.label = 4;
2942
+ case 4:
2943
+ actions_11_1 = actions_11.next();
2944
+ return [3 /*break*/, 2];
2945
+ case 5: return [3 /*break*/, 8];
2946
+ case 6:
2947
+ e_10_1 = _f.sent();
2948
+ e_10 = { error: e_10_1 };
2949
+ return [3 /*break*/, 8];
2950
+ case 7:
2951
+ try {
2952
+ if (actions_11_1 && !actions_11_1.done && (_e = actions_11.return)) _e.call(actions_11);
2953
+ }
2954
+ finally { if (e_10) throw e_10.error; }
2955
+ return [7 /*endfinally*/];
2956
+ case 8: return [2 /*return*/];
2852
2957
  }
2853
2958
  });
2854
2959
  });
2855
2960
  };
2856
2961
  return Apis;
2857
2962
  }());
2963
+ __decorate([
2964
+ kwikidToolkit.logMethod
2965
+ ], Apis.prototype, "setUrl", null);
2858
2966
  __decorate([
2859
2967
  kwikidToolkit.logMethod
2860
2968
  ], Apis.prototype, "setRequestBody", null);
@@ -2870,6 +2978,9 @@
2870
2978
  __decorate([
2871
2979
  kwikidToolkit.logMethod
2872
2980
  ], Apis.prototype, "validateResponse", null);
2981
+ __decorate([
2982
+ kwikidToolkit.logMethod
2983
+ ], Apis.prototype, "callNextApi", null);
2873
2984
 
2874
2985
  /**
2875
2986
  * Generated class for the SafeHtmlPipe pipe.
@@ -3402,72 +3513,75 @@
3402
3513
  });
3403
3514
  });
3404
3515
  };
3405
- KwikIDFormViewComponent.prototype.handleOnClickApiCall = function (e) {
3516
+ KwikIDFormViewComponent.prototype.handleApiCall = function (field, api) {
3406
3517
  var _a, _b, _c, _d, _e, _f, _g;
3407
3518
  return __awaiter(this, void 0, void 0, function () {
3408
- var field, apis, apiCallResponse, url, method, headers, body, response, apis_1;
3519
+ var apis, apiCallResponse, url, method, headers, body, response, apis_1;
3409
3520
  var _h, _j;
3410
3521
  var _this = this;
3411
3522
  return __generator(this, function (_k) {
3412
3523
  switch (_k.label) {
3413
3524
  case 0:
3414
- field = getFormFieldByKey(this.formFields, e.key);
3415
- if (!(field.type === "api-call")) return [3 /*break*/, 11];
3416
- // set button status to loading
3417
- field["api"]["status"]["value"] = EApiStatusType.LOADING;
3418
- field["showLoader"] = true;
3419
- this.viewFormsButton["disabled"] = true;
3420
- this.viewFormsButton["showLoader"] = true;
3421
- this.saveFormButton["disabled"] = true;
3422
- this.saveFormButton["showLoader"] = true;
3423
3525
  apis = new Apis({
3424
3526
  FIELD_CONFIG: field,
3527
+ API_CONFIG: api,
3425
3528
  FORM_FIELDS: this.formFields,
3426
3529
  FORM_DATA: this.formData,
3427
3530
  PREVIOUS_FORM_DATA: this.previousFormData,
3428
3531
  ALL_FORMS_DATA: this.allFormsData
3429
3532
  }, this.takeAction.bind(this));
3430
- return [4 /*yield*/, apis.setRequestHeaders()];
3533
+ return [4 /*yield*/, apis.setUrl()];
3431
3534
  case 1:
3432
- field = _k.sent();
3433
- return [4 /*yield*/, apis.validateRequestHeaders()];
3535
+ api = _k.sent();
3536
+ return [4 /*yield*/, apis.setRequestHeaders()];
3434
3537
  case 2:
3435
- field = _k.sent();
3436
- return [4 /*yield*/, apis.setRequestBody()];
3538
+ api = _k.sent();
3539
+ return [4 /*yield*/, apis.validateRequestHeaders()];
3437
3540
  case 3:
3438
- field = _k.sent();
3439
- return [4 /*yield*/, apis.validateRequestBody()];
3541
+ api = _k.sent();
3542
+ return [4 /*yield*/, apis.setRequestBody()];
3440
3543
  case 4:
3441
- field = _k.sent();
3442
- if (!field.api.request.body.validation.is_valid) return [3 /*break*/, 9];
3443
- apiCallResponse = undefined;
3444
- if (!(field.api.request.url.hasOwnProperty("type") &&
3445
- field.api.request.url.type === "MOCK")) return [3 /*break*/, 5];
3446
- apiCallResponse = field.api.request.url.data;
3447
- return [3 /*break*/, 8];
3544
+ api = _k.sent();
3545
+ return [4 /*yield*/, apis.validateRequestBody()];
3448
3546
  case 5:
3449
- url = field.api.request.url;
3450
- method = (_b = (_a = field.api.request) === null || _a === void 0 ? void 0 : _a.method) !== null && _b !== void 0 ? _b : "POST";
3451
- headers = Object.assign({ "Content-Type": "application/json" }, (((_d = (_c = field.api.request) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d.value) || {}));
3452
- body = (_g = (_f = (_e = field.api.request) === null || _e === void 0 ? void 0 : _e.body) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : null;
3547
+ api = _k.sent();
3548
+ apiCallResponse = undefined;
3549
+ if (!api.request.body.validation.is_valid) return [3 /*break*/, 10];
3550
+ if (!(api.request.url.hasOwnProperty("type") &&
3551
+ api.request.url.type === EApiRequestUrlType.MOCK)) return [3 /*break*/, 6];
3552
+ apiCallResponse = api.request.url.props.mockedData.data;
3553
+ return [3 /*break*/, 9];
3554
+ case 6:
3555
+ url = api.request.url.value;
3556
+ method = (_b = (_a = api.request) === null || _a === void 0 ? void 0 : _a.method) !== null && _b !== void 0 ? _b : "POST";
3557
+ headers = Object.assign({ "Content-Type": "application/json" }, (((_d = (_c = api.request) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d.value) || {}));
3558
+ body = (_g = (_f = (_e = api.request) === null || _e === void 0 ? void 0 : _e.body) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : null;
3453
3559
  return [4 /*yield*/, fetch(url, {
3454
3560
  method: method,
3455
3561
  headers: Object.assign({}, headers),
3456
3562
  body: JSON.stringify(body)
3457
3563
  })];
3458
- case 6:
3564
+ case 7:
3459
3565
  response = _k.sent();
3460
3566
  return [4 /*yield*/, response.json()];
3461
- case 7:
3462
- apiCallResponse = _k.sent();
3463
- _k.label = 8;
3464
3567
  case 8:
3465
- this.formData = Object.assign(Object.assign({}, this.formData), (_h = {}, _h[field.key] = apiCallResponse, _h));
3466
- this.formGroup.patchValue((_j = {},
3467
- _j[field.key] = apiCallResponse,
3468
- _j), { emitEvent: false });
3568
+ apiCallResponse = _k.sent();
3569
+ _k.label = 9;
3570
+ case 9:
3571
+ /**
3572
+ * This runs when API is in old format or new.
3573
+ * If Old Format then it directly patches api response to field data
3574
+ */
3575
+ if (kwikidToolkit.checkObjectKeyExists(field.api, "request")) {
3576
+ this.formData = Object.assign(Object.assign({}, this.formData), (_h = {}, _h[field.key] = apiCallResponse, _h));
3577
+ this.formGroup.patchValue((_j = {},
3578
+ _j[field.key] = apiCallResponse,
3579
+ _j), { emitEvent: false });
3580
+ }
3581
+ api.response = kwikidToolkit.setMissingKeyValue(api.response, "value", apiCallResponse);
3469
3582
  apis_1 = new Apis({
3470
3583
  FIELD_CONFIG: field,
3584
+ API_CONFIG: api,
3471
3585
  FORM_FIELDS: this.formFields,
3472
3586
  FORM_DATA: this.formData,
3473
3587
  PREVIOUS_FORM_DATA: this.previousFormData,
@@ -3478,28 +3592,63 @@
3478
3592
  switch (_h.label) {
3479
3593
  case 0: return [4 /*yield*/, apis_1.validateResponse()];
3480
3594
  case 1:
3481
- field = _h.sent();
3595
+ api = _h.sent();
3482
3596
  return [2 /*return*/];
3483
3597
  }
3484
3598
  });
3485
3599
  }); })();
3486
- return [3 /*break*/, 10];
3487
- case 9:
3488
- // Request Body Validation Failed
3489
- // Highlight Error in UI to User to Retry After Sometime.
3490
- // Take Action based on Validation
3600
+ return [3 /*break*/, 11];
3601
+ case 10:
3491
3602
  setTimeout(function () {
3492
3603
  field["api"]["status"]["value"] = EApiStatusType.FAILED;
3493
3604
  field["showLoader"] = false;
3494
3605
  }, 500);
3495
- _k.label = 10;
3496
- case 10:
3606
+ _k.label = 11;
3607
+ case 11: return [2 /*return*/, { field: field, api: api }];
3608
+ }
3609
+ });
3610
+ });
3611
+ };
3612
+ KwikIDFormViewComponent.prototype.handleOnClickApiCall = function (e) {
3613
+ return __awaiter(this, void 0, void 0, function () {
3614
+ var field, apis;
3615
+ return __generator(this, function (_h) {
3616
+ switch (_h.label) {
3617
+ case 0:
3618
+ field = getFormFieldByKey(this.formFields, e.key);
3619
+ if (!(field.type === "api-call")) return [3 /*break*/, 5];
3620
+ // set button status to loading
3621
+ field["api"]["status"]["value"] = EApiStatusType.LOADING;
3622
+ field["showLoader"] = true;
3623
+ this.viewFormsButton["disabled"] = true;
3624
+ this.viewFormsButton["showLoader"] = true;
3625
+ this.saveFormButton["disabled"] = true;
3626
+ this.saveFormButton["showLoader"] = true;
3627
+ if (!kwikidToolkit.checkObjectKeyExists(field.api, "request")) return [3 /*break*/, 2];
3628
+ return [4 /*yield*/, this.handleApiCall(field, field.api)];
3629
+ case 1:
3630
+ _h.sent();
3631
+ return [3 /*break*/, 4];
3632
+ case 2:
3633
+ apis = new Apis({
3634
+ FIELD_CONFIG: field,
3635
+ API_CONFIG: {},
3636
+ FORM_FIELDS: this.formFields,
3637
+ FORM_DATA: this.formData,
3638
+ PREVIOUS_FORM_DATA: this.previousFormData,
3639
+ ALL_FORMS_DATA: this.allFormsData
3640
+ }, this.takeAction.bind(this));
3641
+ return [4 /*yield*/, apis.callNextApi(field.api.entrypoint)];
3642
+ case 3:
3643
+ _h.sent();
3644
+ _h.label = 4;
3645
+ case 4:
3497
3646
  this.viewFormsButton["disabled"] = false;
3498
3647
  this.viewFormsButton["showLoader"] = false;
3499
3648
  this.saveFormButton["disabled"] = false;
3500
3649
  this.saveFormButton["showLoader"] = false;
3501
- _k.label = 11;
3502
- case 11: return [2 /*return*/];
3650
+ _h.label = 5;
3651
+ case 5: return [2 /*return*/];
3503
3652
  }
3504
3653
  });
3505
3654
  });
@@ -3827,7 +3976,6 @@
3827
3976
  field = removeFormFieldMessage(field, message);
3828
3977
  this.formFields[fieldIndex] = field;
3829
3978
  };
3830
- KwikIDFormViewComponent.prototype.setObjectValue = function (field, path, value) { };
3831
3979
  KwikIDFormViewComponent.prototype.patchFieldControlValue = function (key, value) {
3832
3980
  var _h;
3833
3981
  this.formGroup.patchValue((_h = {},
@@ -3839,7 +3987,11 @@
3839
3987
  throw new Error("formGroup or formData is 'undefined'.");
3840
3988
  }
3841
3989
  else {
3842
- this.formGroup.patchValue(formData, { emitEvent: false });
3990
+ var formDataInKwikUIFormat = {};
3991
+ for (var fieldKey in formData) {
3992
+ formDataInKwikUIFormat[fieldKey] = convertFormFieldValueToKwikUIFormat(getFormFieldByKey(this.formFields, fieldKey), formData[fieldKey]);
3993
+ }
3994
+ this.formGroup.patchValue(formDataInKwikUIFormat, { emitEvent: false });
3843
3995
  }
3844
3996
  };
3845
3997
  KwikIDFormViewComponent.prototype.isFieldValid = function (fieldKey) {
@@ -3876,9 +4028,10 @@
3876
4028
  };
3877
4029
  KwikIDFormViewComponent.prototype.takeAction = function (action, object) {
3878
4030
  return __awaiter(this, void 0, void 0, function () {
3879
- var _h, setValue_Source, sourceValue, setDefaultValue_Source, sourceDefaultValue, destinationDefaultValue_FieldConfig_Config, destinationDefaultValue_FormData_Config__Props__Object__Path, destinationDefaultValue_FormData_Config, setDropdownValue_Sources, dropdownValue, appendToPath, appendToPathStr, optionsPath;
3880
- return __generator(this, function (_j) {
3881
- switch (_j.label) {
4031
+ var _h, setValue_Source, sourceValue, setDefaultValue_Source, sourceDefaultValue, destinationDefaultValue_FieldConfig_Config, destinationDefaultValue_FormData_Config__Props__Object__Path, destinationDefaultValue_FormData_Config, setDropdownValue_Sources, dropdownValue, appendToPath, appendToPathStr, optionsPath, entrypointKey_1, apiField, endpoints, nextApiIndex, response, field, apiCallResponses_1;
4032
+ var _j;
4033
+ return __generator(this, function (_k) {
4034
+ switch (_k.label) {
3882
4035
  case 0:
3883
4036
  _h = action.key;
3884
4037
  switch (_h) {
@@ -3896,52 +4049,54 @@
3896
4049
  case EActionKey.SET_DROPDOWN_OPTIONS: return [3 /*break*/, 14];
3897
4050
  case EActionKey.HANDLE_CONNECTED_ELEMENTS: return [3 /*break*/, 19];
3898
4051
  case EActionKey.CUSTOM: return [3 /*break*/, 20];
4052
+ case EActionKey.API_CALL: return [3 /*break*/, 21];
4053
+ case EActionKey.API_CALL_END: return [3 /*break*/, 23];
3899
4054
  }
3900
- return [3 /*break*/, 21];
4055
+ return [3 /*break*/, 24];
3901
4056
  case 1:
3902
4057
  this.fieldHide(action.props.fieldKey);
3903
- return [3 /*break*/, 22];
4058
+ return [3 /*break*/, 25];
3904
4059
  case 2:
3905
4060
  this.fieldShow(action.props.fieldKey);
3906
- return [3 /*break*/, 22];
4061
+ return [3 /*break*/, 25];
3907
4062
  case 3:
3908
4063
  this.fieldDisable(action.props.fieldKey);
3909
- return [3 /*break*/, 22];
4064
+ return [3 /*break*/, 25];
3910
4065
  case 4:
3911
4066
  this.fieldEnable(action.props.fieldKey);
3912
- return [3 /*break*/, 22];
4067
+ return [3 /*break*/, 25];
3913
4068
  case 5:
3914
4069
  this.fieldReset(action.props.fieldKey);
3915
- return [3 /*break*/, 22];
4070
+ return [3 /*break*/, 25];
3916
4071
  case 6:
3917
4072
  this.fieldErrorShow(action.props.fieldKey, action.props.message);
3918
- return [3 /*break*/, 22];
4073
+ return [3 /*break*/, 25];
3919
4074
  case 7:
3920
4075
  this.fieldErrorHide(action.props.fieldKey, action.props.message);
3921
- return [3 /*break*/, 22];
4076
+ return [3 /*break*/, 25];
3922
4077
  case 8:
3923
4078
  this.fieldMessageShow(action.props.fieldKey, action.props.message);
3924
- return [3 /*break*/, 22];
4079
+ return [3 /*break*/, 25];
3925
4080
  case 9:
3926
4081
  this.fieldMessageHide(action.props.fieldKey, action.props.message);
3927
- return [3 /*break*/, 22];
4082
+ return [3 /*break*/, 25];
3928
4083
  case 10:
3929
4084
  setValue_Source = new kwikidToolkit.Source(object);
3930
4085
  return [4 /*yield*/, setValue_Source.getValueFromSource(action.props.value.source)];
3931
4086
  case 11:
3932
- sourceValue = _j.sent();
4087
+ sourceValue = _k.sent();
3933
4088
  setValue_Source.setValueToSource(action.props.value.destination, sourceValue);
3934
4089
  object.FIELD_CONFIG = setValue_Source.object.FIELD_CONFIG;
3935
4090
  this.formData = setValue_Source.object.FORM_DATA;
3936
4091
  this.patchFormGroup(this.formData);
3937
4092
  this.allFormsData = setValue_Source.object.ALL_FORMS_DATA;
3938
4093
  this.previousFormData = setValue_Source.object.PREVIOUS_FORM_DATA;
3939
- return [3 /*break*/, 22];
4094
+ return [3 /*break*/, 25];
3940
4095
  case 12:
3941
4096
  setDefaultValue_Source = new kwikidToolkit.Source(object);
3942
4097
  return [4 /*yield*/, setDefaultValue_Source.getValueFromSource(action.props.value.source)];
3943
4098
  case 13:
3944
- sourceDefaultValue = _j.sent();
4099
+ sourceDefaultValue = _k.sent();
3945
4100
  destinationDefaultValue_FieldConfig_Config = {
3946
4101
  key: kwikidToolkit.ESourceKey.OBJECT,
3947
4102
  props: {
@@ -3969,17 +4124,17 @@
3969
4124
  this.allFormsData = setDefaultValue_Source.object.ALL_FORMS_DATA;
3970
4125
  this.previousFormData =
3971
4126
  setDefaultValue_Source.object.PREVIOUS_FORM_DATA;
3972
- return [3 /*break*/, 22];
4127
+ return [3 /*break*/, 25];
3973
4128
  case 14:
3974
4129
  setDropdownValue_Sources = new kwikidToolkit.Source(object);
3975
4130
  return [4 /*yield*/, setDropdownValue_Sources.getValueFromSource(action.props.value.source)];
3976
4131
  case 15:
3977
- dropdownValue = _j.sent();
4132
+ dropdownValue = _k.sent();
3978
4133
  if (!kwikidToolkit.checkObjectKeyExists(action.props, "options")) return [3 /*break*/, 18];
3979
4134
  if (!kwikidToolkit.checkObjectKeyExists(action.props.options, "appendToPath")) return [3 /*break*/, 17];
3980
4135
  return [4 /*yield*/, setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source)];
3981
4136
  case 16:
3982
- appendToPath = _j.sent();
4137
+ appendToPath = _k.sent();
3983
4138
  if (kwikidToolkit.isNotEmptyValue(appendToPath)) {
3984
4139
  appendToPathStr = kwikidToolkit.replaceString(appendToPath.match("" + action.props.options.appendToPath.filterSourceValue)[0], "[^a-zA-Z0-9_]", "_");
3985
4140
  optionsPath = "" + action.props.options.path + appendToPathStr;
@@ -3988,7 +4143,7 @@
3988
4143
  return [3 /*break*/, 18];
3989
4144
  case 17:
3990
4145
  dropdownValue = kwikidToolkit.getObjectValueFromPath(dropdownValue, action.props.options.path);
3991
- _j.label = 18;
4146
+ _k.label = 18;
3992
4147
  case 18:
3993
4148
  setDropdownValue_Sources.setValueToSource(action.props.value.destination, dropdownValue);
3994
4149
  object.FIELD_CONFIG = setDropdownValue_Sources.object.FIELD_CONFIG;
@@ -3996,13 +4151,34 @@
3996
4151
  this.allFormsData = setDropdownValue_Sources.object.ALL_FORMS_DATA;
3997
4152
  this.previousFormData =
3998
4153
  setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
3999
- return [3 /*break*/, 22];
4154
+ return [3 /*break*/, 25];
4000
4155
  case 19:
4001
4156
  this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
4002
- return [3 /*break*/, 22];
4003
- case 20: return [3 /*break*/, 22];
4004
- case 21: return [3 /*break*/, 22];
4005
- case 22: return [2 /*return*/];
4157
+ return [3 /*break*/, 25];
4158
+ case 20: return [3 /*break*/, 25];
4159
+ case 21:
4160
+ entrypointKey_1 = action.props.apiKey;
4161
+ apiField = getFormFieldByKey(this.formFields, action.props.fieldKey);
4162
+ endpoints = apiField.api.endpoints;
4163
+ nextApiIndex = endpoints.findIndex(function (api) { return api.apiKey == entrypointKey_1; });
4164
+ return [4 /*yield*/, this.handleApiCall(apiField, endpoints[nextApiIndex])];
4165
+ case 22:
4166
+ response = _k.sent();
4167
+ apiField = response.field;
4168
+ apiField.api.endpoints[nextApiIndex] = response.api;
4169
+ return [3 /*break*/, 25];
4170
+ case 23:
4171
+ field = getFormFieldByKey(this.formFields, action.props.fieldKey);
4172
+ apiCallResponses_1 = {};
4173
+ field.api.endpoints.map(function (api) {
4174
+ if (kwikidToolkit.checkObjectKeyExists(api.response, "value"))
4175
+ apiCallResponses_1 = kwikidToolkit.setMissingKeyValue(apiCallResponses_1, api.apiKey, api.response.value);
4176
+ });
4177
+ this.formData = Object.assign(Object.assign({}, this.formData), (_j = {}, _j[field.key] = apiCallResponses_1, _j));
4178
+ this.patchFormGroup(this.formData);
4179
+ return [3 /*break*/, 25];
4180
+ case 24: return [3 /*break*/, 25];
4181
+ case 25: return [2 /*return*/];
4006
4182
  }
4007
4183
  });
4008
4184
  });
@@ -4053,6 +4229,9 @@
4053
4229
  __decorate([
4054
4230
  kwikidToolkit.logMethod
4055
4231
  ], KwikIDFormViewComponent.prototype, "handleOnClickResetFormFields", null);
4232
+ __decorate([
4233
+ kwikidToolkit.logMethod
4234
+ ], KwikIDFormViewComponent.prototype, "handleApiCall", null);
4056
4235
  __decorate([
4057
4236
  kwikidToolkit.logMethod
4058
4237
  ], KwikIDFormViewComponent.prototype, "handleOnClickApiCall", null);
@@ -4104,9 +4283,6 @@
4104
4283
  __decorate([
4105
4284
  kwikidToolkit.logMethod
4106
4285
  ], KwikIDFormViewComponent.prototype, "fieldMessageHide", null);
4107
- __decorate([
4108
- kwikidToolkit.logMethod
4109
- ], KwikIDFormViewComponent.prototype, "setObjectValue", null);
4110
4286
  __decorate([
4111
4287
  kwikidToolkit.logMethod
4112
4288
  ], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
@@ -4158,7 +4334,7 @@
4158
4334
  type: i0.Output
4159
4335
  }], onClickApiCall: [{
4160
4336
  type: i0.Output
4161
- }], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setObjectValue: [], patchFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], takeActionOnFieldGroup: [], takeAction: [] } });
4337
+ }], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleApiCall: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], patchFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], takeActionOnFieldGroup: [], takeAction: [] } });
4162
4338
 
4163
4339
  /**
4164
4340
  * Generated class for the SafeHtmlPipe pipe.