kwikid-forms 0.2.10 → 0.3.1
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.
- package/bundles/kwikid-forms.umd.js +275 -95
- package/bundles/kwikid-forms.umd.js.map +1 -1
- package/esm2015/lib/renderer/config-converter.helper.js +22 -2
- package/esm2015/lib/renderer/form-view/definitions/form-view.actions.definition.js +3 -1
- package/esm2015/lib/renderer/form-view/definitions/form-view.apis.definition.js +6 -1
- package/esm2015/lib/renderer/form-view/form-view.component.js +110 -59
- package/esm2015/lib/renderer/form-view/helpers/form-view.apis.helper.js +107 -51
- package/fesm2015/kwikid-forms.js +239 -106
- package/fesm2015/kwikid-forms.js.map +1 -1
- package/lib/renderer/form-view/definitions/form-view.actions.definition.d.ts +17 -2
- package/lib/renderer/form-view/definitions/form-view.apis.definition.d.ts +20 -2
- package/lib/renderer/form-view/form-view.component.d.ts +5 -2
- package/lib/renderer/form-view/helpers/form-view.apis.helper.d.ts +3 -2
- package/package.json +1 -1
|
@@ -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.
|
|
2478
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
2748
|
-
case 23: return [2 /*return*/, this._object.
|
|
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.
|
|
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.
|
|
2802
|
-
case 9: return [2 /*return*/, this._object.
|
|
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.
|
|
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.
|
|
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.
|
|
@@ -2981,8 +3092,8 @@
|
|
|
2981
3092
|
_loop_1 = function (field) {
|
|
2982
3093
|
var _r, _s;
|
|
2983
3094
|
if (field.isFormElement) {
|
|
2984
|
-
this_1.previousFormData = Object.assign(Object.assign({}, this_1.previousFormData), (_r = {}, _r[field.key] = this_1.formGroup.controls[field.key].value, _r));
|
|
2985
|
-
this_1.formData = Object.assign(Object.assign({}, this_1.formData), (_s = {}, _s[field.key] = this_1.formGroup.controls[field.key].value, _s));
|
|
3095
|
+
this_1.previousFormData = Object.assign(Object.assign({}, this_1.previousFormData), (_r = {}, _r[field.key] = convertFormFieldValueToStandardFormat(field, this_1.formGroup.controls[field.key].value), _r));
|
|
3096
|
+
this_1.formData = Object.assign(Object.assign({}, this_1.formData), (_s = {}, _s[field.key] = convertFormFieldValueToStandardFormat(field, this_1.formGroup.controls[field.key].value), _s));
|
|
2986
3097
|
this_1.formGroup.controls[field.key].valueChanges
|
|
2987
3098
|
.pipe(operators.pairwise())
|
|
2988
3099
|
.subscribe(function (_h) {
|
|
@@ -3402,72 +3513,75 @@
|
|
|
3402
3513
|
});
|
|
3403
3514
|
});
|
|
3404
3515
|
};
|
|
3405
|
-
KwikIDFormViewComponent.prototype.
|
|
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
|
|
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.
|
|
3533
|
+
return [4 /*yield*/, apis.setUrl()];
|
|
3431
3534
|
case 1:
|
|
3432
|
-
|
|
3433
|
-
return [4 /*yield*/, apis.
|
|
3535
|
+
api = _k.sent();
|
|
3536
|
+
return [4 /*yield*/, apis.setRequestHeaders()];
|
|
3434
3537
|
case 2:
|
|
3435
|
-
|
|
3436
|
-
return [4 /*yield*/, apis.
|
|
3538
|
+
api = _k.sent();
|
|
3539
|
+
return [4 /*yield*/, apis.validateRequestHeaders()];
|
|
3437
3540
|
case 3:
|
|
3438
|
-
|
|
3439
|
-
return [4 /*yield*/, apis.
|
|
3541
|
+
api = _k.sent();
|
|
3542
|
+
return [4 /*yield*/, apis.setRequestBody()];
|
|
3440
3543
|
case 4:
|
|
3441
|
-
|
|
3442
|
-
|
|
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
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
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
|
|
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
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
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
|
-
|
|
3595
|
+
api = _h.sent();
|
|
3482
3596
|
return [2 /*return*/];
|
|
3483
3597
|
}
|
|
3484
3598
|
});
|
|
3485
3599
|
}); })();
|
|
3486
|
-
return [3 /*break*/,
|
|
3487
|
-
case
|
|
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 =
|
|
3496
|
-
case
|
|
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
|
-
|
|
3502
|
-
case
|
|
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,15 @@
|
|
|
3839
3987
|
throw new Error("formGroup or formData is 'undefined'.");
|
|
3840
3988
|
}
|
|
3841
3989
|
else {
|
|
3842
|
-
|
|
3990
|
+
var formDataInKwikUIFormat = {};
|
|
3991
|
+
for (var fieldKey in formData) {
|
|
3992
|
+
var field = getFormFieldByKey(this.formFields, fieldKey);
|
|
3993
|
+
if (!kwikidToolkit.isUndefined(field) && !kwikidToolkit.isNull(field)) {
|
|
3994
|
+
formDataInKwikUIFormat[fieldKey] =
|
|
3995
|
+
convertFormFieldValueToKwikUIFormat(field, formData[fieldKey]);
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
this.formGroup.patchValue(formDataInKwikUIFormat, { emitEvent: false });
|
|
3843
3999
|
}
|
|
3844
4000
|
};
|
|
3845
4001
|
KwikIDFormViewComponent.prototype.isFieldValid = function (fieldKey) {
|
|
@@ -3876,9 +4032,10 @@
|
|
|
3876
4032
|
};
|
|
3877
4033
|
KwikIDFormViewComponent.prototype.takeAction = function (action, object) {
|
|
3878
4034
|
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
|
-
|
|
3881
|
-
|
|
4035
|
+
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;
|
|
4036
|
+
var _j;
|
|
4037
|
+
return __generator(this, function (_k) {
|
|
4038
|
+
switch (_k.label) {
|
|
3882
4039
|
case 0:
|
|
3883
4040
|
_h = action.key;
|
|
3884
4041
|
switch (_h) {
|
|
@@ -3896,52 +4053,54 @@
|
|
|
3896
4053
|
case EActionKey.SET_DROPDOWN_OPTIONS: return [3 /*break*/, 14];
|
|
3897
4054
|
case EActionKey.HANDLE_CONNECTED_ELEMENTS: return [3 /*break*/, 19];
|
|
3898
4055
|
case EActionKey.CUSTOM: return [3 /*break*/, 20];
|
|
4056
|
+
case EActionKey.API_CALL: return [3 /*break*/, 21];
|
|
4057
|
+
case EActionKey.API_CALL_END: return [3 /*break*/, 23];
|
|
3899
4058
|
}
|
|
3900
|
-
return [3 /*break*/,
|
|
4059
|
+
return [3 /*break*/, 24];
|
|
3901
4060
|
case 1:
|
|
3902
4061
|
this.fieldHide(action.props.fieldKey);
|
|
3903
|
-
return [3 /*break*/,
|
|
4062
|
+
return [3 /*break*/, 25];
|
|
3904
4063
|
case 2:
|
|
3905
4064
|
this.fieldShow(action.props.fieldKey);
|
|
3906
|
-
return [3 /*break*/,
|
|
4065
|
+
return [3 /*break*/, 25];
|
|
3907
4066
|
case 3:
|
|
3908
4067
|
this.fieldDisable(action.props.fieldKey);
|
|
3909
|
-
return [3 /*break*/,
|
|
4068
|
+
return [3 /*break*/, 25];
|
|
3910
4069
|
case 4:
|
|
3911
4070
|
this.fieldEnable(action.props.fieldKey);
|
|
3912
|
-
return [3 /*break*/,
|
|
4071
|
+
return [3 /*break*/, 25];
|
|
3913
4072
|
case 5:
|
|
3914
4073
|
this.fieldReset(action.props.fieldKey);
|
|
3915
|
-
return [3 /*break*/,
|
|
4074
|
+
return [3 /*break*/, 25];
|
|
3916
4075
|
case 6:
|
|
3917
4076
|
this.fieldErrorShow(action.props.fieldKey, action.props.message);
|
|
3918
|
-
return [3 /*break*/,
|
|
4077
|
+
return [3 /*break*/, 25];
|
|
3919
4078
|
case 7:
|
|
3920
4079
|
this.fieldErrorHide(action.props.fieldKey, action.props.message);
|
|
3921
|
-
return [3 /*break*/,
|
|
4080
|
+
return [3 /*break*/, 25];
|
|
3922
4081
|
case 8:
|
|
3923
4082
|
this.fieldMessageShow(action.props.fieldKey, action.props.message);
|
|
3924
|
-
return [3 /*break*/,
|
|
4083
|
+
return [3 /*break*/, 25];
|
|
3925
4084
|
case 9:
|
|
3926
4085
|
this.fieldMessageHide(action.props.fieldKey, action.props.message);
|
|
3927
|
-
return [3 /*break*/,
|
|
4086
|
+
return [3 /*break*/, 25];
|
|
3928
4087
|
case 10:
|
|
3929
4088
|
setValue_Source = new kwikidToolkit.Source(object);
|
|
3930
4089
|
return [4 /*yield*/, setValue_Source.getValueFromSource(action.props.value.source)];
|
|
3931
4090
|
case 11:
|
|
3932
|
-
sourceValue =
|
|
4091
|
+
sourceValue = _k.sent();
|
|
3933
4092
|
setValue_Source.setValueToSource(action.props.value.destination, sourceValue);
|
|
3934
4093
|
object.FIELD_CONFIG = setValue_Source.object.FIELD_CONFIG;
|
|
3935
4094
|
this.formData = setValue_Source.object.FORM_DATA;
|
|
3936
4095
|
this.patchFormGroup(this.formData);
|
|
3937
4096
|
this.allFormsData = setValue_Source.object.ALL_FORMS_DATA;
|
|
3938
4097
|
this.previousFormData = setValue_Source.object.PREVIOUS_FORM_DATA;
|
|
3939
|
-
return [3 /*break*/,
|
|
4098
|
+
return [3 /*break*/, 25];
|
|
3940
4099
|
case 12:
|
|
3941
4100
|
setDefaultValue_Source = new kwikidToolkit.Source(object);
|
|
3942
4101
|
return [4 /*yield*/, setDefaultValue_Source.getValueFromSource(action.props.value.source)];
|
|
3943
4102
|
case 13:
|
|
3944
|
-
sourceDefaultValue =
|
|
4103
|
+
sourceDefaultValue = _k.sent();
|
|
3945
4104
|
destinationDefaultValue_FieldConfig_Config = {
|
|
3946
4105
|
key: kwikidToolkit.ESourceKey.OBJECT,
|
|
3947
4106
|
props: {
|
|
@@ -3969,17 +4128,17 @@
|
|
|
3969
4128
|
this.allFormsData = setDefaultValue_Source.object.ALL_FORMS_DATA;
|
|
3970
4129
|
this.previousFormData =
|
|
3971
4130
|
setDefaultValue_Source.object.PREVIOUS_FORM_DATA;
|
|
3972
|
-
return [3 /*break*/,
|
|
4131
|
+
return [3 /*break*/, 25];
|
|
3973
4132
|
case 14:
|
|
3974
4133
|
setDropdownValue_Sources = new kwikidToolkit.Source(object);
|
|
3975
4134
|
return [4 /*yield*/, setDropdownValue_Sources.getValueFromSource(action.props.value.source)];
|
|
3976
4135
|
case 15:
|
|
3977
|
-
dropdownValue =
|
|
4136
|
+
dropdownValue = _k.sent();
|
|
3978
4137
|
if (!kwikidToolkit.checkObjectKeyExists(action.props, "options")) return [3 /*break*/, 18];
|
|
3979
4138
|
if (!kwikidToolkit.checkObjectKeyExists(action.props.options, "appendToPath")) return [3 /*break*/, 17];
|
|
3980
4139
|
return [4 /*yield*/, setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source)];
|
|
3981
4140
|
case 16:
|
|
3982
|
-
appendToPath =
|
|
4141
|
+
appendToPath = _k.sent();
|
|
3983
4142
|
if (kwikidToolkit.isNotEmptyValue(appendToPath)) {
|
|
3984
4143
|
appendToPathStr = kwikidToolkit.replaceString(appendToPath.match("" + action.props.options.appendToPath.filterSourceValue)[0], "[^a-zA-Z0-9_]", "_");
|
|
3985
4144
|
optionsPath = "" + action.props.options.path + appendToPathStr;
|
|
@@ -3988,7 +4147,7 @@
|
|
|
3988
4147
|
return [3 /*break*/, 18];
|
|
3989
4148
|
case 17:
|
|
3990
4149
|
dropdownValue = kwikidToolkit.getObjectValueFromPath(dropdownValue, action.props.options.path);
|
|
3991
|
-
|
|
4150
|
+
_k.label = 18;
|
|
3992
4151
|
case 18:
|
|
3993
4152
|
setDropdownValue_Sources.setValueToSource(action.props.value.destination, dropdownValue);
|
|
3994
4153
|
object.FIELD_CONFIG = setDropdownValue_Sources.object.FIELD_CONFIG;
|
|
@@ -3996,13 +4155,34 @@
|
|
|
3996
4155
|
this.allFormsData = setDropdownValue_Sources.object.ALL_FORMS_DATA;
|
|
3997
4156
|
this.previousFormData =
|
|
3998
4157
|
setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
|
|
3999
|
-
return [3 /*break*/,
|
|
4158
|
+
return [3 /*break*/, 25];
|
|
4000
4159
|
case 19:
|
|
4001
4160
|
this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
|
|
4002
|
-
return [3 /*break*/,
|
|
4003
|
-
case 20: return [3 /*break*/,
|
|
4004
|
-
case 21:
|
|
4005
|
-
|
|
4161
|
+
return [3 /*break*/, 25];
|
|
4162
|
+
case 20: return [3 /*break*/, 25];
|
|
4163
|
+
case 21:
|
|
4164
|
+
entrypointKey_1 = action.props.apiKey;
|
|
4165
|
+
apiField = getFormFieldByKey(this.formFields, action.props.fieldKey);
|
|
4166
|
+
endpoints = apiField.api.endpoints;
|
|
4167
|
+
nextApiIndex = endpoints.findIndex(function (api) { return api.apiKey == entrypointKey_1; });
|
|
4168
|
+
return [4 /*yield*/, this.handleApiCall(apiField, endpoints[nextApiIndex])];
|
|
4169
|
+
case 22:
|
|
4170
|
+
response = _k.sent();
|
|
4171
|
+
apiField = response.field;
|
|
4172
|
+
apiField.api.endpoints[nextApiIndex] = response.api;
|
|
4173
|
+
return [3 /*break*/, 25];
|
|
4174
|
+
case 23:
|
|
4175
|
+
field = getFormFieldByKey(this.formFields, action.props.fieldKey);
|
|
4176
|
+
apiCallResponses_1 = {};
|
|
4177
|
+
field.api.endpoints.map(function (api) {
|
|
4178
|
+
if (kwikidToolkit.checkObjectKeyExists(api.response, "value"))
|
|
4179
|
+
apiCallResponses_1 = kwikidToolkit.setMissingKeyValue(apiCallResponses_1, api.apiKey, api.response.value);
|
|
4180
|
+
});
|
|
4181
|
+
this.formData = Object.assign(Object.assign({}, this.formData), (_j = {}, _j[field.key] = apiCallResponses_1, _j));
|
|
4182
|
+
this.patchFormGroup(this.formData);
|
|
4183
|
+
return [3 /*break*/, 25];
|
|
4184
|
+
case 24: return [3 /*break*/, 25];
|
|
4185
|
+
case 25: return [2 /*return*/];
|
|
4006
4186
|
}
|
|
4007
4187
|
});
|
|
4008
4188
|
});
|
|
@@ -4053,6 +4233,9 @@
|
|
|
4053
4233
|
__decorate([
|
|
4054
4234
|
kwikidToolkit.logMethod
|
|
4055
4235
|
], KwikIDFormViewComponent.prototype, "handleOnClickResetFormFields", null);
|
|
4236
|
+
__decorate([
|
|
4237
|
+
kwikidToolkit.logMethod
|
|
4238
|
+
], KwikIDFormViewComponent.prototype, "handleApiCall", null);
|
|
4056
4239
|
__decorate([
|
|
4057
4240
|
kwikidToolkit.logMethod
|
|
4058
4241
|
], KwikIDFormViewComponent.prototype, "handleOnClickApiCall", null);
|
|
@@ -4104,9 +4287,6 @@
|
|
|
4104
4287
|
__decorate([
|
|
4105
4288
|
kwikidToolkit.logMethod
|
|
4106
4289
|
], KwikIDFormViewComponent.prototype, "fieldMessageHide", null);
|
|
4107
|
-
__decorate([
|
|
4108
|
-
kwikidToolkit.logMethod
|
|
4109
|
-
], KwikIDFormViewComponent.prototype, "setObjectValue", null);
|
|
4110
4290
|
__decorate([
|
|
4111
4291
|
kwikidToolkit.logMethod
|
|
4112
4292
|
], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
|
|
@@ -4158,7 +4338,7 @@
|
|
|
4158
4338
|
type: i0.Output
|
|
4159
4339
|
}], onClickApiCall: [{
|
|
4160
4340
|
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: [],
|
|
4341
|
+
}], 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
4342
|
|
|
4163
4343
|
/**
|
|
4164
4344
|
* Generated class for the SafeHtmlPipe pipe.
|