impaktapps-ui-builder 0.0.409-j → 0.0.409-k

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,10 +1,9 @@
1
1
  import { handlersProps } from "./interface";
2
- export declare const executeEvents: (params: handlersProps) => any;
3
- export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
4
- export declare function executeRefreshHandler(params: handlersProps): Promise<any[][]>;
5
- export declare function executeApiRequest(params: any): any;
6
- export declare function shouldEventExecute(params: handlersProps): any;
7
- export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): {
2
+ export declare const executeEvents: (params: handlersProps) => Promise<any>;
3
+ export declare function executeRefreshHandler(params: handlersProps): Promise<void>;
4
+ export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): Promise<{
8
5
  body: any;
9
6
  headers: any;
10
- };
7
+ }>;
8
+ export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
9
+ export declare function asyncOperation(): Promise<unknown>;
@@ -1,19 +1,18 @@
1
+ export declare const extractEvents: (eventConfig: any) => any;
1
2
  interface funcParamsProps {
2
3
  store: any;
3
4
  dynamicData: any;
5
+ config: any;
6
+ uiSchema: any;
7
+ schema: any;
4
8
  service: any;
5
9
  userValue: any;
6
- functionsProvider?: Record<string, any>;
7
10
  }
8
- export declare const extractEvents: (eventConfig: any) => any;
9
11
  declare const _default: (funcParams: funcParamsProps) => {
10
12
  setPage: () => Promise<void>;
11
- onCellRenderer: (cellParams: any) => {};
12
- onClick: () => void;
13
- onMount: () => void;
14
- onFileDownload: () => void;
15
- onFileUpload: () => void;
16
- backHandler: () => void;
13
+ onClick: () => Promise<void>;
14
+ onFileDownload: () => Promise<void>;
15
+ onFileUpload: () => Promise<void>;
17
16
  onPaginationChange: (paginationValues: any) => Promise<any>;
18
17
  getSelectOptions: (param: any) => Promise<any>;
19
18
  onChange: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.409j",
3
+ "version": "0.0.409k",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -316,7 +316,53 @@ const buildUiSchema = (config: any) => {
316
316
  sizeMap[e.keyName] = e.value
317
317
  });
318
318
  }
319
- elements.elements = transformConfigToOutput(config, sizeMap)
319
+ function nodeProvider(element) {
320
+ if (element.type) {
321
+ return {
322
+ accessorKey: element.name,
323
+ type: element.columnFormat,
324
+ header: element.label || element.name,
325
+ size: sizeMap[element.name] || 180,
326
+ widget: buildUiSchema(element)
327
+
328
+ };
329
+ }
330
+ return {
331
+ accessorKey: element.name,
332
+ type: element.columnFormat,
333
+ header: element.label || element.name,
334
+ size: sizeMap[element.name] || 180,
335
+ }
336
+ }
337
+
338
+ function buildHierarchy(elements, parentName = null) {
339
+ const result = [];
340
+ for (const element of elements) {
341
+ if (element?.parent === parentName) {
342
+ const children = buildHierarchy(elements, element.name);
343
+ const node: any = nodeProvider(element)
344
+ if (children.length > 0) {
345
+ node.columns = children;
346
+ node.type = "group";
347
+ }
348
+ result.push(node);
349
+ }
350
+ }
351
+ return result;
352
+ }
353
+
354
+ function transformConfigToOutput(config) {
355
+ const output = [];
356
+ const hierarchy = buildHierarchy(config.elements, config.name);
357
+ for (const element of config.elements) {
358
+ const parentExists = config.elements.some(e => e.name === element.parent);
359
+ if (!parentExists && element.parent !== config.name) {
360
+ output.push(nodeProvider(element))
361
+ }
362
+ }
363
+ return [ ...hierarchy,...output,];
364
+ }
365
+ elements.elements = transformConfigToOutput(config)
320
366
  }
321
367
  else if (config.type == "Array") {
322
368
  elements.options.detail.elements = config.elements.map((e: any, elemInd: number) => {
@@ -1,5 +1,5 @@
1
1
  import _ from "lodash";
2
- import { ComponentSchema } from "../elements/UiSchema/Component/schema";
2
+ import { ComponentSchema } from "../elements/UiSchema/Component/schema";
3
3
  import { componentBasicUiSchema } from "../elements/UiSchema/Component/uiSchema";
4
4
  import { CoreSection } from "../build/uischema/coreSection";
5
5
  import { EventSection } from "../build/uischema/eventSection";
@@ -10,57 +10,57 @@ import { ValueTab } from "../build/uischema/valueTab";
10
10
  import { ValidationSection } from "../build/uischema/validationSections";
11
11
  import { getFormdataFromLocalStorage, okHandler, saveFormdataInLocalStorage, saveHandler } from "./utils";
12
12
  const sectionLabels = {
13
- Select: ["Core", "Properties","Value", "style", "Event","Validation"],
14
- MultipleSelect: ["Core", "Properties","Value", "style", "Event","Validation"],
15
- Table: ["Core", "Components", "Properties","style", "Event","Validation"],
16
- LeaderBoard: ["Core", "Components", "Properties", "style", "Event","Validation"],
17
- WrapperSection: ["Core", "Components","Properties", "style","Validation"],
18
- TabSection: ["Core", "Components", "Properties", "style","Validation"],
19
- SpeedoMeter:["Core", "Properties", "style", "Event","Validation"],
20
- card:["Core", "Properties", "style", "Event","Validation"],
21
- UploadFile:["Core", "style", "Event","Validation"],
22
- Graph:["Core", "Properties", "style", "Event","Validation"],
23
- DownloadFile:["Core", "style", "Event","Validation"],
24
- Box: ["Core", "style", "Event","Validation"],
25
- Properties: ["Core", "Properties", "style", "Event","Validation"],
26
- ProgressBarCard: ["Core", "Properties", "style", "Event","Validation"],
27
- RankCard: ["Core", "Properties", "style", "Event","Validation"],
28
- Slider: ["Core", "Components", "style", "Event","Validation"],
29
- Timer: ["Core", "style", "Event","Validation"],
30
- Rank: ["Core","style", "Event","Validation"],
31
- Button: ["Core", "Properties", "style", "Event","Validation"],
32
- Array:["Core","Components","Validation"],
33
- Radio:["Core", "Properties", "style", "Event","Validation"],
34
- Text:["Core","Properties","style", "Event","Validation"],
35
- TextArea:["Core","Properties","style", "Event","Validation"],
36
- PopUp: ["Core", "Components","Properties", "style"],
37
- Stepper: ["Core", "Components","Properties","Event", "style"],
38
- DataGrid: ["Core", "Components","Properties","Event", "style"],
39
- InputSlider:["Core","Properties","style", "Event","Validation"],
40
- TreeMap:["Core", "Components","Properties","style", "Event"],
13
+ Select: ["Core", "Properties", "Value", "Event", "Style", "Validation"],
14
+ MultipleSelect: ["Core", "Properties", "Value", "Event", "Style", "Validation"],
15
+ Table: ["Core", "Components", "Properties", "Event", "Style", "Validation"],
16
+ LeaderBoard: ["Core", "Components", "Properties", "Event", "Style", "Validation"],
17
+ WrapperSection: ["Core", "Components", "Properties", "Style", "Validation"],
18
+ TabSection: ["Core", "Components", "Properties", "Style", "Validation"],
19
+ SpeedoMeter: ["Core", "Properties", "Event", "Style", "Validation"],
20
+ card: ["Core", "Properties", "Event", "Style", "Validation"],
21
+ UploadFile: ["Core", "Event", "Style", "Validation"],
22
+ Graph: ["Core", "Properties", "Event", "Style", "Validation"],
23
+ DownloadFile: ["Core", "Event", "Style", "Validation"],
24
+ Box: ["Core", "Event", "Style", "Validation"],
25
+ Properties: ["Core", "Properties", "Event", "Style", "Validation"],
26
+ ProgressBarCard: ["Core", "Properties", "Event", "Style", "Validation"],
27
+ RankCard: ["Core", "Properties", "Event", "Style", "Validation"],
28
+ Slider: ["Core", "Components", "Event", "Style", "Validation"],
29
+ Timer: ["Core", "Event", "Style", "Validation"],
30
+ Rank: ["Core", "Event", "Style", "Validation"],
31
+ Button: ["Core", "Properties", "Event", "Style", "Validation"],
32
+ Array: ["Core", "Components", "Validation"],
33
+ Radio: ["Core", "Properties", "Event", "Style", "Validation"],
34
+ Text: ["Core", "Properties", "Event", "Style", "Validation"],
35
+ TextArea: ["Core", "Properties", "Event", "Style", "Validation"],
36
+ PopUp: ["Core", "Components", "Properties", "Style"],
37
+ Stepper: ["Core", "Components", "Properties", "Event", "Style"],
38
+ DataGrid: ["Core", "Components", "Properties", "Event", "Style"],
39
+ InputSlider: ["Core", "Properties", "Event", "Style", "Validation"],
40
+ TreeMap: ["Core", "Components", "Properties", "Event", "Style",],
41
41
  }
42
42
 
43
43
 
44
44
 
45
- export const refreshPage = (type:string,store:any) => {
45
+ export const refreshPage = (type: string, store: any) => {
46
46
  const UiSchema = _.cloneDeep(componentBasicUiSchema)
47
- if(type){
48
- const sectionUiSchema = {
49
- Core: CoreSection,
50
- Value: ValueTab,
51
- style: StyleSection,
52
- Event: EventSection,
53
- Components: TableSection,
54
- Properties: buildPropertiesSection(type),
55
- Validation:ValidationSection
56
-
47
+ if (type) {
48
+ const sectionUiSchema = {
49
+ Core: CoreSection,
50
+ Value: ValueTab,
51
+ Style: StyleSection,
52
+ Event: EventSection,
53
+ Components: TableSection,
54
+ Properties: buildPropertiesSection(type),
55
+ Validation: ValidationSection
56
+
57
+ }
58
+ const elements = sectionLabels[type]?.map(e => sectionUiSchema[e]);
59
+ UiSchema.elements[1].config.main.tabLabels = sectionLabels[type] || ["Core", "style", "Event", "Validation"];
60
+ UiSchema.elements[1].elements = elements || [CoreSection, StyleSection, EventSection, ValidationSection];
61
+
57
62
  }
58
- const elements = sectionLabels[type]?.map(e => sectionUiSchema[e]);
59
- UiSchema.elements[1].config.main.tabLabels = sectionLabels[type] || ["Core", "style","Event","Validation"];
60
- UiSchema.elements[1].elements = elements || [CoreSection, StyleSection,EventSection,ValidationSection];
61
-
62
- }
63
- store.setUiSchema(UiSchema);
63
+ store.setUiSchema(UiSchema);
64
64
  }
65
65
 
66
66
  export default (store: any, dynamicData: any, submitHandler: any, service: any) => {
@@ -69,26 +69,26 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
69
69
  const formdata = await this.getFormdata();
70
70
  store.setFormdata(formdata);
71
71
  const schema = this.getSchema();
72
- store.setSchema(schema);
73
- this.refreshPage(formdata?.type, store);
74
-
72
+ store.setSchema(schema);
73
+ this.refreshPage(formdata?.type, store);
74
+
75
75
  },
76
- refreshPage:refreshPage,
76
+ refreshPage: refreshPage,
77
77
  getFormdata: function () {
78
78
  const path = store.searchParams?.get("path");
79
- return getFormdataFromLocalStorage(path)
79
+ return getFormdataFromLocalStorage(path)
80
80
  },
81
81
  getSchema: function () {
82
82
  return ComponentSchema;
83
83
  },
84
- okHandler:()=>okHandler(store),
85
- saveHandler: async ()=> await saveHandler(store,service,submitHandler,"PageMaster"),
84
+ okHandler: () => okHandler(store),
85
+ saveHandler: async () => await saveHandler(store, service, submitHandler, "PageMaster"),
86
86
  onChange: function () {
87
87
  if (
88
88
  store?.formData?.type !== store?.newData?.type &&
89
89
  store?.newData?.type !== undefined
90
90
  ) {
91
- this.refreshPage(store?.newData?.type,store);
91
+ this.refreshPage(store?.newData?.type, store);
92
92
  }
93
93
  },
94
94
  editComponents: function () {
@@ -1,148 +1,102 @@
1
- import _ from "lodash";
1
+ import _, { cloneDeep } from "lodash";
2
2
  import { handlersProps } from "./interface";
3
3
 
4
- export const executeEvents = (params: handlersProps) => {
4
+
5
+ export const executeEvents = async (
6
+ params: handlersProps
7
+ ) => {
5
8
  let nextEvent = [];
6
9
  let finalResponse = null;
7
-
8
- if (params.config.isSync !== "Yes") {
9
- return shouldEventExecute(params)
10
- .then((shouldExecute) => {
11
- if (!shouldExecute) {
12
- return { response: undefined, events: undefined };
13
- }
14
- return executeEventsHandler(params);
15
- })
16
- .then((response) => {
17
- finalResponse = response;
18
- const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
19
- nextEvent = SuccessEvent;
20
- })
21
- .catch((err) => {
22
- const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
23
- const setEvent = FailEvent?.length > 0 ? FailEvent : [];
24
- nextEvent = setEvent;
25
- })
26
- .then(() => {
27
- if (nextEvent?.length > 0) {
28
- return nextEvent.reduce((chain, actionConfig) => {
29
- return chain.then(() => executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse }));
30
- }, Promise.resolve());
31
- }
32
- })
33
- .then(() => finalResponse)
34
- }
35
- const shouldExecute = shouldEventExecute(params);
36
- if (!shouldExecute) {
37
- return { response: undefined, events: undefined };
38
- }
39
10
  try {
40
- const eventsResponse = executeEventsHandler(params);
41
- finalResponse = eventsResponse;
11
+ const shouldExecute = await shouldEventExecute(params)
12
+ if (!shouldExecute) {
13
+ return { response: undefined, events: undefined };
14
+ }
15
+ const response = await executeEventsHandler(params)
16
+ finalResponse = response;
42
17
  const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
43
18
  nextEvent = SuccessEvent;
44
- } catch {
45
- const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
46
- const setEvent = FailEvent?.length > 0 ? FailEvent : [];
19
+ } catch (err) {
20
+ const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
21
+ const setEvent = FailEvent?.length > 0 ? FailEvent : []
47
22
  nextEvent = setEvent;
48
23
  }
49
24
  if (nextEvent?.length > 0) {
50
25
  for (const actionConfig of nextEvent) {
51
- executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
26
+ await executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
52
27
  }
53
28
  }
54
29
  return finalResponse;
55
30
  }
56
- function executeEventsHandler(params: handlersProps) {
31
+
32
+ async function executeEventsHandler(params: handlersProps) {
57
33
  if (params.config.Handler === "api") {
58
- return executeApiRequest(params);
59
- } else if (params.config.Handler === "inBuiltFunction") {
60
- return executeInBuiltFunctionHandler(params);
61
- } else if (params.config.Handler === "custom") {
62
- return executeCustomHandler(params);
63
- } else if (params.config.Handler === "refresh") {
64
- return executeRefreshHandler(params);
65
- } else if (params.config.Handler === "mergeFormdata") {
66
- return mergeFormdata(
67
- params.parentEventOutput,
68
- params.componentName,
69
- params.config,
70
- params.store,
71
- params.service
72
- );
73
- } else if (params.config.Handler === "onBackHandler") {
74
- return params.store.functionParameters?.handleBack();
75
- } else if (params.config.Handler === "onNextHandler") {
76
- return params.store.functionParameters?.handleNext();
77
- } else if (params.config.Handler === "onResetHandler") {
78
- return params.store.functionParameters?.handleReset();
34
+ return await executeApiEventHandler(params)
35
+ }
36
+ else if (params.config.Handler === "inBuiltFunction") {
37
+ return await executeInBuiltFunctionHandler(params)
38
+ }
39
+ else if (params.config.Handler === "custom") {
40
+ return await executeCustomHandler(params)
41
+ }
42
+ else if (params.config.Handler === "refresh") {
43
+ return await executeRefreshHandler(params)
44
+ }
45
+ else if (params.config.Handler === "mergeFormdata") {
46
+ const result = await mergeFormdata(
47
+ params.parentEventOutput, params.componentName, params.config, params.store, params.service)
48
+ return result;
49
+ }
50
+ else if (params.config.Handler === "onBackHandler") {
51
+ return params.store.functionParameters?.handleBack()
52
+ }
53
+ else if (params.config.Handler === "onNextHandler") {
54
+ return params.store.functionParameters?.handleNext()
55
+ }
56
+ else if (params.config.Handler === "onResetHandler") {
57
+ return params.store.functionParameters?.handleReset()
79
58
  }
80
59
  }
81
-
82
- export function getRefreshElements(eventConfig: any, eventGropus: any) {
83
- let result: string[] = [];
84
- if (eventConfig?.refreshElements?.length > 0) {
85
- result = eventConfig.refreshElements.map((e) => {
86
- return e.value
87
- })
88
-
89
- } else {
90
- if (eventGropus?.onLoad) {
91
- result = Object.keys(eventGropus?.onLoad)
92
- result.push(result[0]);
60
+ export async function executeRefreshHandler(params: handlersProps) {
61
+ const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
62
+ for (const componentName of compToRefresh) {
63
+ for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
64
+ await executeEvents({ ...params, config: compEventConfig, componentName });
93
65
  }
94
66
  }
95
- return result;
96
67
  }
97
- export function executeRefreshHandler(params: handlersProps) {
98
- const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
99
-
100
- return Promise.all(compToRefresh.map(componentName => {
101
- return Promise.all(params.eventGroups.onLoad[componentName].map(compEventConfig => {
102
- return executeEvents({ ...params, config: compEventConfig, componentName });
103
- }));
104
- }))
105
- };
106
- export function executeApiRequest(params: any) {
68
+ async function executeApiEventHandler(params: handlersProps) {
107
69
  const initialBody = { ...params.userValue?.payload };
108
70
  const initialHeaders = {
109
71
  "X-Requested-With": "XMLHttpRequest",
110
72
  "Access-Control-Allow-Origin": "*"
111
73
  };
74
+ const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
112
75
 
113
- const payloadApi = buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
114
- return params.service[params.config.method](
76
+ const response = await params.service[params.config.method](
115
77
  params.config.path,
116
- payloadApi.body,
117
- { headers: payloadApi.headers }
118
- ).then((response) => {
119
- return response;
120
- });
121
- };
78
+ body,
79
+ headers && { headers: headers }
80
+ );
81
+ return response;
82
+ }
122
83
 
123
- function executeInBuiltFunctionHandler(params: handlersProps) {
84
+ async function executeInBuiltFunctionHandler(params: handlersProps) {
124
85
  let parameter = {};
125
86
  if (params.config.funcParametersCode) {
126
87
  const makeFunc = eval(params.config.funcParametersCode)
127
88
  parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
128
- params.serviceHolder[params.config.inBuiltFunctionType](parameter, params.service)
129
- } else {
130
- params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service)
131
89
  }
90
+ params.serviceHolder[params.config.inBuiltFunctionType](parameter)
132
91
  }
133
92
 
134
- function executeCustomHandler(params: handlersProps) {
93
+ async function executeCustomHandler(params: handlersProps) {
135
94
  const makeFunc = eval(params.config.eventCode)
136
- if (params.config.isSync !== "Yes") {
137
- makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName).then((res) => res)
138
- } else {
139
- const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
140
- return response;
141
- }
142
-
95
+ const response = await makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName);
96
+ return response;
143
97
  }
144
98
 
145
- function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
99
+ async function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
146
100
  if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
147
101
  store.setSchema((pre) => {
148
102
  return {
@@ -177,13 +131,14 @@ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig:
177
131
  }
178
132
  else {
179
133
  if (handlerResponse) {
180
- store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse?.data?.data : handlerResponse.data } });
134
+ store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse.data.data : handlerResponse.data } });
135
+ const demoData = await asyncOperation();
181
136
  }
182
137
  }
183
138
  }
184
139
 
185
140
  const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
186
- let finalBody = { ...userValue?.payload };
141
+ const finalBody = { ...userValue?.payload };
187
142
  body.map((elem) => {
188
143
  if (typeof elem?.value !== "string") {
189
144
  finalBody[elem.key] = elem.value;
@@ -195,12 +150,7 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
195
150
  else if (elem?.value?.startsWith("$")) {
196
151
  const finalpath = elem.value.substring(1);
197
152
  finalBody[elem.key] = _.get(formData, finalpath);;
198
- } else if (elem?.value === "*" && elem?.key === "*") {
199
- finalBody = { ...finalBody, ...formData };
200
- } else if (elem?.value === "*") {
201
- finalBody[elem.key] = formData;
202
- }
203
- else {
153
+ } else {
204
154
  finalBody[elem.key] = elem.value;
205
155
  }
206
156
  }
@@ -219,40 +169,58 @@ const buildHeadersFormat = (headers: any[]) => {
219
169
  return headerObj;
220
170
  }
221
171
 
222
- export function shouldEventExecute(params: handlersProps) {
172
+ async function shouldEventExecute(params: handlersProps) {
223
173
  const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
224
-
225
174
  if (startEvent?.length > 0) {
226
- return executeEventsHandler({ ...params, config: startEvent[0] }).then((response) => {
227
- return response;
228
- });
175
+ const response = await executeEventsHandler({ ...params, config: startEvent[0] });
176
+ return response;
229
177
  } else {
230
- if (params.config.isSync !== "Yes") {
231
- return Promise.resolve(true)
232
- } else {
233
- return true
234
- }
178
+ return true
235
179
  }
236
180
  }
237
181
 
238
-
239
- export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
182
+ export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
240
183
  if (compConfig?.headers) {
241
- headers = buildHeadersFormat(compConfig.headers);
242
- }
184
+ headers = buildHeadersFormat(compConfig.headers)
243
185
 
186
+ }
244
187
  if (compConfig.body) {
245
188
  body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
246
189
  }
247
-
248
- const promiseChain = { body, headers };
249
-
250
-
251
190
  if (compConfig.apiBody) {
252
191
  const makeFunc = eval(compConfig.apiBody);
253
- return { body: makeFunc(store, dynamicData, userValue, promiseChain.body), headers: promiseChain.headers };
254
- // return result;
192
+ const data = await makeFunc(store, dynamicData, userValue, body);
193
+ body = data
194
+ }
195
+ return { body, headers };
196
+ }
197
+
198
+ export function getRefreshElements(eventConfig: any, eventGropus: any) {
199
+ let result: string[] = [];
200
+ if (eventConfig?.refreshElements?.length > 0) {
201
+ result = eventConfig.refreshElements.map((e) => {
202
+ return e.value
203
+ })
255
204
 
205
+ } else {
206
+ if (eventGropus?.onLoad) {
207
+ result = Object.keys(eventGropus?.onLoad)
208
+ result.push(result[0]);
209
+ }
256
210
  }
257
- return promiseChain;
211
+ console.log(result);
212
+ return result;
213
+ }
214
+
215
+
216
+ export function asyncOperation() {
217
+ return new Promise((resolve, reject) => {
218
+ setTimeout(() => {
219
+ const success = true;
220
+ if (success) {
221
+ resolve("Operation completed successfully!");
222
+ reject(new Error("Operation failed!"));
223
+ }
224
+ }, 50);
225
+ });
258
226
  }